hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4a476194d27d7bd99313a779d1b55d4b8614fd3e | 1,337 | h | C | tests/juliet/testcases/CWE690_NULL_Deref_From_Return/s01/CWE690_NULL_Deref_From_Return__int64_t_malloc_83.h | RanerL/analyzer | a401da4680f163201326881802ee535d6cf97f5a | [
"MIT"
] | 28 | 2017-01-20T15:25:54.000Z | 2020-03-17T00:28:31.000Z | testcases/CWE690_NULL_Deref_From_Return/s01/CWE690_NULL_Deref_From_Return__int64_t_malloc_83.h | mellowCS/cwe_checker_juliet_suite | ae604f6fd94964251fbe88ef04d5287f6c1ffbe2 | [
"MIT"
] | 1 | 2017-01-20T15:26:27.000Z | 2018-08-20T00:55:37.000Z | testcases/CWE690_NULL_Deref_From_Return/s01/CWE690_NULL_Deref_From_Return__int64_t_malloc_83.h | mellowCS/cwe_checker_juliet_suite | ae604f6fd94964251fbe88ef04d5287f6c1ffbe2 | [
"MIT"
] | 2 | 2019-07-15T19:07:04.000Z | 2019-09-07T14:21:04.000Z | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE690_NULL_Deref_From_Return__int64_t_malloc_83.h
Label Definition File: CWE690_NULL_Deref_From_Return.free.label.xml
Template File: source-sinks-83.tmpl.h
*/
/*
* @description
* CWE: 690 Unchecked Return Value To NULL Pointer
* BadSource: malloc Allocate data using malloc()
* Sinks:
* GoodSink: Check to see if the data allocation failed and if not, use data
* BadSink : Don't check for NULL and use data
* Flow Variant: 83 Data flow: data passed to class constructor and destructor by declaring the class object on the stack
*
* */
#include "std_testcase.h"
#include <wchar.h>
namespace CWE690_NULL_Deref_From_Return__int64_t_malloc_83
{
#ifndef OMITBAD
class CWE690_NULL_Deref_From_Return__int64_t_malloc_83_bad
{
public:
CWE690_NULL_Deref_From_Return__int64_t_malloc_83_bad(int64_t * dataCopy);
~CWE690_NULL_Deref_From_Return__int64_t_malloc_83_bad();
private:
int64_t * data;
};
#endif /* OMITBAD */
#ifndef OMITGOOD
class CWE690_NULL_Deref_From_Return__int64_t_malloc_83_goodB2G
{
public:
CWE690_NULL_Deref_From_Return__int64_t_malloc_83_goodB2G(int64_t * dataCopy);
~CWE690_NULL_Deref_From_Return__int64_t_malloc_83_goodB2G();
private:
int64_t * data;
};
#endif /* OMITGOOD */
}
| 25.226415 | 122 | 0.756171 |
cc85a18b042487e63c726df537eca62bd04ce664 | 4,295 | h | C | src/plugins/blogique/plugins/hestia/localblogaccount.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | 1 | 2017-01-12T07:05:45.000Z | 2017-01-12T07:05:45.000Z | src/plugins/blogique/plugins/hestia/localblogaccount.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | null | null | null | src/plugins/blogique/plugins/hestia/localblogaccount.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | null | null | null | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2010-2012 Oleg Linkin
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#pragma once
#include <QObject>
#include <interfaces/blogique/iaccount.h>
namespace LeechCraft
{
namespace Blogique
{
namespace Hestia
{
class AccountStorage;
class AccountConfigurationWidget;
class LocalBloggingPlatform;
class LocalBlogAccount : public QObject
, public IAccount
{
Q_OBJECT
Q_INTERFACES (LeechCraft::Blogique::IAccount)
LocalBloggingPlatform *ParentBloggingPlatform_;
QString Name_;
bool IsValid_;
QString DatabasePath_;
AccountStorage *AccountStorage_;
QAction *LoadAllEvents_;
const int DefaultPostsNumber_;
public:
LocalBlogAccount (const QString& name, QObject *parent = 0);
QObject* GetQObject ();
QObject* GetParentBloggingPlatform () const;
QString GetAccountName () const;
QString GetOurLogin () const;
void RenameAccount (const QString& name);
QByteArray GetAccountID () const;
void OpenConfigurationDialog ();
bool IsValid () const;
QObject* GetProfile ();
void RemoveEntry (const Entry& entry);
void UpdateEntry (const Entry& entry);
QList<QAction*> GetUpdateActions () const;
void RequestLastEntries (int count = 0);
void RequestStatistics ();
void RequestTags ();
void GetEntriesByDate (const QDate& date);
void GetEntriesWithFilter (const Filter& filter);
void RequestRecentComments ();
void AddComment (const CommentEntry& comment);
void DeleteComment (qint64 id, bool deleteThread = false);
QHash<QString, int> GetTags () const;
void FillSettings (AccountConfigurationWidget *widget);
void Init ();
QByteArray Serialize () const;
static LocalBlogAccount* Deserialize (const QByteArray& data, QObject *parent);
private:
void Validate ();
public slots:
void updateProfile ();
void submit (const Entry& event);
void preview (const Entry& event);
void handleLoadAllEvents ();
signals:
void accountRenamed (const QString& newName);
void accountSettingsChanged ();
void accountValidated (bool validated);
void requestEntriesBegin ();
void entryPosted (const QList<Entry>& entries);
void entryRemoved (int itemId);
void entryUpdated (const QList<Entry>& entries);
void gotEntries (const QList<Entry>& entries);
void gotFilteredEntries(const QList< Entry >& entries);
void gettingFilteredEntriesFinished();
void gotBlogStatistics (const QMap<QDate, int>& statistics);
void tagsUpdated (const QHash<QString, int>& tags);
void gotRecentComments (const QList<CommentEntry>& comments);
void commentsDeleted (const QList<qint64>& comments);
void gotError(int errorCode, const QString& errorString,
const QString& localizedErrorString = QString ());
};
}
}
}
| 32.293233 | 81 | 0.728056 |
78c0a92ec72c0752fce5cecaca6e552eb1a41d74 | 279 | h | C | Tools/DumpRenderTree/mg/EventSender.h | VincentWei/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 6 | 2017-05-31T01:46:45.000Z | 2018-06-12T10:53:30.000Z | Tools/Tools/DumpRenderTree/mg/EventSender.h | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | null | null | null | Tools/Tools/DumpRenderTree/mg/EventSender.h | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 2 | 2017-07-17T06:02:42.000Z | 2018-09-19T10:08:38.000Z |
#ifndef EventSender_h
#define EventSender_h
typedef const struct OpaqueJSContext* JSContextRef;
typedef struct OpaqueJSValue* JSObjectRef;
JSObjectRef makeEventSender(JSContextRef context, bool isTopFrame);
void replaySavedEvents(long* oleDragAndDropReturnValue = 0);
#endif
| 23.25 | 67 | 0.842294 |
00c4114c52c19721cc37ec2253aae944fe5849ae | 299 | h | C | src/views/AboutView.h | Drone-Entertainment-Creators-Japan/RaceingViewer | db72065992c83d56feeca7d792fea6e669e1a23c | [
"MIT"
] | 1 | 2018-12-17T04:15:15.000Z | 2018-12-17T04:15:15.000Z | src/views/AboutView.h | Drone-Entertainment-Creators-Japan/RaceingViewer | db72065992c83d56feeca7d792fea6e669e1a23c | [
"MIT"
] | 1 | 2018-12-14T15:11:49.000Z | 2018-12-18T00:52:19.000Z | src/views/AboutView.h | Drone-Entertainment-Creators-Japan/RaceingViewer | db72065992c83d56feeca7d792fea6e669e1a23c | [
"MIT"
] | null | null | null | #ifndef ABOUTVIEW_H
#define ABOUTVIEW_H
#include <QWidget>
namespace Ui { class AboutView; }
class AboutView : public QWidget
{
Q_OBJECT
public:
explicit AboutView(QWidget *parent = nullptr);
~AboutView(void);
private:
Ui::AboutView* p_ui;
};
#endif /* ABOUTVIEW_H */
| 13.590909 | 50 | 0.675585 |
2e15a14cf69116629691b36b056dc62f67f5651b | 1,344 | h | C | doLib/doCore/Header/doUIContainer.h | bjioswl/do_Timer | 01b4893c92e5f911dc2bdc151f1ae30792c343c3 | [
"MIT"
] | null | null | null | doLib/doCore/Header/doUIContainer.h | bjioswl/do_Timer | 01b4893c92e5f911dc2bdc151f1ae30792c343c3 | [
"MIT"
] | null | null | null | doLib/doCore/Header/doUIContainer.h | bjioswl/do_Timer | 01b4893c92e5f911dc2bdc151f1ae30792c343c3 | [
"MIT"
] | null | null | null | //
// doUIContainerModel.h
// DoFrame
//
// Created by 程序员 on 14/11/25.
// Copyright (c) 2014年 DongXian. All rights reserved.
//
#import "doUIModule.h"
#import "doUIContainer.h"
#import "doSourceFile.h"
@protocol doIPage;
@interface doUIContainer : NSObject
{
@private
NSMutableDictionary * dictUIModuleIDs;
NSString* uniqueKey;
}
#pragma mark -
@property (nonatomic,strong) NSString* ID;
@property (nonatomic,readonly,assign)double DesignWidth;
@property (nonatomic,readonly,assign)double DesignHeight;
@property (assign,nonatomic,readonly)double InnerXZoom;
@property (assign,nonatomic,readonly)double InnerYZoom;
@property (nonatomic,readonly,strong)doUIModule *RootView;
@property (nonatomic,readonly,strong)NSString *UniqueKey;
@property (nonatomic,readonly,strong)id<doIPage> CurrentPage;
#pragma mark -
-(id) init: (id<doIPage>) _page;
#pragma mark -
-(void)RegistChildUIModule:(NSString*) _id :(doUIModule *)_uiModule;
- (void)UnregistChildUIModule:(NSString *)_id;
-(doUIModule *)GetChildUIModuleByID:(NSString *)_uiid;
- (void)LoadFromFile:(doSourceFile *)_uiFile : (NSString*) _x : (NSString*) _y;
- (void)LoadFromContent:(NSString *)_content : (NSString*) _x : (NSString*) _y :(NSString*) _filepath;
- (void) LoadDefalutScriptFile:(NSString *)_filePath;
-(void) Dispose;
@end
| 34.461538 | 103 | 0.730655 |
28caab9fbe7891690860e55189aa7c7bfc7b7a94 | 4,164 | h | C | include/cedar/2d/level_container.h | cedar-framework/cedar | 9fb53ec221738b8dd16dfb31dc9a18d69fc2cc44 | [
"BSD-3-Clause"
] | 9 | 2018-03-07T19:15:27.000Z | 2019-02-22T20:10:23.000Z | include/cedar/2d/level_container.h | cedar-framework/cedar | 9fb53ec221738b8dd16dfb31dc9a18d69fc2cc44 | [
"BSD-3-Clause"
] | 5 | 2018-11-13T19:59:46.000Z | 2020-04-09T19:31:25.000Z | include/cedar/2d/level_container.h | cedar-framework/cedar | 9fb53ec221738b8dd16dfb31dc9a18d69fc2cc44 | [
"BSD-3-Clause"
] | 2 | 2018-07-20T01:06:48.000Z | 2019-11-25T12:15:16.000Z | #ifndef CEDAR_2D_LEVEL_CONTAINER_H
#define CEDAR_2D_LEVEL_CONTAINER_H
#include <vector>
#include <cedar/2d/stencil_op.h>
#include <cedar/services/mempool.h>
namespace cedar { namespace cdr2 {
template<template<class> class level, class fsten, class rsten>
struct get_helper
{
static level<rsten> & get(std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t i);
};
template<template<class> class level, class fsten>
struct get_helper<level, fsten, five_pt>
{
static level<five_pt> & get(std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t i)
{
if (i != 0) log::error << "coarse operators are nine point (not five)!" << std::endl;
#ifdef BOUNDS_CHECK
return lvls_five.at(0);
#else
return lvls_five[0];
#endif
}
};
template<template<class> class level>
struct get_helper<level, five_pt, nine_pt>
{
static level<nine_pt> & get(std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t i)
{
if (i==0) log::error << "fine grid operator is five point (not nine)!" << std::endl;
#ifdef BOUNDS_CHECK
return lvls_nine.at(i - lvls_five.size());
#else
return lvls_nine[i - lvls_five.size()];
#endif
}
};
template<template<class> class level>
struct get_helper<level, nine_pt, nine_pt>
{
static level<nine_pt> & get(std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t i)
{
#ifdef BOUNDS_CHECK
return lvls_nine.at(i);
#else
return lvls_nine[i];
#endif
}
};
template<template<class> class stencil_op, template<class> class level, class sten>
struct init_helper
{
static void init(stencil_op<sten> & fine_op,
std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t nlevels);
};
template<template<class> class stencil_op, template<class> class level>
struct init_helper<stencil_op, level, five_pt>
{
static void init(stencil_op<five_pt> & fine_op,
services::mempool & mpool,
std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t nlevels)
{
lvls_five.emplace_back(mpool, fine_op);
lvls_nine.reserve(nlevels-1);
}
};
template<template<class> class stencil_op, template<class> class level>
struct init_helper<stencil_op, level, nine_pt>
{
static void init(stencil_op<nine_pt> & fine_op,
services::mempool & mpool,
std::vector<level<nine_pt>> & lvls_nine,
std::vector<level<five_pt>> & lvls_five,
std::size_t nlevels)
{
lvls_nine.reserve(nlevels);
lvls_nine.emplace_back(mpool, fine_op);
}
};
template<template<class> class level, class fsten>
class level_container
{
public:
template<class stencil>
using stencil_op = typename level<fsten>::template stencil_op<stencil>;
template<class rsten> using level_t = level<rsten>;
level_container(stencil_op<fsten> & fine_op) : fine_op(fine_op) {}
void init(services::mempool & mpool, std::size_t nlevels)
{
init_helper<stencil_op, level, fsten>::init(fine_op,
mpool,
lvls_nine,
lvls_five,
nlevels);
}
template<class... Args>
void add(Args&&... args) {
lvls_nine.emplace_back(std::forward<Args>(args)...);
}
template<class rsten=nine_pt> level<rsten>& get(std::size_t i)
{
return get_helper<level,fsten, rsten>::get(lvls_nine, lvls_five, i);
}
std::size_t size() { return lvls_nine.size() + lvls_five.size(); }
protected:
stencil_op<fsten> & fine_op;
std::vector<level<nine_pt>> lvls_nine;
std::vector<level<five_pt>> lvls_five;
};
}}
#endif
| 27.946309 | 87 | 0.610471 |
a378a586d6ca46de4bce7f1ddd6f5d69308e4e6c | 838 | h | C | SpatialUnderstanding/Src/PlaySpace/PlaySpaceInfos_Cst_W.h | matthejo/MixedRealityToolkit | c97ace84cfc4cdf97044b35b568bd9182497497a | [
"MIT"
] | 300 | 2017-08-12T12:57:42.000Z | 2019-05-06T00:31:29.000Z | SpatialUnderstanding/Src/PlaySpace/PlaySpaceInfos_Cst_W.h | matthejo/MixedRealityToolkit | c97ace84cfc4cdf97044b35b568bd9182497497a | [
"MIT"
] | 84 | 2017-08-14T11:03:37.000Z | 2019-04-24T22:59:59.000Z | SpatialUnderstanding/Src/PlaySpace/PlaySpaceInfos_Cst_W.h | matthejo/MixedRealityToolkit | c97ace84cfc4cdf97044b35b568bd9182497497a | [
"MIT"
] | 114 | 2017-08-12T03:51:58.000Z | 2019-05-06T03:36:26.000Z | // Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#ifndef __PLAYSPACEINFOS_CST_H__
#define __PLAYSPACEINFOS_CST_H__
#define SHIFT_CACHE_SCANNING_CELL 7
#define SIZE_CACHE_SCANNING_CELL (1<<SHIFT_CACHE_SCANNING_CELL) // exposant de 2
#define MSK_CACHE_SCANNING_CELL (SIZE_CACHE_SCANNING_CELL-1)
#define POS_CACHE_SCANNING_CELL(ix,iy) ((ix & MSK_CACHE_SCANNING_CELL) + ((iy & MSK_CACHE_SCANNING_CELL) << SHIFT_CACHE_SCANNING_CELL))
#define DEFAULT_SIZE_VOXEL 0.08f
#define MARGIN_WALL_DETECT (8.f * DEFAULT_SIZE_VOXEL)
#define WALL_MAX_HEIGHT 1.4f // Hauteur par rapport aux yeux !
#define MARGIN_GROUND_CEILING 0.2f
#define CONEXITY_MAX_SURF 8192
#define CONEXITY_MAX_ZONE 4096
#endif //__PLAYSPACEINFOS_CST_H__
| 33.52 | 136 | 0.803103 |
434d003e673266ef856fd10167ff4d9c879c53a2 | 1,570 | h | C | blades/xbmc/xbmc/music/karaoke/GUIWindowKaraokeLyrics.h | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 4 | 2016-04-26T03:43:54.000Z | 2016-11-17T08:09:04.000Z | blades/xbmc/xbmc/music/karaoke/GUIWindowKaraokeLyrics.h | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 17 | 2015-01-05T21:06:22.000Z | 2015-12-07T20:45:44.000Z | blades/xbmc/xbmc/music/karaoke/GUIWindowKaraokeLyrics.h | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 3 | 2016-04-26T03:43:55.000Z | 2020-11-06T11:02:08.000Z | #pragma once
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "guilib/GUIWindow.h"
class CKaraokeLyrics;
class CKaraokeWindowBackground;
class CGUIWindowKaraokeLyrics : public CGUIWindow
{
public:
CGUIWindowKaraokeLyrics(void);
virtual ~CGUIWindowKaraokeLyrics(void);
virtual bool OnMessage(CGUIMessage& message);
virtual bool OnAction(const CAction &action);
virtual void Render();
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
void newSong( CKaraokeLyrics * lyrics );
void pauseSong( bool now_paused );
void stopSong();
protected:
//! Critical section protects this class from requests from different threads
CCriticalSection m_CritSection;
//! Pointer to karaoke lyrics renderer
CKaraokeLyrics * m_Lyrics;
//! Pointer to background object
CKaraokeWindowBackground * m_Background;
};
| 29.074074 | 81 | 0.73758 |
1a1ed3a5a7939be2a205a9ce2ee22cba90879dcc | 616 | h | C | examples/TextEditor/resource.h | picrap/vaca | 377070c2124bb71649313f6a144c6bd40fdee723 | [
"MIT"
] | null | null | null | examples/TextEditor/resource.h | picrap/vaca | 377070c2124bb71649313f6a144c6bd40fdee723 | [
"MIT"
] | null | null | null | examples/TextEditor/resource.h | picrap/vaca | 377070c2124bb71649313f6a144c6bd40fdee723 | [
"MIT"
] | null | null | null | #include "../resource.h"
#define IDI_VACADOC 1000
#define ID_FILE_NEW 1001
#define ID_FILE_OPEN 1002
#define ID_FILE_SAVE 1003
#define ID_FILE_SAVE_AS 1004
#define ID_FILE_EXIT 1005
#define ID_EDIT_UNDO 1006
#define ID_EDIT_REDO 1007
#define ID_EDIT_CUT 1008
#define ID_EDIT_COPY 1009
#define ID_EDIT_PASTE 1010
#define ID_EDIT_CLEAR 1011
#define ID_EDIT_FIND 1012
#define ID_EDIT_REPLACE 1013
#define ID_OPTIONS_CHANGE_FONT 1014
#define ID_OPTIONS_VIEW_EOL 1015
#define ID_WINDOWS_CLOSE 1016
#define ID_WINDOWS_DUPLICATE 1017
#define ID_WINDOWS_CASCADE 1018
| 26.782609 | 37 | 0.769481 |
1a6c1a8704c2282467ffbef1115348d80170aa7d | 119 | h | C | src/FileLoader.h | Stibius/TerrainGenerator | 9fd5e9cdf26de12f90358d2a16f28e41abc3cc10 | [
"Unlicense"
] | null | null | null | src/FileLoader.h | Stibius/TerrainGenerator | 9fd5e9cdf26de12f90358d2a16f28e41abc3cc10 | [
"Unlicense"
] | null | null | null | src/FileLoader.h | Stibius/TerrainGenerator | 9fd5e9cdf26de12f90358d2a16f28e41abc3cc10 | [
"Unlicense"
] | null | null | null | #pragma once
#include <string>
class FileLoader
{
public:
static std::string loadFile(const std::string& file);
};
| 10.818182 | 54 | 0.714286 |
fa54308c72aac4091f4f969f9f45356e0b96f4b3 | 43,060 | h | C | third_party/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h | ltaoti/openthread | b24192267d56c9a175739d8b2a285bc4b701deaf | [
"BSD-3-Clause"
] | 1 | 2020-02-01T04:33:01.000Z | 2020-02-01T04:33:01.000Z | third_party/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h | ltaoti/openthread | b24192267d56c9a175739d8b2a285bc4b701deaf | [
"BSD-3-Clause"
] | 2 | 2017-03-23T07:47:54.000Z | 2017-08-21T03:12:31.000Z | third_party/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h | ltaoti/openthread | b24192267d56c9a175739d8b2a285bc4b701deaf | [
"BSD-3-Clause"
] | 3 | 2018-03-14T10:33:34.000Z | 2018-09-11T11:04:21.000Z | /******************************************************************************
* Filename: rf_ieee_cmd.h
* Revised: 2017-11-10 10:42:47 +0100 (Fri, 10 Nov 2017)
* Revision: 18052
*
* Description: CC13x2/CC26x2 API for IEEE 802.15.4 commands
*
* Copyright (c) 2015 - 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of the ORGANIZATION nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef __IEEE_CMD_H
#define __IEEE_CMD_H
#ifndef __RFC_STRUCT
#define __RFC_STRUCT
#endif
#ifndef __RFC_STRUCT_ATTR
#if defined(__GNUC__)
#define __RFC_STRUCT_ATTR __attribute__ ((aligned (4)))
#elif defined(__TI_ARM__)
#define __RFC_STRUCT_ATTR __attribute__ ((__packed__,aligned (4)))
#else
#define __RFC_STRUCT_ATTR
#endif
#endif
//! \addtogroup rfc
//! @{
//! \addtogroup ieee_cmd
//! @{
#include <stdint.h>
#include "rf_mailbox.h"
#include "rf_common_cmd.h"
typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_s rfc_CMD_IEEE_RX_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s rfc_CMD_IEEE_ED_SCAN_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_TX_s rfc_CMD_IEEE_TX_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s rfc_CMD_IEEE_CSMA_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s rfc_CMD_IEEE_RX_ACK_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s rfc_CMD_IEEE_ABORT_BG_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s rfc_CMD_IEEE_MOD_CCA_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s rfc_CMD_IEEE_MOD_FILT_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s rfc_CMD_IEEE_MOD_SRC_MATCH_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s rfc_CMD_IEEE_ABORT_FG_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s rfc_CMD_IEEE_STOP_FG_t;
typedef struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s rfc_CMD_IEEE_CCA_REQ_t;
typedef struct __RFC_STRUCT rfc_ieeeRxOutput_s rfc_ieeeRxOutput_t;
typedef struct __RFC_STRUCT rfc_shortAddrEntry_s rfc_shortAddrEntry_t;
typedef struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s rfc_ieeeRxCorrCrc_t;
//! \addtogroup CMD_IEEE_RX
//! @{
#define CMD_IEEE_RX 0x2801
//! IEEE 802.15.4 Receive Command
struct __RFC_STRUCT rfc_CMD_IEEE_RX_s {
uint16_t commandNo; //!< The command ID number 0x2801
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
uint8_t channel; //!< \brief Channel to tune to in the start of the operation<br>
//!< 0: Use existing channel<br>
//!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz<br>
//!< 60--207: Frequency is (2300 + channel) MHz<br>
//!< Others: <i>Reserved</i>
struct {
uint8_t bAutoFlushCrc:1; //!< If 1, automatically remove packets with CRC error from Rx queue
uint8_t bAutoFlushIgn:1; //!< If 1, automatically remove packets that can be ignored according to frame filtering from Rx queue
uint8_t bIncludePhyHdr:1; //!< If 1, include the received PHY header field in the stored packet; otherwise discard it
uint8_t bIncludeCrc:1; //!< If 1, include the received CRC field in the stored packet; otherwise discard it
uint8_t bAppendRssi:1; //!< If 1, append an RSSI byte to the packet in the Rx queue
uint8_t bAppendCorrCrc:1; //!< If 1, append a correlation value and CRC result byte to the packet in the Rx queue
uint8_t bAppendSrcInd:1; //!< If 1, append an index from the source matching algorithm
uint8_t bAppendTimestamp:1; //!< If 1, append a timestamp to the packet in the Rx queue
} rxConfig;
dataQueue_t* pRxQ; //!< Pointer to receive queue
rfc_ieeeRxOutput_t *pOutput; //!< Pointer to output structure (NULL: Do not store results)
struct {
uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering<br>
//!< 1: Enable frame filtering
uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end<br>
//!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected.
uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK<br>
//!< 1: Enable auto ACK.
uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK<br>
//!< 1: Slotted ACK.
uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled<br>
//!< 1: Auto-pend enabled
uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend
uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet<br>
//!< 1: Use auto-pend for data request packets only
uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator<br>
//!< 1: Device is PAN coordinator
uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value
uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
//!< 0: No modification<br>
//!< 1: Invert MSB<br>
//!< 2: Set MSB to 0<br>
//!< 3: Set MSB to 1
uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
//!< 1: Accept only acknowledgement frames of length 5
} frameFiltOpt; //!< Frame filtering options
struct {
uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):<br>
//!< 0: Reject, unless running ACK receive command<br>
//!< 1: Always accept
uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
} frameTypes; //!< Frame types to receive in frame filtering
struct {
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
//!< 0: Always report busy channel if ccaSync is busy<br>
//!< 1: Always report idle channel if ccaSync is idle
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
} ccaOpt; //!< CCA options
int8_t ccaRssiThr; //!< RSSI threshold for CCA
uint8_t __dummy0;
uint8_t numExtEntries; //!< Number of extended address entries
uint8_t numShortEntries; //!< Number of short address entries
uint32_t* pExtEntryList; //!< Pointer to list of extended address entries
uint32_t* pShortEntryList; //!< Pointer to list of short address entries
uint64_t localExtAddr; //!< The extended address of the local device
uint16_t localShortAddr; //!< The short address of the local device
uint16_t localPanID; //!< The PAN ID of the local device
uint16_t __dummy1;
uint8_t __dummy2;
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} endTrigger; //!< Trigger that causes the device to end the Rx operation
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
//!< operation
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_ED_SCAN
//! @{
#define CMD_IEEE_ED_SCAN 0x2802
//! IEEE 802.15.4 Energy Detect Scan Command
struct __RFC_STRUCT rfc_CMD_IEEE_ED_SCAN_s {
uint16_t commandNo; //!< The command ID number 0x2802
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
uint8_t channel; //!< \brief Channel to tune to in the start of the operation<br>
//!< 0: Use existing channel<br>
//!< 11--26: Use as IEEE 802.15.4 channel, i.e. frequency is (2405 + 5 × (channel - 11)) MHz<br>
//!< 60--207: Frequency is (2300 + channel) MHz<br>
//!< Others: <i>Reserved</i>
struct {
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
//!< 0: Always report busy channel if ccaSync is busy<br>
//!< 1: Always report idle channel if ccaSync is idle
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
} ccaOpt; //!< CCA options
int8_t ccaRssiThr; //!< RSSI threshold for CCA
uint8_t __dummy0;
int8_t maxRssi; //!< The maximum RSSI recorded during the ED scan
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} endTrigger; //!< Trigger that causes the device to end the Rx operation
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the Rx
//!< operation
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_TX
//! @{
#define CMD_IEEE_TX 0x2C01
//! IEEE 802.15.4 Transmit Command
struct __RFC_STRUCT rfc_CMD_IEEE_TX_s {
uint16_t commandNo; //!< The command ID number 0x2C01
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
struct {
uint8_t bIncludePhyHdr:1; //!< \brief 0: Find PHY header automatically<br>
//!< 1: Insert PHY header from the buffer
uint8_t bIncludeCrc:1; //!< \brief 0: Append automatically calculated CRC<br>
//!< 1: Insert FCS (CRC) from the buffer
uint8_t :1;
uint8_t payloadLenMsb:5; //!< \brief Most significant bits of payload length. Should only be non-zero to create long
//!< non-standard packets for test purposes
} txOpt;
uint8_t payloadLen; //!< Number of bytes in the payload
uint8_t* pPayload; //!< Pointer to payload buffer of size <code>payloadLen</code>
ratmr_t timeStamp; //!< Time stamp of transmitted frame
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_CSMA
//! @{
#define CMD_IEEE_CSMA 0x2C02
//! IEEE 802.15.4 CSMA-CA Command
struct __RFC_STRUCT rfc_CMD_IEEE_CSMA_s {
uint16_t commandNo; //!< The command ID number 0x2C02
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
uint16_t randomState; //!< The state of the pseudo-random generator
uint8_t macMaxBE; //!< The IEEE 802.15.4 MAC parameter <i>macMaxBE</i>
uint8_t macMaxCSMABackoffs; //!< The IEEE 802.15.4 MAC parameter <i>macMaxCSMABackoffs</i>
struct {
uint8_t initCW:5; //!< The initialization value for the CW parameter
uint8_t bSlotted:1; //!< \brief 0: non-slotted CSMA<br>
//!< 1: slotted CSMA
uint8_t rxOffMode:2; //!< \brief 0: RX stays on during CSMA backoffs<br>
//!< 1: The CSMA-CA algorithm will suspend the receiver if no frame is being received<br>
//!< 2: The CSMA-CA algorithm will suspend the receiver if no frame is being received,
//!< or after finishing it (including auto ACK) otherwise<br>
//!< 3: The CSMA-CA algorithm will suspend the receiver immediately during back-offs
} csmaConfig;
uint8_t NB; //!< The NB parameter from the IEEE 802.15.4 CSMA-CA algorithm
uint8_t BE; //!< The BE parameter from the IEEE 802.15.4 CSMA-CA algorithm
uint8_t remainingPeriods; //!< The number of remaining periods from a paused backoff countdown
int8_t lastRssi; //!< RSSI measured at the last CCA operation
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} endTrigger; //!< Trigger that causes the device to end the CSMA-CA operation
ratmr_t lastTimeStamp; //!< Time of the last CCA operation
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to end the
//!< CSMA-CA operation
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_RX_ACK
//! @{
#define CMD_IEEE_RX_ACK 0x2C03
//! IEEE 802.15.4 Receive Acknowledgement Command
struct __RFC_STRUCT rfc_CMD_IEEE_RX_ACK_s {
uint16_t commandNo; //!< The command ID number 0x2C03
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
uint8_t seqNo; //!< Sequence number to expect
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} endTrigger; //!< Trigger that causes the device to give up acknowledgement reception
ratmr_t endTime; //!< \brief Time used together with <code>endTrigger</code> that causes the device to give up
//!< acknowledgement reception
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_ABORT_BG
//! @{
#define CMD_IEEE_ABORT_BG 0x2C04
//! IEEE 802.15.4 Abort Background Level Command
struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_BG_s {
uint16_t commandNo; //!< The command ID number 0x2C04
uint16_t status; //!< \brief An integer telling the status of the command. This value is
//!< updated by the radio CPU during operation and may be read by the
//!< system CPU at any time.
rfc_radioOp_t *pNextOp; //!< Pointer to the next operation to run after this operation is done
ratmr_t startTime; //!< Absolute or relative start time (depending on the value of <code>startTrigger</code>)
struct {
uint8_t triggerType:4; //!< The type of trigger
uint8_t bEnaCmd:1; //!< \brief 0: No alternative trigger command<br>
//!< 1: CMD_TRIGGER can be used as an alternative trigger
uint8_t triggerNo:2; //!< The trigger number of the CMD_TRIGGER command that triggers this action
uint8_t pastTrig:1; //!< \brief 0: A trigger in the past is never triggered, or for start of commands, give an error<br>
//!< 1: A trigger in the past is triggered as soon as possible
} startTrigger; //!< Identification of the trigger that starts the operation
struct {
uint8_t rule:4; //!< Condition for running next command: Rule for how to proceed
uint8_t nSkip:4; //!< Number of skips + 1 if the rule involves skipping. 0: same, 1: next, 2: skip next, ...
} condition;
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_MOD_CCA
//! @{
#define CMD_IEEE_MOD_CCA 0x2001
//! IEEE 802.15.4 Modify CCA Parameter Command
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_CCA_s {
uint16_t commandNo; //!< The command ID number 0x2001
struct {
uint8_t ccaEnEnergy:1; //!< Enable energy scan as CCA source
uint8_t ccaEnCorr:1; //!< Enable correlator based carrier sense as CCA source
uint8_t ccaEnSync:1; //!< Enable sync found based carrier sense as CCA source
uint8_t ccaCorrOp:1; //!< \brief Operator to use between energy based and correlator based CCA<br>
//!< 0: Report busy channel if either ccaEnergy or ccaCorr are busy<br>
//!< 1: Report busy channel if both ccaEnergy and ccaCorr are busy
uint8_t ccaSyncOp:1; //!< \brief Operator to use between sync found based CCA and the others<br>
//!< 0: Always report busy channel if ccaSync is busy<br>
//!< 1: Always report idle channel if ccaSync is idle
uint8_t ccaCorrThr:2; //!< Threshold for number of correlation peaks in correlator based carrier sense
} newCcaOpt; //!< New value of <code>ccaOpt</code> for the running background level operation
int8_t newCcaRssiThr; //!< New value of <code>ccaRssiThr</code> for the running background level operation
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_MOD_FILT
//! @{
#define CMD_IEEE_MOD_FILT 0x2002
//! IEEE 802.15.4 Modify Frame Filtering Parameter Command
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_FILT_s {
uint16_t commandNo; //!< The command ID number 0x2002
struct {
uint16_t frameFiltEn:1; //!< \brief 0: Disable frame filtering<br>
//!< 1: Enable frame filtering
uint16_t frameFiltStop:1; //!< \brief 0: Receive all packets to the end<br>
//!< 1: Stop receiving frame once frame filtering has caused the frame to be rejected.
uint16_t autoAckEn:1; //!< \brief 0: Disable auto ACK<br>
//!< 1: Enable auto ACK.
uint16_t slottedAckEn:1; //!< \brief 0: Non-slotted ACK<br>
//!< 1: Slotted ACK.
uint16_t autoPendEn:1; //!< \brief 0: Auto-pend disabled<br>
//!< 1: Auto-pend enabled
uint16_t defaultPend:1; //!< The value of the pending data bit in auto ACK packets that are not subject to auto-pend
uint16_t bPendDataReqOnly:1; //!< \brief 0: Use auto-pend for any packet<br>
//!< 1: Use auto-pend for data request packets only
uint16_t bPanCoord:1; //!< \brief 0: Device is not PAN coordinator<br>
//!< 1: Device is PAN coordinator
uint16_t maxFrameVersion:2; //!< Reject frames where the frame version field in the FCF is greater than this value
uint16_t fcfReservedMask:3; //!< Value to be AND-ed with the reserved part of the FCF; frame rejected if result is non-zero
uint16_t modifyFtFilter:2; //!< \brief Treatment of MSB of frame type field before frame-type filtering:<br>
//!< 0: No modification<br>
//!< 1: Invert MSB<br>
//!< 2: Set MSB to 0<br>
//!< 3: Set MSB to 1
uint16_t bStrictLenFilter:1; //!< \brief 0: Accept acknowledgement frames of any length >= 5<br>
//!< 1: Accept only acknowledgement frames of length 5
} newFrameFiltOpt; //!< New value of <code>frameFiltOpt</code> for the running background level operation
struct {
uint8_t bAcceptFt0Beacon:1; //!< \brief Treatment of frames with frame type 000 (beacon):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt1Data:1; //!< \brief Treatment of frames with frame type 001 (data):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt2Ack:1; //!< \brief Treatment of frames with frame type 010 (ACK):<br>
//!< 0: Reject, unless running ACK receive command<br>
//!< 1: Always accept
uint8_t bAcceptFt3MacCmd:1; //!< \brief Treatment of frames with frame type 011 (MAC command):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt4Reserved:1; //!< \brief Treatment of frames with frame type 100 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt5Reserved:1; //!< \brief Treatment of frames with frame type 101 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt6Reserved:1; //!< \brief Treatment of frames with frame type 110 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
uint8_t bAcceptFt7Reserved:1; //!< \brief Treatment of frames with frame type 111 (reserved):<br>
//!< 0: Reject<br>
//!< 1: Accept
} newFrameTypes; //!< New value of <code>frameTypes</code> for the running background level operation
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_MOD_SRC_MATCH
//! @{
#define CMD_IEEE_MOD_SRC_MATCH 0x2003
//! IEEE 802.15.4 Enable/Disable Source Matching Entry Command
struct __RFC_STRUCT rfc_CMD_IEEE_MOD_SRC_MATCH_s {
uint16_t commandNo; //!< The command ID number 0x2003
struct {
uint8_t bEnable:1; //!< \brief 0: Disable entry<br>
//!< 1: Enable entry
uint8_t srcPend:1; //!< New value of the pending bit for the entry
uint8_t entryType:1; //!< \brief 0: Short address<br>
//!< 1: Extended address
} options;
uint8_t entryNo; //!< Index of entry to enable or disable
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_ABORT_FG
//! @{
#define CMD_IEEE_ABORT_FG 0x2401
//! IEEE 802.15.4 Abort Foreground Level Command
struct __RFC_STRUCT rfc_CMD_IEEE_ABORT_FG_s {
uint16_t commandNo; //!< The command ID number 0x2401
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_STOP_FG
//! @{
#define CMD_IEEE_STOP_FG 0x2402
//! IEEE 802.15.4 Gracefully Stop Foreground Level Command
struct __RFC_STRUCT rfc_CMD_IEEE_STOP_FG_s {
uint16_t commandNo; //!< The command ID number 0x2402
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup CMD_IEEE_CCA_REQ
//! @{
#define CMD_IEEE_CCA_REQ 0x2403
//! IEEE 802.15.4 CCA and RSSI Information Request Command
struct __RFC_STRUCT rfc_CMD_IEEE_CCA_REQ_s {
uint16_t commandNo; //!< The command ID number 0x2403
int8_t currentRssi; //!< The RSSI currently observed on the channel
int8_t maxRssi; //!< The maximum RSSI observed on the channel since Rx was started
struct {
uint8_t ccaState:2; //!< \brief Value of the current CCA state<br>
//!< 0: Idle<br>
//!< 1: Busy<br>
//!< 2: Invalid
uint8_t ccaEnergy:2; //!< \brief Value of the current energy detect CCA state<br>
//!< 0: Idle<br>
//!< 1: Busy<br>
//!< 2: Invalid
uint8_t ccaCorr:2; //!< \brief Value of the current correlator based carrier sense CCA state<br>
//!< 0: Idle<br>
//!< 1: Busy<br>
//!< 2: Invalid
uint8_t ccaSync:1; //!< \brief Value of the current sync found based carrier sense CCA state<br>
//!< 0: Idle<br>
//!< 1: Busy
} ccaInfo;
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup ieeeRxOutput
//! @{
//! Output structure for CMD_IEEE_RX
struct __RFC_STRUCT rfc_ieeeRxOutput_s {
uint8_t nTxAck; //!< Total number of transmitted ACK frames
uint8_t nRxBeacon; //!< Number of received beacon frames
uint8_t nRxData; //!< Number of received data frames
uint8_t nRxAck; //!< Number of received acknowledgement frames
uint8_t nRxMacCmd; //!< Number of received MAC command frames
uint8_t nRxReserved; //!< Number of received frames with reserved frame type
uint8_t nRxNok; //!< Number of received frames with CRC error
uint8_t nRxIgnored; //!< Number of frames received that are to be ignored
uint8_t nRxBufFull; //!< Number of received frames discarded because the Rx buffer was full
int8_t lastRssi; //!< RSSI of last received frame
int8_t maxRssi; //!< Highest RSSI observed in the operation
uint8_t __dummy0;
ratmr_t beaconTimeStamp; //!< Time stamp of last received beacon frame
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup shortAddrEntry
//! @{
//! Structure for short address entries
struct __RFC_STRUCT rfc_shortAddrEntry_s {
uint16_t shortAddr; //!< Short address
uint16_t panId; //!< PAN ID
} __RFC_STRUCT_ATTR;
//! @}
//! \addtogroup ieeeRxCorrCrc
//! @{
//! Receive status byte that may be appended to message in receive buffer
struct __RFC_STRUCT rfc_ieeeRxCorrCrc_s {
struct {
uint8_t corr:6; //!< The correlation value
uint8_t bIgnore:1; //!< 1 if the packet should be rejected by frame filtering, 0 otherwise
uint8_t bCrcErr:1; //!< 1 if the packet was received with CRC error, 0 otherwise
} status;
} __RFC_STRUCT_ATTR;
//! @}
//! @}
//! @}
#endif
| 68.45787 | 149 | 0.527891 |
cfe08a0ca28f8645abf12c3d2b1d2c213e67c223 | 1,787 | h | C | Euro-IOS/Classes/EuroManager.h | visilabs/Euro-IOS | 12259f5bbdc5a4c1d37019550c3f26e82cf3f4d7 | [
"MIT"
] | 18 | 2020-03-02T12:27:43.000Z | 2022-03-05T15:56:49.000Z | Euro-IOS/Classes/EuroManager.h | visilabs/Euro-IOS | 12259f5bbdc5a4c1d37019550c3f26e82cf3f4d7 | [
"MIT"
] | 1 | 2020-06-08T13:42:10.000Z | 2020-06-12T07:36:33.000Z | Euro-IOS/Classes/EuroManager.h | visilabs/Euro-IOS | 12259f5bbdc5a4c1d37019550c3f26e82cf3f4d7 | [
"MIT"
] | 1 | 2020-08-20T15:50:29.000Z | 2020-08-20T15:50:29.000Z | //
// EuroManager.m
// EuroPush
//
// Created by Ozan Uysal on 11/11/14.
// Copyright (c) 2014 Appcent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <UserNotifications/UNNotificationContent.h>
#import "EMMessage.h"
#import "EMTools.h"
#define SDK_VERSION @"1.9.12"
@interface EuroManager : NSObject <UNUserNotificationCenterDelegate>
+ (EuroManager *)sharedManager:(NSString *) applicationKey;
+ (EuroManager *)sharedManager:(NSString *) applicationKey launchOptions:(NSDictionary*)launchOptions;
+ (NSString*)applicationKey;
+ (NSDictionary*)userInfo;
- (void) reportVisilabs: (NSString *) visiUrl;
- (void) setDebug:(BOOL) enable;
- (void) setUserEmail:(NSString *) email;
- (void) setUserKey:(NSString *) userKey;
- (void) setTwitterId:(NSString *) twitterId;
- (void) setFacebookId:(NSString *) facebookId;
- (void) setPhoneNumber:(NSString *) msisdn;
- (void) setAppVersion:(NSString *) appVersion;
- (void) setAdvertisingIdentifier:(NSString *) adIdentifier;
- (void) setUserLatitude:(double) lat andLongitude:(double) lon;
- (void) removeUserParameters;
- (void) addParams:(NSString *) key value:(id) value;
- (void) registerToken:(NSData *) tokenData;
- (void) handlePush:(NSDictionary *) pushDictionary;
- (void) registerForPush;
- (void) synchronize;
+ (void) didReceive:(UNMutableNotificationContent*) bestAttemptContent withContentHandler:(void (^_Nullable)(UNNotificationContent* _Nonnull contentToDeliver))contentHandler API_AVAILABLE(ios(10.0));
- (void) registerEmail:(NSString *) email emailPermit:(BOOL) emailPermit isCommercial:(BOOL) isCommercial success:(void (^_Nullable)(void)) success failure:(void (^_Nullable)(NSString *errorMessage)) failure;
@end
| 33.716981 | 208 | 0.750979 |
9a713753b85c8772f27c5e22dd0c7edc3a055828 | 370 | h | C | src/ackermannization/lackr_model_converter_lazy.h | jar-ben/z3 | 7baa4f88b0cb4458461596d147e1f71853d77126 | [
"MIT"
] | 7,746 | 2015-03-26T18:59:33.000Z | 2022-03-31T15:34:48.000Z | src/ackermannization/lackr_model_converter_lazy.h | jar-ben/z3 | 7baa4f88b0cb4458461596d147e1f71853d77126 | [
"MIT"
] | 5,162 | 2015-03-27T01:12:48.000Z | 2022-03-31T14:56:16.000Z | src/ackermannization/lackr_model_converter_lazy.h | jar-ben/z3 | 7baa4f88b0cb4458461596d147e1f71853d77126 | [
"MIT"
] | 1,529 | 2015-03-26T18:45:30.000Z | 2022-03-31T15:35:16.000Z | /*++
Copyright (c) 2015 Microsoft Corporation
Module Name:
lackr_model_converter_lazy.h
Abstract:
Author:
Mikolas Janota
Revision History:
--*/
#pragma once
#include "tactic/model_converter.h"
#include "ackermannization/ackr_info.h"
model_converter * mk_lackr_model_converter_lazy(ast_manager & m, const ackr_info_ref& info, model_ref& abstr_model);
| 15.416667 | 116 | 0.764865 |
89c0acf0c742be42bba7ff210ddec62dd02e323a | 1,070 | h | C | System/Library/PrivateFrameworks/HomeKitDaemon.framework/HMDUserActionPredictionModel.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 5 | 2021-04-29T04:31:43.000Z | 2021-08-19T18:59:58.000Z | System/Library/PrivateFrameworks/HomeKitDaemon.framework/HMDUserActionPredictionModel.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/HomeKitDaemon.framework/HMDUserActionPredictionModel.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 1 | 2022-03-19T11:16:23.000Z | 2022-03-19T11:16:23.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Wednesday, April 28, 2021 at 9:09:13 PM Mountain Standard Time
* Operating System: Version 14.5 (Build 18L204)
* Image Source: /System/Library/PrivateFrameworks/HomeKitDaemon.framework/HomeKitDaemon
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <HomeKitBackingStore/HMBModel.h>
@class NSUUID, NSNumber;
@interface HMDUserActionPredictionModel : HMBModel
@property (copy) NSUUID * predictionTargetUUID;
@property (copy) NSUUID * targetServiceUUID;
@property (copy) NSUUID * targetServiceGroupUUID;
@property (copy) NSUUID * targetGroupUUID;
@property (copy) NSNumber * type;
@property (copy) NSNumber * groupType;
@property (copy) NSNumber * predictionScore;
+(id)hmbProperties;
+(BOOL)hmbExcludeFromCloudStorage;
-(id)userActionPrediction;
-(id)initWithUserActionPrediction:(id)arg1 ;
@end
| 38.214286 | 130 | 0.676636 |
d61bc9b03b821ed4ed61de5eeb73cebb968ceeb9 | 52 | h | C | netbsdsrc/sys/arch/sun3x/stand/libsa/clock.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | netbsdsrc/sys/arch/sun3x/stand/libsa/clock.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | netbsdsrc/sys/arch/sun3x/stand/libsa/clock.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z |
extern int hz;
time_t getsecs();
int getticks();
| 7.428571 | 17 | 0.673077 |
96756ba89faf18cc83aa613249ab8a205569884f | 5,491 | c | C | lib/qrtr.c | Venji10/qrtr | 096f148ba45a157719dcd211b43201e8d3911796 | [
"BSD-3-Clause"
] | 8 | 2017-04-30T10:06:50.000Z | 2021-08-21T17:46:21.000Z | lib/qrtr.c | Venji10/qrtr | 096f148ba45a157719dcd211b43201e8d3911796 | [
"BSD-3-Clause"
] | 9 | 2016-06-05T23:22:07.000Z | 2022-02-23T00:04:56.000Z | lib/qrtr.c | Venji10/qrtr | 096f148ba45a157719dcd211b43201e8d3911796 | [
"BSD-3-Clause"
] | 15 | 2016-06-03T16:56:31.000Z | 2022-01-29T02:02:10.000Z | #include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <linux/qrtr.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <poll.h>
#include "libqrtr.h"
#include "logging.h"
#include "ns.h"
static int qrtr_getname(int sock, struct sockaddr_qrtr *sq)
{
socklen_t sl = sizeof(*sq);
int rc;
rc = getsockname(sock, (void *)sq, &sl);
if (rc) {
PLOGE("getsockname()");
return -1;
}
if (sq->sq_family != AF_QIPCRTR || sl != sizeof(*sq))
return -1;
return 0;
}
int qrtr_open(int rport)
{
struct timeval tv;
int sock;
int rc;
sock = socket(AF_QIPCRTR, SOCK_DGRAM, 0);
if (sock < 0) {
PLOGE("socket(AF_QIPCRTR)");
return -1;
}
tv.tv_sec = 1;
tv.tv_usec = 0;
rc = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
if (rc) {
PLOGE("setsockopt(SO_RCVTIMEO)");
goto err;
}
if (rport != 0) {
struct sockaddr_qrtr sq = {};
sq.sq_family = AF_QIPCRTR;
sq.sq_node = 1;
sq.sq_port = rport;
rc = bind(sock, (void *)&sq, sizeof(sq));
if (rc < 0) {
PLOGE("bind(%d)", rport);
goto err;
}
}
return sock;
err:
close(sock);
return -1;
}
void qrtr_close(int sock)
{
close(sock);
}
int qrtr_sendto(int sock, uint32_t node, uint32_t port, const void *data, unsigned int sz)
{
struct sockaddr_qrtr sq = {};
int rc;
sq.sq_family = AF_QIPCRTR;
sq.sq_node = node;
sq.sq_port = port;
rc = sendto(sock, data, sz, 0, (void *)&sq, sizeof(sq));
if (rc < 0) {
PLOGE("sendto()");
return -1;
}
return 0;
}
int qrtr_new_server(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
struct qrtr_ctrl_pkt pkt;
struct sockaddr_qrtr sq;
if (qrtr_getname(sock, &sq))
return -1;
memset(&pkt, 0, sizeof(pkt));
pkt.cmd = cpu_to_le32(QRTR_TYPE_NEW_SERVER);
pkt.server.service = cpu_to_le32(service);
pkt.server.instance = cpu_to_le32(instance << 8 | version);
return qrtr_sendto(sock, sq.sq_node, QRTR_PORT_CTRL, &pkt, sizeof(pkt));
}
int qrtr_remove_server(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
struct qrtr_ctrl_pkt pkt;
struct sockaddr_qrtr sq;
if (qrtr_getname(sock, &sq))
return -1;
memset(&pkt, 0, sizeof(pkt));
pkt.cmd = cpu_to_le32(QRTR_TYPE_DEL_SERVER);
pkt.server.service = cpu_to_le32(service);
pkt.server.instance = cpu_to_le32(instance << 8 | version);
pkt.server.node = cpu_to_le32(sq.sq_node);
pkt.server.port = cpu_to_le32(sq.sq_port);
return qrtr_sendto(sock, sq.sq_node, QRTR_PORT_CTRL, &pkt, sizeof(pkt));
}
int qrtr_publish(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
return qrtr_new_server(sock, service, version, instance);
}
int qrtr_bye(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
return qrtr_remove_server(sock, service, version, instance);
}
int qrtr_new_lookup(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
struct qrtr_ctrl_pkt pkt;
struct sockaddr_qrtr sq;
if (qrtr_getname(sock, &sq))
return -1;
memset(&pkt, 0, sizeof(pkt));
pkt.cmd = cpu_to_le32(QRTR_TYPE_NEW_LOOKUP);
pkt.server.service = cpu_to_le32(service);
pkt.server.instance = cpu_to_le32(instance << 8 | version);
return qrtr_sendto(sock, sq.sq_node, QRTR_PORT_CTRL, &pkt, sizeof(pkt));
}
int qrtr_remove_lookup(int sock, uint32_t service, uint16_t version, uint16_t instance)
{
struct qrtr_ctrl_pkt pkt;
struct sockaddr_qrtr sq;
if (qrtr_getname(sock, &sq))
return -1;
memset(&pkt, 0, sizeof(pkt));
pkt.cmd = cpu_to_le32(QRTR_TYPE_DEL_LOOKUP);
pkt.server.service = cpu_to_le32(service);
pkt.server.instance = cpu_to_le32(instance << 8 | version);
pkt.server.node = cpu_to_le32(sq.sq_node);
pkt.server.port = cpu_to_le32(sq.sq_port);
return qrtr_sendto(sock, sq.sq_node, QRTR_PORT_CTRL, &pkt, sizeof(pkt));
}
int qrtr_poll(int sock, unsigned int ms)
{
struct pollfd fds;
fds.fd = sock;
fds.revents = 0;
fds.events = POLLIN | POLLERR;
return poll(&fds, 1, ms);
}
int qrtr_recv(int sock, void *buf, unsigned int bsz)
{
int rc;
rc = recv(sock, buf, bsz, 0);
if (rc < 0)
PLOGE("recv()");
return rc;
}
int qrtr_recvfrom(int sock, void *buf, unsigned int bsz, uint32_t *node, uint32_t *port)
{
struct sockaddr_qrtr sq;
socklen_t sl;
int rc;
sl = sizeof(sq);
rc = recvfrom(sock, buf, bsz, 0, (void *)&sq, &sl);
if (rc < 0) {
PLOGE("recvfrom()");
return rc;
}
if (node)
*node = sq.sq_node;
if (port)
*port = sq.sq_port;
return rc;
}
int qrtr_decode(struct qrtr_packet *dest, void *buf, size_t len,
const struct sockaddr_qrtr *sq)
{
const struct qrtr_ctrl_pkt *ctrl = buf;
if (sq->sq_port == QRTR_PORT_CTRL){
if (len < sizeof(*ctrl))
return -EMSGSIZE;
dest->type = le32_to_cpu(ctrl->cmd);
switch (dest->type) {
case QRTR_TYPE_BYE:
dest->node = le32_to_cpu(ctrl->client.node);
break;
case QRTR_TYPE_DEL_CLIENT:
dest->node = le32_to_cpu(ctrl->client.node);
dest->port = le32_to_cpu(ctrl->client.port);
break;
case QRTR_TYPE_NEW_SERVER:
case QRTR_TYPE_DEL_SERVER:
dest->node = le32_to_cpu(ctrl->server.node);
dest->port = le32_to_cpu(ctrl->server.port);
dest->service = le32_to_cpu(ctrl->server.service);
dest->version = le32_to_cpu(ctrl->server.instance) & 0xff;
dest->instance = le32_to_cpu(ctrl->server.instance) >> 8;
break;
default:
dest->type = 0;
}
} else {
dest->type = QRTR_TYPE_DATA;
dest->node = sq->sq_node;
dest->port = sq->sq_port;
dest->data = buf;
dest->data_len = len;
}
return 0;
}
| 21.200772 | 90 | 0.685667 |
323ca9f928786d86282d8b0f736eeea398f37557 | 778 | c | C | libsploader/header.c | SPLoader/loader | ede8800ed919ec9b3c619ff07e224c5dbee6d22f | [
"MIT"
] | 1 | 2021-11-24T16:43:19.000Z | 2021-11-24T16:43:19.000Z | libsploader/header.c | bringey/SPLoader | ede8800ed919ec9b3c619ff07e224c5dbee6d22f | [
"MIT"
] | null | null | null | libsploader/header.c | bringey/SPLoader | ede8800ed919ec9b3c619ff07e224c5dbee6d22f | [
"MIT"
] | null | null | null | /*
** File: libsploader/header.c
**
** Author: bringey
**
** Contains implementations for all spl_hdr_* functions
*/
#include <sploader.h>
bool spl_hdr_check(SplHeader *header) {
SplHeader copy = *header;
copy.loaderCrc = 0;
copy.headerCrc = 0;
uint32_t crc = spl_crc32(©, sizeof(SplHeader));
return crc == header->headerCrc;
}
bool spl_hdr_checkBin(SplHeader *header, void *binary) {
uint32_t crc = spl_crc32(binary, header->loaderSize);
return crc == header->loaderCrc;
}
#ifndef SPLOADERK
void spl_hdr_setChecksum(SplHeader *header) {
uint32_t tempcrc = header->loaderCrc;
header->headerCrc = 0;
header->loaderCrc = 0;
header->headerCrc = spl_crc32(&header, sizeof(SplHeader));
header->loaderCrc = tempcrc;
}
#endif
| 21.611111 | 62 | 0.690231 |
c5c526709d430b9694d9bcb324e43fbb40113ee6 | 907 | h | C | include/ftw.h | lucvoo/slibc | 2f356f934078425b620b047d6344b85912d219a4 | [
"MIT"
] | 1 | 2018-10-05T14:02:32.000Z | 2018-10-05T14:02:32.000Z | include/ftw.h | lucvoo/slibc | 2f356f934078425b620b047d6344b85912d219a4 | [
"MIT"
] | null | null | null | include/ftw.h | lucvoo/slibc | 2f356f934078425b620b047d6344b85912d219a4 | [
"MIT"
] | null | null | null | #ifndef _FTW_H
#define _FTW_H
#include <sys/stat.h>
#define FTW_F 1 // Regular file
#define FTW_D 4 // Directory
#define FTW_DNR 5 // Directory without read permission
#define FTW_DP 6 // Directory with subdirectories visited
#define FTW_NS 0 // Unknown type; stat() fail
#define FTW_SL 8 // Symbolic link
#define FTW_SLN 9 // Symbolic link to non-existing file
#define FTW_PHYS 1 // do not follow symlink
#define FTW_MOUNT 2 // do not cross a mount point
#define FTW_DEPTH 4 // visit subdirs before itself
#define FTW_CHDIR 8 // change each dir before reading it
struct FTW {
int base;
int level;
};
typedef int (*__ftw_fn_t) (const char *, const struct stat *, int);
typedef int (*__nftw_fn_t) (const char *, const struct stat *, int, struct FTW *);
int ftw(const char *path, __ftw_fn_t fn, int depth);
int nftw(const char *path, __nftw_fn_t fn, int depth, int flags);
#endif
| 29.258065 | 82 | 0.715546 |
d697710b0888e7a42ddb26ea134466b8b648b00c | 6,246 | h | C | cparser/base/parser2d/cunit.h | bajdcc/clibalgserver | 0a464b1657c70244d18345ab8b2a4f222b32c18a | [
"MIT"
] | 12 | 2019-09-25T09:28:40.000Z | 2022-01-24T05:24:35.000Z | cparser/base/parser2d/cunit.h | bajdcc/clibalgserver | 0a464b1657c70244d18345ab8b2a4f222b32c18a | [
"MIT"
] | 3 | 2020-02-22T04:00:36.000Z | 2020-03-19T07:42:03.000Z | cparser/base/parser2d/cunit.h | bajdcc/clibalgserver | 0a464b1657c70244d18345ab8b2a4f222b32c18a | [
"MIT"
] | 2 | 2020-03-06T07:59:28.000Z | 2020-08-17T07:34:48.000Z | //
// Project: clibparser
// Created by CC
//
#ifndef CLIBPARSER_CUNIT_H
#define CLIBPARSER_CUNIT_H
#include <string>
#include <unordered_set>
#include <vector>
#include <map>
#include <bitset>
#include "memory.h"
#define UNIT_NODE_MEM (32 * 1024)
namespace clib {
enum unit_t {
u_none,
u_token,
u_token_ref,
u_rule,
u_rule_ref,
u_sequence,
u_branch,
u_optional,
};
class unit_builder;
struct unit {
unit_t t{ u_none };
unit* next{ nullptr };
unit* prev{ nullptr };
unit_builder* builder{ nullptr };
unit& operator=(const unit& u);
unit& operator+(const unit& u);
unit& operator|(const unit& u);
unit& operator*();
unit& operator~();
unit& init(unit_builder* builder);
unit& set_t(unit_t type);
};
struct unit_token : public unit {
lexer_t type{ l_none };
union {
operator_t op;
keyword_t keyword;
} value;
unit_token& set_type(lexer_t type);
unit_token& set_op(operator_t op);
unit_token& set_keyword(keyword_t keyword);
};
struct unit_collection : public unit {
bool skip{ false };
bool marked{ false };
unit* child{ nullptr };
unit_collection& set_skip(bool skip);
unit_collection& set_marked(bool skip);
unit_collection& set_child(unit* node);
};
struct unit_rule : public unit_collection {
const char* s{ nullptr };
uint32 attr{ 0 };
unit_rule& set_s(const char* str);
unit_rule& set_attr(uint32 attr);
};
struct nga_edge;
struct nga_edge_list;
struct nga_status {
const char* label{ nullptr };
bool final{ false };
nga_edge_list* in{ nullptr }, * out{ nullptr };
};
struct pda_status : public nga_status {
int rule;
};
struct nga_edge {
nga_status* begin{ nullptr }, * end{ nullptr };
bool skip{ false };
bool marked{ false };
unit* data{ nullptr };
};
enum pda_edge_t {
e_shift,
e_pass,
e_move,
e_left_recursion,
e_left_recursion_not_greed,
e_reduce,
e_reduce_exp,
e_finish,
};
struct pda_edge : public nga_edge {
pda_edge_t type{ e_finish };
};
struct nga_edge_list {
nga_edge_list* prev{ nullptr }, * next{ nullptr };
nga_edge* edge{ nullptr };
};
unit_rule* to_rule(unit* u);
unit_token* to_token(unit* u);
unit_collection* to_collection(unit* u);
unit_collection* to_ref(unit* u);
const string_t& pda_edge_str(pda_edge_t type);
const int& pda_edge_priority(pda_edge_t type);
class unit_builder {
public:
virtual unit_collection& append(unit* collection, unit* child) = 0;
virtual unit_collection& merge(unit* a, unit* b) = 0;
virtual unit_collection& collection(unit* a, unit* b, unit_t type) = 0;
virtual unit_collection& optional(unit* a) = 0;
virtual unit* copy(unit* u) = 0;
virtual nga_edge* enga(unit* node, bool init) = 0;
virtual nga_edge* enga(unit* node, unit* u) = 0;
virtual nga_edge* connect(nga_status* a, nga_status* b, bool is_pda = false) = 0;
};
struct nga_rule {
int id;
unit_rule* u;
nga_status* status;
int recursive;
std::unordered_set<unit_token*> tokensList;
std::unordered_set<unit_token*> tokensFirstset;
std::unordered_set<unit_rule*> rulesFirstset;
};
struct pda_trans {
int jump;
pda_edge_t type;
int status;
string_t label;
std::vector<unit*> LA;
bool marked;
};
struct pda_rule {
int id;
int rule;
bool final;
coll_t coll;
string_t label;
std::vector<pda_trans> trans;
};
enum pda_rule_attr {
r_normal = 0,
r_not_greed = 1,
r_exp = 2,
};
// 文法表达式
class cunit : public unit_builder {
public:
cunit() = default;
~cunit() = default;
cunit(const cunit&) = delete;
cunit& operator=(const cunit&) = delete;
unit& token(const lexer_t& type);
unit& token(const operator_t& op);
unit& token(const keyword_t& keyword);
unit& rule(const string_t& s, coll_t t, uint32 attr = 0);
unit_collection& append(unit* collection, unit* child) override;
unit_collection& merge(unit* a, unit* b) override;
unit_collection& collection(unit* a, unit* b, unit_t type) override;
unit_collection& optional(unit* a) override;
unit* copy(unit* u) override;
nga_edge* enga(unit* node, bool init) override;
nga_edge* enga(unit* node, unit* u) override;
nga_edge* connect(nga_status* a, nga_status* b, bool is_pda = false) override;
const std::vector<pda_rule>& get_pda() const;
private:
nga_status* status();
pda_status* status(const char* label, int rule, bool final);
void add_edge(nga_edge_list*& list, nga_edge* edge);
void remove_edge(nga_edge_list*& list, nga_edge_list* edge);
const char* label(unit* focused, bool front);
void label(unit* node, unit* parent, unit* focused, bool front, std::ostream& os);
void disconnect(nga_status* status);
public:
void gen(unit* root);
void dump(std::ostream& os);
private:
void gen_nga();
void check_nga();
void gen_pda(unit* root);
static nga_edge* conv_nga(unit* u);
nga_status* delete_epsilon(nga_edge* edge);
void error(const string_t&);
string_t print_unit(unit*);
private:
const char* str(const string_t& s);
private:
memory_pool<UNIT_NODE_MEM> nodes;
std::unordered_set<std::string> strings;
std::vector<std::string> labels;
std::map<std::string, nga_rule> rules;
std::unordered_map<const char*, coll_t> rulesMap;
std::vector<pda_rule> pdas;
unit_rule* current_rule{ nullptr };
};
};
#endif //CLIBPARSER_CUNIT_H
| 26.243697 | 90 | 0.591258 |
659cebebbbcf7ad9f176dd2274b4e41c2592121c | 155 | h | C | src/Shaders/Include/Shaders.h | zulis/bam | 8d17316dd65fe5404268d94d036ece6bad397407 | [
"MIT"
] | 29 | 2022-02-20T14:03:14.000Z | 2022-03-20T21:59:36.000Z | src/Shaders/Include/Shaders.h | CedricGuillemet/Flooid | 761217e5c0113233893070ca406f56f3ac53ef95 | [
"MIT"
] | 6 | 2022-02-18T23:03:08.000Z | 2022-03-06T04:51:04.000Z | src/Shaders/Include/Shaders.h | CedricGuillemet/Flooid | 761217e5c0113233893070ca406f56f3ac53ef95 | [
"MIT"
] | 5 | 2022-02-20T15:45:55.000Z | 2022-02-25T17:22:02.000Z | #pragma once
#include <bgfx/bgfx.h>
namespace App {
bgfx::ProgramHandle LoadProgram(const char* vertexShaderName, const char* fragmentShaderName);
}
| 19.375 | 98 | 0.76129 |
ca9131146c24357e19cf0b9a2b1fe2ac08b6503e | 433 | h | C | iOSOpenDev/frameworks/DataDetectorsUI.framework/Headers/DDContactUtils.h | bzxy/cydia | f8c838cdbd86e49dddf15792e7aa56e2af80548d | [
"MIT"
] | 678 | 2017-11-17T08:33:19.000Z | 2022-03-26T10:40:20.000Z | iOSOpenDev/frameworks/DataDetectorsUI.framework/Headers/DDContactUtils.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 22 | 2019-04-16T05:51:53.000Z | 2021-11-08T06:18:45.000Z | iOSOpenDev/frameworks/DataDetectorsUI.framework/Headers/DDContactUtils.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 170 | 2018-06-10T07:59:20.000Z | 2022-03-22T16:19:33.000Z | /**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/DataDetectorsUI.framework/DataDetectorsUI
*/
#import <DataDetectorsUI/XXUnknownSuperclass.h>
__attribute__((visibility("hidden")))
@interface DDContactUtils : XXUnknownSuperclass {
}
+ (id)normalizedPhoneNumberFromString:(id)string; // 0xa26d
+ (BOOL)phoneNumber:(id)number isEqualToPhoneNumber:(id)phoneNumber; // 0xa1b9
@end
| 27.0625 | 86 | 0.773672 |
10dc640b92eedaee43188a631d4e5c6b7b651e4d | 93 | c | C | .vim/sourceCode/glibc-2.16.0/sysdeps/ieee754/ldbl-opt/nldbl-gamma.c | lakehui/Vim_config | 6cab80dc1209b34bf6379f42b1a92790bd0c146b | [
"MIT"
] | 47 | 2015-03-10T23:21:52.000Z | 2022-02-17T01:04:14.000Z | include/sysdeps/ieee754/ldbl-opt/nldbl-gamma.c | DalavanCloud/libucresolv | 04a4827aa44c47556f425a4eed5e0ab4a5c0d25a | [
"Apache-2.0"
] | 3 | 2017-10-05T20:52:56.000Z | 2019-02-26T23:05:29.000Z | include/sysdeps/ieee754/ldbl-opt/nldbl-gamma.c | DalavanCloud/libucresolv | 04a4827aa44c47556f425a4eed5e0ab4a5c0d25a | [
"Apache-2.0"
] | 19 | 2015-02-25T19:50:05.000Z | 2021-10-05T14:35:54.000Z | #include "nldbl-compat.h"
double
attribute_hidden
gammal (double x)
{
return gamma (x);
}
| 10.333333 | 25 | 0.709677 |
3403896d361d93dd815685b68bde42f5ce841a44 | 27,908 | h | C | include/ytdl/sig-regex.h | Wykerd/libytdl | a139623eeb97584b2f2d23b0b7023304db9173bb | [
"MIT"
] | 2 | 2021-10-14T10:06:37.000Z | 2021-12-01T15:54:00.000Z | include/ytdl/sig-regex.h | Wykerd/libytdl | a139623eeb97584b2f2d23b0b7023304db9173bb | [
"MIT"
] | null | null | null | include/ytdl/sig-regex.h | Wykerd/libytdl | a139623eeb97584b2f2d23b0b7023304db9173bb | [
"MIT"
] | 1 | 2022-03-22T21:28:05.000Z | 2022-03-22T21:28:05.000Z | /* Compiled RegExp bytecodes */
/* Generated file - do not edit */
const unsigned char action_obj_regexp[] = {
0x00,0x0b,0x02,0x85,0x0f,0x00,0x00,0x08,0x06,0x00,0x00,0x00,0x04,0x07,0xf5,
0xff,0xff,0xff,0x0b,0x00,0x01,0x76,0x00,0x01,0x61,0x00,0x01,0x72,0x00,0x01,
0x20,0x00,0x0b,0x01,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,
0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,
0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,
0x0c,0x01,0x01,0x3d,0x00,0x01,0x7b,0x00,0x0b,0x02,0x09,0xff,0x04,0x00,0x00,
0x09,0x60,0x03,0x00,0x00,0x09,0xb5,0x01,0x00,0x00,0x09,0x3d,0x00,0x00,0x00,
0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,
0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,
0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,0x00,0x00,
0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x03,0x03,
0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x03,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,
0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x03,0x1a,
0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,0x00,0x01,0x22,0x00,
0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,
0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,
0xff,0xff,0x0a,0x0d,0x04,0x04,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x04,0x1c,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,
0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,
0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,
0xff,0xff,0x0a,0x0c,0x04,0x1a,0xb1,0xff,0xff,0xff,0x01,0x22,0x00,0x01,0x3a,
0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,0x63,0x00,0x01,0x74,
0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,0x28,0x00,0x01,0x61,
0x00,0x01,0x29,0x00,0x01,0x7b,0x00,0x1c,0x16,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x72,0x00,0x01,0x65,0x00,
0x01,0x74,0x00,0x01,0x75,0x00,0x01,0x72,0x00,0x01,0x6e,0x00,0x01,0x20,0x00,
0x0a,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x76,
0x00,0x01,0x65,0x00,0x01,0x72,0x00,0x01,0x73,0x00,0x01,0x65,0x00,0x01,0x28,
0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,0xa1,0x01,0x00,0x00,0x09,0x3d,0x00,
0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,
0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,
0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,
0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,
0x05,0x05,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x05,0x1c,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,
0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,
0x05,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,0x00,0x01,
0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0d,0x06,0x06,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,
0x06,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,
0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0c,0x06,0x1a,0xb1,0xff,0xff,0xff,0x01,0x22,0x00,
0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,0x63,0x00,
0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,0x28,0x00,
0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7b,0x00,
0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x74,0x00,0x01,0x75,0x00,0x01,0x72,0x00,
0x01,0x6e,0x00,0x01,0x20,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x73,0x00,
0x01,0x6c,0x00,0x01,0x69,0x00,0x01,0x63,0x00,0x01,0x65,0x00,0x01,0x28,0x00,
0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,0x95,0x01,0x00,0x00,0x09,
0x3d,0x00,0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,
0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,
0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,
0x07,0xfc,0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,
0x0a,0x0d,0x07,0x07,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x07,0x1c,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,
0x0a,0x0c,0x07,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,
0x00,0x01,0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,
0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x08,0x08,0x09,0x4a,0x00,0x00,0x00,
0x19,0x0b,0x08,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,
0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,
0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x08,0x1a,0xb1,0xff,0xff,0xff,0x01,
0x22,0x00,0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,
0x63,0x00,0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,
0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,
0x7b,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x73,0x00,0x01,0x70,0x00,0x01,
0x6c,0x00,0x01,0x69,0x00,0x01,0x63,0x00,0x01,0x65,0x00,0x01,0x28,0x00,0x01,
0x30,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,
0x46,0x02,0x00,0x00,0x09,0x3d,0x00,0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,
0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,
0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,
0x01,0x27,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,
0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x09,0x09,0x09,0x4a,0x00,0x00,0x00,0x19,
0x0b,0x09,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,
0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,
0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x09,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,
0x00,0x07,0x79,0x00,0x00,0x00,0x01,0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x0a,0x0a,
0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x0a,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,
0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x0a,0x1a,
0xb1,0xff,0xff,0xff,0x01,0x22,0x00,0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,
0x00,0x01,0x6e,0x00,0x01,0x63,0x00,0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,
0x00,0x01,0x6e,0x00,0x01,0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,
0x00,0x01,0x29,0x00,0x01,0x7b,0x00,0x01,0x76,0x00,0x01,0x61,0x00,0x01,0x72,
0x00,0x01,0x20,0x00,0x01,0x63,0x00,0x01,0x3d,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x30,0x00,0x01,0x5d,0x00,0x01,0x3b,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x30,0x00,0x01,0x5d,0x00,0x01,0x3d,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x62,0x00,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x25,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,
0x01,0x6c,0x00,0x01,0x65,0x00,0x01,0x6e,0x00,0x01,0x67,0x00,0x01,0x74,0x00,
0x01,0x68,0x00,0x0a,0x01,0x5d,0x00,0x01,0x3b,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x62,0x00,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x25,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,
0x01,0x6c,0x00,0x01,0x65,0x00,0x01,0x6e,0x00,0x01,0x67,0x00,0x01,0x74,0x00,
0x01,0x68,0x00,0x0a,0x01,0x5d,0x00,0x01,0x3d,0x00,0x01,0x63,0x00,0x1c,0x1c,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,
0x01,0x3b,0x00,0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x74,0x00,0x01,0x75,0x00,
0x01,0x72,0x00,0x01,0x6e,0x00,0x01,0x20,0x00,0x01,0x61,0x00,0x0a,0x01,0x7d,
0x00,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x01,0x2c,0x00,0x0a,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x0d,0x00,0x0a,0x1c,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x0a,0x00,0x0a,0x09,0x8f,0x07,0x00,0x00,0x19,0x09,0xff,0x04,0x00,0x00,
0x09,0x60,0x03,0x00,0x00,0x09,0xb5,0x01,0x00,0x00,0x09,0x3d,0x00,0x00,0x00,
0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,
0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,
0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,0x00,0x00,
0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x03,0x03,
0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x03,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,
0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x03,0x1a,
0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,0x00,0x01,0x22,0x00,
0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,
0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,
0xff,0xff,0x0a,0x0d,0x04,0x04,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x04,0x1c,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,
0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,
0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,
0xff,0xff,0x0a,0x0c,0x04,0x1a,0xb1,0xff,0xff,0xff,0x01,0x22,0x00,0x01,0x3a,
0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,0x63,0x00,0x01,0x74,
0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,0x28,0x00,0x01,0x61,
0x00,0x01,0x29,0x00,0x01,0x7b,0x00,0x1c,0x16,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x01,0x72,0x00,0x01,0x65,0x00,
0x01,0x74,0x00,0x01,0x75,0x00,0x01,0x72,0x00,0x01,0x6e,0x00,0x01,0x20,0x00,
0x0a,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x76,
0x00,0x01,0x65,0x00,0x01,0x72,0x00,0x01,0x73,0x00,0x01,0x65,0x00,0x01,0x28,
0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,0xa1,0x01,0x00,0x00,0x09,0x3d,0x00,
0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,
0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,
0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,
0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,
0x05,0x05,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x05,0x1c,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,
0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,
0x05,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,0x00,0x01,
0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0d,0x06,0x06,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,
0x06,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,
0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0c,0x06,0x1a,0xb1,0xff,0xff,0xff,0x01,0x22,0x00,
0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,0x63,0x00,
0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,0x28,0x00,
0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7b,0x00,
0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x74,0x00,0x01,0x75,0x00,0x01,0x72,0x00,
0x01,0x6e,0x00,0x01,0x20,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x73,0x00,
0x01,0x6c,0x00,0x01,0x69,0x00,0x01,0x63,0x00,0x01,0x65,0x00,0x01,0x28,0x00,
0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,0x95,0x01,0x00,0x00,0x09,
0x3d,0x00,0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,
0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,
0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,
0x07,0xfc,0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,
0x0a,0x0d,0x07,0x07,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x07,0x1c,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,
0x0a,0x0c,0x07,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,
0x00,0x01,0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,
0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x08,0x08,0x09,0x4a,0x00,0x00,0x00,
0x19,0x0b,0x08,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,
0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,
0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x08,0x1a,0xb1,0xff,0xff,0xff,0x01,
0x22,0x00,0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,
0x63,0x00,0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x01,
0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,
0x7b,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x73,0x00,0x01,0x70,0x00,0x01,
0x6c,0x00,0x01,0x69,0x00,0x01,0x63,0x00,0x01,0x65,0x00,0x01,0x28,0x00,0x01,
0x30,0x00,0x01,0x2c,0x00,0x01,0x62,0x00,0x01,0x29,0x00,0x01,0x7d,0x00,0x07,
0x46,0x02,0x00,0x00,0x09,0x3d,0x00,0x00,0x00,0x15,0x04,0x00,0x24,0x00,0x24,
0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,
0x61,0x00,0x7a,0x00,0x0a,0x07,0xfc,0x00,0x00,0x00,0x09,0x7e,0x00,0x00,0x00,
0x01,0x27,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,
0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x09,0x09,0x09,0x4a,0x00,0x00,0x00,0x19,
0x0b,0x09,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,
0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,
0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x09,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,
0x00,0x07,0x79,0x00,0x00,0x00,0x01,0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x0a,0x0a,
0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x0a,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,
0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,
0x00,0x21,0x00,0x23,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x0a,0x1a,
0xb1,0xff,0xff,0xff,0x01,0x22,0x00,0x01,0x3a,0x00,0x01,0x66,0x00,0x01,0x75,
0x00,0x01,0x6e,0x00,0x01,0x63,0x00,0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,
0x00,0x01,0x6e,0x00,0x01,0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,0x01,0x62,
0x00,0x01,0x29,0x00,0x01,0x7b,0x00,0x01,0x76,0x00,0x01,0x61,0x00,0x01,0x72,
0x00,0x01,0x20,0x00,0x01,0x63,0x00,0x01,0x3d,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x30,0x00,0x01,0x5d,0x00,0x01,0x3b,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x30,0x00,0x01,0x5d,0x00,0x01,0x3d,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x62,0x00,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x25,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,
0x01,0x6c,0x00,0x01,0x65,0x00,0x01,0x6e,0x00,0x01,0x67,0x00,0x01,0x74,0x00,
0x01,0x68,0x00,0x0a,0x01,0x5d,0x00,0x01,0x3b,0x00,0x01,0x61,0x00,0x01,0x5b,
0x00,0x01,0x62,0x00,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x09,0x00,0x00,0x00,0x01,0x25,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,
0x01,0x6c,0x00,0x01,0x65,0x00,0x01,0x6e,0x00,0x01,0x67,0x00,0x01,0x74,0x00,
0x01,0x68,0x00,0x0a,0x01,0x5d,0x00,0x01,0x3d,0x00,0x01,0x63,0x00,0x1c,0x1c,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,
0x01,0x3b,0x00,0x01,0x72,0x00,0x01,0x65,0x00,0x01,0x74,0x00,0x01,0x75,0x00,
0x01,0x72,0x00,0x01,0x6e,0x00,0x01,0x20,0x00,0x01,0x61,0x00,0x0a,0x01,0x7d,
0x00,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x01,0x2c,0x00,0x0a,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x0d,0x00,0x0a,0x1c,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x0a,0x00,0x0a,0x1a,0x6c,0xf8,0xff,0xff,0x0c,0x02,0x01,0x7d,0x00,0x01,
0x3b,0x00,0x0c,0x00,0x0a
};
const unsigned char action_func_regexp[] = {
0x00,0x04,0x02,0xbe,0x04,0x00,0x00,0x08,0x06,0x00,0x00,0x00,0x04,0x07,0xf5,
0xff,0xff,0xff,0x0b,0x00,0x01,0x66,0x00,0x01,0x75,0x00,0x01,0x6e,0x00,0x01,
0x63,0x00,0x01,0x74,0x00,0x01,0x69,0x00,0x01,0x6f,0x00,0x01,0x6e,0x00,0x09,
0x3b,0x00,0x00,0x00,0x01,0x20,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,
0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,
0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,
0x7a,0x00,0x0a,0x01,0x28,0x00,0x01,0x61,0x00,0x01,0x29,0x00,0x01,0x7b,0x00,
0x01,0x61,0x00,0x01,0x3d,0x00,0x01,0x61,0x00,0x01,0x2e,0x00,0x01,0x73,0x00,
0x01,0x70,0x00,0x01,0x6c,0x00,0x01,0x69,0x00,0x01,0x74,0x00,0x01,0x28,0x00,
0x09,0x0b,0x00,0x00,0x00,0x01,0x27,0x00,0x01,0x27,0x00,0x07,0x06,0x00,0x00,
0x00,0x01,0x22,0x00,0x01,0x22,0x00,0x01,0x29,0x00,0x01,0x3b,0x00,0x1c,0x2c,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,
0x15,0x0a,0x00,0x09,0x00,0x0d,0x00,0x20,0x00,0x20,0x00,0xa0,0x00,0xa0,0x00,
0x80,0x16,0x80,0x16,0x00,0x20,0x0a,0x20,0x28,0x20,0x29,0x20,0x2f,0x20,0x2f,
0x20,0x5f,0x20,0x5f,0x20,0x00,0x30,0x00,0x30,0xff,0xfe,0xff,0xfe,0x0a,0x0b,
0x01,0x1c,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x01,0x61,0x00,0x01,0x3d,0x00,0x0a,0x15,0x04,0x00,0x24,0x00,
0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,
0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,
0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,
0x00,0x61,0x00,0x7a,0x00,0x0a,0x09,0x40,0x00,0x00,0x00,0x01,0x2e,0x00,0x15,
0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,
0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,
0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0x02,0x01,0x00,0x00,
0x01,0x5b,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,
0x02,0x02,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x02,0x1c,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,
0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,
0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,
0x02,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,0x00,0x00,0x01,
0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0d,0x03,0x03,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,
0x03,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,
0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,0x00,0x5b,0x00,
0x5d,0x00,0xff,0xff,0x0a,0x0c,0x03,0x1a,0xb1,0xff,0xff,0xff,0x01,0x22,0x00,
0x01,0x5d,0x00,0x01,0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,0x1c,0x08,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,
0x01,0x00,0x30,0x00,0x39,0x00,0x0a,0x01,0x29,0x00,0x01,0x3b,0x00,0x09,0xc5,
0x01,0x00,0x00,0x19,0x1c,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x61,0x00,0x01,0x3d,0x00,0x0a,0x15,0x04,
0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,
0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,
0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,0x41,0x00,0x5a,0x00,
0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x09,0x40,0x00,0x00,0x00,0x01,
0x2e,0x00,0x15,0x04,0x00,0x24,0x00,0x24,0x00,0x41,0x00,0x5a,0x00,0x5f,0x00,
0x5f,0x00,0x61,0x00,0x7a,0x00,0x1c,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x04,0x00,0x30,0x00,0x39,0x00,
0x41,0x00,0x5a,0x00,0x5f,0x00,0x5f,0x00,0x61,0x00,0x7a,0x00,0x0a,0x07,0x02,
0x01,0x00,0x00,0x01,0x5b,0x00,0x09,0x7e,0x00,0x00,0x00,0x01,0x27,0x00,0x1c,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,
0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,
0xff,0x0a,0x0d,0x02,0x02,0x09,0x4a,0x00,0x00,0x00,0x19,0x0b,0x02,0x1c,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,0x00,0x00,0x00,0xff,0xff,0x1c,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,0x00,
0x00,0x15,0x03,0x00,0x00,0x00,0x26,0x00,0x28,0x00,0x5b,0x00,0x5d,0x00,0xff,
0xff,0x0a,0x0c,0x02,0x1a,0xb1,0xff,0xff,0xff,0x01,0x27,0x00,0x07,0x79,0x00,
0x00,0x00,0x01,0x22,0x00,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,
0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0d,0x03,0x03,0x09,0x4a,0x00,0x00,
0x00,0x19,0x0b,0x03,0x1c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x3a,0x00,0x0a,0x01,0x5c,0x00,0x15,0x01,
0x00,0x00,0x00,0xff,0xff,0x1c,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0xff,0xff,0x7f,0x01,0x00,0x00,0x00,0x15,0x03,0x00,0x00,0x00,0x21,0x00,0x23,
0x00,0x5b,0x00,0x5d,0x00,0xff,0xff,0x0a,0x0c,0x03,0x1a,0xb1,0xff,0xff,0xff,
0x01,0x22,0x00,0x01,0x5d,0x00,0x01,0x28,0x00,0x01,0x61,0x00,0x01,0x2c,0x00,
0x1c,0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x01,0x00,
0x00,0x00,0x15,0x01,0x00,0x30,0x00,0x39,0x00,0x0a,0x01,0x29,0x00,0x01,0x3b,
0x00,0x1a,0x36,0xfe,0xff,0xff,0x0c,0x01,0x01,0x72,0x00,0x01,0x65,0x00,0x01,
0x74,0x00,0x01,0x75,0x00,0x01,0x72,0x00,0x01,0x6e,0x00,0x01,0x20,0x00,0x01,
0x61,0x00,0x01,0x2e,0x00,0x01,0x6a,0x00,0x01,0x6f,0x00,0x01,0x69,0x00,0x01,
0x6e,0x00,0x01,0x28,0x00,0x09,0x0b,0x00,0x00,0x00,0x01,0x27,0x00,0x01,0x27,
0x00,0x07,0x06,0x00,0x00,0x00,0x01,0x22,0x00,0x01,0x22,0x00,0x01,0x29,0x00,
0x01,0x7d,0x00,0x0c,0x00,0x0a
};
| 77.955307 | 79 | 0.749534 |
2c10b33aef7bef021435f92bed36aad9148ba5c7 | 6,840 | c | C | sys/dev/disk/aic7xxx/ahc_pci.c | ivadasz/DragonFlyBSD | 460227f342554313be3c7728ff679dd4a556cce9 | [
"BSD-3-Clause"
] | 1 | 2018-01-12T03:55:33.000Z | 2018-01-12T03:55:33.000Z | sys/dev/disk/aic7xxx/ahc_pci.c | jorisgio/DragonFlyBSD | d37cc9027d161f3e36bf2667d32f41f87606b2ac | [
"BSD-3-Clause"
] | null | null | null | sys/dev/disk/aic7xxx/ahc_pci.c | jorisgio/DragonFlyBSD | d37cc9027d161f3e36bf2667d32f41f87606b2ac | [
"BSD-3-Clause"
] | null | null | null | /*
* FreeBSD, PCI product support functions
*
* Copyright (c) 1995-2001 Justin T. Gibbs
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification, immediately at the beginning of the file.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU Public License ("GPL").
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#19 $
*
* $FreeBSD: src/sys/dev/aic7xxx/ahc_pci.c,v 1.64 2005/03/05 19:24:22 imp Exp $
*/
#include "aic7xxx_osm.h"
static int ahc_pci_probe(device_t dev);
static int ahc_pci_attach(device_t dev);
static device_method_t ahc_pci_device_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ahc_pci_probe),
DEVMETHOD(device_attach, ahc_pci_attach),
DEVMETHOD(device_detach, ahc_detach),
DEVMETHOD_END
};
static driver_t ahc_pci_driver = {
"ahc",
ahc_pci_device_methods,
sizeof(struct ahc_softc)
};
DRIVER_MODULE(ahc_pci, pci, ahc_pci_driver, ahc_devclass, NULL, NULL);
DRIVER_MODULE(ahc_pci, cardbus, ahc_pci_driver, ahc_devclass, NULL, NULL);
MODULE_DEPEND(ahc_pci, ahc, 1, 1, 1);
MODULE_VERSION(ahc_pci, 1);
static int
ahc_pci_probe(device_t dev)
{
struct ahc_pci_identity *entry;
entry = ahc_find_pci_device(dev);
if (entry != NULL) {
device_set_desc(dev, entry->name);
return (BUS_PROBE_DEFAULT);
}
return (ENXIO);
}
static int
ahc_pci_attach(device_t dev)
{
struct ahc_pci_identity *entry;
struct ahc_softc *ahc;
char *name;
int error;
entry = ahc_find_pci_device(dev);
if (entry == NULL)
return (ENXIO);
/*
* Allocate a softc for this card and
* set it up for attachment by our
* common detect routine.
*/
name = kmalloc(strlen(device_get_nameunit(dev)) + 1, M_DEVBUF, M_INTWAIT);
strcpy(name, device_get_nameunit(dev));
ahc = ahc_alloc(dev, name);
if (ahc == NULL)
return (ENOMEM);
ahc_set_unit(ahc, device_get_unit(dev));
/*
* Should we bother disabling 39Bit addressing
* based on installed memory?
*/
if (sizeof(bus_addr_t) > 4)
ahc->flags |= AHC_39BIT_ADDRESSING;
/* Allocate a dmatag for our SCB DMA maps */
/* XXX Should be a child of the PCI bus dma tag */
error = aic_dma_tag_create(ahc, /*parent*/NULL, /*alignment*/1,
/*boundary*/0,
(ahc->flags & AHC_39BIT_ADDRESSING)
? 0x7FFFFFFFFFULL
: BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
/*nsegments*/AHC_NSEG,
/*maxsegsz*/AHC_MAXTRANSFER_SIZE,
/*flags*/0,
&ahc->parent_dmat);
if (error != 0) {
kprintf("ahc_pci_attach: Could not allocate DMA tag "
"- error %d\n", error);
ahc_free(ahc);
return (ENOMEM);
}
ahc->dev_softc = dev;
error = ahc_pci_config(ahc, entry);
if (error != 0) {
ahc_free(ahc);
return (error);
}
ahc_attach(ahc);
return (0);
}
int
ahc_pci_map_registers(struct ahc_softc *ahc)
{
struct resource *regs;
u_int command;
int regs_type;
int regs_id;
int allow_memio;
command = aic_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1);
regs = NULL;
regs_type = 0;
regs_id = 0;
/* Retrieve the per-device 'allow_memio' hint */
if (resource_int_value(device_get_name(ahc->dev_softc),
device_get_unit(ahc->dev_softc),
"allow_memio", &allow_memio) != 0) {
if (bootverbose)
device_printf(ahc->dev_softc, "Defaulting to MEMIO ");
#ifdef AHC_ALLOW_MEMIO
if (bootverbose)
kprintf("on\n");
allow_memio = 1;
#else
if (bootverbose)
kprintf("off\n");
allow_memio = 0;
#endif
}
if ((allow_memio != 0) && (command & PCIM_CMD_MEMEN) != 0) {
regs_type = SYS_RES_MEMORY;
regs_id = AHC_PCI_MEMADDR;
regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
®s_id, RF_ACTIVE);
if (regs != NULL) {
ahc->tag = rman_get_bustag(regs);
ahc->bsh = rman_get_bushandle(regs);
/*
* Do a quick test to see if memory mapped
* I/O is functioning correctly.
*/
if (ahc_pci_test_register_access(ahc) != 0) {
device_printf(ahc->dev_softc,
"PCI Device %d:%d:%d failed memory "
"mapped test. Using PIO.\n",
aic_get_pci_bus(ahc->dev_softc),
aic_get_pci_slot(ahc->dev_softc),
aic_get_pci_function(ahc->dev_softc));
bus_release_resource(ahc->dev_softc, regs_type,
regs_id, regs);
regs = NULL;
} else {
command &= ~PCIM_CMD_PORTEN;
aic_pci_write_config(ahc->dev_softc,
PCIR_COMMAND,
command, /*bytes*/1);
}
}
}
if (regs == NULL && (command & PCIM_CMD_PORTEN) != 0) {
regs_type = SYS_RES_IOPORT;
regs_id = AHC_PCI_IOADDR;
regs = bus_alloc_resource_any(ahc->dev_softc, regs_type,
®s_id, RF_ACTIVE);
if (regs != NULL) {
ahc->tag = rman_get_bustag(regs);
ahc->bsh = rman_get_bushandle(regs);
if (ahc_pci_test_register_access(ahc) != 0) {
device_printf(ahc->dev_softc,
"PCI Device %d:%d:%d failed I/O "
"mapped test.\n",
aic_get_pci_bus(ahc->dev_softc),
aic_get_pci_slot(ahc->dev_softc),
aic_get_pci_function(ahc->dev_softc));
bus_release_resource(ahc->dev_softc, regs_type,
regs_id, regs);
regs = NULL;
} else {
command &= ~PCIM_CMD_MEMEN;
aic_pci_write_config(ahc->dev_softc,
PCIR_COMMAND,
command, /*bytes*/1);
}
}
}
if (regs == NULL) {
device_printf(ahc->dev_softc,
"can't allocate register resources\n");
return (ENOMEM);
}
ahc->platform_data->regs_res_type = regs_type;
ahc->platform_data->regs_res_id = regs_id;
ahc->platform_data->regs = regs;
return (0);
}
| 28.739496 | 79 | 0.68231 |
ece2fc98881dc304fc379d04490273d55d9b9844 | 1,036 | h | C | DrawQuest/DQPaymentObserver.h | VIPjellybear/drawquest | fbe365a2c807c13fc57871d21f0eb6eb7ebac68e | [
"BSD-3-Clause"
] | 38 | 2015-11-10T17:20:55.000Z | 2021-02-20T10:10:43.000Z | DrawQuest/DQPaymentObserver.h | VIPjellybear/drawquest | fbe365a2c807c13fc57871d21f0eb6eb7ebac68e | [
"BSD-3-Clause"
] | null | null | null | DrawQuest/DQPaymentObserver.h | VIPjellybear/drawquest | fbe365a2c807c13fc57871d21f0eb6eb7ebac68e | [
"BSD-3-Clause"
] | 9 | 2015-11-11T00:38:34.000Z | 2021-02-20T10:13:30.000Z | //
// DQPaymentObserver.h
// DrawQuest
//
// Created by David Mauro on 8/8/13.
// Copyright (c) 2013 Canvas. All rights reserved.
//
#import "DQController.h"
#import <StoreKit/StoreKit.h>
extern NSString *DQPaymentObserverDidCancelTransaction;
extern NSString *DQPaymentObserverDidUpdateTransaction;
extern NSString *DQPaymentObserverFailedToUpdateTransaction;
extern NSString *DQPaymentObserverDidRestoreTransactions;
extern NSString *DQPaymentObserverFailedToRestoreTransactions;
extern NSString *DQPaymentObserverErrorDomain;
extern NSString *DQPaymentObserverTransactionKeyString;
extern NSString *DQPaymentObserverResponseDictionaryKeyString;
extern NSString *DQPaymentObserverErrorKeyString;
extern NSString *DQPaymentObserverWillRetryKeyString;
extern NSInteger DQPaymentObserverUnknownError;
extern NSInteger DQPaymentObserverProcessReceiptError;
extern NSInteger DQPaymentObserverStoreKitTransactionError;
@interface DQPaymentObserver : DQController <SKPaymentTransactionObserver>
- (void)runPendingTransactions;
@end
| 33.419355 | 74 | 0.860039 |
263a39539220d8903d2a8d470ab3b5ce7ba78fe8 | 6,779 | h | C | ssl/statem/statem.h | nmav/openssl | 235f9329304ab9e75e43dc5a409901fc3b3de9ca | [
"OpenSSL"
] | 2 | 2021-07-26T16:21:33.000Z | 2021-07-26T16:21:35.000Z | ssl/statem/statem.h | nmav/openssl | 235f9329304ab9e75e43dc5a409901fc3b3de9ca | [
"OpenSSL"
] | null | null | null | ssl/statem/statem.h | nmav/openssl | 235f9329304ab9e75e43dc5a409901fc3b3de9ca | [
"OpenSSL"
] | null | null | null | /* ====================================================================
* Copyright (c) 1998-2015 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED 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 OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
/*****************************************************************************
* *
* These emums should be considered PRIVATE to the state machine. No *
* non-state machine code should need to use these *
* *
*****************************************************************************/
/*
* Valid return codes used for functions performing work prior to or after
* sending or receiving a message
*/
typedef enum {
/* Something went wrong */
WORK_ERROR,
/* We're done working and there shouldn't be anything else to do after */
WORK_FINISHED_STOP,
/* We're done working move onto the next thing */
WORK_FINISHED_CONTINUE,
/* We're working on phase A */
WORK_MORE_A,
/* We're working on phase B */
WORK_MORE_B
} WORK_STATE;
/* Write transition return codes */
typedef enum {
/* Something went wrong */
WRITE_TRAN_ERROR,
/* A transition was successfully completed and we should continue */
WRITE_TRAN_CONTINUE,
/* There is no more write work to be done */
WRITE_TRAN_FINISHED
} WRITE_TRAN;
/* Message flow states */
typedef enum {
/* No handshake in progress */
MSG_FLOW_UNINITED,
/* A permanent error with this connection */
MSG_FLOW_ERROR,
/* We are about to renegotiate */
MSG_FLOW_RENEGOTIATE,
/* We are reading messages */
MSG_FLOW_READING,
/* We are writing messages */
MSG_FLOW_WRITING,
/* Handshake has finished */
MSG_FLOW_FINISHED
} MSG_FLOW_STATE;
/* Read states */
typedef enum {
READ_STATE_HEADER,
READ_STATE_BODY,
READ_STATE_POST_PROCESS
} READ_STATE;
/* Write states */
typedef enum {
WRITE_STATE_TRANSITION,
WRITE_STATE_PRE_WORK,
WRITE_STATE_SEND,
WRITE_STATE_POST_WORK
} WRITE_STATE;
/*****************************************************************************
* *
* This structure should be considered "opaque" to anything outside of the *
* state machine. No non-state machine code should be accessing the members *
* of this structure. *
* *
*****************************************************************************/
struct ossl_statem_st {
MSG_FLOW_STATE state;
WRITE_STATE write_state;
WORK_STATE write_state_work;
READ_STATE read_state;
WORK_STATE read_state_work;
OSSL_HANDSHAKE_STATE hand_state;
int in_init;
int read_state_first_init;
/* true when we are actually in SSL_accept() or SSL_connect() */
int in_handshake;
/* Should we skip the CertificateVerify message? */
unsigned int no_cert_verify;
int use_timer;
#ifndef OPENSSL_NO_SCTP
int in_sctp_read_sock;
#endif
};
typedef struct ossl_statem_st OSSL_STATEM;
/*****************************************************************************
* *
* The following macros/functions represent the libssl internal API to the *
* state machine. Any libssl code may call these functions/macros *
* *
*****************************************************************************/
__owur int ossl_statem_accept(SSL *s);
__owur int ossl_statem_connect(SSL *s);
void ossl_statem_clear(SSL *s);
void ossl_statem_set_renegotiate(SSL *s);
void ossl_statem_set_error(SSL *s);
int ossl_statem_in_error(const SSL *s);
void ossl_statem_set_in_init(SSL *s, int init);
int ossl_statem_get_in_handshake(SSL *s);
void ossl_statem_set_in_handshake(SSL *s, int inhand);
void ossl_statem_set_hello_verify_done(SSL *s);
__owur int ossl_statem_app_data_allowed(SSL *s);
#ifndef OPENSSL_NO_SCTP
void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock);
__owur int ossl_statem_in_sctp_read_sock(SSL *s);
#endif
| 38.517045 | 79 | 0.608792 |
03f5f51862e2ee66e9a72d137631f59c1acdff7e | 207 | h | C | ActionTrack/ActionTrack/HookClass/UICollectionView+Analysis.h | minsol/MinsolPrivate | 831a9b7b1e40f1ab30024bdf088a1e5dad232aee | [
"MIT"
] | 1 | 2019-07-04T09:53:35.000Z | 2019-07-04T09:53:35.000Z | ActionTrack/ActionTrack/HookClass/UICollectionView+Analysis.h | minsol/MinsolPrivate | 831a9b7b1e40f1ab30024bdf088a1e5dad232aee | [
"MIT"
] | null | null | null | ActionTrack/ActionTrack/HookClass/UICollectionView+Analysis.h | minsol/MinsolPrivate | 831a9b7b1e40f1ab30024bdf088a1e5dad232aee | [
"MIT"
] | null | null | null | //
// UICollectionView+Analysis.h
// demo
//
// Created by Minsol on 2018/12/19.
// Copyright © 2018 Minsol. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UICollectionView (Analysis)
@end
| 15.923077 | 49 | 0.690821 |
c1801591056f7da3d4dc9218d46e9cd02af1d77e | 2,213 | h | C | chromecast/shell/browser/devtools/cast_dev_tools_delegate.h | Fusion-Rom/android_external_chromium_org | d8b126911c6ea9753e9f526bee5654419e1d0ebd | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2015-08-13T21:04:58.000Z | 2015-08-13T21:04:58.000Z | chromecast/shell/browser/devtools/cast_dev_tools_delegate.h | Fusion-Rom/android_external_chromium_org | d8b126911c6ea9753e9f526bee5654419e1d0ebd | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | chromecast/shell/browser/devtools/cast_dev_tools_delegate.h | Fusion-Rom/android_external_chromium_org | d8b126911c6ea9753e9f526bee5654419e1d0ebd | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-11-04T06:34:36.000Z | 2020-11-04T06:34:36.000Z | // Copyright 2014 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 CHROMECAST_SHELL_BROWSER_DEVTOOLS_CAST_DEV_TOOLS_DELEGATE_H_
#define CHROMECAST_SHELL_BROWSER_DEVTOOLS_CAST_DEV_TOOLS_DELEGATE_H_
#include "content/public/browser/devtools_http_handler_delegate.h"
#include "content/public/browser/devtools_manager_delegate.h"
#include "net/socket/stream_listen_socket.h"
namespace base {
class FilePath;
}
namespace content {
class BrowserContext;
}
namespace chromecast {
namespace shell {
class CastDevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
public:
CastDevToolsDelegate();
virtual ~CastDevToolsDelegate();
// DevToolsHttpHandlerDelegate implementation.
virtual std::string GetDiscoveryPageHTML() OVERRIDE;
virtual bool BundlesFrontendResources() OVERRIDE;
virtual base::FilePath GetDebugFrontendDir() OVERRIDE;
virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
net::StreamListenSocket::Delegate* delegate,
std::string* name) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(CastDevToolsDelegate);
};
class CastDevToolsManagerDelegate : public content::DevToolsManagerDelegate {
public:
CastDevToolsManagerDelegate();
virtual ~CastDevToolsManagerDelegate();
// DevToolsManagerDelegate implementation.
virtual void Inspect(
content::BrowserContext* browser_context,
content::DevToolsAgentHost* agent_host) OVERRIDE {}
virtual void DevToolsAgentStateChanged(
content::DevToolsAgentHost* agent_host,
bool attached) OVERRIDE {}
virtual base::DictionaryValue* HandleCommand(
content::DevToolsAgentHost* agent_host,
base::DictionaryValue* command) OVERRIDE;
virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget(
const GURL& url) OVERRIDE;
virtual void EnumerateTargets(TargetCallback callback) OVERRIDE;
virtual std::string GetPageThumbnailData(const GURL& url) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(CastDevToolsManagerDelegate);
};
} // namespace shell
} // namespace chromecast
#endif // CHROMECAST_SHELL_BROWSER_DEVTOOLS_CAST_DEV_TOOLS_DELEGATE_H_
| 32.544118 | 77 | 0.799367 |
3261248ea80605e1f6f1a642332480ea17c6a4f9 | 127,313 | c | C | vendors/flecs/src/addons/rules.c | martonp96/Framework | d9a796fa4da9e6cb0f0ac05adfd83670852447e2 | [
"OpenSSL"
] | null | null | null | vendors/flecs/src/addons/rules.c | martonp96/Framework | d9a796fa4da9e6cb0f0ac05adfd83670852447e2 | [
"OpenSSL"
] | null | null | null | vendors/flecs/src/addons/rules.c | martonp96/Framework | d9a796fa4da9e6cb0f0ac05adfd83670852447e2 | [
"OpenSSL"
] | null | null | null | #include "../private_api.h"
#ifdef FLECS_RULES
/** Implementation of the rule query engine.
*
* A rule (terminology borrowed from prolog) is a list of constraints that
* specify which conditions must be met for an entity to match the rule. While
* this description matches any kind of ECS query, the rule engine has features
* that go beyond regular (flecs) ECS queries:
*
* - query for all components of an entity (vs. all entities for a component)
* - query for all relationship pairs of an entity
* - support for query variables that are resolved at evaluation time
* - automatic traversal of transitive relationships
*
* Query terms can have the following forms:
*
* - Component(Subject)
* - Relation(Subject, Object)
*
* Additionally the query parser supports the following shorthand notations:
*
* - Component // short for Component(This)
* - (Relation, Object) // short for Relation(This, Object)
*
* The subject, or first arugment of a term represents the entity on which the
* component or relation is matched. By default the subject is set to a builtin
* This variable, which causes the behavior to match a regular ECS query:
*
* - Position, Velocity
*
* Is equivalent to
*
* - Position(This), Velocity(This)
*
* The function of the variable is to ensure that all components are matched on
* the same entity. Conceptually the query first populates the This variable
* with all entities that have Position. When the query evaluates the Velocity
* term, the variable is populated and the entity it contains will be checked
* for whether it has Velocity.
*
* The actual implementation is more efficient and does not check per-entity.
*
* Custom variables can be used to join parts of different terms. For example,
* the following query can be used to find entities with a parent that has a
* Position component (note that variable names start with a _):
*
* - ChildOf(This, _Parent), Component(_Parent)
*
* The rule engine uses a backtracking algorithm to find the set of entities
* and variables that match all terms. As soon as the engine finds a term that
* does not match with the currently evaluated entity, the entity is discarded.
* When an entity is found for which all terms match, the entity is yielded to
* the iterator.
*
* While a rule is being evaluated, a variable can either contain a single
* entity or a table. The engine will attempt to work with tables as much as
* possible so entities can be eliminated/yielded in bulk. A rule may store
* both the table and entity version of a variable and only switch from table to
* entity when necessary.
*
* The rule engine has an algorithm for computing which variables should be
* resolved first. This algorithm works by finding a "root" variable, which is
* the subject variable that occurs in the term with the least dependencies. The
* remaining variables are then resolved based on their "distance" from the root
* with the closest variables being resolved first.
*
* This generally results in an ordering that resolves the variables with the
* least dependencies first and the most dependencies last, which is beneficial
* for two reasons:
*
* - it improves the average performance of all queries
* - it makes performance less dependent on how an application orders the terms
*
* A possible improvement would be for the query engine to also consider
* the number of tables that need to be evaluated for each term, as starting
* with the smallest term reduces the amount of work. Other than static variable
* analysis however, this can only be determined when the query is executed.
*
* Rules are "compiled" into a set of instructions that encode the operations
* the query needs to perform in order to find the right set of entities.
* Operations can either yield data, which progresses the program, or signal
* that there is no (more) matching data, which discards the current variables.
*
* An operation can yield multiple times, if there are multiple matches for its
* inputs. Operations are called with a redo flag, which can be either true or
* false. When redo is true the operation will yield the next result. When redo
* is false, the operation will reset its state and start from the first result.
*
* Operations can have an input, output and a filter. Most commonly an operation
* either matches the filter against an input and yields if it matches, or uses
* the filter to find all matching results and store the result in the output.
*
* Variables are resolved by matching a filter against the output of an
* operation. When a term contains variables, they are encoded as register ids
* in the filter. When the filter is evaluated, the most recent values of the
* register are used to match/lookup the output.
*
* For example, a filter could be (ChildOf, _Parent). When the program starts,
* the _Parent register is initialized with *, so that when this filter is first
* evaluated, the operation will find all tables with (ChildOf, *). The _Parent
* register is then populated by taking the actual value of the table. If the
* table has type [(ChildOf, Sun)], _Parent will be initialized with Sun.
*
* It is possible that a filter matches multiple times. Consider the filter
* (Likes, _Food), and a table [(Likes, Apples), (Likes, Pears)]. In this case
* an operation will yield the table twice, once with _Food=Apples, and once
* with _Food=Pears.
*
* If a rule contains a term with a transitive relation, it will automatically
* substitute the parts of the term to find a fact that matches. The following
* examples illustrate how transitivity is resolved:
*
* Query:
* LocatedIn(Bob, SanFrancisco)
*
* Expands to:
* LocatedIn(Bob, SanFrancisco:self|subset)
*
* Explanation:
* "Is Bob located in San Francisco" - This term is true if Bob is either
* located in San Francisco, or is located in anything that is itself located
* in (a subset of) San Francisco.
*
*
* Query:
* LocatedIn(Bob, X)
*
* Expands to:
* LocatedIn(Bob, X:self|superset)
*
* Explanation:
* "Where is Bob located?" - This term recursively returns all places that
* Bob is located in, which includes his location and the supersets of his
* location. When Bob is located in San Francisco, he is also located in
* the United States, North America etc.
*
*
* Query:
* LocatedIn(X, NorthAmerica)
*
* Expands to:
* LocatedIn(X, NorthAmerica:self|subset)
*
* Explanation:
* "What is located in North America?" - This term returns everything located
* in North America and its subsets, as something located in San Francisco is
* located in UnitedStates, which is located in NorthAmerica.
*
*
* Query:
* LocatedIn(X, Y)
*
* Expands to:
* LocatedIn(X, Y)
*
* Explanation:
* "Where is everything located" - This term returns everything that is
* located somewhere. No substitution is performed as this would explode the
* results while not yielding new information.
*
*
* In the above terms, the variable indicates the part of the term that is
* unknown at evaluation time. In an actual rule the picked strategy depends on
* whether the variable is known when the term is evaluated. For example, if
* variable X has been resolved by the time Located(X, Y) is evaluated, the
* strategy from the LocatedIn(Bob, X) example will be used.
*/
#define ECS_RULE_MAX_VARIABLE_COUNT (256)
#define RULE_PAIR_PREDICATE (1)
#define RULE_PAIR_OBJECT (2)
/* A rule pair contains a predicate and object that can be stored in a register. */
typedef struct ecs_rule_pair_t {
union {
int32_t reg;
ecs_entity_t ent;
} pred;
union {
int32_t reg;
ecs_entity_t ent;
} obj;
int32_t reg_mask; /* bit 1 = predicate, bit 2 = object, bit 4 = wildcard */
bool transitive; /* Is predicate transitive */
bool final; /* Is predicate final */
bool inclusive; /* Is predicate inclusive */
bool obj_0;
} ecs_rule_pair_t;
/* Filter for evaluating & reifing types and variables. Filters are created ad-
* hoc from pairs, and take into account all variables that had been resolved
* up to that point. */
typedef struct ecs_rule_filter_t {
ecs_id_t mask; /* Mask with wildcard in place of variables */
bool wildcard; /* Does the filter contain wildcards */
bool pred_wildcard; /* Is predicate a wildcard */
bool obj_wildcard; /* Is object a wildcard */
bool same_var; /* True if pred & obj are both the same variable */
int32_t hi_var; /* If hi part should be stored in var, this is the var id */
int32_t lo_var; /* If lo part should be stored in var, this is the var id */
} ecs_rule_filter_t;
/* A rule register stores temporary values for rule variables */
typedef enum ecs_rule_var_kind_t {
EcsRuleVarKindTable, /* Used for sorting, must be smallest */
EcsRuleVarKindEntity,
EcsRuleVarKindUnknown
} ecs_rule_var_kind_t;
typedef struct ecs_rule_reg_t {
/* Used for table variable */
ecs_table_t *table;
int32_t offset;
int32_t count;
/* Used for entity variable. May also be set for table variable if it needs
* to store an empty entity. */
ecs_entity_t entity;
} ecs_rule_reg_t;
/* Operations describe how the rule should be evaluated */
typedef enum ecs_rule_op_kind_t {
EcsRuleInput, /* Input placeholder, first instruction in every rule */
EcsRuleSelect, /* Selects all ables for a given predicate */
EcsRuleWith, /* Applies a filter to a table or entity */
EcsRuleSubSet, /* Finds all subsets for transitive relationship */
EcsRuleSuperSet, /* Finds all supersets for a transitive relationship */
EcsRuleStore, /* Store entity in table or entity variable */
EcsRuleEach, /* Forwards each entity in a table */
EcsRuleSetJmp, /* Set label for jump operation to one of two values */
EcsRuleJump, /* Jump to an operation label */
EcsRuleNot, /* Invert result of an operation */
EcsRuleYield /* Yield result */
} ecs_rule_op_kind_t;
/* Single operation */
typedef struct ecs_rule_op_t {
ecs_rule_op_kind_t kind; /* What kind of operation is it */
ecs_rule_pair_t filter; /* Parameter that contains optional filter */
ecs_entity_t subject; /* If set, operation has a constant subject */
int32_t on_pass; /* Jump location when match succeeds */
int32_t on_fail; /* Jump location when match fails */
int32_t frame; /* Register frame */
int32_t term; /* Corresponding term index in signature */
int32_t r_in; /* Optional In/Out registers */
int32_t r_out;
bool has_in, has_out; /* Keep track of whether operation uses input
* and/or output registers. This helps with
* debugging rule programs. */
} ecs_rule_op_t;
/* With context. Shared with select. */
typedef struct ecs_rule_with_ctx_t {
ecs_id_record_t *idr; /* Currently evaluated table set */
int32_t table_index;
} ecs_rule_with_ctx_t;
/* Subset context */
typedef struct ecs_rule_subset_frame_t {
ecs_rule_with_ctx_t with_ctx;
ecs_table_t *table;
int32_t row;
int32_t column;
} ecs_rule_subset_frame_t;
typedef struct ecs_rule_subset_ctx_t {
ecs_rule_subset_frame_t storage[16]; /* Alloc-free array for small trees */
ecs_rule_subset_frame_t *stack;
int32_t sp;
} ecs_rule_subset_ctx_t;
/* Superset context */
typedef struct ecs_rule_superset_frame_t {
ecs_table_t *table;
int32_t column;
} ecs_rule_superset_frame_t;
typedef struct ecs_rule_superset_ctx_t {
ecs_rule_superset_frame_t storage[16]; /* Alloc-free array for small trees */
ecs_rule_superset_frame_t *stack;
ecs_id_record_t *idr;
int32_t sp;
} ecs_rule_superset_ctx_t;
/* Each context */
typedef struct ecs_rule_each_ctx_t {
int32_t row; /* Currently evaluated row in evaluated table */
} ecs_rule_each_ctx_t;
/* Jump context */
typedef struct ecs_rule_setjmp_ctx_t {
int32_t label; /* Operation label to jump to */
} ecs_rule_setjmp_ctx_t;
/* Operation context. This is a per-operation, per-iterator structure that
* stores information for stateful operations. */
typedef struct ecs_rule_op_ctx_t {
union {
ecs_rule_subset_ctx_t subset;
ecs_rule_superset_ctx_t superset;
ecs_rule_with_ctx_t with;
ecs_rule_each_ctx_t each;
ecs_rule_setjmp_ctx_t setjmp;
} is;
} ecs_rule_op_ctx_t;
/* Rule variables allow for the rule to be parameterized */
typedef struct ecs_rule_var_t {
ecs_rule_var_kind_t kind;
char *name; /* Variable name */
int32_t id; /* Unique variable id */
int32_t occurs; /* Number of occurrences (used for operation ordering) */
int32_t depth; /* Depth in dependency tree (used for operation ordering) */
bool marked; /* Used for cycle detection */
} ecs_rule_var_t;
/* Top-level rule datastructure */
struct ecs_rule_t {
ecs_world_t *world; /* Ref to world so rule can be used by itself */
ecs_rule_op_t *operations; /* Operations array */
ecs_rule_var_t *variables; /* Variable array */
ecs_filter_t filter; /* Filter of rule */
char **variable_names; /* Array with var names, used by iterators */
int32_t *subject_variables; /* Variable id for term subject (if any) */
int32_t variable_count; /* Number of variables in signature */
int32_t subject_variable_count;
int32_t frame_count; /* Number of register frames */
int32_t operation_count; /* Number of operations in rule */
};
static
void rule_error(
const ecs_rule_t *rule,
const char *fmt,
...)
{
va_list valist;
va_start(valist, fmt);
ecs_parser_errorv(rule->filter.name, rule->filter.expr, -1, fmt, valist);
va_end(valist);
}
static
bool subj_is_set(
ecs_term_t *term)
{
return ecs_term_id_is_set(&term->args[0]);
}
static
bool obj_is_set(
ecs_term_t *term)
{
return ecs_term_id_is_set(&term->args[1]) || term->role == ECS_PAIR;
}
static
ecs_rule_op_t* create_operation(
ecs_rule_t *rule)
{
int32_t cur = rule->operation_count ++;
rule->operations = ecs_os_realloc(
rule->operations, (cur + 1) * ECS_SIZEOF(ecs_rule_op_t));
ecs_rule_op_t *result = &rule->operations[cur];
memset(result, 0, sizeof(ecs_rule_op_t));
return result;
}
static
const char* get_var_name(const char *name) {
if (name && !ecs_os_strcmp(name, "This")) {
/* Make sure that both This and . resolve to the same variable */
name = ".";
}
return name;
}
static
ecs_rule_var_t* create_variable(
ecs_rule_t *rule,
ecs_rule_var_kind_t kind,
const char *name)
{
int32_t cur = ++ rule->variable_count;
rule->variables = ecs_os_realloc(
rule->variables, cur * ECS_SIZEOF(ecs_rule_var_t));
name = get_var_name(name);
ecs_rule_var_t *var = &rule->variables[cur - 1];
if (name) {
var->name = ecs_os_strdup(name);
} else {
/* Anonymous register */
char name_buff[32];
ecs_os_sprintf(name_buff, "_%u", cur - 1);
var->name = ecs_os_strdup(name_buff);
}
var->kind = kind;
/* The variable id is the location in the variable array and also points to
* the register element that corresponds with the variable. */
var->id = cur - 1;
/* Depth is used to calculate how far the variable is from the root, where
* the root is the variable with 0 dependencies. */
var->depth = UINT8_MAX;
var->marked = false;
var->occurs = 0;
return var;
}
static
ecs_rule_var_t* create_anonymous_variable(
ecs_rule_t *rule,
ecs_rule_var_kind_t kind)
{
return create_variable(rule, kind, NULL);
}
/* Find variable with specified name and type. If Unknown is provided as type,
* the function will return any variable with the provided name. The root
* variable can occur both as a table and entity variable, as some rules
* require that each entity in a table is iterated. In this case, there are two
* variables, one for the table and one for the entities in the table, that both
* have the same name. */
static
ecs_rule_var_t* find_variable(
const ecs_rule_t *rule,
ecs_rule_var_kind_t kind,
const char *name)
{
ecs_assert(rule != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(name != NULL, ECS_INTERNAL_ERROR, NULL);
name = get_var_name(name);
ecs_rule_var_t *variables = rule->variables;
int32_t i, count = rule->variable_count;
for (i = 0; i < count; i ++) {
ecs_rule_var_t *variable = &variables[i];
if (!ecs_os_strcmp(name, variable->name)) {
if (kind == EcsRuleVarKindUnknown || kind == variable->kind) {
return variable;
}
}
}
return NULL;
}
/* Ensure variable with specified name and type exists. If an existing variable
* is found with an unknown type, its type will be overwritten with the
* specified type. During the variable ordering phase it is not yet clear which
* variable is the root. Which variable is the root determines its type, which
* is why during this phase variables are still untyped. */
static
ecs_rule_var_t* ensure_variable(
ecs_rule_t *rule,
ecs_rule_var_kind_t kind,
const char *name)
{
ecs_rule_var_t *var = find_variable(rule, kind, name);
if (!var) {
var = create_variable(rule, kind, name);
} else {
if (var->kind == EcsRuleVarKindUnknown) {
var->kind = kind;
}
}
return var;
}
static
bool term_id_is_variable(
ecs_term_id_t *term_id)
{
return term_id->var == EcsVarIsVariable;
}
static
const char *term_id_var_name(
ecs_term_id_t *term_id)
{
if (term_id->var == EcsVarIsVariable) {
if (term_id->entity == EcsThis) {
return ".";
} else {
ecs_assert(term_id->name != NULL, ECS_INVALID_PARAMETER, NULL);
return term_id->name;
}
}
return NULL;
}
/* Get variable from a term identifier */
static
ecs_rule_var_t* term_id_to_var(
ecs_rule_t *rule,
ecs_term_id_t *id)
{
if (id->var == EcsVarIsVariable) {;
return find_variable(rule, EcsRuleVarKindUnknown, term_id_var_name(id));
}
return NULL;
}
/* Get variable from a term predicate */
static
ecs_rule_var_t* term_pred(
ecs_rule_t *rule,
ecs_term_t *term)
{
return term_id_to_var(rule, &term->pred);
}
/* Get variable from a term subject */
static
ecs_rule_var_t* term_subj(
ecs_rule_t *rule,
ecs_term_t *term)
{
return term_id_to_var(rule, &term->args[0]);
}
/* Get variable from a term object */
static
ecs_rule_var_t* term_obj(
ecs_rule_t *rule,
ecs_term_t *term)
{
if (obj_is_set(term)) {
return term_id_to_var(rule, &term->args[1]);
} else {
return NULL;
}
}
/* Return predicate variable from pair */
static
ecs_rule_var_t* pair_pred(
ecs_rule_t *rule,
const ecs_rule_pair_t *pair)
{
if (pair->reg_mask & RULE_PAIR_PREDICATE) {
return &rule->variables[pair->pred.reg];
} else {
return NULL;
}
}
/* Return object variable from pair */
static
ecs_rule_var_t* pair_obj(
ecs_rule_t *rule,
const ecs_rule_pair_t *pair)
{
if (pair->reg_mask & RULE_PAIR_OBJECT) {
return &rule->variables[pair->obj.reg];
} else {
return NULL;
}
}
/* Create new frame for storing register values. Each operation that yields data
* gets its own register frame, which contains all variables reified up to that
* point. The preceding frame always contains the reified variables from the
* previous operation. Operations that do not yield data (such as control flow)
* do not have their own frames. */
static
int32_t push_frame(
ecs_rule_t *rule)
{
return rule->frame_count ++;
}
/* Get register array for current stack frame. The stack frame is determined by
* the current operation that is evaluated. The register array contains the
* values for the reified variables. If a variable hasn't been reified yet, its
* register will store a wildcard. */
static
ecs_rule_reg_t* get_register_frame(
ecs_rule_iter_t *it,
int32_t frame)
{
return &it->registers[frame * it->rule->variable_count];
}
/* Get register array for current stack frame. The stack frame is determined by
* the current operation that is evaluated. The register array contains the
* values for the reified variables. If a variable hasn't been reified yet, its
* register will store a wildcard. */
static
ecs_rule_reg_t* get_registers(
ecs_rule_iter_t *it,
ecs_rule_op_t *op)
{
return get_register_frame(it, op->frame);
}
/* Get columns array. Columns store, for each matched column in a table, the
* index at which it occurs. This reduces the amount of searching that
* operations need to do in a type, since select/with already provide it. */
static
int32_t* rule_get_columns_frame(
ecs_rule_iter_t *it,
int32_t frame)
{
return &it->columns[frame * it->rule->filter.term_count];
}
static
int32_t* rule_get_columns(
ecs_rule_iter_t *it,
ecs_rule_op_t *op)
{
return rule_get_columns_frame(it, op->frame);
}
static
ecs_table_t* table_from_entity(
ecs_world_t *world,
ecs_entity_t e)
{
ecs_record_t *record = ecs_eis_get(world, e);
if (record) {
return record->table;
} else {
return NULL;
}
}
static
void entity_reg_set(
const ecs_rule_t *rule,
ecs_rule_reg_t *regs,
int32_t r,
ecs_entity_t entity)
{
(void)rule;
ecs_assert(rule->variables[r].kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
ecs_assert(ecs_is_valid(rule->world, entity),
ECS_INVALID_PARAMETER, NULL);
regs[r].entity = entity;
}
static
ecs_entity_t entity_reg_get(
const ecs_rule_t *rule,
ecs_rule_reg_t *regs,
int32_t r)
{
(void)rule;
ecs_entity_t e = regs[r].entity;
ecs_assert(e != 0, ECS_INTERNAL_ERROR, NULL);
ecs_assert(ecs_is_valid(rule->world, e), ECS_INVALID_PARAMETER, NULL);
return e;
}
static
void table_reg_set(
const ecs_rule_t *rule,
ecs_rule_reg_t *regs,
int32_t r,
ecs_table_t *table)
{
(void)rule;
ecs_assert(rule->variables[r].kind == EcsRuleVarKindTable,
ECS_INTERNAL_ERROR, NULL);
regs[r].table = table;
regs[r].offset = 0;
regs[r].count = 0;
regs[r].entity = 0;
}
static
ecs_table_t* table_reg_get(
const ecs_rule_t *rule,
ecs_rule_reg_t *regs,
int32_t r)
{
(void)rule;
ecs_assert(rule->variables[r].kind == EcsRuleVarKindTable,
ECS_INTERNAL_ERROR, NULL);
return regs[r].table;
}
static
ecs_entity_t reg_get_entity(
const ecs_rule_t *rule,
ecs_rule_op_t *op,
ecs_rule_reg_t *regs,
int32_t r)
{
if (r == UINT8_MAX) {
ecs_assert(op->subject != 0, ECS_INTERNAL_ERROR, NULL);
/* The subject is referenced from the query string by string identifier.
* If subject entity is not valid, it could have been deletd by the
* application after the rule was created */
ecs_assert(ecs_is_valid(rule->world, op->subject),
ECS_INVALID_PARAMETER, NULL);
return op->subject;
}
if (rule->variables[r].kind == EcsRuleVarKindTable) {
int32_t offset = regs[r].offset;
ecs_assert(regs[r].count == 1, ECS_INTERNAL_ERROR, NULL);
ecs_data_t *data = &table_reg_get(rule, regs, r)->storage;
ecs_assert(data != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_entity_t *entities = ecs_vector_first(data->entities, ecs_entity_t);
ecs_assert(entities != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(offset < ecs_vector_count(data->entities),
ECS_INTERNAL_ERROR, NULL);
ecs_assert(ecs_is_valid(rule->world, entities[offset]),
ECS_INVALID_PARAMETER, NULL);
return entities[offset];
}
if (rule->variables[r].kind == EcsRuleVarKindEntity) {
return entity_reg_get(rule, regs, r);
}
/* Must return an entity */
ecs_assert(false, ECS_INTERNAL_ERROR, NULL);
return 0;
}
static
ecs_table_t* reg_get_table(
const ecs_rule_t *rule,
ecs_rule_op_t *op,
ecs_rule_reg_t *regs,
int32_t r)
{
if (r == UINT8_MAX) {
ecs_assert(op->subject != 0, ECS_INTERNAL_ERROR, NULL);
ecs_assert(ecs_is_valid(rule->world, op->subject),
ECS_INVALID_PARAMETER, NULL);
return table_from_entity(rule->world, op->subject);
}
if (rule->variables[r].kind == EcsRuleVarKindTable) {
return table_reg_get(rule, regs, r);
}
if (rule->variables[r].kind == EcsRuleVarKindEntity) {
return table_from_entity(rule->world, entity_reg_get(rule, regs, r));
}
return NULL;
}
static
void reg_set_entity(
const ecs_rule_t *rule,
ecs_rule_reg_t *regs,
int32_t r,
ecs_entity_t entity)
{
if (rule->variables[r].kind == EcsRuleVarKindTable) {
ecs_world_t *world = rule->world;
ecs_assert(ecs_is_valid(world, entity), ECS_INVALID_PARAMETER, NULL);
ecs_record_t *record = ecs_eis_get(world, entity);
if (!record || !record->table) {
regs[r].table = NULL;
regs[r].offset = 0;
regs[r].count = 0;
regs[r].entity = entity;
} else {
bool is_monitored;
regs[r].table = record->table;
regs[r].offset = flecs_record_to_row(record->row, &is_monitored);
regs[r].count = 1;
regs[r].entity = 0;
}
} else {
entity_reg_set(rule, regs, r, entity);
}
}
/* This encodes a column expression into a pair. A pair stores information about
* the variable(s) associated with the column. Pairs are used by operations to
* apply filters, and when there is a match, to reify variables. */
static
ecs_rule_pair_t term_to_pair(
ecs_rule_t *rule,
ecs_term_t *term)
{
ecs_rule_pair_t result = {0};
/* Terms must always have at least one argument (the subject) */
ecs_assert(subj_is_set(term), ECS_INTERNAL_ERROR, NULL);
/* If the predicate id is a variable, find the variable and encode its id
* in the pair so the operation can find it later. */
if (term->pred.var == EcsVarIsVariable) {
/* Always lookup the as an entity, as pairs never refer to tables */
const ecs_rule_var_t *var = find_variable(
rule, EcsRuleVarKindEntity, term->pred.name);
/* Variables should have been declared */
ecs_assert(var != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(var->kind == EcsRuleVarKindEntity, ECS_INTERNAL_ERROR, NULL);
result.pred.reg = var->id;
/* Set flag so the operation can see that the predicate is a variable */
result.reg_mask |= RULE_PAIR_PREDICATE;
result.final = true;
} else {
/* If the predicate is not a variable, simply store its id. */
ecs_entity_t pred_id = term->pred.entity;
result.pred.ent = pred_id;
/* Test if predicate is transitive. When evaluating the predicate, this
* will also take into account transitive relationships */
if (ecs_has_id(rule->world, pred_id, EcsTransitive)) {
/* Transitive queries must have an object */
if (obj_is_set(term)) {
result.transitive = true;
}
}
if (ecs_has_id(rule->world, pred_id, EcsFinal)) {
result.final = true;
}
if (ecs_has_id(rule->world, pred_id, EcsInclusive)) {
result.inclusive = true;
}
}
/* The pair doesn't do anything with the subject (subjects are the things that
* are matched against pairs) so if the column does not have a object,
* there is nothing left to do. */
if (!obj_is_set(term)) {
return result;
}
/* If arguments is higher than 2 this is not a pair but a nested rule */
ecs_assert(obj_is_set(term), ECS_INTERNAL_ERROR, NULL);
/* Same as above, if the object is a variable, store it and flag it */
if (term->args[1].var == EcsVarIsVariable) {
const ecs_rule_var_t *var = find_variable(
rule, EcsRuleVarKindEntity, term->args[1].name);
/* Variables should have been declared */
ecs_assert(var != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(var->kind == EcsRuleVarKindEntity, ECS_INTERNAL_ERROR, NULL);
result.obj.reg = var->id;
result.reg_mask |= RULE_PAIR_OBJECT;
} else {
/* If the object is not a variable, simply store its id */
result.obj.ent = term->args[1].entity;
if (!result.obj.ent) {
result.obj_0 = true;
}
}
return result;
}
/* When an operation has a pair, it is used to filter its input. This function
* translates a pair back into an entity id, and in the process substitutes the
* variables that have already been filled out. It's one of the most important
* functions, as a lot of the filtering logic depends on having an entity that
* has all of the reified variables correctly filled out. */
static
ecs_rule_filter_t pair_to_filter(
ecs_rule_iter_t *it,
ecs_rule_op_t *op,
ecs_rule_pair_t pair)
{
ecs_entity_t pred = pair.pred.ent;
ecs_entity_t obj = pair.obj.ent;
ecs_rule_filter_t result = {
.lo_var = -1,
.hi_var = -1
};
/* Get registers in case we need to resolve ids from registers. Get them
* from the previous, not the current stack frame as the current operation
* hasn't reified its variables yet. */
ecs_rule_reg_t *regs = get_register_frame(it, op->frame - 1);
if (pair.reg_mask & RULE_PAIR_OBJECT) {
obj = entity_reg_get(it->rule, regs, pair.obj.reg);
obj = ecs_entity_t_lo(obj); /* Filters don't have generations */
if (obj == EcsWildcard) {
result.wildcard = true;
result.obj_wildcard = true;
result.lo_var = pair.obj.reg;
}
}
if (pair.reg_mask & RULE_PAIR_PREDICATE) {
pred = entity_reg_get(it->rule, regs, pair.pred.reg);
pred = ecs_entity_t_lo(pred); /* Filters don't have generations */
if (pred == EcsWildcard) {
if (result.wildcard) {
result.same_var = pair.pred.reg == pair.obj.reg;
}
result.wildcard = true;
result.pred_wildcard = true;
if (obj) {
result.hi_var = pair.pred.reg;
} else {
result.lo_var = pair.pred.reg;
}
}
}
if (!obj && !pair.obj_0) {
result.mask = pred;
} else {
result.mask = ecs_pair(pred, obj);
}
return result;
}
/* This function is responsible for reifying the variables (filling them out
* with their actual values as soon as they are known). It uses the pair
* expression returned by pair_get_most_specific_var, and attempts to fill out each of the
* wildcards in the pair. If a variable isn't reified yet, the pair expression
* will still contain one or more wildcards, which is harmless as the respective
* registers will also point to a wildcard. */
static
void reify_variables(
ecs_rule_iter_t *it,
ecs_rule_op_t *op,
ecs_rule_filter_t *filter,
ecs_type_t type,
int32_t column)
{
const ecs_rule_t *rule = it->rule;
const ecs_rule_var_t *vars = rule->variables;
(void)vars;
ecs_rule_reg_t *regs = get_registers(it, op);
ecs_entity_t *elem = ecs_vector_get(type, ecs_entity_t, column);
ecs_assert(elem != NULL, ECS_INTERNAL_ERROR, NULL);
int32_t obj_var = filter->lo_var;
int32_t pred_var = filter->hi_var;
if (obj_var != -1) {
ecs_assert(vars[obj_var].kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
entity_reg_set(rule, regs, obj_var,
ecs_get_alive(rule->world, ECS_PAIR_OBJECT(*elem)));
}
if (pred_var != -1) {
ecs_assert(vars[pred_var].kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
entity_reg_set(rule, regs, pred_var,
ecs_get_alive(rule->world,
ECS_PAIR_RELATION(*elem)));
}
}
/* Returns whether variable is a subject */
static
bool is_subject(
ecs_rule_t *rule,
ecs_rule_var_t *var)
{
ecs_assert(rule != NULL, ECS_INTERNAL_ERROR, NULL);
if (!var) {
return false;
}
if (var->id < rule->subject_variable_count) {
return true;
}
return false;
}
static
bool skip_term(ecs_term_t *term) {
if (term->args[0].set.mask & EcsNothing) {
return true;
}
if (term->oper == EcsNot) {
return true;
}
return false;
}
static
int32_t get_variable_depth(
ecs_rule_t *rule,
ecs_rule_var_t *var,
ecs_rule_var_t *root,
int recur);
static
int32_t crawl_variable(
ecs_rule_t *rule,
ecs_rule_var_t *var,
ecs_rule_var_t *root,
int recur)
{
ecs_term_t *terms = rule->filter.terms;
int32_t i, count = rule->filter.term_count;
for (i = 0; i < count; i ++) {
ecs_term_t *term = &terms[i];
if (skip_term(term)) {
continue;
}
ecs_rule_var_t
*pred = term_pred(rule, term),
*subj = term_subj(rule, term),
*obj = term_obj(rule, term);
/* Variable must at least appear once in term */
if (var != pred && var != subj && var != obj) {
continue;
}
if (pred && pred != var && !pred->marked) {
get_variable_depth(rule, pred, root, recur + 1);
}
if (subj && subj != var && !subj->marked) {
get_variable_depth(rule, subj, root, recur + 1);
}
if (obj && obj != var && !obj->marked) {
get_variable_depth(rule, obj, root, recur + 1);
}
}
return 0;
}
static
int32_t get_depth_from_var(
ecs_rule_t *rule,
ecs_rule_var_t *var,
ecs_rule_var_t *root,
int recur)
{
/* If variable is the root or if depth has been set, return depth + 1 */
if (var == root || var->depth != UINT8_MAX) {
return var->depth + 1;
}
/* Variable is already being evaluated, so this indicates a cycle. Stop */
if (var->marked) {
return 0;
}
/* Variable is not yet being evaluated and depth has not yet been set.
* Calculate depth. */
int32_t depth = get_variable_depth(rule, var, root, recur + 1);
if (depth == UINT8_MAX) {
return depth;
} else {
return depth + 1;
}
}
static
int32_t get_depth_from_term(
ecs_rule_t *rule,
ecs_rule_var_t *cur,
ecs_rule_var_t *pred,
ecs_rule_var_t *obj,
ecs_rule_var_t *root,
int recur)
{
int32_t result = UINT8_MAX;
ecs_assert(cur != pred || cur != obj, ECS_INTERNAL_ERROR, NULL);
/* If neither of the other parts of the terms are variables, this
* variable is guaranteed to have no dependencies. */
if (!pred && !obj) {
result = 0;
} else {
/* If this is a variable that is not the same as the current,
* we can use it to determine dependency depth. */
if (pred && cur != pred) {
int32_t depth = get_depth_from_var(rule, pred, root, recur);
if (depth == UINT8_MAX) {
return UINT8_MAX;
}
/* If the found depth is lower than the depth found, overwrite it */
if (depth < result) {
result = depth;
}
}
/* Same for obj */
if (obj && cur != obj) {
int32_t depth = get_depth_from_var(rule, obj, root, recur);
if (depth == UINT8_MAX) {
return UINT8_MAX;
}
if (depth < result) {
result = depth;
}
}
}
return result;
}
/* Find the depth of the dependency tree from the variable to the root */
static
int32_t get_variable_depth(
ecs_rule_t *rule,
ecs_rule_var_t *var,
ecs_rule_var_t *root,
int recur)
{
var->marked = true;
/* Iterate columns, find all instances where 'var' is not used as subject.
* If the subject of that column is either the root or a variable for which
* the depth is known, the depth for this variable can be determined. */
ecs_term_t *terms = rule->filter.terms;
int32_t i, count = rule->filter.term_count;
int32_t result = UINT8_MAX;
for (i = 0; i < count; i ++) {
ecs_term_t *term = &terms[i];
if (skip_term(term)) {
continue;
}
ecs_rule_var_t
*pred = term_pred(rule, term),
*subj = term_subj(rule, term),
*obj = term_obj(rule, term);
if (subj != var) {
continue;
}
if (!is_subject(rule, pred)) {
pred = NULL;
}
if (!is_subject(rule, obj)) {
obj = NULL;
}
int32_t depth = get_depth_from_term(rule, var, pred, obj, root, recur);
if (depth < result) {
result = depth;
}
}
if (result == UINT8_MAX) {
result = 0;
}
var->depth = result;
/* Dependencies are calculated from subject to (pred, obj). If there were
* subjects that are only related by object (like (X, Y), (Z, Y)) it is
* possible that those have not yet been found yet. To make sure those
* variables are found, loop again & follow predicate & object links */
for (i = 0; i < count; i ++) {
ecs_term_t *term = &terms[i];
if (skip_term(term)) {
continue;
}
ecs_rule_var_t
*subj = term_subj(rule, term),
*pred = term_pred(rule, term),
*obj = term_obj(rule, term);
/* Only evaluate pred & obj for current subject. This ensures that we
* won't evaluate variables that are unreachable from the root. This
* must be detected as unconstrained variables are not allowed. */
if (subj != var) {
continue;
}
crawl_variable(rule, subj, root, recur);
if (pred && pred != var) {
crawl_variable(rule, pred, root, recur);
}
if (obj && obj != var) {
crawl_variable(rule, obj, root, recur);
}
}
return var->depth;
}
/* Compare function used for qsort. It ensures that variables are first ordered
* by depth, followed by how often they occur. */
static
int compare_variable(
const void* ptr1,
const void *ptr2)
{
const ecs_rule_var_t *v1 = ptr1;
const ecs_rule_var_t *v2 = ptr2;
if (v1->kind < v2->kind) {
return -1;
} else if (v1->kind > v2->kind) {
return 1;
}
if (v1->depth < v2->depth) {
return -1;
} else if (v1->depth > v2->depth) {
return 1;
}
if (v1->occurs < v2->occurs) {
return 1;
} else {
return -1;
}
return (v1->id < v2->id) - (v1->id > v2->id);
}
/* After all subject variables have been found, inserted and sorted, the
* remaining variables (predicate & object) still need to be inserted. This
* function serves two purposes. The first purpose is to ensure that all
* variables are known before operations are emitted. This ensures that the
* variables array won't be reallocated while emitting, which simplifies code.
* The second purpose of the function is to ensure that if the root variable
* (which, if it exists has now been created with a table type) is also inserted
* with an entity type if required. This is used later to decide whether the
* rule needs to insert an each instruction. */
static
void ensure_all_variables(
ecs_rule_t *rule)
{
ecs_term_t *terms = rule->filter.terms;
int32_t i, count = rule->filter.term_count;
for (i = 0; i < count; i ++) {
ecs_term_t *term = &terms[i];
if (skip_term(term)) {
continue;
}
/* If predicate is a variable, make sure it has been registered */
if (term->pred.var == EcsVarIsVariable) {
ensure_variable(rule, EcsRuleVarKindEntity, term->pred.name);
}
/* If subject is a variable and it is not This, make sure it is
* registered as an entity variable. This ensures that the program will
* correctly return all permutations */
if (term->args[0].var == EcsVarIsVariable) {
if (term->args[0].entity != EcsThis) {
ensure_variable(rule, EcsRuleVarKindEntity, term->args[0].name);
}
}
/* If object is a variable, make sure it has been registered */
if (obj_is_set(term) && (term->args[1].var == EcsVarIsVariable)) {
ensure_variable(rule, EcsRuleVarKindEntity, term->args[1].name);
}
}
}
/* Scan for variables, put them in optimal dependency order. */
static
int scan_variables(
ecs_rule_t *rule)
{
/* Objects found in rule. One will be elected root */
int32_t subject_count = 0;
/* If this (.) is found, it always takes precedence in root election */
int32_t this_var = UINT8_MAX;
/* Keep track of the subject variable that occurs the most. In the absence of
* this (.) the variable with the most occurrences will be elected root. */
int32_t max_occur = 0;
int32_t max_occur_var = UINT8_MAX;
/* Step 1: find all possible roots */
ecs_term_t *terms = rule->filter.terms;
int32_t i, term_count = rule->filter.term_count;
rule->subject_variables = ecs_os_malloc_n(int32_t, term_count);
for (i = 0; i < term_count; i ++) {
ecs_term_t *term = &terms[i];
/* Evaluate the subject. The predicate and object are not evaluated,
* since they never can be elected as root. */
if (term_id_is_variable(&term->args[0])) {
const char *subj_name = term_id_var_name(&term->args[0]);
ecs_rule_var_t *subj = find_variable(
rule, EcsRuleVarKindTable, subj_name);
if (!subj) {
subj = create_variable(rule, EcsRuleVarKindTable, subj_name);
if (subject_count >= ECS_RULE_MAX_VARIABLE_COUNT) {
rule_error(rule, "too many variables in rule");
goto error;
}
}
if (++ subj->occurs > max_occur) {
max_occur = subj->occurs;
max_occur_var = subj->id;
}
rule->subject_variables[i] = subj->id;
} else {
rule->subject_variables[i] = -1;
}
}
rule->subject_variable_count = rule->variable_count;
ensure_all_variables(rule);
/* Variables in a term with a literal subject have depth 0 */
for (i = 0; i < term_count; i ++) {
ecs_term_t *term = &terms[i];
if (term->args[0].var == EcsVarIsEntity) {
ecs_rule_var_t
*pred = term_pred(rule, term),
*obj = term_obj(rule, term);
if (pred) {
pred->depth = 0;
}
if (obj) {
obj->depth = 0;
}
}
}
/* Elect a root. This is either this (.) or the variable with the most
* occurrences. */
int32_t root_var = this_var;
if (root_var == UINT8_MAX) {
root_var = max_occur_var;
if (root_var == UINT8_MAX) {
/* If no subject variables have been found, the rule expression only
* operates on a fixed set of entities, in which case no root
* election is required. */
goto done;
}
}
ecs_rule_var_t *root = &rule->variables[root_var];
root->depth = get_variable_depth(rule, root, root, 0);
/* Verify that there are no unconstrained variables. Unconstrained variables
* are variables that are unreachable from the root. */
for (i = 0; i < rule->subject_variable_count; i ++) {
if (rule->variables[i].depth == UINT8_MAX) {
rule_error(rule, "unconstrained variable '%s'",
rule->variables[i].name);
goto error;
}
}
/* For each Not term, verify that variables are known */
for (i = 0; i < term_count; i ++) {
ecs_term_t *term = &terms[i];
if (term->oper != EcsNot) {
continue;
}
ecs_rule_var_t
*pred = term_pred(rule, term),
*obj = term_obj(rule, term);
if (!pred && term_id_is_variable(&term->pred)) {
rule_error(rule, "missing predicate variable '%s'",
term->pred.name);
goto error;
}
if (!obj && term_id_is_variable(&term->args[1])) {
rule_error(rule, "missing object variable '%s'",
term->args[1].name);
goto error;
}
}
/* Order variables by depth, followed by occurrence. The variable
* array will later be used to lead the iteration over the terms, and
* determine which operations get inserted first. */
size_t var_count = flecs_to_size_t(rule->variable_count);
qsort(rule->variables, var_count, sizeof(ecs_rule_var_t), compare_variable);
/* Iterate variables to correct ids after sort */
for (i = 0; i < rule->variable_count; i ++) {
rule->variables[i].id = i;
}
done:
return 0;
error:
return -1;
}
/* Get entity variable from table variable */
static
ecs_rule_var_t* to_entity(
ecs_rule_t *rule,
ecs_rule_var_t *var)
{
if (!var) {
return NULL;
}
ecs_rule_var_t *evar = NULL;
if (var->kind == EcsRuleVarKindTable) {
evar = find_variable(rule, EcsRuleVarKindEntity, var->name);
} else {
evar = var;
}
return evar;
}
/* Ensure that if a table variable has been written, the corresponding entity
* variable is populated. The function will return the most specific, populated
* variable. */
static
ecs_rule_var_t* most_specific_var(
ecs_rule_t *rule,
ecs_rule_var_t *var,
bool *written,
bool create)
{
if (!var) {
return NULL;
}
ecs_rule_var_t *tvar, *evar = to_entity(rule, var);
if (!evar) {
return var;
}
if (var->kind == EcsRuleVarKindTable) {
tvar = var;
} else {
tvar = find_variable(rule, EcsRuleVarKindTable, var->name);
}
/* If variable is used as predicate or object, it should have been
* registered as an entity. */
ecs_assert(evar != NULL, ECS_INTERNAL_ERROR, NULL);
/* Usually table variables are resolved before they are used as a predicate
* or object, but in the case of cyclic dependencies this is not guaranteed.
* Only insert an each instruction of the table variable has been written */
if (tvar && written[tvar->id]) {
/* If the variable has been written as a table but not yet
* as an entity, insert an each operation that yields each
* entity in the table. */
if (evar) {
if (written[evar->id]) {
return evar;
} else if (create) {
ecs_rule_op_t *op = create_operation(rule);
op->kind = EcsRuleEach;
op->on_pass = rule->operation_count;
op->on_fail = rule->operation_count - 2;
op->frame = rule->frame_count;
op->has_in = true;
op->has_out = true;
op->r_in = tvar->id;
op->r_out = evar->id;
/* Entity will either be written or has been written */
written[evar->id] = true;
push_frame(rule);
return evar;
} else {
return tvar;
}
}
} else if (evar && written[evar->id]) {
return evar;
}
return var;
}
/* Get most specific known variable */
static
ecs_rule_var_t *get_most_specific_var(
ecs_rule_t *rule,
ecs_rule_var_t *var,
bool *written)
{
return most_specific_var(rule, var, written, false);
}
/* Get or create most specific known variable. This will populate an entity
* variable if a table variable is known but the entity variable isn't. */
static
ecs_rule_var_t *ensure_most_specific_var(
ecs_rule_t *rule,
ecs_rule_var_t *var,
bool *written)
{
return most_specific_var(rule, var, written, true);
}
/* Ensure that an entity variable is written before using it */
static
ecs_rule_var_t* ensure_entity_written(
ecs_rule_t *rule,
ecs_rule_var_t *var,
bool *written)
{
if (!var) {
return NULL;
}
/* Ensure we're working with the most specific version of subj we can get */
ecs_rule_var_t *evar = ensure_most_specific_var(rule, var, written);
/* The post condition of this function is that there is an entity variable,
* and that it is written. Make sure that the result is an entity */
ecs_assert(evar != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(evar->kind == EcsRuleVarKindEntity, ECS_INTERNAL_ERROR, NULL);
/* Make sure the variable has been written */
ecs_assert(written[evar->id] == true, ECS_INTERNAL_ERROR, NULL);
return evar;
}
static
ecs_rule_op_t* insert_operation(
ecs_rule_t *rule,
int32_t term_index,
bool *written)
{
ecs_rule_pair_t pair = {0};
/* Parse the term's type into a pair. A pair extracts the ids from
* the term, and replaces variables with wildcards which can then
* be matched against actual relationships. A pair retains the
* information about the variables, so that when a match happens,
* the pair can be used to reify the variable. */
if (term_index != -1) {
ecs_term_t *term = &rule->filter.terms[term_index];
pair = term_to_pair(rule, term);
/* If the pair contains entity variables that have not yet been written,
* insert each instructions in case their tables are known. Variables in
* a pair that are truly unknown will be populated by the operation,
* but an operation should never overwrite an entity variable if the
* corresponding table variable has already been resolved. */
if (pair.reg_mask & RULE_PAIR_PREDICATE) {
ecs_rule_var_t *pred = &rule->variables[pair.pred.reg];
pred = get_most_specific_var(rule, pred, written);
pair.pred.reg = pred->id;
}
if (pair.reg_mask & RULE_PAIR_OBJECT) {
ecs_rule_var_t *obj = &rule->variables[pair.obj.reg];
obj = get_most_specific_var(rule, obj, written);
pair.obj.reg = obj->id;
}
} else {
/* Not all operations have a filter (like Each) */
}
ecs_rule_op_t *op = create_operation(rule);
op->on_pass = rule->operation_count;
op->on_fail = rule->operation_count - 2;
op->frame = rule->frame_count;
op->filter = pair;
/* Store corresponding signature term so we can correlate and
* store the table columns with signature columns. */
op->term = term_index;
return op;
}
/* Insert first operation, which is always Input. This creates an entry in
* the register stack for the initial state. */
static
void insert_input(
ecs_rule_t *rule)
{
ecs_rule_op_t *op = create_operation(rule);
op->kind = EcsRuleInput;
/* The first time Input is evaluated it goes to the next/first operation */
op->on_pass = 1;
/* When Input is evaluated with redo = true it will return false, which will
* finish the program as op becomes -1. */
op->on_fail = -1;
push_frame(rule);
}
/* Insert last operation, which is always Yield. When the program hits Yield,
* data is returned to the application. */
static
void insert_yield(
ecs_rule_t *rule)
{
ecs_rule_op_t *op = create_operation(rule);
op->kind = EcsRuleYield;
op->has_in = true;
op->on_fail = rule->operation_count - 2;
/* Yield can only "fail" since it is the end of the program */
/* Find variable associated with this. It is possible that the variable
* exists both as a table and as an entity. This can happen when a rule
* first selects a table for this, but then subsequently needs to evaluate
* each entity in that table. In that case the yield instruction should
* return the entity, so look for that first. */
ecs_rule_var_t *var = find_variable(rule, EcsRuleVarKindEntity, ".");
if (!var) {
var = find_variable(rule, EcsRuleVarKindTable, ".");
}
/* If there is no this, there is nothing to yield. In that case the rule
* simply returns true or false. */
if (!var) {
op->r_in = UINT8_MAX;
} else {
op->r_in = var->id;
}
op->frame = push_frame(rule);
}
/* Return superset/subset including the root */
static
void insert_inclusive_set(
ecs_rule_t *rule,
ecs_rule_op_kind_t op_kind,
ecs_rule_var_t *out,
const ecs_rule_pair_t pair,
int32_t c,
bool *written,
bool inclusive)
{
ecs_assert(out != NULL, ECS_INTERNAL_ERROR, NULL);
/* If the operation to be inserted is a superset, the output variable needs
* to be an entity as a superset is always resolved one at a time */
ecs_assert((op_kind != EcsRuleSuperSet) ||
out->kind == EcsRuleVarKindEntity, ECS_INTERNAL_ERROR, NULL);
int32_t setjmp_lbl = rule->operation_count;
int32_t store_lbl = setjmp_lbl + 1;
int32_t set_lbl = setjmp_lbl + 2;
int32_t next_op = setjmp_lbl + 4;
int32_t prev_op = setjmp_lbl - 1;
/* Insert 4 operations at once, so we don't have to worry about how
* the instruction array reallocs. If operation is not inclusive, we only
* need to insert the set operation. */
if (inclusive) {
insert_operation(rule, -1, written);
insert_operation(rule, -1, written);
insert_operation(rule, -1, written);
}
ecs_rule_op_t *op = insert_operation(rule, -1, written);
ecs_rule_op_t *setjmp = op - 3;
ecs_rule_op_t *store = op - 2;
ecs_rule_op_t *set = op - 1;
ecs_rule_op_t *jump = op;
if (!inclusive) {
set_lbl = setjmp_lbl;
set = op;
setjmp = NULL;
store = NULL;
jump = NULL;
next_op = set_lbl + 1;
prev_op = set_lbl - 1;
}
/* The SetJmp operation stores a conditional jump label that either
* points to the Store or *Set operation */
if (inclusive) {
setjmp->kind = EcsRuleSetJmp;
setjmp->on_pass = store_lbl;
setjmp->on_fail = set_lbl;
}
ecs_rule_var_t *pred = pair_pred(rule, &pair);
ecs_rule_var_t *obj = pair_obj(rule, &pair);
/* The Store operation yields the root of the subtree. After yielding,
* this operation will fail and return to SetJmp, which will cause it
* to switch to the *Set operation. */
if (inclusive) {
store->kind = EcsRuleStore;
store->on_pass = next_op;
store->on_fail = setjmp_lbl;
store->has_in = true;
store->has_out = true;
store->r_out = out->id;
store->term = c;
if (!pred) {
store->filter.pred = pair.pred;
} else {
store->filter.pred.reg = pred->id;
store->filter.reg_mask |= RULE_PAIR_PREDICATE;
}
/* If the object of the filter is not a variable, store literal */
if (!obj) {
store->r_in = UINT8_MAX;
store->subject = ecs_get_alive(rule->world, pair.obj.ent);
store->filter.obj = pair.obj;
} else {
store->r_in = obj->id;
store->filter.obj.reg = obj->id;
store->filter.reg_mask |= RULE_PAIR_OBJECT;
}
}
/* This is either a SubSet or SuperSet operation */
set->kind = op_kind;
set->on_pass = next_op;
set->on_fail = prev_op;
set->has_out = true;
set->r_out = out->id;
set->term = c;
/* Predicate can be a variable if it's non-final */
if (!pred) {
set->filter.pred = pair.pred;
} else {
set->filter.pred.reg = pred->id;
set->filter.reg_mask |= RULE_PAIR_PREDICATE;
}
if (!obj) {
set->filter.obj = pair.obj;
} else {
set->filter.obj.reg = obj->id;
set->filter.reg_mask |= RULE_PAIR_OBJECT;
}
if (inclusive) {
/* The jump operation jumps to either the store or subset operation,
* depending on whether the store operation already yielded. The
* operation is inserted last, so that the on_fail label of the next
* operation will point to it */
jump->kind = EcsRuleJump;
/* The pass/fail labels of the Jump operation are not used, since it
* jumps to a variable location. Instead, the pass label is (ab)used to
* store the label of the SetJmp operation, so that the jump can access
* the label it needs to jump to from the setjmp op_ctx. */
jump->on_pass = setjmp_lbl;
jump->on_fail = -1;
}
written[out->id] = true;
}
static
ecs_rule_var_t* store_inclusive_set(
ecs_rule_t *rule,
ecs_rule_op_kind_t op_kind,
ecs_rule_pair_t *pair,
bool *written,
bool inclusive)
{
/* The subset operation returns tables */
ecs_rule_var_kind_t var_kind = EcsRuleVarKindTable;
/* The superset operation returns entities */
if (op_kind == EcsRuleSuperSet) {
var_kind = EcsRuleVarKindEntity;
}
/* Create anonymous variable for storing the set */
ecs_rule_var_t *av = create_anonymous_variable(rule, var_kind);
ecs_rule_var_t *ave = NULL;
/* If the variable kind is a table, also create an entity variable as the
* result of the set operation should be returned as an entity */
if (var_kind == EcsRuleVarKindTable) {
ave = create_variable(rule, EcsRuleVarKindEntity, av->name);
av = &rule->variables[ave->id - 1];
}
/* Ensure we're using the most specific version of obj */
ecs_rule_var_t *obj = pair_obj(rule, pair);
if (obj) {
pair->obj.reg = obj->id;
}
/* Generate the operations */
insert_inclusive_set(rule, op_kind, av, *pair, -1, written, inclusive);
/* Make sure to return entity variable, and that it is populated */
return ensure_entity_written(rule, av, written);
}
static
bool is_known(
ecs_rule_var_t *var,
bool *written)
{
if (!var) {
return true;
} else {
return written[var->id];
}
}
static
bool is_pair_known(
ecs_rule_t *rule,
ecs_rule_pair_t *pair,
bool *written)
{
ecs_rule_var_t *pred_var = pair_pred(rule, pair);
if (!is_known(pred_var, written)) {
return false;
}
ecs_rule_var_t *obj_var = pair_obj(rule, pair);
if (!is_known(obj_var, written)) {
return false;
}
return true;
}
static
void set_input_to_subj(
ecs_rule_t *rule,
ecs_rule_op_t *op,
ecs_term_t *term,
ecs_rule_var_t *var)
{
(void)rule;
op->has_in = true;
if (!var) {
op->r_in = UINT8_MAX;
op->subject = term->args[0].entity;
/* Invalid entities should have been caught during parsing */
ecs_assert(ecs_is_valid(rule->world, op->subject),
ECS_INTERNAL_ERROR, NULL);
} else {
op->r_in = var->id;
}
}
static
void set_output_to_subj(
ecs_rule_t *rule,
ecs_rule_op_t *op,
ecs_term_t *term,
ecs_rule_var_t *var)
{
(void)rule;
op->has_out = true;
if (!var) {
op->r_out = UINT8_MAX;
op->subject = term->args[0].entity;
/* Invalid entities should have been caught during parsing */
ecs_assert(ecs_is_valid(rule->world, op->subject),
ECS_INTERNAL_ERROR, NULL);
} else {
op->r_out = var->id;
}
}
static
void insert_select_or_with(
ecs_rule_t *rule,
int32_t c,
ecs_term_t *term,
ecs_rule_var_t *subj,
ecs_rule_pair_t *pair,
bool *written)
{
ecs_rule_op_t *op;
bool eval_subject_supersets = false;
bool wildcard_subj = term->args[0].entity == EcsWildcard;
/* Find any entity and/or table variables for subject */
ecs_rule_var_t *tvar = NULL, *evar = to_entity(rule, subj), *var = evar;
if (subj && subj->kind == EcsRuleVarKindTable) {
tvar = subj;
if (!evar) {
var = tvar;
}
}
int32_t lbl_start = rule->operation_count;
ecs_rule_pair_t filter;
if (pair) {
filter = *pair;
} else {
filter = term_to_pair(rule, term);
}
if (!var && !wildcard_subj) {
/* Only insert implicit IsA if filter isn't already an IsA */
if (!filter.transitive || filter.pred.ent != EcsIsA) {
ecs_rule_pair_t isa_pair = {
.pred.ent = EcsIsA,
.obj.ent = term->args[0].entity
};
evar = subj = store_inclusive_set(
rule, EcsRuleSuperSet, &isa_pair, written, true);
tvar = NULL;
eval_subject_supersets = true;
}
}
/* If no pair is provided, create operation from specified term */
if (!pair) {
op = insert_operation(rule, c, written);
/* If an explicit pair is provided, override the default one from the
* term. This allows for using a predicate or object variable different
* from what is in the term. One application of this is to substitute a
* predicate with its subsets, if it is non final */
} else {
op = insert_operation(rule, -1, written);
op->filter = *pair;
/* Assign the term id, so that the operation will still be correctly
* associated with the correct expression term. */
op->term = c;
}
/* If entity variable is known and resolved, create with for it */
if (evar && is_known(evar, written)) {
op->kind = EcsRuleWith;
op->r_in = evar->id;
set_input_to_subj(rule, op, term, subj);
/* If table variable is known and resolved, create with for it */
} else if (tvar && is_known(tvar, written)) {
op->kind = EcsRuleWith;
op->r_in = tvar->id;
set_input_to_subj(rule, op, term, subj);
/* If subject is neither table nor entitiy, with operates on literal */
} else if (!tvar && !evar && !wildcard_subj) {
op->kind = EcsRuleWith;
set_input_to_subj(rule, op, term, subj);
/* If subject is table or entity but not known, use select */
} else {
ecs_assert(wildcard_subj || subj != NULL, ECS_INTERNAL_ERROR, NULL);
op->kind = EcsRuleSelect;
if (!wildcard_subj) {
set_output_to_subj(rule, op, term, subj);
written[subj->id] = true;
}
}
/* Optional terms cannot discard an entity, so set fail to the same label as
* pass */
if (term->oper == EcsOptional) {
op->on_fail = op->on_pass;
}
/* If supersets of subject are being evaluated, and we're looking for a
* specific filter, stop as soon as the filter has been matched. */
if (eval_subject_supersets && is_pair_known(rule, &op->filter, written)) {
op = insert_operation(rule, -1, written);
/* When the next operation returns, it will first hit SetJmp with a redo
* which will switch the jump label to the previous operation */
op->kind = EcsRuleSetJmp;
op->on_pass = rule->operation_count;
op->on_fail = lbl_start - 1;
}
if (op->filter.reg_mask & RULE_PAIR_PREDICATE) {
written[op->filter.pred.reg] = true;
}
if (op->filter.reg_mask & RULE_PAIR_OBJECT) {
written[op->filter.obj.reg] = true;
}
}
static
void prepare_predicate(
ecs_rule_t *rule,
ecs_rule_pair_t *pair,
bool *written)
{
/* If pair is not final, resolve term for all IsA relationships of the
* predicate. Note that if the pair has final set to true, it is guaranteed
* that the predicate can be used in an IsA query */
if (!pair->final) {
ecs_rule_pair_t isa_pair = {
.pred.ent = EcsIsA,
.obj.ent = pair->pred.ent
};
ecs_rule_var_t *pred = store_inclusive_set(
rule, EcsRuleSubSet, &isa_pair, written, true);
pair->pred.reg = pred->id;
pair->reg_mask |= RULE_PAIR_PREDICATE;
}
}
static
void insert_term_2(
ecs_rule_t *rule,
ecs_term_t *term,
ecs_rule_pair_t *filter,
int32_t c,
bool *written)
{
int32_t subj_id = -1, obj_id = -1;
ecs_rule_var_t *subj = term_subj(rule, term);
if ((subj = get_most_specific_var(rule, subj, written))) {
subj_id = subj->id;
}
ecs_rule_var_t *obj = term_obj(rule, term);
if ((obj = get_most_specific_var(rule, obj, written))) {
obj_id = obj->id;
}
if (!filter->transitive) {
insert_select_or_with(rule, c, term, subj, filter, written);
} else if (filter->transitive) {
if (is_known(subj, written)) {
if (is_known(obj, written)) {
ecs_rule_var_t *obj_subsets = store_inclusive_set(
rule, EcsRuleSubSet, filter, written, true);
if (subj) {
subj = &rule->variables[subj_id];
}
ecs_rule_pair_t pair = *filter;
pair.obj.reg = obj_subsets->id;
pair.reg_mask |= RULE_PAIR_OBJECT;
insert_select_or_with(rule, c, term, subj, &pair, written);
} else {
ecs_assert(obj != NULL, ECS_INTERNAL_ERROR, NULL);
/* If subject is literal, find supersets for subject */
if (subj == NULL || subj->kind == EcsRuleVarKindEntity) {
obj = to_entity(rule, obj);
ecs_rule_pair_t set_pair = *filter;
set_pair.reg_mask &= RULE_PAIR_PREDICATE;
if (subj) {
set_pair.obj.reg = subj->id;
set_pair.reg_mask |= RULE_PAIR_OBJECT;
} else {
set_pair.obj.ent = term->args[0].entity;
}
insert_inclusive_set(rule, EcsRuleSuperSet, obj, set_pair,
c, written, filter->inclusive);
/* If subject is variable, first find matching pair for the
* evaluated entity(s) and return supersets */
} else {
ecs_rule_var_t *av = create_anonymous_variable(
rule, EcsRuleVarKindEntity);
subj = &rule->variables[subj_id];
obj = &rule->variables[obj_id];
obj = to_entity(rule, obj);
ecs_rule_pair_t set_pair = *filter;
set_pair.obj.reg = av->id;
set_pair.reg_mask |= RULE_PAIR_OBJECT;
/* Insert with to find initial object for relation */
insert_select_or_with(
rule, c, term, subj, &set_pair, written);
push_frame(rule);
/* Find supersets for returned initial object. Make sure
* this is always inclusive since it needs to return the
* object from the pair that the entity has itself. */
insert_inclusive_set(rule, EcsRuleSuperSet, obj, set_pair,
c, written, true);
}
}
/* subj is not known */
} else {
ecs_assert(subj != NULL, ECS_INTERNAL_ERROR, NULL);
if (is_known(obj, written)) {
ecs_rule_pair_t set_pair = *filter;
set_pair.reg_mask &= RULE_PAIR_PREDICATE; /* clear object mask */
if (obj) {
set_pair.obj.reg = obj->id;
set_pair.reg_mask |= RULE_PAIR_OBJECT;
} else {
set_pair.obj.ent = term->args[1].entity;
}
insert_inclusive_set(rule, EcsRuleSubSet, subj, set_pair, c,
written, filter->inclusive);
} else if (subj == obj) {
insert_select_or_with(rule, c, term, subj, filter, written);
} else {
ecs_assert(obj != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_rule_var_t *av = create_anonymous_variable(
rule, EcsRuleVarKindEntity);
subj = &rule->variables[subj_id];
obj = &rule->variables[obj_id];
obj = to_entity(rule, obj);
/* TODO: this instruction currently does not return inclusive
* results. For example, it will return IsA(XWing, Machine) and
* IsA(XWing, Thing), but not IsA(XWing, XWing). To enable
* inclusive behavior, we need to be able to find all subjects
* that have IsA relationships, without expanding to all
* IsA relationships. For this a new mode needs to be supported
* where an operation never does a redo.
*
* This select can then be used to find all subjects, and those
* same subjects can then be used to find all (inclusive)
* supersets for those subjects. */
/* Insert instruction to find all subjects and objects */
ecs_rule_op_t *op = insert_operation(rule, -1, written);
op->kind = EcsRuleSelect;
set_output_to_subj(rule, op, term, subj);
/* Set object to anonymous variable */
op->filter.pred = filter->pred;
op->filter.obj.reg = av->id;
op->filter.reg_mask = filter->reg_mask | RULE_PAIR_OBJECT;
written[subj->id] = true;
written[av->id] = true;
/* Create new frame for operations that create inclusive set */
push_frame(rule);
/* Insert superset instruction to find all supersets */
insert_inclusive_set(rule, EcsRuleSuperSet, obj, op->filter, c,
written, true);
}
}
}
}
static
void insert_term_1(
ecs_rule_t *rule,
ecs_term_t *term,
ecs_rule_pair_t *filter,
int32_t c,
bool *written)
{
ecs_rule_var_t *subj = term_subj(rule, term);
subj = get_most_specific_var(rule, subj, written);
insert_select_or_with(rule, c, term, subj, filter, written);
}
static
void insert_term(
ecs_rule_t *rule,
ecs_term_t *term,
int32_t c,
bool *written)
{
bool obj_set = obj_is_set(term);
ensure_most_specific_var(rule, term_pred(rule, term), written);
if (obj_set) {
ensure_most_specific_var(rule, term_obj(rule, term), written);
}
ecs_rule_pair_t filter = term_to_pair(rule, term);
prepare_predicate(rule, &filter, written);
/* If term has Not operator, prepend Not which turns a fail into a pass */
int32_t prev = rule->operation_count;
ecs_rule_op_t *not_pre;
if (term->oper == EcsNot) {
not_pre = insert_operation(rule, -1, written);
not_pre->kind = EcsRuleNot;
not_pre->has_in = false;
not_pre->has_out = false;
}
if (subj_is_set(term) && !obj_set) {
insert_term_1(rule, term, &filter, c, written);
} else if (obj_set) {
insert_term_2(rule, term, &filter, c, written);
}
/* If term has Not operator, append Not which turns a pass into a fail */
if (term->oper == EcsNot) {
ecs_rule_op_t *not_post = insert_operation(rule, -1, written);
not_post->kind = EcsRuleNot;
not_post->has_in = false;
not_post->has_out = false;
not_post->on_pass = prev - 1;
not_post->on_fail = prev - 1;
not_pre = &rule->operations[prev];
not_pre->on_fail = rule->operation_count;
}
if (term->oper == EcsOptional) {
/* Insert jump instruction that ensures that the optional term is only
* executed once */
ecs_rule_op_t *jump = insert_operation(rule, -1, written);
jump->kind = EcsRuleNot;
jump->has_in = false;
jump->has_out = false;
jump->on_pass = rule->operation_count;
jump->on_fail = prev - 1;
}
push_frame(rule);
}
/* Create program from operations that will execute the query */
static
void compile_program(
ecs_rule_t *rule)
{
/* Trace which variables have been written while inserting instructions.
* This determines which instruction needs to be inserted */
bool written[ECS_RULE_MAX_VARIABLE_COUNT] = { false };
ecs_term_t *terms = rule->filter.terms;
int32_t v, c, term_count = rule->filter.term_count;
ecs_rule_op_t *op;
/* Insert input, which is always the first instruction */
insert_input(rule);
/* First insert all instructions that do not have a variable subject. Such
* instructions iterate the type of an entity literal and are usually good
* candidates for quickly narrowing down the set of potential results. */
for (c = 0; c < term_count; c ++) {
ecs_term_t *term = &terms[c];
if (skip_term(term)) {
continue;
}
if (term->oper == EcsOptional) {
continue;
}
ecs_rule_var_t* subj = term_subj(rule, term);
if (subj) {
continue;
}
if (term->args[0].entity == EcsWildcard) {
continue;
}
insert_term(rule, term, c, written);
}
/* Insert variables based on dependency order */
for (v = 0; v < rule->subject_variable_count; v ++) {
ecs_rule_var_t *var = &rule->variables[v];
ecs_assert(var->kind == EcsRuleVarKindTable, ECS_INTERNAL_ERROR, NULL);
for (c = 0; c < term_count; c ++) {
ecs_term_t *term = &terms[c];
if (skip_term(term)) {
continue;
}
/* Only process columns for which variable is subject */
ecs_rule_var_t* subj = term_subj(rule, term);
if (subj != var) {
continue;
}
insert_term(rule, term, c, written);
var = &rule->variables[v];
}
}
/* Insert terms with wildcard subject */
for (c = 0; c < term_count; c ++) {
ecs_term_t *term = &terms[c];
if (term->args[0].entity != EcsWildcard) {
continue;
}
insert_term(rule, term, c, written);
}
/* Insert terms with Not operators */
for (c = 0; c < term_count; c ++) {
ecs_term_t *term = &terms[c];
if (term->oper != EcsNot) {
continue;
}
insert_term(rule, term, c, written);
}
/* Insert terms with Optional operators last, as optional terms cannot
* eliminate results, and would just add overhead to evaluation of
* non-matching entities. */
for (c = 0; c < term_count; c ++) {
ecs_term_t *term = &terms[c];
if (term->oper != EcsOptional) {
continue;
}
insert_term(rule, term, c, written);
}
/* Verify all subject variables have been written. Subject variables are of
* the table type, and a select/subset should have been inserted for each */
for (v = 0; v < rule->subject_variable_count; v ++) {
if (!written[v]) {
/* If the table variable hasn't been written, this can only happen
* if an instruction wrote the variable before a select/subset could
* have been inserted for it. Make sure that this is the case by
* testing if an entity variable exists and whether it has been
* written. */
ecs_rule_var_t *var = find_variable(
rule, EcsRuleVarKindEntity, rule->variables[v].name);
ecs_assert(written[var->id], ECS_INTERNAL_ERROR, var->name);
(void)var;
}
}
/* Make sure that all entity variables are written. With the exception of
* the this variable, which can be returned as a table, other variables need
* to be available as entities. This ensures that all permutations for all
* variables are correctly returned by the iterator. When an entity variable
* hasn't been written yet at this point, it is because it only constrained
* through a common predicate or object. */
for (; v < rule->variable_count; v ++) {
if (!written[v]) {
ecs_rule_var_t *var = &rule->variables[v];
ecs_assert(var->kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
ecs_rule_var_t *table_var = find_variable(
rule, EcsRuleVarKindTable, var->name);
/* A table variable must exist if the variable hasn't been resolved
* yet. If there doesn't exist one, this could indicate an
* unconstrained variable which should have been caught earlier */
ecs_assert(table_var != NULL, ECS_INTERNAL_ERROR, var->name);
/* Insert each operation that takes the table variable as input, and
* yields each entity in the table */
op = insert_operation(rule, -1, written);
op->kind = EcsRuleEach;
op->r_in = table_var->id;
op->r_out = var->id;
op->frame = rule->frame_count;
op->has_in = true;
op->has_out = true;
written[var->id] = true;
push_frame(rule);
}
}
/* Insert yield, which is always the last operation */
insert_yield(rule);
}
static
void create_variable_name_array(
ecs_rule_t *rule)
{
if (rule->variable_count) {
rule->variable_names = ecs_os_malloc_n(char*, rule->variable_count);
int i;
for (i = 0; i < rule->variable_count; i ++) {
ecs_rule_var_t *var = &rule->variables[i];
rule->variable_names[var->id] = var->name;
}
}
}
ecs_rule_t* ecs_rule_init(
ecs_world_t *world,
const ecs_filter_desc_t *desc)
{
ecs_rule_t *result = ecs_os_calloc(ECS_SIZEOF(ecs_rule_t));
ecs_filter_desc_t local_desc = *desc;
local_desc.substitute_default = true;
/* Parse the signature expression. This initializes the columns array which
* contains the information about which components/pairs are requested. */
if (ecs_filter_init(world, &result->filter, &local_desc)) {
goto error;
}
result->world = world;
/* Rule has no terms */
if (!result->filter.term_count) {
rule_error(result, "rule has no terms");
goto error;
}
ecs_term_t *terms = result->filter.terms;
int32_t i, term_count = result->filter.term_count;
/* Make sure rule doesn't just have Not terms */
for (i = 0; i < term_count; i++) {
ecs_term_t *term = &terms[i];
if (term->oper != EcsNot) {
break;
}
}
if (i == term_count) {
rule_error(result, "rule cannot only have terms with Not operator");
goto error;
}
/* Find all variables & resolve dependencies */
if (scan_variables(result) != 0) {
goto error;
}
/* Generate the opcode array */
compile_program(result);
/* Create array with variable names so this can be easily accessed by
* iterators without requiring access to the ecs_rule_t */
create_variable_name_array(result);
/* Make sure that subject variable ids are pointing to entity variables */
for (i = 0; i < term_count; i ++) {
int32_t var_id = result->subject_variables[i];
if (var_id != -1) {
ecs_rule_var_t *var = &result->variables[var_id];
var = to_entity(result, var);
if (var) {
result->subject_variables[i] = var->id;
} else {
result->subject_variables[i] = -1;
}
}
}
return result;
error:
ecs_rule_fini(result);
return NULL;
}
void ecs_rule_fini(
ecs_rule_t *rule)
{
int32_t i;
for (i = 0; i < rule->variable_count; i ++) {
ecs_os_free(rule->variables[i].name);
}
ecs_os_free(rule->variables);
ecs_os_free(rule->operations);
ecs_os_free(rule->variable_names);
ecs_os_free(rule->subject_variables);
ecs_filter_fini(&rule->filter);
ecs_os_free(rule);
}
const ecs_filter_t* ecs_rule_filter(
const ecs_rule_t *rule)
{
return &rule->filter;
}
/* Quick convenience function to get a variable from an id */
static
ecs_rule_var_t* get_variable(
const ecs_rule_t *rule,
int32_t var_id)
{
if (var_id == UINT8_MAX) {
return NULL;
}
return &rule->variables[var_id];
}
/* Convert the program to a string. This can be useful to analyze how a rule is
* being evaluated. */
char* ecs_rule_str(
ecs_rule_t *rule)
{
ecs_assert(rule != NULL, ECS_INVALID_PARAMETER, NULL);
ecs_world_t *world = rule->world;
ecs_strbuf_t buf = ECS_STRBUF_INIT;
char filter_expr[256];
int32_t i, count = rule->operation_count;
for (i = 1; i < count; i ++) {
ecs_rule_op_t *op = &rule->operations[i];
ecs_rule_pair_t pair = op->filter;
ecs_entity_t pred = pair.pred.ent;
ecs_entity_t obj = pair.obj.ent;
const char *pred_name = NULL, *obj_name = NULL;
char *pred_name_alloc = NULL, *obj_name_alloc = NULL;
if (pair.reg_mask & RULE_PAIR_PREDICATE) {
ecs_assert(rule->variables != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_rule_var_t *type_var = &rule->variables[pair.pred.reg];
pred_name = type_var->name;
} else if (pred) {
pred_name_alloc = ecs_get_fullpath(world, ecs_get_alive(world, pred));
pred_name = pred_name_alloc;
}
if (pair.reg_mask & RULE_PAIR_OBJECT) {
ecs_assert(rule->variables != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_rule_var_t *obj_var = &rule->variables[pair.obj.reg];
obj_name = obj_var->name;
} else if (obj) {
obj_name_alloc = ecs_get_fullpath(world, ecs_get_alive(world, obj));
obj_name = obj_name_alloc;
} else if (pair.obj_0) {
obj_name = "0";
}
ecs_strbuf_append(&buf, "%2d: [S:%2d, P:%2d, F:%2d] ", i,
op->frame, op->on_pass, op->on_fail);
bool has_filter = false;
switch(op->kind) {
case EcsRuleSelect:
ecs_strbuf_append(&buf, "select ");
has_filter = true;
break;
case EcsRuleWith:
ecs_strbuf_append(&buf, "with ");
has_filter = true;
break;
case EcsRuleStore:
ecs_strbuf_append(&buf, "store ");
break;
case EcsRuleSuperSet:
ecs_strbuf_append(&buf, "superset ");
has_filter = true;
break;
case EcsRuleSubSet:
ecs_strbuf_append(&buf, "subset ");
has_filter = true;
break;
case EcsRuleEach:
ecs_strbuf_append(&buf, "each ");
break;
case EcsRuleSetJmp:
ecs_strbuf_append(&buf, "setjmp ");
break;
case EcsRuleJump:
ecs_strbuf_append(&buf, "jump ");
break;
case EcsRuleNot:
ecs_strbuf_append(&buf, "not ");
break;
case EcsRuleYield:
ecs_strbuf_append(&buf, "yield ");
break;
default:
continue;
}
if (op->has_out) {
ecs_rule_var_t *r_out = get_variable(rule, op->r_out);
if (r_out) {
ecs_strbuf_append(&buf, "O:%s%s ",
r_out->kind == EcsRuleVarKindTable ? "t" : "",
r_out->name);
} else if (op->subject) {
char *subj_path = ecs_get_fullpath(world, op->subject);
ecs_strbuf_append(&buf, "O:%s ", subj_path);
ecs_os_free(subj_path);
}
}
if (op->has_in) {
ecs_rule_var_t *r_in = get_variable(rule, op->r_in);
if (r_in) {
ecs_strbuf_append(&buf, "I:%s%s ",
r_in->kind == EcsRuleVarKindTable ? "t" : "",
r_in->name);
} else if (op->subject) {
char *subj_path = ecs_get_fullpath(world, op->subject);
ecs_strbuf_append(&buf, "I:%s ", subj_path);
ecs_os_free(subj_path);
}
}
if (has_filter) {
if (!obj && !pair.obj_0) {
ecs_os_sprintf(filter_expr, "(%s)", pred_name);
} else {
ecs_os_sprintf(filter_expr, "(%s, %s)", pred_name, obj_name);
}
ecs_strbuf_append(&buf, "F:%s", filter_expr);
}
ecs_strbuf_appendstr(&buf, "\n");
ecs_os_free(pred_name_alloc);
ecs_os_free(obj_name_alloc);
}
return ecs_strbuf_get(&buf);
}
/* Public function that returns number of variables. This enables an application
* to iterate the variables and obtain their values. */
int32_t ecs_rule_variable_count(
const ecs_rule_t *rule)
{
ecs_assert(rule != NULL, ECS_INTERNAL_ERROR, NULL);
return rule->variable_count;
}
/* Public function to find a variable by name */
int32_t ecs_rule_find_variable(
const ecs_rule_t *rule,
const char *name)
{
ecs_rule_var_t *v = find_variable(rule, EcsRuleVarKindEntity, name);
if (v) {
return v->id;
} else {
return -1;
}
}
/* Public function to get the name of a variable. */
const char* ecs_rule_variable_name(
const ecs_rule_t *rule,
int32_t var_id)
{
return rule->variables[var_id].name;
}
/* Public function to get the type of a variable. */
bool ecs_rule_variable_is_entity(
const ecs_rule_t *rule,
int32_t var_id)
{
return rule->variables[var_id].kind == EcsRuleVarKindEntity;
}
/* Public function to get the value of a variable. */
ecs_entity_t ecs_rule_variable(
ecs_iter_t *iter,
int32_t var_id)
{
ecs_rule_iter_t *it = &iter->iter.rule;
const ecs_rule_t *rule = it->rule;
/* We can only return entity variables */
if (rule->variables[var_id].kind == EcsRuleVarKindEntity) {
ecs_rule_reg_t *regs = get_register_frame(it, rule->frame_count - 1);
return entity_reg_get(rule, regs, var_id);
} else {
return 0;
}
}
/* Create rule iterator */
ecs_iter_t ecs_rule_iter(
const ecs_world_t *world,
const ecs_rule_t *rule)
{
ecs_iter_t result = {0};
result.world = (ecs_world_t*)world;
result.real_world = (ecs_world_t*)ecs_get_world(rule->world);
ecs_rule_iter_t *it = &result.iter.rule;
it->rule = rule;
if (rule->operation_count) {
if (rule->variable_count) {
it->registers = ecs_os_malloc_n(ecs_rule_reg_t,
rule->operation_count * rule->variable_count);
it->variables = ecs_os_malloc_n(ecs_entity_t, rule->variable_count);
}
it->op_ctx = ecs_os_calloc_n(ecs_rule_op_ctx_t, rule->operation_count);
if (rule->filter.term_count) {
it->columns = ecs_os_malloc_n(int32_t,
rule->operation_count * rule->filter.term_count);
}
}
it->op = 0;
int i;
for (i = 0; i < rule->variable_count; i ++) {
if (rule->variables[i].kind == EcsRuleVarKindEntity) {
entity_reg_set(rule, it->registers, i, EcsWildcard);
} else {
table_reg_set(rule, it->registers, i, NULL);
}
}
result.term_count = rule->filter.term_count;
result.next = ecs_rule_next;
return result;
}
void ecs_rule_iter_free(
ecs_iter_t *iter)
{
ecs_rule_iter_t *it = &iter->iter.rule;
ecs_os_free(it->registers);
ecs_os_free(it->columns);
ecs_os_free(it->op_ctx);
ecs_os_free(it->variables);
it->registers = NULL;
it->columns = NULL;
it->op_ctx = NULL;
flecs_iter_fini(iter);
}
/* Edge case: if the filter has the same variable for both predicate and
* object, they are both resolved at the same time but at the time of
* evaluating the filter they're still wildcards which would match columns
* that have different predicates/objects. Do an additional scan to make
* sure the column we're returning actually matches. */
static
int32_t find_next_same_var(
ecs_type_t type,
int32_t column,
ecs_id_t pattern)
{
/* If same_var is true, this has to be a wildcard pair. We cannot have
* the same variable in a pair, and one part of a pair resolved with
* another part unresolved. */
ecs_assert(pattern == ecs_pair(EcsWildcard, EcsWildcard),
ECS_INTERNAL_ERROR, NULL);
(void)pattern;
/* Keep scanning for an id where rel and obj are the same */
ecs_id_t *ids = ecs_vector_first(type, ecs_id_t);
int32_t i, count = ecs_vector_count(type);
for (i = column + 1; i < count; i ++) {
ecs_id_t id = ids[i];
if (!ECS_HAS_ROLE(id, PAIR)) {
/* If id is not a pair, this will definitely not match, and we
* will find no further matches. */
return -1;
}
if (ECS_PAIR_RELATION(id) == ECS_PAIR_OBJECT(id)) {
/* Found a match! */
return i;
}
}
/* No pairs found with same rel/obj */
return -1;
}
static
int32_t find_next_column(
const ecs_world_t *world,
const ecs_table_t *table,
int32_t column,
ecs_rule_filter_t *filter)
{
ecs_entity_t pattern = filter->mask;
ecs_type_t type = table->type;
if (column == -1) {
ecs_table_record_t *tr = flecs_get_table_record(world, table, pattern);
if (!tr) {
return -1;
}
column = tr->column;
} else {
column ++;
if (ecs_vector_count(table->type) <= column) {
return -1;
}
ecs_id_t *ids = ecs_vector_first(table->type, ecs_id_t);
if (!ecs_id_match(ids[column], pattern)) {
return -1;
}
}
if (filter->same_var) {
column = find_next_same_var(type, column, filter->mask);
}
return column;
}
/* This function finds the next table in a table set, and is used by the select
* operation. The function automatically skips empty tables, so that subsequent
* operations don't waste a lot of processing for nothing. */
static
ecs_table_record_t find_next_table(
ecs_rule_filter_t *filter,
ecs_rule_with_ctx_t *op_ctx)
{
ecs_id_record_t *idr = op_ctx->idr;
const ecs_table_record_t *tables = flecs_id_record_tables(idr);
int32_t i = op_ctx->table_index, count = flecs_id_record_count(idr);
ecs_table_t *table = NULL;
int32_t column = -1;
for (; i < count && (column == -1); i ++) {
const ecs_table_record_t *tr = &tables[i];
table = tr->table;
/* Should only iterate non-empty tables */
ecs_assert(ecs_table_count(table) != 0, ECS_INTERNAL_ERROR, NULL);
column = tr->column;
if (filter->same_var) {
column = find_next_same_var(table->type, column - 1, filter->mask);
}
}
if (column == -1) {
table = NULL;
}
op_ctx->table_index = i;
return (ecs_table_record_t){.table = table, .column = column};
}
static
ecs_id_record_t* find_tables(
ecs_world_t *world,
ecs_id_t id)
{
ecs_id_record_t *idr = flecs_get_id_record(world, id);
if (!flecs_id_record_count(idr)) {
/* Skip ids that don't have (non-empty) tables */
return NULL;
}
return idr;
}
static
ecs_id_t rule_get_column(
ecs_type_t type,
int32_t column)
{
ecs_id_t *comp = ecs_vector_get(type, ecs_id_t, column);
ecs_assert(comp != NULL, ECS_INTERNAL_ERROR, NULL);
return *comp;
}
static
void set_column(
ecs_iter_t *it,
ecs_rule_op_t *op,
ecs_type_t type,
int32_t column)
{
if (op->term == -1) {
/* If operation is not associated with a term, don't set anything */
return;
}
ecs_assert(op->term >= 0, ECS_INTERNAL_ERROR, NULL);
if (type) {
it->ids[op->term] = rule_get_column(type, column);
} else {
it->ids[op->term] = 0;
}
}
static
void set_source(
ecs_iter_t *it,
ecs_rule_op_t *op,
ecs_rule_reg_t *regs,
int32_t r)
{
if (op->term == -1) {
/* If operation is not associated with a term, don't set anything */
return;
}
ecs_assert(op->term >= 0, ECS_INTERNAL_ERROR, NULL);
const ecs_rule_t *rule = it->iter.rule.rule;
if ((r != UINT8_MAX) && rule->variables[r].kind == EcsRuleVarKindEntity) {
it->subjects[op->term] = reg_get_entity(rule, op, regs, r);
} else {
it->subjects[op->term] = 0;
}
}
/* Input operation. The input operation acts as a placeholder for the start of
* the program, and creates an entry in the register array that can serve to
* store variables passed to an iterator. */
static
bool eval_input(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
(void)it;
(void)op;
(void)op_index;
if (!redo) {
/* First operation executed by the iterator. Always return true. */
return true;
} else {
/* When Input is asked to redo, it means that all other operations have
* exhausted their results. Input itself does not yield anything, so
* return false. This will terminate rule execution. */
return false;
}
}
static
bool eval_superset(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
ecs_world_t *world = rule->world;
ecs_rule_superset_ctx_t *op_ctx = &iter->op_ctx[op_index].is.superset;
ecs_rule_superset_frame_t *frame = NULL;
ecs_rule_reg_t *regs = get_registers(iter, op);
/* Get register indices for output */
int32_t sp;
int32_t r = op->r_out;
/* Register cannot be a literal, since we need to store things in it */
ecs_assert(r != UINT8_MAX, ECS_INTERNAL_ERROR, NULL);
/* Superset results are always stored in an entity variable */
ecs_assert(rule->variables[r].kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
/* Get queried for id, fill out potential variables */
ecs_rule_pair_t pair = op->filter;
ecs_rule_filter_t filter = pair_to_filter(iter, op, pair);
ecs_rule_filter_t super_filter = {
.mask = ecs_pair(ECS_PAIR_RELATION(filter.mask), EcsWildcard)
};
ecs_table_t *table = NULL;
if (!redo) {
op_ctx->stack = op_ctx->storage;
sp = op_ctx->sp = 0;
frame = &op_ctx->stack[sp];
/* Get table of object for which to get supersets */
ecs_entity_t obj = ECS_PAIR_OBJECT(filter.mask);
/* If obj is wildcard, there's nothing to determine a superset for */
ecs_assert(obj != EcsWildcard, ECS_INTERNAL_ERROR, NULL);
/* Find first matching column in table */
table = table_from_entity(world, obj);
int32_t column = find_next_column(world, table, -1, &super_filter);
/* If no matching column was found, there are no supersets */
if (column == -1) {
return false;
}
ecs_entity_t col_entity = rule_get_column(table->type, column);
ecs_entity_t col_obj = ecs_entity_t_lo(col_entity);
entity_reg_set(rule, regs, r, col_obj);
set_column(it, op, table->type, column);
frame->table = table;
frame->column = column;
return true;
}
sp = op_ctx->sp;
frame = &op_ctx->stack[sp];
table = frame->table;
int32_t column = frame->column;
ecs_entity_t col_entity = rule_get_column(table->type, column);
ecs_entity_t col_obj = ecs_entity_t_lo(col_entity);
ecs_table_t *next_table = table_from_entity(world, col_obj);
if (next_table) {
sp ++;
frame = &op_ctx->stack[sp];
frame->table = next_table;
frame->column = -1;
}
do {
frame = &op_ctx->stack[sp];
table = frame->table;
column = frame->column;
column = find_next_column(world, table, column, &super_filter);
if (column != -1) {
op_ctx->sp = sp;
frame->column = column;
col_entity = rule_get_column(table->type, column);
col_obj = ecs_entity_t_lo(col_entity);
entity_reg_set(rule, regs, r, col_obj);
set_column(it, op, table->type, column);
return true;
}
sp --;
} while (sp >= 0);
return false;
}
static
bool eval_subset(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
ecs_world_t *world = rule->world;
ecs_rule_subset_ctx_t *op_ctx = &iter->op_ctx[op_index].is.subset;
ecs_rule_subset_frame_t *frame = NULL;
ecs_table_record_t table_record;
ecs_rule_reg_t *regs = get_registers(iter, op);
/* Get register indices for output */
int32_t sp, row;
int32_t r = op->r_out;
ecs_assert(r != UINT8_MAX, ECS_INTERNAL_ERROR, NULL);
/* Get queried for id, fill out potential variables */
ecs_rule_pair_t pair = op->filter;
ecs_rule_filter_t filter = pair_to_filter(iter, op, pair);
ecs_id_record_t *idr;
ecs_table_t *table = NULL;
if (!redo) {
op_ctx->stack = op_ctx->storage;
sp = op_ctx->sp = 0;
frame = &op_ctx->stack[sp];
idr = frame->with_ctx.idr = find_tables(world, filter.mask);
if (!idr) {
return false;
}
frame->with_ctx.table_index = 0;
table_record = find_next_table(&filter, &frame->with_ctx);
/* If first table set has no non-empty table, yield nothing */
if (!table_record.table) {
return false;
}
frame->row = 0;
frame->column = table_record.column;
table_reg_set(rule, regs, r, (frame->table = table_record.table));
set_column(it, op, table_record.table->type, table_record.column);
return true;
}
do {
sp = op_ctx->sp;
frame = &op_ctx->stack[sp];
table = frame->table;
row = frame->row;
/* If row exceeds number of elements in table, find next table in frame that
* still has entities */
while ((sp >= 0) && (row >= ecs_table_count(table))) {
table_record = find_next_table(&filter, &frame->with_ctx);
if (table_record.table) {
table = frame->table = table_record.table;
ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL);
frame->row = 0;
frame->column = table_record.column;
set_column(it, op, table_record.table->type, table_record.column);
table_reg_set(rule, regs, r, table);
return true;
} else {
sp = -- op_ctx->sp;
if (sp < 0) {
/* If none of the frames yielded anything, no more data */
return false;
}
frame = &op_ctx->stack[sp];
table = frame->table;
idr = frame->with_ctx.idr;
row = ++ frame->row;
ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(idr != NULL, ECS_INTERNAL_ERROR, NULL);
}
}
int32_t row_count = ecs_table_count(table);
/* Table must have at least row elements */
ecs_assert(row_count > row, ECS_INTERNAL_ERROR, NULL);
ecs_entity_t *entities = ecs_vector_first(
table->storage.entities, ecs_entity_t);
ecs_assert(entities != NULL, ECS_INTERNAL_ERROR, NULL);
/* The entity used to find the next table set */
do {
ecs_entity_t e = entities[row];
/* Create look_for expression with the resolved entity as object */
pair.reg_mask &= ~RULE_PAIR_OBJECT; /* turn of bit because it's not a reg */
pair.obj.ent = e;
filter = pair_to_filter(iter, op, pair);
/* Find table set for expression */
table = NULL;
idr = find_tables(world, filter.mask);
/* If table set is found, find first non-empty table */
if (idr) {
ecs_rule_subset_frame_t *new_frame = &op_ctx->stack[sp + 1];
new_frame->with_ctx.idr = idr;
new_frame->with_ctx.table_index = 0;
table_record = find_next_table(&filter, &new_frame->with_ctx);
/* If set contains non-empty table, push it to stack */
if (table_record.table) {
table = table_record.table;
op_ctx->sp ++;
new_frame->table = table;
new_frame->row = 0;
new_frame->column = table_record.column;
frame = new_frame;
}
}
/* If no table was found for the current entity, advance row */
if (!table) {
row = ++ frame->row;
}
} while (!table && row < row_count);
} while (!table);
table_reg_set(rule, regs, r, table);
set_column(it, op, table->type, frame->column);
return true;
}
/* Select operation. The select operation finds and iterates a table set that
* corresponds to its pair expression. */
static
bool eval_select(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
ecs_world_t *world = rule->world;
ecs_rule_with_ctx_t *op_ctx = &iter->op_ctx[op_index].is.with;
ecs_table_record_t table_record;
ecs_rule_reg_t *regs = get_registers(iter, op);
/* Get register indices for output */
int32_t r = op->r_out;
ecs_assert(r != UINT8_MAX, ECS_INTERNAL_ERROR, NULL);
/* Get queried for id, fill out potential variables */
ecs_rule_pair_t pair = op->filter;
ecs_rule_filter_t filter = pair_to_filter(iter, op, pair);
ecs_entity_t pattern = filter.mask;
int32_t *columns = rule_get_columns(iter, op);
int32_t column = -1;
ecs_table_t *table = NULL;
ecs_id_record_t *idr;
if (!redo && op->term != -1) {
it->ids[op->term] = pattern;
columns[op->term] = -1;
}
/* If this is a redo, we already looked up the table set */
if (redo) {
idr = op_ctx->idr;
/* If this is not a redo lookup the table set. Even though this may not be
* the first time the operation is evaluated, variables may have changed
* since last time, which could change the table set to lookup. */
} else {
/* A table set is a set of tables that all contain at least the
* requested look_for expression. What is returned is a table record,
* which in addition to the table also stores the first occurrance at
* which the requested expression occurs in the table. This reduces (and
* in most cases eliminates) any searching that needs to occur in a
* table type. Tables are also registered under wildcards, which is why
* this operation can simply use the look_for variable directly */
idr = op_ctx->idr = find_tables(world, pattern);
}
/* If no table set was found for queried for entity, there are no results */
if (!idr) {
return false;
}
/* If this is not a redo, start at the beginning */
if (!redo) {
op_ctx->table_index = 0;
/* Return the first table_record in the table set. */
table_record = find_next_table(&filter, op_ctx);
/* If no table record was found, there are no results. */
if (!table_record.table) {
return false;
}
table = table_record.table;
/* Set current column to first occurrence of queried for entity */
column = columns[op->term] = table_record.column;
/* Store table in register */
table_reg_set(rule, regs, r, table);
/* If this is a redo, progress to the next match */
} else {
/* First test if there are any more matches for the current table, in
* case we're looking for a wildcard. */
if (filter.wildcard) {
table = table_reg_get(rule, regs, r);
ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL);
column = columns[op->term];
column = find_next_column(world, table, column, &filter);
columns[op->term] = column;
}
/* If no next match was found for this table, move to next table */
if (column == -1) {
table_record = find_next_table(&filter, op_ctx);
if (!table_record.table) {
return false;
}
/* Assign new table to table register */
table_reg_set(rule, regs, r, (table = table_record.table));
/* Assign first matching column */
column = columns[op->term] = table_record.column;
}
}
/* If we got here, we found a match. Table and column must be set */
ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(column != -1, ECS_INTERNAL_ERROR, NULL);
/* If this is a wildcard query, fill out the variable registers */
if (filter.wildcard) {
reify_variables(iter, op, &filter, table->type, column);
}
if (!pair.obj_0) {
set_column(it, op, table->type, column);
}
return true;
}
/* With operation. The With operation always comes after either the Select or
* another With operation, and applies additional filters to the table. */
static
bool eval_with(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
ecs_world_t *world = rule->world;
ecs_rule_with_ctx_t *op_ctx = &iter->op_ctx[op_index].is.with;
ecs_rule_reg_t *regs = get_registers(iter, op);
/* Get register indices for input */
int32_t r = op->r_in;
/* Get queried for id, fill out potential variables */
ecs_rule_pair_t pair = op->filter;
ecs_rule_filter_t filter = pair_to_filter(iter, op, pair);
int32_t *columns = rule_get_columns(iter, op);
/* If looked for entity is not a wildcard (meaning there are no unknown/
* unconstrained variables) and this is a redo, nothing more to yield. */
if (redo && !filter.wildcard) {
return false;
}
int32_t column = -1;
ecs_table_t *table = NULL;
ecs_id_record_t *idr;
if (!redo && op->term != -1) {
columns[op->term] = -1;
}
/* If this is a redo, we already looked up the table set */
if (redo) {
idr = op_ctx->idr;
/* If this is not a redo lookup the table set. Even though this may not be
* the first time the operation is evaluated, variables may have changed
* since last time, which could change the table set to lookup. */
} else {
/* Transitive queries are inclusive, which means that if we have a
* transitive predicate which is provided with the same subject and
* object, it should return true. By default with will not return true
* as the subject likely does not have itself as a relationship, which
* is why this is a special case.
*
* TODO: might want to move this code to a separate with_inclusive
* instruction to limit branches for non-transitive queries (and to keep
* code more readable).
*/
if (pair.transitive && pair.inclusive) {
ecs_entity_t subj = 0, obj = 0;
if (r == UINT8_MAX) {
subj = op->subject;
} else {
ecs_rule_var_t *v_subj = &rule->variables[r];
if (v_subj->kind == EcsRuleVarKindEntity) {
subj = entity_reg_get(rule, regs, r);
/* This is the input for the op, so should always be set */
ecs_assert(subj != 0, ECS_INTERNAL_ERROR, NULL);
}
}
/* If subj is set, it means that it is an entity. Try to also
* resolve the object. */
if (subj) {
/* If the object is not a wildcard, it has been reified. Get the
* value from either the register or as a literal */
if (!filter.obj_wildcard) {
obj = ecs_entity_t_lo(filter.mask);
if (subj == obj) {
it->ids[op->term] = filter.mask;
return true;
}
}
}
}
/* The With operation finds the table set that belongs to its pair
* filter. The table set is a sparse set that provides an O(1) operation
* to check whether the current table has the required expression. */
idr = op_ctx->idr = find_tables(world, filter.mask);
}
/* If no table set was found for queried for entity, there are no results.
* If this result is a transitive query, the table we're evaluating may not
* be in the returned table set. Regardless, if the filter that contains a
* transitive predicate does not have any tables associated with it, there
* can be no transitive matches for the filter. */
if (!idr) {
return false;
}
table = reg_get_table(rule, op, regs, r);
if (!table) {
return false;
}
/* If this is not a redo, start at the beginning */
if (!redo) {
column = find_next_column(world, table, -1, &filter);
/* If this is a redo, progress to the next match */
} else {
if (!filter.wildcard) {
return false;
}
/* Find the next match for the expression in the column. The columns
* array keeps track of the state for each With operation, so that
* even after redoing a With, the search doesn't have to start from
* the beginning. */
column = find_next_column(world, table, columns[op->term], &filter);
}
/* If no next match was found for this table, no more data */
if (column == -1) {
return false;
}
columns[op->term] = column;
/* If we got here, we found a match. Table and column must be set */
ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL);
ecs_assert(column != -1, ECS_INTERNAL_ERROR, NULL);
/* If this is a wildcard query, fill out the variable registers */
if (filter.wildcard) {
reify_variables(iter, op, &filter, table->type, column);
}
if (!pair.obj_0) {
set_column(it, op, table->type, column);
}
set_source(it, op, regs, r);
return true;
}
/* Each operation. The each operation is a simple operation that takes a table
* as input, and outputs each of the entities in a table. This operation is
* useful for rules that match a table, and where the entities of the table are
* used as predicate or object. If a rule contains an each operation, an
* iterator is guaranteed to yield an entity instead of a table. The input for
* an each operation can only be the root variable. */
static
bool eval_each(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
ecs_rule_each_ctx_t *op_ctx = &iter->op_ctx[op_index].is.each;
ecs_rule_reg_t *regs = get_registers(iter, op);
int32_t r_in = op->r_in;
int32_t r_out = op->r_out;
ecs_entity_t e;
/* Make sure in/out registers are of the correct kind */
ecs_assert(iter->rule->variables[r_in].kind == EcsRuleVarKindTable,
ECS_INTERNAL_ERROR, NULL);
ecs_assert(iter->rule->variables[r_out].kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
/* Get table, make sure that it contains data. The select operation should
* ensure that empty tables are never forwarded. */
ecs_table_t *table = table_reg_get(iter->rule, regs, r_in);
if (table) {
int32_t row, count = regs[r_in].count;
int32_t offset = regs[r_in].offset;
if (!count) {
count = ecs_table_count(table);
ecs_assert(count != 0, ECS_INTERNAL_ERROR, NULL);
} else {
count += offset;
}
ecs_entity_t *entities = ecs_vector_first(
table->storage.entities, ecs_entity_t);
ecs_assert(entities != NULL, ECS_INTERNAL_ERROR, NULL);
/* If this is is not a redo, start from row 0, otherwise go to the
* next entity. */
if (!redo) {
row = op_ctx->row = offset;
} else {
row = ++ op_ctx->row;
}
/* If row exceeds number of entities in table, return false */
if (row >= count) {
return false;
}
/* Skip builtin entities that could confuse operations */
e = entities[row];
while (e == EcsWildcard || e == EcsThis) {
row ++;
if (row == count) {
return false;
}
e = entities[row];
}
} else {
if (!redo) {
e = entity_reg_get(iter->rule, regs, r_in);
} else {
return false;
}
}
/* Assign entity */
entity_reg_set(iter->rule, regs, r_out, e);
return true;
}
/* Store operation. Stores entity in register. This can either be an entity
* literal or an entity variable that will be stored in a table register. The
* latter facilitates scenarios where an iterator only need to return a single
* entity but where the Yield returns tables. */
static
bool eval_store(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
(void)op_index;
if (redo) {
/* Only ever return result once */
return false;
}
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
ecs_rule_reg_t *regs = get_registers(iter, op);
int32_t r_in = op->r_in;
int32_t r_out = op->r_out;
ecs_entity_t e = reg_get_entity(rule, op, regs, r_in);
reg_set_entity(rule, regs, r_out, e);
if (op->term >= 0) {
ecs_rule_filter_t filter = pair_to_filter(iter, op, op->filter);
it->ids[op->term] = filter.mask;
}
return true;
}
/* A setjmp operation sets the jump label for a subsequent jump label. When the
* operation is first evaluated (redo=false) it sets the label to the on_pass
* label, and returns true. When the operation is evaluated again (redo=true)
* the label is set to on_fail and the operation returns false. */
static
bool eval_setjmp(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
ecs_rule_iter_t *iter = &it->iter.rule;
ecs_rule_setjmp_ctx_t *ctx = &iter->op_ctx[op_index].is.setjmp;
if (!redo) {
ctx->label = op->on_pass;
return true;
} else {
ctx->label = op->on_fail;
return false;
}
}
/* The jump operation jumps to an operation label. The operation always returns
* true. Since the operation modifies the control flow of the program directly,
* the dispatcher does not look at the on_pass or on_fail labels of the jump
* instruction. Instead, the on_pass label is used to store the label of the
* operation that contains the label to jump to. */
static
bool eval_jump(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
(void)it;
(void)op;
(void)op_index;
/* Passthrough, result is not used for control flow */
return !redo;
}
/* The not operation reverts the result of the operation it embeds */
static
bool eval_not(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
(void)it;
(void)op;
(void)op_index;
return !redo;
}
/* Yield operation. This is the simplest operation, as all it does is return
* false. This will move the solver back to the previous instruction which
* forces redo's on previous operations, for as long as there are matching
* results. */
static
bool eval_yield(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
(void)it;
(void)op;
(void)op_index;
(void)redo;
/* Yield always returns false, because there are never any operations after
* a yield. */
return false;
}
/* Dispatcher for operations */
static
bool eval_op(
ecs_iter_t *it,
ecs_rule_op_t *op,
int32_t op_index,
bool redo)
{
switch(op->kind) {
case EcsRuleInput:
return eval_input(it, op, op_index, redo);
case EcsRuleSelect:
return eval_select(it, op, op_index, redo);
case EcsRuleWith:
return eval_with(it, op, op_index, redo);
case EcsRuleSubSet:
return eval_subset(it, op, op_index, redo);
case EcsRuleSuperSet:
return eval_superset(it, op, op_index, redo);
case EcsRuleEach:
return eval_each(it, op, op_index, redo);
case EcsRuleStore:
return eval_store(it, op, op_index, redo);
case EcsRuleSetJmp:
return eval_setjmp(it, op, op_index, redo);
case EcsRuleJump:
return eval_jump(it, op, op_index, redo);
case EcsRuleNot:
return eval_not(it, op, op_index, redo);
case EcsRuleYield:
return eval_yield(it, op, op_index, redo);
default:
return false;
}
}
/* Utility to copy all registers to the next frame. Keeping track of register
* values for each operation is necessary, because if an operation is asked to
* redo matching, it must to be able to pick up from where it left of */
static
void push_registers(
ecs_rule_iter_t *it,
int32_t cur,
int32_t next)
{
if (!it->rule->variable_count) {
return;
}
ecs_rule_reg_t *src_regs = get_register_frame(it, cur);
ecs_rule_reg_t *dst_regs = get_register_frame(it, next);
ecs_os_memcpy_n(dst_regs, src_regs,
ecs_rule_reg_t, it->rule->variable_count);
}
/* Utility to copy all columns to the next frame. Columns keep track of which
* columns are currently being evaluated for a table, and are populated by the
* Select and With operations. The columns array is important, as it is used
* to tell the application where to find component data. */
static
void push_columns(
ecs_rule_iter_t *it,
int32_t cur,
int32_t next)
{
if (!it->rule->filter.term_count) {
return;
}
int32_t *src_cols = rule_get_columns_frame(it, cur);
int32_t *dst_cols = rule_get_columns_frame(it, next);
ecs_os_memcpy_n(dst_cols, src_cols, int32_t, it->rule->filter.term_count);
}
/* Set iterator data from table */
static
void set_iter_table(
ecs_iter_t *it,
ecs_table_t *table,
int32_t offset)
{
/* Tell the iterator how many entities there are */
it->count = ecs_table_count(table);
ecs_assert(it->count != 0, ECS_INTERNAL_ERROR, NULL);
/* Set the entities array */
ecs_entity_t *entities = ecs_vector_first(
table->storage.entities, ecs_entity_t);
ecs_assert(entities != NULL, ECS_INTERNAL_ERROR, NULL);
it->entities = &entities[offset];
/* Set table parameters */
it->table = table;
it->type = table->type;
ecs_assert(table->type != NULL, ECS_INTERNAL_ERROR, NULL);
}
/* Populate iterator with data before yielding to application */
static
void populate_iterator(
const ecs_rule_t *rule,
ecs_iter_t *iter,
ecs_rule_iter_t *it,
ecs_rule_op_t *op)
{
int32_t r = op->r_in;
ecs_rule_reg_t *regs = get_register_frame(it, op->frame);
/* If the input register for the yield does not point to a variable,
* the rule doesn't contain a this (.) variable. In that case, the
* iterator doesn't contain any data, and this function will simply
* return true or false. An application will still be able to obtain
* the variables that were resolved. */
if (r == UINT8_MAX) {
iter->count = 0;
} else {
ecs_rule_var_t *var = &rule->variables[r];
ecs_rule_reg_t *reg = ®s[r];
if (var->kind == EcsRuleVarKindTable) {
ecs_table_t *table = table_reg_get(rule, regs, r);
int32_t count = regs[r].count;
int32_t offset = regs[r].offset;
set_iter_table(iter, table, offset);
if (count) {
iter->offset = offset;
iter->count = count;
}
} else {
/* If a single entity is returned, simply return the
* iterator with count 1 and a pointer to the entity id */
ecs_assert(var->kind == EcsRuleVarKindEntity,
ECS_INTERNAL_ERROR, NULL);
ecs_entity_t e = reg->entity;
ecs_record_t *record = ecs_eis_get(rule->world, e);
bool is_monitored;
int32_t offset = iter->offset = flecs_record_to_row(
record->row, &is_monitored);
/* If an entity is not stored in a table, it could not have
* been matched by anything */
ecs_assert(record != NULL, ECS_INTERNAL_ERROR, NULL);
set_iter_table(iter, record->table, offset);
iter->count = 1;
}
}
int32_t i, variable_count = rule->variable_count;
int32_t term_count = rule->filter.term_count;
iter->variable_count = variable_count;
iter->variable_names = rule->variable_names;
iter->variables = it->variables;
for (i = 0; i < variable_count; i ++) {
if (rule->variables[i].kind == EcsRuleVarKindEntity) {
it->variables[i] = regs[i].entity;
} else {
it->variables[i] = 0;
}
}
for (i = 0; i < term_count; i ++) {
int32_t v = rule->subject_variables[i];
if (v != -1) {
ecs_rule_var_t *var = &rule->variables[v];
if (var->kind == EcsRuleVarKindEntity) {
iter->subjects[i] = regs[var->id].entity;
}
}
}
/* Iterator expects column indices to start at 1 */
iter->columns = rule_get_columns_frame(it, op->frame);
for (i = 0; i < term_count; i ++) {
iter->columns[i] ++;
}
}
static
bool is_control_flow(
ecs_rule_op_t *op)
{
switch(op->kind) {
case EcsRuleSetJmp:
case EcsRuleJump:
return true;
default:
return false;
}
}
/* Iterator next function. This evaluates the program until it reaches a Yield
* operation, and returns the intermediate result(s) to the application. An
* iterator can, depending on the program, either return a table, entity, or
* just true/false, in case a rule doesn't contain the this variable. */
bool ecs_rule_next(
ecs_iter_t *it)
{
ecs_assert(it != NULL, ECS_INVALID_PARAMETER, NULL);
ecs_assert(it->next == ecs_rule_next, ECS_INVALID_PARAMETER, NULL);
ecs_rule_iter_t *iter = &it->iter.rule;
const ecs_rule_t *rule = iter->rule;
bool redo = iter->redo;
int32_t last_frame = -1;
bool init_subjects = it->subjects == NULL;
/* Can't iterate an iterator that's already depleted */
ecs_assert(iter->op != -1, ECS_INVALID_PARAMETER, NULL);
flecs_iter_init(it);
/* Make sure that if there are any terms with literal subjects, they're
* initialized in the subjects array */
if (init_subjects) {
int32_t i;
for (i = 0; i < rule->filter.term_count; i ++) {
ecs_term_t *t = &rule->filter.terms[i];
ecs_term_id_t *subj = &t->args[0];
if (subj->var == EcsVarIsEntity && subj->entity != EcsThis) {
it->subjects[i] = subj->entity;
}
}
for (i = 0; i < rule->filter.term_count; i ++) {
ecs_term_t *term = &rule->filter.terms[i];
if (term->args[0].set.mask & EcsNothing ||
term->oper == EcsNot ||
term->oper == EcsOptional ||
term->id == ecs_pair(EcsChildOf, 0)) {
it->ids[i] = term->id;
}
}
}
do {
/* Evaluate an operation. The result of an operation determines the
* flow of the program. If an operation returns true, the program
* continues to the operation pointed to by 'on_pass'. If the operation
* returns false, the program continues to the operation pointed to by
* 'on_fail'.
*
* In most scenarios, on_pass points to the next operation, and on_fail
* points to the previous operation.
*
* When an operation fails, the previous operation will be invoked with
* redo=true. This will cause the operation to continue its search from
* where it left off. When the operation succeeds, the next operation
* will be invoked with redo=false. This causes the operation to start
* from the beginning, which is necessary since it just received a new
* input. */
int32_t op_index = iter->op;
ecs_rule_op_t *op = &rule->operations[op_index];
int32_t cur = op->frame;
/* If this is not the first operation and is also not a control flow
* operation, push a new frame on the stack for the next operation */
if (!redo && !is_control_flow(op) && cur && cur != last_frame) {
int32_t prev = cur - 1;
push_registers(iter, prev, cur);
push_columns(iter, prev, cur);
}
/* Dispatch the operation */
bool result = eval_op(it, op, op_index, redo);
iter->op = result ? op->on_pass : op->on_fail;
/* If the current operation is yield, return results */
if (op->kind == EcsRuleYield) {
populate_iterator(rule, it, iter, op);
iter->redo = true;
return true;
}
/* If the current operation is a jump, goto stored label */
if (op->kind == EcsRuleJump) {
/* Label is stored in setjmp context */
iter->op = iter->op_ctx[op->on_pass].is.setjmp.label;
}
/* If jumping backwards, it's a redo */
redo = iter->op <= op_index;
if (!is_control_flow(op)) {
last_frame = op->frame;
}
} while (iter->op != -1);
ecs_rule_iter_free(it);
return false;
}
#endif
| 31.622702 | 90 | 0.612522 |
96136745977b72525247f8ef3e6a3cbdf4053de5 | 3,790 | c | C | NR2.0ANSI_v2.06_double/C_recipes/fourfs.c | utrad-ical/LibPR | d14c8215079b5bd5d44acc92695e1f8faab53c54 | [
"BSD-2-Clause"
] | null | null | null | NR2.0ANSI_v2.06_double/C_recipes/fourfs.c | utrad-ical/LibPR | d14c8215079b5bd5d44acc92695e1f8faab53c54 | [
"BSD-2-Clause"
] | null | null | null | NR2.0ANSI_v2.06_double/C_recipes/fourfs.c | utrad-ical/LibPR | d14c8215079b5bd5d44acc92695e1f8faab53c54 | [
"BSD-2-Clause"
] | null | null | null | #include <stdio.h>
#include <math.h>
#define NRANSI
#include "nrutil.h"
#define KBF 128
void fourfs(FILE *file[5], unsigned long nn[], int ndim, int isign)
{
void fourew(FILE *file[5], int *na, int *nb, int *nc, int *nd);
unsigned long j,j12,jk,k,kk,n=1,mm,kc=0,kd,ks,kr,nr,ns,nv;
int cc,na,nb,nc,nd;
double tempr,tempi,*afa,*afb,*afc;
double wr,wi,wpr,wpi,wtemp,theta;
static int mate[5] = {0,2,1,4,3};
afa=vector(1,KBF);
afb=vector(1,KBF);
afc=vector(1,KBF);
for (j=1;j<=ndim;j++) {
n *= nn[j];
if (nn[j] <= 1) nrerror("invalid double or wrong ndim in fourfs");
}
nv=1;
jk=nn[nv];
mm=n;
ns=n/KBF;
nr=ns >> 1;
kd=KBF >> 1;
ks=n;
fourew(file,&na,&nb,&nc,&nd);
for (;;) {
theta=isign*3.141592653589793/(n/mm);
wtemp=sin(0.5*theta);
wpr = -2.0*wtemp*wtemp;
wpi=sin(theta);
wr=1.0;
wi=0.0;
mm >>= 1;
for (j12=1;j12<=2;j12++) {
kr=0;
do {
cc=fread(&afa[1],sizeof(double),KBF,file[na]);
if (cc != KBF) nrerror("read error in fourfs");
cc=fread(&afb[1],sizeof(double),KBF,file[nb]);
if (cc != KBF) nrerror("read error in fourfs");
for (j=1;j<=KBF;j+=2) {
tempr=((double)wr)*afb[j]-((double)wi)*afb[j+1];
tempi=((double)wi)*afb[j]+((double)wr)*afb[j+1];
afb[j]=afa[j]-tempr;
afa[j] += tempr;
afb[j+1]=afa[j+1]-tempi;
afa[j+1] += tempi;
}
kc += kd;
if (kc == mm) {
kc=0;
wr=(wtemp=wr)*wpr-wi*wpi+wr;
wi=wi*wpr+wtemp*wpi+wi;
}
cc=fwrite(&afa[1],sizeof(double),KBF,file[nc]);
if (cc != KBF) nrerror("write error in fourfs");
cc=fwrite(&afb[1],sizeof(double),KBF,file[nd]);
if (cc != KBF) nrerror("write error in fourfs");
} while (++kr < nr);
if (j12 == 1 && ks != n && ks == KBF) {
na=mate[na];
nb=na;
}
if (nr == 0) break;
}
fourew(file,&na,&nb,&nc,&nd);
jk >>= 1;
while (jk == 1) {
mm=n;
jk=nn[++nv];
}
ks >>= 1;
if (ks > KBF) {
for (j12=1;j12<=2;j12++) {
for (kr=1;kr<=ns;kr+=ks/KBF) {
for (k=1;k<=ks;k+=KBF) {
cc=fread(&afa[1],sizeof(double),KBF,file[na]);
if (cc != KBF) nrerror("read error in fourfs");
cc=fwrite(&afa[1],sizeof(double),KBF,file[nc]);
if (cc != KBF) nrerror("write error in fourfs");
}
nc=mate[nc];
}
na=mate[na];
}
fourew(file,&na,&nb,&nc,&nd);
} else if (ks == KBF) nb=na;
else break;
}
j=1;
for (;;) {
theta=isign*3.141592653589793/(n/mm);
wtemp=sin(0.5*theta);
wpr = -2.0*wtemp*wtemp;
wpi=sin(theta);
wr=1.0;
wi=0.0;
mm >>= 1;
ks=kd;
kd >>= 1;
for (j12=1;j12<=2;j12++) {
for (kr=1;kr<=ns;kr++) {
cc=fread(&afc[1],sizeof(double),KBF,file[na]);
if (cc != KBF) nrerror("read error in fourfs");
kk=1;
k=ks+1;
for (;;) {
tempr=((double)wr)*afc[kk+ks]-((double)wi)*afc[kk+ks+1];
tempi=((double)wi)*afc[kk+ks]+((double)wr)*afc[kk+ks+1];
afa[j]=afc[kk]+tempr;
afb[j]=afc[kk]-tempr;
afa[++j]=afc[++kk]+tempi;
afb[j++]=afc[kk++]-tempi;
if (kk < k) continue;
kc += kd;
if (kc == mm) {
kc=0;
wr=(wtemp=wr)*wpr-wi*wpi+wr;
wi=wi*wpr+wtemp*wpi+wi;
}
kk += ks;
if (kk > KBF) break;
else k=kk+ks;
}
if (j > KBF) {
cc=fwrite(&afa[1],sizeof(double),KBF,file[nc]);
if (cc != KBF) nrerror("write error in fourfs");
cc=fwrite(&afb[1],sizeof(double),KBF,file[nd]);
if (cc != KBF) nrerror("write error in fourfs");
j=1;
}
}
na=mate[na];
}
fourew(file,&na,&nb,&nc,&nd);
jk >>= 1;
if (jk > 1) continue;
mm=n;
do {
if (nv < ndim) jk=nn[++nv];
else {
free_vector(afc,1,KBF);
free_vector(afb,1,KBF);
free_vector(afa,1,KBF);
return;
}
} while (jk == 1);
}
}
#undef KBF
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software 9.1-5i. */
| 23.987342 | 68 | 0.529288 |
c582d29dabe38df61e5b50c7a031c9b6bf32116c | 2,442 | h | C | plugin/pxr/maya/lib/usdMaya/colorSpace.h | sopvop/maya-usd | c567a1661152ec2450359767fa2b0ca8cac4dc83 | [
"Apache-2.0"
] | 4 | 2019-11-19T14:58:17.000Z | 2021-03-27T02:27:43.000Z | plugin/pxr/maya/lib/usdMaya/colorSpace.h | ZhongLingXiao/maya-usd | c567a1661152ec2450359767fa2b0ca8cac4dc83 | [
"Apache-2.0"
] | 2 | 2019-08-14T20:44:09.000Z | 2020-01-07T09:12:03.000Z | plugin/pxr/maya/lib/usdMaya/colorSpace.h | ZhongLingXiao/maya-usd | c567a1661152ec2450359767fa2b0ca8cac4dc83 | [
"Apache-2.0"
] | 1 | 2019-08-14T14:33:41.000Z | 2019-08-14T14:33:41.000Z | //
// Copyright 2018 Pixar
//
// 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 PXRUSDMAYA_COLORSPACE_H
#define PXRUSDMAYA_COLORSPACE_H
/// \file usdMaya/colorSpace.h
#include "usdMaya/api.h"
#include "pxr/pxr.h"
#include "pxr/base/gf/gamma.h"
PXR_NAMESPACE_OPEN_SCOPE
/// Helper functions for dealing with colors stored in Maya.
///
/// Technically, this doesn't need to be tied to Usd.
namespace UsdMayaColorSpace
{
/// Returns true if we treat colors from Maya as linear colors.
///
/// Before color management (viewport 1.0), all Maya colors were stored with
/// gamma correction. When we have a mix of shapes we need to draw, some shaded
/// via native Maya and others with our custom shapes, we need to know if the
/// Maya colors are considered linear or not. If things are color correct, our
/// shape needs to write linear colors to the framebuffer and we leave the final
/// correction up to Maya. Otherwise, we want to draw things as if they were
/// modeled in Maya. While this may not be "correct" in all situations, at
/// least it is consistent with native Maya shading.
///
/// Currently, this value is controlled via an environment variable:
///
/// PIXMAYA_LINEAR_COLORS
///
/// You should only be setting that if you've more or less fully switched to
/// Viewport 2.0 (as proper color management is only supported there).
///
PXRUSDMAYA_API
bool
IsColorManaged();
/// Converts a linear color into the appropriate Maya color space as determined by
/// the above \c IsColorManaged.
template <typename T>
T
ConvertLinearToMaya(const T& linearColor)
{
return IsColorManaged() ? linearColor : GfConvertLinearToDisplay(linearColor);
}
/// Converts a Maya color space into a linear color.
template <typename T>
T
ConvertMayaToLinear(const T& mayaColor)
{
return IsColorManaged() ? mayaColor : GfConvertDisplayToLinear(mayaColor);
}
}; // UsdMayaColorSpace
PXR_NAMESPACE_CLOSE_SCOPE
#endif
| 30.525 | 82 | 0.748157 |
04a0c5df85d61f45722780d786926b60cfbfda83 | 1,925 | c | C | AES/src/Main.c | Nordaj/AES | 859d57723c3f072003ccfa1793e7ba224bb87a85 | [
"MIT"
] | null | null | null | AES/src/Main.c | Nordaj/AES | 859d57723c3f072003ccfa1793e7ba224bb87a85 | [
"MIT"
] | null | null | null | AES/src/Main.c | Nordaj/AES | 859d57723c3f072003ccfa1793e7ba224bb87a85 | [
"MIT"
] | 1 | 2020-01-15T02:11:41.000Z | 2020-01-15T02:11:41.000Z | #include <stdio.h>
#include "AES.h"
char pt[] = {
0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
};
const char k128[] = {
0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
};
const char k192[] = {
0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5,
0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B
};
const char k256[] = {
0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81,
0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4
};
const char iv[16] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
};
int main()
{
//Generates a padded byte array on the heap with extra null terminating byte
AESBuffer b = AESGenBuffer("This is a test message");
//Log message
printf("Message: %s\n", b.buf);
printf("Message HEX: \n");
for (int i = 0; i < b.size; i++)
printf("%02X ", b.buf[i]);
printf("\n\n");
//Encrypt
AESEncrypt(AES_CBC_256, b.buf, b.size, k256, iv);
//Log encrypted message
printf("Encrypted Message HEX: \n");
for (int i = 0; i < b.size; i++)
printf("%02X ", b.buf[i]);
printf("\n\n");
//Decrypt
AESDecrypt(AES_CBC_256, b.buf, b.size, k256, iv);
//Log decrypted message
printf("Decrypted Message: %s\n", b.buf);
printf("Decrypted Message HEX: \n");
for (int i = 0; i < b.size; i++)
printf("%02X ", b.buf[i]);
printf("\n\n");
//Finish
AESFreeBuffer(&b);
printf("Any key to exit.");
getchar();
return 0;
}
| 29.166667 | 96 | 0.62961 |
ca2235de37d345ac120c956c8f949f23e338be21 | 9,349 | c | C | examples/cpfskmodem_example.c | gongch/liquid-dsp | 1b715dd0edefc66e1d2a28a5a87461c221173e12 | [
"MIT"
] | null | null | null | examples/cpfskmodem_example.c | gongch/liquid-dsp | 1b715dd0edefc66e1d2a28a5a87461c221173e12 | [
"MIT"
] | null | null | null | examples/cpfskmodem_example.c | gongch/liquid-dsp | 1b715dd0edefc66e1d2a28a5a87461c221173e12 | [
"MIT"
] | 1 | 2020-07-09T05:13:40.000Z | 2020-07-09T05:13:40.000Z | //
// cpfskmodem_example.c
//
// This example demostrates the continuous phase frequency-shift keying
// (CP-FSK) modem in liquid. A message signal is modulated and the
// resulting signal is recovered using a demodulator object.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <math.h>
#include "liquid.h"
#define OUTPUT_FILENAME "cpfskmodem_example.m"
// print usage/help message
void usage()
{
printf("cpfskmodem_example -- continuous-phase frequency-shift keying example\n");
printf("options:\n");
printf(" h : print help\n");
printf(" t : filter type: [square], rcos-full, rcos-half, gmsk\n");
printf(" p : bits/symbol, default: 1\n");
printf(" H : modulation index, default: 0.5\n");
printf(" k : samples/symbol, default: 8\n");
printf(" m : filter delay (symbols), default: 3\n");
printf(" b : filter roll-off, default: 0.35\n");
printf(" n : number of data symbols, default: 80\n");
printf(" s : SNR [dB], default: 40\n");
printf(" F : carrier frequency offset, default: 0\n");
printf(" P : carrier phase offset, default: 0\n");
printf(" T : fractional symbol offset, default: 0\n");
}
int main(int argc, char*argv[])
{
// options
unsigned int bps = 1; // number of bits/symbol
float h = 0.5f; // modulation index (h=1/2 for MSK)
unsigned int k = 4; // filter samples/symbol
unsigned int m = 3; // filter delay (symbols)
float beta = 0.35f; // GMSK bandwidth-time factor
unsigned int num_symbols = 20; // number of data symbols
float SNRdB = 40.0f; // signal-to-noise ratio [dB]
float cfo = 0.0f; // carrier frequency offset
float cpo = 0.0f; // carrier phase offset
float tau = 0.0f; // fractional symbol timing offset
int filter_type = LIQUID_CPFSK_SQUARE;
int dopt;
while ((dopt = getopt(argc,argv,"ht:p:H:k:m:b:n:s:F:P:T:")) != EOF) {
switch (dopt) {
case 'h': usage(); return 0;
case 't':
if (strcmp(optarg,"square")==0) {
filter_type = LIQUID_CPFSK_SQUARE;
} else if (strcmp(optarg,"rcos-full")==0) {
filter_type = LIQUID_CPFSK_RCOS_FULL;
} else if (strcmp(optarg,"rcos-half")==0) {
filter_type = LIQUID_CPFSK_RCOS_PARTIAL;
} else if (strcmp(optarg,"gmsk")==0) {
filter_type = LIQUID_CPFSK_GMSK;
} else {
fprintf(stderr,"error: %s, unknown filter type '%s'\n", argv[0], optarg);
exit(1);
}
break;
case 'p': bps = atoi(optarg); break;
case 'H': h = atof(optarg); break;
case 'k': k = atoi(optarg); break;
case 'm': m = atoi(optarg); break;
case 'b': beta = atof(optarg); break;
case 'n': num_symbols = atoi(optarg); break;
case 's': SNRdB = atof(optarg); break;
case 'F': cfo = atof(optarg); break;
case 'P': cpo = atof(optarg); break;
case 'T': tau = atof(optarg); break;
default:
exit(1);
}
}
unsigned int i;
// derived values
unsigned int num_samples = k*num_symbols;
unsigned int M = 1 << bps; // constellation size
float nstd = powf(10.0f, -SNRdB/20.0f);
// arrays
unsigned int sym_in[num_symbols]; // input symbols
float complex x[num_samples]; // transmitted signal
float complex y[num_samples]; // received signal
unsigned int sym_out[num_symbols]; // output symbols
// create modem objects
cpfskmod mod = cpfskmod_create(bps, h, k, m, beta, filter_type);
cpfskdem dem = cpfskdem_create(bps, h, k, m, beta, filter_type);
// print modulator
cpfskmod_print(mod);
// get full symbol delay
unsigned int delay = cpfskmod_get_delay(mod) + cpfskdem_get_delay(dem);
printf("delay: %u samples\n", delay);
// generate message signal
for (i=0; i<num_symbols; i++) {
sym_in[i] = rand() % M;
printf("sym_in(%3u) = %2u\n", i, sym_in[i]);
}
// modulate signal
for (i=0; i<num_symbols; i++)
cpfskmod_modulate(mod, sym_in[i], &x[k*i]);
// push through channel
float sample_offset = -tau * k;
int sample_delay = (int)roundf(sample_offset);
float dt = sample_offset - (float)sample_delay;
printf("symbol delay : %f\n", tau);
printf("sample delay : %f = %d + %f\n", sample_offset, sample_delay, dt);
firfilt_crcf fchannel = firfilt_crcf_create_kaiser(8*k+2*sample_delay+1, 0.45f, 40.0f, dt);
for (i=0; i<num_samples; i++) {
#if 0
// push through channel delay
firfilt_crcf_push(fchannel, x[i]);
firfilt_crcf_execute(fchannel, &y[i]);
// add carrier frequency/phase offset
y[i] *= cexpf(_Complex_I*(cfo*i + cpo));
// add noise
y[i] += nstd*(randnf() + _Complex_I*randnf())*M_SQRT1_2;
#else
y[i] = x[i];
#endif
}
firfilt_crcf_destroy(fchannel);
// demodulate signal
#if 0
unsigned int nw=0;
cpfskdem_demodulate(dem, y, num_samples, sym_out, &nw);
printf("demodulator wrote %u symbols\n", nw);
#else
for (i=0; i<num_symbols; i++)
sym_out[i] = cpfskdem_demodulate(dem, &y[i*k]);
#endif
// print/count errors
unsigned int num_errors = 0;
for (i=delay; i<num_symbols; i++) {
int is_err = (sym_in[i-delay] == sym_out[i]) ? 0 : 1;
printf(" %3u : %2u %2u %s\n", i, sym_in[i-delay], sym_out[i], is_err ? "*" : "");
num_errors += is_err;
}
printf("errors: %u\n", num_errors);
// destroy modem objects
cpfskmod_destroy(mod);
cpfskdem_destroy(dem);
// compute power spectral density of transmitted signal
unsigned int nfft = 1024;
float psd[nfft];
spgramcf periodogram = spgramcf_create_kaiser(nfft, nfft/2, 8.0f);
spgramcf_estimate_psd(periodogram, x, num_samples, psd);
spgramcf_destroy(periodogram);
//
// export results
//
FILE * fid = fopen(OUTPUT_FILENAME,"w");
fprintf(fid,"%% %s : auto-generated file\n", OUTPUT_FILENAME);
fprintf(fid,"clear all\n");
fprintf(fid,"close all\n");
fprintf(fid,"k = %u;\n", k);
fprintf(fid,"h = %f;\n", h);
fprintf(fid,"num_symbols = %u;\n", num_symbols);
fprintf(fid,"num_samples = %u;\n", num_samples);
fprintf(fid,"nfft = %u;\n", nfft);
fprintf(fid,"delay = %u; %% receive filter delay\n", m);
fprintf(fid,"x = zeros(1,num_samples);\n");
fprintf(fid,"y = zeros(1,num_samples);\n");
for (i=0; i<num_samples; i++) {
fprintf(fid,"x(%4u) = %12.8f + j*%12.8f;\n", i+1, crealf(x[i]), cimagf(x[i]));
fprintf(fid,"y(%4u) = %12.8f + j*%12.8f;\n", i+1, crealf(y[i]), cimagf(y[i]));
}
// save power spectral density
fprintf(fid,"psd = zeros(1,nfft);\n");
for (i=0; i<nfft; i++)
fprintf(fid,"psd(%4u) = %12.8f;\n", i+1, psd[i]);
fprintf(fid,"t=[0:(num_samples-1)]/k;\n");
fprintf(fid,"i = 1:k:num_samples;\n");
fprintf(fid,"figure;\n");
fprintf(fid,"subplot(3,4,1:3);\n");
fprintf(fid," plot(t,real(x),'-', t(i),real(x(i)),'ob',...\n");
fprintf(fid," t,imag(x),'-', t(i),imag(x(i)),'og');\n");
fprintf(fid," axis([0 num_symbols -1.2 1.2]);\n");
fprintf(fid," xlabel('time');\n");
fprintf(fid," ylabel('x(t)');\n");
fprintf(fid," grid on;\n");
fprintf(fid,"subplot(3,4,5:7);\n");
fprintf(fid," plot(t,real(y),'-', t(i),real(y(i)),'ob',...\n");
fprintf(fid," t,imag(y),'-', t(i),imag(y(i)),'og');\n");
fprintf(fid," axis([0 num_symbols -1.2 1.2]);\n");
fprintf(fid," xlabel('time');\n");
fprintf(fid," ylabel('y(t)');\n");
fprintf(fid," grid on;\n");
// plot I/Q constellations
fprintf(fid,"subplot(3,4,4);\n");
fprintf(fid," plot(real(x),imag(x),'-',real(x(i)),imag(x(i)),'rs','MarkerSize',4);\n");
fprintf(fid," xlabel('I');\n");
fprintf(fid," ylabel('Q');\n");
fprintf(fid," axis([-1 1 -1 1]*1.2);\n");
fprintf(fid," axis square;\n");
fprintf(fid," grid on;\n");
fprintf(fid,"subplot(3,4,8);\n");
fprintf(fid," plot(real(y),imag(y),'-',real(y(i)),imag(y(i)),'rs','MarkerSize',4);\n");
fprintf(fid," xlabel('I');\n");
fprintf(fid," ylabel('Q');\n");
fprintf(fid," axis([-1 1 -1 1]*1.2);\n");
fprintf(fid," axis square;\n");
fprintf(fid," grid on;\n");
// plot PSD
fprintf(fid,"f = [0:(nfft-1)]/nfft - 0.5;\n");
fprintf(fid,"subplot(3,4,9:12);\n");
fprintf(fid," plot(f,psd,'LineWidth',1.5);\n");
fprintf(fid," axis([-0.5 0.5 -60 20]);\n");
fprintf(fid," xlabel('Normalized Frequency [f/F_s]');\n");
fprintf(fid," ylabel('PSD [dB]');\n");
fprintf(fid," grid on;\n");
fclose(fid);
printf("results written to '%s'\n", OUTPUT_FILENAME);
return 0;
}
| 38.315574 | 95 | 0.544229 |
a9cf1f943c260a934564a19aecda28c24ccff43c | 1,861 | h | C | paddle/gserver/layers/DataLayer.h | shenchaohua/Paddle | 9c5942db13308d53cc115708058c1e885f4b57a3 | [
"Apache-2.0"
] | 3 | 2018-04-16T23:35:32.000Z | 2019-08-12T01:01:07.000Z | paddle/gserver/layers/DataLayer.h | shenchaohua/Paddle | 9c5942db13308d53cc115708058c1e885f4b57a3 | [
"Apache-2.0"
] | 9 | 2017-09-13T07:39:31.000Z | 2017-10-18T05:58:23.000Z | paddle/gserver/layers/DataLayer.h | shenchaohua/Paddle | 9c5942db13308d53cc115708058c1e885f4b57a3 | [
"Apache-2.0"
] | 2 | 2020-11-04T08:07:46.000Z | 2020-11-06T08:33:24.000Z | /* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <memory>
#include "Layer.h"
namespace paddle {
/**
* This layer just copy data to output, and has no backward propagation.
*
* The config file api is data_layer.
*/
class DataLayer : public Layer {
public:
explicit DataLayer(const LayerConfig& config) : Layer(config) {}
virtual void setData(const Argument& data) { data_ = data; }
/**
* Prefetch sparse matrix/ids only.
*/
void prefetch() override { output_ = data_; }
/**
* Forward propagation. Copy data_ (value, in, grad, ids, cpuSequenceDims,
* sequenceStartPositions, subSequenceStartPositions, strs) to output_.
*/
void forward(PassType passType) override {
Layer::forward(passType);
copyDataToOutput(output_);
if (FLAGS_show_layer_stat) {
showOutputStats();
}
}
/**
* Data layer's backward propagation do nothing.
*/
void backward(const UpdateCallback& callback) override { (void)callback; }
void copyOutputToOtherDevice() override {
for (size_t i = 0; i != outputOtherDevice_.size(); i++) {
copyDataToOutput(outputOtherDevice_[i]);
}
}
private:
void copyDataToOutput(Argument& output);
protected:
Argument data_;
};
typedef std::shared_ptr<DataLayer> DataLayerPtr;
} // namespace paddle
| 26.211268 | 76 | 0.718431 |
a6217e5b26667faa99c8c5748dbd3b82a0a4277d | 2,094 | c | C | DTG/workshop2/SearchFuncAlternative.c | Mikkel-Boje/1semester | 3a7152469c38b28f2f6877fe648e5b7060011c66 | [
"MIT"
] | null | null | null | DTG/workshop2/SearchFuncAlternative.c | Mikkel-Boje/1semester | 3a7152469c38b28f2f6877fe648e5b7060011c66 | [
"MIT"
] | null | null | null | DTG/workshop2/SearchFuncAlternative.c | Mikkel-Boje/1semester | 3a7152469c38b28f2f6877fe648e5b7060011c66 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h> /* Nødvendig for tidtagning */
#define N 8000
void LinSearch(int array[], int n, int x, int print);
void BinSearch(int array[], int n, int x, int print);
int main(void){
int x;
char filename[20];
FILE *myFile;
int array[N];
int k;
int runs = 1000000;
int i;
sprintf(filename, "List%d.txt", N);
printf("Indtast tallet du søger efter\n");
scanf("%d", &x);
myFile = fopen(filename, "r");
/* indlæs fil ind i array */
for (k = 0; k < N; k++){
fscanf(myFile, "%d", &array[k]);
}
fclose(myFile);
printf("Listestørrelsen er %d\n", N);
/* Start tiden */
double startTime = clock();
for (i = 0; i < runs; i++){
BinSearch(array, N, x, 0);
}
/* Slut tiden og print den */
double endTime = clock();
double duration = (endTime - startTime) / CLOCKS_PER_SEC;
printf("BinSearch brugte: %.7fs\n", duration);
/* Start tiden */
startTime = clock();
for (i = 0; i < runs; i++){
LinSearch(array, N, x, 0);
}
/* Slut tiden og print den */
endTime = clock();
duration = (endTime - startTime) / CLOCKS_PER_SEC;
printf("LinSearch brugte: %.7fs\n", duration);
/* Køres en gang for at printe resultat */
LinSearch(array, N, x, 1);
BinSearch(array, N, x, 1);
return 0;
}
void LinSearch(int array[], int n, int x, int print){
int i;
int j;
j = n;
while(i <= j && x != array[i])
{
i += 1;
}
if (print == 1){
if (x == array[i]){
printf("%d er på position %d\n",x,i+1);
}
else {
printf("%d er ikke i listen \n",x);
}
}
}
void BinSearch(int array[], int n, int x, int print){
int i;
int j;
int m;
j = n;
while(i < j)
{
m = floor((i + j) / 2);
if(x > array[m])
{
i = m + 1;
}
else
{
j = m;
}
}
if (print == 1){
if (x == array[i]){
printf("%d er på position %d\n",x,i+1);
}
else {
printf("%d er ikke i listen \n",x);
}
}
}
| 17.45 | 59 | 0.512416 |
107f26ed4182c17e2730b5f6ffdbed88bb55466c | 10,302 | h | C | common/MiniCL/cl_platform.h | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | common/MiniCL/cl_platform.h | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | common/MiniCL/cl_platform.h | skylersaleh/ArgonEngine | 7847269b720892f7e9a64907ec9ee13ab80037fd | [
"MIT"
] | null | null | null | //Generated by the Argon Build System
/**********************************************************************************
* Copyright (c) 2008-2009 The Khronos Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and/or associated documentation files (the
* "Materials"), to deal in the Materials without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Materials, and to
* permit persons to whom the Materials are 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 Materials.
*
* THE MATERIALS ARE 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
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
**********************************************************************************/
#ifndef __CL_PLATFORM_H
#define __CL_PLATFORM_H
#define CL_PLATFORM_MINI_CL 0x12345
struct MiniCLKernelDesc
{
MiniCLKernelDesc(void* pCode, const char* pName);
};
#define MINICL_REGISTER(__kernel_func) static MiniCLKernelDesc __kernel_func##Desc((void*)__kernel_func, #__kernel_func);
#ifdef __APPLE__
/* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
#include <AvailabilityMacros.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define CL_API_ENTRY
#define CL_API_CALL
#ifdef __APPLE__
#define CL_API_SUFFIX__VERSION_1_0 // AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
#else
#define CL_API_SUFFIX__VERSION_1_0
#define CL_EXTENSION_WEAK_LINK
#endif
#if defined (_WIN32) && ! defined (__MINGW32__)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef int8_t cl_char;
typedef uint8_t cl_uchar;
typedef int16_t cl_short ;
typedef uint16_t cl_ushort ;
typedef int32_t cl_int ;
typedef uint32_t cl_uint ;
typedef int64_t cl_long ;
typedef uint64_t cl_ulong ;
typedef uint16_t cl_half ;
typedef float cl_float ;
typedef double cl_double ;
typedef int8_t cl_char2[2] ;
typedef int8_t cl_char4[4] ;
typedef int8_t cl_char8[8] ;
typedef int8_t cl_char16[16] ;
typedef uint8_t cl_uchar2[2] ;
typedef uint8_t cl_uchar4[4] ;
typedef uint8_t cl_uchar8[8] ;
typedef uint8_t cl_uchar16[16] ;
typedef int16_t cl_short2[2] ;
typedef int16_t cl_short4[4] ;
typedef int16_t cl_short8[8] ;
typedef int16_t cl_short16[16] ;
typedef uint16_t cl_ushort2[2] ;
typedef uint16_t cl_ushort4[4] ;
typedef uint16_t cl_ushort8[8] ;
typedef uint16_t cl_ushort16[16] ;
typedef int32_t cl_int2[2] ;
typedef int32_t cl_int4[4] ;
typedef int32_t cl_int8[8] ;
typedef int32_t cl_int16[16] ;
typedef uint32_t cl_uint2[2] ;
typedef uint32_t cl_uint4[4] ;
typedef uint32_t cl_uint8[8] ;
typedef uint32_t cl_uint16[16] ;
typedef int64_t cl_long2[2] ;
typedef int64_t cl_long4[4] ;
typedef int64_t cl_long8[8] ;
typedef int64_t cl_long16[16] ;
typedef uint64_t cl_ulong2[2] ;
typedef uint64_t cl_ulong4[4] ;
typedef uint64_t cl_ulong8[8] ;
typedef uint64_t cl_ulong16[16] ;
typedef float cl_float2[2] ;
typedef float cl_float4[4] ;
typedef float cl_float8[8] ;
typedef float cl_float16[16] ;
typedef double cl_double2[2] ;
typedef double cl_double4[4] ;
typedef double cl_double8[8] ;
typedef double cl_double16[16] ;
#else
#include <stdint.h>
/* scalar types */
typedef int8_t cl_char;
typedef uint8_t cl_uchar;
typedef int16_t cl_short __attribute__((aligned(2)));
typedef uint16_t cl_ushort __attribute__((aligned(2)));
typedef int32_t cl_int __attribute__((aligned(4)));
typedef uint32_t cl_uint __attribute__((aligned(4)));
typedef int64_t cl_long __attribute__((aligned(8)));
typedef uint64_t cl_ulong __attribute__((aligned(8)));
typedef uint16_t cl_half __attribute__((aligned(2)));
typedef float cl_float __attribute__((aligned(4)));
typedef double cl_double __attribute__((aligned(8)));
/*
* Vector types
*
* Note: OpenCL requires that all types be naturally aligned.
* This means that vector types must be naturally aligned.
* For example, a vector of four floats must be aligned to
* a 16 byte boundary (calculated as 4 * the natural 4-byte
* alignment of the float). The alignment qualifiers here
* will only function properly if your compiler supports them
* and if you don't actively work to defeat them. For example,
* in order for a cl_float4 to be 16 byte aligned in a struct,
* the start of the struct must itself be 16-byte aligned.
*
* Maintaining proper alignment is the user's responsibility.
*/
typedef int8_t cl_char2[2] __attribute__((aligned(2)));
typedef int8_t cl_char4[4] __attribute__((aligned(4)));
typedef int8_t cl_char8[8] __attribute__((aligned(8)));
typedef int8_t cl_char16[16] __attribute__((aligned(16)));
typedef uint8_t cl_uchar2[2] __attribute__((aligned(2)));
typedef uint8_t cl_uchar4[4] __attribute__((aligned(4)));
typedef uint8_t cl_uchar8[8] __attribute__((aligned(8)));
typedef uint8_t cl_uchar16[16] __attribute__((aligned(16)));
typedef int16_t cl_short2[2] __attribute__((aligned(4)));
typedef int16_t cl_short4[4] __attribute__((aligned(8)));
typedef int16_t cl_short8[8] __attribute__((aligned(16)));
typedef int16_t cl_short16[16] __attribute__((aligned(32)));
typedef uint16_t cl_ushort2[2] __attribute__((aligned(4)));
typedef uint16_t cl_ushort4[4] __attribute__((aligned(8)));
typedef uint16_t cl_ushort8[8] __attribute__((aligned(16)));
typedef uint16_t cl_ushort16[16] __attribute__((aligned(32)));
typedef int32_t cl_int2[2] __attribute__((aligned(8)));
typedef int32_t cl_int4[4] __attribute__((aligned(16)));
typedef int32_t cl_int8[8] __attribute__((aligned(32)));
typedef int32_t cl_int16[16] __attribute__((aligned(64)));
typedef uint32_t cl_uint2[2] __attribute__((aligned(8)));
typedef uint32_t cl_uint4[4] __attribute__((aligned(16)));
typedef uint32_t cl_uint8[8] __attribute__((aligned(32)));
typedef uint32_t cl_uint16[16] __attribute__((aligned(64)));
typedef int64_t cl_long2[2] __attribute__((aligned(16)));
typedef int64_t cl_long4[4] __attribute__((aligned(32)));
typedef int64_t cl_long8[8] __attribute__((aligned(64)));
typedef int64_t cl_long16[16] __attribute__((aligned(128)));
typedef uint64_t cl_ulong2[2] __attribute__((aligned(16)));
typedef uint64_t cl_ulong4[4] __attribute__((aligned(32)));
typedef uint64_t cl_ulong8[8] __attribute__((aligned(64)));
typedef uint64_t cl_ulong16[16] __attribute__((aligned(128)));
typedef float cl_float2[2] __attribute__((aligned(8)));
typedef float cl_float4[4] __attribute__((aligned(16)));
typedef float cl_float8[8] __attribute__((aligned(32)));
typedef float cl_float16[16] __attribute__((aligned(64)));
typedef double cl_double2[2] __attribute__((aligned(16)));
typedef double cl_double4[4] __attribute__((aligned(32)));
typedef double cl_double8[8] __attribute__((aligned(64)));
typedef double cl_double16[16] __attribute__((aligned(128)));
#endif
#include <stddef.h>
/* and a few goodies to go with them */
#define CL_CHAR_BIT 8
#define CL_SCHAR_MAX 127
#define CL_SCHAR_MIN (-127-1)
#define CL_CHAR_MAX CL_SCHAR_MAX
#define CL_CHAR_MIN CL_SCHAR_MIN
#define CL_UCHAR_MAX 255
#define CL_SHRT_MAX 32767
#define CL_SHRT_MIN (-32767-1)
#define CL_USHRT_MAX 65535
#define CL_INT_MAX 2147483647
#define CL_INT_MIN (-2147483647-1)
#define CL_UINT_MAX 0xffffffffU
#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
#define CL_FLT_DIG 6
#define CL_FLT_MANT_DIG 24
#define CL_FLT_MAX_10_EXP +38
#define CL_FLT_MAX_EXP +128
#define CL_FLT_MIN_10_EXP -37
#define CL_FLT_MIN_EXP -125
#define CL_FLT_RADIX 2
#define CL_FLT_MAX 0x1.fffffep127f
#define CL_FLT_MIN 0x1.0p-126f
#define CL_FLT_EPSILON 0x1.0p-23f
#define CL_DBL_DIG 15
#define CL_DBL_MANT_DIG 53
#define CL_DBL_MAX_10_EXP +308
#define CL_DBL_MAX_EXP +1024
#define CL_DBL_MIN_10_EXP -307
#define CL_DBL_MIN_EXP -1021
#define CL_DBL_RADIX 2
#define CL_DBL_MAX 0x1.fffffffffffffp1023
#define CL_DBL_MIN 0x1.0p-1022
#define CL_DBL_EPSILON 0x1.0p-52
/* There are no vector types for half */
#ifdef __cplusplus
}
#endif
#endif // __CL_PLATFORM_H
| 40.085603 | 121 | 0.657348 |
bde17232a2cffdb7d67fca3e1f7588738f6e41a7 | 46,650 | h | C | iPhoneOS11.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioConverter.h | onezens/sdks | a194d40f2ef4c4a00d8d3d1b3a2d7a9a110449b7 | [
"MIT"
] | 416 | 2016-08-20T03:40:59.000Z | 2022-03-30T14:27:47.000Z | iPhoneOS11.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioConverter.h | tobygrand/sdks | d43e7efaa664af3f92e6a4b306ee56a8e7a3eef6 | [
"MIT"
] | 41 | 2016-08-22T14:41:42.000Z | 2022-02-25T11:38:16.000Z | iPhoneOS11.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioConverter.h | tobygrand/sdks | d43e7efaa664af3f92e6a4b306ee56a8e7a3eef6 | [
"MIT"
] | 173 | 2016-08-28T15:09:18.000Z | 2022-03-23T15:42:52.000Z | /*!
@file AudioConverter.h
@framework AudioToolbox.framework
@copyright (c) 1985-2015 by Apple, Inc., all rights reserved.
@abstract API's to perform audio format conversions.
@discussion
AudioConverters convert between various linear PCM and compressed
audio formats. Supported transformations include:
- PCM float/integer/bit depth conversions
- PCM sample rate conversion
- PCM interleaving and deinterleaving
- encoding PCM to compressed formats
- decoding compressed formats to PCM
A single AudioConverter may perform more than one
of the above transformations.
*/
#ifndef AudioToolbox_AudioConverter_h
#define AudioToolbox_AudioConverter_h
//==================================================================================================
/*!
@header AudioConverter.h
*/
//=============================================================================
// Includes
//=============================================================================
#include <Availability.h>
#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
#include <CoreAudio/CoreAudioTypes.h>
#else
#include <CoreAudioTypes.h>
#endif
CF_ASSUME_NONNULL_BEGIN
#if defined(__cplusplus)
extern "C"
{
#endif
//=============================================================================
// Theory of Operation
//=============================================================================
//=============================================================================
// Types specific to the Audio Converter API
//=============================================================================
/*!
@typedef AudioConverterRef
@abstract A reference to an AudioConverter object.
*/
typedef struct OpaqueAudioConverter * AudioConverterRef;
typedef UInt32 AudioConverterPropertyID;
//=============================================================================
// Standard Properties
//=============================================================================
/*!
@enum AudioConverterPropertyID
@abstract The properties of an AudioConverter, accessible via AudioConverterGetProperty()
and AudioConverterSetProperty().
@constant kAudioConverterPropertyMinimumInputBufferSize
a UInt32 that indicates the size in bytes of the smallest buffer of input
data that can be supplied via the AudioConverterInputProc or as the input to
AudioConverterConvertBuffer
@constant kAudioConverterPropertyMinimumOutputBufferSize
a UInt32 that indicates the size in bytes of the smallest buffer of output
data that can be supplied to AudioConverterFillComplexBuffer or as the output to
AudioConverterConvertBuffer
@constant kAudioConverterPropertyMaximumInputBufferSize
DEPRECATED. The AudioConverter input proc may be passed any number of packets of data.
If fewer are packets are returned than required, then the input proc will be called again.
If more packets are passed than required, they will remain in the client's buffer and be
consumed as needed.
@constant kAudioConverterPropertyMaximumInputPacketSize
a UInt32 that indicates the size in bytes of the largest single packet of
data in the input format. This is mostly useful for variable bit rate
compressed data (decoders).
@constant kAudioConverterPropertyMaximumOutputPacketSize
a UInt32 that indicates the size in bytes of the largest single packet of
data in the output format. This is mostly useful for variable bit rate
compressed data (encoders).
@constant kAudioConverterPropertyCalculateInputBufferSize
a UInt32 that on input holds a size in bytes that is desired for the output
data. On output, it will hold the size in bytes of the input buffer required
to generate that much output data. Note that some converters cannot do this
calculation.
@constant kAudioConverterPropertyCalculateOutputBufferSize
a UInt32 that on input holds a size in bytes that is desired for the input
data. On output, it will hold the size in bytes of the output buffer
required to hold the output data that will be generated. Note that some
converters cannot do this calculation.
@constant kAudioConverterPropertyInputCodecParameters
The value of this property varies from format to format and is considered
private to the format. It is treated as a buffer of untyped data.
@constant kAudioConverterPropertyOutputCodecParameters
The value of this property varies from format to format and is considered
private to the format. It is treated as a buffer of untyped data.
@constant kAudioConverterSampleRateConverterAlgorithm
DEPRECATED: please use kAudioConverterSampleRateConverterComplexity instead
@constant kAudioConverterSampleRateConverterComplexity
An OSType that specifies the sample rate converter algorithm to use (as defined in
AudioToolbox/AudioUnitProperties.h)
@constant kAudioConverterSampleRateConverterQuality
A UInt32 that specifies rendering quality of the sample rate converter (see
enum constants below)
@constant kAudioConverterSampleRateConverterInitialPhase
A Float64 with value 0.0 <= x < 1.0 giving the initial subsample position of the
sample rate converter.
@constant kAudioConverterCodecQuality
A UInt32 that specifies rendering quality of a codec (see enum constants
below)
@constant kAudioConverterPrimeMethod
a UInt32 specifying priming method (usually for sample-rate converter) see
explanation for struct AudioConverterPrimeInfo below along with enum
constants
@constant kAudioConverterPrimeInfo
A pointer to AudioConverterPrimeInfo (see explanation for struct
AudioConverterPrimeInfo below)
@constant kAudioConverterChannelMap
An array of SInt32's. The size of the array is the number of output
channels, and each element specifies which input channel's data is routed to
that output channel (using a 0-based index of the input channels), or -1 if
no input channel is to be routed to that output channel. The default
behavior is as follows. I = number of input channels, O = number of output
channels. When I > O, the first O inputs are routed to the first O outputs,
and the remaining puts discarded. When O > I, the first I inputs are routed
to the first O outputs, and the remaining outputs are zeroed.
A simple example for splitting mono input to stereo output (instead of routing
the input to only the first output channel):
<pre>
// this should be as large as the number of output channels:
SInt32 channelMap[2] = { 0, 0 };
AudioConverterSetProperty(theConverter, kAudioConverterChannelMap,
sizeof(channelMap), channelMap);
</pre>
@constant kAudioConverterDecompressionMagicCookie
A void * pointing to memory set up by the caller. Required by some formats
in order to decompress the input data.
@constant kAudioConverterCompressionMagicCookie
A void * pointing to memory set up by the caller. Returned by the converter
so that it may be stored along with the output data. It can then be passed
back to the converter for decompression at a later time.
@constant kAudioConverterEncodeBitRate
A UInt32 containing the number of bits per second to aim for when encoding
data. Some decoders will also allow you to get this property to discover the bit rate.
@constant kAudioConverterEncodeAdjustableSampleRate
For encoders where the AudioConverter was created with an output sample rate
of zero, and the codec can do rate conversion on its input, this provides a
way to set the output sample rate. The property value is a Float64.
@constant kAudioConverterInputChannelLayout
The property value is an AudioChannelLayout.
@constant kAudioConverterOutputChannelLayout
The property value is an AudioChannelLayout.
@constant kAudioConverterApplicableEncodeBitRates
The property value is an array of AudioValueRange describing applicable bit
rates based on current settings.
@constant kAudioConverterAvailableEncodeBitRates
The property value is an array of AudioValueRange describing available bit
rates based on the input format. You can get all available bit rates from
the AudioFormat API.
@constant kAudioConverterApplicableEncodeSampleRates
The property value is an array of AudioValueRange describing applicable
sample rates based on current settings.
@constant kAudioConverterAvailableEncodeSampleRates
The property value is an array of AudioValueRange describing available
sample rates based on the input format. You can get all available sample
rates from the AudioFormat API.
@constant kAudioConverterAvailableEncodeChannelLayoutTags
The property value is an array of AudioChannelLayoutTags for the format and
number of channels specified in the input format going to the encoder.
@constant kAudioConverterCurrentOutputStreamDescription
Returns the current completely specified output AudioStreamBasicDescription.
For example when encoding to AAC, your original output stream description
will not have been completely filled out.
@constant kAudioConverterCurrentInputStreamDescription
Returns the current completely specified input AudioStreamBasicDescription.
@constant kAudioConverterPropertySettings
Returns the a CFArray of property settings for converters.
@constant kAudioConverterPropertyBitDepthHint
An SInt32 of the source bit depth to preserve. This is a hint to some
encoders like lossless about how many bits to preserve in the input. The
converter usually tries to preserve as many as possible, but a lossless
encoder will do poorly if more bits are supplied than are desired in the
output. The bit depth is expressed as a negative number if the source was floating point,
e.g. -32 for float, -64 for double.
@constant kAudioConverterPropertyFormatList
An array of AudioFormatListItem structs describing all the data formats produced by the
encoder end of the AudioConverter. If the ioPropertyDataSize parameter indicates that
outPropertyData is sizeof(AudioFormatListItem), then only the best format is returned.
This property may be used for example to discover all the data formats produced by the AAC_HE2
(AAC High Efficiency vers. 2) encoder.
*/
CF_ENUM(AudioConverterPropertyID)
{
kAudioConverterPropertyMinimumInputBufferSize = 'mibs',
kAudioConverterPropertyMinimumOutputBufferSize = 'mobs',
kAudioConverterPropertyMaximumInputBufferSize = 'xibs',
kAudioConverterPropertyMaximumInputPacketSize = 'xips',
kAudioConverterPropertyMaximumOutputPacketSize = 'xops',
kAudioConverterPropertyCalculateInputBufferSize = 'cibs',
kAudioConverterPropertyCalculateOutputBufferSize = 'cobs',
kAudioConverterPropertyInputCodecParameters = 'icdp',
kAudioConverterPropertyOutputCodecParameters = 'ocdp',
kAudioConverterSampleRateConverterAlgorithm = 'srci',
kAudioConverterSampleRateConverterComplexity = 'srca',
kAudioConverterSampleRateConverterQuality = 'srcq',
kAudioConverterSampleRateConverterInitialPhase = 'srcp',
kAudioConverterCodecQuality = 'cdqu',
kAudioConverterPrimeMethod = 'prmm',
kAudioConverterPrimeInfo = 'prim',
kAudioConverterChannelMap = 'chmp',
kAudioConverterDecompressionMagicCookie = 'dmgc',
kAudioConverterCompressionMagicCookie = 'cmgc',
kAudioConverterEncodeBitRate = 'brat',
kAudioConverterEncodeAdjustableSampleRate = 'ajsr',
kAudioConverterInputChannelLayout = 'icl ',
kAudioConverterOutputChannelLayout = 'ocl ',
kAudioConverterApplicableEncodeBitRates = 'aebr',
kAudioConverterAvailableEncodeBitRates = 'vebr',
kAudioConverterApplicableEncodeSampleRates = 'aesr',
kAudioConverterAvailableEncodeSampleRates = 'vesr',
kAudioConverterAvailableEncodeChannelLayoutTags = 'aecl',
kAudioConverterCurrentOutputStreamDescription = 'acod',
kAudioConverterCurrentInputStreamDescription = 'acid',
kAudioConverterPropertySettings = 'acps',
kAudioConverterPropertyBitDepthHint = 'acbd',
kAudioConverterPropertyFormatList = 'flst'
};
#if TARGET_OS_IPHONE
/*!
@enum AudioConverterPropertyID (iOS only)
@abstract iOS-specific properties of an AudioConverter, accessible via AudioConverterGetProperty()
and AudioConverterSetProperty().
@constant kAudioConverterPropertyCanResumeFromInterruption
A read-only UInt32 signifying whether the underlying codec supports resumption following
an interruption. If the property is unimplemented (i.e. AudioConverterGetProperty
returns an error), then the codec is not a hardware codec. If the property's value
is 1, then the codec can resume work following an interruption. If the property's
value is 0, then interruptions destroy the codec's state.
*/
CF_ENUM(AudioConverterPropertyID)
{
kAudioConverterPropertyCanResumeFromInterruption = 'crfi'
};
#endif
#if !TARGET_OS_IPHONE
//=============================================================================
//
//=============================================================================
/*!
@enum Mac OS X AudioConverter Properties
@constant kAudioConverterPropertyDithering
A UInt32. Set to a value from the enum of dithering algorithms below.
Zero means no dithering and is the default. (Mac OS X only.)
@constant kAudioConverterPropertyDitherBitDepth
A UInt32. Dither is applied at this bit depth. (Mac OS X only.)
*/
CF_ENUM(AudioConverterPropertyID)
{
kAudioConverterPropertyDithering = 'dith',
kAudioConverterPropertyDitherBitDepth = 'dbit'
};
/*!
@enum Dithering algorithms
@abstract Constants to be used as the value for kAudioConverterPropertyDithering.
@constant kDitherAlgorithm_TPDF Dither signal is generated by a white noise source with a triangular probability density function
@constant kDitherAlgorithm_NoiseShaping Use a static, perceptually weighted noise shaped dither
*/
CF_ENUM(UInt32)
{
kDitherAlgorithm_TPDF = 1,
kDitherAlgorithm_NoiseShaping = 2
};
#endif
/*!
@enum Quality constants
@abstract Constants to be used with kAudioConverterSampleRateConverterQuality.
@constant kAudioConverterQuality_Max maximum quality
@constant kAudioConverterQuality_High high quality
@constant kAudioConverterQuality_Medium medium quality
@constant kAudioConverterQuality_Low low quality
@constant kAudioConverterQuality_Min minimum quality
*/
CF_ENUM(UInt32)
{
kAudioConverterQuality_Max = 0x7F,
kAudioConverterQuality_High = 0x60,
kAudioConverterQuality_Medium = 0x40,
kAudioConverterQuality_Low = 0x20,
kAudioConverterQuality_Min = 0
};
/*!
@enum Sample Rate Converter Complexity
@constant kAudioConverterSampleRateConverterComplexity_Linear
@discussion Linear interpolation. lowest quality, cheapest.
InitialPhase and PrimeMethod properties are not operative with this mode.
@constant kAudioConverterSampleRateConverterComplexity_Normal
@discussion Normal quality sample rate conversion.
@constant kAudioConverterSampleRateConverterComplexity_Mastering
@discussion Mastering quality sample rate conversion. More expensive.
@constant kAudioConverterSampleRateConverterComplexity_MinimumPhase
@discussion Minimum phase impulse response. Stopband attenuation varies with quality setting.
The InitialPhase and PrimeMethod properties are not operative with this mode.
There are three levels of quality provided.
kAudioConverterQuality_Low (or Min) : noise floor to -96 dB
kAudioConverterQuality_Medium : noise floor to -144 dB
kAudioConverterQuality_High (or Max) : noise floor to -160 dB (this uses double precision internally)
Quality equivalences to the other complexity modes are very roughly as follows:
MinimumPhase Low is somewhat better than Normal Medium.
MinimumPhase Medium is similar to Normal Max.
MinimumPhase High is similar to Mastering Low.
In general, MinimumPhase performs better than Normal and Mastering for the equivalent qualities listed above.
MinimumPhase High is several times faster than Mastering Low.
*/
CF_ENUM(UInt32)
{
kAudioConverterSampleRateConverterComplexity_Linear = 'line', // linear interpolation
kAudioConverterSampleRateConverterComplexity_Normal = 'norm', // normal quality range, the default
kAudioConverterSampleRateConverterComplexity_Mastering = 'bats', // higher quality range, more expensive
kAudioConverterSampleRateConverterComplexity_MinimumPhase = 'minp' // minimum phase impulse response.
};
/*!
@enum Prime method constants
@abstract Constants to be used with kAudioConverterPrimeMethod.
@constant kConverterPrimeMethod_Pre
Primes with leading + trailing input frames.
@constant kConverterPrimeMethod_Normal
Only primes with trailing (zero latency). Leading frames are assumed to be
silence.
@constant kConverterPrimeMethod_None
Acts in "latency" mode. Both leading and trailing frames assumed to be
silence.
*/
CF_ENUM(UInt32)
{
kConverterPrimeMethod_Pre = 0,
kConverterPrimeMethod_Normal = 1,
kConverterPrimeMethod_None = 2
};
/*!
@struct AudioConverterPrimeInfo
@abstract Specifies priming information.
@field leadingFrames
Specifies the number of leading (previous) input frames, relative to the normal/desired
start input frame, required by the converter to perform a high quality conversion. If
using kConverterPrimeMethod_Pre, the client should "pre-seek" the input stream provided
through the input proc by leadingFrames. If no frames are available previous to the
desired input start frame (because, for example, the desired start frame is at the very
beginning of available audio), then provide "leadingFrames" worth of initial zero frames
in the input proc. Do not "pre-seek" in the default case of
kConverterPrimeMethod_Normal or when using kConverterPrimeMethod_None.
@field trailingFrames
Specifies the number of trailing input frames (past the normal/expected end input frame)
required by the converter to perform a high quality conversion. The client should be
prepared to provide this number of additional input frames except when using
kConverterPrimeMethod_None. If no more frames of input are available in the input stream
(because, for example, the desired end frame is at the end of an audio file), then zero
(silent) trailing frames will be synthesized for the client.
@discussion
When using AudioConverterFillComplexBuffer() (either a single call or a series of calls), some
conversions, particularly involving sample-rate conversion, ideally require a certain
number of input frames previous to the normal start input frame and beyond the end of
the last expected input frame in order to yield high-quality results.
These are expressed in the leadingFrames and trailingFrames members of the structure.
The very first call to AudioConverterFillComplexBuffer(), or first call after
AudioConverterReset(), will request additional input frames beyond those normally
expected in the input proc callback to fulfill this first AudioConverterFillComplexBuffer()
request. The number of additional frames requested, depending on the prime method, will
be approximately:
<pre>
kConverterPrimeMethod_Pre leadingFrames + trailingFrames
kConverterPrimeMethod_Normal trailingFrames
kConverterPrimeMethod_None 0
</pre>
Thus, in effect, the first input proc callback(s) may provide not only the leading
frames, but also may "read ahead" by an additional number of trailing frames depending
on the prime method.
kConverterPrimeMethod_None is useful in a real-time application processing live input,
in which case trailingFrames (relative to input sample rate) of through latency will be
seen at the beginning of the output of the AudioConverter. In other real-time
applications such as DAW systems, it may be possible to provide these initial extra
audio frames since they are stored on disk or in memory somewhere and
kConverterPrimeMethod_Pre may be preferable. The default method is
kConverterPrimeMethod_Normal, which requires no pre-seeking of the input stream and
generates no latency at the output.
*/
struct AudioConverterPrimeInfo {
UInt32 leadingFrames;
UInt32 trailingFrames;
};
typedef struct AudioConverterPrimeInfo AudioConverterPrimeInfo;
//=============================================================================
// Errors
//=============================================================================
CF_ENUM(OSStatus)
{
kAudioConverterErr_FormatNotSupported = 'fmt?',
kAudioConverterErr_OperationNotSupported = 0x6F703F3F, // 'op??', integer used because of trigraph
kAudioConverterErr_PropertyNotSupported = 'prop',
kAudioConverterErr_InvalidInputSize = 'insz',
kAudioConverterErr_InvalidOutputSize = 'otsz',
// e.g. byte size is not a multiple of the frame size
kAudioConverterErr_UnspecifiedError = 'what',
kAudioConverterErr_BadPropertySizeError = '!siz',
kAudioConverterErr_RequiresPacketDescriptionsError = '!pkd',
kAudioConverterErr_InputSampleRateOutOfRange = '!isr',
kAudioConverterErr_OutputSampleRateOutOfRange = '!osr'
};
#if TARGET_OS_IPHONE
/*!
@enum AudioConverter errors (iPhone only)
@abstract iPhone-specific OSStatus results for AudioConverter
@constant kAudioConverterErr_HardwareInUse
Returned from AudioConverterFillComplexBuffer if the underlying hardware codec has
become unavailable, probably due to an interruption. In this case, your application
must stop calling AudioConverterFillComplexBuffer. If the converter can resume from an
interruption (see kAudioConverterPropertyCanResumeFromInterruption), you must
wait for an EndInterruption notification from AudioSession, and call AudioSessionSetActive(true)
before resuming.
@constant kAudioConverterErr_NoHardwarePermission
Returned from AudioConverterNew if the new converter would use a hardware codec
which the application does not have permission to use.
*/
CF_ENUM(OSStatus)
{
kAudioConverterErr_HardwareInUse = 'hwiu',
kAudioConverterErr_NoHardwarePermission = 'perm'
};
#endif
//=============================================================================
// Routines
//=============================================================================
//-----------------------------------------------------------------------------
/*!
@function AudioConverterNew
@abstract Create a new AudioConverter.
@param inSourceFormat
The format of the source audio to be converted.
@param inDestinationFormat
The destination format to which the audio is to be converted.
@param outAudioConverter
On successful return, points to a new AudioConverter instance.
@result An OSStatus result code.
@discussion
For a pair of linear PCM formats, the following conversions
are supported:
<ul>
<li>addition and removal of channels, when the stream descriptions'
mChannelsPerFrame does not match. Channels may also be reordered and removed
using the kAudioConverterChannelMap property.</li>
<li>sample rate conversion</li>
<li>interleaving/deinterleaving, when the stream descriptions' (mFormatFlags &
kAudioFormatFlagIsNonInterleaved) does not match.</li>
<li>conversion between any pair of the following formats:</li>
<ul>
<li>8 bit integer, signed or unsigned</li>
<li>16, 24, or 32-bit integer, big- or little-endian. Other integral
bit depths, if high-aligned and non-packed, are also supported</li>
<li>32 and 64-bit float, big- or little-endian.</li>
</ul>
</ul>
Also, encoding and decoding between linear PCM and compressed formats is
supported. Functions in AudioToolbox/AudioFormat.h return information about the
supported formats. When using a codec, you can use any supported PCM format (as
above); the converter will perform any necessary additional conversion between
your PCM format and the one created or consumed by the codec.
*/
extern OSStatus
AudioConverterNew( const AudioStreamBasicDescription * inSourceFormat,
const AudioStreamBasicDescription * inDestinationFormat,
AudioConverterRef __nullable * __nonnull outAudioConverter) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterNewSpecific
@abstract Create a new AudioConverter using specific codecs.
@param inSourceFormat
The format of the source audio to be converted.
@param inDestinationFormat
The destination format to which the audio is to be converted.
@param inNumberClassDescriptions
The number of class descriptions.
@param inClassDescriptions
AudioClassDescriptions specifiying the codec to instantiate.
@param outAudioConverter
On successful return, points to a new AudioConverter instance.
@result An OSStatus result code.
@discussion
This function is identical to AudioConverterNew(), except that the client may
explicitly choose which codec to instantiate if there is more than one choice.
*/
extern OSStatus
AudioConverterNewSpecific( const AudioStreamBasicDescription * inSourceFormat,
const AudioStreamBasicDescription * inDestinationFormat,
UInt32 inNumberClassDescriptions,
const AudioClassDescription * inClassDescriptions,
AudioConverterRef __nullable * __nonnull outAudioConverter)
__OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterDispose
@abstract Destroy an AudioConverter.
@param inAudioConverter
The AudioConverter to dispose.
@result An OSStatus result code.
*/
extern OSStatus
AudioConverterDispose( AudioConverterRef inAudioConverter) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterReset
@abstract Reset an AudioConverter
@param inAudioConverter
The AudioConverter to reset.
@result An OSStatus result code.
@discussion
Should be called whenever there is a discontinuity in the source audio stream
being provided to the converter. This will flush any internal buffers in the
converter.
*/
extern OSStatus
AudioConverterReset( AudioConverterRef inAudioConverter) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterGetPropertyInfo
@abstract Returns information about an AudioConverter property.
@param inAudioConverter
The AudioConverter to query.
@param inPropertyID
The property to query.
@param outSize
If non-null, on exit, the maximum size of the property value in bytes.
@param outWritable
If non-null, on exit, indicates whether the property value is writable.
@result An OSStatus result code.
*/
extern OSStatus
AudioConverterGetPropertyInfo( AudioConverterRef inAudioConverter,
AudioConverterPropertyID inPropertyID,
UInt32 * __nullable outSize,
Boolean * __nullable outWritable) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterGetProperty
@abstract Returns an AudioConverter property value.
@param inAudioConverter
The AudioConverter to query.
@param inPropertyID
The property to fetch.
@param ioPropertyDataSize
On entry, the size of the memory pointed to by outPropertyData. On
successful exit, the size of the property value.
@param outPropertyData
On exit, the property value.
@result An OSStatus result code.
*/
extern OSStatus
AudioConverterGetProperty( AudioConverterRef inAudioConverter,
AudioConverterPropertyID inPropertyID,
UInt32 * ioPropertyDataSize,
void * outPropertyData) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterSetProperty
@abstract Sets an AudioConverter property value.
@param inAudioConverter
The AudioConverter to modify.
@param inPropertyID
The property to set.
@param inPropertyDataSize
The size in bytes of the property value.
@param inPropertyData
Points to the new property value.
@result An OSStatus result code.
*/
extern OSStatus
AudioConverterSetProperty( AudioConverterRef inAudioConverter,
AudioConverterPropertyID inPropertyID,
UInt32 inPropertyDataSize,
const void * inPropertyData) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@typedef AudioConverterInputDataProc
@abstract Callback function for supplying input data to AudioConverterFillBuffer.
@param inAudioConverter
The AudioConverter requesting input.
@param ioDataSize
On entry, the minimum number of bytes of audio data the converter
would like in order to fulfill its current FillBuffer request.
On exit, the number of bytes of audio data actually being provided
for input, or 0 if there is no more input.
@param outData
On exit, *outData should point to the audio data being provided
for input.
@param inUserData
The inInputDataProcUserData parameter passed to AudioConverterFillBuffer().
@result An OSStatus result code.
@discussion
<b>NOTE:</b> This API is now deprecated,
use AudioConverterFillComplexBuffer instead.
This callback function supplies input to AudioConverterFillBuffer.
The AudioConverter requests a minimum amount of data (*ioDataSize). The callback
may return any amount of data. If it is less than than the minimum, the callback
will simply be called again in the near future.
The callback supplies a pointer to a buffer of audio data. The callback is
responsible for not freeing or altering this buffer until it is called again.
If the callback returns an error, it must return zero bytes of data.
AudioConverterFillBuffer will stop producing output and return whatever output
has already been produced to its caller, along with the error code. This
mechanism can be used when an input proc has temporarily run out of data, but
has not yet reached end of stream.
*/
typedef OSStatus
(*AudioConverterInputDataProc)( AudioConverterRef inAudioConverter,
UInt32 * ioDataSize,
void * __nonnull * __nonnull outData,
void * __nullable inUserData);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterFillBuffer
@abstract Converts data supplied by an input callback function.
@param inAudioConverter
The AudioConverter to use.
@param inInputDataProc
A callback function which supplies the input data.
@param inInputDataProcUserData
A value for the use of the callback function.
@param ioOutputDataSize
On entry, the size of the buffer pointed to by outOutputData.
On exit, the number of bytes written to outOutputData
@param outOutputData
The buffer into which the converted data is written.
@result An OSStatus result code.
@discussion
<b>NOTE:</b> This API is now deprecated,
use AudioConverterFillComplexBuffer instead.
Produces a buffer of output data from an AudioConverter. The supplied input
callback function is called whenever necessary.
*/
#if !TARGET_OS_IPHONE
extern OSStatus
AudioConverterFillBuffer( AudioConverterRef inAudioConverter,
AudioConverterInputDataProc inInputDataProc,
void * __nullable inInputDataProcUserData,
UInt32 * ioOutputDataSize,
void * outOutputData)
__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1,__MAC_10_5, __IPHONE_NA, __IPHONE_NA);
#endif // !TARGET_OS_IPHONE
//-----------------------------------------------------------------------------
/*!
@function AudioConverterConvertBuffer
@abstract Converts data from an input buffer to an output buffer.
@param inAudioConverter
The AudioConverter to use.
@param inInputDataSize
The size of the buffer inInputData.
@param inInputData
The input audio data buffer.
@param ioOutputDataSize
On entry, the size of the buffer outOutputData. On exit, the number of bytes
written to outOutputData.
@param outOutputData
The output data buffer.
@result
Produces a buffer of output data from an AudioConverter, using the supplied
input buffer.
@discussion
<b>WARNING:</b> this function will fail for any conversion where there is a
variable relationship between the input and output data buffer sizes. This
includes sample rate conversions and most compressed formats. In these cases,
use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
PCM-to-PCM conversions where there is no sample rate conversion.
*/
extern OSStatus
AudioConverterConvertBuffer( AudioConverterRef inAudioConverter,
UInt32 inInputDataSize,
const void * inInputData,
UInt32 * ioOutputDataSize,
void * outOutputData) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@typedef AudioConverterComplexInputDataProc
@abstract Callback function for supplying input data to AudioConverterFillComplexBuffer.
@param inAudioConverter
The AudioConverter requesting input.
@param ioNumberDataPackets
On entry, the minimum number of packets of input audio data the converter
would like in order to fulfill its current FillBuffer request. On exit, the
number of packets of audio data actually being provided for input, or 0 if
there is no more input.
@param ioData
On exit, the members of ioData should be set to point to the audio data
being provided for input.
@param outDataPacketDescription
If non-null, on exit, the callback is expected to fill this in with
an AudioStreamPacketDescription for each packet of input data being provided.
@param inUserData
The inInputDataProcUserData parameter passed to AudioConverterFillComplexBuffer().
@result An OSStatus result code.
@discussion
This callback function supplies input to AudioConverterFillComplexBuffer.
The AudioConverter requests a minimum number of packets (*ioNumberDataPackets).
The callback may return one or more packets. If this is less than the minimum,
the callback will simply be called again in the near future.
The callback manipulates the members of ioData to point to one or more buffers
of audio data (multiple buffers are used with non-interleaved PCM data). The
callback is responsible for not freeing or altering this buffer until it is
called again.
If the callback returns an error, it must return zero packets of data.
AudioConverterFillComplexBuffer will stop producing output and return whatever
output has already been produced to its caller, along with the error code. This
mechanism can be used when an input proc has temporarily run out of data, but
has not yet reached end of stream.
*/
typedef OSStatus
(*AudioConverterComplexInputDataProc)( AudioConverterRef inAudioConverter,
UInt32 * ioNumberDataPackets,
AudioBufferList * ioData,
AudioStreamPacketDescription * __nullable * __nullable outDataPacketDescription,
void * __nullable inUserData);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterFillComplexBuffer
@abstract Converts data supplied by an input callback function, supporting non-interleaved
and packetized formats.
@param inAudioConverter
The AudioConverter to use.
@param inInputDataProc
A callback function which supplies the input data.
@param inInputDataProcUserData
A value for the use of the callback function.
@param ioOutputDataPacketSize
On entry, the capacity of outOutputData expressed in packets in the
converter's output format. On exit, the number of packets of converted
data that were written to outOutputData.
@param outOutputData
The converted output data is written to this buffer.
@param outPacketDescription
If non-null, and the converter's output uses packet descriptions, then
packet descriptions are written to this array. It must point to a memory
block capable of holding *ioOutputDataPacketSize packet descriptions.
(See AudioFormat.h for ways to determine whether an audio format
uses packet descriptions).
@result An OSStatus result code.
@discussion
Produces a buffer list of output data from an AudioConverter. The supplied input
callback function is called whenever necessary.
*/
extern OSStatus
AudioConverterFillComplexBuffer( AudioConverterRef inAudioConverter,
AudioConverterComplexInputDataProc inInputDataProc,
void * __nullable inInputDataProcUserData,
UInt32 * ioOutputDataPacketSize,
AudioBufferList * outOutputData,
AudioStreamPacketDescription * __nullable outPacketDescription)
__OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0);
//-----------------------------------------------------------------------------
/*!
@function AudioConverterConvertComplexBuffer
@abstract Converts PCM data from an input buffer list to an output buffer list.
@param inAudioConverter
The AudioConverter to use.
@param inNumberPCMFrames
The number of PCM frames to convert.
@param inInputData
The source audio buffer list.
@param outOutputData
The converted output data is written to this buffer list.
@result An OSStatus result code.
@discussion
<b>WARNING:</b> this function will fail for any conversion where there is a
variable relationship between the input and output data buffer sizes. This
includes sample rate conversions and most compressed formats. In these cases,
use AudioConverterFillComplexBuffer. Generally this function is only appropriate for
PCM-to-PCM conversions where there is no sample rate conversion.
*/
extern OSStatus
AudioConverterConvertComplexBuffer( AudioConverterRef inAudioConverter,
UInt32 inNumberPCMFrames,
const AudioBufferList * inInputData,
AudioBufferList * outOutputData)
__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0);
#if defined(__cplusplus)
}
#endif
CF_ASSUME_NONNULL_END
#endif // AudioToolbox_AudioConverter_h
| 52.711864 | 147 | 0.611683 |
0c121bc9b13d1f9dcccd290d79157d9e473fe84d | 232 | h | C | RCRefreshControlDemo/TableViewController.h | c0ming/RCRefreshControl | c65102fc531d2d9eda7e76bae49dae009d5df7a2 | [
"MIT"
] | 1 | 2015-11-08T08:42:43.000Z | 2015-11-08T08:42:43.000Z | RCRefreshControlDemo/TableViewController.h | c0ming/RCRefreshControl | c65102fc531d2d9eda7e76bae49dae009d5df7a2 | [
"MIT"
] | null | null | null | RCRefreshControlDemo/TableViewController.h | c0ming/RCRefreshControl | c65102fc531d2d9eda7e76bae49dae009d5df7a2 | [
"MIT"
] | null | null | null | //
// TableViewController.h
// RCRefreshControlDemo
//
// Created by c0ming on 10/28/15.
// Copyright © 2015 c0ming. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController
@end
| 16.571429 | 54 | 0.724138 |
83d69dec35aef40f2b881a8d202ba40247ba4331 | 3,022 | h | C | SDKs/CryCode/3.8.1/CryEngine/CryCommon/IDynamicResponseCondition.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | 4 | 2017-12-18T20:10:16.000Z | 2021-02-07T21:21:24.000Z | SDKs/CryCode/3.8.1/CryEngine/CryCommon/IDynamicResponseCondition.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | null | null | null | SDKs/CryCode/3.8.1/CryEngine/CryCommon/IDynamicResponseCondition.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | 3 | 2019-03-11T21:36:15.000Z | 2021-02-07T21:21:26.000Z | // Copyright 2001-2015 Crytek GmbH. All rights reserved.
/************************************************************************
An Interface for Conditions that can be added to Response Segments
/************************************************************************/
#ifndef _DYNAMICRESPONSECONDITION_H_
#define _DYNAMICRESPONSECONDITION_H_
#include <IXml.h>
namespace DRS
{
struct IResponseActor;
struct IVariableCollection;
struct IResponseCondition
{
virtual ~IResponseCondition() {}
typedef unsigned int ConditionIdentifierHash;
// <title IsMet>
// Syntax: its called by the DRS system, to evaluate if this condition is fulfilled
// Description:
// the condition is required to check all needed data as fast as possible and return if the response can therefore be executed
// Arguments:
// pObject - a pointer to the current active Actor for this response, can be used to get local variable collections from or use as execution object
// pContextVariableCollection - a pointer to the context variable collection for the current event.
// Returns:
// needs to return, if the response is allowed to execute
virtual bool IsMet(const IResponseActor* pObject, const IVariableCollection* pContextVariableCollection) = 0;
// <title Release>
// Syntax: its called by the DRS system, when this condition instance is no longer needed by the DRS
// Description:
// Informs the Condition that the DRS will not use this instance any more. Its up to the implementation to decide what needs to be done.
// The Condition could be deleted, or still remains in some cache so that is can be re-used. straight forward implementation could be a "delete this;"
// Arguments:
// Returns:
virtual void Release() = 0;
};
struct IResponseConditionCreator
{
// <title CreateOrGetConditionFromXML>
// Syntax: its called by the DRS system, when a condition of the type is requested by a response definition
// Description:
// Will Create a new Condition with the parameters from the xml-node, or may return a existing one, if a action with these parameters already exist
// Remark: The DRS will call ReleaseCondition for every condition requested through this
// Arguments:
// pConditionNode - an pointer to an cry-xml-node from the response definition which contains the data for the condition.
// Returns:
// Will return the generated or re-used condition if successful. 0 otherwise
virtual IResponseCondition* CreateOrGetConditionFromXML(XmlNodeRef pConditionNode) = 0;
// <title Release>
// Syntax: its called by the DRS system, on shutdown
// Description:
// Will Release the ActionCreator. Depending on the caching strategy of the creator, it might destroy all created actions. So dont use any Actions of the type after calling release.
// Arguments:
// Returns:
// See Also:
virtual void Release() = 0;
protected:
virtual ~IResponseConditionCreator() {}
};
} //namespace DRS
#endif //_DYNAMICRESPONSECONDITION_H_ | 41.972222 | 188 | 0.71542 |
6411e5a6dedc78c69554ba643e2be39cc875ebc2 | 2,239 | h | C | bellina_core/bellina_core/bellina/bl-node.h | amortaza/bellina_core | 295c3693afa4879c59c8f4e351c82d2b48dc776b | [
"MIT"
] | null | null | null | bellina_core/bellina_core/bellina/bl-node.h | amortaza/bellina_core | 295c3693afa4879c59c8f4e351c82d2b48dc776b | [
"MIT"
] | 66 | 2016-04-09T01:02:43.000Z | 2016-05-06T00:54:42.000Z | bellina_core/bellina_core/bellina/bl-node.h | amortaza/bellina_core | 295c3693afa4879c59c8f4e351c82d2b48dc776b | [
"MIT"
] | null | null | null | #pragma once
#include <map>
#include "bl-types.h"
namespace g2 { extern class CanvasRef; }
namespace g2 { extern class TextureRef; }
using namespace std;
namespace bl {
class Node {
public:
BasePluginCtx* getPluginCtxFromShadow(char* pluginName, char* signature, PluginCtxFactory factory);
public:
Point global_pos;
list<NodeMouseScrollCallback> onMouseScroll_callbacks;
list<NodeMouseMoveCallback> onMouseMove_callbacks;
list<NodeMouseDownCallback> onMouseDown_callbacks;
list<NodeMouseUpCallback> onMouseUp_callbacks;
char* nid;
int x, y;
int w, h;
unsigned char r1, g1, b1;
unsigned char r2, g2, b2;
unsigned char text_red, text_green, text_blue;
float alpha1_canvas, alpha2_canvas;
float text_alpha;
g2::TextureRef* texture_;
g2::TextureRef* mask_;
// affects texture
// label
int padding_left, padding_top, padding_right, padding_bottom;
BorderSide border_left, border_top, border_right, border_bottom;
int flags;
char* text_;
char* font_name;
int font_size;
bool text_tops_canvas;
Node* parent;
list<Node*> kids;
public:
g2::CanvasRef* canvas;
int fontHeight;
Node(Node *parent_);
~Node();
void id(char*);
void pos(int _x, int _y);
void dim(int _w, int _h);
void color1(unsigned char r, unsigned char g, unsigned char b);
void color2(unsigned char r, unsigned char g, unsigned char b);
void canvasOpacity1(float);
void canvasOpacity2(float);
void textOpacity(float);
void texture(g2::TextureRef*);
void mask(g2::TextureRef*);
void padding(int l, int t, int r, int b);
void borderColor(unsigned int border_flag, unsigned char r, unsigned char g, unsigned char b);
void borderThickness(unsigned int border_flag, int);
void borderTops(unsigned int border_flag, bool);
void borderOpacity(unsigned int border_flag, float);
void font(char *name, int size);
void textColor(unsigned char r, unsigned char g, unsigned char b);
void text(char *);
void addKid(Node *);
void resetFlags(int);
void addFlag(int);
void removeFlag(int);
void textTops(bool);
void setColorSolidFlag();
void setColorHorizGradientFlag();
void setColorVertGradientFlag();
void setTextureFlag();
};
}
| 20.925234 | 101 | 0.721751 |
8c5722001de17ce04f442275e686b7cf34cc2aea | 1,307 | h | C | hls4ml/templates/vivado/nnet_utils/nnet_dense.h | necst/hls4ml | 37ac556cc0170b3a2443bec8fca93c7f35dcafa4 | [
"Apache-2.0"
] | 1 | 2021-07-06T12:09:49.000Z | 2021-07-06T12:09:49.000Z | hls4ml/templates/vivado/nnet_utils/nnet_dense.h | necst/hls4ml | 37ac556cc0170b3a2443bec8fca93c7f35dcafa4 | [
"Apache-2.0"
] | null | null | null | hls4ml/templates/vivado/nnet_utils/nnet_dense.h | necst/hls4ml | 37ac556cc0170b3a2443bec8fca93c7f35dcafa4 | [
"Apache-2.0"
] | null | null | null | #ifndef NNET_DENSE_H_
#define NNET_DENSE_H_
#include "nnet_common.h"
#include "nnet_mult.h"
#include "nnet_dense_latency.h"
#include "nnet_dense_resource.h"
#include "nnet_helpers.h"
#include "hls_stream.h"
#include <math.h>
namespace nnet {
struct dense_config
{
// Internal data type definitions
typedef float bias_t;
typedef float weight_t;
typedef float accum_t;
// Layer Sizes
static const unsigned n_in = 10;
static const unsigned n_out = 10;
// Resource reuse info
static const unsigned io_type = io_parallel;
static const unsigned strategy = latency;
static const unsigned reuse_factor = 1;
static const bool store_weights_in_bram = false;
static const unsigned n_zeros = 0;
// partitioning arrays cyclically to go with roll factors?
};
template<class data_T, class res_T, typename CONFIG_T>
void dense(
data_T data[CONFIG_T::n_in],
res_T res[CONFIG_T::n_out],
typename CONFIG_T::weight_t weights[CONFIG_T::n_in*CONFIG_T::n_out],
typename CONFIG_T::bias_t biases[CONFIG_T::n_out])
{
if (CONFIG_T::strategy == latency) {
dense_latency<data_T, res_T, CONFIG_T>(data, res, weights, biases);
} else {
dense_resource<data_T, res_T, CONFIG_T>(data, res, weights, biases);
}
}
}
#endif
| 25.627451 | 76 | 0.704667 |
96910d37a9a190a3737f0b8b8c69f8aef24c9d88 | 9,305 | h | C | src/developer/debug/debug_agent/debugged_thread.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | null | null | null | src/developer/debug/debug_agent/debugged_thread.h | zhangpf/fuchsia-rs | 903568f28ddf45f09157ead36d61b50322c9cf49 | [
"BSD-3-Clause"
] | 5 | 2020-09-06T09:02:06.000Z | 2022-03-02T04:44:22.000Z | src/developer/debug/debug_agent/debugged_thread.h | ZVNexus/fuchsia | c5610ad15208208c98693618a79c705af935270c | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2018 The Fuchsia 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 SRC_DEVELOPER_DEBUG_DEBUG_AGENT_DEBUGGED_THREAD_H_
#define SRC_DEVELOPER_DEBUG_DEBUG_AGENT_DEBUGGED_THREAD_H_
#include <lib/zx/exception.h>
#include <lib/zx/thread.h>
#include <zircon/syscalls/exception.h>
#include "src/developer/debug/ipc/protocol.h"
#include "src/lib/fxl/macros.h"
struct zx_thread_state_general_regs;
namespace debug_agent {
class DebugAgent;
class DebuggedProcess;
class ProcessBreakpoint;
class ProcessWatchpoint;
enum class ThreadCreationOption {
// Already running, don't do anything
kRunningKeepRunning,
// Already suspended, keep it suspended
kSuspendedKeepSuspended,
// Already suspended, run it
kSuspendedShouldRun
};
class DebuggedThread {
public:
// Represents the state the client thinks this thread is in. Certain
// operations can suspend all the threads of a process and the debugger needs
// to know which threads should remain suspended after that operation is done.
enum class ClientState {
kRunning,
kPaused,
};
const char* ClientStateToString(ClientState);
// When a thread is first created and we get a notification about it, it
// will be suspended, but when we attach to a process with existing threads
// it won't in in this state. The |starting| flag indicates that this is
// a thread discovered via a debug notification.
DebuggedThread(DebuggedProcess* process, zx::thread thread,
zx_koid_t thread_koid, zx::exception exception,
ThreadCreationOption option);
virtual ~DebuggedThread();
const DebuggedProcess* process() const { return process_; }
zx::thread& thread() { return thread_; }
const zx::thread& thread() const { return thread_; }
zx_koid_t koid() const { return koid_; }
void OnException(zx::exception exception_token,
zx_exception_info_t exception_info);
// Resumes execution of the thread. The thread should currently be in a
// stopped state. If it's not stopped, this will be ignored.
void Resume(const debug_ipc::ResumeRequest& request);
// Resumes the thread according to the current run mode.
void ResumeForRunMode();
// Resume the thread from an exception.
// If |exception_token_| is not valid, this will no-op.
virtual void ResumeException();
// Resume the thread from a suspension.
// if |suspend_token_| is not valid, this will no-op.
virtual void ResumeSuspension();
// Pauses execution of the thread. Pausing happens asynchronously so the
// thread will not necessarily have stopped when this returns. Set the
// |synchronous| flag for blocking on the suspended signal and make this call
// block until the thread is suspended.
//
// |new_state| represents what the new state of the client should be. If no
// change is wanted, you can use the overload that doesn't receives that.
//
// Returns true if the thread was running at the moment of this call being
// made. Returns false if it was on a suspension condition (suspended or on an
// exception).
//
// A nullopt means an error ocurred while suspending.
virtual bool Suspend(bool synchronous = false);
// The typical suspend deadline users should use when suspending.
static zx::time DefaultSuspendDeadline();
// Waits on a suspension token.
// Returns true if we could find a valid suspension condition (either
// suspended or on an exception). False if timeout or error.
virtual bool WaitForSuspension(zx::time deadline = DefaultSuspendDeadline());
// Fills the thread status record. If full_stack is set, a full backtrace
// will be generated, otherwise a minimal one will be generated.
//
// If optional_regs is non-null, it should point to the current registers of
// the thread. If null, these will be fetched automatically (this is an
// optimization for cases where the caller has already requested registers).
void FillThreadRecord(debug_ipc::ThreadRecord::StackAmount stack_amount,
const zx_thread_state_general_regs* optional_regs,
debug_ipc::ThreadRecord* record) const;
// Register reading and writing.
void ReadRegisters(
const std::vector<debug_ipc::RegisterCategory::Type>& cats_to_get,
std::vector<debug_ipc::RegisterCategory>* out) const;
zx_status_t WriteRegisters(const std::vector<debug_ipc::Register>& regs);
// Sends a notification to the client about the state of this thread.
void SendThreadNotification() const;
// Notification that a ProcessBreakpoint is about to be deleted.
void WillDeleteProcessBreakpoint(ProcessBreakpoint* bp);
ClientState client_state() const { return client_state_; }
void set_client_state(ClientState cs) { client_state_ = cs; }
bool running() const { return !IsSuspended() && !IsInException(); }
virtual bool IsSuspended() const { return suspend_token_.is_valid(); }
virtual bool IsInException() const { return exception_token_.is_valid(); }
bool stepping_over_breakpoint() const { return stepping_over_breakpoint_; }
void set_stepping_over_breakpoint(bool so) { stepping_over_breakpoint_ = so; }
private:
enum class OnStop {
kIgnore, // Don't do anything, keep the thread stopped and don't notify.
kNotify, // Send client notification like normal.
kResume, // The thread should be resumed from this exception.
};
void HandleSingleStep(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
void HandleGeneralException(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
void HandleSoftwareBreakpoint(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
void HandleHardwareBreakpoint(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
void HandleWatchpoint(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
void SendExceptionNotification(debug_ipc::NotifyException*,
zx_thread_state_general_regs*);
OnStop UpdateForSoftwareBreakpoint(
zx_thread_state_general_regs* regs,
std::vector<debug_ipc::BreakpointStats>* hit_breakpoints);
OnStop UpdateForHardwareBreakpoint(
zx_thread_state_general_regs* regs,
std::vector<debug_ipc::BreakpointStats>* hit_breakpoints);
OnStop UpdateForWatchpoint(
zx_thread_state_general_regs* regs,
std::vector<debug_ipc::BreakpointStats>* hit_breakpoints);
// When hitting a SW breakpoint, the PC needs to be correctly re-set depending
// on where the CPU leaves the PC after a SW exception.
void FixSoftwareBreakpointAddress(ProcessBreakpoint* process_breakpoint,
zx_thread_state_general_regs* regs);
void FixAddressForWatchpointHit(ProcessWatchpoint* watchpoint,
zx_thread_state_general_regs* regs);
// Handles an exception corresponding to a ProcessBreakpoint. All
// Breakpoints affected will have their updated stats added to
// *hit_breakpoints.
//
// WARNING: The ProcessBreakpoint argument could be deleted in this call
// if it was a one-shot breakpoint.
void UpdateForHitProcessBreakpoint(
debug_ipc::BreakpointType exception_type,
ProcessBreakpoint* process_breakpoint, zx_thread_state_general_regs* regs,
std::vector<debug_ipc::BreakpointStats>* hit_breakpoints);
// WARNING: The ProcessWatchpoint argument could be deleted in this call
// if it was a one-shot breakpoint.
void UpdateForWatchpointHit(
ProcessWatchpoint*, zx_thread_state_general_regs* regs,
std::vector<debug_ipc::BreakpointStats>* hit_breakpoints);
// Sets or clears the single step bit on the thread.
void SetSingleStep(bool single_step);
DebugAgent* debug_agent_; // Non-owning.
DebuggedProcess* process_; // Non-owning.
zx::thread thread_;
zx_koid_t koid_;
// The main thing we're doing. When automatically resuming, this will be
// what happens.
debug_ipc::ResumeRequest::How run_mode_ =
debug_ipc::ResumeRequest::How::kContinue;
// When run_mode_ == kStepInRange, this defines the range (end non-inclusive).
uint64_t step_in_range_begin_ = 0;
uint64_t step_in_range_end_ = 0;
// This is the state the client is considering this thread to be. This is used
// for internal suspension the agent can do.
ClientState client_state_ = ClientState::kRunning;
// Active if the thread is suspended (by the debugger).
zx::suspend_token suspend_token_;
// Active if the thread is currently on an exception.
zx::exception exception_token_;
// Whether this thread is currently stepping over.
bool stepping_over_breakpoint_ = false;
// This can be set in two cases:
// - When suspended after hitting a breakpoint, this will be the breakpoint
// that was hit.
// - When single-stepping over a breakpoint, this will be the breakpoint
// being stepped over.
ProcessBreakpoint* current_breakpoint_ = nullptr;
FXL_DISALLOW_COPY_AND_ASSIGN(DebuggedThread);
};
} // namespace debug_agent
#endif // SRC_DEVELOPER_DEBUG_DEBUG_AGENT_DEBUGGED_THREAD_H_
| 39.595745 | 80 | 0.733369 |
9f08a984eb4d63eb1e8a5d6c51fe2f787874ee49 | 23,589 | c | C | main/streaming.c | plkumar/esp32-homekit-camera | 9ae7bf0482bfa08eec7a7e52a920a2664e19f7d6 | [
"MIT"
] | 286 | 2019-01-09T14:33:32.000Z | 2022-03-29T00:18:28.000Z | main/streaming.c | plkumar/esp32-homekit-camera | 9ae7bf0482bfa08eec7a7e52a920a2664e19f7d6 | [
"MIT"
] | 95 | 2019-01-13T13:14:12.000Z | 2022-03-26T16:15:50.000Z | main/streaming.c | plkumar/esp32-homekit-camera | 9ae7bf0482bfa08eec7a7e52a920a2664e19f7d6 | [
"MIT"
] | 71 | 2019-01-07T22:56:17.000Z | 2022-03-03T19:53:37.000Z | #include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <time.h>
#include <esp_log.h>
#include <esp_err.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/event_groups.h>
#include <esp_camera.h>
#include <x264.h>
#include <jpeglib.h>
#include "config.h"
#include "debug.h"
#include "camera_session.h"
#include "crypto.h"
#include "streaming.h"
#define RTCP_SR 200
#define RTCP_SR_INTERVAL 5000000U
#define RTP_VERSION 2
#define RTCP_VERSION 2
#define RTP_MAX_PACKET_LENGTH 2048 // 8192
#define NTP_OFFSET 2208988800ULL
#define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL)
#define HMAC_SIZE 10
typedef struct {
uint8_t reception_report_count:5;
uint8_t padding:1;
uint8_t version:2;
uint8_t payload_type;
uint16_t length;
uint32_t sender_ssrc;
} rtcp_header_t;
typedef struct {
uint32_t ntp_timestamp_seconds;
uint32_t ntp_timestamp_picoseconds;
uint32_t rtp_timestamp;
uint32_t sender_packet_count;
uint32_t sender_octet_count;
} rtcp_sender_report_t;
typedef struct {
unsigned int cc:4; /* CSRC count */
unsigned int extension:1; /* header extension flag */
unsigned int padding:1; /* padding flag */
unsigned int version:2; /* protocol version */
unsigned int payload_type:7; /* payload type */
unsigned int marker:1; /* marker bit */
unsigned int seq:16; /* sequence number */
uint32_t timestamp; /* timestamp */
uint32_t ssrc; /* synchronization source */
uint32_t csrc[]; /* optional CSRC list */
} rtp_header_t;
uint64_t ntp_get_time() {
struct timeval tv;
if (gettimeofday(&tv, NULL)) {
ESP_LOGE(TAG, "Failed to get current time for RTCP Sender Report");
return -1;
}
return ((((uint64_t)tv.tv_sec) * 1000000 + tv.tv_usec) / 1000) * 1000 + NTP_OFFSET_US;
}
uint32_t get_time_millis() {
return xTaskGetTickCount() * portTICK_PERIOD_MS;
}
uint8_t* find_nal_start(uint8_t* start, uint8_t* end) {
if (start >= end)
return end;
uint8_t* p = start;
uint8_t state = 0;
while (p < end) {
switch (state) {
case 0:
if (*p == 0)
state++;
break;
case 1:
if (*p == 0) {
state++;
} else {
state = 0;
}
break;
case 2:
if (*p == 0) {
state++;
} else if (*p == 1) {
return p - 2;
} else {
state = 0;
}
break;
case 3:
if (*p == 1) {
return p - 3;
} else if (*p != 0) {
state = 0;
}
break;
}
p++;
}
return p;
}
static int video_socket = -1;
static int video_port = 0;
static int session_send_encrypted(streaming_session_t *session, uint8_t *buffer, size_t size) {
int encrypted_size = session_encrypt(session, buffer, size, RTP_MAX_PACKET_LENGTH);
if (encrypted_size < 0) {
ESP_LOGE(TAG, "Failed to encrypt payload (code %d)", encrypted_size);
return -1;
}
int r;
do {
r = sendto(video_socket, buffer, encrypted_size, 0,
(struct sockaddr*)&session->controller_addr, sizeof(session->controller_addr));
} while (r == -1 && errno == EAGAIN);
if (r < 0) {
ESP_LOGE(TAG, "Failed to send encrypted packet (code %d)", errno);
return -2;
}
return 0;
}
static int session_send_rtcp_sender_report(streaming_session_t *session) {
uint8_t *buffer = (uint8_t*) malloc(RTP_MAX_PACKET_LENGTH);
if (!buffer) {
ESP_LOGE(TAG, "Failed to allocate buffer for RTCP Sender Report");
return -1;
}
rtcp_header_t *rtcp_header = (rtcp_header_t*) buffer;
memset(rtcp_header, 0, sizeof(*rtcp_header));
rtcp_header->version = RTCP_VERSION;
rtcp_header->payload_type = RTCP_SR;
rtcp_header->length = htons((sizeof(rtcp_header_t) + sizeof(rtcp_sender_report_t) + 3) / 4 - 1);
rtcp_header->sender_ssrc = htonl(session->settings->video_ssrc);
rtcp_sender_report_t *sender_report = (rtcp_sender_report_t*) (buffer + sizeof(rtcp_header_t));
uint64_t ntp_time = ntp_get_time();
sender_report->ntp_timestamp_seconds = htonl(ntp_time / 1000000);
sender_report->ntp_timestamp_picoseconds = htonl(((ntp_time % 1000000) << 32) / 1000000);
sender_report->rtp_timestamp = htonl(session->timestamp);
sender_report->sender_packet_count = 0;
sender_report->sender_octet_count = 0;
ESP_LOGI(TAG, "Sending RTCP sender report");
int r = session_send_encrypted(session, buffer, sizeof(rtcp_header_t) + sizeof(rtcp_sender_report_t));
if (r < 0) {
ESP_LOGE(TAG, "Failed to send RTCP sender report packet (code %d)", r);
free(buffer);
return -1;
}
session->rtcp_sr_timestamp = get_time_millis() * 1000;
free(buffer);
return 0;
}
static int session_send_data(streaming_session_t *session, bool last) {
size_t size = session->video_buffer_ptr - session->video_buffer;
if (size <= sizeof(rtp_header_t))
return 0;
rtp_header_t *header = (rtp_header_t*) session->video_buffer;
header->version = RTP_VERSION;
header->payload_type = session->settings->video_rtp_payload_type;
header->ssrc = htonl(session->settings->video_ssrc);
header->timestamp = htonl(session->timestamp);
header->marker = last;
header->seq = htons(session->sequence);
session->sequence = (session->sequence + 1) & 0xffff;
int r = session_send_encrypted(session, session->video_buffer, size);
session->video_buffer_ptr = session->video_buffer + sizeof(rtp_header_t);
if (r < 0) {
ESP_LOGE(TAG, "Failed to send RTP packet (code %d)", r);
return -1;
}
return 0;
}
static int session_flush_buffered(streaming_session_t *session, bool last) {
size_t size = session->video_buffer_ptr - session->video_buffer;
if (size == 0)
return 0;
if (session->buffered_nals == 1) {
memmove(session->video_buffer + sizeof(rtp_header_t),
session->video_buffer + sizeof(rtp_header_t) + 3,
size - 3);
session->video_buffer_ptr -= 3;
}
if (session_send_data(session, last))
return -1;
session->buffered_nals = 0;
return 0;
}
static int session_send_nal(streaming_session_t *session, uint8_t *nal, size_t nal_size, bool last) {
int r;
if (nal_size <= session->settings->video_rtp_max_mtu) {
int buffered_size = session->video_buffer_ptr - session->video_buffer - sizeof(rtp_header_t);
if (buffered_size + 2 + nal_size > session->settings->video_rtp_max_mtu) {
r = session_flush_buffered(session, false);
if (r)
return -1;
buffered_size = 0;
}
if (buffered_size + 3 + nal_size <= session->settings->video_rtp_max_mtu) {
if (buffered_size == 0) {
*(session->video_buffer_ptr++) = 24; // STAP-A
}
*(session->video_buffer_ptr++) = (nal_size >> 8) & 0xff;
*(session->video_buffer_ptr++) = nal_size & 0xff;
memcpy(session->video_buffer_ptr, nal, nal_size);
session->video_buffer_ptr += nal_size;
session->buffered_nals++;
} else {
r = session_flush_buffered(session, false);
if (r)
return -1;
memcpy(session->video_buffer_ptr, nal, nal_size);
session->video_buffer_ptr += nal_size;
r = session_send_data(session, last);
if (r)
return -1;
}
} else {
r = session_flush_buffered(session, false);
if (r)
return -1;
uint8_t type = nal[0] & 0x1F;
uint8_t nri = nal[0] & 0x60;
uint8_t *nal_end = nal + nal_size;
nal += 1;
size_t fragment_header_size = 2;
size_t max_fragment_payload_size = session->settings->video_rtp_max_mtu - fragment_header_size;
bool first_fragment = true;
while (nal_end - nal > max_fragment_payload_size) {
session->video_buffer_ptr = session->video_buffer + sizeof(rtp_header_t);
*(session->video_buffer_ptr++) = nri | 28; // Fragmented Unit Indicator (FU-A)
*(session->video_buffer_ptr++) = (first_fragment ? 0x80 : 0x00) | type;
memcpy(session->video_buffer_ptr, nal, max_fragment_payload_size);
session->video_buffer_ptr += max_fragment_payload_size;
r = session_send_data(session, false);
if (r)
return -1;
nal += max_fragment_payload_size;
first_fragment = false;
}
session->video_buffer_ptr = session->video_buffer + sizeof(rtp_header_t);
*(session->video_buffer_ptr++) = nri | 28; // Fragmented Unit Indicator (FU-A)
*(session->video_buffer_ptr++) = 0x40 | type; // ending fragment flag
memcpy(session->video_buffer_ptr, nal, nal_end - nal);
session->video_buffer_ptr += (nal_end - nal);
r = session_send_data(session, last);
if (r)
return -1;
}
return 0;
}
const static JOCTET EOI_BUFFER[1] = { JPEG_EOI };
typedef struct {
struct jpeg_source_mgr pub;
const JOCTET *data;
size_t len;
} jpeg_memory_src_mgr;
static void jpeg_memory_src_init_source(j_decompress_ptr cinfo) {
}
static boolean jpeg_memory_src_fill_input_buffer(j_decompress_ptr cinfo) {
jpeg_memory_src_mgr *src = (jpeg_memory_src_mgr *)cinfo->src;
// No more data. Probably an incomplete image; just output EOI.
src->pub.next_input_byte = EOI_BUFFER;
src->pub.bytes_in_buffer = 1;
return TRUE;
}
static void jpeg_memory_src_skip_input_data(j_decompress_ptr cinfo, long num_bytes) {
jpeg_memory_src_mgr *src = (jpeg_memory_src_mgr *)cinfo->src;
if (src->pub.bytes_in_buffer < num_bytes) {
// Skipping over all of remaining data; output EOI.
src->pub.next_input_byte = EOI_BUFFER;
src->pub.bytes_in_buffer = 1;
} else {
// Skipping over only some of the remaining data.
src->pub.next_input_byte += num_bytes;
src->pub.bytes_in_buffer -= num_bytes;
}
}
static void jpeg_memory_src_term_source(j_decompress_ptr cinfo) {
}
static void jpeg_memory_src_set_source_mgr(j_decompress_ptr cinfo, const char* data, size_t len) {
if (cinfo->src == 0) {
cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(jpeg_memory_src_mgr));
}
jpeg_memory_src_mgr *src = (jpeg_memory_src_mgr *)cinfo->src;
src->pub.init_source = jpeg_memory_src_init_source;
src->pub.fill_input_buffer = jpeg_memory_src_fill_input_buffer;
src->pub.skip_input_data = jpeg_memory_src_skip_input_data;
src->pub.resync_to_restart = jpeg_resync_to_restart; // default
src->pub.term_source = jpeg_memory_src_term_source;
// fill the buffers
src->data = (const JOCTET *)data;
src->len = len;
src->pub.bytes_in_buffer = len;
src->pub.next_input_byte = src->data;
}
int grab_camera_frame(x264_picture_t *pic) {
camera_fb_t *fb = esp_camera_fb_get();
if (!fb) {
ESP_LOGE(TAG, "Camera capture failed");
return -1;
}
struct jpeg_decompress_struct dinfo;
struct jpeg_error_mgr jerr;
dinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&dinfo);
jpeg_memory_src_set_source_mgr(&dinfo, (const char *)fb->buf, fb->len);
jpeg_read_header(&dinfo, TRUE);
dinfo.raw_data_out = true;
dinfo.out_color_space = JCS_YCbCr;
dinfo.scale_num = VIDEO_IMAGE_SCALE_NUM;
dinfo.scale_denom = VIDEO_IMAGE_SCALE_DENOM;
jpeg_start_decompress(&dinfo);
ESP_LOGI(TAG, "JPEG output size: %dx%d", dinfo.output_width, dinfo.output_height);
#define SAMPLE_SIZE 16
uint8_t *data_y[SAMPLE_SIZE],
*data_cb[SAMPLE_SIZE/2],
*data_cr[SAMPLE_SIZE/2];
uint8_t **data[3];
data[0] = data_y;
data[1] = data_cb;
data[2] = data_cr;
for (size_t j=0; j<dinfo.output_height; ) {
for (size_t i=0; i<SAMPLE_SIZE; i+=2) {
data_y[i] = pic->img.plane[0] + dinfo.output_width * (i+j);
data_y[i+1] = pic->img.plane[0] + dinfo.output_width * (i+1+j);
data_cb[i / 2] = pic->img.plane[1] + dinfo.output_width / 2 * ((i + j) / 2);
data_cr[i / 2] = pic->img.plane[2] + dinfo.output_width / 2 * ((i + j) / 2);
}
j += jpeg_read_raw_data(&dinfo, data, SAMPLE_SIZE);
}
ESP_LOGI(TAG, "JPEG finishing");
jpeg_finish_decompress(&dinfo);
ESP_LOGI(TAG, "JPEG destroying");
jpeg_destroy_decompress(&dinfo);
ESP_LOGI(TAG, "Returning frame buffer");
esp_camera_fb_return(fb);
ESP_LOGI(TAG, "Done grabbing a frame");
return 0;
}
static streaming_session_t *streaming_sessions = NULL;
static SemaphoreHandle_t streaming_sessions_mutex = NULL;
static TaskHandle_t stream_task_handle = NULL;
static EventGroupHandle_t stream_control_events;
#define STREAM_CONTROL_EVENT_STOP (1 << 0)
void stream_task(void *arg);
int streaming_get_video_port() {
return video_port;
}
int streaming_get_audio_port() {
return video_port + 1;
}
int streaming_init() {
ESP_LOGI(TAG, "Initializing streaming");
video_socket = socket(PF_INET, SOCK_DGRAM, 0);
if (video_socket < 0) {
ESP_LOGE(TAG, "Failed to open video stream socket, error = %d", errno);
return -1;
}
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
if (bind(video_socket, (struct sockaddr*)&addr, sizeof(addr))) {
ESP_LOGE(TAG, "Failed to bind video stream socket, error = %d", errno);
return -1;
}
socklen_t addr_len = sizeof(addr);
if (getsockname(video_socket, (struct sockaddr*)&addr, &addr_len)) {
ESP_LOGE(TAG, "Failed to get port of video stream socket, error = %d", errno);
return -1;
}
video_port = ntohs(addr.sin_port);
streaming_sessions = NULL;
streaming_sessions_mutex = xSemaphoreCreateBinary();
xSemaphoreGive(streaming_sessions_mutex);
stream_control_events = xEventGroupCreate();
if (stream_control_events == NULL) {
ESP_LOGE(TAG, "Failed to create camera control event group");
return -1;
}
ESP_LOGI(TAG, "Streaming initialized");
return 0;
}
static bool stream_running() {
return stream_task_handle != NULL;
}
static void stream_start() {
if (stream_running())
return;
xEventGroupClearBits(stream_control_events, STREAM_CONTROL_EVENT_STOP);
xTaskCreate(stream_task, "Camera Stream",
4096*8, NULL, 1, &stream_task_handle);
}
static void stream_stop() {
if (!stream_running())
return;
ESP_LOGI(TAG, "Stopping video stream");
xEventGroupSetBits(stream_control_events, STREAM_CONTROL_EVENT_STOP);
}
static void streaming_sessions_lock() {
xSemaphoreTake(streaming_sessions_mutex, 5000 / portTICK_PERIOD_MS);
}
static void streaming_sessions_unlock() {
xSemaphoreGive(streaming_sessions_mutex);
}
static streaming_session_t *streaming_session_new(camera_session_t *settings) {
streaming_session_t *session = (streaming_session_t*) calloc(1, sizeof(streaming_session_t));
if (!session) {
ESP_LOGE(TAG, "Failed to allocate streaming session");
return NULL;
}
session->settings = settings;
session->started = false;
session->failed = false;
session->timestamp = 0;
session->rtcp_sr_timestamp = 0;
session->sequence = 123;
session->video_buffer = (uint8_t*) calloc(1, RTP_MAX_PACKET_LENGTH);
if (!session->video_buffer) {
ESP_LOGE(TAG, "Failed to allocate streaming session video buffer");
free(session);
return NULL;
}
session->video_buffer_ptr = session->video_buffer + sizeof(rtp_header_t);
session_init_crypto(session);
session->controller_addr.sin_family = AF_INET;
session->controller_addr.sin_port = htons(session->settings->controller_video_port);
if (inet_pton(AF_INET, session->settings->controller_ip_address, &session->controller_addr.sin_addr) <= 0) {
ESP_LOGE(TAG, "Failed to parse controller IP address");
free(session->video_buffer);
free(session);
return NULL;
}
return session;
}
void streaming_session_free(streaming_session_t *session) {
if (session->video_buffer)
free(session->video_buffer);
free(session);
}
int streaming_sessions_add(camera_session_t *settings) {
streaming_sessions_lock();
streaming_session_t *session = streaming_session_new(settings);
if (!session) {
ESP_LOGI(TAG, "Failed to create streaming session");
streaming_sessions_unlock();
return -1;
}
ESP_LOGI(TAG, "Adding streaming session");
session->next = streaming_sessions;
streaming_sessions = session;
stream_start();
streaming_sessions_unlock();
return 0;
}
void streaming_sessions_remove(camera_session_t *settings) {
streaming_sessions_lock();
ESP_LOGI(TAG, "Removing streaming session");
if (!streaming_sessions) {
streaming_sessions_unlock();
return;
}
if (streaming_sessions->settings == settings) {
streaming_session_t *s = streaming_sessions;
streaming_sessions = streaming_sessions->next;
streaming_session_free(s);
} else {
streaming_session_t *t = streaming_sessions;
while (t->next) {
if (t->next->settings == settings) {
streaming_session_t *s = t->next;
t->next = t->next->next;
streaming_session_free(s);
break;
}
t = t->next;
}
}
if (!streaming_sessions)
stream_stop();
streaming_sessions_unlock();
}
void stream_task(void *arg) {
ESP_LOGI(TAG, "Starting streaming");
ESP_LOGI(TAG, "Total free memory: %u", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
x264_param_t param;
x264_param_default(¶m);
if (x264_param_apply_profile(¶m, "baseline") < 0) {
ESP_LOGE(TAG, "Failed to intialize H.264 profile");
return;
}
if (x264_param_default_preset(¶m, "ultrafast", "zerolatency") < 0) {
ESP_LOGE(TAG, "Failed to initialize H.264 preset");
return;
}
param.i_width = VIDEO_WIDTH;
param.i_height = VIDEO_HEIGHT;
param.i_bitdepth = 8;
param.i_csp = X264_CSP_I420;
param.i_threads = 1;
// param.b_repeat_headers = 1;
param.i_keyint_max = 1;
param.rc.i_qp_constant = 26;
x264_picture_t pic, pic_out;
x264_picture_init(&pic);
pic.img.i_csp = param.i_csp;
pic.img.i_plane = 3;
pic.img.i_stride[0] = param.i_width;
pic.img.i_stride[1] = param.i_width / 2;
pic.img.i_stride[2] = param.i_width / 2;
const int plane_size = VIDEO_WIDTH * VIDEO_HEIGHT;
pic.img.plane[0] = (uint8_t*) malloc(plane_size * 3);
pic.img.plane[1] = pic.img.plane[0] + plane_size;
pic.img.plane[2] = pic.img.plane[1] + plane_size / 4;
x264_t *encoder = x264_encoder_open(¶m);
if (!encoder) {
ESP_LOGE(TAG, "Failed to open H.264 encoder");
free(pic.img.plane[0]);
return;
}
x264_nal_t *nal = NULL;
int i_nal;
int frame_size = 0;
ESP_LOGI(TAG, "Executing streaming loop");
ESP_LOGI(TAG, "Total free memory: %u", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
while (true) {
if (xEventGroupGetBits(stream_control_events) & STREAM_CONTROL_EVENT_STOP)
break;
ESP_LOGI(TAG, "Getting a frame");
ESP_LOGI(TAG, "Total free memory: %u", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
if (grab_camera_frame(&pic) < 0) {
continue;
}
ESP_LOGI(TAG, "Encoding a frame");
ESP_LOGI(TAG, "Total free memory: %u", heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
frame_size = x264_encoder_encode(encoder, &nal, &i_nal, &pic, &pic_out);
// TODO: free up pic_out
ESP_LOGI(TAG, "Encoded frame, size = %d", frame_size);
if( frame_size < 0 ) {
ESP_LOGE(TAG, "Image H264 encoding failed error = %d", frame_size);
continue;
} else if( frame_size == 0 ) {
ESP_LOGE(TAG, "Frame is empty");
continue;
}
// dump_binary("Frame: ", nal->p_payload, 20);
streaming_sessions_lock();
for (streaming_session_t *session = streaming_sessions; session; session=session->next) {
session->started = true;
session->timestamp = get_time_millis() * 1000;
if(session->rtcp_sr_timestamp + RTCP_SR_INTERVAL < session->timestamp){
if (session_send_rtcp_sender_report(session)) {
ESP_LOGE(TAG, "Error sending RTCP SenderReport to %s:%d",
session->settings->controller_ip_address,
session->settings->controller_video_port);
session->failed = true;
}
}
}
for (streaming_session_t *session = streaming_sessions; session; session=session->next) {
session->timestamp = get_time_millis() * 1000;
}
// dump_binary("Frame: ", nal->p_payload, frame_size);
uint8_t* end = nal->p_payload + frame_size;
uint8_t* nal_data = find_nal_start(nal->p_payload, end);
while (nal_data < end) {
nal_data += (nal_data[2] == 1) ? 3 : 4; // skip header
uint8_t* next_nal_data = find_nal_start(nal_data, end);
size_t nal_data_size = next_nal_data - nal_data;
for (streaming_session_t *session = streaming_sessions; session; session=session->next) {
if (session_send_nal(session, nal_data, nal_data_size, (next_nal_data == end)))
session->failed = true;
}
nal_data = next_nal_data;
}
ESP_LOGI(TAG, "Done sending frame data");
for (streaming_session_t *session = streaming_sessions; session; session=session->next) {
if (session_flush_buffered(session, true))
session->failed = true;
}
// cleanup failed streaming sessions
while (streaming_sessions && streaming_sessions->failed) {
streaming_session_t *t = streaming_sessions;
streaming_sessions = streaming_sessions->next;
streaming_session_free(t);
}
if (!streaming_sessions) {
streaming_sessions_unlock();
break;
}
streaming_session_t *t = streaming_sessions;
while (t->next) {
if (t->next->failed) {
streaming_session_t *tt = t;
t = t->next;
streaming_session_free(tt);
} else {
t = t->next;
}
}
streaming_sessions_unlock();
vTaskDelay(10 / portTICK_PERIOD_MS);
}
x264_encoder_close(encoder);
free(pic.img.plane[0]);
ESP_LOGI(TAG, "Done with stream");
stream_task_handle = NULL;
vTaskDelete(NULL);
}
| 29.086313 | 112 | 0.628895 |
bb1e71dcdc0708c01644f307ed79d36861550f01 | 628 | c | C | regression/cbmc/array-cell-sensitivity13/test.c | tobireinhard/cbmc | fc165c119985adf8db9a13493f272a2def4e79fa | [
"BSD-4-Clause"
] | 412 | 2016-04-02T01:14:27.000Z | 2022-03-27T09:24:09.000Z | regression/cbmc/array-cell-sensitivity13/test.c | tobireinhard/cbmc | fc165c119985adf8db9a13493f272a2def4e79fa | [
"BSD-4-Clause"
] | 4,671 | 2016-02-25T13:52:16.000Z | 2022-03-31T22:14:46.000Z | regression/cbmc/array-cell-sensitivity13/test.c | tobireinhard/cbmc | fc165c119985adf8db9a13493f272a2def4e79fa | [
"BSD-4-Clause"
] | 266 | 2016-02-23T12:48:00.000Z | 2022-03-22T18:15:51.000Z | #include <assert.h>
struct A
{
int data;
struct A *children[2];
};
int main(int argc, char **argv)
{
struct A root;
struct A node1, node2;
root.children[0] = argc % 2 ? &node1 : &node2;
root.children[1] = argc % 3 ? &node1 : &node2;
node1.children[0] = argc % 5 ? &node1 : &node2;
node1.children[1] = argc % 7 ? &node1 : &node2;
node2.children[0] = argc % 11 ? &node1 : &node2;
node2.children[1] = argc % 13 ? &node1 : &node2;
root.children[0]->children[1]->children[1]->children[0]->data = 1;
assert(root.children[0]->children[1]->children[1]->children[0]->data == 1);
assert(node1.data == argc);
}
| 27.304348 | 77 | 0.609873 |
633146d2f92603edf001ed84cf4c27fe1243dafa | 1,434 | h | C | include/tdp/bb/node_impl.h | jstraub/tdp | dcab53662be5b88db1538cf831707b07ab96e387 | [
"MIT-feh"
] | 1 | 2017-10-17T19:25:47.000Z | 2017-10-17T19:25:47.000Z | include/tdp/bb/node_impl.h | jstraub/tdp | dcab53662be5b88db1538cf831707b07ab96e387 | [
"MIT-feh"
] | 1 | 2018-05-02T06:04:06.000Z | 2018-05-02T06:04:06.000Z | include/tdp/bb/node_impl.h | jstraub/tdp | dcab53662be5b88db1538cf831707b07ab96e387 | [
"MIT-feh"
] | 5 | 2017-09-17T18:46:20.000Z | 2019-03-11T12:52:57.000Z | /* Copyright (c) 2015, Julian Straub <jstraub@csail.mit.edu> Licensed
* under the MIT license. See the license file LICENSE.
*/
namespace tdp {
template<class Node>
std::vector<uint32_t> CountBranchesInTree(const std::list<Node>& nodes) {
uint32_t max_lvl = 0;
for (auto& node : nodes) if (node.GetLevel() > max_lvl)
max_lvl = node.GetLevel();
std::cout << "# nodes: " << nodes.size()
<< " max depth in nodes: " << max_lvl << std::endl;
std::vector<std::map<uint64_t, uint32_t>> counts(max_lvl+1);
std::vector<std::map<uint64_t, const Node*>> nodesPerLvl(max_lvl+1);
for (auto& node : nodes) {
uint32_t node_lvl = node.GetLevel();
for (uint32_t lvl = 0; lvl < node_lvl+1; ++lvl) {
++ counts[lvl][node.GetIdAtLevel(lvl)];
if (lvl == node_lvl)
nodesPerLvl[lvl][node.GetIdAtLevel(lvl)] = &node;
else
nodesPerLvl[lvl][node.GetIdAtLevel(lvl)] = NULL;
}
}
std::vector<uint32_t> countsPerLevel(max_lvl,0);
for (uint32_t lvl = 0; lvl < max_lvl; ++lvl) {
std::cout << "@ lvl " << lvl << std::endl;
for (auto& count : counts[lvl]) {
std::cout << " id: " << count.first << "\t#:" << count.second;
if (nodesPerLvl[lvl][count.first])
std::cout << "\tinfo: " << nodesPerLvl[lvl][count.first]->ToString()
<< std::endl;
else
std::cout << std::endl;
++ countsPerLevel[lvl];
}
}
return countsPerLevel;
}
}
| 33.348837 | 76 | 0.601116 |
ebd0b27dbfb34b782b6636f289b780f9585701db | 2,877 | h | C | source/AttributeType.h | vonLeebpl/WKIrrlichtLime | 79e17540574bceaecc27049d99eb4ee2f6ca3479 | [
"Zlib"
] | 19 | 2019-06-23T15:43:58.000Z | 2021-07-22T14:22:52.000Z | source/AttributeType.h | vonLeebpl/WKIrrlichtLime | 79e17540574bceaecc27049d99eb4ee2f6ca3479 | [
"Zlib"
] | 4 | 2019-06-23T15:46:02.000Z | 2022-02-07T14:42:58.000Z | source/AttributeType.h | vonLeebpl/WKIrrlichtLime | 79e17540574bceaecc27049d99eb4ee2f6ca3479 | [
"Zlib"
] | 6 | 2019-11-17T08:42:22.000Z | 2022-01-11T07:40:17.000Z | #pragma once
#include "stdafx.h"
using namespace irr;
using namespace io;
using namespace System;
namespace IrrlichtLime {
namespace IO {
/// <summary>
/// Types of attributes available for <c>Attributes</c>.
/// </summary>
public enum class AttributeType
{
/// <summary>
/// Integer attribute.
/// </summary>
Int = EAT_INT,
/// <summary>
/// Float attribute.
/// </summary>
Float = EAT_FLOAT,
/// <summary>
/// String attribute.
/// </summary>
String = EAT_STRING,
/// <summary>
/// Boolean attribute.
/// </summary>
Bool = EAT_BOOL,
/// <summary>
/// Enumeration attribute. Read-only. Please use <see cref="Int"/> in case you need to write.
/// </summary>
Enum = EAT_ENUM, // read-only type; i don't have clear solution for implementation of adding and modifying values; read more in Attributes::AddValue() in proper switch-case region
/// <summary>
/// Color attribute.
/// </summary>
Color = EAT_COLOR,
/// <summary>
/// Floating point color attribute.
/// </summary>
Colorf = EAT_COLORF,
/// <summary>
/// 3d vector attribute.
/// </summary>
Vector3Df = EAT_VECTOR3D,
/// <summary>
/// Integer 2d vector attribute.
/// </summary>
Vector2Di = EAT_POSITION2D,
/// <summary>
/// Float point 2d vector attribute.
/// </summary>
Vector2Df = EAT_VECTOR2D,
/// <summary>
/// Rectangle attribute.
/// </summary>
Recti = EAT_RECT,
/// <summary>
/// Matrix attribute.
/// </summary>
Matrix = EAT_MATRIX,
/// <summary>
/// Quaternion attribute.
/// </summary>
Quaternion = EAT_QUATERNION,
/// <summary>
/// 3d bounding box attribute.
/// </summary>
AABBox = EAT_BBOX,
/// <summary>
/// Plane attribute.
/// </summary>
Plane3Df = EAT_PLANE,
/// <summary>
/// Triangle attribute.
/// </summary>
Triangle3Df = EAT_TRIANGLE3D,
// EAT_LINE2D // we don't support it, because we do not have Line2Df type
/// <summary>
/// Line attribute.
/// </summary>
Line3Df = EAT_LINE3D,
/// <summary>
/// Array of strings attribute.
/// </summary>
StringArray = EAT_STRINGWARRAY,
// EAT_FLOATARRAY // i have no idea how to add/read/write this type using io::IAttributes :(
// EAT_INTARRAY // (either)
/// <summary>
/// Byte array attribute.
/// </summary>
ByteArray = EAT_BINARY,
/// <summary>
/// Texture reference attribute.
/// </summary>
Texture = EAT_TEXTURE,
// EAT_USER_POINTER // we don't support it
// EAT_DIMENSION2D // we don't have Dimension2Du type; for holding Dimension2Di-type-like value user can use Vector2Di
/// <summary>
/// Unknown attribute.
/// </summary>
Unknown = EAT_UNKNOWN
};
} // end namespace IO
} // end namespace IrrlichtLime
| 21.631579 | 182 | 0.598888 |
6fdaff4b44a4399fbb12d042e97e764b617ef653 | 447 | h | C | Lab03/include/Point.h | ZhiquanW/CS590-Generative-Methods-in-Computer-Graphics | 9bf0954ff1a8353e1abafb0b9d034ad9e0651dbe | [
"Apache-2.0"
] | null | null | null | Lab03/include/Point.h | ZhiquanW/CS590-Generative-Methods-in-Computer-Graphics | 9bf0954ff1a8353e1abafb0b9d034ad9e0651dbe | [
"Apache-2.0"
] | null | null | null | Lab03/include/Point.h | ZhiquanW/CS590-Generative-Methods-in-Computer-Graphics | 9bf0954ff1a8353e1abafb0b9d034ad9e0651dbe | [
"Apache-2.0"
] | null | null | null | //
// @Author: Zhiquan Wang
// @Date: 2/29/20.
// Copyright (c) 2020 Zhiquan Wang. All rights reserved.
//
#ifndef LAB03_POINT_H
#define LAB03_POINT_H
#include <glad/glad.h>
#include <glm/glm.hpp>
class Point {
public:
static GLuint counter;
GLuint id;
glm::vec3 pos{};
Point();
Point(glm::vec3,bool= true);
bool operator <(const Point p) const ;
bool operator ==(const Point p) const ;
};
#endif //LAB03_POINT_H
| 17.88 | 56 | 0.64877 |
6fec2278c74d69dbae10e478b541cfb985cbf790 | 247 | h | C | src/app_mt/wifi/core/cc3000_spi.h | skonzem/model-t | 96e8ca32626190e7019e65b8777348191cabcef8 | [
"MIT"
] | null | null | null | src/app_mt/wifi/core/cc3000_spi.h | skonzem/model-t | 96e8ca32626190e7019e65b8777348191cabcef8 | [
"MIT"
] | null | null | null | src/app_mt/wifi/core/cc3000_spi.h | skonzem/model-t | 96e8ca32626190e7019e65b8777348191cabcef8 | [
"MIT"
] | null | null | null |
#ifndef __CC3000_SPI_H__
#define __CC3000_SPI_H__
#include <string.h>
#include <stdlib.h>
#include "types.h"
void spi_open(void);
void spi_close(void);
uint8_t* spi_get_buffer(void);
void spi_write(uint16_t usLength);
#endif
| 14.529412 | 35 | 0.716599 |
173edba23801cf90eeec9cb10401d281b8e8d1d2 | 1,679 | h | C | content/browser/media/capture/cursor_renderer_mac.h | google-ar/chromium | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 777 | 2017-08-29T15:15:32.000Z | 2022-03-21T05:29:41.000Z | content/browser/media/capture/cursor_renderer_mac.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 66 | 2017-08-30T18:31:18.000Z | 2021-08-02T10:59:35.000Z | content/browser/media/capture/cursor_renderer_mac.h | harrymarkovskiy/WebARonARCore | 2441c86a5fd975f09a6c30cddb57dfb7fc239699 | [
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 123 | 2017-08-30T01:19:34.000Z | 2022-03-17T22:55:31.000Z | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_
#import <AppKit/AppKit.h>
#include "base/mac/scoped_nsobject.h"
#include "content/browser/media/capture/cursor_renderer.h"
#import "ui/base/cocoa/tracking_area.h"
@interface CursorRendererMouseTracker : NSObject {
@private
ui::ScopedCrTrackingArea trackingArea_;
// The view on which mouse movement is detected.
base::scoped_nsobject<NSView> capturedView_;
// Runs on any mouse interaction from user.
base::Closure mouseInteractionObserver_;
}
- (instancetype)initWithView:(NSView*)nsView;
// Register an observer for mouse interaction.
- (void)registerMouseInteractionObserver:(const base::Closure&)observer;
@end
namespace content {
class CONTENT_EXPORT CursorRendererMac : public CursorRenderer {
public:
explicit CursorRendererMac(gfx::NativeView view);
~CursorRendererMac() final;
// CursorRender implementation.
bool IsCapturedViewActive() final;
gfx::Size GetCapturedViewSize() final;
gfx::Point GetCursorPositionInView() final;
gfx::NativeCursor GetLastKnownCursor() final;
SkBitmap GetLastKnownCursorImage(gfx::Point* hot_point) final;
private:
// Called for mouse activity events.
void OnMouseEvent();
NSView* const view_;
base::scoped_nsobject<CursorRendererMouseTracker> mouse_tracker_;
DISALLOW_COPY_AND_ASSIGN(CursorRendererMac);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_CURSOR_RENDERER_MAC_H_
| 27.983333 | 73 | 0.792138 |
e2d3b5f1babb5393245f4c2c65a04cfa270fd936 | 16,343 | h | C | chisel/Gorilla++/emulator/Top.h | seyedmaysamlavasani/GorillaPP | 348c308c4f08b41e5d59448b3558e9622755ac6f | [
"BSD-3-Clause"
] | 2 | 2018-06-18T22:04:55.000Z | 2021-03-03T20:49:16.000Z | chisel/Gorilla++/emulator/Top.h | seyedmaysamlavasani/GorillaPP | 348c308c4f08b41e5d59448b3558e9622755ac6f | [
"BSD-3-Clause"
] | null | null | null | chisel/Gorilla++/emulator/Top.h | seyedmaysamlavasani/GorillaPP | 348c308c4f08b41e5d59448b3558e9622755ac6f | [
"BSD-3-Clause"
] | 1 | 2021-06-11T01:58:35.000Z | 2021-06-11T01:58:35.000Z | #include "emulator.h"
class Top_t : public mod_t {
public:
dat_t<1> Top_generatedTop_offComp_vThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_offComp_vThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_offComp_vThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_offComp_vThreadEncoder__io_chosen__prev;
dat_t<32> Top_generatedTop_offComp__outputReg_0;
dat_t<32> Top_generatedTop_offComp__outputReg_0_shadow;
dat_t<32> Top_generatedTop_offComp__outputReg_0__prev;
dat_t<1> Top_generatedTop__reset;
dat_t<1> Top_generatedTop__reset__prev;
dat_t<1> Top_generatedTop_offComp__reset;
dat_t<1> Top_generatedTop_offComp__reset__prev;
dat_t<1> Top_generatedTop_mainComp__io_pcOut_bits_request;
dat_t<1> Top_generatedTop_mainComp__io_pcOut_bits_request__prev;
dat_t<1> Top_generatedTop_offComp__io_pcIn_bits_request;
dat_t<1> Top_generatedTop_offComp__io_pcIn_bits_request__prev;
dat_t<16> Top_generatedTop_mainComp__io_pcOut_bits_moduleId;
dat_t<16> Top_generatedTop_mainComp__io_pcOut_bits_moduleId__prev;
dat_t<16> Top_generatedTop_offComp__io_pcIn_bits_moduleId;
dat_t<16> Top_generatedTop_offComp__io_pcIn_bits_moduleId__prev;
dat_t<1> Top_generatedTop_mainComp__io_pcOut_valid;
dat_t<1> Top_generatedTop_mainComp__io_pcOut_valid__prev;
dat_t<1> Top_generatedTop_offComp__io_pcIn_valid;
dat_t<1> Top_generatedTop_offComp__io_pcIn_valid__prev;
dat_t<1> R0;
dat_t<1> R0_shadow;
dat_t<1> R0__prev;
dat_t<16> R1;
dat_t<16> R1_shadow;
dat_t<16> R1__prev;
dat_t<4> Top_generatedTop_mainComp__io_pcOut_bits_pcType;
dat_t<4> Top_generatedTop_mainComp__io_pcOut_bits_pcType__prev;
dat_t<4> Top_generatedTop_offComp__io_pcIn_bits_pcType;
dat_t<4> Top_generatedTop_offComp__io_pcIn_bits_pcType__prev;
dat_t<4> R2;
dat_t<4> R2_shadow;
dat_t<4> R2__prev;
dat_t<8> Top_generatedTop_mainComp__io_pcOut_bits_portId;
dat_t<8> Top_generatedTop_mainComp__io_pcOut_bits_portId__prev;
dat_t<8> Top_generatedTop_offComp__io_pcIn_bits_portId;
dat_t<8> Top_generatedTop_offComp__io_pcIn_bits_portId__prev;
dat_t<8> R3;
dat_t<8> R3_shadow;
dat_t<8> R3__prev;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_ready;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_ready__prev;
dat_t<1> Top_generatedTop_offComp__io_out_ready;
dat_t<1> Top_generatedTop_offComp__io_out_ready__prev;
dat_t<1> Top_generatedTop_offComp_rThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_offComp_rThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_offComp_rThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_offComp_rThreadEncoder__io_chosen__prev;
dat_t<1> Top_generatedTop_offComp__io_out_valid;
dat_t<1> Top_generatedTop_offComp__io_out_valid__prev;
dat_t<5> R4;
dat_t<5> R4_shadow;
dat_t<5> R4__prev;
dat_t<1> Top_generatedTop_offComp_sThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_offComp_sThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_offComp_sThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_offComp_sThreadEncoder__io_chosen__prev;
dat_t<1> Top_generatedTop_offComp__io_in_ready;
dat_t<1> Top_generatedTop_offComp__io_in_ready__prev;
dat_t<1> Top_generatedTop_mainComp_rThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_mainComp_rThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_mainComp_rThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_mainComp_rThreadEncoder__io_chosen__prev;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_req_valid;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_req_valid__prev;
dat_t<1> Top_generatedTop_offComp__io_in_valid;
dat_t<1> Top_generatedTop_offComp__io_in_valid__prev;
dat_t<5> R5;
dat_t<5> R5_shadow;
dat_t<5> R5__prev;
dat_t<5> R6;
dat_t<5> R6_shadow;
dat_t<5> R6__prev;
dat_t<20> R7;
dat_t<20> R7_shadow;
dat_t<20> R7__prev;
dat_t<8> Top_generatedTop_offComp__EmitReturnState_0;
dat_t<8> Top_generatedTop_offComp__EmitReturnState_0_shadow;
dat_t<8> Top_generatedTop_offComp__EmitReturnState_0__prev;
dat_t<10> Top_generatedTop_mainComp__mainOff_incrementFactor_req_tag;
dat_t<10> Top_generatedTop_mainComp__mainOff_incrementFactor_req_tag__prev;
dat_t<10> Top_generatedTop_offComp__io_in_tag;
dat_t<10> Top_generatedTop_offComp__io_in_tag__prev;
dat_t<10> Top_generatedTop_offComp__inputTag_0;
dat_t<10> Top_generatedTop_offComp__inputTag_0_shadow;
dat_t<10> Top_generatedTop_offComp__inputTag_0__prev;
dat_t<1> Top_generatedTop_offComp__subStateTh_0;
dat_t<1> Top_generatedTop_offComp__subStateTh_0_shadow;
dat_t<1> Top_generatedTop_offComp__subStateTh_0__prev;
dat_t<8> Top_generatedTop_offComp__State_0;
dat_t<8> Top_generatedTop_offComp__State_0_shadow;
dat_t<8> Top_generatedTop_offComp__State_0__prev;
dat_t<1> R8;
dat_t<1> R8_shadow;
dat_t<1> R8__prev;
dat_t<20> R9;
dat_t<20> R9_shadow;
dat_t<20> R9__prev;
dat_t<20> Top_generatedTop_mainComp__io_pcOut_bits_pcValue;
dat_t<20> Top_generatedTop_mainComp__io_pcOut_bits_pcValue__prev;
dat_t<20> Top_generatedTop_offComp__io_pcIn_bits_pcValue;
dat_t<20> Top_generatedTop_offComp__io_pcIn_bits_pcValue__prev;
dat_t<20> R10;
dat_t<20> R10_shadow;
dat_t<20> R10__prev;
dat_t<1> R11;
dat_t<1> R11_shadow;
dat_t<1> R11__prev;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_b;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_b_shadow;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_b__prev;
dat_t<32> Top__io_in_bits_a;
dat_t<32> Top__io_in_bits_a__prev;
dat_t<32> Top_generatedTop__io_in_bits_a;
dat_t<32> Top_generatedTop__io_in_bits_a__prev;
dat_t<32> Top_generatedTop_mainComp__io_in_bits_a;
dat_t<32> Top_generatedTop_mainComp__io_in_bits_a__prev;
dat_t<1> Top_generatedTop_mainComp_sThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_mainComp_sThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_mainComp_sThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_mainComp_sThreadEncoder__io_chosen__prev;
dat_t<1> Top__io_in_valid;
dat_t<1> Top__io_in_valid__prev;
dat_t<1> Top_generatedTop__io_in_valid;
dat_t<1> Top_generatedTop__io_in_valid__prev;
dat_t<1> Top_generatedTop_mainComp__io_in_valid;
dat_t<1> Top_generatedTop_mainComp__io_in_valid__prev;
dat_t<32> Top_generatedTop_mainComp__inputReg_0_a;
dat_t<32> Top_generatedTop_mainComp__inputReg_0_a_shadow;
dat_t<32> Top_generatedTop_mainComp__inputReg_0_a__prev;
dat_t<10> Top_generatedTop_offComp__io_out_tag;
dat_t<10> Top_generatedTop_offComp__io_out_tag__prev;
dat_t<10> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_tag;
dat_t<10> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_tag__prev;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_valid;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_valid__prev;
dat_t<1> Top_generatedTop_mainComp_vThreadEncoder__io_valid_0;
dat_t<1> Top_generatedTop_mainComp_vThreadEncoder__io_valid_0__prev;
dat_t<1> Top_generatedTop_mainComp_vThreadEncoder__io_chosen;
dat_t<1> Top_generatedTop_mainComp_vThreadEncoder__io_chosen__prev;
dat_t<32> Top_generatedTop_offComp__io_out_bits;
dat_t<32> Top_generatedTop_offComp__io_out_bits__prev;
dat_t<32> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_bits;
dat_t<32> Top_generatedTop_mainComp__mainOff_incrementFactor_rep_bits__prev;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_a;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_a_shadow;
dat_t<32> Top_generatedTop_mainComp__outputReg_0_a__prev;
dat_t<10> Top__io_in_tag;
dat_t<10> Top__io_in_tag__prev;
dat_t<10> Top_generatedTop__io_in_tag;
dat_t<10> Top_generatedTop__io_in_tag__prev;
dat_t<10> Top_generatedTop_mainComp__io_in_tag;
dat_t<10> Top_generatedTop_mainComp__io_in_tag__prev;
dat_t<10> Top_generatedTop_mainComp__inputTag_0;
dat_t<10> Top_generatedTop_mainComp__inputTag_0_shadow;
dat_t<10> Top_generatedTop_mainComp__inputTag_0__prev;
dat_t<1> Top_generatedTop_mainComp__reset;
dat_t<1> Top_generatedTop_mainComp__reset__prev;
dat_t<4> Top__io_pcIn_bits_pcType;
dat_t<4> Top__io_pcIn_bits_pcType__prev;
dat_t<4> Top_generatedTop__io_pcIn_bits_pcType;
dat_t<4> Top_generatedTop__io_pcIn_bits_pcType__prev;
dat_t<4> Top_generatedTop_mainComp__io_pcIn_bits_pcType;
dat_t<4> Top_generatedTop_mainComp__io_pcIn_bits_pcType__prev;
dat_t<1> Top__io_pcIn_bits_request;
dat_t<1> Top__io_pcIn_bits_request__prev;
dat_t<1> Top_generatedTop__io_pcIn_bits_request;
dat_t<1> Top_generatedTop__io_pcIn_bits_request__prev;
dat_t<1> Top_generatedTop_mainComp__io_pcIn_bits_request;
dat_t<1> Top_generatedTop_mainComp__io_pcIn_bits_request__prev;
dat_t<1> Top__io_pcIn_valid;
dat_t<1> Top__io_pcIn_valid__prev;
dat_t<1> Top_generatedTop__io_pcIn_valid;
dat_t<1> Top_generatedTop__io_pcIn_valid__prev;
dat_t<1> Top_generatedTop_mainComp__io_pcIn_valid;
dat_t<1> Top_generatedTop_mainComp__io_pcIn_valid__prev;
dat_t<1> Top__io_out_ready;
dat_t<1> Top__io_out_ready__prev;
dat_t<1> Top_generatedTop__io_out_ready;
dat_t<1> Top_generatedTop__io_out_ready__prev;
dat_t<1> Top_generatedTop_mainComp__io_out_ready;
dat_t<1> Top_generatedTop_mainComp__io_out_ready__prev;
dat_t<1> Top_generatedTop_mainComp__io_out_valid;
dat_t<1> Top_generatedTop_mainComp__io_out_valid__prev;
dat_t<5> R12;
dat_t<5> R12_shadow;
dat_t<5> R12__prev;
dat_t<1> Top_generatedTop_mainComp__io_in_ready;
dat_t<1> Top_generatedTop_mainComp__io_in_ready__prev;
dat_t<5> R13;
dat_t<5> R13_shadow;
dat_t<5> R13__prev;
dat_t<5> R14;
dat_t<5> R14_shadow;
dat_t<5> R14__prev;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_req_ready;
dat_t<1> Top_generatedTop_mainComp__mainOff_incrementFactor_req_ready__prev;
dat_t<20> R15;
dat_t<20> R15_shadow;
dat_t<20> R15__prev;
dat_t<20> R16;
dat_t<20> R16_shadow;
dat_t<20> R16__prev;
dat_t<20> R17;
dat_t<20> R17_shadow;
dat_t<20> R17__prev;
dat_t<1> R18;
dat_t<1> R18_shadow;
dat_t<1> R18__prev;
dat_t<20> R19;
dat_t<20> R19_shadow;
dat_t<20> R19__prev;
dat_t<8> Top__io_pcIn_bits_portId;
dat_t<8> Top__io_pcIn_bits_portId__prev;
dat_t<8> Top_generatedTop__io_pcIn_bits_portId;
dat_t<8> Top_generatedTop__io_pcIn_bits_portId__prev;
dat_t<8> Top_generatedTop_mainComp__io_pcIn_bits_portId;
dat_t<8> Top_generatedTop_mainComp__io_pcIn_bits_portId__prev;
dat_t<16> Top__io_pcIn_bits_moduleId;
dat_t<16> Top__io_pcIn_bits_moduleId__prev;
dat_t<16> Top_generatedTop__io_pcIn_bits_moduleId;
dat_t<16> Top_generatedTop__io_pcIn_bits_moduleId__prev;
dat_t<16> Top_generatedTop_mainComp__io_pcIn_bits_moduleId;
dat_t<16> Top_generatedTop_mainComp__io_pcIn_bits_moduleId__prev;
dat_t<20> Top__io_pcIn_bits_pcValue;
dat_t<20> Top__io_pcIn_bits_pcValue__prev;
dat_t<20> Top_generatedTop__io_pcIn_bits_pcValue;
dat_t<20> Top_generatedTop__io_pcIn_bits_pcValue__prev;
dat_t<20> Top_generatedTop_mainComp__io_pcIn_bits_pcValue;
dat_t<20> Top_generatedTop_mainComp__io_pcIn_bits_pcValue__prev;
dat_t<20> R20;
dat_t<20> R20_shadow;
dat_t<20> R20__prev;
dat_t<8> R21;
dat_t<8> R21_shadow;
dat_t<8> R21__prev;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_ready_received;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_ready_received_shadow;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_ready_received__prev;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadReadyRequest;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadReadyRequest_shadow;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadReadyRequest__prev;
dat_t<32> Top_generatedTop_mainComp__counter_0;
dat_t<32> Top_generatedTop_mainComp__counter_0_shadow;
dat_t<32> Top_generatedTop_mainComp__counter_0__prev;
dat_t<8> Top_generatedTop_mainComp__EmitReturnState_0;
dat_t<8> Top_generatedTop_mainComp__EmitReturnState_0_shadow;
dat_t<8> Top_generatedTop_mainComp__EmitReturnState_0__prev;
dat_t<8> Top_generatedTop_mainComp__State_0;
dat_t<8> Top_generatedTop_mainComp__State_0_shadow;
dat_t<8> Top_generatedTop_mainComp__State_0__prev;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_valid_received_0;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_valid_received_0_shadow;
dat_t<1> Top_generatedTop_mainComp__incrementFactor_valid_received_0__prev;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadValidRequest_0;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadValidRequest_0_shadow;
dat_t<1> Top_generatedTop_mainComp__incrementFactorPortHadValidRequest_0__prev;
dat_t<1> Top_generatedTop_mainComp__subStateTh_0;
dat_t<1> Top_generatedTop_mainComp__subStateTh_0_shadow;
dat_t<1> Top_generatedTop_mainComp__subStateTh_0__prev;
dat_t<4> R22;
dat_t<4> R22_shadow;
dat_t<4> R22__prev;
dat_t<1> R23;
dat_t<1> R23_shadow;
dat_t<1> R23__prev;
dat_t<16> R24;
dat_t<16> R24_shadow;
dat_t<16> R24__prev;
dat_t<1> R25;
dat_t<1> R25_shadow;
dat_t<1> R25__prev;
dat_t<32> Top_generatedTop_mainComp__io_out_bits_b;
dat_t<32> Top_generatedTop_mainComp__io_out_bits_b__prev;
dat_t<32> Top_generatedTop__io_out_bits_b;
dat_t<32> Top_generatedTop__io_out_bits_b__prev;
dat_t<32> Top__io_out_bits_b;
dat_t<32> Top__io_out_bits_b__prev;
dat_t<32> Top_generatedTop_mainComp__io_out_bits_a;
dat_t<32> Top_generatedTop_mainComp__io_out_bits_a__prev;
dat_t<32> Top_generatedTop__io_out_bits_a;
dat_t<32> Top_generatedTop__io_out_bits_a__prev;
dat_t<32> Top__io_out_bits_a;
dat_t<32> Top__io_out_bits_a__prev;
dat_t<1> Top_generatedTop__io_out_valid;
dat_t<1> Top_generatedTop__io_out_valid__prev;
dat_t<1> Top__io_out_valid;
dat_t<1> Top__io_out_valid__prev;
dat_t<10> Top_generatedTop_mainComp__io_out_tag;
dat_t<10> Top_generatedTop_mainComp__io_out_tag__prev;
dat_t<10> Top_generatedTop__io_out_tag;
dat_t<10> Top_generatedTop__io_out_tag__prev;
dat_t<10> Top__io_out_tag;
dat_t<10> Top__io_out_tag__prev;
dat_t<1> Top_generatedTop__io_in_ready;
dat_t<1> Top_generatedTop__io_in_ready__prev;
dat_t<1> Top__io_in_ready;
dat_t<1> Top__io_in_ready__prev;
dat_t<1> Top_generatedTop_offComp__io_pcOut_bits_request;
dat_t<1> Top_generatedTop_offComp__io_pcOut_bits_request__prev;
dat_t<1> Top_generatedTop__io_pcOut_bits_request;
dat_t<1> Top_generatedTop__io_pcOut_bits_request__prev;
dat_t<1> Top__io_pcOut_bits_request;
dat_t<1> Top__io_pcOut_bits_request__prev;
dat_t<16> Top_generatedTop_offComp__io_pcOut_bits_moduleId;
dat_t<16> Top_generatedTop_offComp__io_pcOut_bits_moduleId__prev;
dat_t<16> Top_generatedTop__io_pcOut_bits_moduleId;
dat_t<16> Top_generatedTop__io_pcOut_bits_moduleId__prev;
dat_t<16> Top__io_pcOut_bits_moduleId;
dat_t<16> Top__io_pcOut_bits_moduleId__prev;
dat_t<4> Top_generatedTop_offComp__io_pcOut_bits_pcType;
dat_t<4> Top_generatedTop_offComp__io_pcOut_bits_pcType__prev;
dat_t<4> Top_generatedTop__io_pcOut_bits_pcType;
dat_t<4> Top_generatedTop__io_pcOut_bits_pcType__prev;
dat_t<4> Top__io_pcOut_bits_pcType;
dat_t<4> Top__io_pcOut_bits_pcType__prev;
dat_t<8> Top_generatedTop_offComp__io_pcOut_bits_portId;
dat_t<8> Top_generatedTop_offComp__io_pcOut_bits_portId__prev;
dat_t<8> Top_generatedTop__io_pcOut_bits_portId;
dat_t<8> Top_generatedTop__io_pcOut_bits_portId__prev;
dat_t<8> Top__io_pcOut_bits_portId;
dat_t<8> Top__io_pcOut_bits_portId__prev;
dat_t<20> Top_generatedTop_offComp__io_pcOut_bits_pcValue;
dat_t<20> Top_generatedTop_offComp__io_pcOut_bits_pcValue__prev;
dat_t<20> Top_generatedTop__io_pcOut_bits_pcValue;
dat_t<20> Top_generatedTop__io_pcOut_bits_pcValue__prev;
dat_t<20> Top__io_pcOut_bits_pcValue;
dat_t<20> Top__io_pcOut_bits_pcValue__prev;
dat_t<1> Top_generatedTop_offComp__io_pcOut_valid;
dat_t<1> Top_generatedTop_offComp__io_pcOut_valid__prev;
dat_t<1> Top_generatedTop__io_pcOut_valid;
dat_t<1> Top_generatedTop__io_pcOut_valid__prev;
dat_t<1> Top__io_pcOut_valid;
dat_t<1> Top__io_pcOut_valid__prev;
dat_t<32> io_in_bits_b;
dat_t<32> io_in_bits_b__prev;
void init ( bool rand_init = false );
void clock_lo ( dat_t<1> reset );
void clock_hi ( dat_t<1> reset );
void print ( FILE* f );
bool scan ( FILE* f );
void dump ( FILE* f, int t );
};
| 46.428977 | 82 | 0.84862 |
53dcb469d02540e8e02e4f11f60799a81f1143ad | 9,478 | c | C | OfflineSAM/OfflineAddAdmin.c | zha0/PSBits | 8ea4684b41ac693ea200ee40a90e3edcfe30e916 | [
"Unlicense"
] | null | null | null | OfflineSAM/OfflineAddAdmin.c | zha0/PSBits | 8ea4684b41ac693ea200ee40a90e3edcfe30e916 | [
"Unlicense"
] | null | null | null | OfflineSAM/OfflineAddAdmin.c | zha0/PSBits | 8ea4684b41ac693ea200ee40a90e3edcfe30e916 | [
"Unlicense"
] | null | null | null | #ifndef UNICODE
#error Unicode environment required. I will fix it sooner or later.
#include <Windows.h>
#include <tchar.h>
#include <NTSecAPI.h>
#include <sddl.h>
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
typedef PVOID OFFLINELSA_HANDLE, * POFFLINELSA_HANDLE;
typedef NTSTATUS(WINAPI* LSAOFFLINEOPENPOLICY)(LPWSTR, POFFLINELSA_HANDLE);
typedef NTSTATUS(WINAPI* LSAOFFLINECLOSE)(OFFLINELSA_HANDLE);
typedef NTSTATUS(WINAPI* LSAOFFLINEENUMERATEACCOUNTS)(OFFLINELSA_HANDLE, PLSA_ENUMERATION_HANDLE, PVOID*, ULONG, PULONG);
typedef NTSTATUS(WINAPI* LSAOFFLINEFREEMEMORY)(PVOID);
typedef NTSTATUS(WINAPI* LSAOFFLINEENUMERATEACCOUNTRIGHTS)(OFFLINELSA_HANDLE, PSID, PLSA_UNICODE_STRING*, PULONG);
typedef NTSTATUS(WINAPI* LSAOFFLINEADDACCOUNTRIGHTS)(OFFLINELSA_HANDLE, PSID, PLSA_UNICODE_STRING, ULONG);
HMODULE hOfflineLsaDLL;
OFFLINELSA_HANDLE hOfflineLsaPolicy;
NTSTATUS
NTAPI
LsaOfflineOpenPolicy(
LPWSTR pszWindowsDirectory,
POFFLINELSA_HANDLE PolicyHandle
)
{
static LSAOFFLINEOPENPOLICY pfnLsaOfflineOpenPolicy = NULL;
if (NULL == pfnLsaOfflineOpenPolicy)
{
pfnLsaOfflineOpenPolicy = (LSAOFFLINEOPENPOLICY)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineOpenPolicy");
}
if (NULL == pfnLsaOfflineOpenPolicy)
{
_tprintf(_T("LsaOfflineOpenPolicy could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineOpenPolicy(pszWindowsDirectory, PolicyHandle);
}
NTSTATUS
NTAPI
LsaOfflineClose(
OFFLINELSA_HANDLE PolicyHandle
)
{
static LSAOFFLINECLOSE pfnLsaOfflineClose = NULL;
if (NULL == pfnLsaOfflineClose)
{
pfnLsaOfflineClose = (LSAOFFLINECLOSE)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineClose");
}
if (NULL == pfnLsaOfflineClose)
{
_tprintf(_T("LsaOfflineClose could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineClose(PolicyHandle);
}
NTSTATUS
NTAPI
LsaOfflineEnumerateAccounts(
OFFLINELSA_HANDLE PolicyHandle,
PLSA_ENUMERATION_HANDLE EnumerationContext,
PVOID* Buffer,
ULONG PreferredMaximumLength,
PULONG CountReturned
)
{
static LSAOFFLINEENUMERATEACCOUNTS pfnLsaOfflineEnumerateAccounts = NULL;
if (NULL == pfnLsaOfflineEnumerateAccounts)
{
pfnLsaOfflineEnumerateAccounts = (LSAOFFLINEENUMERATEACCOUNTS)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineEnumerateAccounts");
}
if (NULL == pfnLsaOfflineEnumerateAccounts)
{
_tprintf(_T("LsaOfflineEnumerateAccounts could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineEnumerateAccounts(
PolicyHandle,
EnumerationContext,
Buffer,
PreferredMaximumLength,
CountReturned);
}
NTSTATUS
NTAPI
LsaOfflineFreeMemory(
PVOID Buffer
)
{
static LSAOFFLINEFREEMEMORY pfnLsaOfflineFreeMemory = NULL;
if (NULL == pfnLsaOfflineFreeMemory)
{
pfnLsaOfflineFreeMemory = (LSAOFFLINEFREEMEMORY)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineFreeMemory");
}
if (NULL == pfnLsaOfflineFreeMemory)
{
_tprintf(_T("LsaOfflineClose could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineFreeMemory(Buffer);
}
NTSTATUS
NTAPI
LsaOfflineEnumerateAccountRights(
OFFLINELSA_HANDLE PolicyHandle,
PSID AccountSid,
PLSA_UNICODE_STRING* UserRights,
PULONG CountOfRights
)
{
static LSAOFFLINEENUMERATEACCOUNTRIGHTS pfnLsaOfflineEnumerateAccountRights = NULL;
if (NULL == pfnLsaOfflineEnumerateAccountRights)
{
pfnLsaOfflineEnumerateAccountRights = (LSAOFFLINEENUMERATEACCOUNTRIGHTS)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineEnumerateAccountRights");
}
if (NULL == pfnLsaOfflineEnumerateAccountRights)
{
_tprintf(_T("LsaOfflineEnumerateAccountRights could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineEnumerateAccountRights(
PolicyHandle,
AccountSid,
UserRights,
CountOfRights);
}
NTSTATUS
NTAPI
LsaOfflineAddAccountRights(
OFFLINELSA_HANDLE PolicyHandle,
PSID AccountSid,
PLSA_UNICODE_STRING UserRights,
ULONG CountOfRights
)
{
static LSAOFFLINEADDACCOUNTRIGHTS pfnLsaOfflineAddAccountRights = NULL;
if (NULL == pfnLsaOfflineAddAccountRights)
{
pfnLsaOfflineAddAccountRights = (LSAOFFLINEADDACCOUNTRIGHTS)(LPVOID)GetProcAddress(hOfflineLsaDLL, "LsaOfflineAddAccountRights");
}
if (NULL == pfnLsaOfflineAddAccountRights)
{
_tprintf(_T("LsaOfflineEnumerateAccountRights could not be found.\r\n"));
_exit(ERROR_PROC_NOT_FOUND);
}
return pfnLsaOfflineAddAccountRights(
PolicyHandle,
AccountSid,
UserRights,
CountOfRights);
}
int _tmain(int argc, _TCHAR** argv, _TCHAR** envp)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(envp);
if (argv[1] == NULL)
{
_tprintf(_T("Usage: OfflineAddAdmin.exe windows_folder\r\n"));
_tprintf(_T(" where windows_folder is the offline Windows folder i.e. D:\\Windows\r\n"));
return -1;
}
hOfflineLsaDLL = LoadLibrary(_T("offlinelsa.dll"));
if (NULL == hOfflineLsaDLL)
{
_tprintf(_T("offlinelsa.dll could not be found.\r\n"));
return ERROR_DELAY_LOAD_FAILED;
}
NTSTATUS status;
status = LsaOfflineOpenPolicy(argv[1], &hOfflineLsaPolicy);
if (!NT_SUCCESS(status))
{
_tprintf(_T("ERROR: LsaOfflineOpenPolicy() returned %li.\r\n"), LsaNtStatusToWinError(status));
return (int)LsaNtStatusToWinError(status);
}
LSA_ENUMERATION_HANDLE lsaEnumContext = { 0 };
PLSA_ENUMERATION_INFORMATION plsaSidsBuffer = NULL;
ULONG ulCountOfSids = 0;
// LsaOfflineEnumerateAccounts() is undocumented but I have made some assumptions based on my best knowledge and experiments:
// - PreferredMaximumLength is ignored.
// - EnumerationContext idea is somewhat similar to LsaEnumerateTrustedDomainsEx()
// - Buffer the LSA_ENUMERATION_INFORMATION - per analogiam ad LsaEnumerateAccountsWithUserRight()
// - Never seen STATUS_MORE_ENTRIES as a result, but stadard checking covers it. See documentation for LsaEnumerateTrustedDomainsEx().
// - Checking buffer == NULL just in case.
// - Calling LsaOfflineFreeMemory as I'd call LsaFreeMemory.
status = LsaOfflineEnumerateAccounts(hOfflineLsaPolicy, &lsaEnumContext, (PVOID*)&plsaSidsBuffer, 0, &ulCountOfSids);
if (!NT_SUCCESS(status) || (!plsaSidsBuffer))
{
_tprintf(_T("ERROR: LsaOfflineEnumerateAccounts() returned %li.\r\n"), LsaNtStatusToWinError(status));
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return (int)LsaNtStatusToWinError(status);
}
_tprintf(_T("Number of SIDs in offline SAM: %li.\r\n"), ulCountOfSids);
PLSA_UNICODE_STRING plsaRightsBuffer = NULL;
ULONG ulCountOfRights = 0;
BYTE pSidAdmins[SECURITY_MAX_SID_SIZE] = { 0 };
BYTE pSidUsers[SECURITY_MAX_SID_SIZE] = { 0 };
DWORD dwSidSize;
BOOL bStatus;
dwSidSize = sizeof(pSidAdmins);
bStatus = CreateWellKnownSid(WinBuiltinAdministratorsSid, NULL, (PSID)pSidAdmins, &dwSidSize);
if (!bStatus)
{
_tprintf(_T("ERROR: CreateWellKnownSid() returned %lu\r\n"), GetLastError());
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return (int)GetLastError();
}
dwSidSize = sizeof(pSidUsers);
bStatus = CreateWellKnownSid(WinBuiltinUsersSid, NULL, (PSID)pSidUsers, &dwSidSize);
if (!bStatus)
{
_tprintf(_T("ERROR: CreateWellKnownSid() returned %lu\r\n"), GetLastError());
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return (int)GetLastError();
}
//let's go through sids trying to spot admins and grab privileges into the buffer
for (ULONG i = 0; i < ulCountOfSids; i++)
{
PSID sid = plsaSidsBuffer[i].Sid;
LPTSTR szSidStr = NULL;
ConvertSidToStringSid(sid, &szSidStr);
_tprintf(_T("SID[%i]: %s\r\n"), i, szSidStr);
if (!EqualSid(pSidAdmins, sid))
{
LocalFree(szSidStr);
continue;
}
status = LsaOfflineEnumerateAccountRights(hOfflineLsaPolicy, sid, &plsaRightsBuffer, &ulCountOfRights);
if (!NT_SUCCESS(status))
{
_tprintf(_T("ERROR: LsaOfflineEnumerateAccountRights() returned %li.\r\n"), LsaNtStatusToWinError(status));
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return (int)LsaNtStatusToWinError(status);
}
_tprintf(_T(" Number of rights assigned to %s in offline SAM: %li.\r\n"), szSidStr, ulCountOfRights);
LocalFree(szSidStr);
for (ULONG j = 0; j < ulCountOfRights; j++)
{
_tprintf(_T(" priv[%i]: %wZ\r\n"), j, plsaRightsBuffer[j]);
}
}
if (!plsaRightsBuffer) //no privs??
{
_tprintf(_T("ERROR: No privileges for local administrators found.\r\n"));
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return ERROR_NO_SUCH_GROUP;
}
//let's go through sids trying to spot users and apply privileges from the buffer
for (ULONG i = 0; i < ulCountOfSids; i++)
{
PSID sid = plsaSidsBuffer[i].Sid;
if (!EqualSid(pSidUsers, sid))
{
continue;
}
status = LsaOfflineAddAccountRights(hOfflineLsaPolicy, sid, plsaRightsBuffer, ulCountOfRights);
if (!NT_SUCCESS(status))
{
_tprintf(_T("ERROR: LsaOfflineAddAccountRights() returned %li.\r\n"), LsaNtStatusToWinError(status));
LsaOfflineClose(hOfflineLsaPolicy); //let's try, ignoring the result
return (int)LsaNtStatusToWinError(status);
}
}
LsaOfflineFreeMemory(plsaRightsBuffer); //best effort, ignore failures.
LsaOfflineFreeMemory(plsaSidsBuffer); //best effort, ignore failures.
status = LsaOfflineClose(hOfflineLsaPolicy);
if (!NT_SUCCESS(status))
{
_tprintf(_T("ERROR: LsaOfflineClose() returned %li.\r\n"), LsaNtStatusToWinError(status));
return (int)LsaNtStatusToWinError(status);
}
if (NULL != hOfflineLsaDLL)
{
FreeLibrary(hOfflineLsaDLL);
}
_tprintf(_T("Done.\r\n"));
}
| 30.973856 | 149 | 0.769466 |
53fb8016d86276c9389b4899f7b84e153413a16b | 4,160 | c | C | agent/qtcreator/src/writerthread.c | toby1984/threadwatch | fdc4898c98acacf0e4013bb8563348b6fc6f0082 | [
"Apache-2.0"
] | 4 | 2016-08-13T19:08:06.000Z | 2021-09-03T02:13:22.000Z | agent/qtcreator/src/writerthread.c | toby1984/threadwatch | fdc4898c98acacf0e4013bb8563348b6fc6f0082 | [
"Apache-2.0"
] | null | null | null | agent/qtcreator/src/writerthread.c | toby1984/threadwatch | fdc4898c98acacf0e4013bb8563348b6fc6f0082 | [
"Apache-2.0"
] | 1 | 2016-10-22T14:13:05.000Z | 2016-10-22T14:13:05.000Z | /*
Copyright 2013 Tobias Gierke <tobias.gierke@code-sourcery.de>
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 <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include "config.h"
#include "global.h"
#include "writerthread.h"
#include "events.h"
static pthread_t writerThreadId;
static FILE *outputFile = NULL;
static volatile int terminateWriter = 0;
static void *writerThread(RingBuffer *buffer);
void startWriterThread(RingBuffer *buffer,char *file)
{
int err;
unsigned int magic = FILEHEADER_MAGIC;
pthread_attr_t tattr;
if ( configuration.verboseMode ) {
printf("INFO: Started writer thread that writes to file %s\n",file);
}
if ( ! (outputFile=fopen(file,"w+") ) )
{
fprintf(stderr,"ERROR: Failed to open output file %s\n",file);
abort();
}
// write header
if ( fwrite(&magic,1,sizeof(magic),outputFile) != sizeof(magic) ) {
fprintf(stderr,"ERROR: Failed to write to output file %s\n",file);
abort();
}
/* initialized with default attributes */
pthread_attr_init(&tattr);
/* call an appropriate functions to alter a default value */
pthread_attr_setstacksize(&tattr , 1 * 1024 * 1024);
if ( ( err = pthread_create( &writerThreadId , &tattr , (void *(*)(void *)) &writerThread , buffer ) ) ) {
fprintf( stderr,"ERROR: Failed to create pthread , err=%d\n", err);
abort();
}
}
static void writeMember(void *data,size_t byteCount)
{
int bytesWritten = fwrite( data , 1 , byteCount , outputFile );
if ( bytesWritten != byteCount )
{
fprintf(stderr,"ERROR: Failed to write %d bytes to output file\n",byteCount);
abort();
}
}
static void writeRecordToFile(DataRecord *record)
{
// write common fields
writeMember( &record->type , sizeof( record->type ) );
writeMember( &record->uniqueThreadId , sizeof( record->uniqueThreadId ) );
writeMember( &record->timestamp , sizeof( record->timestamp ) );
switch( record->type )
{
case EVENT_THREAD_START:
printf("Writing thread name %s\n",&record->startEvent.threadName[0]);
writeMember( &record->startEvent.threadName[0] , sizeof( record->startEvent.threadName ) );
break;
case EVENT_THREAD_DEATH:
break;
case EVENT_THREAD_SAMPLE:
writeMember( &record->stateChangeEvent.state , sizeof( record->stateChangeEvent.state ) );
break;
default:
fprintf(stderr,"ERROR: Internal error, don't know how to write record with type %d\n",record->type);
abort();
}
#ifdef DEBUG
printf("Writing record to file (type: %d)\n",record->type);
fflush(stdout);
#endif
}
static void *writerThread(RingBuffer *buffer)
{
#ifdef DEBUG
printf("Writer thread is running.");
#endif
do
{
while( readRecord( buffer , &writeRecordToFile ) );
usleep( WRITERTHREAD_SLEEP_TIME_MILLIS * 1000);
__sync_synchronize();
} while ( ! terminateWriter );
#ifdef DEBUG
printf("Writer thread is terminating.");
#endif
while( readRecord( buffer , &writeRecordToFile ) );
fflush(outputFile);
fclose(outputFile);
if ( configuration.verboseMode ) {
printf("INFO: Closed output file.\n");
}
return NULL;
}
void terminateWriterThread()
{
#ifdef DEBUG
printf("Asking writer thread to terminate.");
#endif
__sync_synchronize();
terminateWriter = 1;
if ( outputFile != NULL && pthread_join( writerThreadId , NULL ) )
{
fprintf(stderr,"ERROR: Failed to join() with writer thread");
}
}
| 27.919463 | 112 | 0.655769 |
c42a424a012d352e329f04dc73208cfd8205493a | 1,299 | h | C | NAMD_2.12_Source/charm-6.7.1/src/libs/ck-libs/search/problem.h | scottkwarren/config-db | fb5c3da2465e5cff0ad30950493b11d452bd686b | [
"MIT"
] | 1 | 2019-01-17T20:07:23.000Z | 2019-01-17T20:07:23.000Z | NAMD_2.12_Source/charm-6.7.1/src/libs/ck-libs/search/problem.h | scottkwarren/config-db | fb5c3da2465e5cff0ad30950493b11d452bd686b | [
"MIT"
] | null | null | null | NAMD_2.12_Source/charm-6.7.1/src/libs/ck-libs/search/problem.h | scottkwarren/config-db | fb5c3da2465e5cff0ad30950493b11d452bd686b | [
"MIT"
] | null | null | null | /*
* Parallel state space search library
*
* Jonathan A. Booth
* Sun Mar 2 22:39:32 CST 2003
*/
#ifndef __UIUC_CHARM_PROBLEM_H
#define __UIUC_CHARM_PROBLEM_H
#include <charm++.h>
#include <ckbitvector.h>
#include <cklists.h>
#include <pup.h>
class problem : public PUP::able {
public:
// Declared public so the child classes can mess with these without a
// stupid set of functions to read and write them. You should leave both
// these fields set at their defaults when you create a child class of
// problem.
CkChareID Parent;
int Root;
CkBitVector Priority;
public:
// I define these
problem();
problem(const problem &p);
problem(CkMigrateMessage *m);
// User must define the following functions in their child class
virtual void children(CkQ<problem *> *list) = 0;// Return children of node
virtual problem * clone() = 0; // Clone this node
virtual int depth(); // How far are we?
virtual int depthToSolution(); // and How far is the answer?
virtual void print(); // Print this node
virtual void pup(PUP::er &p); // Pack/unpack this node
virtual bool solution() = 0; // Node is solution?
// This is required to make pup work with an abstract class
PUPable_abstract(problem);
};
#endif /* __UIUC_CHARM_PROBLEM_H */
| 28.23913 | 76 | 0.692841 |
3fafef986da1fb6e6f2a67d488874bf3f324ca3a | 536 | h | C | src/Mobs.h | delenko/Game | 767d24781ac8bc248a637e58e02597e7031941d2 | [
"Apache-2.0"
] | null | null | null | src/Mobs.h | delenko/Game | 767d24781ac8bc248a637e58e02597e7031941d2 | [
"Apache-2.0"
] | null | null | null | src/Mobs.h | delenko/Game | 767d24781ac8bc248a637e58e02597e7031941d2 | [
"Apache-2.0"
] | null | null | null | #pragma once
class Mobs
{
private:
unsigned long health, attack, defense, magic, magic_def, level;
public:
void setHealth(unsigned long sHealth);
unsigned long getHealth();
void setAttack(unsigned long sAttack);
unsigned long getAttack();
void setDefense(unsigned long sDefense);
unsigned long getDefense();
void setMagic(unsigned long sMagic);
unsigned long getMagic();
void setMagicDef(unsigned long sMagicDef);
unsigned long getMagicDef();
void setLevel(unsigned long sLevel);
unsigned long getLevel();
Mobs();
};
| 22.333333 | 64 | 0.759328 |
b2031fa38ebadf0d0e2b64b7e51d409026c6a39a | 636 | c | C | basic/2017/10/18/mq/send.c | zing-dev/learn-c | 193e5f419bf9503aaca93b451b2f2f61bcb668ac | [
"Apache-2.0"
] | 1 | 2020-06-01T14:19:55.000Z | 2020-06-01T14:19:55.000Z | basic/2017/10/18/mq/send.c | zhangrxiang/learn-c | 193e5f419bf9503aaca93b451b2f2f61bcb668ac | [
"Apache-2.0"
] | null | null | null | basic/2017/10/18/mq/send.c | zhangrxiang/learn-c | 193e5f419bf9503aaca93b451b2f2f61bcb668ac | [
"Apache-2.0"
] | null | null | null | //
// Created by zhangrongxiang on 2017/10/18 10:43
// File send
//
#include "mq.h"
int main() {
struct mq_attr mq_attr;
mq_attr.mq_msgsize = MQ_MSGSIZE;
mq_attr.mq_maxmsg = MQ_MAXMSG;
int mqd;
if (mq_unlink(NAME) == 0)
fprintf(stdout, "Message queue %s removed from system.\n", NAME);
mqd = mq_open(NAME, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, &mq_attr);
if (mqd == -1) {
perror("mq_open error");
}
char *string = "hello world";
if (mq_send(mqd, string, mq_attr.mq_msgsize, 1) == -1) {
perror("mq_send error");
exit(-2);
}
return 0;
} | 24.461538 | 91 | 0.592767 |
8bbb7502857009c2a87a25be298118c0d6dad448 | 354 | h | C | RemoteUI.framework/RUIDetailButtonElement.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | RemoteUI.framework/RUIDetailButtonElement.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | RemoteUI.framework/RUIDetailButtonElement.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/RemoteUI.framework/RemoteUI
*/
@interface RUIDetailButtonElement : RUIElement {
long long _visibility;
}
@property (nonatomic) long long visibility;
- (id)initWithAttributes:(id)arg1 parent:(id)arg2;
- (void)setVisibility:(long long)arg1;
- (long long)visibility;
@end
| 22.125 | 71 | 0.757062 |
6a66e1054eeafae2432a9cedfd3dd5f649acaadf | 344 | h | C | FYKeyBoard/DemoTableViewController.h | sdwangxianwen/FYKeyBoard | 8340185a5fc41f12db0be42a5b1f49e531d6335e | [
"MIT"
] | null | null | null | FYKeyBoard/DemoTableViewController.h | sdwangxianwen/FYKeyBoard | 8340185a5fc41f12db0be42a5b1f49e531d6335e | [
"MIT"
] | null | null | null | FYKeyBoard/DemoTableViewController.h | sdwangxianwen/FYKeyBoard | 8340185a5fc41f12db0be42a5b1f49e531d6335e | [
"MIT"
] | null | null | null | //
// DemoTableViewController.h
// FYKeyBoard
//
// Created by wang on 2020/6/7.
// Copyright © 2020 wang. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface DemoTableViewController : UITableViewController
@property (nonatomic, strong)void(^(selectNameBlock))(NSString *name);
@end
NS_ASSUME_NONNULL_END
| 19.111111 | 70 | 0.755814 |
acd26e6bc2c4f4b8422e84d4edd452aa8310f1ae | 3,004 | h | C | robot2019-ros/roborts_decision/example_behavior/shoot_behavior.h | junhuizhou/ROS_Learning | bb3a0c867ba2bd147bbd59176cf1224c09a63914 | [
"MIT"
] | null | null | null | robot2019-ros/roborts_decision/example_behavior/shoot_behavior.h | junhuizhou/ROS_Learning | bb3a0c867ba2bd147bbd59176cf1224c09a63914 | [
"MIT"
] | 1 | 2021-05-07T07:30:11.000Z | 2021-05-07T07:30:11.000Z | robot2019-ros/roborts_decision/example_behavior/shoot_behavior.h | junhuizhou/ROS_Learning | bb3a0c867ba2bd147bbd59176cf1224c09a63914 | [
"MIT"
] | null | null | null | #ifndef ROBORTS_DECISION_SHOOT_BEHAVIOR_H
#define ROBORTS_DECISION_SHOOT_BEHAVIOR_H
#include "io/io.h"
#include "../blackboard/blackboard.h"
#include "../executor/chassis_executor.h"
#include "../executor/shoot_executor.h"
#include "../behavior_tree/behavior_state.h"
#include "../proto/decision.pb.h"
#include "roborts_msgs/ShootCmd.h"
#include "line_iterator.h"
namespace roborts_decision {
class ShootBehavior {
public:
ShootBehavior(ShootExecutor* &shoot_executor, ChassisExecutor* &chassis_executor, Blackboard* &blackboard,
const std::string &proto_file_path) :
shoot_executor_(shoot_executor), chassis_executor_(chassis_executor), blackboard_(blackboard) {
if (!LoadParam(proto_file_path)) {
ROS_ERROR("%s can't open file", __FUNCTION__);
}
}
void Run() {
// float enemy_x_shooter = (float)blackboard_->GetEnemyInCamera().pose.position.x/1000 + offset_x_;
// std::cout << "enemy_x_shooter" << enemy_x_shooter << std::endl;
// if (enemy_x_shooter < half_robot_length_ && enemy_x_shooter > -half_robot_length_) {
// auto executor_state = Update();
// std::cout << "state: " << (int)(executor_state) << std::endl;
// std::cout << "send shoot_cmd" << std::endl;
// //shootdecision();
// shoot_cmd_.request.mode = 1;
// shoot_cmd_.request.number = 1;
// shoot_executor_->Execute(shoot_cmd_);
// //if(shoot_executor_->GetIsPublished()){
// //blackboard_->MinusShootNum(shoot_cmd_);
// //}
// }
chassis_executor_->Execute(blackboard_->GetGimbalYaw());
}
void Cancel() {
shoot_executor_->Cancel();
}
BehaviorState Update() {
return shoot_executor_->Update();
}
~ShootBehavior() = default;
bool LoadParam(const std::string &proto_file_path) {
roborts_decision::DecisionConfig decision_config;
if (!roborts_common::ReadProtoFromTextFile(proto_file_path, &decision_config)) {
return false;
}
offset_x_ = decision_config.offset_x();
half_robot_length_ = decision_config.half_robot_length();
return true;
}
private:
void shootdecision() {
int CD;
int f_max;
//update parameters
if (blackboard_->GetRemainHP() >= 400){
CD = 120;
}
else{
CD = 240;
}
// v~d determine v by d
//determine max f
if((360 - blackboard_->GetShooterHeat() - blackboard_->GetShootVel() * blackboard_->GetBulletNum()) >= 0){
f_max = 20;
}
else{
f_max = CD * blackboard_->GetBulletNum() / (blackboard_->GetShootVel() * blackboard_->GetBulletNum() + blackboard_->GetShooterHeat() - 360);
}
//mode 0 stop 1 once 2 continuous
shoot_cmd_.request.mode = 1;
shoot_cmd_.request.number = 1;
}
//! executor
ShootExecutor* const shoot_executor_;
ChassisExecutor* const chassis_executor_;
roborts_msgs::ShootCmd shoot_cmd_;
//! perception information
Blackboard* const blackboard_;
float offset_x_;
float half_robot_length_;
};
}
#endif //ROBORTS_DECISION_SHOOT_BEHAVIOR_H
| 27.309091 | 148 | 0.683422 |
ac0a5233bd57f92ce4f308ce01e2cbbb09fc9d57 | 524 | h | C | macOS/10.13/AddressBook.framework/ABGroupCopyPasteboardData.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.13/AddressBook.framework/ABGroupCopyPasteboardData.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.13/AddressBook.framework/ABGroupCopyPasteboardData.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/AddressBook.framework/Versions/A/AddressBook
*/
@interface ABGroupCopyPasteboardData : NSObject <ABPasteboardData> {
ABGroup * _group;
}
@property (atomic, readonly, copy) NSString *debugDescription;
@property (atomic, readonly, copy) NSString *description;
@property (atomic, readonly) unsigned long long hash;
@property (atomic, readonly) Class superclass;
- (void)dealloc;
- (id)initWithGroup:(id)arg1;
- (void)writeToPasteboard:(id)arg1;
@end
| 27.578947 | 81 | 0.763359 |
3896735c49ee252abd3c90d2789e8486ddb60237 | 594 | h | C | dist/AzulCore/include/GraphicsObject_ColorNoTexture.h | anunez97/fergilnad-game-engine | 75528633d32aed41223e0f52d8d7715073d9210a | [
"MIT"
] | null | null | null | dist/AzulCore/include/GraphicsObject_ColorNoTexture.h | anunez97/fergilnad-game-engine | 75528633d32aed41223e0f52d8d7715073d9210a | [
"MIT"
] | null | null | null | dist/AzulCore/include/GraphicsObject_ColorNoTexture.h | anunez97/fergilnad-game-engine | 75528633d32aed41223e0f52d8d7715073d9210a | [
"MIT"
] | null | null | null | #ifndef GRAPHICS_OBJECT_COLOR_NO_TEXTURE_H
#define GRAPHICS_OBJECT_COLOR_NO_TEXTURE_H
#include "GraphicsObject.h"
class GraphicsObject_ColorNoTexture :public GraphicsObject
{
public:
GraphicsObject_ColorNoTexture(Model *model, ShaderObject *pShaderObj);
protected:
// Rendermaterial contract
virtual void privSetState() override;
virtual void privSetDataGPU( Camera *pCam ) override;
virtual void privDraw() override;
virtual void privRestoreState() override;
public:
// data: place uniform instancing here
GraphicsObject_ColorNoTexture() = delete;
};
#endif | 25.826087 | 72 | 0.784512 |
55594d7d1cd975b2774d23a48f258a29a1dbf991 | 141 | h | C | tests/cpp/default/Error_if_control28.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | null | null | null | tests/cpp/default/Error_if_control28.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | 4 | 2019-12-07T08:08:29.000Z | 2021-01-22T00:19:10.000Z | tests/cpp/default/Error_if_control28.h | zaimoni/Z.C- | 7ca97ec0af14d092c87a25e07d7ed486c7912266 | [
"BSL-1.0"
] | null | null | null | // default\Error_if_control28.h
// code coverage: unary - of pointer
// (C)2009 Kenneth Boyd, license: MIT.txt
#if (-"A")[0]
#endif
| 17.625 | 42 | 0.638298 |
e1a2845f08b63e065aff8fa470daa7c749d6784c | 301 | h | C | _ABVolumeHUDOrientationManager.h | jacc/Ultrasound | fab66d43a0136316efd6a4fe464d731356d75f9f | [
"MIT"
] | 61 | 2019-06-19T10:09:34.000Z | 2022-02-28T12:42:16.000Z | _ABVolumeHUDOrientationManager.h | Mighel881/Ultrasound | 9b4180dc2335a9c694d0a950f67400d0eed33f41 | [
"MIT"
] | 10 | 2019-06-19T11:40:55.000Z | 2020-08-19T16:37:01.000Z | _ABVolumeHUDOrientationManager.h | Mighel881/Ultrasound | 9b4180dc2335a9c694d0a950f67400d0eed33f41 | [
"MIT"
] | 20 | 2019-06-19T13:29:04.000Z | 2020-03-02T13:33:07.000Z | //
// _ABVolumeHUDOrientationManager.h
// Ultrasound
//
// Created by Ayden Panhuyzen on 2019-03-02.
// Copyright © 2018 Ayden Panhuyzen. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Headers.h"
@interface _ABVolumeHUDOrientationManager : NSObject <SBUIActiveOrientationObserver>
@end | 23.153846 | 84 | 0.757475 |
0e2a171abcc667bfe2938c1ddea6ed8ddfe6b08e | 4,384 | h | C | src/xraylib-error-private.h | mschollmeier/xraylib | abf5005cd2a9c8d42d7d70a0f1ef21b6c6bd7ccd | [
"BSD-3-Clause"
] | 85 | 2015-03-10T07:21:36.000Z | 2022-03-15T18:08:13.000Z | src/xraylib-error-private.h | mschollmeier/xraylib | abf5005cd2a9c8d42d7d70a0f1ef21b6c6bd7ccd | [
"BSD-3-Clause"
] | 107 | 2015-01-30T13:50:38.000Z | 2022-03-20T17:56:52.000Z | src/xraylib-error-private.h | mschollmeier/xraylib | abf5005cd2a9c8d42d7d70a0f1ef21b6c6bd7ccd | [
"BSD-3-Clause"
] | 49 | 2015-01-06T20:14:34.000Z | 2022-02-05T18:02:15.000Z | /* Copyright (C) 2018 Tom Schoonjans
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.
* The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Tom Schoonjans '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 Tom Schoonjans BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef XRAYLIB_ERROR_PRIVATE_H
#define XRAYLIB_ERROR_PRIVATE_H
#include "xraylib.h"
#include "xraylib-error.h"
#include <stdarg.h>
/*
* This file is mostly copy-pasted from GLib's error methods...
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else /* !__GNUC__ */
#define GNUC_PRINTF( format_idx, arg_idx )
#endif /* !__GNUC__ */
XRL_EXTERN
xrl_error* xrl_error_new(xrl_error_code code, const char *format, ...) GNUC_PRINTF (2, 3);
XRL_EXTERN
xrl_error* xrl_error_new_literal(xrl_error_code code, const char *message);
XRL_EXTERN
xrl_error* xrl_error_new_valist(xrl_error_code code, const char *format, va_list args) GNUC_PRINTF(2, 0);
XRL_EXTERN
void xrl_set_error(xrl_error **err, xrl_error_code code , const char *format, ...) GNUC_PRINTF (3, 4);
XRL_EXTERN
void xrl_set_error_literal(xrl_error **err, xrl_error_code code, const char *message);
/* predefined error messages */
#define Z_OUT_OF_RANGE "Z out of range"
#define NEGATIVE_ENERGY "Energy must be strictly positive"
#define NEGATIVE_DENSITY "Density must be strictly positive"
#define NEGATIVE_Q "q must be positive"
#define NEGATIVE_PZ "pz must be positive"
#define INVALID_SHELL "Invalid shell for this atomic number"
#define INVALID_LINE "Invalid line for this atomic number"
#define INVALID_CK "Invalid Coster-Kronig transition for this atomic number"
#define INVALID_AUGER "Invalid Auger transition macro for this atomic number"
#define UNKNOWN_SHELL "Unknown shell macro provided"
#define UNKNOWN_LINE "Unknown line macro provided"
#define UNKNOWN_CK "Unknown Coster-Kronig transition macro provided"
#define UNKNOWN_AUGER "Unknown Auger transition macro provided"
#define UNAVAILABLE_JUMP_FACTOR "Jump factor unavailable for element and shell"
#define UNAVAILABLE_FLUOR_YIELD "Fluorescence yield unavailable for atomic number and shell"
#define TOO_LOW_EXCITATION_ENERGY "The excitation energy too low to excite the shell"
#define UNAVAILABLE_PHOTO_CS "Photoionization cross section unavailable for atomic number and energy"
#define UNAVAILABLE_RAD_RATE "Radiative rate unavailable for this atomic number and line macro"
#define UNAVAILABLE_CK "Coster-Kronig transition probability unavailable for this atomic number and transition macro"
#define UNKNOWN_COMPOUND "Compound is not a valid chemical formula and is not present in the NIST compound database"
#define MALLOC_ERROR "Could not allocate memory: %s"
#define INVALID_MILLER "Miller indices cannot all be zero"
#define NEGATIVE_DEBYE_FACTOR "Debye-Waller factor must be strictly positive"
#define CRYSTAL_NULL "Crystal cannot be NULL"
#define SPLINT_X_TOO_LOW "Spline extrapolation is not allowed"
#define SPLINT_X_TOO_HIGH "Spline extrapolation is not allowed"
#define LININTERP_X_TOO_LOW "Linear extrapolation is not allowed"
#define LININTERP_X_TOO_HIGH "Linear extrapolation is not allowed"
#endif
| 56.205128 | 709 | 0.804973 |
6dd1f1421d07a20b1ed60a0b045510e0690f46a6 | 858 | h | C | src/inform-1.0.0/include/inform/pid.h | ELIFE-ASU/rinform | c8050f1fa6ea586ac641f7ab76b15c5b2542de26 | [
"MIT"
] | 1 | 2018-08-01T13:51:16.000Z | 2018-08-01T13:51:16.000Z | src/inform-1.0.0/include/inform/pid.h | cran/rinform | c3631b2d9f7922f778644f29052f5200532c7c37 | [
"MIT"
] | 19 | 2017-06-21T00:58:59.000Z | 2019-04-16T00:05:26.000Z | src/inform-1.0.0/include/inform/pid.h | cran/rinform | c3631b2d9f7922f778644f29052f5200532c7c37 | [
"MIT"
] | 3 | 2017-12-01T08:22:26.000Z | 2021-02-04T01:09:01.000Z | // Copyright 2016-2017 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once
#include <inform/error.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct inform_pid_source
{
size_t *name;
struct inform_pid_source **above;
struct inform_pid_source **below;
size_t size, n_above, n_below;
double imin;
double pi;
} inform_pid_source;
typedef struct inform_pid_lattice
{
inform_pid_source **sources;
inform_pid_source *top;
inform_pid_source *bottom;
size_t size;
} inform_pid_lattice;
EXPORT void inform_pid_lattice_free(inform_pid_lattice *l);
EXPORT inform_pid_lattice *inform_pid(int const *stimulus, int const *responses, size_t l,
size_t n, int bs, int const *br, inform_error *err);
#ifdef __cplusplus
}
#endif
| 22 | 90 | 0.737762 |
0d7974d83326c6043c97b04a8ea4a23b65a7734e | 35,124 | h | C | Libraries/Infra/Sfr/TC29B/_Reg/IfxMinimcds_regdef.h | lvgl/lv_port_aurix | b50cba7ad4d3a033ea8eba83b40dc262d1b0ebb6 | [
"MIT"
] | 2 | 2021-03-18T12:04:50.000Z | 2021-04-28T10:52:46.000Z | Libraries/Infra/Sfr/TC29B/_Reg/IfxMinimcds_regdef.h | lvgl/lv_port_aurix | b50cba7ad4d3a033ea8eba83b40dc262d1b0ebb6 | [
"MIT"
] | null | null | null | Libraries/Infra/Sfr/TC29B/_Reg/IfxMinimcds_regdef.h | lvgl/lv_port_aurix | b50cba7ad4d3a033ea8eba83b40dc262d1b0ebb6 | [
"MIT"
] | 2 | 2020-12-13T16:00:45.000Z | 2021-05-21T08:23:26.000Z | /**
* \file IfxMinimcds_regdef.h
* \brief
* \copyright Copyright (c) 2016 Infineon Technologies AG. All rights reserved.
*
* Version: TC29XB_UM_V1.3.R0
* Specification: tc29xB_um_v1.3_MCSFR.xml (Revision: UM_V1.3)
* MAY BE CHANGED BY USER [yes/no]: No
*
* IMPORTANT NOTICE
*
* Infineon Technologies AG (Infineon) is supplying this file for use
* exclusively with Infineon's microcontroller products. This file can be freely
* distributed within development tools that are supporting such microcontroller
* products.
*
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
* \defgroup IfxLld_Minimcds Minimcds
* \ingroup IfxLld
*
* \defgroup IfxLld_Minimcds_Bitfields Bitfields
* \ingroup IfxLld_Minimcds
*
* \defgroup IfxLld_Minimcds_union Union
* \ingroup IfxLld_Minimcds
*
* \defgroup IfxLld_Minimcds_struct Struct
* \ingroup IfxLld_Minimcds
*
*/
#ifndef IFXMINIMCDS_REGDEF_H
#define IFXMINIMCDS_REGDEF_H 1
/******************************************************************************/
#include "Ifx_TypesReg.h"
/******************************************************************************/
/** \addtogroup IfxLld_Minimcds_Bitfields
* \{ */
/** \brief Action Definition Register */
typedef struct _Ifx_MINIMCDS_ACT_Bits
{
Ifx_Strict_32Bit AIS0:5; /**< \brief [4:0] Action Input Selector (rw) */
Ifx_Strict_32Bit AIQ0:2; /**< \brief [6:5] Action Input Qualifier (rw) */
Ifx_Strict_32Bit LV0:1; /**< \brief [7:7] Action Input Level Mode (rw) */
Ifx_Strict_32Bit AIS1:5; /**< \brief [12:8] Action Input Selector (rw) */
Ifx_Strict_32Bit AIQ1:2; /**< \brief [14:13] Action Input Qualifier (rw) */
Ifx_Strict_32Bit LV1:1; /**< \brief [15:15] Action Input Level Mode (rw) */
Ifx_Strict_32Bit AIS2:5; /**< \brief [20:16] Action Input Selector (rw) */
Ifx_Strict_32Bit AIQ2:2; /**< \brief [22:21] Action Input Qualifier (rw) */
Ifx_Strict_32Bit LV2:1; /**< \brief [23:23] Action Input Level Mode (rw) */
Ifx_Strict_32Bit AIS3:5; /**< \brief [28:24] Action Input Selector (rw) */
Ifx_Strict_32Bit AIQ3:2; /**< \brief [30:29] Action Input Qualifier (rw) */
Ifx_Strict_32Bit LV3:1; /**< \brief [31:31] Action Input Level Mode (rw) */
} Ifx_MINIMCDS_ACT_Bits;
/** \brief Clock Control Register */
typedef struct _Ifx_MINIMCDS_CLC_Bits
{
Ifx_Strict_32Bit DISR:1; /**< \brief [0:0] Module Disable Request Bit (rw) */
Ifx_Strict_32Bit DISS:1; /**< \brief [1:1] Module Disable Status Bit (rh) */
Ifx_Strict_32Bit reserved_2:30; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_CLC_Bits;
/** \brief Counter Control Register */
typedef struct _Ifx_MINIMCDS_CNT_CCL_Bits
{
Ifx_Strict_32Bit INC0:7; /**< \brief [6:0] Count Input Selector (rw) */
Ifx_Strict_32Bit ILV0:1; /**< \brief [7:7] Count Input Level Mode (rw) */
Ifx_Strict_32Bit CLR0:6; /**< \brief [13:8] Clear Input Selector (rw) */
Ifx_Strict_32Bit reserved_14:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit CLV0:1; /**< \brief [15:15] Clear Input Level Mode (rw) */
Ifx_Strict_32Bit INC1:7; /**< \brief [22:16] Count Input Selector (rw) */
Ifx_Strict_32Bit ILV1:1; /**< \brief [23:23] Count Input Level Mode (rw) */
Ifx_Strict_32Bit CLR1:6; /**< \brief [29:24] Clear Input Selector (rw) */
Ifx_Strict_32Bit reserved_30:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit CLV1:1; /**< \brief [31:31] Clear Input Level Mode (rw) */
} Ifx_MINIMCDS_CNT_CCL_Bits;
/** \brief Current Count Register */
typedef struct _Ifx_MINIMCDS_CNT_CNT_Bits
{
Ifx_Strict_32Bit COUNT:16; /**< \brief [15:0] Current Counter (rh) */
Ifx_Strict_32Bit reserved_16:16; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_CNT_CNT_Bits;
/** \brief Counter Limit Register */
typedef struct _Ifx_MINIMCDS_CNT_LMT_Bits
{
Ifx_Strict_32Bit LIMIT:16; /**< \brief [15:0] Counter Limit (rw) */
Ifx_Strict_32Bit reserved_16:14; /**< \brief \internal Reserved */
Ifx_Strict_32Bit MOD0:1; /**< \brief [30:30] Modulo Count Control (rw) */
Ifx_Strict_32Bit MOD1:1; /**< \brief [31:31] Modulo Count Control (rw) */
} Ifx_MINIMCDS_CNT_LMT_Bits;
/** \brief MCDS Control Register */
typedef struct _Ifx_MINIMCDS_CT_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit KOK:1; /**< \brief [5:5] Key OK Flag (rh) */
Ifx_Strict_32Bit reserved_6:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit KAV:1; /**< \brief [7:7] Key Available Flag (rh) */
Ifx_Strict_32Bit reserved_8:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit EN:1; /**< \brief [13:13] MCDS Enable Flag (rh) */
Ifx_Strict_32Bit CLRE:1; /**< \brief [14:14] Clear MCDS Enable Flag (w) */
Ifx_Strict_32Bit SETE:1; /**< \brief [15:15] Set MCDS Enable Flag (w) */
Ifx_Strict_32Bit BED:1; /**< \brief [16:16] Bus Error Disable Flag (rw) */
Ifx_Strict_32Bit reserved_17:2; /**< \brief \internal Reserved */
Ifx_Strict_32Bit BED_P:1; /**< \brief [19:19] Bus Error Disable Protection (w) */
Ifx_Strict_32Bit reserved_20:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit IRA:1; /**< \brief [21:21] Invalid Read Access Flag (rh) */
Ifx_Strict_32Bit CLRI:1; /**< \brief [22:22] Clear Invalid Access Bits (w) */
Ifx_Strict_32Bit IWA:1; /**< \brief [23:23] Invalid Write Access Flag (rh) */
Ifx_Strict_32Bit reserved_24:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit RES:1; /**< \brief [29:29] MCDS Reset Flag (rh) */
Ifx_Strict_32Bit reserved_30:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit SETR:1; /**< \brief [31:31] MCDS Reset Request Bit (w) */
} Ifx_MINIMCDS_CT_Bits;
/** \brief Event Definition Register */
typedef struct _Ifx_MINIMCDS_EVT_Bits
{
Ifx_Strict_32Bit EIQ0:2; /**< \brief [1:0] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ1:2; /**< \brief [3:2] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ2:2; /**< \brief [5:4] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ3:2; /**< \brief [7:6] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ4:2; /**< \brief [9:8] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ5:2; /**< \brief [11:10] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ6:2; /**< \brief [13:12] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ7:2; /**< \brief [15:14] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ8:2; /**< \brief [17:16] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ9:2; /**< \brief [19:18] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ10:2; /**< \brief [21:20] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ11:2; /**< \brief [23:22] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ12:2; /**< \brief [25:24] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ13:2; /**< \brief [27:26] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ14:2; /**< \brief [29:28] Event Input Qualifier (rw) */
Ifx_Strict_32Bit EIQ15:2; /**< \brief [31:30] Event Input Qualifier (rw) */
} Ifx_MINIMCDS_EVT_Bits;
/** \brief Trace Buffer Bottom Register */
typedef struct _Ifx_MINIMCDS_FIFOBOT_Bits
{
Ifx_Strict_32Bit reserved_0:10; /**< \brief \internal Reserved */
Ifx_Strict_32Bit BOTTOM:3; /**< \brief [12:10] Trace Buffer lower Bound (rw) */
Ifx_Strict_32Bit reserved_13:19; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_FIFOBOT_Bits;
/** \brief Trace Buffer Control Register */
typedef struct _Ifx_MINIMCDS_FIFOCTL_Bits
{
Ifx_Strict_32Bit TRG:1; /**< \brief [0:0] Trigger Received Flag (rh) */
Ifx_Strict_32Bit FFE:1; /**< \brief [1:1] FIFO Feeder Empty (rh) */
Ifx_Strict_32Bit reserved_2:7; /**< \brief \internal Reserved */
Ifx_Strict_32Bit TRDIS:1; /**< \brief [9:9] Trigger Disable Flag (rh) */
Ifx_Strict_32Bit TRON:1; /**< \brief [10:10] Clear Trigger Disable Flag (w) */
Ifx_Strict_32Bit TROFF:1; /**< \brief [11:11] Set Trigger Disable Flag (w) */
Ifx_Strict_32Bit reserved_12:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit FLSH:1; /**< \brief [13:13] Flush Flag (rh) */
Ifx_Strict_32Bit CLR:1; /**< \brief [14:14] Clear Flush Flag (w) */
Ifx_Strict_32Bit SET:1; /**< \brief [15:15] Set Flush Flag (w) */
Ifx_Strict_32Bit reserved_16:16; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_FIFOCTL_Bits;
/** \brief Trace Buffer Write Pointer */
typedef struct _Ifx_MINIMCDS_FIFONOW_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit NOW:8; /**< \brief [12:5] Trace Buffer Current Write Pointer (rh) */
Ifx_Strict_32Bit reserved_13:19; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_FIFONOW_Bits;
/** \brief Trace Buffer PRE/POST Register */
typedef struct _Ifx_MINIMCDS_FIFOPRE_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit PRE:8; /**< \brief [12:5] Trace Buffer Pre-Trigger Area Size (rw) */
Ifx_Strict_32Bit reserved_13:19; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_FIFOPRE_Bits;
/** \brief Trace Buffer Top Register */
typedef struct _Ifx_MINIMCDS_FIFOTOP_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit TOP:8; /**< \brief [12:5] Trace Buffer upper Bound (rw) */
Ifx_Strict_32Bit reserved_13:19; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_FIFOTOP_Bits;
/** \brief Trace Buffer Comparator Register */
typedef struct _Ifx_MINIMCDS_FIFOWARN0_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit WARN:8; /**< \brief [12:5] Trace Buffer Warn Level (rw) */
Ifx_Strict_32Bit reserved_13:18; /**< \brief \internal Reserved */
Ifx_Strict_32Bit EN:1; /**< \brief [31:31] Enable Trigger Generation (rw) */
} Ifx_MINIMCDS_FIFOWARN0_Bits;
/** \brief Trace Buffer Comparator Register */
typedef struct _Ifx_MINIMCDS_FIFOWARN1_Bits
{
Ifx_Strict_32Bit reserved_0:5; /**< \brief \internal Reserved */
Ifx_Strict_32Bit WARN:8; /**< \brief [12:5] Trace Buffer Warn Level (rw) */
Ifx_Strict_32Bit reserved_13:18; /**< \brief \internal Reserved */
Ifx_Strict_32Bit EN:1; /**< \brief [31:31] Enable Trigger Generation (rw) */
} Ifx_MINIMCDS_FIFOWARN1_Bits;
/** \brief Module Identification Register */
typedef struct _Ifx_MINIMCDS_ID_Bits
{
Ifx_Strict_32Bit MOD_REV:8; /**< \brief [7:0] Module Revision Number (r) */
Ifx_Strict_32Bit MOD_TYPE:8; /**< \brief [15:8] Module Type (r) */
Ifx_Strict_32Bit MODNUMBER:16; /**< \brief [31:16] Module Number Value (r) */
} Ifx_MINIMCDS_ID_Bits;
/** \brief MCDS Signal Source Control */
typedef struct _Ifx_MINIMCDS_MUX_Bits
{
Ifx_Strict_32Bit TMUX0:4; /**< \brief [3:0] Trace Source Select 0 (rw) */
Ifx_Strict_32Bit reserved_4:3; /**< \brief \internal Reserved */
Ifx_Strict_32Bit TM0_P:1; /**< \brief [7:7] Trace Source Select 0 Protection (w) */
Ifx_Strict_32Bit TMUX1:4; /**< \brief [11:8] Trace Source Select 1 (rw) */
Ifx_Strict_32Bit reserved_12:3; /**< \brief \internal Reserved */
Ifx_Strict_32Bit TM1_P:1; /**< \brief [15:15] Trace Source Select 1 Protection (w) */
Ifx_Strict_32Bit TMUX2:3; /**< \brief [18:16] Trace Source Select 2 (rw) */
Ifx_Strict_32Bit TM2_P:1; /**< \brief [19:19] Trace Source Select 2 Protection (w) */
Ifx_Strict_32Bit TMUX3:3; /**< \brief [22:20] Trace Source Select 3 (rw) */
Ifx_Strict_32Bit TM3_P:1; /**< \brief [23:23] Trace Source Select 3 Protection (w) */
Ifx_Strict_32Bit RC:1; /**< \brief [24:24] Reference Clock Select (rw) */
Ifx_Strict_32Bit reserved_25:2; /**< \brief \internal Reserved */
Ifx_Strict_32Bit RC_P:1; /**< \brief [27:27] Reference Clock Select Protection (w) */
Ifx_Strict_32Bit reserved_28:4; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_MUX_Bits;
/** \brief OCDS Control and Status */
typedef struct _Ifx_MINIMCDS_OCS_Bits
{
Ifx_Strict_32Bit reserved_0:24; /**< \brief \internal Reserved */
Ifx_Strict_32Bit SUS:4; /**< \brief [27:24] OCDS Suspend Control (rw) */
Ifx_Strict_32Bit SUS_P:1; /**< \brief [28:28] SUS Write Protection (w) */
Ifx_Strict_32Bit SUSSTA:1; /**< \brief [29:29] Suspend State (rh) */
Ifx_Strict_32Bit reserved_30:2; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_OCS_Bits;
/** \brief Compact Function Trace Register */
typedef struct _Ifx_MINIMCDS_TCX_CFT_Bits
{
Ifx_Strict_32Bit VSHRT_FCT:10; /**< \brief [9:0] Length of very short leaf function (rw) */
Ifx_Strict_32Bit reserved_10:6; /**< \brief \internal Reserved */
Ifx_Strict_32Bit SHRT_FCT:10; /**< \brief [25:16] Length of short leaf function (rw) */
Ifx_Strict_32Bit reserved_26:6; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_TCX_CFT_Bits;
/** \brief Current Instruction Pointer */
typedef struct _Ifx_MINIMCDS_TCX_CIP_Bits
{
Ifx_Strict_32Bit reserved_0:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit CURRENT:31; /**< \brief [31:1] Current Instruction Pointer (rh) */
} Ifx_MINIMCDS_TCX_CIP_Bits;
/** \brief Debug Status Register */
typedef struct _Ifx_MINIMCDS_TCX_DCSTS_Bits
{
Ifx_Strict_32Bit SUS:1; /**< \brief [0:0] Suspended Flag (rh) */
Ifx_Strict_32Bit IDLE:1; /**< \brief [1:1] Run Flag (rh) */
Ifx_Strict_32Bit HALT:1; /**< \brief [2:2] Halted Flag (rh) */
Ifx_Strict_32Bit ISR:1; /**< \brief [3:3] Interrupt Service Flag (rh) */
Ifx_Strict_32Bit HBRK:1; /**< \brief [4:4] Hardware Break Flag (rh) */
Ifx_Strict_32Bit SBRK:1; /**< \brief [5:5] Software Break Flag (rh) */
Ifx_Strict_32Bit reserved_6:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit IEN:1; /**< \brief [7:7] Interrupt Enable Flag (rh) */
Ifx_Strict_32Bit DBGEN:1; /**< \brief [8:8] Debug Enabled Flag (rh) */
Ifx_Strict_32Bit CLKDIV:2; /**< \brief [10:9] Current Clock Divider (rh) */
Ifx_Strict_32Bit reserved_11:21; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_TCX_DCSTS_Bits;
/** \brief Comparator Bound Register */
typedef struct _Ifx_MINIMCDS_TCXEA_BND_Bits
{
Ifx_Strict_32Bit BOUND:32; /**< \brief [31:0] Address Comparator range lower bound (rw) */
} Ifx_MINIMCDS_TCXEA_BND_Bits;
/** \brief Comparator Range Register */
typedef struct _Ifx_MINIMCDS_TCXEA_RNG_Bits
{
Ifx_Strict_32Bit RANGE:32; /**< \brief [31:0] Address Comparator range size (rw) */
} Ifx_MINIMCDS_TCXEA_RNG_Bits;
/** \brief Comparator Bound Register */
typedef struct _Ifx_MINIMCDS_TCXIP_BND_Bits
{
Ifx_Strict_32Bit reserved_0:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit BOUND:31; /**< \brief [31:1] IP Comparator range lower bound (rw) */
} Ifx_MINIMCDS_TCXIP_BND_Bits;
/** \brief Comparator Range Register */
typedef struct _Ifx_MINIMCDS_TCXIP_RNG_Bits
{
Ifx_Strict_32Bit reserved_0:1; /**< \brief \internal Reserved */
Ifx_Strict_32Bit RANGE:31; /**< \brief [31:1] IP Comparator range size (rw) */
} Ifx_MINIMCDS_TCXIP_RNG_Bits;
/** \brief Comparator Bound Register */
typedef struct _Ifx_MINIMCDS_TCXWD_BND_Bits
{
Ifx_Strict_32Bit BOUND:32; /**< \brief [31:0] Data Comparator range lower bound (rw) */
} Ifx_MINIMCDS_TCXWD_BND_Bits;
/** \brief Comparator Mask Register */
typedef struct _Ifx_MINIMCDS_TCXWD_MSK_Bits
{
Ifx_Strict_32Bit MASK:32; /**< \brief [31:0] Data Comparator bit mask (rw) */
} Ifx_MINIMCDS_TCXWD_MSK_Bits;
/** \brief Comparator Range Register */
typedef struct _Ifx_MINIMCDS_TCXWD_RNG_Bits
{
Ifx_Strict_32Bit RANGE:32; /**< \brief [31:0] Data Comparator range size (rw) */
} Ifx_MINIMCDS_TCXWD_RNG_Bits;
/** \brief Comparator Sign Register */
typedef struct _Ifx_MINIMCDS_TCXWD_SGN_Bits
{
Ifx_Strict_32Bit SIGN:5; /**< \brief [4:0] Bit number (1...31) of sign bit (rw) */
Ifx_Strict_32Bit reserved_5:27; /**< \brief \internal Reserved */
} Ifx_MINIMCDS_TCXWD_SGN_Bits;
/** \brief Clock Counter Register */
typedef struct _Ifx_MINIMCDS_TSUEMUCNT_Bits
{
Ifx_Strict_32Bit COUNT:32; /**< \brief [31:0] Current Count Value (rh) */
} Ifx_MINIMCDS_TSUEMUCNT_Bits;
/** \brief Clock Prescaler Register */
typedef struct _Ifx_MINIMCDS_TSUPRSCL_Bits
{
Ifx_Strict_32Bit RELOAD:32; /**< \brief [31:0] Prescaler Reload Value (rw) */
} Ifx_MINIMCDS_TSUPRSCL_Bits;
/** \brief Clock Counter Register */
typedef struct _Ifx_MINIMCDS_TSUREFCNT_Bits
{
Ifx_Strict_32Bit COUNT:32; /**< \brief [31:0] Current Count Value (rh) */
} Ifx_MINIMCDS_TSUREFCNT_Bits;
/** \} */
/******************************************************************************/
/******************************************************************************/
/** \addtogroup IfxLld_Minimcds_union
* \{ */
/** \brief Action Definition Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_ACT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_ACT;
/** \brief Clock Control Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_CLC_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_CLC;
/** \brief Counter Control Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_CNT_CCL_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_CNT_CCL;
/** \brief Current Count Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_CNT_CNT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_CNT_CNT;
/** \brief Counter Limit Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_CNT_LMT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_CNT_LMT;
/** \brief MCDS Control Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_CT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_CT;
/** \brief Event Definition Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_EVT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_EVT;
/** \brief Trace Buffer Bottom Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOBOT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOBOT;
/** \brief Trace Buffer Control Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOCTL_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOCTL;
/** \brief Trace Buffer Write Pointer */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFONOW_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFONOW;
/** \brief Trace Buffer PRE/POST Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOPRE_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOPRE;
/** \brief Trace Buffer Top Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOTOP_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOTOP;
/** \brief Trace Buffer Comparator Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOWARN0_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOWARN0;
/** \brief Trace Buffer Comparator Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_FIFOWARN1_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_FIFOWARN1;
/** \brief Module Identification Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_ID_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_ID;
/** \brief MCDS Signal Source Control */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_MUX_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_MUX;
/** \brief OCDS Control and Status */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_OCS_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_OCS;
/** \brief Compact Function Trace Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCX_CFT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCX_CFT;
/** \brief Current Instruction Pointer */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCX_CIP_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCX_CIP;
/** \brief Debug Status Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCX_DCSTS_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCX_DCSTS;
/** \brief Comparator Bound Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXEA_BND_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXEA_BND;
/** \brief Comparator Range Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXEA_RNG_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXEA_RNG;
/** \brief Comparator Bound Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXIP_BND_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXIP_BND;
/** \brief Comparator Range Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXIP_RNG_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXIP_RNG;
/** \brief Comparator Bound Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXWD_BND_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXWD_BND;
/** \brief Comparator Mask Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXWD_MSK_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXWD_MSK;
/** \brief Comparator Range Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXWD_RNG_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXWD_RNG;
/** \brief Comparator Sign Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TCXWD_SGN_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TCXWD_SGN;
/** \brief Clock Counter Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TSUEMUCNT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TSUEMUCNT;
/** \brief Clock Prescaler Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TSUPRSCL_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TSUPRSCL;
/** \brief Clock Counter Register */
typedef union
{
unsigned int U; /**< \brief Unsigned access */
signed int I; /**< \brief Signed access */
Ifx_MINIMCDS_TSUREFCNT_Bits B; /**< \brief Bitfield access */
} Ifx_MINIMCDS_TSUREFCNT;
/** \} */
/******************************************************************************/
/******************************************************************************/
/** \addtogroup IfxLld_Minimcds_struct
* \{ */
/******************************************************************************/
/** \name Object L2
* \{ */
/** \brief Counter objects */
typedef volatile struct _Ifx_MINIMCDS_CNT
{
Ifx_MINIMCDS_CNT_CCL CCL; /**< \brief 0, Counter Control Register */
Ifx_MINIMCDS_CNT_LMT LMT; /**< \brief 4, Counter Limit Register */
Ifx_MINIMCDS_CNT_CNT CNT; /**< \brief 8, Current Count Register */
unsigned char reserved_C[4]; /**< \brief C, \internal Reserved */
} Ifx_MINIMCDS_CNT;
/** \brief Comparator objects */
typedef volatile struct _Ifx_MINIMCDS_TCXEA
{
Ifx_MINIMCDS_TCXEA_BND BND; /**< \brief 0, Comparator Bound Register */
Ifx_MINIMCDS_TCXEA_RNG RNG; /**< \brief 4, Comparator Range Register */
unsigned char reserved_8[8]; /**< \brief 8, \internal Reserved */
} Ifx_MINIMCDS_TCXEA;
/** \brief Comparator objects */
typedef volatile struct _Ifx_MINIMCDS_TCXIP
{
Ifx_MINIMCDS_TCXIP_BND BND; /**< \brief 0, Comparator Bound Register */
Ifx_MINIMCDS_TCXIP_RNG RNG; /**< \brief 4, Comparator Range Register */
unsigned char reserved_8[8]; /**< \brief 8, \internal Reserved */
} Ifx_MINIMCDS_TCXIP;
/** \brief Comparator objects */
typedef volatile struct _Ifx_MINIMCDS_TCXWD
{
Ifx_MINIMCDS_TCXWD_BND BND; /**< \brief 0, Comparator Bound Register */
unsigned char reserved_4[4]; /**< \brief 4, \internal Reserved */
Ifx_MINIMCDS_TCXWD_RNG RNG; /**< \brief 8, Comparator Range Register */
unsigned char reserved_C[4]; /**< \brief C, \internal Reserved */
Ifx_MINIMCDS_TCXWD_MSK MSK; /**< \brief 10, Comparator Mask Register */
unsigned char reserved_14[8]; /**< \brief 14, \internal Reserved */
Ifx_MINIMCDS_TCXWD_SGN SGN; /**< \brief 1C, Comparator Sign Register */
} Ifx_MINIMCDS_TCXWD;
/** \} */
/******************************************************************************/
/** \} */
/******************************************************************************/
/******************************************************************************/
/** \addtogroup IfxLld_Minimcds_struct
* \{ */
/******************************************************************************/
/** \name Object L1
* \{ */
/** \brief MCX object */
typedef volatile struct _Ifx_MINIMCDS_MCX
{
Ifx_MINIMCDS_EVT EVT[16]; /**< \brief 0, Event Definition Register */
unsigned char reserved_40[64]; /**< \brief 40, \internal Reserved */
Ifx_MINIMCDS_ACT ACT[41]; /**< \brief 80, Action Definition Register */
unsigned char reserved_124[220]; /**< \brief 124, \internal Reserved */
Ifx_MINIMCDS_CNT CNT[8]; /**< \brief 200, Counter objects */
} Ifx_MINIMCDS_MCX;
/** \brief TCX object */
typedef volatile struct _Ifx_MINIMCDS_TCX
{
Ifx_MINIMCDS_TCX_DCSTS DCSTS; /**< \brief 0, Debug Status Register */
unsigned char reserved_4[4]; /**< \brief 4, \internal Reserved */
Ifx_MINIMCDS_TCX_CIP CIP; /**< \brief 8, Current Instruction Pointer */
Ifx_MINIMCDS_TCX_CFT CFT; /**< \brief C, Compact Function Trace Register */
unsigned char reserved_10[1008]; /**< \brief 10, \internal Reserved */
Ifx_MINIMCDS_TCXEA EA[2]; /**< \brief 400, Comparator objects */
unsigned char reserved_420[96]; /**< \brief 420, \internal Reserved */
Ifx_MINIMCDS_TCXWD WD[2]; /**< \brief 480, Comparator objects */
unsigned char reserved_4C0[2880]; /**< \brief 4C0, \internal Reserved */
Ifx_MINIMCDS_TCXIP IP[2]; /**< \brief 1000, Comparator objects */
} Ifx_MINIMCDS_TCX;
/** \} */
/******************************************************************************/
/** \} */
/******************************************************************************/
/******************************************************************************/
/** \addtogroup IfxLld_Minimcds_struct
* \{ */
/******************************************************************************/
/** \name Object L0
* \{ */
/** \brief MINIMCDS object */
typedef volatile struct _Ifx_MINIMCDS
{
Ifx_MINIMCDS_CLC CLC; /**< \brief 0, Clock Control Register */
Ifx_MINIMCDS_OCS OCS; /**< \brief 4, OCDS Control and Status */
Ifx_MINIMCDS_ID ID; /**< \brief 8, Module Identification Register */
unsigned char reserved_C[4]; /**< \brief C, \internal Reserved */
Ifx_MINIMCDS_CT CT; /**< \brief 10, MCDS Control Register */
Ifx_MINIMCDS_MUX MUX; /**< \brief 14, MCDS Signal Source Control */
unsigned char reserved_18[488]; /**< \brief 18, \internal Reserved */
Ifx_MINIMCDS_FIFONOW FIFONOW; /**< \brief 200, Trace Buffer Write Pointer */
Ifx_MINIMCDS_FIFOBOT FIFOBOT; /**< \brief 204, Trace Buffer Bottom Register */
Ifx_MINIMCDS_FIFOPRE FIFOPRE; /**< \brief 208, Trace Buffer PRE/POST Register */
Ifx_MINIMCDS_FIFOTOP FIFOTOP; /**< \brief 20C, Trace Buffer Top Register */
Ifx_MINIMCDS_FIFOCTL FIFOCTL; /**< \brief 210, Trace Buffer Control Register */
Ifx_MINIMCDS_FIFOWARN0 FIFOWARN0; /**< \brief 214, Trace Buffer Comparator Register */
Ifx_MINIMCDS_FIFOWARN1 FIFOWARN1; /**< \brief 218, Trace Buffer Comparator Register */
unsigned char reserved_21C[484]; /**< \brief 21C, \internal Reserved */
Ifx_MINIMCDS_TSUREFCNT TSUREFCNT; /**< \brief 400, Clock Counter Register */
Ifx_MINIMCDS_TSUPRSCL TSUPRSCL; /**< \brief 404, Clock Prescaler Register */
Ifx_MINIMCDS_TSUEMUCNT TSUEMUCNT; /**< \brief 408, Clock Counter Register */
unsigned char reserved_40C[1012]; /**< \brief 40C, \internal Reserved */
Ifx_MINIMCDS_MCX MCX; /**< \brief 800, MCX object */
unsigned char reserved_A80[5504]; /**< \brief A80, \internal Reserved */
Ifx_MINIMCDS_TCX TCX; /**< \brief 2000, TCX object */
unsigned char reserved_3020[4064]; /**< \brief 3020, \internal Reserved */
} Ifx_MINIMCDS;
/** \} */
/******************************************************************************/
/** \} */
/******************************************************************************/
/******************************************************************************/
#endif /* IFXMINIMCDS_REGDEF_H */
| 48.446897 | 107 | 0.569269 |
339ccc2de1a234119519dd376c73833fcff1c9bb | 901 | h | C | PrivateFrameworks/Preferences.framework/PSTableCellHighlightContext.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/Preferences.framework/PSTableCellHighlightContext.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/Preferences.framework/PSTableCellHighlightContext.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/Preferences.framework/Preferences
*/
@interface PSTableCellHighlightContext : NSObject {
bool _animateUnhighlight;
UITableViewCell * _cell;
long long _originalSelectionStyle;
NSTimer * _timer;
bool _valid;
}
@property (nonatomic, readonly) bool animateUnhighlight;
@property (nonatomic) UITableViewCell *cell;
@property (nonatomic) long long originalSelectionStyle;
@property (nonatomic, readonly) bool valid;
+ (id)contextWithCell:(id)arg1;
- (void).cxx_destruct;
- (void)_killTimer;
- (void)_timerFired;
- (bool)animateUnhighlight;
- (id)cell;
- (void)dealloc;
- (void)invalidate;
- (long long)originalSelectionStyle;
- (void)performHighlightForDuration:(double)arg1 animateUnhighlight:(bool)arg2;
- (void)setCell:(id)arg1;
- (void)setOriginalSelectionStyle:(long long)arg1;
- (bool)valid;
@end
| 26.5 | 79 | 0.759156 |
b8da777e81d5b3b9083086aaba1f3b4afcf3071f | 2,402 | h | C | macOS/10.12/UIFoundation.framework/NSCollectionViewLayoutInvalidationContext.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.12/UIFoundation.framework/NSCollectionViewLayoutInvalidationContext.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.12/UIFoundation.framework/NSCollectionViewLayoutInvalidationContext.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation
*/
@interface NSCollectionViewLayoutInvalidationContext : NSObject {
struct CGPoint {
double x;
double y;
} _contentOffsetAdjustment;
struct CGSize {
double width;
double height;
} _contentSizeAdjustment;
NSMutableDictionary * _invalidatedDecorationIndexPaths;
NSMutableSet * _invalidatedItemIndexPaths;
NSMutableDictionary * _invalidatedSupplementaryIndexPaths;
struct {
unsigned int invalidateDataSource : 1;
unsigned int invalidateEverything : 1;
} _invalidationContextFlags;
NSArray * _updateItems;
}
@property (nonatomic, readwrite) struct CGPoint { double x1; double x2; } contentOffsetAdjustment;
@property (nonatomic, readwrite) struct CGSize { double x1; double x2; } contentSizeAdjustment;
@property (setter=_setInvalidateDataSourceCounts:, nonatomic, readwrite) BOOL invalidateDataSourceCounts;
@property (setter=_setInvalidateEverything:, nonatomic, readwrite) BOOL invalidateEverything;
@property (nonatomic, readonly) NSDictionary *invalidatedDecorationIndexPaths;
@property (nonatomic, readonly) NSSet *invalidatedItemIndexPaths;
@property (nonatomic, readonly) NSDictionary *invalidatedSupplementaryIndexPaths;
@property (getter=_updateItems, setter=_setUpdateItems:, nonatomic, readwrite, retain) NSArray *updateItems;
- (id)_invalidatedSupplementaryViews;
- (void)_setInvalidateDataSourceCounts:(BOOL)arg1;
- (void)_setInvalidateEverything:(BOOL)arg1;
- (void)_setInvalidatedSupplementaryViews:(id)arg1;
- (void)_setUpdateItems:(id)arg1;
- (id)_updateItems;
- (struct CGPoint { double x1; double x2; })contentOffsetAdjustment;
- (struct CGSize { double x1; double x2; })contentSizeAdjustment;
- (void)dealloc;
- (BOOL)invalidateDataSourceCounts;
- (void)invalidateDecorationElementsOfKind:(id)arg1 atIndexPaths:(id)arg2;
- (BOOL)invalidateEverything;
- (void)invalidateItemsAtIndexPaths:(id)arg1;
- (void)invalidateSupplementaryElementsOfKind:(id)arg1 atIndexPaths:(id)arg2;
- (id)invalidatedDecorationIndexPaths;
- (id)invalidatedItemIndexPaths;
- (id)invalidatedSupplementaryIndexPaths;
- (void)setContentOffsetAdjustment:(struct CGPoint { double x1; double x2; })arg1;
- (void)setContentSizeAdjustment:(struct CGSize { double x1; double x2; })arg1;
@end
| 44.481481 | 108 | 0.781432 |
9855d00e1594050bec0685b3ef3738236bbe6858 | 6,153 | h | C | geo3d/include/CGAL/Polynomial/internal/CORE_polynomial.h | vipuserr/vipuserr-Geological-hazard | 2b29c03cdac6f5e1ceac4cd2f15b594040ef909c | [
"MIT"
] | 187 | 2019-01-23T04:07:11.000Z | 2022-03-27T03:44:58.000Z | 3rd_party/cgal_4.9/include/cgal/Polynomial/internal/CORE_polynomial.h | nimzi/CGALViewer | 25e28196a9192c2b7174a5656f441f97b9c94bd8 | [
"MIT"
] | 8 | 2019-03-22T13:27:38.000Z | 2020-06-18T13:23:23.000Z | 3rd_party/cgal_4.9/include/cgal/Polynomial/internal/CORE_polynomial.h | nimzi/CGALViewer | 25e28196a9192c2b7174a5656f441f97b9c94bd8 | [
"MIT"
] | 34 | 2019-02-13T01:11:12.000Z | 2022-02-28T03:29:40.000Z | // Copyright (c) 2005,2006 Stanford University (USA).
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$ $Date$
//
//
// Author(s) : Daniel Russel <drussel@alumni.princeton.edu>
#ifndef CGAL_POLYNOMIAL_POLYNOMIAL_POLYCORE_KERNEL_H
#define CGAL_POLYNOMIAL_POLYNOMIAL_POLYCORE_KERNEL_H
#include <CGAL/Polynomial/basic.h>
#include <CGAL/CORE_Expr.h>
#include <CGAL/CORE/poly/Poly.h>
#include <CGAL/CORE_BigFloat.h>
#include <CGAL/CORE_Expr.h>
#include <CGAL/CORE_BigRat.h>
namespace CGAL { namespace POLYNOMIAL { namespace internal {
struct CORE_polynomial {
typedef CORE::Polynomial<CORE::BigRat> P;
typedef CORE::BigRat NT;
template <class It>
CORE_polynomial(It b, It e): p_(std::vector<NT> (b,e)) {
/*for (int i=0; i<= degree(); ++i){
CGAL_precondition(P::getCoeffi(i).err()==0);
}*/
}
CORE_polynomial(){
}
CORE_polynomial(NT n): p_(0, &n){
}
CORE_polynomial(int d): p_(d){}
CORE_polynomial(const P&p): p_(p){
/*for (int i=0; i<= degree(); ++i){
CGAL_precondition(p_.getCoeffi(i).err()==0);
}*/
}
NT operator[](unsigned int i) const {
return p_.getCoeffi(i);
}
/*NT &operator[](unsigned int i) {
return p_.getCoeffi(i);
}*/
NT operator()(const NT &nt) const {
return p_.eval(nt);
}
bool operator==(const CORE_polynomial&o ) const {
if (p_.getTrueDegree() != o.p_.getTrueDegree()) {
return false;
} else {
for (int i=0; i<= p_.getTrueDegree(); ++i) {
if (operator[](i) != o[i]) return false;
}
}
return true;
}
void contract() {
p_.contract();
}
bool operator!=(const CORE_polynomial&o ) const {
return !operator==(o);
}
CORE_polynomial operator/(const NT &nt) const {
P ret(p_.getTrueDegree());
for (int i=0; i<= degree(); ++i){
ret.setCoeff(i, operator[](i)/nt);
//CGAL_assertion(rr);
}
return CORE_polynomial(ret);
}
CORE_polynomial operator-() const {
P ret(p_.getTrueDegree());
for (int i=0; i<= degree(); ++i){
ret.setCoeff(i, -operator[](i));
//CGAL_assertion(setr);
}
return CORE_polynomial(ret);
}
CORE_polynomial operator-(const CORE_polynomial &o) const {
CORE_polynomial r(core_polynomial());
r.p_-=o.core_polynomial();
return r;
}
CORE_polynomial operator+(const CORE_polynomial &o) const {
CORE_polynomial r(core_polynomial());
r.p_+=o.core_polynomial();
return r;
}
CORE_polynomial operator*(const CORE_polynomial &o) const {
CORE_polynomial r(core_polynomial());
r.p_*=o.core_polynomial();
return r;
}
CORE::Expr operator()(const CORE::Expr &nt) const {
return p_.eval(nt);
}
int degree() const {
return p_.getTrueDegree();
}
const P &core_polynomial() const {
return p_;
}
//! write it in maple format
template <class C, class T>
void write(std::basic_ostream<C,T> &out) const
{
std::basic_ostringstream<C,T> s;
s.flags(out.flags());
s.imbue(out.getloc());
s.precision(12);
if (degree()<0) {
s << "0";
}
else {
for (int i=0; i<= degree(); ++i) {
if (i==0) {
if (p_.getCoeffi(i) != 0) s << p_.getCoeffi(i);
}
else {
if ( p_.getCoeffi(i) != 0 ) {
if (p_.getCoeffi(i) >0) s << "+";
s << p_.getCoeffi(i) << "*t";
if (i != 1) {
s << "^" << i;
}
}
}
}
}
out << s.str();
}
//! Read very stylized input
template <class charT, class Traits>
void read(std::basic_istream<charT, Traits> &in) {
std::vector<NT> coefs;
bool pos=(in.peek()!='-');
if (in.peek() == '+' || in.peek() == '-') {
char c;
in >> c;
}
char v='\0';
while (true) {
char vc, t;
NT coef;
// eat
in >> coef;
//coef.makeExact();
if (!in.good()) return;
unsigned int pow;
char p= in.peek();
if (in.peek() =='*') {
in >> t >> vc;
if (t != '*') {
in.setstate(std::ios_base::failbit);
return;
//return in;
}
if ( !(v=='\0' || v== vc)) {
in.setstate(std::ios_base::failbit);
return;
//return in;
}
v=vc;
p=in.peek();
if (in.peek() =='^') {
char c;
in >> c >> pow;
}
else {
pow=1;
}
}
else {
pow=0;
}
if (coefs.size() <=pow) {
coefs.resize(pow+1);
}
if (!pos) coef=-coef;
coefs[pow]=coef;
char n= in.peek();
if (n=='+' || n=='-') {
pos= (n!='-');
char e;
in >> e;
} else {
/*bool f= in.fail();
bool g= in.good();
bool e= in.eof();
bool b= in.bad();*/
// This is necessary since peek could have failed if we hit the end of the buffer
// it would better to do without peek, but that is too messy
in.clear();
//std::cout << f << g << e << b<<std::endl;
break;
}
}
p_.operator=(P(coefs));
}
bool is_constant() const {
return degree() < 1;
}
typedef const NT* iterator;
iterator begin() const {
return p_.coeff;
}
iterator end() const {
return p_.coeff+p_.degree+1;
}
protected:
P p_;
};
template < class C, class Tr>
inline std::ostream &operator<<(std::basic_ostream<C, Tr> &out,
const CORE_polynomial &poly)
{
poly.write(out);
return out;
}
template <class C, class Tr>
inline std::istream &operator>>(std::basic_istream<C, Tr> &in,
CORE_polynomial &poly)
{
poly.read(in);
return in;
}
inline CORE_polynomial operator*(const CORE_polynomial::NT &a,
const CORE_polynomial &p){
//CORE_polynomial::NT ac(a);
return CORE_polynomial(CORE_polynomial::P(0, &a)*p.core_polynomial());
}
} } } //namespace CGAL::POLYNOMIAL::internal
#endif
| 22.053763 | 82 | 0.590119 |
f10b5e91f07f7cb44928141d2aa06301b751cbe3 | 822 | h | C | chapter_11/higher_order/list.h | GeertArien/low-level-programming | 4e20bf60973c72a55efa5b340eee734431cd28e2 | [
"MIT"
] | null | null | null | chapter_11/higher_order/list.h | GeertArien/low-level-programming | 4e20bf60973c72a55efa5b340eee734431cd28e2 | [
"MIT"
] | null | null | null | chapter_11/higher_order/list.h | GeertArien/low-level-programming | 4e20bf60973c72a55efa5b340eee734431cd28e2 | [
"MIT"
] | null | null | null | #ifndef LIST_H_
#define LIST_H_
#include <stdlib.h>
#include <stdbool.h>
struct list_t {
int value;
struct list_t* next;
};
struct list_t* list_create(const int val);
struct list_t* list_back(struct list_t* list);
void list_add_front(const int value, struct list_t** list);
void list_add_back(const int value, struct list_t** list);
struct list_t* list_node_at(struct list_t* list, const size_t index);
int list_get(struct list_t* list, const size_t index);
void list_free(struct list_t* list);
size_t list_length(struct list_t* list);
int list_sum(struct list_t* list);
bool save(struct list_t* lst, const char* filename);
bool load(struct list_t** lst, const char* filename);
bool serialize(struct list_t* lst, const char* filename);
bool deserialize(struct list_t** lst, const char* filename);
#endif | 24.909091 | 69 | 0.754258 |
112a0aeb96e061c8b59bcee3ae117d7953e35746 | 1,349 | h | C | include/libft/system/signals/private.h | ncoden/libft | a02a5103eb0c8571a5bb260524770cd7a896ad06 | [
"Apache-2.0"
] | 12 | 2015-08-24T23:49:18.000Z | 2022-02-17T21:22:01.000Z | include/libft/system/signals/private.h | ncoden/libft | a02a5103eb0c8571a5bb260524770cd7a896ad06 | [
"Apache-2.0"
] | 2 | 2015-08-24T23:29:31.000Z | 2016-01-09T20:52:24.000Z | include/libft/system/signals/private.h | ncoden/libft | a02a5103eb0c8571a5bb260524770cd7a896ad06 | [
"Apache-2.0"
] | 5 | 2017-02-11T22:32:20.000Z | 2020-06-17T13:43:18.000Z | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* private.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ncoden <ncoden@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/12/22 10:21:17 by ncoden #+# #+# */
/* Updated: 2015/11/09 18:09:29 by ncoden ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFT_SIGNALS_PRIVATE_H
# define LIBFT_SIGNALS_PRIVATE_H
# include <stdint.h>
# include "libft/containers/list.h"
# include "libft/system/signals.h"
typedef struct s_lst_sgnl_hook
{
LST_BASE (struct s_lst_sgnl_hook);
void *hook;
enum e_sgnl_hook_type
{
HOOK_SIG,
HOOK_SIGS
} type;
} t_lst_sgnl_hook;
int32_t g_sgnl_mask;
t_lst_sgnl_hook *g_sgnl_hooks;
void sgnl_mask_add(int sig);
void sgnl_mask_set(int32_t mask);
#endif
| 35.5 | 80 | 0.326168 |
115bef216e01ac01c8ae99e420118ba530c9288a | 3,980 | c | C | cmd/bin/uudecode.c | p-durlej/xenus | 44a83de9f863672c349adf6e7b0baac2337183f8 | [
"BSD-2-Clause"
] | 2 | 2019-06-06T06:19:25.000Z | 2019-12-29T19:33:28.000Z | cmd/bin/uudecode.c | p-durlej/xenus | 44a83de9f863672c349adf6e7b0baac2337183f8 | [
"BSD-2-Clause"
] | 1 | 2019-06-06T07:21:07.000Z | 2019-06-08T09:39:08.000Z | cmd/bin/uudecode.c | p-durlej/xenus | 44a83de9f863672c349adf6e7b0baac2337183f8 | [
"BSD-2-Clause"
] | null | null | null | /* Copyright (c) Piotr Durlej
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/termios.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
static struct termios tp, otp;
static int ttyfd = -1;
static int rflag;
static int xit;
static int otoi(char *nptr)
{
int n = 0;
while (*nptr >= '0' && *nptr <= '7')
{
n <<= 3;
n += *nptr++ - '0';
}
return n;
}
static int uudecode1(unsigned char *p, FILE *f)
{
int len = *p++ - ' ';
unsigned w;
int i;
if (len < 0 || len > 64)
return 1;
if (len == 64)
len = 0;
while (len)
{
w = (*p++ - ' ') & 63; w <<= 6;
w |= (*p++ - ' ') & 63; w <<= 6;
w |= (*p++ - ' ') & 63; w <<= 6;
w |= (*p++ - ' ') & 63;
for (i = 0; i < 3 && len; i++, len--)
{
fputc(w >> 16, f);
w <<= 8;
}
}
return 0;
}
static void uudecode(char *path)
{
FILE *f = NULL, *inf = stdin;
char *p, *n, *ms;
char buf[256];
mode_t m;
int fd = -1;
if (strcmp(path, "-"))
inf = fopen(path, "r");
if (!inf)
goto ifail;
retry:
if (!fgets(buf, sizeof buf, inf))
goto ifail;
p = strchr(buf, '\n');
if (p)
*p = 0;
p = strtok(buf, " ");
ms = strtok(NULL, " ");
n = strtok(NULL, " ");
if (!p || !n || !ms || strcmp(p, "begin"))
goto retry;
m = otoi(ms);
fd = open(n, O_CREAT | O_TRUNC | O_WRONLY, m);
if (fd < 0)
goto ofail;
f = fdopen(fd, "w");
if (!f)
goto ofail;
for (;;)
{
if (!fgets(buf, sizeof buf, inf))
goto ifail;
p = strchr(buf, '\n');
if (p)
*p = 0;
if (!strcmp(buf, "end"))
break;
if (uudecode1((unsigned char *)buf, f))
goto badfmt;
if (ferror(f))
goto ofail;
if (rflag && ttyfd >= 0)
write(ttyfd, ".", 1);
}
if (rflag && ttyfd >= 0)
write(ttyfd, "\n", 1);
clean:
if (inf != stdin)
fclose(inf);
if (f && fclose(f))
goto ofail;
if (fd >= 0 && !f)
close(fd);
return;
badfmt:
fprintf(stderr, "%s: Invalid format\n", path);
xit = 1;
goto clean;
ofail:
perror(n);
xit = 1;
goto clean;
ifail:
if (ferror(inf))
perror(path);
else
fprintf(stderr, "%s: EOF\n", path);
xit = 1;
goto clean;
}
static void intr(int nr)
{
tcsetattr(0, TCSANOW, &otp);
raise(nr);
}
int main(int argc, char **argv)
{
char *p;
int i;
p = strrchr(*argv, '/') + 1;
if (p == (char *)1)
p = *argv;
if (!strcmp(p, "uureceive") || !strcmp(p, "uur"))
{
ttyfd = open("/dev/tty", O_WRONLY);
tcgetattr(0, &otp);
signal(SIGINT, intr);
tp = otp;
tp.c_lflag &= ~ECHO;
tcsetattr(0, TCSANOW, &tp);
rflag = 1;
}
for (i = 1; i < argc; i++)
uudecode(argv[i]);
if (argc < 2)
uudecode("-");
if (rflag)
tcsetattr(0, TCSANOW, &otp);
return xit;
}
| 20.203046 | 78 | 0.601759 |
52825cd35d00b8aeb4bb00acbee79429357c5140 | 742 | c | C | lib/guilds/spells/necromancy/_doo_nee_maa.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/guilds/spells/necromancy/_doo_nee_maa.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/guilds/spells/necromancy/_doo_nee_maa.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | #define MASTERY_D "/daemons/mastery_d"
#define DIR "/guilds/necro/obj/"
/* Mass raise skeletons */
resolve(bonus) {
int i, val;
object *obs;
object horde;
horde = present("horde", environment(this_player()));
if(!horde) { write("There are no horde here.\n"); return 1; }
val = 0;
obs = all_inventory(environment(this_player()));
for(i=0;i<sizeof(obs);i++) {
if(obs[i]->query_corpse() && !obs[i]->query_animal()) {
val += 1;
destruct(obs[i]);
}
}
if(val == 0) {
write("There are no corpses that you can convert to the horde!\n");
return 1;
}
horde->add_skeletons(val);
write("You add "+val+" animated skeletons to the horde.\n");
MASTERY_D->mastery("Mastery of dark arts",this_player());
return 1;
}
| 24.733333 | 69 | 0.638814 |
f83f3f32875c7639da03dcfcaa9e22995bc129d7 | 769 | h | C | src/parse/util.h | cselab/aphros | 3e4203e2bf528768043719bd8fd66863b22d2c5a | [
"MIT"
] | 252 | 2020-06-03T16:01:59.000Z | 2022-03-30T14:06:32.000Z | src/parse/util.h | cselab/aphros | 3e4203e2bf528768043719bd8fd66863b22d2c5a | [
"MIT"
] | 4 | 2021-03-13T11:13:55.000Z | 2022-03-31T15:11:22.000Z | src/parse/util.h | cselab/aphros | 3e4203e2bf528768043719bd8fd66863b22d2c5a | [
"MIT"
] | 27 | 2020-09-18T04:12:03.000Z | 2022-03-30T04:22:42.000Z | // Created by Petr Karnakov on 04.04.2019
// Copyright 2019 ETH Zurich
#pragma once
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>
// Returns set of words from space separated string.
inline std::unordered_set<std::string> GetWords(std::string s) {
std::unordered_set<std::string> r;
std::stringstream st(s);
st >> std::skipws;
while (true) {
std::string e;
st >> e;
if (st) {
r.insert(e);
} else {
break;
}
}
return r;
}
// Splits string by delimiter.
inline std::vector<std::string> SplitByDelimiter(std::string str, char delim) {
std::vector<std::string> ss;
std::istringstream f(str);
std::string s;
while (std::getline(f, s, delim)) {
ss.push_back(s);
}
return ss;
}
| 20.236842 | 79 | 0.642393 |
fb5e630002044c59010fac63051117d9ac75164a | 1,167 | h | C | src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/HitForcePickup.h | thoo0224/rl_dumper | b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba | [
"MIT"
] | 5 | 2020-05-20T00:24:28.000Z | 2021-05-01T23:22:53.000Z | src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/HitForcePickup.h | thoo0224/rl_dumper | b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba | [
"MIT"
] | 6 | 2020-02-02T06:58:07.000Z | 2021-11-12T16:29:39.000Z | src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/HitForcePickup.h | thoo0224/rl_dumper | b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba | [
"MIT"
] | 2 | 2020-05-20T15:13:39.000Z | 2020-08-09T15:23:59.000Z | #pragma once
template<class T> class ArrayWrapper;
template<typename T> class StructArrayWrapper;
#include "../../WrapperStructs.h"
#include "../.././GameObject/RumbleComponent/RumblePickupComponentWrapper.h"
class RBActorWrapper;
class BAKKESMOD_PLUGIN_IMPORT HitForcePickup : public RumblePickupComponentWrapper {
public:
CONSTRUCTORS(HitForcePickup)
//AUTO-GENERATED FROM FIELDS
unsigned long GetbBallForce();
void SetbBallForce(unsigned long newbBallForce);
unsigned long GetbCarForce();
void SetbCarForce(unsigned long newbCarForce);
unsigned long GetbDemolishCars();
void SetbDemolishCars(unsigned long newbDemolishCars);
float GetBallHitForce();
void SetBallHitForce(float newBallHitForce);
float GetCarHitForce();
void SetCarHitForce(float newCarHitForce);
float GetMinFXTime();
void SetMinFXTime(float newMinFXTime);
float GetOrigBallHitForce();
void SetOrigBallHitForce(float newOrigBallHitForce);
float GetOrigCarHitForce();
void SetOrigCarHitForce(float newOrigCarHitForce);
float GetLastFXTime();
void SetLastFXTime(float newLastFXTime);
//AUTO-GENERATED FUNCTION PROXIES
void PickupEnd();
void PickupStart();
private:
PIMPL
}; | 31.540541 | 84 | 0.810626 |
1f177ee43ad77b52ff1ff74f5c46cc6e242ff338 | 2,036 | c | C | src/csv.c | github188/catlib | 54d239e5ac9ccb6febb7d172d072f100e137cba2 | [
"MIT"
] | 5 | 2015-12-06T23:16:14.000Z | 2020-10-21T19:58:56.000Z | src/csv.c | github188/catlib | 54d239e5ac9ccb6febb7d172d072f100e137cba2 | [
"MIT"
] | null | null | null | src/csv.c | github188/catlib | 54d239e5ac9ccb6febb7d172d072f100e137cba2 | [
"MIT"
] | 1 | 2018-11-22T06:46:15.000Z | 2018-11-22T06:46:15.000Z | /*
* csv.c -- functions to manipulated comma-separated value files.
*
* by Christopher Adam Telfer
*
* Copyright 2003-2012 See accompanying license
*
*/
#include <cat/cat.h>
#include <cat/csv.h>
#include <cat/grow.h>
#include <string.h>
void csv_init(struct csv_state *csv, getchar_f gc, void *gcctx)
{
abort_unless(csv && gc);
memset(csv, 0, sizeof(*csv));
csv->csv_getc = gc;
csv->csv_gcctx = gcctx;
csv->csv_last = -1;
}
int csv_next(struct csv_state *csv, char *p, size_t len, size_t *rlen)
{
size_t i = 0;
getchar_f getc = csv->csv_getc;
void *gcctx = csv->csv_gcctx;
int c, code = CSV_OK, prquote;
if ( !csv || !p || len-- < 2 )
return CSV_ERR;
if ( csv->csv_done > 0 )
return CSV_EOF;
else if ( csv->csv_done < 0 )
return CSV_ERR;
do {
if ( csv->csv_last < 0 ) {
c = (*getc)(gcctx);
} else {
c = csv->csv_last;
csv->csv_last = -1;
}
if ( c < 0 ) {
if ( c == CSV_GETC_EOF ) {
csv->csv_done = 1;
code = CSV_REC;
} else {
abort_unless(c == CSV_GETC_ERR);
csv->csv_done = -1;
code = CSV_ERR;
}
break;
} else if ( c == '"' ) {
csv->csv_inquote = !csv->csv_inquote;
prquote = !csv->csv_inquote && csv->csv_sawquote;
csv->csv_sawquote = 1;
if ( !prquote )
continue;
} else {
csv->csv_sawquote = 0;
}
if ( c == ',' && !csv->csv_inquote ) {
code = CSV_FLD;
} else if ( c == '\n' && !csv->csv_inquote ) {
code = CSV_REC;
} else {
if ( i == len ) {
csv->csv_last = c;
if ( c == '"' )
csv->csv_inquote = !csv->csv_inquote;
code = CSV_CNT;
} else {
*p++ = c;
++i;
}
}
} while ( code == CSV_OK );
if ( i == 0 && csv->csv_done > 0 )
code = CSV_EOF;
if ( code != CSV_EOF ) {
*p = '\0';
if ( code != CSV_CNT ) {
csv->csv_inquote = 0;
csv->csv_sawquote = 0;
}
if ( rlen )
*rlen = i;
}
return code;
}
int csv_clear_field(struct csv_state *csv)
{
char buf[256];
int code;
while ( (code = csv_next(csv, buf, sizeof(buf), 0)) == CSV_CNT )
;
return code;
}
| 18.178571 | 70 | 0.55943 |
20a3718e6edfc3962c39cc6fcb1f0657d7a5a9a0 | 280 | h | C | Example/AXMagicIdentifiers/AXTableViewController.h | DmitriyFrolow/AXMagicIdentifiers | 126c7cba7b60167a6d19d4a63dbbeab6be460a42 | [
"MIT"
] | 19 | 2015-05-09T00:34:12.000Z | 2019-03-16T14:42:50.000Z | Example/AXMagicIdentifiers/AXTableViewController.h | DmitriyFrolow/AXMagicIdentifiers | 126c7cba7b60167a6d19d4a63dbbeab6be460a42 | [
"MIT"
] | 2 | 2015-05-15T15:26:44.000Z | 2018-09-06T11:52:35.000Z | Example/AXMagicIdentifiers/AXTableViewController.h | DmitriyFrolow/AXMagicIdentifiers | 126c7cba7b60167a6d19d4a63dbbeab6be460a42 | [
"MIT"
] | 3 | 2016-11-03T09:25:59.000Z | 2017-09-14T14:32:31.000Z | //
// AXTableViewController.h
// AXMagicIdentifiers
//
// Created by Alexandre Garrefa on 5/9/15.
// Copyright (c) 2015 Alexandre Garrefa. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AXTableViewController : UITableViewController <UITableViewDataSource>
@end
| 20 | 80 | 0.75 |
2dd4739a56792fd3dc434ed17bf4a7870bcdd23f | 2,370 | h | C | src/utils/cmd_line_utils.h | stevencpp/cpp_modules | a49f8077450eef378d8788ea1e12685cb280ba0e | [
"MIT"
] | 18 | 2019-12-27T20:05:00.000Z | 2022-01-27T16:10:14.000Z | src/utils/cmd_line_utils.h | stevencpp/cpp_modules | a49f8077450eef378d8788ea1e12685cb280ba0e | [
"MIT"
] | 1 | 2020-02-01T22:55:50.000Z | 2020-02-01T22:55:50.000Z | src/utils/cmd_line_utils.h | stevencpp/cpp_modules | a49f8077450eef378d8788ea1e12685cb280ba0e | [
"MIT"
] | 1 | 2021-01-30T11:39:12.000Z | 2021-01-30T11:39:12.000Z | #include <functional>
#include <string>
#include <string_view>
#include <string>
#include <vector>
#include <fmt/format.h>
namespace cppm {
namespace detail {
struct ApplyCommandLineFromFile {
bool allocated_a = false, allocated_w = false;
int argc; char** argv_a = nullptr; wchar_t** argv_w = nullptr;
ApplyCommandLineFromFile(int argc, wchar_t* argv[]);
ApplyCommandLineFromFile(int argc, char* argv[]);
template<typename T>
void init(int argc, T* argv[]);
void to_argv_a();
~ApplyCommandLineFromFile();
};
struct ExecutablePath {
ExecutablePath();
};
} // namespace cppm::detail
template<typename T, typename ArgsFunc>
decltype(auto) apply_command_line_from_file(int argc, T* argv[], ArgsFunc&& args_func) {
auto aclff = detail::ApplyCommandLineFromFile { argc, argv };
if constexpr (std::is_invocable_v<ArgsFunc, int, wchar_t**>) {
return args_func(aclff.argc, aclff.argv_w);
} else {
aclff.to_argv_a();
return args_func(aclff.argc, aclff.argv_a);
}
}
std::string executable_path();
std::string find_command_line_argument(std::string_view command_line, std::string_view starts_with);
std::string get_command_line_argument(std::string_view command_line, int idx);
struct CmdArgs {
std::vector<std::string> arg_vec;
CmdArgs() {}
template<typename... Args>
CmdArgs(std::string_view format_string, Args&&... args) {
append(format_string, std::forward<Args>(args)...);
}
template<typename... Args>
CmdArgs& append(std::string_view format_string, Args&&... args) {
std::string str = fmt::format(format_string, std::forward<Args>(args)...);
std::string cur;
for (size_t i = 0; i < str.size(); i++) {
char c = str[i];
if (c == ' ') {
if (!cur.empty()) {
arg_vec.push_back(cur);
cur.clear();
}
} else if (c == '\"') {
i++;
while (str[i] != '\"') { cur += str[i]; i++; }
} else {
cur += c;
}
}
if (!cur.empty())
arg_vec.push_back(cur);
return *this;
}
std::string to_string() {
std::string cmd;
bool first = true;
for (auto& arg : arg_vec) {
if (!first) cmd += " ";
else first = false;
cmd += arg;
}
return cmd;
}
};
int64_t run_cmd(const CmdArgs& args);
int64_t run_cmd_read_lines(const CmdArgs& args,
const std::function<bool(std::string_view)>& stdout_callback,
const std::function<bool(std::string_view)>& stderr_callback);
} // namespace cppm | 24.43299 | 100 | 0.672574 |
a70f7957da633dbc519d470f372f51610b3b2ed9 | 959 | h | C | include/hlang/ast/stmt/params_decl.h | TranHHoang/cpphlang | 84ae06d4f1bb43b6c3ede3fb0a9b2da027a2dbeb | [
"MIT"
] | null | null | null | include/hlang/ast/stmt/params_decl.h | TranHHoang/cpphlang | 84ae06d4f1bb43b6c3ede3fb0a9b2da027a2dbeb | [
"MIT"
] | null | null | null | include/hlang/ast/stmt/params_decl.h | TranHHoang/cpphlang | 84ae06d4f1bb43b6c3ede3fb0a9b2da027a2dbeb | [
"MIT"
] | null | null | null | #pragma once
#include "statement.h"
namespace HLang
{
class ParamDeclStmt : public Statement {
public:
ParamDeclStmt(Token token, PExprNode paramModifier, PExprNode paramName, PExprNode paramType, PExprNode paramValue)
: Statement(StatementType::ParamDecl, std::move(token)),
paramModifier(std::move(paramModifier)),
paramName(std::move(paramName)),
paramType(std::move(paramType)),
paramValue(std::move(paramValue)) { }
void accept(AbstractVisitor &visitor) override;
Expression* getParamModifier() const { return paramModifier.get(); }
Expression* getParamName() const { return paramName.get(); }
Expression* getParamType() const { return paramType.get(); }
Expression* getParamValue() const { return paramValue.get(); }
private:
PExprNode paramModifier, paramName, paramType, paramValue;
};
}
| 38.36 | 123 | 0.646507 |
4ce92f5981af177c3fb69b9066ca9c6ca43c4345 | 4,014 | h | C | interfaces/innerkits/base/include/ohos/aafwk/base/pac_map_node.h | chaoyangcui/aafwk_standard | 6a1ba0b0aa175c709e7a0d684f89ebd41a006061 | [
"Apache-2.0"
] | null | null | null | interfaces/innerkits/base/include/ohos/aafwk/base/pac_map_node.h | chaoyangcui/aafwk_standard | 6a1ba0b0aa175c709e7a0d684f89ebd41a006061 | [
"Apache-2.0"
] | null | null | null | interfaces/innerkits/base/include/ohos/aafwk/base/pac_map_node.h | chaoyangcui/aafwk_standard | 6a1ba0b0aa175c709e7a0d684f89ebd41a006061 | [
"Apache-2.0"
] | 1 | 2021-09-13T12:07:39.000Z | 2021-09-13T12:07:39.000Z | /*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 OHOS_AppExecFwk_PAC_MAP_NODE_H
#define OHOS_AppExecFwk_PAC_MAP_NODE_H
#include "parcel.h"
namespace OHOS {
namespace AppExecFwk {
// base: 0x00000001 ~ 0x000000FF
// array: 0x00000100 ~ 0x0000FF00
// boject: 0x00010000 ~ 0x00FF0000
#define PACMAP_DATA_SHORT 0x00000001
#define PACMAP_DATA_INTEGER 0x00000002
#define PACMAP_DATA_LONG 0x00000003
#define PACMAP_DATA_CHAR 0x00000004
#define PACMAP_DATA_BYTE 0x00000005
#define PACMAP_DATA_BOOLEAN 0x00000007
#define PACMAP_DATA_FLOAT 0x00000008
#define PACMAP_DATA_DOUBLE 0x00000009
#define PACMAP_DATA_STRING 0x0000000A
#define PACMAP_DATA_ARRAY_SHORT 0x00000100
#define PACMAP_DATA_ARRAY_INTEGER 0x00000200
#define PACMAP_DATA_ARRAY_LONG 0x00000300
#define PACMAP_DATA_ARRAY_CHAR 0x00000400
#define PACMAP_DATA_ARRAY_BYTE 0x00000500
#define PACMAP_DATA_ARRAY_BOOLEAN 0x00000600
#define PACMAP_DATA_ARRAY_FLOAT 0x00000700
#define PACMAP_DATA_ARRAY_DOUBLE 0x00000800
#define PACMAP_DATA_ARRAY_STRING 0x00000900
#define PACMAP_DATA_OBJECT 0x00010000
typedef enum {
DT_PACMAP_BASE = 0, /* Basic data types */
DT_PACMAP_ARRAY, /* Basic aray of data types */
DT_PACMAP_OBJECT /* custum object */
} PacMapNodeType;
class PacMapNode {
public:
/**
* @brief A constructor data.
* @param data_type Rough data types, it is an enumerated type, see {@PacMapNodeType}.
*/
PacMapNode(PacMapNodeType data_type) : data_type_(data_type)
{}
virtual ~PacMapNode() = default;
PacMapNode() = default;
/**
* @brief A constructor data.
*/
PacMapNode(const PacMapNode &other);
PacMapNode &operator=(const PacMapNode &other);
inline bool IsBase(void) const
{
return data_type_ == DT_PACMAP_BASE;
}
inline bool IsArray(void) const
{
return data_type_ == DT_PACMAP_ARRAY;
}
inline bool IsObject(void) const
{
return data_type_ == DT_PACMAP_OBJECT;
}
inline PacMapNodeType GetMapNodeTypType(void)
{
return data_type_;
}
/**
* @brief Indicates whether some other object is "equal to" this one.
* @param other The object with which to compare.
* @return Resturns true if this object is the same as the obj argument; false otherwise.
*/
virtual bool Equals(const PacMapNode *other) = 0;
/**
* @brief Copy the data of the specified object to the current object with deepcopy
* @param other The original object that stores the data.
*/
virtual void DeepCopy(const PacMapNode *other) = 0;
/**
* @brief Marshals this Sequenceable object to a Parcel.
* @param key Indicates the key in String format.
* @param parcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
* @return Marshals success returns true, otherwise returns false.
*/
virtual bool Marshalling(const std::string &key, Parcel &parcel) const = 0;
/**
* @brief Unmarshals this Sequenceable object from a Parcel.
* @param dataType Indicates the type of data stored.
* @param parcel Indicates the Parcel object into which the Sequenceable object has been marshaled.
* @return Unmarshals success returns true, otherwise returns false.
*/
virtual bool Unmarshalling(int32_t dataType, Parcel &parcel) = 0;
protected:
PacMapNodeType data_type_;
};
} // namespace AppExecFwk
} // namespace OHOS
#endif
| 32.634146 | 103 | 0.729198 |
f0ebc2b7d0f33dd25da4a90701c46fed78098be4 | 439 | h | C | FMCategoryKit/Foundation/NSMutableArray/NSMutableArray+FMAdd.h | yfming93/FMCategoryKit | 38d4e4cea87f2a191093b7785d16ba467f7edd95 | [
"MIT"
] | 4 | 2019-05-17T07:36:33.000Z | 2020-04-19T09:37:37.000Z | FMCategoryKit/Foundation/NSMutableArray/NSMutableArray+FMAdd.h | yfming93/FMCategoryKit | 38d4e4cea87f2a191093b7785d16ba467f7edd95 | [
"MIT"
] | null | null | null | FMCategoryKit/Foundation/NSMutableArray/NSMutableArray+FMAdd.h | yfming93/FMCategoryKit | 38d4e4cea87f2a191093b7785d16ba467f7edd95 | [
"MIT"
] | null | null | null | //
// NSMutableArray+FMAdd.h
// Pods
//
// Created by mingo on 2019/12/25.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSMutableArray (FMAdd)
/// 用 输入的 “字符” 拼接每一个字符串数组里面的元素,末尾不拼接
- (NSString *)fm_appendingAllItemsWith:(NSString *)str;
/// 用“,”拼接每个一个字符串数组里面的元素,末尾不拼接
- (NSString *)fm_appendingSemicolonForAllItems;
/// 数组转json字符串
- (NSString *)fm_arrToJsonString;
@end
NS_ASSUME_NONNULL_END
| 18.291667 | 55 | 0.722096 |
7199ffb8640101706ffbe328285de21303f145af | 2,024 | c | C | shoveler/client/src/component/text_texture_renderer.c | improbablejan/shoveler-spatialos | f0bed77332478ba2dfd2d282a57fd6fd5f3ad712 | [
"MIT"
] | null | null | null | shoveler/client/src/component/text_texture_renderer.c | improbablejan/shoveler-spatialos | f0bed77332478ba2dfd2d282a57fd6fd5f3ad712 | [
"MIT"
] | null | null | null | shoveler/client/src/component/text_texture_renderer.c | improbablejan/shoveler-spatialos | f0bed77332478ba2dfd2d282a57fd6fd5f3ad712 | [
"MIT"
] | null | null | null | #include "shoveler/component/text_texture_renderer.h"
#include <assert.h>
#include "shoveler/client_system.h"
#include "shoveler/component/font_atlas_texture.h"
#include "shoveler/component_system.h"
#include "shoveler/schema.h"
#include "shoveler/system.h"
#include "shoveler/text_texture_renderer.h"
static void* activateTextTextureRendererComponent(
ShovelerComponent* component, void* clientSystemPointer);
static void deactivateTextTextureRendererComponent(
ShovelerComponent* component, void* clientSystemPointer);
void shovelerClientSystemAddTextTextureRendererSystem(ShovelerClientSystem* clientSystem) {
ShovelerComponentType* componentType = shovelerSchemaGetComponentType(
clientSystem->schema, shovelerComponentTypeIdTextTextureRenderer);
assert(componentType != NULL);
ShovelerComponentSystem* componentSystem =
shovelerSystemForComponentType(clientSystem->system, componentType);
componentSystem->activateComponent = activateTextTextureRendererComponent;
componentSystem->deactivateComponent = deactivateTextTextureRendererComponent;
componentSystem->callbackUserData = clientSystem;
}
static void* activateTextTextureRendererComponent(
ShovelerComponent* component, void* clientSystemPointer) {
ShovelerClientSystem* clientSystem = clientSystemPointer;
ShovelerComponent* fontAtlasTextureComponent = shovelerComponentGetDependency(
component, SHOVELER_COMPONENT_TEXT_TEXTURE_RENDERER_FIELD_ID_FONT_ATLAS_TEXTURE);
assert(fontAtlasTextureComponent != NULL);
ShovelerFontAtlasTexture* fontAtlasTexture =
shovelerComponentGetFontAtlasTexture(fontAtlasTextureComponent);
assert(fontAtlasTexture != NULL);
return shovelerTextTextureRendererCreate(fontAtlasTexture, clientSystem->shaderCache);
}
static void deactivateTextTextureRendererComponent(
ShovelerComponent* component, void* clientSystemPointer) {
ShovelerTextTextureRenderer* textTextureRenderer = component->systemData;
shovelerTextTextureRendererFree(textTextureRenderer);
}
| 41.306122 | 91 | 0.838439 |
90b9d7ab97f7c2d5ffa031070371a7f73df17ac0 | 552 | h | C | WWZCategory/Classes/NSString+WWZ.h | ccwuzhou/WWZCategory | 7fb5b341ca4b494756faabc82612a0bd183e6104 | [
"MIT"
] | null | null | null | WWZCategory/Classes/NSString+WWZ.h | ccwuzhou/WWZCategory | 7fb5b341ca4b494756faabc82612a0bd183e6104 | [
"MIT"
] | null | null | null | WWZCategory/Classes/NSString+WWZ.h | ccwuzhou/WWZCategory | 7fb5b341ca4b494756faabc82612a0bd183e6104 | [
"MIT"
] | null | null | null | //
// NSString+WWZ.h
// ZCCarOwner
//
// Created by apple on 2017/6/23.
// Copyright © 2017年 zhichekeji. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (WWZ)
/**
documentPath下文件路径
*/
+ (NSString *)wwz_filePathWithFileName:(NSString *)fileName;
/**
是否是手机号
*/
+ (BOOL)wwz_isMobileNumber:(NSString *)mobileNum;
/**
同时包含数字和字符
*/
+ (BOOL)wwz_judgePassWordLegal:(NSString *)pass;
/**
判断是否以字母开头
*/
+ (BOOL)wwz_judgeOwnerNumberLegal:(NSString *)ownerNumber;
/**
* MD5加密
*/
- (NSString *)wwz_md5String;
@end
| 14.526316 | 60 | 0.681159 |
5dd69db2fef494dabd72d36ddb1db4626b895877 | 184 | c | C | ios/Awesome/Natives/abi_test.c | limitLiu/react-native-mirror | 76ecaa15d069ee7bcbc90a8b7eaa42975b3d2d4f | [
"MIT"
] | null | null | null | ios/Awesome/Natives/abi_test.c | limitLiu/react-native-mirror | 76ecaa15d069ee7bcbc90a8b7eaa42975b3d2d4f | [
"MIT"
] | null | null | null | ios/Awesome/Natives/abi_test.c | limitLiu/react-native-mirror | 76ecaa15d069ee7bcbc90a8b7eaa42975b3d2d4f | [
"MIT"
] | null | null | null | //
// abi_test.c
// Awesome
//
// Created by liuyu on 2018/5/6.
// Copyright © 2018 Facebook. All rights reserved.
//
#include "abi_test.h"
long plus(long i) {
return i + 1;
}
| 13.142857 | 51 | 0.61413 |
42c20a8f5987b381632b6b545ac0572aa02938dd | 1,867 | h | C | src/include/efl_assist_screen_reader.h | tizenorg/platform.core.uifw.efl-assist | 914d817d338c5e2ce19f20bbaeed471b8a626f68 | [
"Apache-2.0"
] | null | null | null | src/include/efl_assist_screen_reader.h | tizenorg/platform.core.uifw.efl-assist | 914d817d338c5e2ce19f20bbaeed471b8a626f68 | [
"Apache-2.0"
] | null | null | null | src/include/efl_assist_screen_reader.h | tizenorg/platform.core.uifw.efl-assist | 914d817d338c5e2ce19f20bbaeed471b8a626f68 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef __EFL_ASSIST_SCREEN_READER_H__
#define __EFL_ASSIST_SCREEN_READER_H__
#include <Elementary.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Set an application window property whether the application supports screen reader or not.
*
* @return ret The return value that indicates this function works properly or not.
* If this function works without error, the ret will be EINA_TRUE.
*
* @param[in] win The window(elm_win) object of the application.
* @param[in] support The property value that will set to the windonw(elm_win).
*
* @brief This function sets an application window property which indicates the application
* supports screen reader or not.
*/
EAPI Eina_Bool ea_screen_reader_support_set(Evas_Object *win, Eina_Bool support);
/**
* Get an application window property whether the application supports screen reader or not.
*
* @return property The property value that an application has currently.
*
* @brief This function gets an application window property which indicates the application
* supports screen reader or not.
*/
EAPI Eina_Bool ea_screen_reader_support_get();
#ifdef __cplusplus
}
#endif
#endif /* __EFL_ASSIST_SCREEN_READER_H__ */
| 33.339286 | 92 | 0.747188 |
4235df8604972c083bd1c476869eece6c86afb8d | 544 | h | C | src/usb/inlretro.h | tsr/BSFlashManager | 74c36d246700be0e060fcbfd7153e810cf0adeef | [
"MIT"
] | 11 | 2019-09-17T01:08:57.000Z | 2021-12-27T22:57:03.000Z | src/usb/inlretro.h | tsr/BSFlashManager | 74c36d246700be0e060fcbfd7153e810cf0adeef | [
"MIT"
] | null | null | null | src/usb/inlretro.h | tsr/BSFlashManager | 74c36d246700be0e060fcbfd7153e810cf0adeef | [
"MIT"
] | 1 | 2020-11-27T10:34:35.000Z | 2020-11-27T10:34:35.000Z | #pragma once
#include "device.h"
class INLRetroDevice : public USBDevice
{
Q_OBJECT
public:
INLRetroDevice(QObject *parent = nullptr);
~INLRetroDevice() {}
bool open();
quint8 readByte(quint8 bank, quint16 addr, bool *ok = nullptr);
QByteArray readBytes(quint8 bank, quint16 addr, unsigned size, bool *ok = nullptr);
bool writeByte(quint8 bank, quint16 addr, quint8 data);
private:
void setBank(quint8 bank);
void writeControlPacket(quint8 bRequest, quint16 wValue, quint16 wIndex, quint16 wLength = 1);
quint8 currentBank;
};
| 21.76 | 95 | 0.748162 |
56c16b60f8e8c1e646df1f58178015bff500a538 | 211 | c | C | mie creazioni/Informatica/C/Facolta/23_11_2015/esercizio3_23_11_2015/esercizio3_23_11_2015/main.c | andre-bisa/Archive | 9599342d684172391d8919714e5494082615efb8 | [
"MIT"
] | null | null | null | mie creazioni/Informatica/C/Facolta/23_11_2015/esercizio3_23_11_2015/esercizio3_23_11_2015/main.c | andre-bisa/Archive | 9599342d684172391d8919714e5494082615efb8 | [
"MIT"
] | null | null | null | mie creazioni/Informatica/C/Facolta/23_11_2015/esercizio3_23_11_2015/esercizio3_23_11_2015/main.c | andre-bisa/Archive | 9599342d684172391d8919714e5494082615efb8 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
int main() {
int temp[31][24];
int i,j;
for (i=0; i<31; i++)
for (j=0; j<24; j++)
srand(rand()), temp[i][j] = 18 + rand() % 3;
system("pause");
return 0;
} | 11.722222 | 47 | 0.511848 |
5e15f15c1a54b38504d9911d1d13bb1e28d7e556 | 581 | h | C | JustEngine/Include/Buffer.h | luxuia/JustEngine | b8785b16d2c4495a41d9c16cfa0c0c18bc01c5b0 | [
"MIT"
] | 1 | 2016-04-13T08:31:56.000Z | 2016-04-13T08:31:56.000Z | JustEngine/Include/Buffer.h | luxuia/JustEngine | b8785b16d2c4495a41d9c16cfa0c0c18bc01c5b0 | [
"MIT"
] | null | null | null | JustEngine/Include/Buffer.h | luxuia/JustEngine | b8785b16d2c4495a41d9c16cfa0c0c18bc01c5b0 | [
"MIT"
] | null | null | null | #pragma once
#include "Macros.h"
namespace JustEngine
{
class DLL_EXPORT Buffer
{
protected:
bool mDirty = true;
public:
virtual void DeleteBuffer();
virtual bool UpdateBuffer();
virtual void* GetBuffer();
virtual UINT GetStride();
virtual UINT GetOffset();
bool GetDirty() const
{
return mDirty;
}
};
inline void Buffer::DeleteBuffer() {}
inline bool Buffer::UpdateBuffer()
{
return false;
}
inline void * Buffer::GetBuffer()
{
return NULL;
}
inline UINT Buffer::GetStride() { return 0; }
inline UINT Buffer::GetOffset() { return 0; }
} | 16.138889 | 46 | 0.678141 |
e53133a7a3a65fd4250e35824edad48570f733cc | 1,047 | h | C | utilities/macros.h | CARV-ICS-FORTH/tebis | b6c9e5cb6f8f38516ff7f5c73867e49951143e3a | [
"Apache-2.0"
] | 5 | 2022-02-03T18:18:02.000Z | 2022-02-06T20:24:34.000Z | utilities/macros.h | CARV-ICS-FORTH/tebis | b6c9e5cb6f8f38516ff7f5c73867e49951143e3a | [
"Apache-2.0"
] | null | null | null | utilities/macros.h | CARV-ICS-FORTH/tebis | b6c9e5cb6f8f38516ff7f5c73867e49951143e3a | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <stdint.h>
#define WAIT_REPLICA_TO_COMMIT 0xFD
#define DO_NOT_WAIT_REPLICA_TO_COMMIT 0xAC
#define NUM_OF_TRIES 1000
extern uint64_t wake_up_workers_operations;
/* Macro for printing debug messages
* Note: ##__VA_ARGS__ is used instead of just __VA_ARGS__ so that gcc will not
* produce an error when __VA_ARGS__ is empty
*/
#define DPRINT(format_string, ...) printf("[%s:%s:%d] " format_string, __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#define ERRPRINT(format_string, ...) \
fprintf(stderr, "[%s:%s:%d] ERROR: " format_string, __FILE__, __func__, __LINE__, ##__VA_ARGS__)
/*gesalous: the def below is used for performance debugging reasons. It is used to evaluate
* the performance of the insert path excluding I/O. It could have be done better through an appropriate extension
* of the protocol but due to pressure of time we did it this way. Should add this feature in a next version
* */
#define OMMIT_IO_IN_THE_INSERT_PATH 0
| 49.857143 | 120 | 0.709647 |
ab4672be4190fb93ad925de9848d8b2e01dbb492 | 2,302 | h | C | src/cyad/CommandsDispatcher.h | Samsung/cynara | be455dcaf1400bec0272a6ce90852b9147393a60 | [
"Apache-2.0"
] | 22 | 2015-05-19T08:33:30.000Z | 2022-02-27T02:19:32.000Z | src/cyad/CommandsDispatcher.h | Samsung/cynara | be455dcaf1400bec0272a6ce90852b9147393a60 | [
"Apache-2.0"
] | 10 | 2015-05-07T19:01:54.000Z | 2016-07-07T07:37:37.000Z | src/cyad/CommandsDispatcher.h | Samsung/cynara | be455dcaf1400bec0272a6ce90852b9147393a60 | [
"Apache-2.0"
] | 23 | 2015-02-28T21:31:58.000Z | 2020-04-23T02:25:37.000Z | /*
* Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file src/cyad/CommandsDispatcher.h
* @author Aleksander Zdyb <a.zdyb@samsung.com>
* @version 1.0
* @brief CommandsDispatcher class
*/
#ifndef SRC_CYAD_COMMANDSDISPATCHER_H_
#define SRC_CYAD_COMMANDSDISPATCHER_H_
#include <cyad/BaseAdminApiWrapper.h>
#include <cyad/BaseErrorApiWrapper.h>
#include <cyad/CommandlineParser/CyadCommand.h>
#include <cyad/DispatcherIO.h>
#include <cyad/PolicyTypeTranslator.h>
struct cynara_admin;
struct cynara_admin_policy;
namespace Cynara {
class CommandsDispatcher {
public:
CommandsDispatcher(BaseDispatcherIO &io, BaseAdminApiWrapper &adminApiWrapper,
BaseErrorApiWrapper &errorApiWrapper);
virtual ~CommandsDispatcher();
virtual int execute(CyadCommand &);
virtual int execute(HelpCyadCommand &);
virtual int execute(ErrorCyadCommand &);
virtual int execute(DeleteBucketCyadCommand &);
virtual int execute(SetBucketCyadCommand &);
virtual int execute(SetPolicyCyadCommand &);
virtual int execute(SetPolicyBulkCyadCommand &);
virtual int execute(EraseCyadCommand &);
virtual int execute(CheckCyadCommand &);
virtual int execute(ListPoliciesCyadCommand &);
virtual int execute(ListPoliciesDescCyadCommand &);
protected:
void printAdminApiError(int errnum);
void initPolicyTranslator(void);
private:
PolicyTypeTranslator m_policyTranslator;
BaseDispatcherIO &m_io;
BaseAdminApiWrapper &m_adminApiWrapper;
BaseErrorApiWrapper &m_errorApiWrapper;
struct cynara_admin *m_cynaraAdmin;
};
} /* namespace Cynara */
#endif /* SRC_CYAD_COMMANDSDISPATCHER_H_ */
| 32.885714 | 82 | 0.741095 |
5855991a335a9a44ce35e6d029e265986b31458e | 2,180 | h | C | src/CBSection.h | HMRdesigns/ConfigurableTableView | 43de9618374a06f47b4d845bb353886d388901ab | [
"MIT"
] | 1 | 2019-09-10T05:16:14.000Z | 2019-09-10T05:16:14.000Z | src/CBSection.h | HMRdesigns/ConfigurableTableView | 43de9618374a06f47b4d845bb353886d388901ab | [
"MIT"
] | null | null | null | src/CBSection.h | HMRdesigns/ConfigurableTableView | 43de9618374a06f47b4d845bb353886d388901ab | [
"MIT"
] | null | null | null | //
// CBTableViewGroup.h
// ConfigurableTableView
//
// Created by Christian Beer on 04.12.09.
// Copyright 2010 Christian Beer. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class CBConfigurableTableViewController;
@class CBTable;
@class CBSection;
@class CBCell;
@protocol CBSectionHeaderView
- (CGFloat) heightForHeaderInTableView:(UITableView*)tableView;
@end
@interface CBSection : NSObject {
CBConfigurableTableViewController *__weak _controller;
CBTable *__weak _table;
NSString *_tag;
NSString *_title;
NSMutableArray *_cells;
UIView *_headerView;
NSString *_footerTitle;
UIView *_footerView;
}
@property (nonatomic, weak) CBConfigurableTableViewController *controller;
@property (nonatomic, weak) CBTable *table;
@property (nonatomic, assign) BOOL hidden;
@property (nonatomic, copy) NSString *tag;
@property (nonatomic, copy) NSString *title;
@property (weak, readonly) NSArray *cells;
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) NSString *footerTitle;
@property (nonatomic, strong) UIView *footerView;
- (id) initWithTitle:(NSString*)title andCells:(NSArray*)cells;
- (id) initWithTitle:(NSString*)title;
- (CBSection*) applyTag:(NSString *)tag;
+ (id) sectionWithTitle:(NSString*)title;
+ (id) sectionWithTitle:(NSString*)title andCells:(CBCell*)cell, ...NS_REQUIRES_NIL_TERMINATION;
- (NSInteger) cellCount;
- (id) cellAtIndex:(NSUInteger)idx;
- (NSUInteger) indexOfCell:(CBCell*)cell;
- (NSUInteger) indexOfCellWithTag:(NSString*)tag;
- (id) addCell:(CBCell*)cell;
- (id) insertCell:(CBCell*)cell atIndex:(NSUInteger)index;
- (void) insertCells:(NSArray*)cells atIndex:(NSUInteger)index;
- (void) addCells:(CBCell*)cell, ...NS_REQUIRES_NIL_TERMINATION;
- (void) addCellsFromArray:(NSArray*)cells;
- (id) cellWithTag:(NSString*)tag;
- (id) cellWithValueKeyPath:(NSString*)valuePath;
- (id) removeCell:(CBCell*)cell;
- (void) removeCellsInArray:(NSArray*)cells;
- (void) removeCells:(CBCell*)cell, ...NS_REQUIRES_NIL_TERMINATION;
- (id) removeCellWithTag:(NSString*)cellTag;
- (void) setHidden:(BOOL)hidden tellDelegate:(BOOL)delegate;
@end
| 25.952381 | 96 | 0.747706 |
586ed94300b19b9a3e3693113f9e5a5f4cda7164 | 1,500 | h | C | src/data_block.h | bombehub/IndexZoo | 75af96797a8019c3b41186eebdc6d497c41dbb79 | [
"Apache-2.0"
] | 22 | 2018-06-08T05:32:55.000Z | 2021-09-24T10:54:43.000Z | src/data_block.h | bombehub/IndexZoo | 75af96797a8019c3b41186eebdc6d497c41dbb79 | [
"Apache-2.0"
] | null | null | null | src/data_block.h | bombehub/IndexZoo | 75af96797a8019c3b41186eebdc6d497c41dbb79 | [
"Apache-2.0"
] | 3 | 2018-09-11T13:00:06.000Z | 2020-04-01T04:38:44.000Z | #pragma once
#include <atomic>
#include <cstring>
#include "offset.h"
const uint64_t MaxBlockCapacity = 1000;
class DataBlock {
public:
DataBlock(const BlockIDT block_id, const size_t tuple_size, const uint64_t max_block_capacity) :
block_id_(block_id),
tuple_size_(tuple_size),
max_rel_offset_(max_block_capacity) {
next_rel_offset_ = 0;
tuples_ = new char[tuple_size_ * max_rel_offset_];
memset(tuples_, 0, tuple_size_ * max_rel_offset_);
}
~DataBlock() {
delete[] tuples_;
tuples_ = nullptr;
}
RelOffsetT get_next_rel_offset() {
RelOffsetT rel_offset = next_rel_offset_.fetch_add(1);
if (rel_offset < max_rel_offset_) {
return rel_offset;
} else {
return INVALID_OFFSET;
}
}
char* get_tuple(const RelOffsetT rel_offset) const {
ASSERT(rel_offset < max_rel_offset_, "wrong offset: " << rel_offset << " " << max_rel_offset_);
return tuples_ + rel_offset * tuple_size_;
}
BlockIDT get_block_id() const {
return block_id_;
}
RelOffsetT get_max_rel_offset() const {
return max_rel_offset_;
}
size_t size() const {
return next_rel_offset_;
}
private:
DataBlock(const DataBlock &);
DataBlock& operator=(const DataBlock &);
private:
const RelOffsetT max_rel_offset_;
BlockIDT block_id_;
std::atomic<RelOffsetT> next_rel_offset_;
size_t tuple_size_;
char *tuples_;
};
| 21.73913 | 101 | 0.656667 |
bf6dc8ece6fa87db96a8494c4917dfaa66cccf40 | 543 | h | C | CustomControl/CustomView/LZListView/LZListViewCell.h | darling0825/CustomControl | 724af2b7d81753c41a5ca7f82c80c7e1faf46fb2 | [
"MIT"
] | null | null | null | CustomControl/CustomView/LZListView/LZListViewCell.h | darling0825/CustomControl | 724af2b7d81753c41a5ca7f82c80c7e1faf46fb2 | [
"MIT"
] | null | null | null | CustomControl/CustomView/LZListView/LZListViewCell.h | darling0825/CustomControl | 724af2b7d81753c41a5ca7f82c80c7e1faf46fb2 | [
"MIT"
] | null | null | null | //
// LZListViewCell.h
// CustomControl
//
// Created by liww on 2014/12/1.
// Copyright (c) 2014年 liww. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface LZListViewCell : NSView{
IBOutlet NSTextField *_textField;
IBOutlet NSImageView *_imageView;
NSString *_text;
NSImage *_image;
NSString *_reuseIdentifier;
}
@property (nonatomic, readonly, copy) NSString *reuseIdentifier;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, retain)NSImage *image;
- (void)prepareForReuse;
@end
| 21.72 | 64 | 0.703499 |
baaf8857c3cccb7fb05bba32e20155c4c6c1d8f0 | 2,447 | h | C | emdrv/ezradiodrv/common/inc/si4x55/ezradio_api_lib_add.h | ryankurte/efm32-base | 6349c2d8203355a7ca1523572d9e58e02f54eb05 | [
"MIT"
] | 73 | 2015-11-07T08:07:27.000Z | 2022-02-08T09:16:36.000Z | emdrv/ezradiodrv/common/inc/si4x55/ezradio_api_lib_add.h | ryankurte/efm32-base | 6349c2d8203355a7ca1523572d9e58e02f54eb05 | [
"MIT"
] | 26 | 2015-06-09T17:16:46.000Z | 2021-05-04T23:42:18.000Z | emdrv/ezradiodrv/common/inc/si4x55/ezradio_api_lib_add.h | ryankurte/efm32-base | 6349c2d8203355a7ca1523572d9e58e02f54eb05 | [
"MIT"
] | 36 | 2017-02-25T09:12:57.000Z | 2022-03-27T10:39:43.000Z | /***************************************************************************//**
* @file
* @brief This file contains the additional API library for the listed members of
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#ifndef _EZRADIO_API_LIB_ADD_H_
#define _EZRADIO_API_LIB_ADD_H_
#include "ezradio_api_lib.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup emdrv
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup EZRADIODRV
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup API_Layer
* @{
******************************************************************************/
EZRADIO_ConfigRet_t ezradio_configuration_init(const uint8_t* pSetPropCmd);
void ezradio_write_ezconfig_array(uint8_t numBytes, uint8_t* pEzConfigArray);
void ezradio_ezconfig_check(uint16_t checksum, ezradio_cmd_reply_t *ezradioReply);
#ifdef EZRADIO_DRIVER_EXTENDED_SUPPORT
/* Extended driver support functions */
#ifdef EZRADIO_DRIVER_FULL_SUPPORT
/* Full driver support functions */
void ezradio_get_adc_reading(uint8_t adc_en, uint8_t adc_cfg, ezradio_cmd_reply_t *ezradioReply);
#endif /* EZRADIO_DRIVER_FULL_SUPPORT */
#endif /* EZRADIO_DRIVER_EXTENDED_SUPPORT */
/** @} (end addtogroup API_Layer) */
/** @} (end addtogroup EZRADIODRV) */
/** @} (end addtogroup emdrv) */
#ifdef __cplusplus
}
#endif
#else //_EZRADIO_API_LIB_ADD_H_
#error Additional EZRadio API library is already defined.
#endif //_EZRADIO_API_LIB_ADD_H_
| 35.463768 | 97 | 0.518186 |
c79ea52634e9a5f35a6810e1d4d2abeb2d86ff3d | 498 | h | C | app/src/main/cpp/IObserver.h | yishuinanfeng/UnitedPlayer | 3e3e43ac7ecaa6636965870420eda600205be34d | [
"Apache-2.0"
] | 100 | 2020-02-01T05:39:16.000Z | 2022-03-15T06:54:27.000Z | app/src/main/cpp/IObserver.h | yishuinanfeng/UnitedPlayer | 3e3e43ac7ecaa6636965870420eda600205be34d | [
"Apache-2.0"
] | null | null | null | app/src/main/cpp/IObserver.h | yishuinanfeng/UnitedPlayer | 3e3e43ac7ecaa6636965870420eda600205be34d | [
"Apache-2.0"
] | 16 | 2020-02-04T05:52:42.000Z | 2021-08-09T07:15:27.000Z | //
// Created by yanxi on 2019/9/1.
//
#ifndef MANCHESTERUNITEDPLAYER_IOBSERVER_H
#define MANCHESTERUNITEDPLAYER_IOBSERVER_H
#include "XData.h"
#include "XThread.h"
#include <vector>
#include <mutex>
/**
* 既是观察者又是被观察者
*/
class IObserver :public XThread{
public:
virtual void Update(XData data){}
void AddOberver(IObserver *observer);
void notify(XData data);
private:
std::vector<IObserver *> obervers;
std::mutex mutex;
};
#endif //MANCHESTERUNITEDPLAYER_IOBSERVER_H
| 16.064516 | 43 | 0.722892 |
2a1e331ec8fa053938643efd4fed17756c8a488b | 180 | c | C | chapter 10/examples/str10.c | realme72/beginning | 9c6c5abaf675a53f88552dbc7fbf44c6bc94087c | [
"MIT"
] | 2 | 2018-07-01T07:39:44.000Z | 2020-05-17T07:26:26.000Z | chapter 10/examples/str10.c | realme72/beginning | 9c6c5abaf675a53f88552dbc7fbf44c6bc94087c | [
"MIT"
] | null | null | null | chapter 10/examples/str10.c | realme72/beginning | 9c6c5abaf675a53f88552dbc7fbf44c6bc94087c | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
int main()
{
char *str;
str=(char *)malloc(10);
printf("Enter a string\n");
scanf("%s",str);
printf("String is %s\n",str);
return 0;
} | 15 | 30 | 0.611111 |
686294c079b3f1364cc9c427d8fe8a22c977bacc | 1,963 | c | C | C/example04/main.c | sasasagagaga/Code-examples | 084db5bca241b164a670e303f73048fe4e6dad79 | [
"MIT"
] | null | null | null | C/example04/main.c | sasasagagaga/Code-examples | 084db5bca241b164a670e303f73048fe4e6dad79 | [
"MIT"
] | null | null | null | C/example04/main.c | sasasagagaga/Code-examples | 084db5bca241b164a670e303f73048fe4e6dad79 | [
"MIT"
] | null | null | null |
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
enum
{
MAX_SIZE = 1000000,
MAX_LEN = 32,
START_MEM = 8,
};
typedef struct Type
{
char name[MAX_LEN];
size_t size, allign;
} Type;
void
find_type(Type *types, int arr_size, char *type_name, size_t *size, size_t *allign)
{
*size = 0;
*allign = 0;
for (int i = 0; i < arr_size; ++i) {
if (strcmp(type_name, types[i].name) == 0) {
*size = types[i].size;
*allign = types[i].allign;
break;
}
}
}
void
end(Type *types)
{
free(types);
puts("0 0");
}
int
main(void)
{
int used = 0;
int alloc = START_MEM;
Type *types = calloc(START_MEM, sizeof(types[0]));
Type buf;
while (scanf("%s%zu%zu", buf.name, &buf.size, &buf.allign) == 3) {
if (used >= alloc) {
types = realloc(types, (alloc *= 2) * sizeof(types[0]));
}
types[used++] = buf;
}
size_t size = 0;
size_t allign = 1;
char name[MAX_LEN];
size_t count;
while (scanf("%s%zu", name, &count) == 2) {
size_t cur_size, cur_allign;
find_type(types, used, name, &cur_size, &cur_allign);
size_t extra = size % cur_allign;
if (extra && __builtin_add_overflow(size, cur_allign - extra, &size)) {
end(types);
return 0;
}
size_t tmp;
if (__builtin_mul_overflow(cur_size, count, &tmp) ||
__builtin_add_overflow(size, tmp, &size)) {
end(types);
return 0;
}
if (allign < cur_allign) {
allign = cur_allign;
}
}
size_t extra = size % allign;
if (extra && __builtin_add_overflow(size, allign - extra, &size)) {
end(types);
return 0;
}
if (size == 0 || allign == 0) {
size = 1;
allign = 1;
}
printf("%zu %zu\n", size, allign);
free(types);
}
| 19.058252 | 83 | 0.516556 |
be755bc8a4e6834bf8da815a81aabfc26156cac0 | 818 | h | C | src/model/world/Section.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 14 | 2020-05-27T16:50:50.000Z | 2022-01-17T17:13:40.000Z | src/model/world/Section.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 2 | 2021-06-20T15:48:09.000Z | 2021-07-02T13:57:49.000Z | src/model/world/Section.h | githubcraft/NextCraft | e758590434e418c24dd8e66177f853445716b50d | [
"Apache-2.0"
] | 5 | 2020-05-15T08:04:24.000Z | 2021-07-22T03:00:32.000Z | //
// Created by twome on 22/01/2020.
//
#ifndef NEXTCRAFT_SECTION_H
#define NEXTCRAFT_SECTION_H
#include <cstdint>
#include "BlockData.h"
#include "../../mesh/SectionMesh.h"
class SectionMesh;
namespace chunk {
struct Section {
public:
int x;
int y;
int z;
SectionMesh *mesh;
BlockData *data;
Section(int x, int y, int z);
~Section();
BlockData &GetBlockData(int x, int y, int z);
void SetBlockData(int x, int y, int z, BlockData block);
void SetBlock(int x, int y, int z, uint8_t id);
void SetMeta(int x, int y, int z, uint8_t meta);
void CheckFluid(uint8_t blockId) const;
private:
inline BlockData *GetBlockDataPtr(int x, int y, int z) const;
};
}
#endif //NEXTCRAFT_SECTION_H
| 17.404255 | 69 | 0.606357 |
848197a9096d996332bd1efd73b6aacf9ea68d95 | 307 | h | C | KidsTC/KidsTC/Business/Main/Product/FlashBuy/OrderList/C/FlashServiceOrderListViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | null | null | null | KidsTC/KidsTC/Business/Main/Product/FlashBuy/OrderList/C/FlashServiceOrderListViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | null | null | null | KidsTC/KidsTC/Business/Main/Product/FlashBuy/OrderList/C/FlashServiceOrderListViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | 1 | 2018-09-18T07:26:36.000Z | 2018-09-18T07:26:36.000Z | //
// FlashServiceOrderListViewController.h
// KidsTC
//
// Created by zhanping on 8/18/16.
// Copyright © 2016 詹平. All rights reserved.
//
#import "ViewController.h"
extern NSString *const FlashServiceOrderListCellCountDownNoti;
@interface FlashServiceOrderListViewController : ViewController
@end
| 19.1875 | 63 | 0.771987 |
84c4ceb79d97b73190411c4b5dd6c20165cb9657 | 136 | h | C | lab_09/c_requester.h | v-ilya99/lab09 | 955dce7e41dfe02398bb037782ba94c616a8f958 | [
"MIT"
] | null | null | null | lab_09/c_requester.h | v-ilya99/lab09 | 955dce7e41dfe02398bb037782ba94c616a8f958 | [
"MIT"
] | null | null | null | lab_09/c_requester.h | v-ilya99/lab09 | 955dce7e41dfe02398bb037782ba94c616a8f958 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
class c_requester
{
public:
c_requester();
std::string do_request(std::string const& url);
};
| 11.333333 | 51 | 0.676471 |
51029b7fd0872c58318d83ff68aa3fd2e6cecdbb | 1,126 | h | C | src/blynk.h | kleewyck/PowerGate | fe141345cc15c3075da0c82909b50423b8685b00 | [
"Apache-2.0"
] | null | null | null | src/blynk.h | kleewyck/PowerGate | fe141345cc15c3075da0c82909b50423b8685b00 | [
"Apache-2.0"
] | null | null | null | src/blynk.h | kleewyck/PowerGate | fe141345cc15c3075da0c82909b50423b8685b00 | [
"Apache-2.0"
] | null | null | null | #ifndef LVD_BLYNK_H_
#define LVD_BLYNK_H_
#define BLYNK_HEADER_SIZE 5
#define BLYNK_RESPONSE 0
#define BLYNK_LOGIN 2
#define BLYNK_PING 6
#define BLYNK_HARDWARE 20
//
// Virtual Pins
//
#define VIRT_CURRENT_PIN 0
#define VIRT_BATT_V_PIN 1
#define VIRT_PS_V_PIN 2
#define VIRT_OUT_V_PIN 3
#define VIRT_RELAY_PIN 4
//
// External Variables
//
extern int s_reconnect_interval_ms;
typedef void (*blynk_handler_t)(struct mg_connection *, const char *cmd,
int pin, int val, void *user_data);
void blynk_send(struct mg_connection *c, uint8_t type, uint16_t id,
const void *data, uint16_t len);
void blynk_set_handler(blynk_handler_t func, void *user_data);
void default_blynk_handler(struct mg_connection *c, const char *cmd,
int pin, int val, void *user_data);
void handle_blynk_frame(struct mg_connection *c, void *user_data,
const uint8_t *data, uint16_t len);
void ev_handler(struct mg_connection *c, int ev, void *ev_data,
void *user_data);
void reconnect_timer_cb(void *arg);
#endif
| 29.631579 | 72 | 0.692718 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.