text
stringlengths 2
100k
| meta
dict |
---|---|
ฮฮฮฮฮฮฮฮฮฮฮฮฮฮฮฮ ฮกฮฃฮคฮฅฮฆฮงฮจฮฉ <- Greek
๐๐๐๐๐๐
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐ <- Etruscan
ABCDEFGHIJKLMNOPQRSTUVWXYZ <- Latin
ะะะะะะะะะะะะะะะะะ ะกะขะฃะคะฅะฆะงะจะฉะชะซะฌะญะฎะฏ <- Cyrillic
๐ฐ๐ฑ๐ฒ๐ณ๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ผ๐ฝ๐พ๐ฟ๐๐๐๐๐๐
๐๐๐ <- Gothic
ืืืืืืืืืืืืืืืืื ืกืขืฃืคืฅืฆืงืจืฉ <- Hebrew
| {
"pile_set_name": "Github"
} |
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var a = {};
function foo() {
a.push();
}
function bar() {
foo();
}
bar();
| {
"pile_set_name": "Github"
} |
config BR2_PACKAGE_ZIP
bool "zip"
help
Zip is a compression and file packaging/archive utility.
Although highly compatible both with PKWARE's PKZIP and
PKUNZIP utilities for MS-DOS and with Info-ZIP's own UnZip,
our primary objectives have been portability and
other-than-MSDOS functionality.
http://infozip.sourceforge.net/Zip.html
| {
"pile_set_name": "Github"
} |
//
// EXTADT.h
// extobjc
//
// Created by Justin Spahr-Summers on 19.06.12.
// Copyright (C) 2012 Justin Spahr-Summers.
// Released under the MIT license.
//
#import "metamacros.h"
#import "EXTRuntimeExtensions.h"
/**
* Creates an algebraic data type with the given name and one or more data
* constructors. Each constructor should be specified using the \c constructor()
* macro, the first argument of which is the constructor name. Zero or more
* parameters, which should look just like variable declarations (e.g., "int x")
* may follow the constructor name.
*
* Among many other things, this can be used to create type-safe enumerations
* which can be printed as strings (and optionally associated with data).
*
* This macro will create:
*
* - A structure type NameT, where "Name" is the first argument to this macro.
* Instances of the structure will each contain a member "tag", which is filled
* in with the enum value of the constructor used to create the value.
* - A function NSStringFromName(), which will convert an ADT value into
* a human-readable string.
* - A function NameEqualToName(), which determines whether two ADT values are
* equal. For the purposes of the check, object parameters are compared with \c
* isEqual:.
* - And, for each constructor Cons:
* - An enum value Cons, which can be used to refer to that data constructor.
* - A function Name.Cons(...), which accepts the parameters of the
* constructor and returns a new NameT structure.
* - Members (properties) for each of the constructor's named parameters,
* which can be used to get and set the data associated with that
* constructor.
*
* @code
// this invocation:
ADT(Color,
constructor(Red),
constructor(Green),
constructor(Blue),
constructor(Gray, double alpha),
constructor(Other, double r, double g, double b)
);
// produces (effectively) these definitions:
typedef struct {
enum { Red, Green, Blue, Gray, Other } tag;
union {
struct {
double alpha;
}
struct {
double r;
double g;
double b;
}
}
} ColorT;
NSString *NSStringFromColor (ColorT c);
ColorT Color.Red ();
ColorT Color.Green ();
ColorT Color.Blue ();
ColorT Color.Gray (double alpha);
ColorT Color.Other (double r, double g, double b);
* @endcode
*
* @note Each constructor parameter must have a name that is unique among all of
* the ADT's constructors, so that dot-syntax (e.g., "color.r") works without
* needing to prefix the name of the data constructor (e.g., "color.Other.r").
*
* @note To define recursive types, ADT parameters can be pointers to the type
* already being defined. For example, a parameter for the Color ADT is allowed
* to be a pointer to a ColorT.
*
* @warning Accessing members that do not correspond to the structure's tag
* (e.g., parameter data from other constructors) is considered undefined
* behavior.
*
* @bug Currently, only up to nineteen data constructors are supported, and each
* constructor may only have up to nineteen parameters. This is a limitation
* imposed primarily by #metamacro_foreach_cxt.
*
* @bug An ADT value nested within another ADT value will not be very readable
* when printed out with the generated NSStringFromโฆ function. All other data
* will behave correctly.
*/
#define ADT(NAME, ...) \
/* a type (NameT) for values defined by this ADT */ \
typedef struct ADT_CURRENT_T NAME ## T; \
\
/* create typedefs for all of the parameters types used with any constructor */ \
/* this will append ADT_typedef_ to each constructor() call, thus invoking
* ADT_typedef_constructor() instead */ \
metamacro_foreach_concat(ADT_typedef_,, __VA_ARGS__) \
\
struct ADT_CURRENT_T { \
/* an enum listing all the constructor names for this ADT */ \
/* this will also be how we know the type of this value */ \
const enum { \
metamacro_foreach_concat(ADT_enum_,, __VA_ARGS__) \
} tag; \
\
/* overlapping storage for all the possible constructors */ \
/* the tag above determines which parts of this union are in use */ \
union { \
metamacro_foreach_concat(ADT_payload_,, __VA_ARGS__) \
}; \
}; \
\
/* defines the actual constructor functions for this type */ \
metamacro_foreach_concat(ADT_,, __VA_ARGS__) \
\
/* this structure is used like a simple namespace for the constructors: */ \
/* ColorT c = Color.Red(); */ \
const struct { \
/* as the structure definition, list the function pointers and names of the constructors */ \
metamacro_foreach_concat(ADT_fptrs_,, __VA_ARGS__) \
} NAME = { \
/* then fill them in with the actual function addresses */ \
metamacro_foreach_concat(ADT_fptrinit_,, __VA_ARGS__) \
}; \
\
/* implements NSStringFromName(), to describe an ADT value */ \
static inline NSString *NSStringFrom ## NAME (NAME ## T s) { \
NSMutableString *str = [[NSMutableString alloc] init]; \
\
/* only values with parameters will have braces added */ \
BOOL addedBraces = NO; \
\
/* construct the description differently depending on the constructor used */ \
switch (s.tag) { \
metamacro_foreach_concat(ADT_tostring_,, __VA_ARGS__) \
default: \
return nil; \
} \
\
if (addedBraces) \
[str appendString:@" }"]; \
\
return str; \
} \
\
/* implements NameEqualToName(), to compare ADT values for equality */ \
static inline BOOL NAME ## EqualTo ## NAME (NAME ## T a, NAME ## T b) { \
if (a.tag != b.tag) \
return NO; \
\
/* construct the check differently depending on the constructor used */ \
switch (a.tag) { \
metamacro_foreach_concat(ADT_equalto_,, __VA_ARGS__) \
default: \
; \
} \
\
return YES; \
}
/*** implementation details follow ***/
/*
* This macro simply creates an enum entry for the given constructor name.
*/
#define ADT_enum_constructor(...) \
/* pop off the first variadic argument instead of using a named argument */ \
/* (necessary because the ... in the argument list needs to match at least one argument) */ \
metamacro_head(__VA_ARGS__),
/*
* The "payload" terminology here refers to the data actually stored in an ADT
* value, and more specifically to the data pertaining only to the constructor
* that was used.
*
* These macros generate the internal layout of the NameT structure.
*
* For the following ADT:
ADT(Color,
constructor(Red),
constructor(Green),
constructor(Blue),
constructor(Gray, double alpha),
constructor(Other, double r, double g, double b)
);
* The resulting structure is laid out something like this:
typedef struct {
const enum { Red, Green, Blue, Gray, Other } tag;
union {
// Gray
struct {
union {
union {
double alpha;
} Gray_payload_0;
double alpha;
};
};
// Other
struct {
union {
union {
double r;
} Other_payload_0;
double r;
};
union {
union {
double g;
} Other_payload_1;
double g;
};
union {
union {
double b;
} Other_payload_2;
double b;
};
};
};
} ColorT;
* The use of anonymous structures and the containing anonymous union allows
* a user to access parameter data without intervening steps (e.g.,
* 'color.alpha', instead of 'color.Gray.alpha'), but does prevent two
* parameters -- even for different constructors -- from having the same name.
*/
#define ADT_payload_constructor(...) \
/* our first argument will always be the constructor name, so if we only
* have one argument, we only have a constructor */ \
metamacro_if_eq(1, metamacro_argcount(__VA_ARGS__)) \
(/* this constructor has only a name, don't add any structures */)\
( \
/* create structures for the parameters that exist */ \
ADT_payload_constructor_(__VA_ARGS__) \
)
#define ADT_payload_constructor_(CONS, ...) \
struct { \
metamacro_foreach_cxt_recursive(ADT_payload_entry_iter,, CONS, __VA_ARGS__) \
};
#define ADT_payload_entry_iter(INDEX, CONS, PARAM) \
ADT_CURRENT_CONS_UNION_T(CONS, INDEX, PARAM);
/*
* The next few macros create type definitions for the unions used for each
* parameter in the current ADT (e.g., those within the example structures
* above).
*
* We do this so that instead of a type and name for each parameter (e.g.,
* 'double alpha'), we can manipulate a union (e.g., 'Gray_payload_0') that
* matches the type, but has a name we define.
*
* The type definitions are later used for function parameters created by
* ADT_prototype_iter().
*/
#define ADT_typedef_constructor(...) \
/* our first argument will always be the constructor name, so if we only
* have one argument, we only have a constructor */ \
metamacro_if_eq(1, metamacro_argcount(__VA_ARGS__)) \
(/* no parameters, don't add any typedefs */) \
( \
/* there are actually parameters */ \
ADT_typedef_constructor_(__VA_ARGS__) \
)
#define ADT_typedef_constructor_(CONS, ...) \
metamacro_foreach_cxt_recursive(ADT_typedef_iter,, CONS, __VA_ARGS__)
#define ADT_typedef_iter(INDEX, CONS, PARAM) \
typedef ADT_CURRENT_CONS_UNION_T(CONS, INDEX, PARAM) __attribute__((transparent_union)) \
ADT_CURRENT_CONS_ALIAS_T(CONS, INDEX);
/*
* This macro generates an inline function corresponding to one of the data
* constructors, which will initialize an ADT value and return it.
*
* The first variadic argument here is always the name of the constructor, with
* the rest of the argument list being the parameters given by the user.
*
* Unfortunately, we cannot give an argument name to the constructor, since
* constructors may have no parameters, and the ... in the macro's argument list
* needs to always match at least one argument. Instead, metamacro_head() is
* used to get the constructor name.
*/
#define ADT_constructor(...) \
static inline struct ADT_CURRENT_T \
\
/* the function name (e.g., 'Red_init_') */ \
metamacro_concat(metamacro_head(__VA_ARGS__), _init_) \
\
/* the parameter list for this function */ \
(metamacro_foreach_cxt_recursive(ADT_prototype_iter,, metamacro_head(__VA_ARGS__), __VA_ARGS__)) \
{ \
/* the actual work of initializing the structure */ \
/* the local variables for this function are defined in the first iteration of the loop */ \
metamacro_foreach_cxt_recursive(ADT_initialize_iter,, metamacro_head(__VA_ARGS__), __VA_ARGS__) \
return s; \
}
/*
* The macros below define each parameter to the constructor function.
*
* We use the type definitions created by ADT_typedef_iter() and give them
* simple, sequentially-numbered names, so we don't have to do any more work to
* parse or otherwise manipulate the declarations given by the user.
*
* Because the first argument to metamacro_foreach_recursive_cxt() is the
* constructor name, our parameters actually need to be shifted down --
* index 1 actually corresponds to v0, our first parameter.
*/
#define ADT_prototype_iter(INDEX, CONS, PARAM) \
metamacro_if_eq(0, INDEX) \
(/* the constructor name itself is passed as the first argument (again to
* work around the caveat with variadic arguments), but we don't want it in
* the parameter list, so we do nothing */) \
( \
/* insert a comma for every argument after index 1 */ \
metamacro_if_eq_recursive(1, INDEX)()(,) \
\
/* parameter type */ \
ADT_CURRENT_CONS_ALIAS_T(CONS, metamacro_dec(INDEX)) \
\
/* parameter name */ \
metamacro_concat(v, metamacro_dec(INDEX)) \
)
/*
* The macros below generate the initialization code that is actually executed
* in the constructor function.
*
* We merely need to map the given arguments onto the internal unions defined by
* ADT_payload_entry_iter(). Because the union is itself unioned with the
* user-facing fields, the value can then be read by the user with the name they
* gave it.
*
* As with ADT_prototype*(), our parameter numbers need to be shifted down to
* correspond to the values in the structure.
*/
#define ADT_initialize_iter(INDEX, CONS, PARAM) \
metamacro_if_eq(0, INDEX) \
( \
/* initialize the tag when the structure is created, because it cannot change later */ \
struct ADT_CURRENT_T s = { .tag = CONS } \
) \
(ADT_initialize_memcpy(ADT_CURRENT_CONS_PAYLOAD_T(CONS, metamacro_dec(INDEX)), s, metamacro_concat(v, metamacro_dec(INDEX)))) \
;
#define ADT_initialize_memcpy(UNION_NAME, ADT, ARG) \
memcpy(&ADT.UNION_NAME, &ARG.UNION_NAME, sizeof(ADT.UNION_NAME));
/*
* The macros below declare and initialize the function pointers used to
* psuedo-namespace the data constructors.
*
* As with ADT_constructor(), the first variadic argument here is always the
* constructor name. The arguments following are the parameters (as given by the
* user).
*
* The result looks something like this (using the Color example from above):
const struct {
ColorT (*Red)();
ColorT (*Green)();
ColorT (*Blue)();
ColorT (*Gray)(double v0);
ColorT (*Other)(double v0, double v1, double v2);
} Color = {
.Red = &Red_init_,
.Green = &Green_init_,
.Blue = &Blue_init_,
.Gray = &Gray_init_,
.Other = &Other_init_,
};
* Thanks goes out to Jon Sterling and his CADT project for this idea:
* http://www.jonmsterling.com/CADT/
*/
#define ADT_fptrs_constructor(...) \
struct ADT_CURRENT_T \
\
/* the function pointer name (matches that of the constructor) */ \
(*metamacro_head(__VA_ARGS__)) \
\
/* the parameter list for the function -- we just reuse ADT_prototype_iter() for this */ \
(metamacro_foreach_cxt_recursive(ADT_prototype_iter,, metamacro_head(__VA_ARGS__), __VA_ARGS__));
#define ADT_fptrinit_constructor(...) \
/* this uses designated initializer syntax to fill in the function pointers
* with the actual addresses of the inline functions created by ADT_constructor() */ \
.metamacro_head(__VA_ARGS__) = &metamacro_concat(metamacro_head(__VA_ARGS__), _init_),
/*
* The following macros are used to generate the code for the
* NSStringFromName() function. They essentially do something similar to
* an Objective-C implementation of -description.
*
* As with ADT_constructor(), the first variadic argument here is always the
* constructor name. The arguments following are the parameters (as given by the
* user).
*
* As with ADT_prototype*(), our parameter numbers need to be shifted down to
* correspond to the values in the structure.
*/
#define ADT_tostring_constructor(...) \
/* try to match each constructor against the value's tag */ \
case metamacro_head(__VA_ARGS__): { \
/* now create a description from the constructor name and any parameters */ \
metamacro_foreach_cxt_recursive(ADT_tostring_iter,, metamacro_head(__VA_ARGS__), __VA_ARGS__) \
break; \
}
#define ADT_tostring_iter(INDEX, CONS, PARAM) \
/* dispatches to one of the case macros below, based on the INDEX */ \
metamacro_if_eq(0, INDEX) \
(ADT_tostring_case0(CONS, PARAM)) \
(metamacro_if_eq_recursive(1, INDEX) \
(ADT_tostring_case1(CONS, PARAM)) \
(ADT_tostring_defaultcase(INDEX, CONS, PARAM)) \
)
#define ADT_tostring_case0(CONS, PARAM) \
/* this is the first (and possibly) only part of the description: the name
* of the data constructor */ \
[str appendString:@ # CONS];
#define ADT_tostring_case1(CONS, PARAM) \
/* we know now that we have arguments, so we insert a brace (and flip the
* corresponding flag), then begin by describing the first argument */ \
[str appendFormat:@" { %@", ADT_CURRENT_PARAMETER_DESCRIPTION(CONS, PARAM, s, 0)]; \
addedBraces = YES;
#define ADT_tostring_defaultcase(INDEX, CONS, PARAM) \
[str appendFormat: @", %@", ADT_CURRENT_PARAMETER_DESCRIPTION(CONS, PARAM, s, metamacro_dec(INDEX))];
/*
* The following macros are used to generate the code for the
* NameEqualToName() function. They essentially do something similar to
* an Objective-C implementation of -isEqual:.
*
* As with ADT_constructor(), the first variadic argument here is always the
* constructor name. The arguments following are the parameters (as given by the
* user).
*
* As with ADT_prototype*(), our parameter numbers need to be shifted down to
* correspond to the values in the structure.
*/
#define ADT_equalto_constructor(...) \
/* try to match each constructor against the value's tag */ \
case metamacro_head(__VA_ARGS__): { \
metamacro_if_eq(1, metamacro_argcount(...)) \
(/* no parameters, so we're equal merely if the tags are the same */) \
(metamacro_foreach_cxt_recursive(ADT_equalto_iter,, __VA_ARGS__)) \
\
break; \
}
#define ADT_equalto_iter(INDEX, CONS, PARAM) \
{ \
const char *paramEncoding = ext_trimADTJunkFromTypeEncoding(@encode(ADT_CURRENT_CONS_ALIAS_T(CONS, INDEX)); \
\
/* use isEqual: for objects (including class objects) */ \
if (*paramEncoding == *@encode(id) || *paramEncoding == *@encode(Class)) { \
id aObj = *(__unsafe_unretained id *)&a.ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX); \
id bObj = *(__unsafe_unretained id *)&b.ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX); \
\
if (!aObj) { \
if (bObj) { \
return NO; \
} \
} else if (![aObj isEqual:bObj]) { \
return NO; \
} \
} else { \
/* prefer == to memcmp() here, since ADT values may have garbage padding
* bits that would cause false negatives with the latter */ \
if (a.ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX) != b.ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX)) \
return NO; \
} \
}
/*
* The structure tag for the ADT currently being defined. This takes advantage
* of the fact that the main ADT() is considered to exist on one line, even if
* it spans multiple lines in an editor.
*
* This does prevent multiple ADT() definitions from being provided on the same
* line, however.
*/
#define ADT_CURRENT_T \
metamacro_concat(_ADT_, __LINE__)
/*
* This generates an alias name that can be used to refer to the type of
* parameter INDEX of constructor CONS (as a transparent union).
*
* The actual typedef, which is then referred to later, is generated with
* ADT_typedef_iter().
*
* Because the type by this name is a transparent union, it can be used as
* a function or method argument and appear to be the actual parameter type
* given by the user.
*/
#define ADT_CURRENT_CONS_ALIAS_T(CONS, INDEX) \
metamacro_concat(metamacro_concat(ADT_CURRENT_T, _), metamacro_concat(CONS ## _alias, INDEX))
/**
* Creates an anonymous union that contains the user's parameter declaration as
* a member, as well as an (other) internal union that is used to access the
* data without needing to know the name given by the user.
*
* See ADT_payload_constructor() for more information.
*/
#define ADT_CURRENT_CONS_UNION_T(CONS, INDEX, PARAM) \
/* create unions upon unions (oh my!) so that we can treat the user's
* parameter as a typedef, without needing to split apart the type and name
* inside it (which is probably not possible) */ \
union { \
union { \
PARAM; \
} ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX); \
\
PARAM; \
}
#define ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX) \
metamacro_concat(CONS ## _payload_, INDEX)
/*
* Expands to an NSString with a human-readable description of the current value
* at INDEX, for constructor CONS, in the internal value structure of ADT. PARAM
* is the parameter declaration originally given by the user.
*/
#define ADT_CURRENT_PARAMETER_DESCRIPTION(CONS, PARAM, ADT, INDEX) \
[NSString stringWithFormat:@"%@ = %@", \
/* this is the only place where we actually parse a parameter declaration */ \
/* we do it here to remove the type from the description, keeping only the name */ \
ext_parameterNameFromDeclaration(@ # PARAM), \
/* convert the parameter type into an Objective-C type encoding, which,
* along with a pointer to the data, can be used to generate
* a human-readable description of the actual value */ \
ext_stringFromTypedBytes(&(ADT).ADT_CURRENT_CONS_PAYLOAD_T(CONS, INDEX), \
ext_trimADTJunkFromTypeEncoding(@encode(ADT_CURRENT_CONS_ALIAS_T(CONS, INDEX)))) \
]
const char *ext_trimADTJunkFromTypeEncoding (const char *encoding);
NSString *ext_parameterNameFromDeclaration (NSString *declaration);
| {
"pile_set_name": "Github"
} |
;; copyright 2003-2005 stefan kersten <[email protected]>
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
;; USA
(eval-when-compile
(require 'cl)
(require 'sclang-util)
(require 'compile)
)
;; =====================================================================
;; post buffer access
;; =====================================================================
;; FIXME: everything will fail when renaming the post buffer!
(defconst sclang-post-buffer (sclang-make-buffer-name "PostBuffer")
"Name of the SuperCollider process output buffer.")
(defconst sclang-bullet-latin-1 (string-to-char (decode-coding-string "\xa5" 'utf-8))
"Character for highlighting errors (latin-1).")
(defconst sclang-bullet-utf-8 (string-to-char (decode-coding-string "\xe2\x80\xa2" 'utf-8))
"Character for highlighting errors (utf-8).")
(defconst sclang-parse-error-regexp
"^\\(WARNING\\|ERROR\\): .*\n[\t ]*in file '\\([^']\+\\)'\n[\t ]*line \\([0-9]\+\\) char \\([0-9]\+\\)"
"Regular expression matching parse errors during library compilation.")
(defcustom sclang-max-post-buffer-size 0
"*Maximum number of characters to insert in post buffer.
Zero means no limit."
:group 'sclang-interface
:version "21.3"
:type 'integer)
(defcustom sclang-auto-scroll-post-buffer nil
"*Automatically scroll post buffer on output regardless of point position.
Default behavior is to only scroll when point is not at end of buffer."
:group 'sclang-interface
:version "21.3"
:type 'boolean)
(defun sclang-get-post-buffer ()
(get-buffer-create sclang-post-buffer))
(defmacro with-sclang-post-buffer (&rest body)
`(with-current-buffer (sclang-get-post-buffer)
,@body))
;; (defun sclang-post-string (string)
;; (with-sclang-post-buffer
;; (let ((eobp (mapcar (lambda (w)
;; (cons w (= (window-point w) (point-max))))
;; (get-buffer-window-list (current-buffer) nil t))))
;; (save-excursion
;; ;; insert STRING into process buffer
;; (goto-char (point-max))
;; (insert string))
;; (dolist (assoc eobp)
;; (when (cdr assoc)
;; (save-selected-window
;; (let ((window (car assoc)))
;; (select-window window)
;; (set-window-point window (point-max))
;; (recenter -1))))))))
;; (defun sclang-post-string (string &optional proc)
;; (let* ((buffer (process-buffer proc))
;; (window (display-buffer buffer)))
;; (with-current-buffer buffer
;; (let ((moving (= (point) (process-mark proc))))
;; (save-excursion
;; ;; Insert the text, advancing the process marker.
;; (goto-char (process-mark proc))
;; (insert string)
;; (set-marker (process-mark proc) (point)))
;; (when moving
;; (goto-char (process-mark proc))
;; (set-window-point window (process-mark proc)))))))
(defun sclang-show-post-buffer (&optional eob-p)
"Show SuperCollider process buffer.
If EOB-P is non-nil, positions cursor at end of buffer."
(interactive "P")
(with-sclang-post-buffer
(let ((window (display-buffer (current-buffer))))
(when eob-p
(goto-char (point-max))
(save-selected-window
(set-window-point window (point-max)))))))
(defun sclang-clear-post-buffer ()
"Clear the output buffer."
(interactive)
(with-sclang-post-buffer (erase-buffer)))
(defun sclang-init-post-buffer ()
"Initialize post buffer."
(get-buffer-create sclang-post-buffer)
(with-sclang-post-buffer
;; setup sclang mode
(sclang-mode)
(set (make-local-variable 'font-lock-fontify-region-function)
(lambda (&rest args)))
;; setup compilation mode
(compilation-minor-mode)
(set (make-variable-buffer-local 'compilation-error-screen-columns) nil)
(set (make-variable-buffer-local 'compilation-error-regexp-alist)
(cons (list sclang-parse-error-regexp 2 3 4) compilation-error-regexp-alist))
(set (make-variable-buffer-local 'compilation-parse-errors-function)
(lambda (limit-search find-at-least)
(compilation-parse-errors limit-search find-at-least)))
(set (make-variable-buffer-local 'compilation-parse-errors-filename-function)
(lambda (file-name)
file-name)))
(sclang-clear-post-buffer)
(sclang-show-post-buffer))
;; =====================================================================
;; interpreter interface
;; =====================================================================
(defconst sclang-process "SCLang"
"Name of the SuperCollider interpreter subprocess.")
(defcustom sclang-program "sclang"
"*Name of the SuperCollider interpreter program."
:group 'sclang-programs
:version "21.3"
:type 'string)
(defcustom sclang-runtime-directory ""
"*Path to the SuperCollider runtime directory."
:group 'sclang-options
:version "21.3"
:type 'directory
:options '(:must-match))
(defcustom sclang-library-configuration-file ""
"*Path of the library configuration file."
:group 'sclang-options
:version "21.3"
:type 'file
:options '(:must-match))
(defcustom sclang-heap-size ""
"*Initial heap size."
:group 'sclang-options
:version "21.3"
:type 'string)
(defcustom sclang-heap-growth ""
"*Heap growth."
:group 'sclang-options
:version "21.3"
:type 'string)
(defcustom sclang-udp-port -1
"*UDP listening port."
:group 'sclang-options
:version "21.3"
:type 'integer)
(defcustom sclang-main-run nil
"*Call Main.run on startup."
:group 'sclang-options
:version "21.3"
:type 'boolean)
(defcustom sclang-main-stop nil
"*Call Main.stop on shutdown."
:group 'sclang-options
:version "21.3"
:type 'boolean)
;; =====================================================================
;; helper functions
;; =====================================================================
(defun sclang-get-process ()
(get-process sclang-process))
;; =====================================================================
;; library startup/shutdown
;; =====================================================================
(defvar sclang-library-initialized-p nil)
(defcustom sclang-library-startup-hook nil
"*Hook run after initialization of the SCLang process."
:group 'sclang-interface
:type 'hook)
(defcustom sclang-library-shutdown-hook nil
"*Hook run before deletion of the SCLang process."
:group 'sclang-interface
:type 'hook)
;; library initialization works like this:
;;
;; * emacs starts sclang with SCLANG_COMMAND_FIFO set in the environment
;; * sclang opens fifo for communication with emacs during class tree
;; initialization
;; * sclang sends '_init' command
;; * '_init' command handler calls sclang-on-library-startup to complete
;; initialization
(defun sclang-library-initialized-p ()
(and (sclang-get-process)
sclang-library-initialized-p))
(defun sclang-on-library-startup ()
(sclang-message "Initializing library...")
(setq sclang-library-initialized-p t)
(run-hooks 'sclang-library-startup-hook)
(sclang-message "Initializing library...done"))
(defun sclang-on-library-shutdown ()
(when sclang-library-initialized-p
(run-hooks 'sclang-library-shutdown-hook)
(setq sclang-library-initialized-p nil)
(sclang-message "Shutting down library...")))
;; =====================================================================
;; process hooks
;; =====================================================================
(defun sclang-process-sentinel (proc msg)
(with-sclang-post-buffer
(goto-char (point-max))
(insert
(if (and (bolp) (eolp)) "\n" "\n\n")
(format "*** %s %s ***" proc (substring msg 0 -1))
"\n\n"))
(when (memq (process-status proc) '(exit signal))
(sclang-on-library-shutdown)
(sclang-stop-command-process)))
(defun sclang-process-filter (process string)
(let ((buffer (process-buffer process)))
(with-current-buffer buffer
(when (and (> sclang-max-post-buffer-size 0)
(> (buffer-size) sclang-max-post-buffer-size))
(erase-buffer))
(let ((move-point (or sclang-auto-scroll-post-buffer
(= (point) (process-mark process)))))
(save-excursion
;; replace mac-roman bullet with unicode character
(subst-char-in-string sclang-bullet-latin-1 sclang-bullet-utf-8 string t)
;; insert the text, advancing the process marker.
(goto-char (process-mark process))
(insert string)
(set-marker (process-mark process) (point)))
(when move-point
(goto-char (process-mark process))
(walk-windows
(lambda (window)
(when (eq buffer (window-buffer window))
(set-window-point window (process-mark process))))
nil t))))))
;; =====================================================================
;; process startup/shutdown
;; =====================================================================
(defun sclang-memory-option-p (string)
(let ((case-fold-search nil))
(string-match "^[1-9][0-9]*[km]?$" string)))
(defun sclang-port-option-p (number)
(and (>= number 0) (<= number #XFFFF)))
(defun sclang-make-options ()
(let ((default-directory "")
(res ()))
(flet ((append-option
(option &optional value)
(setq res (append res (list option) (and value (list value))))))
(if (file-directory-p sclang-runtime-directory)
(append-option "-d" (expand-file-name sclang-runtime-directory)))
(if (file-exists-p sclang-library-configuration-file)
(append-option "-l" (expand-file-name sclang-library-configuration-file)))
(if (sclang-memory-option-p sclang-heap-size)
(append-option "-m" sclang-heap-size))
(if (sclang-memory-option-p sclang-heap-growth)
(append-option "-g" sclang-heap-growth))
(if (sclang-port-option-p sclang-udp-port)
(append-option "-u" (number-to-string sclang-udp-port)))
(if sclang-main-run
(append-option "-r"))
(if sclang-main-stop
(append-option "-s"))
(append-option "-iscel")
res)))
(defun sclang-start ()
"Start SuperCollider process."
(interactive)
(sclang-stop)
(sclang-on-library-shutdown)
(sit-for 1)
(sclang-init-post-buffer)
(sclang-start-command-process)
(let ((process-connection-type nil))
(let ((proc (apply 'start-process
sclang-process sclang-post-buffer
sclang-program (sclang-make-options))))
(set-process-sentinel proc 'sclang-process-sentinel)
(set-process-filter proc 'sclang-process-filter)
(set-process-coding-system proc 'mule-utf-8 'mule-utf-8)
(set-process-query-on-exit-flag proc nil)
proc)))
(defun sclang-kill ()
"Kill SuperCollider process."
(interactive)
(when (sclang-get-process)
(kill-process sclang-process)
(delete-process sclang-process)))
(defun sclang-stop ()
"Stop SuperCollider process."
(interactive)
(when (sclang-get-process)
(process-send-eof sclang-process)
(let ((tries 4)
(i 0))
(while (and (sclang-get-process)
(< i tries))
(incf i)
(sit-for 0.5))))
(sclang-kill)
(sclang-stop-command-process))
(defun sclang-recompile ()
"Recompile class library."
(interactive)
(when (sclang-get-process)
(process-send-string sclang-process "\x18")
))
;; =====================================================================
;; command process
;; =====================================================================
(defcustom sclang-mkfifo-program "mkfifo"
"*Name of the \"mkfifo\" program.
Change this if \"mkfifo\" has a non-standard name or location."
:group 'sclang-programs
:type 'string)
(defcustom sclang-cat-program "cat"
"*Name of the \"cat\" program.
Change this if \"cat\" has a non-standard name or location."
:group 'sclang-programs
:type 'string)
(defconst sclang-command-process "SCLang Command"
"Subprocess for receiving command results from sclang.")
(defconst sclang-cmd-helper-proc "SCLang Command Helper"
"Dummy subprocess that will keep the command fifo open for writing
so reading does not fail automatically when sclang closes its own
writing end of the fifo")
(defvar sclang-command-fifo nil
"FIFO for communicating with the subprocess.")
(defun sclang-delete-command-fifo ()
(and sclang-command-fifo
(file-exists-p sclang-command-fifo)
(delete-file sclang-command-fifo)))
(defun sclang-release-command-fifo ()
(sclang-delete-command-fifo)
(setq sclang-command-fifo nil))
(defun sclang-create-command-fifo ()
(setq sclang-command-fifo (make-temp-name
(expand-file-name
"sclang-command-fifo." temporary-file-directory)))
(sclang-delete-command-fifo)
(let ((res (call-process sclang-mkfifo-program
nil t t
sclang-command-fifo)))
(unless (eq 0 res)
(message "SCLang: Couldn't create command fifo")
(setq sclang-command-fifo nil))))
(defun sclang-start-command-process ()
(sclang-create-command-fifo)
(when sclang-command-fifo
;; start the dummy process to keep the fifo open
(let ((process-connection-type nil))
(let ((proc (start-process-shell-command
sclang-cmd-helper-proc nil
(concat sclang-cat-program " > " sclang-command-fifo))))
(set-process-query-on-exit-flag proc nil)))
;; sclang gets the fifo path via the environment
(setenv "SCLANG_COMMAND_FIFO" sclang-command-fifo)
(let ((process-connection-type nil))
(let ((proc (start-process
sclang-command-process nil
sclang-cat-program sclang-command-fifo)))
(set-process-filter proc 'sclang-command-process-filter)
;; this is important. use a unibyte stream without eol
;; conversion for communication.
(set-process-coding-system proc 'no-conversion 'no-conversion)
(set-process-query-on-exit-flag proc nil)))
(unless (get-process sclang-command-process)
(message "SCLang: Couldn't start command process"))))
(defun sclang-stop-command-process ()
(when (get-process sclang-cmd-helper-proc)
(kill-process sclang-cmd-helper-proc)
(delete-process sclang-cmd-helper-proc))
;; the real command process should now quit automatically,
;; since there is no more writers to the command fifo
(sclang-release-command-fifo))
(defvar sclang-command-process-previous nil
"Unprocessed command process output.")
(defun sclang-command-process-filter (proc string)
(when sclang-command-process-previous
(setq string (concat sclang-command-process-previous string)))
(let (end)
(while (and (> (length string) 3)
(>= (length string)
(setq end (+ 4 (sclang-string-to-int32 string)))))
(sclang-handle-command-result (car (read-from-string string 4 end)))
(setq string (substring string end))))
(setq sclang-command-process-previous string))
;; =====================================================================
;; command interface
;; =====================================================================
;; symbol property: sclang-command-handler
(defun sclang-set-command-handler (symbol function)
(put symbol 'sclang-command-handler function))
(defun sclang-perform-command (symbol &rest args)
(sclang-eval-string (sclang-format
"Emacs.lispPerformCommand(%o, %o, true)"
symbol args)))
(defun sclang-perform-command-no-result (symbol &rest args)
(sclang-eval-string (sclang-format
"Emacs.lispPerformCommand(%o, %o, false)"
symbol args)))
(defun sclang-default-command-handler (fun arg)
"Default command handler.
Displays short message on error."
(condition-case nil
(funcall fun arg)
(error (sclang-message "Error in command handler") nil)))
(defun sclang-debug-command-handler (fun arg)
"Debugging command handler.
Enters debugger on error."
(let ((debug-on-error t)
(debug-on-signal t))
(funcall fun arg)))
(defvar sclang-command-handler 'sclang-default-command-handler
"Function called when handling command result.")
(defun sclang-toggle-debug-command-handler (&optional arg)
"Toggle debugging of command handler.
With arg, activate debugging iff arg is positive."
(interactive "P")
(setq sclang-command-handler
(if (or (and arg (> arg 0))
(eq sclang-command-handler 'sclang-debug-command-handler))
'sclang-default-command-handler
'sclang-default-command-handler))
(sclang-message "Command handler debugging %s."
(if (eq sclang-command-handler 'sclang-debug-command-handler)
"enabled"
"disabled")))
(defun sclang-handle-command-result (list)
(condition-case nil
(let ((fun (get (nth 0 list) 'sclang-command-handler))
(arg (nth 1 list))
(id (nth 2 list)))
(when (functionp fun)
(let ((res (funcall sclang-command-handler fun arg)))
(when id
(sclang-eval-string
(sclang-format "Emacs.lispHandleCommandResult(%o, %o)" id res))))))
(error nil)))
;; =====================================================================
;; code evaluation
;; =====================================================================
(defconst sclang-token-interpret-cmd-line (char-to-string #X1b))
(defconst sclang-token-interpret-print-cmd-line (char-to-string #X0c))
(defcustom sclang-eval-line-forward t
"*If non-nil `sclang-eval-line' advances to the next line."
:group 'sclang-interface
:type 'boolean)
(defun sclang-send-string (token string &optional force)
(let ((proc (sclang-get-process)))
(when (and proc (or (sclang-library-initialized-p) force))
(process-send-string proc (concat string token))
string)))
(defun sclang-eval-string (string &optional print-p)
"Send STRING to the sclang process for evaluation and print the result
if PRINT-P is non-nil. Return STRING if successful, otherwise nil."
(sclang-send-string
(if print-p sclang-token-interpret-print-cmd-line sclang-token-interpret-cmd-line)
string))
(defun sclang-eval-expression (string &optional silent-p)
"Execute STRING as SuperCollider code."
(interactive "sEval: \nP")
(sclang-eval-string string (not silent-p)))
(defun sclang-eval-line (&optional silent-p)
"Execute the current line as SuperCollider code."
(interactive "P")
(let ((string (sclang-line-at-point)))
(when string
(sclang-eval-string string (not silent-p)))
(and sclang-eval-line-forward
(/= (line-end-position) (point-max))
(forward-line 1))
string))
(defun sclang-eval-region (&optional silent-p)
"Execute the region as SuperCollider code."
(interactive "P")
(sclang-eval-string
(buffer-substring-no-properties (region-beginning) (region-end))
(not silent-p)))
(defun sclang-eval-region-or-line (&optional silent-p)
(interactive "P")
(if (and transient-mark-mode mark-active)
(sclang-eval-region silent-p)
(sclang-eval-line silent-p)))
(defun sclang-eval-defun (&optional silent-p)
(interactive "P")
(let ((string (sclang-defun-at-point)))
(when (and string (string-match "^(" string))
(sclang-eval-string string (not silent-p))
string)))
(defun sclang-eval-document (&optional silent-p)
"Execute the whole document as SuperCollider code."
(interactive "P")
(save-excursion
(mark-whole-buffer)
(sclang-eval-string
(buffer-substring-no-properties (region-beginning) (region-end))
(not silent-p))))
(defvar sclang-eval-results nil
"Save results of sync SCLang evaluation.")
(sclang-set-command-handler
'evalSCLang
(lambda (arg) (push arg sclang-eval-results)))
(defun sclang-eval-sync (string)
"Eval STRING in sclang and return result as a lisp value."
(let ((proc (get-process sclang-command-process)))
(if (and (processp proc) (eq (process-status proc) 'run))
(let ((time (current-time)) (tick 10000) elt)
(sclang-perform-command 'evalSCLang string time)
(while (and (> (decf tick) 0)
(not (setq elt (find time sclang-eval-results
:key #'car :test #'equal))))
(accept-process-output proc 0 100))
(if elt
(prog1 (if (eq (nth 1 elt) 'ok)
(nth 2 elt)
(setq sclang-eval-results (delq elt sclang-eval-results))
(signal 'sclang-error (nth 2 elt)))
(setq sclang-eval-results (delq elt sclang-eval-results)))
(error "SCLang sync eval timeout")))
(error "SCLang Command process not running"))))
;; =====================================================================
;; searching
;; =====================================================================
;; (defun sclang-help-file-paths ()
;; "Return a list of help file paths."
;; (defun sclang-grep-help-files ()
;; (interactive)
;; (let ((sclang-grep-prompt "Search help files: ")
;; (sclang-grep-files (mapcar 'cdr sclang-help-topic-alist)))
;; (call-interactively 'sclang-grep-files)))
;; (defvar sclang-grep-history nil)
;; (defcustom sclang-grep-case-fold-search t
;; "*Non-nil if sclang-grep-files should ignore case."
;; :group 'sclang-interface
;; :version "21.4"
;; :type 'boolean)
;; (defvar sclang-grep-files nil)
;; (defvar sclang-grep-prompt "Grep: ")
;; (defun sclang-grep-files (regexp)
;; (interactive
;; (let ((grep-default (or (when current-prefix-arg (sclang-symbol-at-point))
;; (car sclang-grep-history))))
;; (list (read-from-minibuffer sclang-grep-prompt
;; grep-default
;; nil nil 'sclang-grep-history))))
;; (grep-compute-defaults)
;; (grep (concat grep-program
;; " -n"
;; (and sclang-grep-case-fold-search " -i")
;; " -e" regexp
;; " " (mapconcat 'shell-quote-argument sclang-grep-files " "))))
;; =====================================================================
;; workspace
;; =====================================================================
(defcustom sclang-show-workspace-on-startup t
"*If non-nil show the workspace buffer on library startup."
:group 'sclang-interface
:type 'boolean)
(defconst sclang-workspace-buffer (sclang-make-buffer-name "Workspace"))
(defun sclang-fill-workspace-mode-map (map)
(define-key map "\C-c}" 'bury-buffer))
(defun sclang-switch-to-workspace ()
(interactive)
(let ((buffer (get-buffer sclang-workspace-buffer)))
(unless buffer
(setq buffer (get-buffer-create sclang-workspace-buffer))
(with-current-buffer buffer
(sclang-mode)
(let ((map (make-sparse-keymap)))
(set-keymap-parent map sclang-mode-map)
(sclang-fill-workspace-mode-map map)
(use-local-map map))
(let ((line (concat "// " (make-string 69 ?=) "\n")))
(insert line)
(insert "// SuperCollider Workspace\n")
(insert line)
;; (insert "// using HTML Help: C-c C-h as usual, then switch to w3m buffer\n")
;; (insert "// and do M-x sclang-minor-mode in order te enable sclang code execution\n")
;; (insert line)
(insert "\n"))
(set-buffer-modified-p nil)
;; cwd to sclang-runtime-directory
(if (and sclang-runtime-directory
(file-directory-p sclang-runtime-directory))
(setq default-directory sclang-runtime-directory))))
(switch-to-buffer buffer)))
(add-hook 'sclang-library-startup-hook
(lambda () (and sclang-show-workspace-on-startup
(sclang-switch-to-workspace))))
;; =====================================================================
;; language control
;; =====================================================================
(defun sclang-main-run ()
(interactive)
(sclang-eval-string "thisProcess.run"))
(defun sclang-main-stop ()
(interactive)
(sclang-eval-string "thisProcess.stop"))
;; =====================================================================
;; default command handlers
;; =====================================================================
(sclang-set-command-handler '_init (lambda (arg) (sclang-on-library-startup)))
(sclang-set-command-handler
'_eval
(lambda (expr)
(when (stringp expr)
(eval (read expr)))))
;; =====================================================================
;; module setup
;; =====================================================================
;; shutdown process cleanly
(add-hook 'kill-emacs-hook (lambda () (sclang-stop)))
;; add command line switches
(add-to-list 'command-switch-alist
(cons "-sclang"
(lambda (switch)
(sclang-start))))
(add-to-list 'command-switch-alist
(cons "-sclang-debug"
(lambda (switch)
(sclang-toggle-debug-command-handler 1))))
(add-to-list 'command-switch-alist
(cons "-scmail"
(lambda (switch)
(sclang-start)
(when command-line-args-left
(let ((file (pop command-line-args-left)))
(with-current-buffer (get-buffer-create sclang-workspace-buffer)
(and (file-exists-p file) (insert-file-contents file))
(set-buffer-modified-p nil)
(sclang-mode)
(switch-to-buffer (current-buffer))))))))
(provide 'sclang-interp)
;; EOF
| {
"pile_set_name": "Github"
} |
//
// detail/posix_thread.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_POSIX_THREAD_HPP
#define ASIO_DETAIL_POSIX_THREAD_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#if defined(ASIO_HAS_PTHREADS)
#include <pthread.h>
#include "asio/detail/noncopyable.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
extern "C"
{
ASIO_DECL void* asio_detail_posix_thread_function(void* arg);
}
class posix_thread
: private noncopyable
{
public:
// Constructor.
template <typename Function>
posix_thread(Function f, unsigned int = 0)
: joined_(false)
{
start_thread(new func<Function>(f));
}
// Destructor.
ASIO_DECL ~posix_thread();
// Wait for the thread to exit.
ASIO_DECL void join();
private:
friend void* asio_detail_posix_thread_function(void* arg);
class func_base
{
public:
virtual ~func_base() {}
virtual void run() = 0;
};
struct auto_func_base_ptr
{
func_base* ptr;
~auto_func_base_ptr() { delete ptr; }
};
template <typename Function>
class func
: public func_base
{
public:
func(Function f)
: f_(f)
{
}
virtual void run()
{
f_();
}
private:
Function f_;
};
ASIO_DECL void start_thread(func_base* arg);
::pthread_t thread_;
bool joined_;
};
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#if defined(ASIO_HEADER_ONLY)
# include "asio/detail/impl/posix_thread.ipp"
#endif // defined(ASIO_HEADER_ONLY)
#endif // defined(ASIO_HAS_PTHREADS)
#endif // ASIO_DETAIL_POSIX_THREAD_HPP
| {
"pile_set_name": "Github"
} |
/*----------------------------------------------------------------------------
* RL-ARM - RTX
*----------------------------------------------------------------------------
* Name: RT_HAL_CM.H
* Purpose: Hardware Abstraction Layer for Cortex-M definitions
* Rev.: V4.60
*----------------------------------------------------------------------------
*
* Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
*---------------------------------------------------------------------------*/
/* Definitions */
#define INITIAL_xPSR 0x01000000
#define DEMCR_TRCENA 0x01000000
#define ITM_ITMENA 0x00000001
#define MAGIC_WORD 0xE25A2EA5
#if defined (__CC_ARM) /* ARM Compiler */
#if ((__TARGET_ARCH_7_M || __TARGET_ARCH_7E_M) && !NO_EXCLUSIVE_ACCESS)
#define __USE_EXCLUSIVE_ACCESS
#else
#undef __USE_EXCLUSIVE_ACCESS
#endif
#elif defined (__GNUC__) /* GNU Compiler */
#undef __USE_EXCLUSIVE_ACCESS
#if defined (__CORTEX_M0) || defined (__CORTEX_M0PLUS)
#define __TARGET_ARCH_6S_M 1
#else
#define __TARGET_ARCH_6S_M 0
#endif
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#define __TARGET_FPU_VFP 1
#else
#define __TARGET_FPU_VFP 0
#endif
#define __inline inline
#define __weak __attribute__((weak))
#ifndef __CMSIS_GENERIC
__attribute__((always_inline)) static inline void __enable_irq(void)
{
__asm volatile ("cpsie i");
}
__attribute__((always_inline)) static inline U32 __disable_irq(void)
{
U32 result;
__asm volatile ("mrs %0, primask" : "=r" (result));
__asm volatile ("cpsid i");
return(result & 1);
}
#endif
__attribute__(( always_inline)) static inline U8 __clz(U32 value)
{
U8 result;
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
return(result);
}
#elif defined (__ICCARM__) /* IAR Compiler */
#undef __USE_EXCLUSIVE_ACCESS
#if (__CORE__ == __ARM6M__)
#define __TARGET_ARCH_6S_M 1
#else
#define __TARGET_ARCH_6S_M 0
#endif
#if defined __ARMVFP__
#define __TARGET_FPU_VFP 1
#else
#define __TARGET_FPU_VFP 0
#endif
#define __inline inline
#ifndef __CMSIS_GENERIC
static inline void __enable_irq(void)
{
__asm volatile ("cpsie i");
}
static inline U32 __disable_irq(void)
{
U32 result;
__asm volatile ("mrs %0, primask" : "=r" (result));
__asm volatile ("cpsid i");
return(result & 1);
}
#endif
static inline U8 __clz(U32 value)
{
U8 result;
__asm volatile ("clz %0, %1" : "=r" (result) : "r" (value));
return(result);
}
#endif
/* NVIC registers */
#define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010))
#define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014))
#define NVIC_ST_CURRENT (*((volatile U32 *)0xE000E018))
#define NVIC_ISER ((volatile U32 *)0xE000E100)
#define NVIC_ICER ((volatile U32 *)0xE000E180)
#if (__TARGET_ARCH_6S_M)
#define NVIC_IP ((volatile U32 *)0xE000E400)
#else
#define NVIC_IP ((volatile U8 *)0xE000E400)
#endif
#define NVIC_INT_CTRL (*((volatile U32 *)0xE000ED04))
#define NVIC_AIR_CTRL (*((volatile U32 *)0xE000ED0C))
#define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C))
#define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20))
#define OS_PEND_IRQ() NVIC_INT_CTRL = (1<<28)
#define OS_PENDING ((NVIC_INT_CTRL >> 26) & (1<<2 | 1))
#define OS_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_PENDING) << 25
#define OS_PEND(fl,p) NVIC_INT_CTRL = (fl | p<<2) << 26
#define OS_LOCK() NVIC_ST_CTRL = 0x0005
#define OS_UNLOCK() NVIC_ST_CTRL = 0x0007
#define OS_X_PENDING ((NVIC_INT_CTRL >> 28) & 1)
#define OS_X_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_X_PENDING) << 27
#define OS_X_PEND(fl,p) NVIC_INT_CTRL = (fl | p) << 28
#if (__TARGET_ARCH_6S_M)
#define OS_X_INIT(n) NVIC_IP[n>>2] |= 0xFF << (8*(n & 0x03)); \
NVIC_ISER[n>>5] = 1 << (n & 0x1F)
#else
#define OS_X_INIT(n) NVIC_IP[n] = 0xFF; \
NVIC_ISER[n>>5] = 1 << (n & 0x1F)
#endif
#define OS_X_LOCK(n) NVIC_ICER[n>>5] = 1 << (n & 0x1F)
#define OS_X_UNLOCK(n) NVIC_ISER[n>>5] = 1 << (n & 0x1F)
/* Core Debug registers */
#define DEMCR (*((volatile U32 *)0xE000EDFC))
/* ITM registers */
#define ITM_CONTROL (*((volatile U32 *)0xE0000E80))
#define ITM_ENABLE (*((volatile U32 *)0xE0000E00))
#define ITM_PORT30_U32 (*((volatile U32 *)0xE0000078))
#define ITM_PORT31_U32 (*((volatile U32 *)0xE000007C))
#define ITM_PORT31_U16 (*((volatile U16 *)0xE000007C))
#define ITM_PORT31_U8 (*((volatile U8 *)0xE000007C))
/* Variables */
extern BIT dbg_msg;
/* Functions */
#ifdef __USE_EXCLUSIVE_ACCESS
#define rt_inc(p) while(__strex((__ldrex(p)+1),p))
#define rt_dec(p) while(__strex((__ldrex(p)-1),p))
#else
#define rt_inc(p) __disable_irq();(*p)++;__enable_irq();
#define rt_dec(p) __disable_irq();(*p)--;__enable_irq();
#endif
__inline static U32 rt_inc_qi (U32 size, U8 *count, U8 *first) {
U32 cnt,c2;
#ifdef __USE_EXCLUSIVE_ACCESS
do {
if ((cnt = __ldrex(count)) == size) {
__clrex();
return (cnt); }
} while (__strex(cnt+1, count));
do {
c2 = (cnt = __ldrex(first)) + 1;
if (c2 == size) c2 = 0;
} while (__strex(c2, first));
#else
__disable_irq();
if ((cnt = *count) < size) {
*count = cnt+1;
c2 = (cnt = *first) + 1;
if (c2 == size) c2 = 0;
*first = c2;
}
__enable_irq ();
#endif
return (cnt);
}
__inline static void rt_systick_init (void) {
NVIC_ST_RELOAD = os_trv;
NVIC_ST_CURRENT = 0;
NVIC_ST_CTRL = 0x0007;
NVIC_SYS_PRI3 |= 0xFF000000;
}
__inline static void rt_svc_init (void) {
#if !(__TARGET_ARCH_6S_M)
int sh,prigroup;
#endif
NVIC_SYS_PRI3 |= 0x00FF0000;
#if (__TARGET_ARCH_6S_M)
NVIC_SYS_PRI2 |= (NVIC_SYS_PRI3<<(8+1)) & 0xFC000000;
#else
sh = 8 - __clz (~((NVIC_SYS_PRI3 << 8) & 0xFF000000));
prigroup = ((NVIC_AIR_CTRL >> 8) & 0x07);
if (prigroup >= sh) {
sh = prigroup + 1;
}
NVIC_SYS_PRI2 = ((0xFEFFFFFF << sh) & 0xFF000000) | (NVIC_SYS_PRI2 & 0x00FFFFFF);
#endif
}
extern void rt_set_PSP (U32 stack);
extern U32 rt_get_PSP (void);
extern void os_set_env (void);
extern void *_alloc_box (void *box_mem);
extern int _free_box (void *box_mem, void *box);
extern void rt_init_stack (P_TCB p_TCB, FUNCP task_body);
extern void rt_ret_val (P_TCB p_TCB, U32 v0);
extern void rt_ret_val2 (P_TCB p_TCB, U32 v0, U32 v1);
extern void dbg_init (void);
extern void dbg_task_notify (P_TCB p_tcb, BOOL create);
extern void dbg_task_switch (U32 task_id);
#ifdef DBG_MSG
#define DBG_INIT() dbg_init()
#define DBG_TASK_NOTIFY(p_tcb,create) if (dbg_msg) dbg_task_notify(p_tcb,create)
#define DBG_TASK_SWITCH(task_id) if (dbg_msg && (os_tsk.new_tsk != os_tsk.run)) \
dbg_task_switch(task_id)
#else
#define DBG_INIT()
#define DBG_TASK_NOTIFY(p_tcb,create)
#define DBG_TASK_SWITCH(task_id)
#endif
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
| {
"pile_set_name": "Github"
} |
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
datToFoam
Description
Reads in a datToFoam mesh file and outputs a points file. Used in
conjunction with blockMesh.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IFstream.H"
#include "OFstream.H"
#include "pointField.H"
#include "unitConversion.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("dat file");
argList args(argc, argv);
if (!args.check())
{
FatalError.exit();
}
#include "createTime.H"
std::ifstream plot3dFile(args.args()[1].c_str());
string line;
std::getline(plot3dFile, line);
std::getline(plot3dFile, line);
IStringStream Istring(line);
word block;
string zoneName;
token punctuation;
label iPoints;
label jPoints;
Istring >> block;
Istring >> block;
Istring >> zoneName;
Istring >> punctuation;
Istring >> block;
Istring >> iPoints;
Istring >> block;
Istring >> jPoints;
Info<< "Number of vertices in i direction = " << iPoints << endl
<< "Number of vertices in j direction = " << jPoints << endl;
// We ignore the first layer of points in i and j the biconic meshes
label nPointsij = (iPoints - 1)*(jPoints - 1);
pointField points(nPointsij, Zero);
for (direction comp = 0; comp < 2; comp++)
{
label p(0);
for (label j = 0; j < jPoints; j++)
{
for (label i = 0; i < iPoints; i++)
{
double coord;
plot3dFile >> coord;
// if statement ignores the first layer in i and j
if (i>0 && j>0)
{
points[p++][comp] = coord;
}
}
}
}
// correct error in biconic meshes
forAll(points, i)
{
if (points[i][1] < 1e-07)
{
points[i][1] = 0.0;
}
}
pointField pointsWedge(nPointsij*2, Zero);
fileName pointsFile(runTime.constantPath()/"points.tmp");
OFstream pFile(pointsFile);
scalar a(degToRad(0.1));
tensor rotateZ =
tensor
(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, -::sin(a), ::cos(a)
);
forAll(points, i)
{
pointsWedge[i] = (rotateZ & points[i]);
pointsWedge[i+nPointsij] = cmptMultiply
(
vector(1.0, 1.0, -1.0),
pointsWedge[i]
);
}
Info<< "Writing points to: " << nl
<< " " << pointsFile << endl;
pFile << pointsWedge;
Info<< "End" << endl;
return 0;
}
// ************************************************************************* //
| {
"pile_set_name": "Github"
} |
/**
* Copyright (c) ppy Pty Ltd <[email protected]>.
*
* This file is part of osu!web. osu!web is distributed with the hope of
* attracting more community contributions to the core ecosystem of osu!.
*
* osu!web is free software: you can redistribute it and/or modify
* it under the terms of the Affero GNU General Public License version 3
* as published by the Free Software Foundation.
*
* osu!web is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with osu!web. If not, see <http://www.gnu.org/licenses/>.
*/
import { dispatch, dispatcher } from 'app-dispatcher';
import { NotificationBundleJson } from 'interfaces/notification-json';
import NotificationController from 'notifications/notification-controller';
import { NotificationEventMoreLoaded } from 'notifications/notification-events';
import { toJson } from 'notifications/notification-identity';
import NotificationStore from 'stores/notification-store';
import { makeNotificationJson, makeStackJson } from './helpers';
const identities = [
{ id: 1002, objectType: 'beatmapset', objectId: 2, category: 'beatmapset_discussion' },
{ id: 1001, objectType: 'beatmapset', objectId: 1, category: 'beatmapset_discussion' },
];
describe('Notification Index', () => {
// @ts-ignore
beforeEach(() => dispatcher.listeners.clear());
// @ts-ignore
afterEach(() => dispatcher.listeners.clear());
const bundle: NotificationBundleJson = {
notifications: [identities[0]].map(toJson).map(makeNotificationJson),
stacks: [makeStackJson(identities[0], 5, 'beatmapset_discussion_post_new', identities[0].id )],
timestamp: new Date().toJSON(),
types: [
{ cursor: { id: identities[0].id }, name: null, total: 20 },
{ cursor: { id: identities[0].id }, name: 'beatmapset', total: 5 },
],
};
let store!: NotificationStore;
beforeEach(() => {
store = new NotificationStore();
store.stacks.updateWithBundle(bundle);
});
describe('when starting on All', () => {
let controller!: NotificationController;
beforeEach(() => {
controller = new NotificationController(store, { isWidget: false }, null);
});
it('should filter by All', () => {
expect(controller.currentFilter).toBe(null);
});
it('should have 1 notification', () => {
expect(store.notifications.size).toBe(1);
});
it('should have 1 stack', () => {
expect([...controller.stacks].length).toBe(1);
});
describe('after loading more', () => {
beforeEach(() => {
const loadMoreBundle: NotificationBundleJson = {
notifications: [identities[1]].map(toJson).map(makeNotificationJson),
stacks: [makeStackJson(identities[1], 5, 'beatmapset_discussion_post_new', identities[1].id )],
timestamp: new Date().toJSON(),
types: [
{ cursor: { id: identities[1].id }, name: null, total: 20 },
{ cursor: { id: identities[1].id }, name: 'beatmapset', total: 5 },
],
};
dispatch(new NotificationEventMoreLoaded(loadMoreBundle, { isWidget: false }));
});
it('should have 2 notifications', () => {
expect(store.notifications.size).toBe(2);
});
it('should have 2 stacks', () => {
expect([...controller.stacks].length).toBe(2);
});
describe('change filter to Beatmapsets', () => {
beforeEach(() => {
controller.navigateTo('beatmapset');
});
it('should filter by Beatmapsets', () => {
expect(controller.currentFilter).toBe('beatmapset');
});
it('should contain the extra notifications', () => {
expect([...controller.stacks].length).toBe(2);
});
});
});
describe('swithcing to a filter with no items', () => {
it('should automatically try to load more', () => {
spyOn(controller, 'loadMore');
controller.navigateTo('user');
expect(controller.loadMore).toHaveBeenCalledTimes(1);
});
});
describe('swithcing to a filter with items', () => {
it('should not automatically try to load more', () => {
spyOn(controller, 'loadMore');
controller.navigateTo('beatmapset');
expect(controller.loadMore).toHaveBeenCalledTimes(0);
});
});
});
describe('when starting on Beatmapsets', () => {
let controller!: NotificationController;
beforeEach(() => {
controller = new NotificationController(store, { isWidget: false }, 'beatmapset');
});
it('should filter by Beatmapsets', () => {
expect(controller.currentFilter).toBe('beatmapset');
});
it('should have 1 notifications', () => {
expect(store.notifications.size).toBe(1);
});
it('should have 1 stack', () => {
expect([...controller.stacks].length).toBe(1);
});
describe('after loading more', () => {
beforeEach(() => {
const loadMoreBundle: NotificationBundleJson = {
notifications: [identities[1]].map(toJson).map(makeNotificationJson),
stacks: [makeStackJson(identities[1], 5, 'beatmapset_discussion_post_new', identities[1].id )],
timestamp: new Date().toJSON(),
types: [
{ cursor: { id: identities[1].id }, name: 'beatmapset', total: 5 },
],
};
dispatch(new NotificationEventMoreLoaded(loadMoreBundle, { isWidget: false }));
});
it('should have 2 notifications', () => {
expect(store.notifications.size).toBe(2);
});
describe('change filter to All', () => {
beforeEach(() => {
controller.navigateTo(null);
});
it('should filter by All', () => {
expect(controller.currentFilter).toBe(null);
});
it('should reset the loaded notifications', () => {
expect([...controller.stacks].length).toBe(1);
});
});
});
});
});
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: a248f6591afb49f46beb329ea2296243
timeCreated: 1513737329
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
/*
* mcp3422.c - driver for the Microchip mcp3422/3/4/6/7/8 chip family
*
* Copyright (C) 2013, Angelo Compagnucci
* Author: Angelo Compagnucci <[email protected]>
*
* Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf
* http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
*
* This driver exports the value of analog input voltage to sysfs, the
* voltage unit is nV.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/sysfs.h>
#include <linux/of.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
/* Masks */
#define MCP3422_CHANNEL_MASK 0x60
#define MCP3422_PGA_MASK 0x03
#define MCP3422_SRATE_MASK 0x0C
#define MCP3422_SRATE_240 0x0
#define MCP3422_SRATE_60 0x1
#define MCP3422_SRATE_15 0x2
#define MCP3422_SRATE_3 0x3
#define MCP3422_PGA_1 0
#define MCP3422_PGA_2 1
#define MCP3422_PGA_4 2
#define MCP3422_PGA_8 3
#define MCP3422_CONT_SAMPLING 0x10
#define MCP3422_CHANNEL(config) (((config) & MCP3422_CHANNEL_MASK) >> 5)
#define MCP3422_PGA(config) ((config) & MCP3422_PGA_MASK)
#define MCP3422_SAMPLE_RATE(config) (((config) & MCP3422_SRATE_MASK) >> 2)
#define MCP3422_CHANNEL_VALUE(value) (((value) << 5) & MCP3422_CHANNEL_MASK)
#define MCP3422_PGA_VALUE(value) ((value) & MCP3422_PGA_MASK)
#define MCP3422_SAMPLE_RATE_VALUE(value) ((value << 2) & MCP3422_SRATE_MASK)
#define MCP3422_CHAN(_index) \
{ \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.channel = _index, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \
| BIT(IIO_CHAN_INFO_SCALE), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
}
static const int mcp3422_scales[4][4] = {
{ 1000000, 500000, 250000, 125000 },
{ 250000 , 125000, 62500 , 31250 },
{ 62500 , 31250 , 15625 , 7812 },
{ 15625 , 7812 , 3906 , 1953 } };
/* Constant msleep times for data acquisitions */
static const int mcp3422_read_times[4] = {
[MCP3422_SRATE_240] = 1000 / 240,
[MCP3422_SRATE_60] = 1000 / 60,
[MCP3422_SRATE_15] = 1000 / 15,
[MCP3422_SRATE_3] = 1000 / 3 };
/* sample rates to integer conversion table */
static const int mcp3422_sample_rates[4] = {
[MCP3422_SRATE_240] = 240,
[MCP3422_SRATE_60] = 60,
[MCP3422_SRATE_15] = 15,
[MCP3422_SRATE_3] = 3 };
/* sample rates to sign extension table */
static const int mcp3422_sign_extend[4] = {
[MCP3422_SRATE_240] = 11,
[MCP3422_SRATE_60] = 13,
[MCP3422_SRATE_15] = 15,
[MCP3422_SRATE_3] = 17 };
/* Client data (each client gets its own) */
struct mcp3422 {
struct i2c_client *i2c;
u8 id;
u8 config;
u8 pga[4];
struct mutex lock;
};
static int mcp3422_update_config(struct mcp3422 *adc, u8 newconfig)
{
int ret;
mutex_lock(&adc->lock);
ret = i2c_master_send(adc->i2c, &newconfig, 1);
if (ret > 0) {
adc->config = newconfig;
ret = 0;
}
mutex_unlock(&adc->lock);
return ret;
}
static int mcp3422_read(struct mcp3422 *adc, int *value, u8 *config)
{
int ret = 0;
u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config);
u8 buf[4] = {0, 0, 0, 0};
u32 temp;
if (sample_rate == MCP3422_SRATE_3) {
ret = i2c_master_recv(adc->i2c, buf, 4);
temp = buf[0] << 16 | buf[1] << 8 | buf[2];
*config = buf[3];
} else {
ret = i2c_master_recv(adc->i2c, buf, 3);
temp = buf[0] << 8 | buf[1];
*config = buf[2];
}
*value = sign_extend32(temp, mcp3422_sign_extend[sample_rate]);
return ret;
}
static int mcp3422_read_channel(struct mcp3422 *adc,
struct iio_chan_spec const *channel, int *value)
{
int ret;
u8 config;
u8 req_channel = channel->channel;
if (req_channel != MCP3422_CHANNEL(adc->config)) {
config = adc->config;
config &= ~MCP3422_CHANNEL_MASK;
config |= MCP3422_CHANNEL_VALUE(req_channel);
config &= ~MCP3422_PGA_MASK;
config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
ret = mcp3422_update_config(adc, config);
if (ret < 0)
return ret;
msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]);
}
return mcp3422_read(adc, value, &config);
}
static int mcp3422_read_raw(struct iio_dev *iio,
struct iio_chan_spec const *channel, int *val1,
int *val2, long mask)
{
struct mcp3422 *adc = iio_priv(iio);
int err;
u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config);
u8 pga = MCP3422_PGA(adc->config);
switch (mask) {
case IIO_CHAN_INFO_RAW:
err = mcp3422_read_channel(adc, channel, val1);
if (err < 0)
return -EINVAL;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
*val1 = 0;
*val2 = mcp3422_scales[sample_rate][pga];
return IIO_VAL_INT_PLUS_NANO;
case IIO_CHAN_INFO_SAMP_FREQ:
*val1 = mcp3422_sample_rates[MCP3422_SAMPLE_RATE(adc->config)];
return IIO_VAL_INT;
default:
break;
}
return -EINVAL;
}
static int mcp3422_write_raw(struct iio_dev *iio,
struct iio_chan_spec const *channel, int val1,
int val2, long mask)
{
struct mcp3422 *adc = iio_priv(iio);
u8 temp;
u8 config = adc->config;
u8 req_channel = channel->channel;
u8 sample_rate = MCP3422_SAMPLE_RATE(config);
u8 i;
switch (mask) {
case IIO_CHAN_INFO_SCALE:
if (val1 != 0)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(mcp3422_scales[0]); i++) {
if (val2 == mcp3422_scales[sample_rate][i]) {
adc->pga[req_channel] = i;
config &= ~MCP3422_CHANNEL_MASK;
config |= MCP3422_CHANNEL_VALUE(req_channel);
config &= ~MCP3422_PGA_MASK;
config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
return mcp3422_update_config(adc, config);
}
}
return -EINVAL;
case IIO_CHAN_INFO_SAMP_FREQ:
switch (val1) {
case 240:
temp = MCP3422_SRATE_240;
break;
case 60:
temp = MCP3422_SRATE_60;
break;
case 15:
temp = MCP3422_SRATE_15;
break;
case 3:
if (adc->id > 4)
return -EINVAL;
temp = MCP3422_SRATE_3;
break;
default:
return -EINVAL;
}
config &= ~MCP3422_CHANNEL_MASK;
config |= MCP3422_CHANNEL_VALUE(req_channel);
config &= ~MCP3422_SRATE_MASK;
config |= MCP3422_SAMPLE_RATE_VALUE(temp);
return mcp3422_update_config(adc, config);
default:
break;
}
return -EINVAL;
}
static int mcp3422_write_raw_get_fmt(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, long mask)
{
switch (mask) {
case IIO_CHAN_INFO_SCALE:
return IIO_VAL_INT_PLUS_NANO;
case IIO_CHAN_INFO_SAMP_FREQ:
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
}
static ssize_t mcp3422_show_samp_freqs(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev));
if (adc->id > 4)
return sprintf(buf, "240 60 15\n");
return sprintf(buf, "240 60 15 3\n");
}
static ssize_t mcp3422_show_scales(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev));
u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config);
return sprintf(buf, "0.%09u 0.%09u 0.%09u 0.%09u\n",
mcp3422_scales[sample_rate][0],
mcp3422_scales[sample_rate][1],
mcp3422_scales[sample_rate][2],
mcp3422_scales[sample_rate][3]);
}
static IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO,
mcp3422_show_samp_freqs, NULL, 0);
static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO,
mcp3422_show_scales, NULL, 0);
static struct attribute *mcp3422_attributes[] = {
&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_in_voltage_scale_available.dev_attr.attr,
NULL,
};
static const struct attribute_group mcp3422_attribute_group = {
.attrs = mcp3422_attributes,
};
static const struct iio_chan_spec mcp3422_channels[] = {
MCP3422_CHAN(0),
MCP3422_CHAN(1),
};
static const struct iio_chan_spec mcp3424_channels[] = {
MCP3422_CHAN(0),
MCP3422_CHAN(1),
MCP3422_CHAN(2),
MCP3422_CHAN(3),
};
static const struct iio_info mcp3422_info = {
.read_raw = mcp3422_read_raw,
.write_raw = mcp3422_write_raw,
.write_raw_get_fmt = mcp3422_write_raw_get_fmt,
.attrs = &mcp3422_attribute_group,
.driver_module = THIS_MODULE,
};
static int mcp3422_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct iio_dev *indio_dev;
struct mcp3422 *adc;
int err;
u8 config;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adc));
if (!indio_dev)
return -ENOMEM;
adc = iio_priv(indio_dev);
adc->i2c = client;
adc->id = (u8)(id->driver_data);
mutex_init(&adc->lock);
indio_dev->dev.parent = &client->dev;
indio_dev->name = dev_name(&client->dev);
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &mcp3422_info;
switch (adc->id) {
case 2:
case 3:
case 6:
case 7:
indio_dev->channels = mcp3422_channels;
indio_dev->num_channels = ARRAY_SIZE(mcp3422_channels);
break;
case 4:
case 8:
indio_dev->channels = mcp3424_channels;
indio_dev->num_channels = ARRAY_SIZE(mcp3424_channels);
break;
}
/* meaningful default configuration */
config = (MCP3422_CONT_SAMPLING
| MCP3422_CHANNEL_VALUE(1)
| MCP3422_PGA_VALUE(MCP3422_PGA_1)
| MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240));
mcp3422_update_config(adc, config);
err = devm_iio_device_register(&client->dev, indio_dev);
if (err < 0)
return err;
i2c_set_clientdata(client, indio_dev);
return 0;
}
static const struct i2c_device_id mcp3422_id[] = {
{ "mcp3422", 2 },
{ "mcp3423", 3 },
{ "mcp3424", 4 },
{ "mcp3426", 6 },
{ "mcp3427", 7 },
{ "mcp3428", 8 },
{ }
};
MODULE_DEVICE_TABLE(i2c, mcp3422_id);
#ifdef CONFIG_OF
static const struct of_device_id mcp3422_of_match[] = {
{ .compatible = "mcp3422" },
{ }
};
MODULE_DEVICE_TABLE(of, mcp3422_of_match);
#endif
static struct i2c_driver mcp3422_driver = {
.driver = {
.name = "mcp3422",
.of_match_table = of_match_ptr(mcp3422_of_match),
},
.probe = mcp3422_probe,
.id_table = mcp3422_id,
};
module_i2c_driver(mcp3422_driver);
MODULE_AUTHOR("Angelo Compagnucci <[email protected]>");
MODULE_DESCRIPTION("Microchip mcp3422/3/4/6/7/8 driver");
MODULE_LICENSE("GPL v2");
| {
"pile_set_name": "Github"
} |
^D:\GNU\EXIV2\SAMPLES\TAGLIST.CPP|D:\GNU\EXIV2\SRC\UTILS.CPP
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\UTILS.SBR
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\TAGLIST.SBR
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\TAGLIST.OBJ
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\UTILS.OBJ
^D:\GNU\EXIV2\SAMPLES\TAGLIST.CPP
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\VC100.PDB
^D:\GNU\EXIV2\SRC\UTILS.CPP
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\VC100.PDB
^D:\GNU\EXIV2\SRC\GETOPT_WIN32.C|D:\GNU\EXIV2\SRC\LOCALTIME.C
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\LOCALTIME.SBR
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\GETOPT_WIN32.SBR
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\GETOPT_WIN32.OBJ
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\LOCALTIME.OBJ
^D:\GNU\EXIV2\SRC\GETOPT_WIN32.C
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\VC100.PDB
^D:\GNU\EXIV2\SRC\LOCALTIME.C
D:\GNU\EXIV2\MSVC2005\TAGLIST\BUILD\WIN32\DEBUG\VC100.PDB
| {
"pile_set_name": "Github"
} |
import { purry } from './purry';
/**
* Sorts an array. The comparator function should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal.
* Sorting is based on a native `sort` function. It's not guaranteed to be stable.
* @param items the array to sort
* @param cmp the comparator function
* @signature
* R.sort(items, cmp)
* @example
* R.sort([4, 2, 7, 5], (a, b) => a - b) // => [2, 4, 5, 7]
* @data_first
* @category Array
*/
export function sort<T>(items: readonly T[], cmp: (a: T, b: T) => number): T[];
/**
* Sorts an array. The comparator function should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal.
* Sorting is based on a native `sort` function. It's not guaranteed to be stable.
* @param cmp the comparator function
* @signature
* R.sort(cmp)(items)
* @example
* R.pipe([4, 2, 7, 5], R.sort((a, b) => a - b)) // => [2, 4, 5, 7]
* @data_last
* @category Array
*/
export function sort<T>(
cmp: (a: T, b: T) => number
): (items: readonly T[]) => T[];
export function sort<T>() {
return purry(_sort, arguments);
}
function _sort<T>(items: T[], cmp: (a: T, b: T) => number) {
const ret = [...items];
ret.sort(cmp);
return ret;
}
| {
"pile_set_name": "Github"
} |
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env bash
url=file://$HOME/bin/Linux/ext/android-sdk-linux/docs/reference/$(ajoke-get-package $1 | perl -npe 's#\.#/#g')$(basename $1|perl -npe 's/\.java$/.html/')
emacsclient -e '(w3m-goto-url "'$url'")' >/dev/null 2>&1 &
| {
"pile_set_name": "Github"
} |
package httpclient
import "net/http"
// BasicAuth is an http.RoundTripper that makes HTTP
// requests, wrapping a base RoundTripper and adding
// a basic authorization header.
type BasicAuth struct {
Base http.RoundTripper
Username string
Password string
}
// RoundTrip adds the Authorization header to the request.
func (t *BasicAuth) RoundTrip(r *http.Request) (*http.Response, error) {
if r.Header.Get("Authorization") != "" {
return t.base().RoundTrip(r)
}
req := cloneRequest(r)
req.SetBasicAuth(t.Username, t.Password)
return t.base().RoundTrip(req)
}
func (t *BasicAuth) base() http.RoundTripper {
if t.Base != nil {
return t.Base
}
return http.DefaultTransport
}
func cloneRequest(r *http.Request) *http.Request {
req := new(http.Request)
*req = *r
req.Header = make(http.Header, len(r.Header))
for k, s := range r.Header {
req.Header[k] = append([]string(nil), s...)
}
return req
}
| {
"pile_set_name": "Github"
} |
/* crypto/dh/p192.c */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson ([email protected]).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 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 acknowledgement:
* "This product includes cryptographic software written by
* Eric Young ([email protected])"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson ([email protected])"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include <stdio.h>
#include <openssl/bn.h>
#include <openssl/asn1.h>
#include <openssl/dh.h>
#include <openssl/pem.h>
unsigned char data[] = {
0xD4, 0xA0, 0xBA, 0x02, 0x50, 0xB6, 0xFD, 0x2E,
0xC6, 0x26, 0xE7, 0xEF, 0xD6, 0x37, 0xDF, 0x76,
0xC7, 0x16, 0xE2, 0x2D, 0x09, 0x44, 0xB8, 0x8B,
};
main()
{
DH *dh;
dh = DH_new();
dh->p = BN_bin2bn(data, sizeof(data), NULL);
dh->g = BN_new();
BN_set_word(dh->g, 3);
PEM_write_DHparams(stdout, dh);
}
| {
"pile_set_name": "Github"
} |
/* Trivial test of ordered. */
/* { dg-require-effective-target sync_int_long } */
#include <omp.h>
#include <string.h>
#include <assert.h>
#include "libgomp_g.h"
#define N 100
static int next;
static int CHUNK, NTHR;
static void clean_data (void)
{
next = 0;
}
static void set_data (long i)
{
int n = __sync_fetch_and_add (&next, 1);
assert (n == i);
}
#define TMPL_1(sched) \
static void f_##sched##_1 (void *dummy) \
{ \
long s0, e0, i; \
if (GOMP_loop_ordered_##sched##_start (0, N, 1, CHUNK, &s0, &e0)) \
do \
{ \
for (i = s0; i < e0; ++i) \
{ \
GOMP_ordered_start (); \
set_data (i); \
GOMP_ordered_end (); \
} \
} \
while (GOMP_loop_ordered_##sched##_next (&s0, &e0)); \
GOMP_loop_end (); \
} \
static void t_##sched##_1 (void) \
{ \
clean_data (); \
GOMP_parallel_start (f_##sched##_1, NULL, NTHR); \
f_##sched##_1 (NULL); \
GOMP_parallel_end (); \
}
TMPL_1(static)
TMPL_1(dynamic)
TMPL_1(guided)
static void test (void)
{
t_static_1 ();
t_dynamic_1 ();
t_guided_1 ();
}
int main()
{
omp_set_dynamic (0);
NTHR = 4;
CHUNK = 1;
test ();
CHUNK = 5;
test ();
CHUNK = 7;
test ();
CHUNK = 0;
t_static_1 ();
return 0;
}
| {
"pile_set_name": "Github"
} |
ID=0 ROUT='ATL_damm0_1m_7x1x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=1 MU=7 MB=120 NB=120 KB=120 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_3x1x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=1 MU=3 MB=120 NB=120 KB=120 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_5x1x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=1 MU=5 MB=120 NB=120 KB=120 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_8x2x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=2 MU=8 MB=16 NB=16 KB=16 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_3x6x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=6 MU=3 MB=18 NB=18 KB=18 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_2x2x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=2 MU=2 MB=4 NB=4 KB=4 NOBCAST=0 KUISKB=0 KVEC=0 \
L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 KRUNTIME=1 \
LDCTOP=1 X87=0
ID=0 ROUT='ATL_damm0_1m_5x5x1.c' AUTH='R. Clint Whaley' TA='T' TB='N' \
OPMV=3 VLEN=1 KU=1 NU=5 MU=5 MB=45 NB=45 KB=44 NOBCAST=0 KUISKB=0 \
KVEC=0 L14NB=0 PFCELTS=0 PFBCOLS=0 PFABLK=0 PFACOLS=0 AOUTER=1 \
KRUNTIME=1 LDCTOP=1 X87=0
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
| {
"pile_set_name": "Github"
} |
"""
Trigger examples
"""
__version__ = "$Revision: 1.7 $"
import sys, os
thisPath = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.abspath(os.path.join(thisPath,"..")))
from ExampleBuilder import ExampleBuilder
import Utils.Libraries.PorterStemmer as PorterStemmer
from Core.IdSet import IdSet
import Core.ExampleUtils as ExampleUtils
#from Core.Gazetteer import Gazetteer
import Utils.InteractionXML.MapPhrases as MapPhrases
import Utils.Settings as Settings
import Utils.Download
from FeatureBuilders.TriggerFeatureBuilder import TriggerFeatureBuilder
coNPPhraseFirstToken = set(["both", "each", "it", "its", "itself", "neither", "others",
"that", "the", "their", "them", "themselves", "these", "they",
"this", "those"])
def installBBData(destPath=None, downloadPath=None, redownload=False, updateLocalSettings=False):
print >> sys.stderr, "---------------", "Downloading TEES data files for BB", "---------------"
print >> sys.stderr, "Bacteria tokens derived from LPSN (http://www.bacterio.cict.fr/)"
if destPath == None:
destPath = os.path.join(Settings.DATAPATH, "resources")
if downloadPath == None:
downloadPath = os.path.join(Settings.DATAPATH, "resources/download")
Utils.Download.downloadAndExtract(Settings.URL["TEES_RESOURCES"], destPath, downloadPath, redownload=redownload)
Settings.setLocal("TEES_RESOURCES", destPath, updateLocalSettings)
def getBacteriaNames(filename):
f = open(filename, "rt")
names = []
for line in f:
if line.strip == "":
continue
if line.startswith("Note:"):
continue
namePart = line.split("18")[0].split("19")[0].split("(")[0]
names.append(namePart)
f.close()
return names
def getBacteriaTokens(names=None):
# Install file if needed
if not hasattr(Settings, "TEES_RESOURCES"):
print >> sys.stderr, "TEES example builder data files not installed, installing now"
installBBData(updateLocalSettings=True)
# Get the tokens
tokens = set()
if names != None:
for name in names:
for split in name.split():
tokens.add(split.lower())
else:
f = open(os.path.join(Settings.TEES_RESOURCES, "bacteria-tokens.txt"), "rt")
for line in f:
tokens.add(line.strip())
f.close()
return tokens
class PhraseTriggerExampleBuilder(ExampleBuilder):
def __init__(self, style=None, classSet=None, featureSet=None, gazetteerFileName=None):
if classSet == None:
classSet = IdSet(1)
assert( classSet.getId("neg") == 1 )
if featureSet == None:
featureSet = IdSet()
ExampleBuilder.__init__(self, classSet, featureSet)
self._setDefaultParameters(["co_limits"])
self.styles = self.getParameters(style)
self.triggerFeatureBuilder = TriggerFeatureBuilder(self.featureSet)
self.triggerFeatureBuilder.useNonNameEntities = False
self.phraseTypeCounts = {}
# @classmethod
# def run(cls, input, output, parse, tokenization, style, idFileTag=None, gazetteerFileName=None):
# classSet, featureSet = cls.getIdSets(idFileTag)
# e = PhraseTriggerExampleBuilder(style, classSet, featureSet)
# if "names" in style:
# sentences = cls.getSentences(input, parse, tokenization, removeNameInfo=True)
# else:
# sentences = cls.getSentences(input, parse, tokenization, removeNameInfo=False)
# e.phraseTypeCounts = {}
# e.buildExamplesForSentences(sentences, output, idFileTag)
# print >> sys.stderr, "Phrase type counts:", e.phraseTypeCounts
def buildLinearOrderFeatures(self,sentenceGraph,index,tag,features):
"""
Linear features are built by marking token features with a tag
that defines their relative position in the linear order.
"""
tag = "linear_"+tag
tokenFeatures, tokenFeatureWeights = self.getTokenFeatures(sentenceGraph.tokens[index], sentenceGraph)
for tokenFeature in tokenFeatures:
features[self.featureSet.getId(tag+tokenFeature)] = tokenFeatureWeights[tokenFeature]
def buildLinearNGram(self, phraseTokens, sentenceGraph, features):
ngram = "ngram"
for token in phraseTokens:
ngram += "_" + sentenceGraph.getTokenText(token).lower()
features[self.featureSet.getId(ngram)] = 1
def getPhraseHeadToken(self, phrase, phraseTokens):
bestToken = (-9999, None)
for token in phraseTokens:
headScore = int(token.get("headScore"))
if headScore >= bestToken[0]: # >= because rightmost is best
bestToken = (headScore, token)
return bestToken[1]
def getPhraseTokens(self, phrase, sentenceGraph):
phraseBegin = int(phrase.get("begin"))
phraseEnd = int(phrase.get("end"))
return sentenceGraph.tokens[phraseBegin:phraseEnd+1]
def getCategoryName(self, phrase, phraseToEntity):
if phrase not in phraseToEntity:
return "neg"
entityTypes = set()
for entity in phraseToEntity[phrase]:
entityTypes.add(entity.get("type"))
return "---".join(sorted(list(entityTypes)))
def isPotentialCOTrigger(self, phrase, phraseTokens, sentenceGraph):
global coNPPhraseFirstToken
# Check type
if phrase.get("type") not in ["NP", "NP-IN"]: # only limit these types
return True
# Check named entities
for token in phraseTokens:
if sentenceGraph.tokenIsName[token]:
return True
# Check first word
if phraseTokens[0].get("text") in coNPPhraseFirstToken:
return True
else:
return False
def buildExamplesFromGraph(self, sentenceGraph, outfile, goldGraph=None, structureAnalyzer=None):
"""
Build one example for each phrase in the sentence
"""
self.triggerFeatureBuilder.initSentence(sentenceGraph)
#examples = []
exampleIndex = 0
# Prepare phrases, create subphrases
#filter = set(["NP", "TOK-IN", "WHADVP", "WHNP", "TOK-WP$", "TOK-PRP$", "NP-IN"])
phrases = MapPhrases.getPhrases(sentenceGraph.parseElement, sentenceGraph.tokens, set(["NP", "WHADVP", "WHNP"]))
phraseDict = MapPhrases.getPhraseDict(phrases)
phrases.extend( MapPhrases.makeINSubPhrases(phrases, sentenceGraph.tokens, phraseDict, ["NP"]) )
phrases.extend( MapPhrases.makeTokenSubPhrases(sentenceGraph.tokens, phraseDict) )
phraseToEntity = MapPhrases.getPhraseEntityMapping(sentenceGraph.entities, phraseDict)
# Make counts
phraseTypeCounts = MapPhrases.getPhraseTypeCounts(phrases)
for key in phraseTypeCounts.keys():
if not self.phraseTypeCounts.has_key(key):
self.phraseTypeCounts[key] = 0
self.phraseTypeCounts[key] += phraseTypeCounts[key]
self.exampleStats.addVariable("Phrase type counts", self.phraseTypeCounts) # can be added on each loop, will always point to the same thing
# Build one example for each phrase
for phrase in phrases:
features = {}
self.triggerFeatureBuilder.setFeatureVector(features)
categoryName = self.getCategoryName(phrase, phraseToEntity)
category = self.classSet.getId(categoryName)
phraseTokens = self.getPhraseTokens(phrase, sentenceGraph)
phraseHeadToken = self.getPhraseHeadToken(phrase, phraseTokens)
self.exampleStats.beginExample(categoryName)
if self.styles["co_limits"] and not self.isPotentialCOTrigger(phrase, phraseTokens, sentenceGraph):
self.exampleStats.filter("co_limits")
self.exampleStats.endExample()
continue
# Sentence level features
features.update(self.triggerFeatureBuilder.bowFeatures)
# Whole phrase features
self.buildLinearNGram(phraseTokens, sentenceGraph, features)
features[self.featureSet.getId("pType_"+phrase.get("type"))] = 1
for split in phrase.get("type").split("-"):
features[self.featureSet.getId("pSubType_"+split)] = 1
# Check named entities
nameCount = 0
for token in phraseTokens:
if sentenceGraph.tokenIsName[token]:
nameCount += 1
features[self.featureSet.getId("phraseNames_"+str(nameCount))] = 1
features[self.featureSet.getId("phraseNameCount")] = nameCount
# Head token features
self.triggerFeatureBuilder.setTag("head_")
self.triggerFeatureBuilder.buildFeatures(phraseHeadToken)
self.triggerFeatureBuilder.buildAttachedEdgeFeatures(phraseHeadToken, sentenceGraph)
self.triggerFeatureBuilder.setTag()
# Features for all phrase tokens
self.triggerFeatureBuilder.setTag("ptok_")
phraseTokenPos = 0
#print len(phraseTokens)
for token in phraseTokens:
self.triggerFeatureBuilder.setTag("ptok_")
self.triggerFeatureBuilder.buildFeatures(phraseHeadToken, linear=False, chains=False)
self.triggerFeatureBuilder.setTag("ptok_" + str(phraseTokenPos) + "_" )
self.triggerFeatureBuilder.buildFeatures(phraseHeadToken, linear=False, chains=False)
self.triggerFeatureBuilder.setTag("ptok_" + str(phraseTokenPos-len(phraseTokens)) + "_" )
self.triggerFeatureBuilder.buildFeatures(phraseHeadToken, linear=False, chains=False)
#self.triggerFeatureBuilder.buildAttachedEdgeFeatures(phraseHeadToken)
phraseTokenPos += 1
self.triggerFeatureBuilder.setTag()
extra = {"xtype":"phrase","t":phraseHeadToken.get("id"), "p":phrase.get("id"), "ptype":phrase.get("type")}
extra["charOffset"] = phrase.get("charOffset")
if phrase not in phraseToEntity:
extra["eids"] = "neg"
else:
extra["eids"] = ",".join([x.get("id") for x in phraseToEntity[phrase]])
example = (sentenceGraph.getSentenceId()+".x"+str(exampleIndex), category, features, extra)
ExampleUtils.appendExamples([example], outfile)
self.exampleStats.endExample()
exampleIndex += 1
# Mark missed entities in exampleStats
linkedEntities = set( sum(phraseToEntity.values(), []) )
for entity in sentenceGraph.entities:
if entity.get("given") != "True" and entity not in linkedEntities:
self.exampleStats.addValue("Entities with no phrase", 1)
# Marking these as filtered examples was misleading, as examples are per phrase, and these are entities
#self.exampleStats.beginExample(entity.get("type"))
#self.exampleStats.filter("no_phrase")
#self.exampleStats.endExample()
return exampleIndex | {
"pile_set_name": "Github"
} |
---
title: "Create windowsInformationProtectionNetworkLearningSummary"
description: "Create a new windowsInformationProtectionNetworkLearningSummary object."
author: "dougeby"
localization_priority: Normal
ms.prod: "intune"
doc_type: apiPageType
---
# Create windowsInformationProtectionNetworkLearningSummary
Namespace: microsoft.graph
> **Important:** Microsoft Graph APIs under the /beta version are subject to change; production use is not supported.
> **Note:** The Microsoft Graph API for Intune requires an [active Intune license](https://go.microsoft.com/fwlink/?linkid=839381) for the tenant.
Create a new [windowsInformationProtectionNetworkLearningSummary](../resources/intune-wip-windowsinformationprotectionnetworklearningsummary.md) object.
## Prerequisites
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see [Permissions](/graph/permissions-reference).
|Permission type|Permissions (from most to least privileged)|
|:---|:---|
|Delegated (work or school account)|DeviceManagementApps.ReadWrite.All|
|Delegated (personal Microsoft account)|Not supported.|
|Application|DeviceManagementApps.ReadWrite.All|
## HTTP Request
<!-- {
"blockType": "ignored"
}
-->
``` http
POST /deviceManagement/windowsInformationProtectionNetworkLearningSummaries
```
## Request headers
|Header|Value|
|:---|:---|
|Authorization|Bearer <token> Required.|
|Accept|application/json|
## Request body
In the request body, supply a JSON representation for the windowsInformationProtectionNetworkLearningSummary object.
The following table shows the properties that are required when you create the windowsInformationProtectionNetworkLearningSummary.
|Property|Type|Description|
|:---|:---|:---|
|id|String|Unique Identifier for the WindowsInformationProtectionNetworkLearningSummary.|
|url|String|Website url|
|deviceCount|Int32|Device Count|
## Response
If successful, this method returns a `201 Created` response code and a [windowsInformationProtectionNetworkLearningSummary](../resources/intune-wip-windowsinformationprotectionnetworklearningsummary.md) object in the response body.
## Example
### Request
Here is an example of the request.
``` http
POST https://graph.microsoft.com/beta/deviceManagement/windowsInformationProtectionNetworkLearningSummaries
Content-type: application/json
Content-length: 137
{
"@odata.type": "#microsoft.graph.windowsInformationProtectionNetworkLearningSummary",
"url": "Url value",
"deviceCount": 11
}
```
### Response
Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
``` http
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 186
{
"@odata.type": "#microsoft.graph.windowsInformationProtectionNetworkLearningSummary",
"id": "242108f7-08f7-2421-f708-2124f7082124",
"url": "Url value",
"deviceCount": 11
}
```
| {
"pile_set_name": "Github"
} |
/*
* INT3406 thermal driver for display participant device
*
* Copyright (C) 2016, Intel Corporation
* Authors: Aaron Lu <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/acpi.h>
#include <linux/backlight.h>
#include <linux/thermal.h>
#include <acpi/video.h>
#define INT3406_BRIGHTNESS_LIMITS_CHANGED 0x80
struct int3406_thermal_data {
int upper_limit;
int lower_limit;
acpi_handle handle;
struct acpi_video_device_brightness *br;
struct backlight_device *raw_bd;
struct thermal_cooling_device *cooling_dev;
};
/*
* According to the ACPI spec,
* "Each brightness level is represented by a number between 0 and 100,
* and can be thought of as a percentage. For example, 50 can be 50%
* power consumption or 50% brightness, as defined by the OEM."
*
* As int3406 device uses this value to communicate with the native
* graphics driver, we make the assumption that it represents
* the percentage of brightness only
*/
#define ACPI_TO_RAW(v, d) (d->raw_bd->props.max_brightness * v / 100)
#define RAW_TO_ACPI(v, d) (v * 100 / d->raw_bd->props.max_brightness)
static int
int3406_thermal_get_max_state(struct thermal_cooling_device *cooling_dev,
unsigned long *state)
{
struct int3406_thermal_data *d = cooling_dev->devdata;
*state = d->upper_limit - d->lower_limit;
return 0;
}
static int
int3406_thermal_set_cur_state(struct thermal_cooling_device *cooling_dev,
unsigned long state)
{
struct int3406_thermal_data *d = cooling_dev->devdata;
int acpi_level, raw_level;
if (state > d->upper_limit - d->lower_limit)
return -EINVAL;
acpi_level = d->br->levels[d->upper_limit - state];
raw_level = ACPI_TO_RAW(acpi_level, d);
return backlight_device_set_brightness(d->raw_bd, raw_level);
}
static int
int3406_thermal_get_cur_state(struct thermal_cooling_device *cooling_dev,
unsigned long *state)
{
struct int3406_thermal_data *d = cooling_dev->devdata;
int acpi_level;
int index;
acpi_level = RAW_TO_ACPI(d->raw_bd->props.brightness, d);
/*
* There is no 1:1 mapping between the firmware interface level
* with the raw interface level, we will have to find one that is
* right above it.
*/
for (index = d->lower_limit; index < d->upper_limit; index++) {
if (acpi_level <= d->br->levels[index])
break;
}
*state = d->upper_limit - index;
return 0;
}
static const struct thermal_cooling_device_ops video_cooling_ops = {
.get_max_state = int3406_thermal_get_max_state,
.get_cur_state = int3406_thermal_get_cur_state,
.set_cur_state = int3406_thermal_set_cur_state,
};
static int int3406_thermal_get_index(int *array, int nr, int value)
{
int i;
for (i = 2; i < nr; i++) {
if (array[i] == value)
break;
}
return i == nr ? -ENOENT : i;
}
static void int3406_thermal_get_limit(struct int3406_thermal_data *d)
{
acpi_status status;
unsigned long long lower_limit, upper_limit;
status = acpi_evaluate_integer(d->handle, "DDDL", NULL, &lower_limit);
if (ACPI_SUCCESS(status))
d->lower_limit = int3406_thermal_get_index(d->br->levels,
d->br->count, lower_limit);
status = acpi_evaluate_integer(d->handle, "DDPC", NULL, &upper_limit);
if (ACPI_SUCCESS(status))
d->upper_limit = int3406_thermal_get_index(d->br->levels,
d->br->count, upper_limit);
/* lower_limit and upper_limit should be always set */
d->lower_limit = d->lower_limit > 0 ? d->lower_limit : 2;
d->upper_limit = d->upper_limit > 0 ? d->upper_limit : d->br->count - 1;
}
static void int3406_notify(acpi_handle handle, u32 event, void *data)
{
if (event == INT3406_BRIGHTNESS_LIMITS_CHANGED)
int3406_thermal_get_limit(data);
}
static int int3406_thermal_probe(struct platform_device *pdev)
{
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
struct int3406_thermal_data *d;
struct backlight_device *bd;
int ret;
if (!ACPI_HANDLE(&pdev->dev))
return -ENODEV;
d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
if (!d)
return -ENOMEM;
d->handle = ACPI_HANDLE(&pdev->dev);
bd = backlight_device_get_by_type(BACKLIGHT_RAW);
if (!bd)
return -ENODEV;
d->raw_bd = bd;
ret = acpi_video_get_levels(ACPI_COMPANION(&pdev->dev), &d->br, NULL);
if (ret)
return ret;
int3406_thermal_get_limit(d);
d->cooling_dev = thermal_cooling_device_register(acpi_device_bid(adev),
d, &video_cooling_ops);
if (IS_ERR(d->cooling_dev))
goto err;
ret = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
int3406_notify, d);
if (ret)
goto err_cdev;
platform_set_drvdata(pdev, d);
return 0;
err_cdev:
thermal_cooling_device_unregister(d->cooling_dev);
err:
kfree(d->br);
return -ENODEV;
}
static int int3406_thermal_remove(struct platform_device *pdev)
{
struct int3406_thermal_data *d = platform_get_drvdata(pdev);
thermal_cooling_device_unregister(d->cooling_dev);
kfree(d->br);
return 0;
}
static const struct acpi_device_id int3406_thermal_match[] = {
{"INT3406", 0},
{}
};
MODULE_DEVICE_TABLE(acpi, int3406_thermal_match);
static struct platform_driver int3406_thermal_driver = {
.probe = int3406_thermal_probe,
.remove = int3406_thermal_remove,
.driver = {
.name = "int3406 thermal",
.acpi_match_table = int3406_thermal_match,
},
};
module_platform_driver(int3406_thermal_driver);
MODULE_DESCRIPTION("INT3406 Thermal driver");
MODULE_LICENSE("GPL v2");
| {
"pile_set_name": "Github"
} |
/* PipeWire
*
* Copyright ยฉ 2018 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <sys/mman.h>
#include <spa/pod/parser.h>
#include <spa/debug/types.h>
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
#include "extensions/protocol-native.h"
#define NAME "core"
/** \cond */
/** \endcond */
static void core_event_ping(void *data, uint32_t id, int seq)
{
struct pw_core *this = data;
pw_log_debug(NAME" %p: object %u ping %u", this, id, seq);
pw_core_pong(this->core, id, seq);
}
static void core_event_done(void *data, uint32_t id, int seq)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
pw_log_trace(NAME" %p: object %u done %d", this, id, seq);
proxy = pw_map_lookup(&this->objects, id);
if (proxy)
pw_proxy_emit_done(proxy, seq);
}
static void core_event_error(void *data, uint32_t id, int seq, int res, const char *message)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
proxy = pw_map_lookup(&this->objects, id);
pw_log_error(NAME" %p: proxy %p id:%u: seq:%d res:%d (%s) msg:\"%s\"",
this, proxy, id, seq, res, spa_strerror(res), message);
if (proxy)
pw_proxy_emit_error(proxy, seq, res, message);
}
static void core_event_remove_id(void *data, uint32_t id)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
pw_log_debug(NAME" %p: object remove %u", this, id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL)
pw_proxy_remove(proxy);
}
static void core_event_bound_id(void *data, uint32_t id, uint32_t global_id)
{
struct pw_core *this = data;
struct pw_proxy *proxy;
pw_log_debug(NAME" %p: proxy id %u bound %u", this, id, global_id);
if ((proxy = pw_map_lookup(&this->objects, id)) != NULL) {
pw_proxy_set_bound_id(proxy, global_id);
}
}
static void core_event_add_mem(void *data, uint32_t id, uint32_t type, int fd, uint32_t flags)
{
struct pw_core *this = data;
struct pw_memblock *m;
pw_log_debug(NAME" %p: add mem %u type:%u fd:%d flags:%u", this, id, type, fd, flags);
m = pw_mempool_import(this->pool, flags, type, fd);
if (m->id != id) {
pw_log_error(NAME" %p: invalid mem id %u, expected %u",
this, id, m->id);
pw_proxy_errorf(&this->proxy, -EINVAL, "invalid mem id %u, expected %u", id, m->id);
pw_memblock_unref(m);
}
}
static void core_event_remove_mem(void *data, uint32_t id)
{
struct pw_core *this = data;
pw_log_debug(NAME" %p: remove mem %u", this, id);
pw_mempool_remove_id(this->pool, id);
}
static const struct pw_core_events core_events = {
PW_VERSION_CORE_EVENTS,
.error = core_event_error,
.ping = core_event_ping,
.done = core_event_done,
.remove_id = core_event_remove_id,
.bound_id = core_event_bound_id,
.add_mem = core_event_add_mem,
.remove_mem = core_event_remove_mem,
};
SPA_EXPORT
struct pw_context *pw_core_get_context(struct pw_core *core)
{
return core->context;
}
SPA_EXPORT
const struct pw_properties *pw_core_get_properties(struct pw_core *core)
{
return core->properties;
}
SPA_EXPORT
int pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict)
{
int changed;
changed = pw_properties_update(core->properties, dict);
pw_log_debug(NAME" %p: updated %d properties", core, changed);
if (!changed)
return 0;
if (core->client)
pw_client_update_properties(core->client, &core->properties->dict);
return changed;
}
SPA_EXPORT
void *pw_core_get_user_data(struct pw_core *core)
{
return core->user_data;
}
static int remove_proxy(void *object, void *data)
{
struct pw_core *core = data;
struct pw_proxy *p = object;
if (object == NULL)
return 0;
if (object != core)
pw_proxy_remove(p);
return 0;
}
static int destroy_proxy(void *object, void *data)
{
struct pw_core *core = data;
struct pw_proxy *p = object;
if (object == NULL)
return 0;
if (object != core) {
pw_log_warn(NAME" %p: leaked proxy %p id:%d", core, p, p->id);
p->core = NULL;
}
return 0;
}
static void proxy_core_removed(void *data)
{
struct pw_core *core = data;
struct pw_stream *stream, *s2;
struct pw_filter *filter, *f2;
if (core->removed)
return;
core->removed = true;
pw_log_debug(NAME" %p: core proxy removed", core);
spa_list_remove(&core->link);
spa_list_for_each_safe(stream, s2, &core->stream_list, link)
pw_stream_disconnect(stream);
spa_list_for_each_safe(filter, f2, &core->filter_list, link)
pw_filter_disconnect(filter);
pw_map_for_each(&core->objects, remove_proxy, core);
}
static void proxy_core_destroy(void *data)
{
struct pw_core *core = data;
struct pw_stream *stream;
struct pw_filter *filter;
if (core->destroyed)
return;
core->destroyed = true;
pw_log_debug(NAME" %p: core proxy destroy", core);
spa_list_consume(stream, &core->stream_list, link)
pw_stream_destroy(stream);
spa_list_consume(filter, &core->filter_list, link)
pw_filter_destroy(filter);
pw_proxy_destroy((struct pw_proxy*)core->client);
pw_map_for_each(&core->objects, destroy_proxy, core);
pw_map_reset(&core->objects);
pw_protocol_client_disconnect(core->conn);
pw_mempool_destroy(core->pool);
pw_protocol_client_destroy(core->conn);
pw_map_clear(&core->objects);
pw_log_debug(NAME" %p: free", core);
pw_properties_free(core->properties);
}
static const struct pw_proxy_events proxy_core_events = {
PW_VERSION_PROXY_EVENTS,
.removed = proxy_core_removed,
.destroy = proxy_core_destroy,
};
SPA_EXPORT
struct pw_client * pw_core_get_client(struct pw_core *core)
{
return core->client;
}
SPA_EXPORT
struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id)
{
return pw_map_lookup(&core->objects, id);
}
SPA_EXPORT
struct pw_proxy *pw_core_export(struct pw_core *core,
const char *type, const struct spa_dict *props, void *object,
size_t user_data_size)
{
struct pw_proxy *proxy;
const struct pw_export_type *t;
int res;
t = pw_context_find_export_type(core->context, type);
if (t == NULL) {
res = -EPROTO;
goto error_export_type;
}
proxy = t->func(core, t->type, props, object, user_data_size);
if (proxy == NULL) {
res = -errno;
goto error_proxy_failed;
}
pw_log_debug(NAME" %p: export:%s proxy:%p", core, type, proxy);
return proxy;
error_export_type:
pw_log_error(NAME" %p: can't export type %s: %s", core, type, spa_strerror(res));
goto exit;
error_proxy_failed:
pw_log_error(NAME" %p: failed to create proxy: %s", core, spa_strerror(res));
goto exit;
exit:
errno = -res;
return NULL;
}
static struct pw_core *core_new(struct pw_context *context,
struct pw_properties *properties, size_t user_data_size)
{
struct pw_core *p;
struct pw_protocol *protocol;
const char *protocol_name;
int res;
p = calloc(1, sizeof(struct pw_core) + user_data_size);
if (p == NULL) {
res = -errno;
goto exit_cleanup;
}
pw_log_debug(NAME" %p: new", p);
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);
if (properties == NULL)
goto error_properties;
pw_properties_add(properties, &context->properties->dict);
p->proxy.core = p;
p->context = context;
p->properties = properties;
p->pool = pw_mempool_new(NULL);
p->core = p;
if (user_data_size > 0)
p->user_data = SPA_MEMBER(p, sizeof(struct pw_core), void);
p->proxy.user_data = p->user_data;
pw_map_init(&p->objects, 64, 32);
spa_list_init(&p->stream_list);
spa_list_init(&p->filter_list);
if ((protocol_name = pw_properties_get(properties, PW_KEY_PROTOCOL)) == NULL &&
(protocol_name = pw_properties_get(context->properties, PW_KEY_PROTOCOL)) == NULL)
protocol_name = PW_TYPE_INFO_PROTOCOL_Native;
protocol = pw_context_find_protocol(context, protocol_name);
if (protocol == NULL) {
res = -ENOTSUP;
goto error_protocol;
}
p->conn = pw_protocol_new_client(protocol, p, &properties->dict);
if (p->conn == NULL)
goto error_connection;
if ((res = pw_proxy_init(&p->proxy, PW_TYPE_INTERFACE_Core, PW_VERSION_CORE)) < 0)
goto error_proxy;
p->client = (struct pw_client*)pw_proxy_new(&p->proxy,
PW_TYPE_INTERFACE_Client, PW_VERSION_CLIENT, 0);
if (p->client == NULL) {
res = -errno;
goto error_proxy;
}
pw_core_add_listener(p, &p->core_listener, &core_events, p);
pw_proxy_add_listener(&p->proxy, &p->proxy_core_listener, &proxy_core_events, p);
pw_core_hello(p, PW_VERSION_CORE);
pw_client_update_properties(p->client, &p->properties->dict);
spa_list_append(&context->core_list, &p->link);
return p;
error_properties:
res = -errno;
pw_log_error(NAME" %p: can't create properties: %m", p);
goto exit_free;
error_protocol:
pw_log_error(NAME" %p: can't find native protocol: %s", p, spa_strerror(res));
goto exit_free;
error_connection:
res = -errno;
pw_log_error(NAME" %p: can't create new native protocol connection: %m", p);
goto exit_free;
error_proxy:
pw_log_error(NAME" %p: can't initialize proxy: %s", p, spa_strerror(res));
goto exit_free;
exit_free:
free(p);
exit_cleanup:
if (properties)
pw_properties_free(properties);
errno = -res;
return NULL;
}
SPA_EXPORT
struct pw_core *
pw_context_connect(struct pw_context *context, struct pw_properties *properties,
size_t user_data_size)
{
struct pw_core *core;
int res;
core = core_new(context, properties, user_data_size);
if (core == NULL)
return NULL;
pw_log_debug(NAME" %p: connect", core);
if ((res = pw_protocol_client_connect(core->conn,
&core->properties->dict,
NULL, NULL)) < 0)
goto error_free;
return core;
error_free:
pw_core_disconnect(core);
errno = -res;
return NULL;
}
SPA_EXPORT
struct pw_core *
pw_context_connect_fd(struct pw_context *context, int fd, struct pw_properties *properties,
size_t user_data_size)
{
struct pw_core *core;
int res;
core = core_new(context, properties, user_data_size);
if (core == NULL)
return NULL;
pw_log_debug(NAME" %p: connect fd:%d", core, fd);
if ((res = pw_protocol_client_connect_fd(core->conn, fd, true)) < 0)
goto error_free;
return core;
error_free:
pw_core_disconnect(core);
errno = -res;
return NULL;
}
SPA_EXPORT
struct pw_core *
pw_context_connect_self(struct pw_context *context, struct pw_properties *properties,
size_t user_data_size)
{
if (properties == NULL)
properties = pw_properties_new(NULL, NULL);
if (properties == NULL)
return NULL;
pw_properties_set(properties, PW_KEY_REMOTE_NAME, "internal");
return pw_context_connect(context, properties, user_data_size);
}
SPA_EXPORT
int pw_core_steal_fd(struct pw_core *core)
{
int fd = pw_protocol_client_steal_fd(core->conn);
pw_log_debug(NAME" %p: fd:%d", core, fd);
return fd;
}
SPA_EXPORT
int pw_core_set_paused(struct pw_core *core, bool paused)
{
pw_log_debug(NAME" %p: state:%s", core, paused ? "pause" : "resume");
return pw_protocol_client_set_paused(core->conn, paused);
}
SPA_EXPORT
struct pw_mempool * pw_core_get_mempool(struct pw_core *core)
{
return core->pool;
}
SPA_EXPORT
int pw_core_disconnect(struct pw_core *core)
{
pw_log_debug(NAME" %p: disconnect", core);
pw_proxy_remove(&core->proxy);
pw_proxy_destroy(&core->proxy);
return 0;
}
| {
"pile_set_name": "Github"
} |
๏ปฟ/*
Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.plugins.setLang("devtools","en-au",{title:"Element Information",dialogName:"Dialog window name",tabName:"Tab name",elementId:"Element ID",elementType:"Element type"}); | {
"pile_set_name": "Github"
} |
<?php
/*
* UserFrosting (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/UserFrosting
* @copyright Copyright (c) 2019 Alexander Weissman
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
*/
/**
* Thai message token translations for the 'account' sprinkle.
*
* @author Karuhut Komol
* @author Atthaphon Urairat
*/
return [
'VALIDATE' => [
'PASSWORD_MISMATCH' => 'เธฃเธซเธฑเธชเธเนเธฒเธเนเธฅเธฐเธฃเธซเธฑเธชเธเนเธฒเธเธขเธทเธเธขเธฑเธเธเธญเธเธเธธเธเธเธฐเธเนเธญเธเธเธฃเธเธเธฑเธ',
'USERNAME' => 'เธเธทเนเธญเธเธนเนเนเธเนเธเธฐเธเนเธญเธเธเธฃเธฐเธเธญเธเธเนเธงเธขเธเธฑเธงเธญเธฑเธเธฉเธฃเธเธฑเธงเนเธฅเนเธ เธเธฑเธงเนเธฅเธ \'.\', \'-\' เนเธฅเธฐ \'_\' เนเธเธตเธขเธเนเธเนเธฒเธเธฑเนเธ',
],
];
| {
"pile_set_name": "Github"
} |
/* -----------------------------------------------------------------------
unix.S - Copyright (c) 1998, 2008 Red Hat, Inc.
Copyright (c) 2000 Hewlett Packard Company
IA64/unix Foreign Function Interface
Primary author: Hans Boehm, HP Labs
Loosely modeled on Cygnus code for other platforms.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
#include "ia64_flags.h"
.pred.safe_across_calls p1-p5,p16-p63
.text
/* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue,
void (*fn)(void), int flags);
*/
.align 16
.global ffi_call_unix
.proc ffi_call_unix
ffi_call_unix:
.prologue
/* Bit o trickiness. We actually share a stack frame with ffi_call.
Rely on the fact that ffi_call uses a vframe and don't bother
tracking one here at all. */
.fframe 0
.save ar.pfs, r36 // loc0
alloc loc0 = ar.pfs, 4, 3, 8, 0
.save rp, loc1
mov loc1 = b0
.body
add r16 = 16, in0
mov loc2 = gp
mov r8 = in1
;;
/* Load up all of the argument registers. */
ldf.fill f8 = [in0], 32
ldf.fill f9 = [r16], 32
;;
ldf.fill f10 = [in0], 32
ldf.fill f11 = [r16], 32
;;
ldf.fill f12 = [in0], 32
ldf.fill f13 = [r16], 32
;;
ldf.fill f14 = [in0], 32
ldf.fill f15 = [r16], 24
;;
ld8 out0 = [in0], 16
ld8 out1 = [r16], 16
;;
ld8 out2 = [in0], 16
ld8 out3 = [r16], 16
;;
ld8 out4 = [in0], 16
ld8 out5 = [r16], 16
;;
ld8 out6 = [in0]
ld8 out7 = [r16]
;;
/* Deallocate the register save area from the stack frame. */
mov sp = in0
/* Call the target function. */
ld8 r16 = [in2], 8
;;
ld8 gp = [in2]
mov b6 = r16
br.call.sptk.many b0 = b6
;;
/* Dispatch to handle return value. */
mov gp = loc2
zxt1 r16 = in3
;;
mov ar.pfs = loc0
addl r18 = @ltoffx(.Lst_table), gp
;;
ld8.mov r18 = [r18], .Lst_table
mov b0 = loc1
;;
shladd r18 = r16, 3, r18
;;
ld8 r17 = [r18]
shr in3 = in3, 8
;;
add r17 = r17, r18
;;
mov b6 = r17
br b6
;;
.Lst_void:
br.ret.sptk.many b0
;;
.Lst_uint8:
zxt1 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_sint8:
sxt1 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_uint16:
zxt2 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_sint16:
sxt2 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_uint32:
zxt4 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_sint32:
sxt4 r8 = r8
;;
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_int64:
st8 [in1] = r8
br.ret.sptk.many b0
;;
.Lst_float:
stfs [in1] = f8
br.ret.sptk.many b0
;;
.Lst_double:
stfd [in1] = f8
br.ret.sptk.many b0
;;
.Lst_ldouble:
stfe [in1] = f8
br.ret.sptk.many b0
;;
.Lst_small_struct:
add sp = -16, sp
cmp.lt p6, p0 = 8, in3
cmp.lt p7, p0 = 16, in3
cmp.lt p8, p0 = 24, in3
;;
add r16 = 8, sp
add r17 = 16, sp
add r18 = 24, sp
;;
st8 [sp] = r8
(p6) st8 [r16] = r9
mov out0 = in1
(p7) st8 [r17] = r10
(p8) st8 [r18] = r11
mov out1 = sp
mov out2 = in3
br.call.sptk.many b0 = memcpy#
;;
mov ar.pfs = loc0
mov b0 = loc1
mov gp = loc2
br.ret.sptk.many b0
.Lst_hfa_float:
add r16 = 4, in1
cmp.lt p6, p0 = 4, in3
;;
stfs [in1] = f8, 8
(p6) stfs [r16] = f9, 8
cmp.lt p7, p0 = 8, in3
cmp.lt p8, p0 = 12, in3
;;
(p7) stfs [in1] = f10, 8
(p8) stfs [r16] = f11, 8
cmp.lt p9, p0 = 16, in3
cmp.lt p10, p0 = 20, in3
;;
(p9) stfs [in1] = f12, 8
(p10) stfs [r16] = f13, 8
cmp.lt p6, p0 = 24, in3
cmp.lt p7, p0 = 28, in3
;;
(p6) stfs [in1] = f14
(p7) stfs [r16] = f15
br.ret.sptk.many b0
;;
.Lst_hfa_double:
add r16 = 8, in1
cmp.lt p6, p0 = 8, in3
;;
stfd [in1] = f8, 16
(p6) stfd [r16] = f9, 16
cmp.lt p7, p0 = 16, in3
cmp.lt p8, p0 = 24, in3
;;
(p7) stfd [in1] = f10, 16
(p8) stfd [r16] = f11, 16
cmp.lt p9, p0 = 32, in3
cmp.lt p10, p0 = 40, in3
;;
(p9) stfd [in1] = f12, 16
(p10) stfd [r16] = f13, 16
cmp.lt p6, p0 = 48, in3
cmp.lt p7, p0 = 56, in3
;;
(p6) stfd [in1] = f14
(p7) stfd [r16] = f15
br.ret.sptk.many b0
;;
.Lst_hfa_ldouble:
add r16 = 16, in1
cmp.lt p6, p0 = 16, in3
;;
stfe [in1] = f8, 32
(p6) stfe [r16] = f9, 32
cmp.lt p7, p0 = 32, in3
cmp.lt p8, p0 = 48, in3
;;
(p7) stfe [in1] = f10, 32
(p8) stfe [r16] = f11, 32
cmp.lt p9, p0 = 64, in3
cmp.lt p10, p0 = 80, in3
;;
(p9) stfe [in1] = f12, 32
(p10) stfe [r16] = f13, 32
cmp.lt p6, p0 = 96, in3
cmp.lt p7, p0 = 112, in3
;;
(p6) stfe [in1] = f14
(p7) stfe [r16] = f15
br.ret.sptk.many b0
;;
.endp ffi_call_unix
.align 16
.global ffi_closure_unix
.proc ffi_closure_unix
#define FRAME_SIZE (8*16 + 8*8 + 8*16)
ffi_closure_unix:
.prologue
.save ar.pfs, r40 // loc0
alloc loc0 = ar.pfs, 8, 4, 4, 0
.fframe FRAME_SIZE
add r12 = -FRAME_SIZE, r12
.save rp, loc1
mov loc1 = b0
.save ar.unat, loc2
mov loc2 = ar.unat
.body
/* Retrieve closure pointer and real gp. */
#ifdef _ILP32
addp4 out0 = 0, gp
addp4 gp = 16, gp
#else
mov out0 = gp
add gp = 16, gp
#endif
;;
ld8 gp = [gp]
/* Spill all of the possible argument registers. */
add r16 = 16 + 8*16, sp
add r17 = 16 + 8*16 + 16, sp
;;
stf.spill [r16] = f8, 32
stf.spill [r17] = f9, 32
mov loc3 = gp
;;
stf.spill [r16] = f10, 32
stf.spill [r17] = f11, 32
;;
stf.spill [r16] = f12, 32
stf.spill [r17] = f13, 32
;;
stf.spill [r16] = f14, 32
stf.spill [r17] = f15, 24
;;
.mem.offset 0, 0
st8.spill [r16] = in0, 16
.mem.offset 8, 0
st8.spill [r17] = in1, 16
add out1 = 16 + 8*16, sp
;;
.mem.offset 0, 0
st8.spill [r16] = in2, 16
.mem.offset 8, 0
st8.spill [r17] = in3, 16
add out2 = 16, sp
;;
.mem.offset 0, 0
st8.spill [r16] = in4, 16
.mem.offset 8, 0
st8.spill [r17] = in5, 16
mov out3 = r8
;;
.mem.offset 0, 0
st8.spill [r16] = in6
.mem.offset 8, 0
st8.spill [r17] = in7
/* Invoke ffi_closure_unix_inner for the hard work. */
br.call.sptk.many b0 = ffi_closure_unix_inner
;;
/* Dispatch to handle return value. */
mov gp = loc3
zxt1 r16 = r8
;;
addl r18 = @ltoffx(.Lld_table), gp
mov ar.pfs = loc0
;;
ld8.mov r18 = [r18], .Lld_table
mov b0 = loc1
;;
shladd r18 = r16, 3, r18
mov ar.unat = loc2
;;
ld8 r17 = [r18]
shr r8 = r8, 8
;;
add r17 = r17, r18
add r16 = 16, sp
;;
mov b6 = r17
br b6
;;
.label_state 1
.Lld_void:
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_int:
.body
.copy_state 1
ld8 r8 = [r16]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_float:
.body
.copy_state 1
ldfs f8 = [r16]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_double:
.body
.copy_state 1
ldfd f8 = [r16]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_ldouble:
.body
.copy_state 1
ldfe f8 = [r16]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_small_struct:
.body
.copy_state 1
add r17 = 8, r16
cmp.lt p6, p0 = 8, r8
cmp.lt p7, p0 = 16, r8
cmp.lt p8, p0 = 24, r8
;;
ld8 r8 = [r16], 16
(p6) ld8 r9 = [r17], 16
;;
(p7) ld8 r10 = [r16]
(p8) ld8 r11 = [r17]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_hfa_float:
.body
.copy_state 1
add r17 = 4, r16
cmp.lt p6, p0 = 4, r8
;;
ldfs f8 = [r16], 8
(p6) ldfs f9 = [r17], 8
cmp.lt p7, p0 = 8, r8
cmp.lt p8, p0 = 12, r8
;;
(p7) ldfs f10 = [r16], 8
(p8) ldfs f11 = [r17], 8
cmp.lt p9, p0 = 16, r8
cmp.lt p10, p0 = 20, r8
;;
(p9) ldfs f12 = [r16], 8
(p10) ldfs f13 = [r17], 8
cmp.lt p6, p0 = 24, r8
cmp.lt p7, p0 = 28, r8
;;
(p6) ldfs f14 = [r16]
(p7) ldfs f15 = [r17]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_hfa_double:
.body
.copy_state 1
add r17 = 8, r16
cmp.lt p6, p0 = 8, r8
;;
ldfd f8 = [r16], 16
(p6) ldfd f9 = [r17], 16
cmp.lt p7, p0 = 16, r8
cmp.lt p8, p0 = 24, r8
;;
(p7) ldfd f10 = [r16], 16
(p8) ldfd f11 = [r17], 16
cmp.lt p9, p0 = 32, r8
cmp.lt p10, p0 = 40, r8
;;
(p9) ldfd f12 = [r16], 16
(p10) ldfd f13 = [r17], 16
cmp.lt p6, p0 = 48, r8
cmp.lt p7, p0 = 56, r8
;;
(p6) ldfd f14 = [r16]
(p7) ldfd f15 = [r17]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.Lld_hfa_ldouble:
.body
.copy_state 1
add r17 = 16, r16
cmp.lt p6, p0 = 16, r8
;;
ldfe f8 = [r16], 32
(p6) ldfe f9 = [r17], 32
cmp.lt p7, p0 = 32, r8
cmp.lt p8, p0 = 48, r8
;;
(p7) ldfe f10 = [r16], 32
(p8) ldfe f11 = [r17], 32
cmp.lt p9, p0 = 64, r8
cmp.lt p10, p0 = 80, r8
;;
(p9) ldfe f12 = [r16], 32
(p10) ldfe f13 = [r17], 32
cmp.lt p6, p0 = 96, r8
cmp.lt p7, p0 = 112, r8
;;
(p6) ldfe f14 = [r16]
(p7) ldfe f15 = [r17]
.restore sp
add sp = FRAME_SIZE, sp
br.ret.sptk.many b0
;;
.endp ffi_closure_unix
.section .rodata
.align 8
.Lst_table:
data8 @pcrel(.Lst_void) // FFI_TYPE_VOID
data8 @pcrel(.Lst_sint32) // FFI_TYPE_INT
data8 @pcrel(.Lst_float) // FFI_TYPE_FLOAT
data8 @pcrel(.Lst_double) // FFI_TYPE_DOUBLE
data8 @pcrel(.Lst_ldouble) // FFI_TYPE_LONGDOUBLE
data8 @pcrel(.Lst_uint8) // FFI_TYPE_UINT8
data8 @pcrel(.Lst_sint8) // FFI_TYPE_SINT8
data8 @pcrel(.Lst_uint16) // FFI_TYPE_UINT16
data8 @pcrel(.Lst_sint16) // FFI_TYPE_SINT16
data8 @pcrel(.Lst_uint32) // FFI_TYPE_UINT32
data8 @pcrel(.Lst_sint32) // FFI_TYPE_SINT32
data8 @pcrel(.Lst_int64) // FFI_TYPE_UINT64
data8 @pcrel(.Lst_int64) // FFI_TYPE_SINT64
data8 @pcrel(.Lst_void) // FFI_TYPE_STRUCT
data8 @pcrel(.Lst_int64) // FFI_TYPE_POINTER
data8 @pcrel(.Lst_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT
data8 @pcrel(.Lst_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT
data8 @pcrel(.Lst_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE
data8 @pcrel(.Lst_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE
.Lld_table:
data8 @pcrel(.Lld_void) // FFI_TYPE_VOID
data8 @pcrel(.Lld_int) // FFI_TYPE_INT
data8 @pcrel(.Lld_float) // FFI_TYPE_FLOAT
data8 @pcrel(.Lld_double) // FFI_TYPE_DOUBLE
data8 @pcrel(.Lld_ldouble) // FFI_TYPE_LONGDOUBLE
data8 @pcrel(.Lld_int) // FFI_TYPE_UINT8
data8 @pcrel(.Lld_int) // FFI_TYPE_SINT8
data8 @pcrel(.Lld_int) // FFI_TYPE_UINT16
data8 @pcrel(.Lld_int) // FFI_TYPE_SINT16
data8 @pcrel(.Lld_int) // FFI_TYPE_UINT32
data8 @pcrel(.Lld_int) // FFI_TYPE_SINT32
data8 @pcrel(.Lld_int) // FFI_TYPE_UINT64
data8 @pcrel(.Lld_int) // FFI_TYPE_SINT64
data8 @pcrel(.Lld_void) // FFI_TYPE_STRUCT
data8 @pcrel(.Lld_int) // FFI_TYPE_POINTER
data8 @pcrel(.Lld_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT
data8 @pcrel(.Lld_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT
data8 @pcrel(.Lld_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE
data8 @pcrel(.Lld_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
#endif
| {
"pile_set_name": "Github"
} |
'\" t
'\" The line above instructs most `man' programs to invoke tbl
'\"
'\" Separate paragraphs; not the same as PP which resets indent level.
.de SP
.if t .sp .5
.if n .sp
..
'\"
'\" Replacement em-dash for nroff (default is too short).
.ie n .ds m " -
.el .ds m \(em
'\"
'\" Placeholder macro for if longer nroff arrow is needed.
.ds RA \(->
'\"
'\" Decimal point set slightly raised
.if t .ds d \v'-.15m'.\v'+.15m'
.if n .ds d .
'\"
'\" Enclosure macro for examples
.de EX
.SP
.nf
.ft CW
..
.de EE
.ft R
.SP
.fi
..
.TH j2k_to_image 1 "Version 1.4.0" "j2k_to_image" "converts jpeg2000 files"
.P
.SH NAME
j2k_to_image -
This program reads in a jpeg2000 image and converts it to another
image type. It is part of the OpenJPEG library.
.SP
Valid input image extensions are
.B .j2k, .jp2, .j2c, .jpt
.SP
Valid output image extensions are
.B .bmp, .pgm, .pgx, .png, .pnm, .ppm, .raw, .tga, .tif \fR. For PNG resp. TIF it needs libpng resp. libtiff .
.SH SYNOPSIS
.P
.B j2k_to_image -i \fRinfile.j2k \fB-o \fRoutfile.png
.P
.B j2k_to_image -ImgDir \fRimages/ \fB-OutFor \fRbmp
.P
.B j2k_to_image -h \fRPrint help message and exit
.P
.R See JPWL OPTIONS for special options
.SH OPTIONS
.TP
.B \-\^i "name"
(jpeg2000 input file name)
.TP
.B \-\^l "n"
n is the maximum number of quality layers to decode. See LAYERS below)
.TP
.B \-\^o "name"
(output file name with extension)
.TP
.B \-\^r "n"
(n is the highest resolution level to be discarded. See REDUCTION below)
.TP
.B \-\^x "name"
(use name as index file and fill it)
.TP
.B \-\^ImgDir "directory_name"
(directory containing input files)
.TP
.B \-\^OutFor "ext"
(extension for output files)
.P
.SH JPWL OPTIONS
Options usable only if the library has been compiled with
.B -DUSE_JPWL
.TP
.B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3)
.TP
.B -W t\fR[=Nt] (Nt is the maximum number of tiles in the codestream; default:8192)
.TP
.B -W c\fR[=Nc]\fB, t\fR[=Nt] \fR(same as above)
.P
.SH REDUCTION
Set the number of highest resolution levels to be discarded.
The image resolution is effectively divided by 2 to the power of the number of discarded levels. The reduce factor is limited by the smallest total number of decomposition levels among tiles.
.SH TILES
Set the maximum number of quality layers to decode. If there are less quality layers than the specified number, all the quality layers are decoded.
.P
'\".SH BUGS
.SH AUTHORS
Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
.br
Copyright (c) 2002-2007, Professor Benoit Macq
.br
Copyright (c) 2001-2003, David Janssens
.br
Copyright (c) 2002-2003, Yannick Verschueren
.br
Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
.br
Copyright (c) 2005, Herve Drolon, FreeImage Team
.br
Copyright (c) 2006-2007, Parvatha Elangovan
.P
.SH "SEE ALSO"
image_to_j2k(1) j2k_dump(1)
| {
"pile_set_name": "Github"
} |
# ุงุฎุชุจุงุฑ Widevine CDM
In Electron you can use the Widevine CDM library shipped with Chrome browser.
Widevine Content Decryption Modules (CDMs) are how streaming services protect content using HTML5 video to web browsers without relying on an NPAPI plugin like Flash or Silverlight. Widevine support is an alternative solution for streaming services that currently rely on Silverlight for playback of DRM-protected video content. It will allow websites to show DRM-protected video content in Firefox without the use of NPAPI plugins. The Widevine CDM runs in an open-source CDM sandbox providing better user security than NPAPI plugins.
#### Note on VMP
As of [`Electron v1.8.0 (Chrome v59)`](https://electronjs.org/releases#1.8.1), the below steps are may only be some of the necessary steps to enable Widevine; any app on or after that version intending to use the Widevine CDM may need to be signed using a license obtained from [Widevine](https://www.widevine.com/) itself.
Per [Widevine](https://www.widevine.com/):
> Chrome 59 (and later) includes support for Verified Media Path (VMP). VMP provides a method to verify the authenticity of a device platform. For browser deployments, this will provide an additional signal to determine if a browser-based implementation is reliable and secure.
>
> The proxy integration guide has been updated with information about VMP and how to issue licenses.
>
> Widevine recommends our browser-based integrations (vendors and browser-based applications) add support for VMP.
To enable video playback with this new restriction, [castLabs](https://castlabs.com/open-source/downstream/) has created a [fork](https://github.com/castlabs/electron-releases) that has implemented the necessary changes to enable Widevine to be played in an Electron application if one has obtained the necessary licenses from widevine.
## Getting the library
Open `chrome://components/` in Chrome browser, find `Widevine Content Decryption Module` and make sure it is up to date, then you can find the library files from the application directory.
### On Windows
The library file `widevinecdm.dll` will be under `Program Files(x86)/Google/Chrome/Application/CHROME_VERSION/WidevineCdm/_platform_specific/win_(x86|x64)/` directory.
### ูู macOS
The library file `libwidevinecdm.dylib` will be under `/Applications/Google Chrome.app/Contents/Versions/CHROME_VERSION/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_(x86|x64)/` directory.
**Note:** Make sure that chrome version used by Electron is greater than or equal to the `min_chrome_version` value of Chrome's widevine cdm component. The value can be found in `manifest.json` under `WidevineCdm` directory.
## Using the library
After getting the library files, you should pass the path to the file with `--widevine-cdm-path` command line switch, and the library's version with `--widevine-cdm-version` switch. The command line switches have to be passed before the `ready` event of `app` module gets emitted.
Example code:
```javascript
const { app, BrowserWindow } = require('electron')
// You have to pass the directory that contains widevine library here, it is
// * `libwidevinecdm.dylib` on macOS,
// * `widevinecdm.dll` on Windows.
app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevine_library')
// The version of plugin can be got from `chrome://components` page in Chrome.
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866')
let win = null
app.whenReady().then(() => {
win = new BrowserWindow()
win.show()
})
```
## Verifying Widevine CDM support
To verify whether widevine works, you can use following ways:
* Open https://shaka-player-demo.appspot.com/ and load a manifest that uses `Widevine`.
* Open http://www.dash-player.com/demo/drm-test-area/, check whether the page says `bitdash uses Widevine in your browser`, then play the video.
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2019 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.numkt.math
import org.jetbrains.numkt.callFunc
import org.jetbrains.numkt.core.KtNDArray
import org.jetbrains.numkt.core.None
/**
* Returns the discrete, linear convolution of two one-dimensional sequences.
*/
fun <T : Number, E : Number> convolve(a: KtNDArray<T>, v: KtNDArray<E>, mode: String = "full"): KtNDArray<E> =
callFunc(nameMethod = arrayOf("convolve"), args = arrayOf(a, v, mode))
/**
* Clip (limit) the values in an array.
*/
fun <T : Number> clip(a: KtNDArray<T>, aMin: T?, aMax: T?): KtNDArray<T> =
callFunc(nameMethod = arrayOf("clip"), args = arrayOf(a, aMin ?: None.none, aMax ?: None.none))
/**
* Return the non-negative square-root of an array, element-wise.
*/
fun <T : Number> sqrt(x: KtNDArray<T>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("sqrt"), args = arrayOf(x), dtype = Double::class)
/**
* Return the cube-root of an array, element-wise.
*/
fun <T : Number> cbrt(x: KtNDArray<T>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("cbrt"), args = arrayOf(x), dtype = Double::class)
/**
* Return the element-wise square of the input.
*/
fun <T : Number> square(x: KtNDArray<T>): KtNDArray<T> =
callFunc(nameMethod = arrayOf("square"), args = arrayOf(x))
/**
* Calculate the absolute value element-wise.
*/
fun <T : Number> absolute(x: KtNDArray<T>): KtNDArray<T> =
callFunc(nameMethod = arrayOf("absolute"), args = arrayOf(x))
/**
* Compute the absolute values element-wise.
*/
fun <T : Number> fabs(x: KtNDArray<T>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("fabs"), args = arrayOf(x), dtype = Double::class)
/**
* Returns an element-wise indication of the sign of a number.
*/
fun <T : Number> sign(x: KtNDArray<T>): KtNDArray<T> =
callFunc(nameMethod = arrayOf("sign"), args = arrayOf(x))
/**
* Compute the Heaviside step function.
*/
fun <T : Number, E : Number> heaviside(x1: KtNDArray<T>, x2: KtNDArray<E>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("heaviside"), args = arrayOf(x1, x2), dtype = Double::class)
/**
* Element-wise maximum of array elements.
*/
fun <T : Number> maximum(x1: KtNDArray<T>, x2: KtNDArray<T>): KtNDArray<T> =
callFunc(nameMethod = arrayOf("maximum"), args = arrayOf(x1, x2))
/**
* Element-wise minimum of array elements.
*/
fun <T : Number> minimum(x1: KtNDArray<T>, x2: KtNDArray<T>): KtNDArray<T> =
callFunc(nameMethod = arrayOf("minimum"), args = arrayOf(x1, x2))
/**
* Element-wise maximum of array elements.
*/
fun <T : Number, E : Number> fmax(x1: KtNDArray<T>, x2: KtNDArray<E>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("fmax"), args = arrayOf(x1, x2), dtype = Double::class)
/**
* Element-wise minimum of array elements.
*/
fun <T : Number, E : Number> fmin(x1: KtNDArray<T>, x2: KtNDArray<E>): KtNDArray<Double> =
callFunc(nameMethod = arrayOf("fmin"), args = arrayOf(x1, x2), dtype = Double::class)
/**
* Replace NaN with zero and infinity with large finite numbers (default behaviour).
*/
fun <T : Number> nanToNum(
x: KtNDArray<T>,
nan: Double = 0.0,
posinf: Double? = null,
neginf: Double? = null
): KtNDArray<T> =
callFunc(nameMethod = arrayOf("nan_to_num"), args = arrayOf(x, nan, posinf ?: None.none, neginf ?: None.none))
/**
* One-dimensional linear interpolation.
*/
fun <T : Number, E : Number, R : Number> interp(
x: KtNDArray<T>,
xp: KtNDArray<E>,
fp: KtNDArray<R>,
left: Double? = null,
right: Double? = null,
period: Double? = null
): KtNDArray<Double> =
callFunc(
nameMethod = arrayOf("interp"),
args = arrayOf(x, xp, fp, left ?: None.none, right ?: None.none, period ?: None.none)
) | {
"pile_set_name": "Github"
} |
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/base/file_stream_metrics.h"
namespace net {
int GetFileErrorUmaBucket(int error) {
return 1;
}
int MaxFileErrorUmaBucket() {
return 2;
}
int MaxFileErrorUmaValue() {
return 160;
}
} // namespace net
| {
"pile_set_name": "Github"
} |
// Copyright 2014 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.shell;
import com.google.common.annotations.VisibleForTesting;
import java.time.Duration;
import java.util.Optional;
/**
* Represents the termination status of a command. {@link Process#waitFor} is
* not very precisely specified, so this class encapsulates the interpretation
* of values returned by it.
*
* Caveat: due to the lossy encoding, it's not always possible to accurately
* distinguish signal and exit cases. In particular, processes that exit with
* a value within the interval [129, 191] will be mistaken for having been
* terminated by a signal.
*
* Instances are immutable.
*/
public final class TerminationStatus {
private final int waitResult;
private final boolean timedOut;
private final Optional<Duration> wallExecutionTime;
private final Optional<Duration> userExecutionTime;
private final Optional<Duration> systemExecutionTime;
/**
* Values taken from the glibc strsignal(3) function.
*/
private static final String[] SIGNAL_STRINGS = {
null,
"Hangup",
"Interrupt",
"Quit",
"Illegal instruction",
"Trace/breakpoint trap",
"Aborted",
"Bus error",
"Floating point exception",
"Killed",
"User defined signal 1",
"Segmentation fault",
"User defined signal 2",
"Broken pipe",
"Alarm clock",
"Terminated",
"Stack fault",
"Child exited",
"Continued",
"Stopped (signal)",
"Stopped",
"Stopped (tty input)",
"Stopped (tty output)",
"Urgent I/O condition",
"CPU time limit exceeded",
"File size limit exceeded",
"Virtual timer expired",
"Profiling timer expired",
"Window changed",
"I/O possible",
"Power failure",
"Bad system call",
};
private static String getSignalString(int signum) {
return signum > 0 && signum < SIGNAL_STRINGS.length
? SIGNAL_STRINGS[signum]
: "Signal " + signum;
}
/**
* Construct a TerminationStatus instance from a Process waitFor code.
*
* @param waitResult the value returned by {@link java.lang.Process#waitFor}.
* @param timedOut whether the execution timed out
*/
public TerminationStatus(int waitResult, boolean timedOut) {
this(waitResult, timedOut, Optional.empty(), Optional.empty(), Optional.empty());
}
/**
* Construct a TerminationStatus instance from a Process waitFor code.
*
* <p>TerminationStatus objects are considered equal if they have the same waitResult.
*
* @param waitResult the value returned by {@link java.lang.Process#waitFor}.
* @param timedOut whether the execution timed out
* @param wallExecutionTime the wall execution time of the command, if available
* @param userExecutionTime the user execution time of the command, if available
* @param systemExecutionTime the system execution time of the command, if available
*/
public TerminationStatus(
int waitResult,
boolean timedOut,
Optional<Duration> wallExecutionTime,
Optional<Duration> userExecutionTime,
Optional<Duration> systemExecutionTime) {
this.waitResult = waitResult;
this.timedOut = timedOut;
this.wallExecutionTime = wallExecutionTime;
this.userExecutionTime = userExecutionTime;
this.systemExecutionTime = systemExecutionTime;
}
/**
* Returns the exit code returned by the subprocess.
*/
public int getRawExitCode() {
return waitResult;
}
/**
* Returns true iff the process exited with code 0.
*/
public boolean success() {
return exited() && getExitCode() == 0;
}
// We're relying on undocumented behaviour of Process.waitFor, specifically
// that waitResult is the exit status when the process returns normally, or
// 128+signalnumber when the process is terminated by a signal. We further
// assume that value signal numbers fall in the interval [1, 63].
@VisibleForTesting static final int SIGNAL_1 = 128 + 1;
@VisibleForTesting static final int SIGNAL_63 = 128 + 63;
@VisibleForTesting static final int SIGNAL_SIGABRT = 128 + 6;
@VisibleForTesting static final int SIGNAL_SIGKILL = 128 + 9;
@VisibleForTesting static final int SIGNAL_SIGBUS = 128 + 10;
@VisibleForTesting static final int SIGNAL_SIGTERM = 128 + 15;
/**
* Returns true if the given exit code represents a crash.
*
* <p>This is a static function that processes a raw exit status because that's all the
* information that we have around in the single use case of this function. Propagating a {@link
* TerminationStatus} object to that point would be costly. If this function is needed for
* anything else, then this should be reevaluated.
*/
public static boolean crashed(int rawStatus) {
return rawStatus == SIGNAL_SIGABRT || rawStatus == SIGNAL_SIGBUS;
}
/** Returns true iff the process exited normally. */
public boolean exited() {
return !timedOut && (waitResult < SIGNAL_1 || waitResult > SIGNAL_63);
}
/** Returns true if the process timed out. */
public boolean timedOut() {
return timedOut;
}
/**
* Returns the exit code of the subprocess. Undefined if exited() is false.
*/
public int getExitCode() {
if (!exited()) {
throw new IllegalStateException("getExitCode() not defined");
}
return waitResult;
}
/**
* Returns the number of the signal that terminated the process. Undefined
* if exited() returns true.
*/
public int getTerminatingSignal() {
if (exited() || timedOut) {
throw new IllegalStateException("getTerminatingSignal() not defined");
}
return waitResult - SIGNAL_1 + 1;
}
/**
* Returns the wall execution time.
*
* @return the measurement, or empty in case of execution errors or when the measurement is not
* implemented for the current platform
*/
public Optional<Duration> getWallExecutionTime() {
return wallExecutionTime;
}
/**
* Returns the user execution time.
*
* @return the measurement, or empty in case of execution errors or when the measurement is not
* implemented for the current platform
*/
public Optional<Duration> getUserExecutionTime() {
return userExecutionTime;
}
/**
* Returns the system execution time.
*
* @return the measurement, or empty in case of execution errors or when the measurement is not
* implemented for the current platform
*/
public Optional<Duration> getSystemExecutionTime() {
return systemExecutionTime;
}
/**
* Returns a short string describing the termination status.
* e.g. "Exit 1" or "Hangup".
*/
public String toShortString() {
return exited()
? "Exit " + getExitCode()
: (timedOut ? "Timeout" : getSignalString(getTerminatingSignal()));
}
@Override
public String toString() {
if (exited()) {
return "Process exited with status " + getExitCode();
} else if (timedOut) {
return "Timed out";
} else {
return "Process terminated by signal " + getTerminatingSignal();
}
}
@Override
public int hashCode() {
return waitResult;
}
@Override
public boolean equals(Object other) {
return other instanceof TerminationStatus
&& ((TerminationStatus) other).waitResult == this.waitResult;
}
/** Returns a new {@link TerminationStatus.Builder}. */
public static Builder builder() {
return new TerminationStatus.Builder();
}
/** Builder for {@link TerminationStatus} objects. */
public static class Builder {
// We use nullness here instead of Optional to avoid confusion between fields that may not
// yet have been set from fields that can legitimately hold an Optional value in the built
// object.
private Integer waitResponse = null;
private Boolean timedOut = null;
private Optional<Duration> wallExecutionTime = Optional.empty();
private Optional<Duration> userExecutionTime = Optional.empty();
private Optional<Duration> systemExecutionTime = Optional.empty();
/** Sets the value returned by {@link java.lang.Process#waitFor}. */
public Builder setWaitResponse(int waitResponse) {
this.waitResponse = waitResponse;
return this;
}
/** Sets whether the action timed out or not. */
public Builder setTimedOut(boolean timedOut) {
this.timedOut = timedOut;
return this;
}
/** Sets the wall execution time. */
public Builder setWallExecutionTime(Duration wallExecutionTime) {
this.wallExecutionTime = Optional.of(wallExecutionTime);
return this;
}
/** Sets or clears the wall execution time. */
public Builder setWallExecutionTime(Optional<Duration> wallExecutionTime) {
this.wallExecutionTime = wallExecutionTime;
return this;
}
/** Sets the user execution time. */
public Builder setUserExecutionTime(Duration userExecutionTime) {
this.userExecutionTime = Optional.of(userExecutionTime);
return this;
}
/** Sets or clears the user execution time. */
public Builder setUserExecutionTime(Optional<Duration> userExecutionTime) {
this.userExecutionTime = userExecutionTime;
return this;
}
/** Sets the system execution time. */
public Builder setSystemExecutionTime(Duration systemExecutionTime) {
this.systemExecutionTime = Optional.of(systemExecutionTime);
return this;
}
/** Sets or clears the system execution time. */
public Builder setSystemExecutionTime(Optional<Duration> systemExecutionTime) {
this.systemExecutionTime = systemExecutionTime;
return this;
}
/** Builds a {@link TerminationStatus} object. */
public TerminationStatus build() {
if (waitResponse == null) {
throw new IllegalStateException("waitResponse never set");
}
if (timedOut == null) {
throw new IllegalStateException("timedOut never set");
}
return new TerminationStatus(
waitResponse, timedOut, wallExecutionTime, userExecutionTime, systemExecutionTime);
}
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>
| {
"pile_set_name": "Github"
} |
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.vigicrues.internal.json;
import java.time.ZonedDateTime;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
/**
* The {@link VigiCruesFields} is the Java class used to map the JSON
* response to the webservice request.
*
* @author Gaรซl L'hopital - Initial contribution
*/
@NonNullByDefault
public class VigiCruesFields {
@SerializedName("debit")
private @Nullable Double flow;
@SerializedName("hauteur")
private @Nullable Double height;
private @Nullable ZonedDateTime timestamp;
public Optional<ZonedDateTime> getTimestamp() {
ZonedDateTime timestamp = this.timestamp;
if (timestamp != null) {
return Optional.of(timestamp);
}
return Optional.empty();
}
public Optional<Double> getFlow() {
Double flow = this.flow;
if (flow != null) {
return Optional.of(flow);
}
return Optional.empty();
}
public Optional<Double> getHeight() {
Double height = this.height;
if (height != null) {
return Optional.of(height);
}
return Optional.empty();
}
}
| {
"pile_set_name": "Github"
} |
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// get the form
$form = $displayData->getForm();
// get the layout fields override method name (from layout path/ID)
$layout_path_array = explode('.', $this->getLayoutId());
// Since we cannot pass the layout and tab names as parameters to the model method
// this name combination of tab and layout in the method name is the only work around
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
// example of layout name: details_left.php
// example of method name: getFields_details_left()
$fields_tab_layout = 'fields_' . $layout_path_array[1];
// get the fields
$fields = $displayData->get($fields_tab_layout) ?: array(
'joomla_component'
);
$hiddenFields = $displayData->get('hidden_fields') ?: array();
?>
<?php if ($fields && count((array) $fields)) :?>
<div class="form-inline form-inline-header">
<?php foreach($fields as $field): ?>
<?php if (in_array($field, $hiddenFields)) : ?>
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
<?php endif; ?>
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
| {
"pile_set_name": "Github"
} |
library(pystr)
context("pystr_zfill")
test_that("it fills up to the width", {
expect_equal(pystr_zfill("42", 5), "00042")
})
test_that("it leaves the minus sign at the beginning", {
expect_equal(pystr_zfill("-42", 5), "-0042")
})
test_that("it leaves the plus sign at the beginning", {
expect_equal(pystr_zfill("+42", 5), "+0042")
})
test_that("it returns the string itself if width <= nchar(str)", {
expect_equal(pystr_zfill("hello", 4), "hello")
})
test_that("it works with a character vector", {
expect_equal(pystr_zfill(c("42", "7"), 5), c("00042", "00007"))
})
| {
"pile_set_name": "Github"
} |
/* BEGIN_HEADER */
#include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h"
/*
* Number of calls made to entropy_dummy_source()
*/
static size_t entropy_dummy_calls;
/*
* Dummy entropy source
*
* If data is NULL, write exactly the requested length.
* Otherwise, write the length indicated by data or error if negative
*/
static int entropy_dummy_source( void *data, unsigned char *output,
size_t len, size_t *olen )
{
entropy_dummy_calls++;
if( data == NULL )
*olen = len;
else
{
int *d = (int *) data;
if( *d < 0 )
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
else
*olen = *d;
}
memset( output, 0x2a, *olen );
return( 0 );
}
#if defined(MBEDTLS_ENTROPY_NV_SEED)
/*
* Ability to clear entropy sources to allow testing with just predefined
* entropy sources. This function or tests depending on it might break if there
* are internal changes to how entropy sources are registered.
*
* To be called immediately after mbedtls_entropy_init().
*
* Just resetting the counter. New sources will overwrite existing ones.
* This might break memory checks in the future if sources need 'free-ing' then
* as well.
*/
static void entropy_clear_sources( mbedtls_entropy_context *ctx )
{
ctx->source_count = 0;
}
/*
* NV seed read/write functions that use a buffer instead of a file
*/
static unsigned char buffer_seed[MBEDTLS_ENTROPY_BLOCK_SIZE];
static int buffer_nv_seed_read( unsigned char *buf, size_t buf_len )
{
if( buf_len != MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
memcpy( buf, buffer_seed, MBEDTLS_ENTROPY_BLOCK_SIZE );
return( 0 );
}
static int buffer_nv_seed_write( unsigned char *buf, size_t buf_len )
{
if( buf_len != MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
memcpy( buffer_seed, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
return( 0 );
}
/*
* NV seed read/write helpers that fill the base seedfile
*/
static int write_nv_seed( unsigned char *buf, size_t buf_len )
{
FILE *f;
if( buf_len != MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
if( ( f = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL )
return( -1 );
if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) !=
MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
fclose( f );
return( 0 );
}
static int read_nv_seed( unsigned char *buf, size_t buf_len )
{
FILE *f;
if( buf_len != MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
if( ( f = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
return( -1 );
if( fread( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) !=
MBEDTLS_ENTROPY_BLOCK_SIZE )
return( -1 );
fclose( f );
return( 0 );
}
#endif /* MBEDTLS_ENTROPY_NV_SEED */
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_ENTROPY_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */
void entropy_seed_file( char *path, int ret )
{
mbedtls_entropy_context ctx;
mbedtls_entropy_init( &ctx );
TEST_ASSERT( mbedtls_entropy_write_seed_file( &ctx, path ) == ret );
TEST_ASSERT( mbedtls_entropy_update_seed_file( &ctx, path ) == ret );
exit:
mbedtls_entropy_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE */
void entropy_too_many_sources( )
{
mbedtls_entropy_context ctx;
size_t i;
mbedtls_entropy_init( &ctx );
/*
* It's hard to tell precisely when the error will occur,
* since we don't know how many sources were automatically added.
*/
for( i = 0; i < MBEDTLS_ENTROPY_MAX_SOURCES; i++ )
(void) mbedtls_entropy_add_source( &ctx, entropy_dummy_source, NULL,
16, MBEDTLS_ENTROPY_SOURCE_WEAK );
TEST_ASSERT( mbedtls_entropy_add_source( &ctx, entropy_dummy_source, NULL,
16, MBEDTLS_ENTROPY_SOURCE_WEAK )
== MBEDTLS_ERR_ENTROPY_MAX_SOURCES );
exit:
mbedtls_entropy_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE */
void entropy_func_len( int len, int ret )
{
mbedtls_entropy_context ctx;
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE + 10] = { 0 };
unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE + 10] = { 0 };
size_t i, j;
mbedtls_entropy_init( &ctx );
/*
* See comments in mbedtls_entropy_self_test()
*/
for( i = 0; i < 8; i++ )
{
TEST_ASSERT( mbedtls_entropy_func( &ctx, buf, len ) == ret );
for( j = 0; j < sizeof( buf ); j++ )
acc[j] |= buf[j];
}
if( ret == 0 )
for( j = 0; j < (size_t) len; j++ )
TEST_ASSERT( acc[j] != 0 );
for( j = len; j < sizeof( buf ); j++ )
TEST_ASSERT( acc[j] == 0 );
}
/* END_CASE */
/* BEGIN_CASE */
void entropy_source_fail( char *path )
{
mbedtls_entropy_context ctx;
int fail = -1;
unsigned char buf[16];
mbedtls_entropy_init( &ctx );
TEST_ASSERT( mbedtls_entropy_add_source( &ctx, entropy_dummy_source,
&fail, 16,
MBEDTLS_ENTROPY_SOURCE_WEAK )
== 0 );
TEST_ASSERT( mbedtls_entropy_func( &ctx, buf, sizeof( buf ) )
== MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
TEST_ASSERT( mbedtls_entropy_gather( &ctx )
== MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
#if defined(MBEDTLS_FS_IO) && defined(MBEDTLS_ENTROPY_NV_SEED)
TEST_ASSERT( mbedtls_entropy_write_seed_file( &ctx, path )
== MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
TEST_ASSERT( mbedtls_entropy_update_seed_file( &ctx, path )
== MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
#else
((void) path);
#endif
exit:
mbedtls_entropy_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE */
void entropy_threshold( int threshold, int chunk_size, int result )
{
mbedtls_entropy_context ctx;
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
int ret;
mbedtls_entropy_init( &ctx );
TEST_ASSERT( mbedtls_entropy_add_source( &ctx, entropy_dummy_source,
&chunk_size, threshold,
MBEDTLS_ENTROPY_SOURCE_WEAK ) == 0 );
entropy_dummy_calls = 0;
ret = mbedtls_entropy_func( &ctx, buf, sizeof( buf ) );
if( result >= 0 )
{
TEST_ASSERT( ret == 0 );
#if defined(MBEDTLS_ENTROPY_NV_SEED)
// Two times as much calls due to the NV seed update
result *= 2;
#endif
TEST_ASSERT( entropy_dummy_calls == (size_t) result );
}
else
{
TEST_ASSERT( ret == result );
}
exit:
mbedtls_entropy_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */
void nv_seed_file_create()
{
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
TEST_ASSERT( write_nv_seed( buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO:MBEDTLS_PLATFORM_NV_SEED_ALT */
void entropy_nv_seed_std_io()
{
unsigned char io_seed[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char check_seed[MBEDTLS_ENTROPY_BLOCK_SIZE];
memset( io_seed, 1, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( check_seed, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
mbedtls_platform_set_nv_seed( mbedtls_platform_std_nv_seed_read,
mbedtls_platform_std_nv_seed_write );
/* Check if platform NV read and write manipulate the same data */
TEST_ASSERT( write_nv_seed( io_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
TEST_ASSERT( mbedtls_nv_seed_read( check_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) ==
MBEDTLS_ENTROPY_BLOCK_SIZE );
TEST_ASSERT( memcmp( io_seed, check_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
memset( check_seed, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
/* Check if platform NV write and raw read manipulate the same data */
TEST_ASSERT( mbedtls_nv_seed_write( io_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) ==
MBEDTLS_ENTROPY_BLOCK_SIZE );
TEST_ASSERT( read_nv_seed( check_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
TEST_ASSERT( memcmp( io_seed, check_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_PLATFORM_NV_SEED_ALT:MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */
void entropy_nv_seed( char *read_seed_str )
{
mbedtls_sha512_context accumulator;
mbedtls_entropy_context ctx;
unsigned char header[2];
unsigned char entropy[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char empty[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char read_seed[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char check_seed[MBEDTLS_ENTROPY_BLOCK_SIZE];
unsigned char check_entropy[MBEDTLS_ENTROPY_BLOCK_SIZE];
memset( entropy, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( buffer_seed, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( empty, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( check_seed, 2, MBEDTLS_ENTROPY_BLOCK_SIZE );
memset( check_entropy, 3, MBEDTLS_ENTROPY_BLOCK_SIZE );
// Set the initial NV seed to read
unhexify( read_seed, read_seed_str );
memcpy( buffer_seed, read_seed, MBEDTLS_ENTROPY_BLOCK_SIZE );
// Make sure we read/write NV seed from our buffers
mbedtls_platform_set_nv_seed( buffer_nv_seed_read, buffer_nv_seed_write );
mbedtls_entropy_init( &ctx );
entropy_clear_sources( &ctx );
TEST_ASSERT( mbedtls_entropy_add_source( &ctx, mbedtls_nv_seed_poll, NULL,
MBEDTLS_ENTROPY_BLOCK_SIZE,
MBEDTLS_ENTROPY_SOURCE_STRONG ) == 0 );
// Do an entropy run
TEST_ASSERT( mbedtls_entropy_func( &ctx, entropy, sizeof( entropy ) ) == 0 );
// Determine what should have happened with manual entropy internal logic
// Only use the SHA-512 version to check
// Init accumulator
header[1] = MBEDTLS_ENTROPY_BLOCK_SIZE;
mbedtls_sha512_starts( &accumulator, 0 );
// First run for updating write_seed
header[0] = 0;
mbedtls_sha512_update( &accumulator, header, 2 );
mbedtls_sha512_update( &accumulator, read_seed, MBEDTLS_ENTROPY_BLOCK_SIZE );
mbedtls_sha512_finish( &accumulator, buf );
memset( &accumulator, 0, sizeof( mbedtls_sha512_context ) );
mbedtls_sha512_starts( &accumulator, 0 );
mbedtls_sha512_update( &accumulator, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
mbedtls_sha512( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, check_seed, 0 );
// Second run for actual entropy (triggers mbedtls_entropy_update_nv_seed)
header[0] = MBEDTLS_ENTROPY_SOURCE_MANUAL;
mbedtls_sha512_update( &accumulator, header, 2 );
mbedtls_sha512_update( &accumulator, empty, MBEDTLS_ENTROPY_BLOCK_SIZE );
header[0] = 0;
mbedtls_sha512_update( &accumulator, header, 2 );
mbedtls_sha512_update( &accumulator, check_seed, MBEDTLS_ENTROPY_BLOCK_SIZE );
mbedtls_sha512_finish( &accumulator, buf );
mbedtls_sha512( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, check_entropy, 0 );
// Check result of both NV file and entropy received with the manual calculations
TEST_ASSERT( memcmp( check_seed, buffer_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
TEST_ASSERT( memcmp( check_entropy, entropy, MBEDTLS_ENTROPY_BLOCK_SIZE ) == 0 );
mbedtls_entropy_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void entropy_selftest( int result )
{
TEST_ASSERT( mbedtls_entropy_self_test( 1 ) == result );
}
/* END_CASE */
| {
"pile_set_name": "Github"
} |
---
title: "Line 'item1': Can't set Shortcut property in menu 'item2'. Parent menu cannot have a shortcut key."
keywords: vblr6.chm60117
f1_keywords:
- vblr6.chm60117
ms.prod: office
ms.assetid: fabb46ea-3969-ea1f-e5b0-5f502b78d69c
ms.date: 06/08/2017
---
# Line 'item1': Can't set Shortcut property in menu 'item2'. Parent menu cannot have a shortcut key.
A top-level **Menu** control appeared in the ASCII form file with a shortcut key defined. Top-level menus can't have a shortcut key. The **Menu** control will be loaded, but its **Shortcut** property won't be set.
| {
"pile_set_name": "Github"
} |
/// @ref gtx_easing
/// @file glm/gtx/easing.hpp
/// @author Robert Chisholm
///
/// @see core (dependence)
///
/// @defgroup gtx_easing GLM_GTX_easing
/// @ingroup gtx
///
/// Include <glm/gtx/easing.hpp> to use the features of this extension.
///
/// Easing functions for animations and transitons
/// All functions take a parameter x in the range [0.0,1.0]
///
/// Based on the AHEasing project of Warren Moore (https://github.com/warrenm/AHEasing)
#pragma once
// Dependency:
#include "../glm.hpp"
#include "../gtc/constants.hpp"
#include "../detail/qualifier.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# ifndef GLM_ENABLE_EXPERIMENTAL
# pragma message("GLM: GLM_GTX_easing is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
# else
# pragma message("GLM: GLM_GTX_easing extension included")
# endif
#endif
namespace glm{
/// @addtogroup gtx_easing
/// @{
/// Modelled after the line y = x
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType linearInterpolation(genType const & a);
/// Modelled after the parabola y = x^2
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseIn(genType const & a);
/// Modelled after the parabola y = -x^2 + 2x
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseOut(genType const & a);
/// Modelled after the piecewise quadratic
/// y = (1/2)((2x)^2) ; [0, 0.5)
/// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quadraticEaseInOut(genType const & a);
/// Modelled after the cubic y = x^3
template <typename genType>
GLM_FUNC_DECL genType cubicEaseIn(genType const & a);
/// Modelled after the cubic y = (x - 1)^3 + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType cubicEaseOut(genType const & a);
/// Modelled after the piecewise cubic
/// y = (1/2)((2x)^3) ; [0, 0.5)
/// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType cubicEaseInOut(genType const & a);
/// Modelled after the quartic x^4
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseIn(genType const & a);
/// Modelled after the quartic y = 1 - (x - 1)^4
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseOut(genType const & a);
/// Modelled after the piecewise quartic
/// y = (1/2)((2x)^4) ; [0, 0.5)
/// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quarticEaseInOut(genType const & a);
/// Modelled after the quintic y = x^5
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseIn(genType const & a);
/// Modelled after the quintic y = (x - 1)^5 + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseOut(genType const & a);
/// Modelled after the piecewise quintic
/// y = (1/2)((2x)^5) ; [0, 0.5)
/// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType quinticEaseInOut(genType const & a);
/// Modelled after quarter-cycle of sine wave
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseIn(genType const & a);
/// Modelled after quarter-cycle of sine wave (different phase)
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseOut(genType const & a);
/// Modelled after half sine wave
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType sineEaseInOut(genType const & a);
/// Modelled after shifted quadrant IV of unit circle
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseIn(genType const & a);
/// Modelled after shifted quadrant II of unit circle
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseOut(genType const & a);
/// Modelled after the piecewise circular function
/// y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5)
/// y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType circularEaseInOut(genType const & a);
/// Modelled after the exponential function y = 2^(10(x - 1))
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseIn(genType const & a);
/// Modelled after the exponential function y = -2^(-10x) + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseOut(genType const & a);
/// Modelled after the piecewise exponential
/// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
/// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType exponentialEaseInOut(genType const & a);
/// Modelled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1))
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseIn(genType const & a);
/// Modelled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseOut(genType const & a);
/// Modelled after the piecewise exponentially-damped sine wave:
/// y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
/// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType elasticEaseInOut(genType const & a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseIn(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseOut(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseInOut(genType const& a);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseIn(genType const& a, genType const& o);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseOut(genType const& a, genType const& o);
/// @param a parameter
/// @param o Optional overshoot modifier
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType backEaseInOut(genType const& a, genType const& o);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseIn(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseOut(genType const& a);
/// @see gtx_easing
template <typename genType>
GLM_FUNC_DECL genType bounceEaseInOut(genType const& a);
/// @}
}//namespace glm
#include "easing.inl"
| {
"pile_set_name": "Github"
} |
<?php
require_once('require/class.Connection.php');
require_once('require/class.Spotter.php');
require_once('require/class.Language.php');
if (!isset($_GET['country'])) {
header('Location: '.$globalURL.'/country');
die();
}
$Spotter = new Spotter();
$country = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))));
$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
$spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
if (!empty($spotter_array))
{
$title = sprintf(_("Most Common Aircraft from %s"),$country);
require_once('header.php');
print '<div class="select-item">';
print '<form action="'.$globalURL.'/country" method="post">';
print '<select name="country" class="selectpicker" data-live-search="true">';
print '<option></option>';
$all_countries = $Spotter->getAllCountries();
foreach($all_countries as $all_country)
{
if($country == $all_country['country'])
{
print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
} else {
print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'">'.$all_country['country'].'</option>';
}
}
print '</select>';
print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
print '</form>';
print '</div>';
if ($_GET['country'] != "NA")
{
print '<div class="info column">';
print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>';
print '</div>';
} else {
print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
}
include('country-sub-menu.php');
print '<div class="column">';
print '<h2>'._("Most Common Aircraft").'</h2>';
print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights from <strong>%s</strong>."),$country).'</p>';
$aircraft_array = $Spotter->countAllAircraftTypesByCountry($country);
if (!empty($aircraft_array))
{
print '<div class="table-responsive">';
print '<table class="common-type table-striped">';
print '<thead>';
print '<th></th>';
print '<th>'._("Aircraft Type").'</th>';
print '<th>'._("# of times").'</th>';
print '</thead>';
print '<tbody>';
$i = 1;
foreach($aircraft_array as $aircraft_item)
{
print '<tr>';
print '<td><strong>'.$i.'</strong></td>';
print '<td>';
print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
print '</td>';
print '<td>';
print $aircraft_item['aircraft_icao_count'];
print '</td>';
print '</tr>';
$i++;
}
print '<tbody>';
print '</table>';
print '</div>';
}
print '</div>';
} else {
$title = _("Country");
require_once('header.php');
print '<h1>'._("Error").'</h1>';
print '<p>'._("Sorry, the country does not exist in this database. :(").'</p>';
}
require_once('footer.php');
?> | {
"pile_set_name": "Github"
} |
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package collate
import (
"reflect"
"strings"
"testing"
"golang.org/x/text/internal/colltab"
"golang.org/x/text/language"
)
var (
defaultIgnore = ignore(colltab.Tertiary)
defaultTable = getTable(locales[0])
)
func TestOptions(t *testing.T) {
for i, tt := range []struct {
in []Option
out options
}{
0: {
out: options{
ignore: defaultIgnore,
},
},
1: {
in: []Option{IgnoreDiacritics},
out: options{
ignore: [colltab.NumLevels]bool{false, true, false, true, true},
},
},
2: {
in: []Option{IgnoreCase, IgnoreDiacritics},
out: options{
ignore: ignore(colltab.Primary),
},
},
3: {
in: []Option{ignoreDiacritics, IgnoreWidth},
out: options{
ignore: ignore(colltab.Primary),
caseLevel: true,
},
},
4: {
in: []Option{IgnoreWidth, ignoreDiacritics},
out: options{
ignore: ignore(colltab.Primary),
caseLevel: true,
},
},
5: {
in: []Option{IgnoreCase, IgnoreWidth},
out: options{
ignore: ignore(colltab.Secondary),
},
},
6: {
in: []Option{IgnoreCase, IgnoreWidth, Loose},
out: options{
ignore: ignore(colltab.Primary),
},
},
7: {
in: []Option{Force, IgnoreCase, IgnoreWidth, Loose},
out: options{
ignore: [colltab.NumLevels]bool{false, true, true, true, false},
},
},
8: {
in: []Option{IgnoreDiacritics, IgnoreCase},
out: options{
ignore: ignore(colltab.Primary),
},
},
9: {
in: []Option{Numeric},
out: options{
ignore: defaultIgnore,
numeric: true,
},
},
10: {
in: []Option{OptionsFromTag(language.MustParse("und-u-ks-level1"))},
out: options{
ignore: ignore(colltab.Primary),
},
},
11: {
in: []Option{OptionsFromTag(language.MustParse("und-u-ks-level4"))},
out: options{
ignore: ignore(colltab.Quaternary),
},
},
12: {
in: []Option{OptionsFromTag(language.MustParse("und-u-ks-identic"))},
out: options{},
},
13: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-kn-true-kb-true-kc-true")),
},
out: options{
ignore: defaultIgnore,
caseLevel: true,
backwards: true,
numeric: true,
},
},
14: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-kn-true-kb-true-kc-true")),
OptionsFromTag(language.MustParse("und-u-kn-false-kb-false-kc-false")),
},
out: options{
ignore: defaultIgnore,
},
},
15: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-kn-true-kb-true-kc-true")),
OptionsFromTag(language.MustParse("und-u-kn-foo-kb-foo-kc-foo")),
},
out: options{
ignore: defaultIgnore,
caseLevel: true,
backwards: true,
numeric: true,
},
},
16: { // Normal options take precedence over tag options.
in: []Option{
Numeric, IgnoreCase,
OptionsFromTag(language.MustParse("und-u-kn-false-kc-true")),
},
out: options{
ignore: ignore(colltab.Secondary),
caseLevel: false,
numeric: true,
},
},
17: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-ka-shifted")),
},
out: options{
ignore: defaultIgnore,
alternate: altShifted,
},
},
18: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-ka-blanked")),
},
out: options{
ignore: defaultIgnore,
alternate: altBlanked,
},
},
19: {
in: []Option{
OptionsFromTag(language.MustParse("und-u-ka-posix")),
},
out: options{
ignore: defaultIgnore,
alternate: altShiftTrimmed,
},
},
} {
c := newCollator(defaultTable)
c.t = nil
c.variableTop = 0
c.f = 0
c.setOptions(tt.in)
if !reflect.DeepEqual(c.options, tt.out) {
t.Errorf("%d: got %v; want %v", i, c.options, tt.out)
}
}
}
func TestAlternateSortTypes(t *testing.T) {
testCases := []struct {
lang string
in []string
want []string
}{{
lang: "zh,cmn,zh-Hant-u-co-pinyin,zh-HK-u-co-pinyin,zh-pinyin",
in: []string{"็ธ็ธ", "ๅฆๅฆ", "ๅฟๅญ", "ๅฅณๅฟ"},
want: []string{"็ธ็ธ", "ๅฟๅญ", "ๅฆๅฆ", "ๅฅณๅฟ"},
}, {
lang: "zh-Hant,zh-u-co-stroke,zh-Hant-u-co-stroke",
in: []string{"็ธ็ธ", "ๅฆๅฆ", "ๅฟๅญ", "ๅฅณๅฟ"},
want: []string{"ๅฟๅญ", "ๅฅณๅฟ", "ๅฆๅฆ", "็ธ็ธ"},
}}
for _, tc := range testCases {
for _, tag := range strings.Split(tc.lang, ",") {
got := append([]string{}, tc.in...)
New(language.MustParse(tag)).SortStrings(got)
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("New(%s).SortStrings(%v) = %v; want %v", tag, tc.in, got, tc.want)
}
}
}
}
| {
"pile_set_name": "Github"
} |
DEFINITION MODULE OSCALLS;
__DEF_SWITCHES__
#ifdef HM2
#ifdef __LONG_WHOLE__
(*$!i+: Modul muss mit $i- uebersetzt werden! *)
(*$!w+: Modul muss mit $w- uebersetzt werden! *)
#else
(*$!i-: Modul muss mit $i+ uebersetzt werden! *)
(*$!w-: Modul muss mit $w+ uebersetzt werden! *)
#endif
#endif
(*****************************************************************************)
(* Dies soll kein allgemeingueltiges Modul fuer "GEMDOS"- und "MiNT"-Aufrufe *)
(* sein, sondern lediglich die in M2POSIX verwendeten Aufrufe bereitstellen, *)
(* damit keine Makros benutzt werden muessen. *)
(* Wenn die Betriebssystemfunktion eine Fehlermeldung liefern kann, hat die *)
(* Prozedur einen BOOLEAN-Returnwert: TRUE bedeutet: OK, FALSE bedeutet: *)
(* es ist ein Fehler aufgetreten. Der Fehlercode wird dann in der entspre- *)
(* chenden Resultatsvariable zurueckgeliefert, die hierfuer moeglicherweise *)
(* noch in einen INTEGER-Wert konvertiert werden muss (falls z.B. das Resul- *)
(* tat ein ADDRESS-Parameter ist). *)
(* --------------------------------------------------------------------------*)
(* 14-Mai-94, Holger Kleinschmidt *)
(*****************************************************************************)
FROM SYSTEM IMPORT
(* TYPE *) ADDRESS;
FROM PORTAB IMPORT
(* TYPE *) UNSIGNEDWORD, SIGNEDWORD, UNSIGNEDLONG, SIGNEDLONG, ANYLONG,
ANYWORD, WORDSET;
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
PROCEDURE Vsync;
PROCEDURE Supexec(proc:PROC);
PROCEDURE Setexc(vec:CARDINAL;adr:ADDRESS):ADDRESS;
PROCEDURE Bconin(dev:CARDINAL):UNSIGNEDLONG;
PROCEDURE Bconout(dev:CARDINAL;ch:CARDINAL):BOOLEAN;
PROCEDURE Bconstat(dev:CARDINAL):BOOLEAN;
PROCEDURE Cconis():BOOLEAN;
PROCEDURE Cnecin():UNSIGNEDLONG;
PROCEDURE Cconout(c:CHAR);
PROCEDURE Cconws(str:ADDRESS);
PROCEDURE Dsetdrv(drv:CARDINAL):UNSIGNEDLONG;
PROCEDURE Dgetdrv():CARDINAL;
PROCEDURE Fsetdta(dta:ADDRESS);
PROCEDURE Super(dat:UNSIGNEDLONG):SIGNEDLONG;
PROCEDURE Tgetdate():WORDSET;
PROCEDURE Tsetdate(date:ANYWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Tgettime():WORDSET;
PROCEDURE Tsettime(time:ANYWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fgetdta():ADDRESS;
PROCEDURE Sversion():CARDINAL;
PROCEDURE Dcreate(dir:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Ddelete(dir:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Dsetpath(dir:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Dfree(buf:ADDRESS;drv:CARDINAL;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fcreate(file:ADDRESS;attr:ANYWORD;VAR hndl:INTEGER):BOOLEAN;
PROCEDURE Fopen(file:ADDRESS;mode:ANYWORD;VAR hndl:INTEGER):BOOLEAN;
PROCEDURE Fclose(hndl:INTEGER;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fread(hndl:INTEGER;len:UNSIGNEDLONG;buf:ADDRESS;VAR cnt:SIGNEDLONG):BOOLEAN;
PROCEDURE Fwrite(hndl:INTEGER;len:UNSIGNEDLONG;buf:ADDRESS;VAR cnt:SIGNEDLONG):BOOLEAN;
PROCEDURE Fdelete(file:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fseek(off:SIGNEDLONG;hndl:INTEGER;mode:CARDINAL;VAR pos:SIGNEDLONG):BOOLEAN;
PROCEDURE Fattrib(file:ADDRESS;flag:CARDINAL;attr:ANYWORD;VAR old:WORDSET):BOOLEAN;
PROCEDURE Mxalloc(size:SIGNEDLONG;mode:ANYWORD;VAR adr:ADDRESS):BOOLEAN;
PROCEDURE Fdup(std:INTEGER;VAR hndl:INTEGER):BOOLEAN;
PROCEDURE Fforce(std:INTEGER;hndl:INTEGER;VAR res:INTEGER):BOOLEAN;
PROCEDURE Dgetpath(buf:ADDRESS;drv:CARDINAL;VAR res:INTEGER):BOOLEAN;
PROCEDURE Malloc(size:SIGNEDLONG;VAR adr:ADDRESS):BOOLEAN;
PROCEDURE Mfree(adr:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Mshrink(adr:ADDRESS;size:SIGNEDLONG;VAR res:INTEGER):BOOLEAN;
PROCEDURE Pexec(mode:CARDINAL;prog:ADDRESS;tail:ADDRESS;env:ADDRESS;VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Pterm(ret:INTEGER);
PROCEDURE Fsfirst(file:ADDRESS;attr:ANYWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fsnext(VAR res:INTEGER):BOOLEAN;
PROCEDURE Frename(old:ADDRESS;new:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fdatime(datime:ADDRESS;hndl:INTEGER;flag:CARDINAL);
PROCEDURE Flock(hndl:INTEGER;mode:CARDINAL;from:UNSIGNEDLONG;len:UNSIGNEDLONG;VAR res:INTEGER):BOOLEAN;
/*==========================================================================*/
/* MiNT-Calls */
/*==========================================================================*/
PROCEDURE Syield():INTEGER;
PROCEDURE Fpipe(buf:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fcntl(hndl:INTEGER;arg:ANYLONG;cmd:CARDINAL;VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Pwait(VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Pgetpid():INTEGER;
PROCEDURE Pgetppid():INTEGER;
PROCEDURE Pgetpgrp():INTEGER;
PROCEDURE Psetpgrp(pid:INTEGER;grp:INTEGER;VAR res:INTEGER):BOOLEAN;
PROCEDURE Pgetuid():INTEGER;
PROCEDURE Psetuid(uid:UNSIGNEDWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Pkill(pid:INTEGER;sig:CARDINAL;VAR res:INTEGER):BOOLEAN;
PROCEDURE Psignal(sig:CARDINAL;handler:ADDRESS;VAR old:ADDRESS):BOOLEAN;
PROCEDURE Pgetgid():INTEGER;
PROCEDURE Psetgid(gid:UNSIGNEDWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Psigblock(mask:UNSIGNEDLONG):UNSIGNEDLONG;
PROCEDURE Psigsetmask(mask:UNSIGNEDLONG):UNSIGNEDLONG;
PROCEDURE Pusrval(arg:SIGNEDLONG):SIGNEDLONG;
PROCEDURE Pdomain(dom:INTEGER):INTEGER;
PROCEDURE Psigreturn;
PROCEDURE Pfork():INTEGER;
PROCEDURE Pwait3(flag:ANYWORD;rusage:ADDRESS;VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Fselect(timeout:CARDINAL;rfds:ADDRESS;wfds:ADDRESS;xfds:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Prusage(rscadr:ADDRESS):INTEGER;
PROCEDURE Talarm(secs:SIGNEDLONG):SIGNEDLONG;
PROCEDURE Tmalarm(msecs:SIGNEDLONG):SIGNEDLONG;
PROCEDURE Pause():INTEGER;
PROCEDURE Sysconf(which:INTEGER;VAR val:SIGNEDLONG):BOOLEAN;
PROCEDURE Psigpending():SIGNEDLONG;
PROCEDURE Dpathconf(path:ADDRESS;which:INTEGER;VAR val:SIGNEDLONG):BOOLEAN;
PROCEDURE Dopendir(path:ADDRESS;flag:CARDINAL;VAR dir:UNSIGNEDLONG):BOOLEAN;
PROCEDURE Dreaddir(len:CARDINAL;dir:UNSIGNEDLONG;buf:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Drewinddir(dir:UNSIGNEDLONG;VAR res:INTEGER):BOOLEAN;
PROCEDURE Dclosedir(dir:UNSIGNEDLONG;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fxattr(flag:CARDINAL;file:ADDRESS;xattr:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Flink(old:ADDRESS;new:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fsymlink(old:ADDRESS;new:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Freadlink(bufsiz:CARDINAL;buf:ADDRESS;file:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Dcntl(cmd:CARDINAL;path:ADDRESS;arg:ANYLONG;VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Fchown(file:ADDRESS;uid:UNSIGNEDWORD;gid:UNSIGNEDWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Fchmod(file:ADDRESS;mode:ANYWORD;VAR res:INTEGER):BOOLEAN;
PROCEDURE Pumask(mode:ANYWORD):SIGNEDLONG;
PROCEDURE Psigpause(sigmask:UNSIGNEDLONG):INTEGER;
PROCEDURE Psigaction(sig:CARDINAL;act:ADDRESS;oact:ADDRESS;VAR res:INTEGER):BOOLEAN;
PROCEDURE Pgeteuid():INTEGER;
PROCEDURE Pgetegid():INTEGER;
PROCEDURE Pwaitpid(pid:INTEGER;flag:ANYWORD;rusage:ADDRESS;VAR res:SIGNEDLONG):BOOLEAN;
PROCEDURE Dgetcwd(path:ADDRESS;drv:CARDINAL;size:CARDINAL;VAR res:INTEGER):BOOLEAN;
END OSCALLS.
| {
"pile_set_name": "Github"
} |
## ไฝฟ็จ่ฏดๆ
```jsx
// ๆ้ๅผๅ
ฅ้่ฆๅจ app.scss ไธญๅผๅ
ฅๅฏนๅบๆ ทๅผ menuList.scss
import { ClMenuList } from "mp-colorui";
```
## ไธ่ฌ็จๆณ
<CodeShow componentName='menuList' />
## ๅๆฐ่ฏดๆ
### MenuList ๅๆฐ
| ๅๆฐ | ่ฏดๆ | ็ฑปๅ | ๅฏ้ๅผ | ้ป่ฎคๅผ |
| ----------- | ---------------- | ------- | -------------------------------------------- | --------- |
| shortBorder | _ๆฏๅฆไธบ็ญๅๅฒ็บฟ_ | boolean | _`true`_,_`false`_ | _`false`_ |
| card | _ๆฏๅฆๆฏๅก็ๅฝขๅผ_ | boolean | _`true`_,_`false`_ | _`false`_ |
| list | _ๅ่กจๆฏไธ้กน_ | list[] | [่ฏฆๆ
](/mp-colorui-doc/layout/menuList#list) | [] |
### list
| ๅๆฐ | ่ฏดๆ | ็ฑปๅ | ๅฏ้ๅผ | ้ป่ฎคๅผ |
| ---------- | -------------- | ------- | ---------------------------------------------------------------- | --------- |
| icon | _ๅ่กจๅพๆ _ | Object | ๅ่ๆๆกฃ [Icon-_Icon_ ๅๆฐ](/mp-colorui-doc/base/icon#icon-ๅๆฐ) | {} |
| titleColor | _ๆ ้ข้ข่ฒ_ | string | ๅ่ๆๆกฃ [้ป่ฎค่ฒ-ๆ ๅ่ฒ](/mp-colorui-doc/home/color#ๆ ๅ่ฒ) | _`black`_ |
| arrow | _ๆฏๅฆๆพ็คบ็ฎญๅคด_ | boolean | _`true`_,_`false`_ | _`false`_ |
| title | _ๆ ้ข_ | string | - | - |
| imgUrl | _ๅพ็ๅฐๅ_ | string | - | - |
| disabled | _็ฆๆญข็นๅป_ | boolean | - | _`false`_ |
| value | _ๅณไพงๆๅญ_ | string | - | - |
### MenuList ไบไปถ
| ไบไปถๅ็งฐ | ่ฏดๆ | ๅๆฐ่ฟๅ |
| -------- | ---------- | -------- |
| onClick | _็นๅปไบไปถ_ | index |
<FloatPhone url="https://yinliangdream.github.io/mp-colorui-h5-demo/#/package/layoutPackage/menuList/index" />
| {
"pile_set_name": "Github"
} |
/************************************************************************
IMPORTANT NOTE : this file contains two clearly delimited sections :
the ARCHITECTURE section (in two parts) and the USER section. Each section
is governed by its own copyright and license. Please check individually
each section for license and copyright information.
*************************************************************************/
/*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/
/************************************************************************
FAUST Architecture File
Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This Architecture section is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; If not, see <http://www.gnu.org/licenses/>.
EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************
************************************************************************/
#ifndef __dsp_combiner__
#define __dsp_combiner__
#include <string.h>
#include <assert.h>
#include "faust/dsp/dsp.h"
// Combine two DSP in sequence
class dsp_sequencer : public dsp {
private:
dsp* fDSP1;
dsp* fDSP2;
FAUSTFLOAT** fSeqBuffer;
public:
dsp_sequencer(dsp* dsp1, dsp* dsp2, int buffer_size = 4096)
:fDSP1(dsp1), fDSP2(dsp2)
{
assert(fDSP1->getNumOutputs() == fDSP2->getNumInputs());
fSeqBuffer = new FAUSTFLOAT*[fDSP1->getNumOutputs()];
for (int i = 0; i < fDSP1->getNumOutputs(); i++) {
fSeqBuffer[i] = new FAUSTFLOAT[buffer_size];
}
}
virtual ~dsp_sequencer()
{
for (int i = 0; i < fDSP1->getNumOutputs(); i++) {
delete [] fSeqBuffer[i];
}
delete [] fSeqBuffer;
delete fDSP1;
delete fDSP2;
}
virtual int getNumInputs() { return fDSP1->getNumInputs(); }
virtual int getNumOutputs() { return fDSP2->getNumOutputs(); }
virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openTabBox("Sequencer");
ui_interface->openVerticalBox("DSP1");
fDSP1->buildUserInterface(ui_interface);
ui_interface->closeBox();
ui_interface->openVerticalBox("DSP2");
fDSP2->buildUserInterface(ui_interface);
ui_interface->closeBox();
ui_interface->closeBox();
}
virtual int getSampleRate()
{
return fDSP1->getSampleRate();
}
virtual void init(int samplingRate)
{
fDSP1->init(samplingRate);
fDSP2->init(samplingRate);
}
virtual void instanceInit(int samplingRate)
{
fDSP1->instanceInit(samplingRate);
fDSP2->instanceInit(samplingRate);
}
virtual void instanceConstants(int samplingRate)
{
fDSP1->instanceConstants(samplingRate);
fDSP2->instanceConstants(samplingRate);
}
virtual void instanceResetUserInterface()
{
fDSP1->instanceResetUserInterface();
fDSP2->instanceResetUserInterface();
}
virtual void instanceClear()
{
fDSP1->instanceClear();
fDSP2->instanceClear();
}
virtual dsp* clone()
{
return new dsp_sequencer(fDSP1->clone(), fDSP2->clone());
}
virtual void metadata(Meta* m)
{
fDSP1->metadata(m);
fDSP2->metadata(m);
}
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
fDSP1->compute(count, inputs, fSeqBuffer);
fDSP2->compute(count, fSeqBuffer, outputs);
}
virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); }
};
// Combine two DSP in parallel
class dsp_parallelizer : public dsp {
private:
dsp* fDSP1;
dsp* fDSP2;
public:
dsp_parallelizer(dsp* dsp1, dsp* dsp2, int buffer_size = 4096)
:fDSP1(dsp1), fDSP2(dsp2)
{}
virtual ~dsp_parallelizer()
{
delete fDSP1;
delete fDSP2;
}
virtual int getNumInputs() { return fDSP1->getNumInputs() + fDSP2->getNumInputs(); }
virtual int getNumOutputs() { return fDSP1->getNumOutputs() + fDSP2->getNumOutputs(); }
virtual void buildUserInterface(UI* ui_interface)
{
ui_interface->openTabBox("Parallelizer");
ui_interface->openVerticalBox("DSP1");
fDSP1->buildUserInterface(ui_interface);
ui_interface->closeBox();
ui_interface->openVerticalBox("DSP2");
fDSP2->buildUserInterface(ui_interface);
ui_interface->closeBox();
ui_interface->closeBox();
}
virtual int getSampleRate()
{
return fDSP1->getSampleRate();
}
virtual void init(int samplingRate)
{
fDSP1->init(samplingRate);
fDSP2->init(samplingRate);
}
virtual void instanceInit(int samplingRate)
{
fDSP1->instanceInit(samplingRate);
fDSP2->instanceInit(samplingRate);
}
virtual void instanceConstants(int samplingRate)
{
fDSP1->instanceConstants(samplingRate);
fDSP2->instanceConstants(samplingRate);
}
virtual void instanceResetUserInterface()
{
fDSP1->instanceResetUserInterface();
fDSP2->instanceResetUserInterface();
}
virtual void instanceClear()
{
fDSP1->instanceClear();
fDSP2->instanceClear();
}
virtual dsp* clone()
{
return new dsp_parallelizer(fDSP1->clone(), fDSP2->clone());
}
virtual void metadata(Meta* m)
{
fDSP1->metadata(m);
fDSP2->metadata(m);
}
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
fDSP1->compute(count, inputs, outputs);
// Shift inputs/outputs channels for fDSP2
FAUSTFLOAT** inputs_dsp2 = (FAUSTFLOAT**)alloca(fDSP2->getNumInputs() * sizeof(FAUSTFLOAT*));
for (int chan = 0; chan < fDSP2->getNumInputs(); chan++) {
inputs_dsp2[chan] = inputs[fDSP1->getNumInputs() + chan];
}
FAUSTFLOAT** outputs_dsp2 = (FAUSTFLOAT**)alloca(fDSP2->getNumOutputs() * sizeof(FAUSTFLOAT*));
for (int chan = 0; chan < fDSP2->getNumOutputs(); chan++) {
outputs_dsp2[chan] = inputs[fDSP1->getNumOutputs() + chan];
}
fDSP2->compute(count, inputs_dsp2, outputs_dsp2);
}
virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); }
};
#endif
| {
"pile_set_name": "Github"
} |
๏ปฟ// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MandrillException.cs" company="">
//
// </copyright>
// <summary>
// General Exception that is thrown by the Mandrill Api
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Net;
using System.Net.Http;
using Mandrill.Models;
using Mandrill.Requests;
namespace Mandrill.Utilities
{
/// <summary>
/// General Exception that is thrown by the Mandrill Api
/// </summary>
public class MandrillException : Exception
{
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="MandrillException" /> class.
/// </summary>
public MandrillException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MandrillException" /> class.
/// </summary>
/// <param name="message">
/// The message.
/// </param>
public MandrillException(string message)
: base(message, new Exception(message))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MandrillException" /> class.
/// </summary>
/// <param name="error">
/// The error.
/// </param>
/// <param name="message">
/// The message.
/// </param>
public MandrillException(ErrorResponse error, string message)
: base(message, new Exception(error.Message))
{
Error = error;
}
/// <summary>
/// Initializes a new instance of the <see cref="MandrillException" /> class.
/// </summary>
/// <param name="message">
/// The message.
/// </param>
/// <param name="innerException">
/// The inner exception.
/// </param>
public MandrillException(string message, Exception innerException)
: base(message, innerException)
{
}
#endregion
#region Public Properties
/// <summary>
/// Gets the error.
/// </summary>
public ErrorResponse Error { get; private set; }
/// <summary>
/// Gets the response message if any
/// </summary>
public HttpResponseMessage HttpResponseMessage { get; set; }
/// <summary>
/// Gets the mandrill request used.
/// </summary>
public RequestBase MandrillRequest { get; set; }
#endregion
}
} | {
"pile_set_name": "Github"
} |
/* QLogic qed NIC Driver
* Copyright (c) 2015 QLogic Corporation
*
* This software is available under the terms of the GNU General Public License
* (GPL) Version 2, available from the file COPYING in the main directory of
* this source tree.
*/
#include <linux/crc32.h>
#include <linux/etherdevice.h>
#include "qed.h"
#include "qed_sriov.h"
#include "qed_vf.h"
static void *qed_vf_pf_prep(struct qed_hwfn *p_hwfn, u16 type, u16 length)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
void *p_tlv;
/* This lock is released when we receive PF's response
* in qed_send_msg2pf().
* So, qed_vf_pf_prep() and qed_send_msg2pf()
* must come in sequence.
*/
mutex_lock(&(p_iov->mutex));
DP_VERBOSE(p_hwfn,
QED_MSG_IOV,
"preparing to send 0x%04x tlv over vf pf channel\n",
type);
/* Reset Requst offset */
p_iov->offset = (u8 *)p_iov->vf2pf_request;
/* Clear mailbox - both request and reply */
memset(p_iov->vf2pf_request, 0, sizeof(union vfpf_tlvs));
memset(p_iov->pf2vf_reply, 0, sizeof(union pfvf_tlvs));
/* Init type and length */
p_tlv = qed_add_tlv(p_hwfn, &p_iov->offset, type, length);
/* Init first tlv header */
((struct vfpf_first_tlv *)p_tlv)->reply_address =
(u64)p_iov->pf2vf_reply_phys;
return p_tlv;
}
static int qed_send_msg2pf(struct qed_hwfn *p_hwfn, u8 *done, u32 resp_size)
{
union vfpf_tlvs *p_req = p_hwfn->vf_iov_info->vf2pf_request;
struct ustorm_trigger_vf_zone trigger;
struct ustorm_vf_zone *zone_data;
int rc = 0, time = 100;
zone_data = (struct ustorm_vf_zone *)PXP_VF_BAR0_START_USDM_ZONE_B;
/* output tlvs list */
qed_dp_tlv_list(p_hwfn, p_req);
/* need to add the END TLV to the message size */
resp_size += sizeof(struct channel_list_end_tlv);
/* Send TLVs over HW channel */
memset(&trigger, 0, sizeof(struct ustorm_trigger_vf_zone));
trigger.vf_pf_msg_valid = 1;
DP_VERBOSE(p_hwfn,
QED_MSG_IOV,
"VF -> PF [%02x] message: [%08x, %08x] --> %p, %08x --> %p\n",
GET_FIELD(p_hwfn->hw_info.concrete_fid,
PXP_CONCRETE_FID_PFID),
upper_32_bits(p_hwfn->vf_iov_info->vf2pf_request_phys),
lower_32_bits(p_hwfn->vf_iov_info->vf2pf_request_phys),
&zone_data->non_trigger.vf_pf_msg_addr,
*((u32 *)&trigger), &zone_data->trigger);
REG_WR(p_hwfn,
(uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.lo,
lower_32_bits(p_hwfn->vf_iov_info->vf2pf_request_phys));
REG_WR(p_hwfn,
(uintptr_t)&zone_data->non_trigger.vf_pf_msg_addr.hi,
upper_32_bits(p_hwfn->vf_iov_info->vf2pf_request_phys));
/* The message data must be written first, to prevent trigger before
* data is written.
*/
wmb();
REG_WR(p_hwfn, (uintptr_t)&zone_data->trigger, *((u32 *)&trigger));
/* When PF would be done with the response, it would write back to the
* `done' address. Poll until then.
*/
while ((!*done) && time) {
msleep(25);
time--;
}
if (!*done) {
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"VF <-- PF Timeout [Type %d]\n",
p_req->first_tlv.tl.type);
rc = -EBUSY;
goto exit;
} else {
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"PF response: %d [Type %d]\n",
*done, p_req->first_tlv.tl.type);
}
exit:
mutex_unlock(&(p_hwfn->vf_iov_info->mutex));
return rc;
}
#define VF_ACQUIRE_THRESH 3
static void qed_vf_pf_acquire_reduce_resc(struct qed_hwfn *p_hwfn,
struct vf_pf_resc_request *p_req,
struct pf_vf_resc *p_resp)
{
DP_VERBOSE(p_hwfn,
QED_MSG_IOV,
"PF unwilling to fullill resource request: rxq [%02x/%02x] txq [%02x/%02x] sbs [%02x/%02x] mac [%02x/%02x] vlan [%02x/%02x] mc [%02x/%02x]. Try PF recommended amount\n",
p_req->num_rxqs,
p_resp->num_rxqs,
p_req->num_rxqs,
p_resp->num_txqs,
p_req->num_sbs,
p_resp->num_sbs,
p_req->num_mac_filters,
p_resp->num_mac_filters,
p_req->num_vlan_filters,
p_resp->num_vlan_filters,
p_req->num_mc_filters, p_resp->num_mc_filters);
/* humble our request */
p_req->num_txqs = p_resp->num_txqs;
p_req->num_rxqs = p_resp->num_rxqs;
p_req->num_sbs = p_resp->num_sbs;
p_req->num_mac_filters = p_resp->num_mac_filters;
p_req->num_vlan_filters = p_resp->num_vlan_filters;
p_req->num_mc_filters = p_resp->num_mc_filters;
}
static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_acquire_resp_tlv *resp = &p_iov->pf2vf_reply->acquire_resp;
struct pf_vf_pfdev_info *pfdev_info = &resp->pfdev_info;
struct vf_pf_resc_request *p_resc;
bool resources_acquired = false;
struct vfpf_acquire_tlv *req;
int rc = 0, attempts = 0;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_ACQUIRE, sizeof(*req));
p_resc = &req->resc_request;
/* starting filling the request */
req->vfdev_info.opaque_fid = p_hwfn->hw_info.opaque_fid;
p_resc->num_rxqs = QED_MAX_VF_CHAINS_PER_PF;
p_resc->num_txqs = QED_MAX_VF_CHAINS_PER_PF;
p_resc->num_sbs = QED_MAX_VF_CHAINS_PER_PF;
p_resc->num_mac_filters = QED_ETH_VF_NUM_MAC_FILTERS;
p_resc->num_vlan_filters = QED_ETH_VF_NUM_VLAN_FILTERS;
req->vfdev_info.os_type = VFPF_ACQUIRE_OS_LINUX;
req->vfdev_info.fw_major = FW_MAJOR_VERSION;
req->vfdev_info.fw_minor = FW_MINOR_VERSION;
req->vfdev_info.fw_revision = FW_REVISION_VERSION;
req->vfdev_info.fw_engineering = FW_ENGINEERING_VERSION;
req->vfdev_info.eth_fp_hsi_major = ETH_HSI_VER_MAJOR;
req->vfdev_info.eth_fp_hsi_minor = ETH_HSI_VER_MINOR;
/* Fill capability field with any non-deprecated config we support */
req->vfdev_info.capabilities |= VFPF_ACQUIRE_CAP_100G;
/* pf 2 vf bulletin board address */
req->bulletin_addr = p_iov->bulletin.phys;
req->bulletin_size = p_iov->bulletin.size;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
while (!resources_acquired) {
DP_VERBOSE(p_hwfn,
QED_MSG_IOV, "attempting to acquire resources\n");
/* send acquire request */
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
/* copy acquire response from buffer to p_hwfn */
memcpy(&p_iov->acquire_resp, resp, sizeof(p_iov->acquire_resp));
attempts++;
if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
/* PF agrees to allocate our resources */
if (!(resp->pfdev_info.capabilities &
PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE)) {
DP_INFO(p_hwfn,
"PF is using old incompatible driver; Either downgrade driver or request provider to update hypervisor version\n");
return -EINVAL;
}
DP_VERBOSE(p_hwfn, QED_MSG_IOV, "resources acquired\n");
resources_acquired = true;
} else if (resp->hdr.status == PFVF_STATUS_NO_RESOURCE &&
attempts < VF_ACQUIRE_THRESH) {
qed_vf_pf_acquire_reduce_resc(p_hwfn, p_resc,
&resp->resc);
/* Clear response buffer */
memset(p_iov->pf2vf_reply, 0, sizeof(union pfvf_tlvs));
} else if ((resp->hdr.status == PFVF_STATUS_NOT_SUPPORTED) &&
pfdev_info->major_fp_hsi &&
(pfdev_info->major_fp_hsi != ETH_HSI_VER_MAJOR)) {
DP_NOTICE(p_hwfn,
"PF uses an incompatible fastpath HSI %02x.%02x [VF requires %02x.%02x]. Please change to a VF driver using %02x.xx.\n",
pfdev_info->major_fp_hsi,
pfdev_info->minor_fp_hsi,
ETH_HSI_VER_MAJOR,
ETH_HSI_VER_MINOR, pfdev_info->major_fp_hsi);
return -EINVAL;
} else {
DP_ERR(p_hwfn,
"PF returned error %d to VF acquisition request\n",
resp->hdr.status);
return -EAGAIN;
}
}
/* Update bulletin board size with response from PF */
p_iov->bulletin.size = resp->bulletin_size;
/* get HW info */
p_hwfn->cdev->type = resp->pfdev_info.dev_type;
p_hwfn->cdev->chip_rev = resp->pfdev_info.chip_rev;
p_hwfn->cdev->chip_num = pfdev_info->chip_num & 0xffff;
/* Learn of the possibility of CMT */
if (IS_LEAD_HWFN(p_hwfn)) {
if (resp->pfdev_info.capabilities & PFVF_ACQUIRE_CAP_100G) {
DP_NOTICE(p_hwfn, "100g VF\n");
p_hwfn->cdev->num_hwfns = 2;
}
}
if (ETH_HSI_VER_MINOR &&
(resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR)) {
DP_INFO(p_hwfn,
"PF is using older fastpath HSI; %02x.%02x is configured\n",
ETH_HSI_VER_MAJOR, resp->pfdev_info.minor_fp_hsi);
}
return 0;
}
int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov;
u32 reg;
/* Set number of hwfns - might be overriden once leading hwfn learns
* actual configuration from PF.
*/
if (IS_LEAD_HWFN(p_hwfn))
p_hwfn->cdev->num_hwfns = 1;
/* Set the doorbell bar. Assumption: regview is set */
p_hwfn->doorbells = (u8 __iomem *)p_hwfn->regview +
PXP_VF_BAR0_START_DQ;
reg = PXP_VF_BAR0_ME_OPAQUE_ADDRESS;
p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn, reg);
reg = PXP_VF_BAR0_ME_CONCRETE_ADDRESS;
p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn, reg);
/* Allocate vf sriov info */
p_iov = kzalloc(sizeof(*p_iov), GFP_KERNEL);
if (!p_iov) {
DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_sriov'\n");
return -ENOMEM;
}
/* Allocate vf2pf msg */
p_iov->vf2pf_request = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union vfpf_tlvs),
&p_iov->vf2pf_request_phys,
GFP_KERNEL);
if (!p_iov->vf2pf_request) {
DP_NOTICE(p_hwfn,
"Failed to allocate `vf2pf_request' DMA memory\n");
goto free_p_iov;
}
p_iov->pf2vf_reply = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union pfvf_tlvs),
&p_iov->pf2vf_reply_phys,
GFP_KERNEL);
if (!p_iov->pf2vf_reply) {
DP_NOTICE(p_hwfn,
"Failed to allocate `pf2vf_reply' DMA memory\n");
goto free_vf2pf_request;
}
DP_VERBOSE(p_hwfn,
QED_MSG_IOV,
"VF's Request mailbox [%p virt 0x%llx phys], Response mailbox [%p virt 0x%llx phys]\n",
p_iov->vf2pf_request,
(u64) p_iov->vf2pf_request_phys,
p_iov->pf2vf_reply, (u64)p_iov->pf2vf_reply_phys);
/* Allocate Bulletin board */
p_iov->bulletin.size = sizeof(struct qed_bulletin_content);
p_iov->bulletin.p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
p_iov->bulletin.size,
&p_iov->bulletin.phys,
GFP_KERNEL);
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"VF's bulletin Board [%p virt 0x%llx phys 0x%08x bytes]\n",
p_iov->bulletin.p_virt,
(u64)p_iov->bulletin.phys, p_iov->bulletin.size);
mutex_init(&p_iov->mutex);
p_hwfn->vf_iov_info = p_iov;
p_hwfn->hw_info.personality = QED_PCI_ETH;
return qed_vf_pf_acquire(p_hwfn);
free_vf2pf_request:
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union vfpf_tlvs),
p_iov->vf2pf_request, p_iov->vf2pf_request_phys);
free_p_iov:
kfree(p_iov);
return -ENOMEM;
}
int qed_vf_pf_rxq_start(struct qed_hwfn *p_hwfn,
u8 rx_qid,
u16 sb,
u8 sb_index,
u16 bd_max_bytes,
dma_addr_t bd_chain_phys_addr,
dma_addr_t cqe_pbl_addr,
u16 cqe_pbl_size, void __iomem **pp_prod)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_start_queue_resp_tlv *resp;
struct vfpf_start_rxq_tlv *req;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_RXQ, sizeof(*req));
req->rx_qid = rx_qid;
req->cqe_pbl_addr = cqe_pbl_addr;
req->cqe_pbl_size = cqe_pbl_size;
req->rxq_addr = bd_chain_phys_addr;
req->hw_sb = sb;
req->sb_index = sb_index;
req->bd_max_bytes = bd_max_bytes;
req->stat_id = -1;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->queue_start;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
/* Learn the address of the producer from the response */
if (pp_prod) {
u64 init_prod_val = 0;
*pp_prod = (u8 __iomem *)p_hwfn->regview + resp->offset;
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"Rxq[0x%02x]: producer at %p [offset 0x%08x]\n",
rx_qid, *pp_prod, resp->offset);
/* Init the rcq, rx bd and rx sge (if valid) producers to 0 */
__internal_ram_wr(p_hwfn, *pp_prod, sizeof(u64),
(u32 *)&init_prod_val);
}
return rc;
}
int qed_vf_pf_rxq_stop(struct qed_hwfn *p_hwfn, u16 rx_qid, bool cqe_completion)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_stop_rxqs_tlv *req;
struct pfvf_def_resp_tlv *resp;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_RXQS, sizeof(*req));
req->rx_qid = rx_qid;
req->num_rxqs = 1;
req->cqe_completion = cqe_completion;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
return rc;
}
int qed_vf_pf_txq_start(struct qed_hwfn *p_hwfn,
u16 tx_queue_id,
u16 sb,
u8 sb_index,
dma_addr_t pbl_addr,
u16 pbl_size, void __iomem **pp_doorbell)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_start_queue_resp_tlv *resp;
struct vfpf_start_txq_tlv *req;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_START_TXQ, sizeof(*req));
req->tx_qid = tx_queue_id;
/* Tx */
req->pbl_addr = pbl_addr;
req->pbl_size = pbl_size;
req->hw_sb = sb;
req->sb_index = sb_index;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->queue_start;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
goto exit;
if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
rc = -EINVAL;
goto exit;
}
if (pp_doorbell) {
*pp_doorbell = (u8 __iomem *)p_hwfn->doorbells + resp->offset;
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"Txq[0x%02x]: doorbell at %p [offset 0x%08x]\n",
tx_queue_id, *pp_doorbell, resp->offset);
}
exit:
return rc;
}
int qed_vf_pf_txq_stop(struct qed_hwfn *p_hwfn, u16 tx_qid)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_stop_txqs_tlv *req;
struct pfvf_def_resp_tlv *resp;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_STOP_TXQS, sizeof(*req));
req->tx_qid = tx_qid;
req->num_txqs = 1;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
return rc;
}
int qed_vf_pf_vport_start(struct qed_hwfn *p_hwfn,
u8 vport_id,
u16 mtu,
u8 inner_vlan_removal,
enum qed_tpa_mode tpa_mode,
u8 max_buffers_per_cqe, u8 only_untagged)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_vport_start_tlv *req;
struct pfvf_def_resp_tlv *resp;
int rc, i;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_START, sizeof(*req));
req->mtu = mtu;
req->vport_id = vport_id;
req->inner_vlan_removal = inner_vlan_removal;
req->tpa_mode = tpa_mode;
req->max_buffers_per_cqe = max_buffers_per_cqe;
req->only_untagged = only_untagged;
/* status blocks */
for (i = 0; i < p_hwfn->vf_iov_info->acquire_resp.resc.num_sbs; i++)
if (p_hwfn->sbs_info[i])
req->sb_addr[i] = p_hwfn->sbs_info[i]->sb_phys;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
return rc;
}
int qed_vf_pf_vport_stop(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
int rc;
/* clear mailbox and prep first tlv */
qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_TEARDOWN,
sizeof(struct vfpf_first_tlv));
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
return rc;
}
static bool
qed_vf_handle_vp_update_is_needed(struct qed_hwfn *p_hwfn,
struct qed_sp_vport_update_params *p_data,
u16 tlv)
{
switch (tlv) {
case CHANNEL_TLV_VPORT_UPDATE_ACTIVATE:
return !!(p_data->update_vport_active_rx_flg ||
p_data->update_vport_active_tx_flg);
case CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH:
return !!p_data->update_tx_switching_flg;
case CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP:
return !!p_data->update_inner_vlan_removal_flg;
case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN:
return !!p_data->update_accept_any_vlan_flg;
case CHANNEL_TLV_VPORT_UPDATE_MCAST:
return !!p_data->update_approx_mcast_flg;
case CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM:
return !!(p_data->accept_flags.update_rx_mode_config ||
p_data->accept_flags.update_tx_mode_config);
case CHANNEL_TLV_VPORT_UPDATE_RSS:
return !!p_data->rss_params;
case CHANNEL_TLV_VPORT_UPDATE_SGE_TPA:
return !!p_data->sge_tpa_params;
default:
DP_INFO(p_hwfn, "Unexpected vport-update TLV[%d]\n",
tlv);
return false;
}
}
static void
qed_vf_handle_vp_update_tlvs_resp(struct qed_hwfn *p_hwfn,
struct qed_sp_vport_update_params *p_data)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_def_resp_tlv *p_resp;
u16 tlv;
for (tlv = CHANNEL_TLV_VPORT_UPDATE_ACTIVATE;
tlv < CHANNEL_TLV_VPORT_UPDATE_MAX; tlv++) {
if (!qed_vf_handle_vp_update_is_needed(p_hwfn, p_data, tlv))
continue;
p_resp = (struct pfvf_def_resp_tlv *)
qed_iov_search_list_tlvs(p_hwfn, p_iov->pf2vf_reply,
tlv);
if (p_resp && p_resp->hdr.status)
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"TLV[%d] Configuration %s\n",
tlv,
(p_resp && p_resp->hdr.status) ? "succeeded"
: "failed");
}
}
int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
struct qed_sp_vport_update_params *p_params)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_vport_update_tlv *req;
struct pfvf_def_resp_tlv *resp;
u8 update_rx, update_tx;
u32 resp_size = 0;
u16 size, tlv;
int rc;
resp = &p_iov->pf2vf_reply->default_resp;
resp_size = sizeof(*resp);
update_rx = p_params->update_vport_active_rx_flg;
update_tx = p_params->update_vport_active_tx_flg;
/* clear mailbox and prep header tlv */
qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_VPORT_UPDATE, sizeof(*req));
/* Prepare extended tlvs */
if (update_rx || update_tx) {
struct vfpf_vport_update_activate_tlv *p_act_tlv;
size = sizeof(struct vfpf_vport_update_activate_tlv);
p_act_tlv = qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
if (update_rx) {
p_act_tlv->update_rx = update_rx;
p_act_tlv->active_rx = p_params->vport_active_rx_flg;
}
if (update_tx) {
p_act_tlv->update_tx = update_tx;
p_act_tlv->active_tx = p_params->vport_active_tx_flg;
}
}
if (p_params->update_tx_switching_flg) {
struct vfpf_vport_update_tx_switch_tlv *p_tx_switch_tlv;
size = sizeof(struct vfpf_vport_update_tx_switch_tlv);
tlv = CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH;
p_tx_switch_tlv = qed_add_tlv(p_hwfn, &p_iov->offset,
tlv, size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
p_tx_switch_tlv->tx_switching = p_params->tx_switching_flg;
}
if (p_params->update_approx_mcast_flg) {
struct vfpf_vport_update_mcast_bin_tlv *p_mcast_tlv;
size = sizeof(struct vfpf_vport_update_mcast_bin_tlv);
p_mcast_tlv = qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_VPORT_UPDATE_MCAST, size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
memcpy(p_mcast_tlv->bins, p_params->bins,
sizeof(unsigned long) * ETH_MULTICAST_MAC_BINS_IN_REGS);
}
update_rx = p_params->accept_flags.update_rx_mode_config;
update_tx = p_params->accept_flags.update_tx_mode_config;
if (update_rx || update_tx) {
struct vfpf_vport_update_accept_param_tlv *p_accept_tlv;
tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM;
size = sizeof(struct vfpf_vport_update_accept_param_tlv);
p_accept_tlv = qed_add_tlv(p_hwfn, &p_iov->offset, tlv, size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
if (update_rx) {
p_accept_tlv->update_rx_mode = update_rx;
p_accept_tlv->rx_accept_filter =
p_params->accept_flags.rx_accept_filter;
}
if (update_tx) {
p_accept_tlv->update_tx_mode = update_tx;
p_accept_tlv->tx_accept_filter =
p_params->accept_flags.tx_accept_filter;
}
}
if (p_params->rss_params) {
struct qed_rss_params *rss_params = p_params->rss_params;
struct vfpf_vport_update_rss_tlv *p_rss_tlv;
size = sizeof(struct vfpf_vport_update_rss_tlv);
p_rss_tlv = qed_add_tlv(p_hwfn,
&p_iov->offset,
CHANNEL_TLV_VPORT_UPDATE_RSS, size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
if (rss_params->update_rss_config)
p_rss_tlv->update_rss_flags |=
VFPF_UPDATE_RSS_CONFIG_FLAG;
if (rss_params->update_rss_capabilities)
p_rss_tlv->update_rss_flags |=
VFPF_UPDATE_RSS_CAPS_FLAG;
if (rss_params->update_rss_ind_table)
p_rss_tlv->update_rss_flags |=
VFPF_UPDATE_RSS_IND_TABLE_FLAG;
if (rss_params->update_rss_key)
p_rss_tlv->update_rss_flags |= VFPF_UPDATE_RSS_KEY_FLAG;
p_rss_tlv->rss_enable = rss_params->rss_enable;
p_rss_tlv->rss_caps = rss_params->rss_caps;
p_rss_tlv->rss_table_size_log = rss_params->rss_table_size_log;
memcpy(p_rss_tlv->rss_ind_table, rss_params->rss_ind_table,
sizeof(rss_params->rss_ind_table));
memcpy(p_rss_tlv->rss_key, rss_params->rss_key,
sizeof(rss_params->rss_key));
}
if (p_params->update_accept_any_vlan_flg) {
struct vfpf_vport_update_accept_any_vlan_tlv *p_any_vlan_tlv;
size = sizeof(struct vfpf_vport_update_accept_any_vlan_tlv);
tlv = CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN;
p_any_vlan_tlv = qed_add_tlv(p_hwfn, &p_iov->offset, tlv, size);
resp_size += sizeof(struct pfvf_def_resp_tlv);
p_any_vlan_tlv->accept_any_vlan = p_params->accept_any_vlan;
p_any_vlan_tlv->update_accept_any_vlan_flg =
p_params->update_accept_any_vlan_flg;
}
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, resp_size);
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
qed_vf_handle_vp_update_tlvs_resp(p_hwfn, p_params);
return rc;
}
int qed_vf_pf_reset(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_def_resp_tlv *resp;
struct vfpf_first_tlv *req;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_CLOSE, sizeof(*req));
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EAGAIN;
p_hwfn->b_int_enabled = 0;
return 0;
}
int qed_vf_pf_release(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_def_resp_tlv *resp;
struct vfpf_first_tlv *req;
u32 size;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_RELEASE, sizeof(*req));
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (!rc && resp->hdr.status != PFVF_STATUS_SUCCESS)
rc = -EAGAIN;
p_hwfn->b_int_enabled = 0;
if (p_iov->vf2pf_request)
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union vfpf_tlvs),
p_iov->vf2pf_request,
p_iov->vf2pf_request_phys);
if (p_iov->pf2vf_reply)
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union pfvf_tlvs),
p_iov->pf2vf_reply, p_iov->pf2vf_reply_phys);
if (p_iov->bulletin.p_virt) {
size = sizeof(struct qed_bulletin_content);
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
size,
p_iov->bulletin.p_virt, p_iov->bulletin.phys);
}
kfree(p_hwfn->vf_iov_info);
p_hwfn->vf_iov_info = NULL;
return rc;
}
void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
struct qed_filter_mcast *p_filter_cmd)
{
struct qed_sp_vport_update_params sp_params;
int i;
memset(&sp_params, 0, sizeof(sp_params));
sp_params.update_approx_mcast_flg = 1;
if (p_filter_cmd->opcode == QED_FILTER_ADD) {
for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) {
u32 bit;
bit = qed_mcast_bin_from_mac(p_filter_cmd->mac[i]);
__set_bit(bit, sp_params.bins);
}
}
qed_vf_pf_vport_update(p_hwfn, &sp_params);
}
int qed_vf_pf_filter_ucast(struct qed_hwfn *p_hwfn,
struct qed_filter_ucast *p_ucast)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct vfpf_ucast_filter_tlv *req;
struct pfvf_def_resp_tlv *resp;
int rc;
/* clear mailbox and prep first tlv */
req = qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_UCAST_FILTER, sizeof(*req));
req->opcode = (u8) p_ucast->opcode;
req->type = (u8) p_ucast->type;
memcpy(req->mac, p_ucast->mac, ETH_ALEN);
req->vlan = p_ucast->vlan;
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
resp = &p_iov->pf2vf_reply->default_resp;
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EAGAIN;
return 0;
}
int qed_vf_pf_int_cleanup(struct qed_hwfn *p_hwfn)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct pfvf_def_resp_tlv *resp = &p_iov->pf2vf_reply->default_resp;
int rc;
/* clear mailbox and prep first tlv */
qed_vf_pf_prep(p_hwfn, CHANNEL_TLV_INT_CLEANUP,
sizeof(struct vfpf_first_tlv));
/* add list termination tlv */
qed_add_tlv(p_hwfn, &p_iov->offset,
CHANNEL_TLV_LIST_END, sizeof(struct channel_list_end_tlv));
rc = qed_send_msg2pf(p_hwfn, &resp->hdr.status, sizeof(*resp));
if (rc)
return rc;
if (resp->hdr.status != PFVF_STATUS_SUCCESS)
return -EINVAL;
return 0;
}
u16 qed_vf_get_igu_sb_id(struct qed_hwfn *p_hwfn, u16 sb_id)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
if (!p_iov) {
DP_NOTICE(p_hwfn, "vf_sriov_info isn't initialized\n");
return 0;
}
return p_iov->acquire_resp.resc.hw_sbs[sb_id].hw_sb_id;
}
int qed_vf_read_bulletin(struct qed_hwfn *p_hwfn, u8 *p_change)
{
struct qed_vf_iov *p_iov = p_hwfn->vf_iov_info;
struct qed_bulletin_content shadow;
u32 crc, crc_size;
crc_size = sizeof(p_iov->bulletin.p_virt->crc);
*p_change = 0;
/* Need to guarantee PF is not in the middle of writing it */
memcpy(&shadow, p_iov->bulletin.p_virt, p_iov->bulletin.size);
/* If version did not update, no need to do anything */
if (shadow.version == p_iov->bulletin_shadow.version)
return 0;
/* Verify the bulletin we see is valid */
crc = crc32(0, (u8 *)&shadow + crc_size,
p_iov->bulletin.size - crc_size);
if (crc != shadow.crc)
return -EAGAIN;
/* Set the shadow bulletin and process it */
memcpy(&p_iov->bulletin_shadow, &shadow, p_iov->bulletin.size);
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"Read a bulletin update %08x\n", shadow.version);
*p_change = 1;
return 0;
}
void __qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_params *p_params,
struct qed_bulletin_content *p_bulletin)
{
memset(p_params, 0, sizeof(*p_params));
p_params->speed.autoneg = p_bulletin->req_autoneg;
p_params->speed.advertised_speeds = p_bulletin->req_adv_speed;
p_params->speed.forced_speed = p_bulletin->req_forced_speed;
p_params->pause.autoneg = p_bulletin->req_autoneg_pause;
p_params->pause.forced_rx = p_bulletin->req_forced_rx;
p_params->pause.forced_tx = p_bulletin->req_forced_tx;
p_params->loopback_mode = p_bulletin->req_loopback;
}
void qed_vf_get_link_params(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_params *params)
{
__qed_vf_get_link_params(p_hwfn, params,
&(p_hwfn->vf_iov_info->bulletin_shadow));
}
void __qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_state *p_link,
struct qed_bulletin_content *p_bulletin)
{
memset(p_link, 0, sizeof(*p_link));
p_link->link_up = p_bulletin->link_up;
p_link->speed = p_bulletin->speed;
p_link->full_duplex = p_bulletin->full_duplex;
p_link->an = p_bulletin->autoneg;
p_link->an_complete = p_bulletin->autoneg_complete;
p_link->parallel_detection = p_bulletin->parallel_detection;
p_link->pfc_enabled = p_bulletin->pfc_enabled;
p_link->partner_adv_speed = p_bulletin->partner_adv_speed;
p_link->partner_tx_flow_ctrl_en = p_bulletin->partner_tx_flow_ctrl_en;
p_link->partner_rx_flow_ctrl_en = p_bulletin->partner_rx_flow_ctrl_en;
p_link->partner_adv_pause = p_bulletin->partner_adv_pause;
p_link->sfp_tx_fault = p_bulletin->sfp_tx_fault;
}
void qed_vf_get_link_state(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_state *link)
{
__qed_vf_get_link_state(p_hwfn, link,
&(p_hwfn->vf_iov_info->bulletin_shadow));
}
void __qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_capabilities *p_link_caps,
struct qed_bulletin_content *p_bulletin)
{
memset(p_link_caps, 0, sizeof(*p_link_caps));
p_link_caps->speed_capabilities = p_bulletin->capability_speed;
}
void qed_vf_get_link_caps(struct qed_hwfn *p_hwfn,
struct qed_mcp_link_capabilities *p_link_caps)
{
__qed_vf_get_link_caps(p_hwfn, p_link_caps,
&(p_hwfn->vf_iov_info->bulletin_shadow));
}
void qed_vf_get_num_rxqs(struct qed_hwfn *p_hwfn, u8 *num_rxqs)
{
*num_rxqs = p_hwfn->vf_iov_info->acquire_resp.resc.num_rxqs;
}
void qed_vf_get_port_mac(struct qed_hwfn *p_hwfn, u8 *port_mac)
{
memcpy(port_mac,
p_hwfn->vf_iov_info->acquire_resp.pfdev_info.port_mac, ETH_ALEN);
}
void qed_vf_get_num_vlan_filters(struct qed_hwfn *p_hwfn, u8 *num_vlan_filters)
{
struct qed_vf_iov *p_vf;
p_vf = p_hwfn->vf_iov_info;
*num_vlan_filters = p_vf->acquire_resp.resc.num_vlan_filters;
}
bool qed_vf_check_mac(struct qed_hwfn *p_hwfn, u8 *mac)
{
struct qed_bulletin_content *bulletin;
bulletin = &p_hwfn->vf_iov_info->bulletin_shadow;
if (!(bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)))
return true;
/* Forbid VF from changing a MAC enforced by PF */
if (ether_addr_equal(bulletin->mac, mac))
return false;
return false;
}
bool qed_vf_bulletin_get_forced_mac(struct qed_hwfn *hwfn,
u8 *dst_mac, u8 *p_is_forced)
{
struct qed_bulletin_content *bulletin;
bulletin = &hwfn->vf_iov_info->bulletin_shadow;
if (bulletin->valid_bitmap & (1 << MAC_ADDR_FORCED)) {
if (p_is_forced)
*p_is_forced = 1;
} else if (bulletin->valid_bitmap & (1 << VFPF_BULLETIN_MAC_ADDR)) {
if (p_is_forced)
*p_is_forced = 0;
} else {
return false;
}
ether_addr_copy(dst_mac, bulletin->mac);
return true;
}
void qed_vf_get_fw_version(struct qed_hwfn *p_hwfn,
u16 *fw_major, u16 *fw_minor,
u16 *fw_rev, u16 *fw_eng)
{
struct pf_vf_pfdev_info *info;
info = &p_hwfn->vf_iov_info->acquire_resp.pfdev_info;
*fw_major = info->fw_major;
*fw_minor = info->fw_minor;
*fw_rev = info->fw_rev;
*fw_eng = info->fw_eng;
}
static void qed_handle_bulletin_change(struct qed_hwfn *hwfn)
{
struct qed_eth_cb_ops *ops = hwfn->cdev->protocol_ops.eth;
u8 mac[ETH_ALEN], is_mac_exist, is_mac_forced;
void *cookie = hwfn->cdev->ops_cookie;
is_mac_exist = qed_vf_bulletin_get_forced_mac(hwfn, mac,
&is_mac_forced);
if (is_mac_exist && is_mac_forced && cookie)
ops->force_mac(cookie, mac);
/* Always update link configuration according to bulletin */
qed_link_update(hwfn);
}
void qed_iov_vf_task(struct work_struct *work)
{
struct qed_hwfn *hwfn = container_of(work, struct qed_hwfn,
iov_task.work);
u8 change = 0;
if (test_and_clear_bit(QED_IOV_WQ_STOP_WQ_FLAG, &hwfn->iov_task_flags))
return;
/* Handle bulletin board changes */
qed_vf_read_bulletin(hwfn, &change);
if (change)
qed_handle_bulletin_change(hwfn);
/* As VF is polling bulletin board, need to constantly re-schedule */
queue_delayed_work(hwfn->iov_wq, &hwfn->iov_task, HZ);
}
| {
"pile_set_name": "Github"
} |
#include "Copter.h"
// This file contains the high-level takeoff logic for Loiter, PosHold, AltHold, Sport modes.
// The take-off can be initiated from a GCS NAV_TAKEOFF command which includes a takeoff altitude
// A safe takeoff speed is calculated and used to calculate a time_ms
// the pos_control target is then slowly increased until time_ms expires
// return true if this flight mode supports user takeoff
// must_nagivate is true if mode must also control horizontal position
bool Copter::current_mode_has_user_takeoff(bool must_navigate)
{
switch (control_mode) {
case GUIDED:
case LOITER:
case POSHOLD:
return true;
case ALT_HOLD:
case SPORT:
return !must_navigate;
default:
return false;
}
}
// initiate user takeoff - called when MAVLink TAKEOFF command is received
bool Copter::do_user_takeoff(float takeoff_alt_cm, bool must_navigate)
{
if (motors->armed() && ap.land_complete && current_mode_has_user_takeoff(must_navigate) && takeoff_alt_cm > current_loc.alt) {
#if FRAME_CONFIG == HELI_FRAME
// Helicopters should return false if MAVlink takeoff command is received while the rotor is not spinning
if (!motors->rotor_runup_complete()) {
return false;
}
#endif
switch(control_mode) {
case GUIDED:
if (guided_takeoff_start(takeoff_alt_cm)) {
set_auto_armed(true);
return true;
}
return false;
case LOITER:
case POSHOLD:
case ALT_HOLD:
case SPORT:
set_auto_armed(true);
takeoff_timer_start(takeoff_alt_cm);
return true;
default:
return false;
}
}
return false;
}
// start takeoff to specified altitude above home in centimeters
void Copter::takeoff_timer_start(float alt_cm)
{
// calculate climb rate
float speed = MIN(wp_nav->get_speed_up(), MAX(g.pilot_velocity_z_max*2.0f/3.0f, g.pilot_velocity_z_max-50.0f));
// sanity check speed and target
if (takeoff_state.running || speed <= 0.0f || alt_cm <= 0.0f) {
return;
}
// initialise takeoff state
takeoff_state.running = true;
takeoff_state.max_speed = speed;
takeoff_state.start_ms = millis();
takeoff_state.alt_delta = alt_cm;
}
// stop takeoff
void Copter::takeoff_stop()
{
takeoff_state.running = false;
takeoff_state.start_ms = 0;
}
// returns pilot and takeoff climb rates
// pilot_climb_rate is both an input and an output
// takeoff_climb_rate is only an output
// has side-effect of turning takeoff off when timeout as expired
void Copter::takeoff_get_climb_rates(float& pilot_climb_rate, float& takeoff_climb_rate)
{
// return pilot_climb_rate if take-off inactive
if (!takeoff_state.running) {
takeoff_climb_rate = 0.0f;
return;
}
// acceleration of 50cm/s/s
static const float takeoff_accel = 50.0f;
float takeoff_minspeed = MIN(50.0f,takeoff_state.max_speed);
float time_elapsed = (millis()-takeoff_state.start_ms)*1.0e-3f;
float speed = MIN(time_elapsed*takeoff_accel+takeoff_minspeed, takeoff_state.max_speed);
float time_to_max_speed = (takeoff_state.max_speed-takeoff_minspeed)/takeoff_accel;
float height_gained;
if (time_elapsed <= time_to_max_speed) {
height_gained = 0.5f*takeoff_accel*sq(time_elapsed) + takeoff_minspeed*time_elapsed;
} else {
height_gained = 0.5f*takeoff_accel*sq(time_to_max_speed) + takeoff_minspeed*time_to_max_speed +
(time_elapsed-time_to_max_speed)*takeoff_state.max_speed;
}
// check if the takeoff is over
if (height_gained >= takeoff_state.alt_delta) {
takeoff_stop();
}
// if takeoff climb rate is zero return
if (speed <= 0.0f) {
takeoff_climb_rate = 0.0f;
return;
}
// default take-off climb rate to maximum speed
takeoff_climb_rate = speed;
// if pilot's commands descent
if (pilot_climb_rate < 0.0f) {
// if overall climb rate is still positive, move to take-off climb rate
if (takeoff_climb_rate + pilot_climb_rate > 0.0f) {
takeoff_climb_rate = takeoff_climb_rate + pilot_climb_rate;
pilot_climb_rate = 0;
} else {
// if overall is negative, move to pilot climb rate
pilot_climb_rate = pilot_climb_rate + takeoff_climb_rate;
takeoff_climb_rate = 0.0f;
}
} else { // pilot commands climb
// pilot climb rate is zero until it surpasses the take-off climb rate
if (pilot_climb_rate > takeoff_climb_rate) {
pilot_climb_rate = pilot_climb_rate - takeoff_climb_rate;
} else {
pilot_climb_rate = 0.0f;
}
}
}
void Copter::auto_takeoff_set_start_alt(void)
{
// start with our current altitude
auto_takeoff_no_nav_alt_cm = inertial_nav.get_altitude();
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock() || ap.land_complete) {
// we are not flying, add the wp_navalt_min
auto_takeoff_no_nav_alt_cm += g2.wp_navalt_min * 100;
}
}
/*
call attitude controller for automatic takeoff, limiting roll/pitch
if below wp_navalt_min
*/
void Copter::auto_takeoff_attitude_run(float target_yaw_rate)
{
float nav_roll, nav_pitch;
if (g2.wp_navalt_min > 0 && inertial_nav.get_altitude() < auto_takeoff_no_nav_alt_cm) {
// we haven't reached the takeoff navigation altitude yet
nav_roll = 0;
nav_pitch = 0;
#if FRAME_CONFIG == HELI_FRAME
// prevent hover roll starting till past specified altitude
hover_roll_trim_scalar_slew = 0;
#endif
// tell the position controller that we have limited roll/pitch demand to prevent integrator buildup
pos_control->set_limit_accel_xy();
} else {
nav_roll = wp_nav->get_roll();
nav_pitch = wp_nav->get_pitch();
}
// roll & pitch from waypoint controller, yaw rate from pilot
attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(nav_roll, nav_pitch, target_yaw_rate, get_smoothing_gain());
}
| {
"pile_set_name": "Github"
} |
package pl.pszklarska.livedatabinding.viewmodel
import pl.pszklarska.livedatabinding.model.Kitty
import java.util.*
import java.util.concurrent.TimeUnit
typealias NewKittiesReceived = (Kitty) -> Unit
class KittyRepository {
private val timer = Timer()
private val random = Random()
private val period = TimeUnit.SECONDS.toMillis(1)
internal fun receiveNewKitties(newKittiesReceived: NewKittiesReceived) {
timer.schedule(object : TimerTask() {
override fun run() {
val nameRandom = random.nextInt(KittyNames.values().size)
val ageRandom = random.nextInt(5)
newKittiesReceived.invoke(Kitty(KittyNames.values()[nameRandom].name, ageRandom))
}
}, period, period)
}
}
| {
"pile_set_name": "Github"
} |
//
// BalloonMarker.swift
// ChartsDemo
//
// Created by Daniel Cohen Gindi on 19/3/15.
//
// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
// A port of MPAndroidChart for iOS
// Licensed under Apache License 2.0
//
// https://github.com/danielgindi/ios-charts
// https://github.com/danielgindi/Charts/blob/1788e53f22eb3de79eb4f08574d8ea4b54b5e417/ChartsDemo/Classes/Components/BalloonMarker.swift
// Edit: Added textColor
import Foundation;
import Charts;
import SwiftyJSON;
open class BalloonMarker: MarkerView {
open var color: UIColor?
open var arrowSize = CGSize(width: 15, height: 11)
open var font: UIFont?
open var textColor: UIColor?
open var minimumSize = CGSize()
fileprivate var insets = UIEdgeInsets(top: 8.0,left: 8.0,bottom: 20.0,right: 8.0)
fileprivate var topInsets = UIEdgeInsets(top: 20.0,left: 8.0,bottom: 8.0,right: 8.0)
fileprivate var labelns: NSString?
fileprivate var _labelSize: CGSize = CGSize()
fileprivate var _size: CGSize = CGSize()
fileprivate var _paragraphStyle: NSMutableParagraphStyle?
fileprivate var _drawAttributes = [NSAttributedString.Key: Any]()
public init(color: UIColor, font: UIFont, textColor: UIColor, textAlign: NSTextAlignment) {
super.init(frame: CGRect.zero);
self.color = color
self.font = font
self.textColor = textColor
_paragraphStyle = NSParagraphStyle.default.mutableCopy() as? NSMutableParagraphStyle
_paragraphStyle?.alignment = textAlign
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented");
}
func drawRect(context: CGContext, point: CGPoint) -> CGRect{
let chart = super.chartView
let width = _size.width
var rect = CGRect(origin: point, size: _size)
if point.y - _size.height < 0 {
if point.x - _size.width / 2.0 < 0 {
drawTopLeftRect(context: context, rect: rect)
} else if (chart != nil && point.x + width - _size.width / 2.0 > (chart?.bounds.width)!) {
rect.origin.x -= _size.width
drawTopRightRect(context: context, rect: rect)
} else {
rect.origin.x -= _size.width / 2.0
drawTopCenterRect(context: context, rect: rect)
}
rect.origin.y += self.topInsets.top
rect.size.height -= self.topInsets.top + self.topInsets.bottom
} else {
rect.origin.y -= _size.height
if point.x - _size.width / 2.0 < 0 {
drawLeftRect(context: context, rect: rect)
} else if (chart != nil && point.x + width - _size.width / 2.0 > (chart?.bounds.width)!) {
rect.origin.x -= _size.width
drawRightRect(context: context, rect: rect)
} else {
rect.origin.x -= _size.width / 2.0
drawCenterRect(context: context, rect: rect)
}
rect.origin.y += self.insets.top
rect.size.height -= self.insets.top + self.insets.bottom
}
return rect
}
func drawCenterRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + (rect.size.width + arrowSize.width) / 2.0, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width / 2.0, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x + (rect.size.width - arrowSize.width) / 2.0, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.fillPath()
}
func drawLeftRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + arrowSize.width / 2.0, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.fillPath()
}
func drawRightRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width - arrowSize.width / 2.0, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height - arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.fillPath()
}
func drawTopCenterRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x + rect.size.width / 2.0, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + (rect.size.width + arrowSize.width) / 2.0, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + (rect.size.width - arrowSize.width) / 2.0, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width / 2.0, y: rect.origin.y))
context.fillPath()
}
func drawTopLeftRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + arrowSize.width / 2.0, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y))
context.fillPath()
}
func drawTopRightRect(context: CGContext, rect: CGRect) {
context.setFillColor((color?.cgColor)!)
context.beginPath()
context.move(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + rect.size.height))
context.addLine(to: CGPoint(x: rect.origin.x, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width - arrowSize.height / 2.0, y: rect.origin.y + arrowSize.height))
context.addLine(to: CGPoint(x: rect.origin.x + rect.size.width, y: rect.origin.y))
context.fillPath()
}
open override func draw(context: CGContext, point: CGPoint) {
if (labelns == nil || labelns?.length == 0) {
return
}
context.saveGState()
let rect = drawRect(context: context, point: point)
UIGraphicsPushContext(context)
labelns?.draw(in: rect, withAttributes: _drawAttributes)
UIGraphicsPopContext()
context.restoreGState()
}
open override func refreshContent(entry: ChartDataEntry, highlight: Highlight) {
var label : String;
if let candleEntry = entry as? CandleChartDataEntry {
label = candleEntry.close.description
} else {
label = entry.y.description
}
if let object = entry.data as? JSON {
if object["marker"].exists() {
label = object["marker"].stringValue;
if highlight.stackIndex != -1 && object["marker"].array != nil {
label = object["marker"].arrayValue[highlight.stackIndex].stringValue
}
}
}
labelns = label as NSString
_drawAttributes.removeAll()
_drawAttributes[NSAttributedString.Key.font] = self.font
_drawAttributes[NSAttributedString.Key.paragraphStyle] = _paragraphStyle
_drawAttributes[NSAttributedString.Key.foregroundColor] = self.textColor
_labelSize = labelns?.size(withAttributes: _drawAttributes) ?? CGSize.zero
_size.width = _labelSize.width + self.insets.left + self.insets.right
_size.height = _labelSize.height + self.insets.top + self.insets.bottom
_size.width = max(minimumSize.width, _size.width)
_size.height = max(minimumSize.height, _size.height)
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.runtime;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.types.*;
/** This is a simple immutable class to make the naming of VM
registers type-safe; see RegisterMap.java and frame.hpp. */
public class VMReg {
private int value;
// C2 only
public static Address matcherRegEncodeAddr;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static void initialize(TypeDataBase db) {
if (VM.getVM().isServerCompiler()) {
Type type = db.lookupType("Matcher");
Field f = type.getField("_regEncode");
matcherRegEncodeAddr = f.getStaticFieldAddress();
}
}
public VMReg(int i) {
value = i;
}
public int getValue() {
return value;
}
public int regEncode() {
if (matcherRegEncodeAddr != null) {
return (int) matcherRegEncodeAddr.getCIntegerAt(value, 1, true);
}
return value;
}
public boolean equals(Object arg) {
if ((arg != null) || (!(arg instanceof VMReg))) {
return false;
}
return ((VMReg) arg).value == value;
}
public boolean lessThan(VMReg arg) { return value < arg.value; }
public boolean lessThanOrEqual(VMReg arg) { return value <= arg.value; }
public boolean greaterThan(VMReg arg) { return value > arg.value; }
public boolean greaterThanOrEqual(VMReg arg) { return value >= arg.value; }
public int minus(VMReg arg) { return value - arg.value; }
public int reg2Stack() {
return value - VM.getVM().getVMRegImplInfo().getStack0().getValue();
}
}
| {
"pile_set_name": "Github"
} |
#include <stdio.h>
int main()
{
puts("Hello from main project!");
return 0;
} | {
"pile_set_name": "Github"
} |
Description:
Compare two memory areas with possibly different lengths.
Files:
lib/memcmp2.h
lib/memcmp2.c
Depends-on:
configure.ac:
Makefile.am:
lib_SOURCES += memcmp2.c
Include:
"memcmp2.h"
License:
LGPLv2+
Maintainer:
all
| {
"pile_set_name": "Github"
} |
# escape sequences are permitted only inside strings
# { 'command': 'foo', 'data': {} }
{ 'command': 'foo', 'data'\u003a{} }
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS 2.1 Test Suite: display</title>
<style type="text/css"><![CDATA[
p, div { color: navy; }
.one {display: block;}
.two {display: inline;}
.three {display: list-item; list-style-type: decimal; list-style-position: inside;}
.four {display: none; color: yellow; background: red;}
a {display: block;}
]]></style>
<link title="12.5 Lists" href="http://www.w3.org/TR/CSS21/generate.html#q10" rel="help"/>
<link title="9.2.4 The 'display' property" href="http://www.w3.org/TR/CSS21/visuren.html#display-prop" rel="help"/>
</head>
<body>
<p class="pc">There should be eight numbered lines below, all identical except for the numbering. </p>
<div class="three"> This should be line one. </div>
<div class="one"> 2. This should be line two. </div>
<div class="two"> 3. This should </div>
<div class="two"> be line three. </div>
<div> 4. This should be line four. </div>
<div class="four"> FAIL: This text should not appear. </div>
<div> 5. This should be line five. <span class="four">FAIL: This text should not appear.</span> </div>
<div> 6. This should be line six. <a>7. This should be line seven.</a> 8. This should be line eight. </div>
</body>
</html> | {
"pile_set_name": "Github"
} |
/*
* QtDownload.h
*
*
* Copyright 2013 Scott Wilson.
*
* This file is part of SuperCollider.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QObject>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class QtDownload : public QObject {
Q_OBJECT
Q_PROPERTY(QString source READ source WRITE setSource);
Q_PROPERTY(QString destination READ destination WRITE setDestination);
public:
explicit QtDownload();
~QtDownload();
void setSource(const QString& t);
void setDestination(const QString& l);
QString source() { return m_target; }
QString destination() { return m_local; }
Q_INVOKABLE void cancel();
Q_INVOKABLE void download();
Q_SIGNALS:
void doFinished();
void doError();
void doProgress(int, int);
private:
QNetworkAccessManager* m_manager;
QString m_target;
QString m_local;
QNetworkReply* m_reply;
bool started;
public Q_SLOTS:
void downloadFinished();
void downloadProgress(qint64 received, qint64 total);
void replyError(QNetworkReply::NetworkError errorCode);
}; | {
"pile_set_name": "Github"
} |
# frozen_string_literal: true
Capybara::SpecHelper.spec '#match_selector?' do
let(:element) { @session.find(:xpath, '//span', text: '42') }
before do
@session.visit('/with_html')
end
it 'should be true if the element matches the given selector' do
expect(element).to match_selector(:xpath, '//span')
expect(element).to match_selector(:css, 'span.number')
expect(element.matches_selector?(:css, 'span.number')).to be true
end
it 'should be false if the element does not match the given selector' do
expect(element).not_to match_selector(:xpath, '//div')
expect(element).not_to match_selector(:css, 'span.not_a_number')
expect(element.matches_selector?(:css, 'span.not_a_number')).to be false
end
it 'should use default selector' do
Capybara.default_selector = :css
expect(element).not_to match_selector('span.not_a_number')
expect(element).to match_selector('span.number')
end
it 'should work with elements located via a sibling selector' do
sibling = element.sibling(:css, 'span', text: 'Other span')
expect(sibling).to match_selector(:xpath, '//span')
expect(sibling).to match_selector(:css, 'span')
end
it 'should work with the html element' do
html = @session.find('/html')
expect(html).to match_selector(:css, 'html')
end
context 'with text' do
it 'should discard all matches where the given string is not contained' do
expect(element).to match_selector('//span', text: '42')
expect(element).not_to match_selector('//span', text: 'Doesnotexist')
end
end
it 'should have css sugar' do
expect(element.matches_css?('span.number')).to be true
expect(element.matches_css?('span.not_a_number')).to be false
expect(element.matches_css?('span.number', text: '42')).to be true
expect(element.matches_css?('span.number', text: 'Nope')).to be false
end
it 'should have xpath sugar' do
expect(element.matches_xpath?('//span')).to be true
expect(element.matches_xpath?('//div')).to be false
expect(element.matches_xpath?('//span', text: '42')).to be true
expect(element.matches_xpath?('//span', text: 'Nope')).to be false
end
it 'should accept selector filters' do
@session.visit('/form')
cbox = @session.find(:css, '#form_pets_dog')
expect(cbox.matches_selector?(:checkbox, id: 'form_pets_dog', option: 'dog', name: 'form[pets][]', checked: true)).to be true
end
it 'should accept a custom filter block' do
@session.visit('/form')
cbox = @session.find(:css, '#form_pets_dog')
expect(cbox).to match_selector(:checkbox) { |node| node[:id] == 'form_pets_dog' }
expect(cbox).not_to match_selector(:checkbox) { |node| node[:id] != 'form_pets_dog' }
expect(cbox.matches_selector?(:checkbox) { |node| node[:id] == 'form_pets_dog' }).to be true
expect(cbox.matches_selector?(:checkbox) { |node| node[:id] != 'form_pets_dog' }).to be false
end
end
Capybara::SpecHelper.spec '#not_matches_selector?' do
let(:element) { @session.find(:css, 'span', text: 42) }
before do
@session.visit('/with_html')
end
it 'should be false if the given selector matches the element' do
expect(element).not_to not_match_selector(:xpath, '//span')
expect(element).not_to not_match_selector(:css, 'span.number')
expect(element.not_matches_selector?(:css, 'span.number')).to be false
end
it 'should be true if the given selector does not match the element' do
expect(element).to not_match_selector(:xpath, '//abbr')
expect(element).to not_match_selector(:css, 'p a#doesnotexist')
expect(element.not_matches_selector?(:css, 'p a#doesnotexist')).to be true
end
it 'should use default selector' do
Capybara.default_selector = :css
expect(element).to not_match_selector('p a#doesnotexist')
expect(element).not_to not_match_selector('span.number')
end
context 'with text' do
it 'should discard all matches where the given string is contained' do
expect(element).not_to not_match_selector(:css, 'span.number', text: '42')
expect(element).to not_match_selector(:css, 'span.number', text: 'Doesnotexist')
end
end
it 'should have CSS sugar' do
expect(element.not_matches_css?('span.number')).to be false
expect(element.not_matches_css?('p a#doesnotexist')).to be true
expect(element.not_matches_css?('span.number', text: '42')).to be false
expect(element.not_matches_css?('span.number', text: 'Doesnotexist')).to be true
end
it 'should have xpath sugar' do
expect(element.not_matches_xpath?('//span')).to be false
expect(element.not_matches_xpath?('//div')).to be true
expect(element.not_matches_xpath?('//span', text: '42')).to be false
expect(element.not_matches_xpath?('//span', text: 'Doesnotexist')).to be true
end
end
| {
"pile_set_name": "Github"
} |
# frozen_string_literal: true
# WARNING ABOUT GENERATED CODE
#
# This file is generated. See the contributing guide for more information:
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
#
# WARNING ABOUT GENERATED CODE
Gem::Specification.new do |spec|
spec.name = 'aws-sdk-simpledb'
spec.version = File.read(File.expand_path('../VERSION', __FILE__)).strip
spec.summary = 'AWS SDK for Ruby - Amazon SimpleDB'
spec.description = 'Official AWS Ruby gem for Amazon SimpleDB. This gem is part of the AWS SDK for Ruby.'
spec.author = 'Amazon Web Services'
spec.homepage = 'https://github.com/aws/aws-sdk-ruby'
spec.license = 'Apache-2.0'
spec.email = ['[email protected]']
spec.require_paths = ['lib']
spec.files = Dir['lib/**/*.rb']
spec.metadata = {
'source_code_uri' => 'https://github.com/aws/aws-sdk-ruby/tree/master/gems/aws-sdk-simpledb',
'changelog_uri' => 'https://github.com/aws/aws-sdk-ruby/tree/master/gems/aws-sdk-simpledb/CHANGELOG.md'
}
spec.add_dependency('aws-sdk-core', '~> 3', '>= 3.99.0')
spec.add_dependency('aws-sigv2', '~> 1.0')
end
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
| {
"pile_set_name": "Github"
} |
import { CommonModule } from '@angular/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { DelonUtilModule } from '@delon/util';
import { ACLIfDirective } from './acl-if.directive';
import { ACLDirective } from './acl.directive';
import { ACLService } from './acl.service';
const COMPONENTS = [ACLDirective, ACLIfDirective];
@NgModule({
imports: [CommonModule, DelonUtilModule],
declarations: [...COMPONENTS],
exports: [...COMPONENTS],
})
export class DelonACLModule {
static forRoot(): ModuleWithProviders<DelonACLModule> {
return {
ngModule: DelonACLModule,
providers: [ACLService],
};
}
}
| {
"pile_set_name": "Github"
} |
const fetch = require('node-fetch');
{{?data.bodyParameter.present}}const inputBody = '{{=data.bodyParameter.exampleValues.json}}';{{?}}
{{?data.allHeaders.length}}const headers = {
{{~data.allHeaders :p:index}} '{{=p.name}}':{{=p.exampleValues.json}}{{?index < data.allHeaders.length-1}},{{?}}
{{~}}
};
{{?}}
fetch('{{=data.url}}{{=data.requiredQueryString}}',
{
method: '{{=data.methodUpper}}'{{?data.bodyParameter.present || data.allHeaders.length}},{{?}}
{{?data.bodyParameter.present}} body: inputBody{{?}}{{? data.bodyParameter.present && data.allHeaders.length}},{{?}}
{{?data.allHeaders.length}} headers: headers{{?}}
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
| {
"pile_set_name": "Github"
} |
Contribute Code
===================================
This project has adopted the `Microsoft Open Source Code of Conduct <https://opensource.microsoft.com/codeofconduct/>`__.
For more information see the `Code of Conduct FAQ <https://opensource.microsoft.com/codeofconduct/faq/>`__ or contact `[email protected] <mailto:[email protected]>`__ with any additional questions or comments.
If you would like to become an active contributor to this project please
follow the instructions provided in `Microsoft Azure Projects Contribution Guidelines <http://azure.github.io/guidelines.html>`__
| {
"pile_set_name": "Github"
} |
/*
* Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
*
* This file is part of Jam - see jam.c for Copyright information.
*/
/* This file is ALSO:
* Copyright 2001-2004 David Abrahams.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
# include "jam.h"
# include "hash.h"
# include "filesys.h"
# include "pathsys.h"
# include "timestamp.h"
# include "newstr.h"
# include "strings.h"
/*
* timestamp.c - get the timestamp of a file or archive member
*
* 09/22/00 (seiwald) - downshift names on OS2, too
*/
/*
* BINDING - all known files
*/
typedef struct _binding BINDING;
struct _binding {
char *name;
short flags;
# define BIND_SCANNED 0x01 /* if directory or arch, has been scanned */
short progress;
# define BIND_INIT 0 /* never seen */
# define BIND_NOENTRY 1 /* timestamp requested but file never found */
# define BIND_SPOTTED 2 /* file found but not timed yet */
# define BIND_MISSING 3 /* file found but can't get timestamp */
# define BIND_FOUND 4 /* file found and time stamped */
time_t time; /* update time - 0 if not exist */
};
static struct hash * bindhash = 0;
static void time_enter( void *, char *, int, time_t );
static char * time_progress[] =
{
"INIT",
"NOENTRY",
"SPOTTED",
"MISSING",
"FOUND"
};
/*
* timestamp() - return timestamp on a file, if present.
*/
void timestamp( char * target, time_t * time )
{
PROFILE_ENTER( timestamp );
PATHNAME f1;
PATHNAME f2;
BINDING binding;
BINDING * b = &binding;
string buf[ 1 ];
#ifdef DOWNSHIFT_PATHS
string path;
char * p;
#endif
#ifdef DOWNSHIFT_PATHS
string_copy( &path, target );
p = path.value;
do
{
*p = tolower( *p );
#ifdef NT
/* On NT, we must use backslashes or the file will not be found. */
if ( *p == '/' )
*p = PATH_DELIM;
#endif
}
while ( *p++ );
target = path.value;
#endif /* #ifdef DOWNSHIFT_PATHS */
string_new( buf );
if ( !bindhash )
bindhash = hashinit( sizeof( BINDING ), "bindings" );
/* Quick path - is it there? */
b->name = target;
b->time = b->flags = 0;
b->progress = BIND_INIT;
if ( hashenter( bindhash, (HASHDATA * *)&b ) )
b->name = newstr( target ); /* never freed */
if ( b->progress != BIND_INIT )
goto afterscanning;
b->progress = BIND_NOENTRY;
/* Not found - have to scan for it. */
path_parse( target, &f1 );
/* Scan directory if not already done so. */
{
BINDING binding;
BINDING * b = &binding;
f2 = f1;
f2.f_grist.len = 0;
path_parent( &f2 );
path_build( &f2, buf, 0 );
b->name = buf->value;
b->time = b->flags = 0;
b->progress = BIND_INIT;
if ( hashenter( bindhash, (HASHDATA * *)&b ) )
b->name = newstr( buf->value ); /* never freed */
if ( !( b->flags & BIND_SCANNED ) )
{
file_dirscan( buf->value, time_enter, bindhash );
b->flags |= BIND_SCANNED;
}
}
/* Scan archive if not already done so. */
if ( f1.f_member.len )
{
BINDING binding;
BINDING * b = &binding;
f2 = f1;
f2.f_grist.len = 0;
f2.f_member.len = 0;
string_truncate( buf, 0 );
path_build( &f2, buf, 0 );
b->name = buf->value;
b->time = b->flags = 0;
b->progress = BIND_INIT;
if ( hashenter( bindhash, (HASHDATA * *)&b ) )
b->name = newstr( buf->value ); /* never freed */
if ( !( b->flags & BIND_SCANNED ) )
{
file_archscan( buf->value, time_enter, bindhash );
b->flags |= BIND_SCANNED;
}
}
afterscanning:
if ( b->progress == BIND_SPOTTED )
{
b->progress = file_time( b->name, &b->time ) < 0
? BIND_MISSING
: BIND_FOUND;
}
*time = b->progress == BIND_FOUND ? b->time : 0;
string_free( buf );
#ifdef DOWNSHIFT_PATHS
string_free( &path );
#endif
PROFILE_EXIT( timestamp );
}
static void time_enter( void * closure, char * target, int found, time_t time )
{
BINDING binding;
BINDING * b = &binding;
struct hash * bindhash = (struct hash *)closure;
#ifdef DOWNSHIFT_PATHS
char path[ MAXJPATH ];
char * p = path;
do *p++ = tolower( *target );
while ( *target++ );
target = path;
#endif
b->name = target;
b->flags = 0;
if ( hashenter( bindhash, (HASHDATA * *)&b ) )
b->name = newstr( target ); /* never freed */
b->time = time;
b->progress = found ? BIND_FOUND : BIND_SPOTTED;
if ( DEBUG_BINDSCAN )
printf( "time ( %s ) : %s\n", target, time_progress[ b->progress ] );
}
/*
* stamps_done() - free timestamp tables.
*/
void stamps_done()
{
hashdone( bindhash );
}
| {
"pile_set_name": "Github"
} |
/*
* File: CategoryBalancedBaggingLearnerTest.java
* Authors: Justin Basilico
* Company: Sandia National Laboratories
* Project: Cognitive Foundry Learning Core
*
* Copyright June 15, 2011, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government. Export
* of this program may require a license from the United States Government.
*/
package gov.sandia.cognition.learning.algorithm.ensemble;
import gov.sandia.cognition.learning.data.DefaultInputOutputPair;
import gov.sandia.cognition.learning.data.InputOutputPair;
import gov.sandia.cognition.learning.function.categorization.LinearBinaryCategorizer;
import gov.sandia.cognition.math.matrix.VectorFactory;
import gov.sandia.cognition.util.WeightedValue;
import java.util.ArrayList;
import java.util.Random;
import gov.sandia.cognition.learning.algorithm.perceptron.Perceptron;
import gov.sandia.cognition.math.matrix.Vector;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Unit test for class CategoryBalancedBaggingLearner.
*
* @author Justin Basilico
* @since 3.3.0
*/
public class CategoryBalancedBaggingLearnerTest
{
/** Random number generator to use. */
protected Random random = new Random(211);
/**
* Creates a new test.
*/
public CategoryBalancedBaggingLearnerTest()
{
}
/**
* Test of constructors of class CategoryBalancedBaggingLearner.
*/
@Test
public void testConstructors()
{
Perceptron learner = null;
double percentToSample = BaggingCategorizerLearner.DEFAULT_PERCENT_TO_SAMPLE;
int maxIterations = BaggingCategorizerLearner.DEFAULT_MAX_ITERATIONS;
CategoryBalancedBaggingLearner<Vector, Boolean> instance =
new CategoryBalancedBaggingLearner<Vector, Boolean>();
assertSame(learner, instance.getLearner());
assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
assertEquals(maxIterations, instance.getMaxIterations());
assertNotNull(instance.getRandom());
learner = new Perceptron();
instance = new CategoryBalancedBaggingLearner<Vector, Boolean>(learner);
assertSame(learner, instance.getLearner());
assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
assertEquals(maxIterations, instance.getMaxIterations());
assertNotNull(instance.getRandom());
percentToSample = percentToSample / 3.4;
maxIterations = maxIterations * 9;
instance = new CategoryBalancedBaggingLearner<Vector, Boolean>(learner, maxIterations, percentToSample, random);
assertSame(learner, instance.getLearner());
assertEquals(percentToSample, instance.getPercentToSample(), 0.0);
assertEquals(maxIterations, instance.getMaxIterations());
assertSame(random, instance.getRandom());
}
/**
* Test of learn method, of class CategoryBalancedBaggingLearner.
*/
@Test
public void testLearn()
{
CategoryBalancedBaggingLearner<Vector, Boolean> instance =
new CategoryBalancedBaggingLearner<Vector, Boolean>();
instance.setLearner(new Perceptron());
instance.setRandom(random);
instance.setMaxIterations(5);
instance.setPercentToSample(0.5);
assertNull(instance.getResult());
ArrayList<InputOutputPair<Vector, Boolean>> data =
new ArrayList<InputOutputPair<Vector, Boolean>>();
VectorFactory<?> vectorFactory = VectorFactory.getDefault();
for (int i = 0; i < 100; i++)
{
data.add(new DefaultInputOutputPair<Vector, Boolean>(
vectorFactory.createUniformRandom(
14, 0.0, 1.0, random), true));
}
for (int i = 0; i < 2; i++)
{
data.add(new DefaultInputOutputPair<Vector, Boolean>(
vectorFactory.createUniformRandom(
14, -1.0, 0.0, random), false));
}
WeightedVotingCategorizerEnsemble<Vector, Boolean, ?> result =
instance.learn(data);
assertSame(result, instance.getResult());
assertEquals(5, result.getMembers().size());
for (WeightedValue<?> member : result.getMembers())
{
assertEquals(1.0, member.getWeight(), 0.0);
assertNotNull(member.getValue());
assertTrue(member.getValue() instanceof LinearBinaryCategorizer);
}
}
} | {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 80235951880a7094ea0abade92e4f535
timeCreated: 1480605820
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName: 20170219
assetBundleVariant: 0201
| {
"pile_set_name": "Github"
} |
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI=5
# ebuild generated by hackport 0.3.9999
CABAL_FEATURES="bin lib profile haddock hoogle hscolour"
inherit haskell-cabal
DESCRIPTION="Parse numeric literals from ByteStrings"
HOMEPAGE="https://github.com/solidsnack/bytestring-nums"
SRC_URI="https://hackage.haskell.org/package/${P}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~x86"
IUSE=""
RDEPEND=">=dev-lang/ghc-6.10.4:="
DEPEND="${RDEPEND}
>=dev-haskell/cabal-1.6"
src_install() {
cabal_src_install
rm -rf "${D}/usr/bin"
}
| {
"pile_set_name": "Github"
} |
// RUN: %target-swift-frontend -disable-objc-attr-requires-foundation-module -print-ast %s | %FileCheck %s
// REQUIRES: objc_interop
// This bug required an elaborate setup where isObjC() was checked prior
// to validateDecl() getting called on a declaration. In this case, we
// did not infer @objc from witnessed protocol requirements as required.
//
// https://bugs.swift.org/browse/SR-10257
@objc public protocol P {
@objc optional func f()
}
public class Other {
// This triggers a walk over all nominals in the file, collecting
// @objc members into the dynamic dispatch lookup table.
let a = (Base() as AnyObject).g()
}
@objc public class Base : P {
@objc public func g() -> Int { return 0 }
}
public class D : Base {
// This method witnesses P.f() and so it should be @objc.
//
// CHECK-LABEL: @objc public func f()
public func f() {}
}
| {
"pile_set_name": "Github"
} |
% File src/library/tcltk/man/tkProgressBar.Rd
% Part of the R package, https://www.R-project.org
% Copyright 2008 R Core Team
% Distributed under GPL 2 or later
\name{tkProgressBar}
\alias{tkProgressBar}
\alias{getTkProgressBar}
\alias{setTkProgressBar}
\alias{close.tkProgressBar}
\title{Progress Bars via Tk}
\description{
Put up a Tk progress bar widget.
}
\usage{
tkProgressBar(title = "R progress bar", label = "",
min = 0, max = 1, initial = 0, width = 300)
getTkProgressBar(pb)
setTkProgressBar(pb, value, title = NULL, label = NULL)
\method{close}{tkProgressBar}(con, \dots)
}
\arguments{
\item{title, label}{character strings, giving the window title and the
label on the dialog box respectively.}
\item{min, max}{(finite) numeric values for the extremes of the
progress bar.}
\item{initial, value}{initial or new value for the progress bar.}
\item{width}{the width of the progress bar in pixels: the dialog box
will be 40 pixels wider (plus frame).}
\item{pb, con}{an object of class \code{"tkProgressBar"}.}
\item{\dots}{for consistency with the generic.}
}
\details{
\code{tkProgressBar} will display a widget containing a label and
progress bar.
\code{setTkProgessBar} will update the value and for non-\code{NULL}
values, the title and label (provided there was one when the widget
was created). Missing (\code{\link{NA}}) and out-of-range values of
\code{value} will be (silently) ignored.
The progress bar should be \code{close}d when finished with.
This will use the \code{ttk::progressbar} widget for Tk version 8.5 or
later, otherwise \R's copy of BWidget's \code{progressbar}.
}
\value{
For \code{tkProgressBar} an object of class \code{"tkProgressBar"}.
For \code{getTkProgressBar} and \code{setTkProgressBar}, a
length-one numeric vector giving the previous value (invisibly for
\code{setTkProgressBar}).
}
\seealso{
\code{\link{txtProgressBar}}
#ifdef windows
\code{\link{winProgressBar}} for a version using Windows native
controls (which this also does for Tk >= 8.5).
#endif
}
\examples{\donttest{% popups are irritating
pb <- tkProgressBar("test progress bar", "Some information in \%",
0, 100, 50)
Sys.sleep(0.5)
u <- c(0, sort(runif(20, 0, 100)), 100)
for(i in u) {
Sys.sleep(0.1)
info <- sprintf("\%d\%\% done", round(i))
setTkProgressBar(pb, i, sprintf("test (\%s)", info), info)
}
Sys.sleep(5)
close(pb)
}}
\keyword{utilities}
| {
"pile_set_name": "Github"
} |
//
// AbuCandChartView.m
// AbuKlineView
//
// Created by ้ฟๅธ on 17/9/7.
// Copyright ยฉ 2017ๅนด ้ฟๅธ. All rights reserved.
//
#import "AbuCandChartView.h"
#import "KlineQuotaColumnLayer.h"
#import "KlineCandelLayer.h"
#import "KlineTimeLayer.h"
#import "KlineMALayer.h"
#define MINDISPLAYCOUNT 6
@interface AbuCandChartView()<UIScrollViewDelegate,AbuChartViewProtocol>
@property (nonatomic,strong) UIScrollView * scrollView;
@property (nonatomic, strong) FBKVOController * KVOController;
@property (nonatomic,assign) CGFloat leftPostion;
@property (nonatomic,strong) NSMutableArray * currentDisplayArray;
@property (nonatomic,assign) CGFloat previousOffsetX;
@property (nonatomic,assign) CGFloat maxAssert;
@property (nonatomic,assign) CGFloat minAssert;
@property (nonatomic,assign) CGFloat heightPerpoint;
@property (nonatomic, assign) BOOL isRefresh;
@property (nonatomic, strong) KlineTimeLayer * timeLayer;
@property (nonatomic, strong) KlineCandelLayer * candelLayer;
@property (nonatomic, strong) KlineMALayer * ma5LineLayer;
@property (nonatomic, strong) KlineMALayer * ma10LineLayer;
@property (nonatomic, strong) KlineMALayer * ma20LineLayer;
@property (nonatomic,assign) double quotaMinAssert;
@property (nonatomic,assign) double quotaMaxAssert;
@property (nonatomic,assign) CGFloat quotaHeightPerPoint;
@property (nonatomic, strong) KlineQuotaColumnLayer * macdLayer;
@property (nonatomic, strong) KlineMALayer * deaLayer;
@property (nonatomic, strong) KlineMALayer * diffLayer;
@property (nonatomic,strong) KlineMALayer * kLineLayer;
@property (nonatomic,strong) KlineMALayer * dLineLayer;
@property (nonatomic,strong) KlineMALayer * wrLineLayer;
@property (nonatomic,assign) float chartSize;
@property (nonatomic,assign) BOOL isShowSubView;
@property (nonatomic, assign) CGFloat contentHeight;
@end
@implementation AbuCandChartView
- (instancetype)init
{
self = [super init];
if (self) {
[self initConfig];
[self calcuteCandleWidth];
}
return self;
}
-(void)initConfig
{
self.kvoEnable = YES;
self.isRefresh = YES;
self.chartSize = orignChartScale;
self.isShowSubView = YES;
}
- (void)reloadKline
{
[self updateWidth];
[self drawKLine];
}
#pragma mark KVO
-(void)didMoveToSuperview
{
[super didMoveToSuperview];
_scrollView = (UIScrollView*)self.superview;
_scrollView.delegate = self;
[self addListener];
}
- (void)addListener
{
FBKVOController *KVOController = [FBKVOController controllerWithObserver:self];
self.KVOController = KVOController;
WS(weakSelf);
[self.KVOController observe:_scrollView keyPath:ContentOffSet options:NSKeyValueObservingOptionNew block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSString *,id> * _Nonnull change) {
if (self.kvoEnable)
{
weakSelf.contentOffset = weakSelf.scrollView.contentOffset.x;
weakSelf.previousOffsetX = weakSelf.scrollView.contentSize.width -weakSelf.scrollView.contentOffset.x;
[weakSelf drawKLine];
}
}];
}
- (void)setKvoEnable:(BOOL)kvoEnable
{
_kvoEnable = kvoEnable;
}
- (NSInteger)currentStartIndex
{
CGFloat scrollViewOffsetX = self.leftPostion < 0 ? 0 : self.leftPostion;
NSInteger leftArrCount = (scrollViewOffsetX) / (self.candleWidth+self.candleSpace);
if (leftArrCount > self.dataArray.count)
{
_currentStartIndex = self.dataArray.count - 1;
}
else if (leftArrCount == 0)
{
_currentStartIndex = 0;
}
else
{
_currentStartIndex = leftArrCount ;
}
return _currentStartIndex;
}
- (CGFloat)leftPostion
{
CGFloat scrollViewOffsetX = _contentOffset < 0 ? 0 : _contentOffset;
if (scrollViewOffsetX == 0) {
scrollViewOffsetX = 10;
}
if (_contentOffset + self.scrollView.width >= self.scrollView.contentSize.width)
{
scrollViewOffsetX = self.scrollView.contentSize.width - self.scrollView.width;
}
return scrollViewOffsetX;
}
- (void)initCurrentDisplayModels
{
NSInteger needDrawKLineCount = self.scrollView.width / self.candleWidth;
NSInteger currentStartIndex = self.currentStartIndex;
NSInteger count = (currentStartIndex + needDrawKLineCount) >self.dataArray.count ? self.dataArray.count :currentStartIndex+needDrawKLineCount;
[self.currentDisplayArray removeAllObjects];
if (currentStartIndex < count)
{
for (NSInteger i = currentStartIndex; i < count ; i++)
{
KLineModel *model = self.dataArray[i];
[self.currentDisplayArray addObject:model];
}
}
}
- (void)calcuteMaxAndMinValue
{
self.maxAssert = CGFLOAT_MIN;
self.minAssert = CGFLOAT_MAX;
NSInteger idx = 0;
for (NSInteger i = idx; i < self.currentDisplayArray.count; i++)
{
KLineModel * entity = [self.currentDisplayArray objectAtIndex:i];
self.minAssert = self.minAssert < entity.lowPrice ? self.minAssert : entity.lowPrice;
self.maxAssert = self.maxAssert > entity.highPrice ? self.maxAssert : entity.highPrice;
if (self.maxAssert - self.minAssert < 0.5)
{
self.maxAssert += 0.5;
self.minAssert -= 0.5;
}
}
CGFloat contentHeigh = self.scrollView.height / self.chartSize - topDistance - timeheight- topDistance;
self.contentHeight = contentHeigh;
self.heightPerpoint = contentHeigh / (self.maxAssert-self.minAssert);
}
- (void)drawMALineLayer
{
if (IsArrayNull(self.currentDisplayArray)) {
return;
}
if (self.ma5LineLayer)
{
[self.ma5LineLayer removeFromSuperlayer];
}
self.ma5LineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.maxAssert heightPerpoint:self.heightPerpoint totalHeight:0 lineWidth:1 lineColor:[UIColor greenColor] wireType:MA5TYPE klineSubOrMain:Main];
[self.layer addSublayer:self.ma5LineLayer];
if (self.ma10LineLayer)
{
[self.ma10LineLayer removeFromSuperlayer];
}
self.ma10LineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.maxAssert heightPerpoint:self.heightPerpoint totalHeight:0 lineWidth:1 lineColor:[UIColor redColor] wireType:MA10TYPE klineSubOrMain:Main];
[self.layer addSublayer:self.ma10LineLayer];
if (self.ma20LineLayer)
{
[self.ma20LineLayer removeFromSuperlayer];
}
self.ma20LineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.maxAssert heightPerpoint:self.heightPerpoint totalHeight:0 lineWidth:1 lineColor:[UIColor blueColor] wireType:MA20TYPE klineSubOrMain:Main];
[self.layer addSublayer:self.ma20LineLayer];
}
#pragma mark publicMethod
- (CAShapeLayer*)getAxispLayer
{
CAShapeLayer *layer = [CAShapeLayer layer];
layer.strokeColor = [UIColor colorWithHexString:@"#ededed"].CGColor;
layer.fillColor = [[UIColor clearColor] CGColor];
layer.contentsScale = [UIScreen mainScreen].scale;
return layer;
}
- (void)calcuteCandleWidth
{
self.candleWidth = minCandelWith;
}
- (void)drawKLine
{
[self drawMainKline];
if (self.delegate && [self.delegate respondsToSelector:@selector(reloadPriceViewWithPriceArr:)]) {
NSArray * priceArray = [self calculatePrcieArrWhenScroll];
[self.delegate reloadPriceViewWithPriceArr:priceArray];
}
[self drawPresetQuota:KlineSubKPITypeMACD];
if (self.delegate && [self.delegate respondsToSelector:@selector(refreshCurrentPrice:candleModel:)]) {
KLineModel * model = self.currentDisplayArray.lastObject;
KLineModel *candelModel = self.currentDisplayArray.lastObject;
[self.delegate refreshCurrentPrice:model candleModel:candelModel];
}
}
- (void)drawMainKline
{
[self drawCandelLayer];
[self drawMALineLayer];
[self drawTimeLayer];
}
- (void)drawCandelLayer
{
[self initCurrentDisplayModels];
[self calcuteMaxAndMinValue];
if (self.delegate && [self.delegate respondsToSelector: @selector(displayScreenleftPostion:startIndex:count:)])
{
[_delegate displayScreenleftPostion:self.leftPostion startIndex:self.currentStartIndex count:self.currentDisplayArray.count];
}
if (self.delegate && [self.delegate respondsToSelector:@selector(displayLastModel:)])
{
KLineModel *lastModel = self.currentDisplayArray.lastObject;
[_delegate displayLastModel:lastModel];
}
if (self.candelLayer)
{
[self.candelLayer removeFromSuperlayer];
}
self.candelLayer = [[KlineCandelLayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.maxAssert heightPerpoint:self.heightPerpoint scrollViewContentWidth:self.scrollView.contentSize.width];
[self.layer addSublayer:self.candelLayer];
}
- (void)drawTimeLayer
{
if (self.timeLayer)
{
[self.timeLayer removeFromSuperlayer];
self.timeLayer = nil;
}
self.timeLayer = [[KlineTimeLayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth height:self.scrollView.height / self.chartSize timeHight:timeheight bottomMargin:0 lineWidth:0];
[self.layer addSublayer:self.timeLayer];
}
- (NSArray *)calculatePrcieArrWhenScroll
{
NSMutableArray *priceArr = [NSMutableArray array];
for (int i = 5; i>=0; i--) {
if (i==5) {
[priceArr addObject:@(self.maxAssert)];
continue;
}
if (i==0) {
[priceArr addObject:@(self.minAssert)];
continue;
}
[priceArr addObject:@((self.minAssert + ((self.contentHeight/5)*i/self.heightPerpoint)))];
}
return [priceArr copy];
}
- (void)updateWidth
{
CGFloat klineWidth = self.dataArray.count * (self.candleWidth + self.candleSpace) + 5;
if(klineWidth < self.scrollView.width)
{
klineWidth = self.scrollView.width;
}
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(@(klineWidth));
}];
self.scrollView.contentSize = CGSizeMake(klineWidth,0);
if (self.isRefresh) {
self.scrollView.contentOffset = CGPointMake(klineWidth - self.scrollView.width, 0);
}
}
-(CGPoint)getLongPressModelPostionWithXPostion:(CGFloat)xPostion
{
CGFloat localPostion = xPostion;
NSInteger startIndex = (NSInteger)((localPostion - self.leftPostion) / (self.candleSpace + self.candleWidth));
NSInteger arrCount = self.currentDisplayArray.count;
for (NSInteger index = startIndex > 0 ? startIndex - 1 : 0; index < arrCount; ++index) {
KLineModel *kLinePositionModel = self.currentDisplayArray[index];
CGFloat minX = kLinePositionModel.highestPoint.x - (self.candleSpace + self.candleWidth/2);
CGFloat maxX = kLinePositionModel.highestPoint.x + (self.candleSpace + self.candleWidth/2);
if(localPostion > minX && localPostion < maxX)
{
if(self.delegate && [self.delegate respondsToSelector:@selector(longPressCandleViewWithIndex:kLineModel:)])
{
[self.delegate longPressCandleViewWithIndex:index kLineModel:self.currentDisplayArray[index]];
}
return CGPointMake(kLinePositionModel.highestPoint.x, kLinePositionModel.opensPoint.y);
}
}
KLineModel *lastPositionModel = self.currentDisplayArray.lastObject;
if (localPostion >= lastPositionModel.closesPoint.x)
{
return CGPointMake(lastPositionModel.highestPoint.x, lastPositionModel.opensPoint.y);
}
KLineModel *firstPositionModel = self.currentDisplayArray.firstObject;
if (firstPositionModel.closesPoint.x >= localPostion)
{
return CGPointMake(firstPositionModel.highestPoint.x, firstPositionModel.opensPoint.y);
}
return CGPointZero;
}
- (void)drawPresetQuota:(KlineSubKPIType)presetQuotaName;
{
if (self.isShowSubView) {
[self calcuteQuotaMaxAssertAndMinAssert:presetQuotaName];
switch (presetQuotaName) {
case KlineSubKPITypeMACD:
[self drawPresetMACD];
break;
case KlineSubKPITypeKD:
[self drawPresetKD];
break;
case KlineSubKPITypeW_R:
[self drawPresetWR];
break;
default:
break;
}
}
else
{
[self removeSubSubLayers];
}
}
- (void)drawPresetMACD
{
if (self.macdLayer) {
[self.macdLayer removeFromSuperlayer];
}
self.macdLayer = [[KlineQuotaColumnLayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint qutoaHeight:self.scrollView.height * orignIndicatorOrignY];
[self.layer addSublayer:self.macdLayer];
if (self.diffLayer) {
[self.diffLayer removeFromSuperlayer];
}
self.diffLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint totalHeight:self.scrollView.height *orignIndicatorOrignY lineWidth:1 lineColor:[UIColor yellowColor] wireType:MACDDIFF klineSubOrMain:Sub];
[self.layer addSublayer:self.diffLayer];
if (self.deaLayer) {
[self.deaLayer removeFromSuperlayer];
}
self.deaLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint totalHeight:self.scrollView.height *orignIndicatorOrignY lineWidth:1 lineColor:[UIColor purpleColor] wireType:MACDDEA klineSubOrMain:Sub];
[self.layer addSublayer:self.deaLayer];
}
- (void)drawPresetKD
{
if (self.kLineLayer) {
[self.kLineLayer removeFromSuperlayer];
}
self.kLineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint totalHeight:self.scrollView.height *orignIndicatorOrignY lineWidth:1 lineColor:[UIColor yellowColor] wireType:KDJ_K klineSubOrMain:Sub];
[self.layer addSublayer:self.kLineLayer];
if (self.dLineLayer) {
[self.dLineLayer removeFromSuperlayer];
}
self.dLineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint totalHeight:self.scrollView.height *orignIndicatorOrignY lineWidth:1 lineColor:[UIColor orangeColor] wireType:KDJ_D klineSubOrMain:Sub];
[self.layer addSublayer:self.dLineLayer];
}
- (void)drawPresetWR
{
if (self.wrLineLayer) {
[self.wrLineLayer removeFromSuperlayer];
}
self.wrLineLayer = [[KlineMALayer alloc] initQuotaDataArr:self.currentDisplayArray candleWidth:self.candleWidth candleSpace:self.candleSpace startIndex:self.leftPostion maxValue:self.quotaMaxAssert heightPerpoint:self.quotaHeightPerPoint totalHeight:self.scrollView.height *orignIndicatorOrignY lineWidth:1 lineColor:[UIColor orangeColor] wireType:KLINE_WR klineSubOrMain:Sub];
[self.layer addSublayer:self.wrLineLayer];
}
- (void)calcuteQuotaMaxAssertAndMinAssert:(KlineSubKPIType)subType
{
NSDictionary *resultDic;
CGFloat contentHeigh = self.scrollView.height * orignIndicatorOrignY - midDistance;
if (subType == KlineSubKPITypeMACD) {
NSMutableArray * DEAArray = [NSMutableArray array];
NSMutableArray * DIFArray = [NSMutableArray array];
NSMutableArray * MACDArray = [NSMutableArray array];
for (NSInteger i = 0;i<self.currentDisplayArray.count;i++)
{
KLineModel *macdData = [self.currentDisplayArray objectAtIndex:i];
[DIFArray addObject:[NSNumber numberWithFloat:[macdData.DEA floatValue]]];
[DIFArray addObject:[NSNumber numberWithFloat:[macdData.DIF floatValue]]];
[MACDArray addObject:[NSNumber numberWithFloat:[macdData.MACD floatValue]]];
}
resultDic = [[KLineCalculate sharedInstance] calculateMaxAndMinValueWithDataArr:@[DEAArray,MACDArray,DIFArray]];
self.quotaMaxAssert = [resultDic[kMaxValue] floatValue];
self.quotaMinAssert = [resultDic[kMinValue] floatValue];
contentHeigh = self.scrollView.height * orignIndicatorScale - midDistance;
self.quotaHeightPerPoint = (self.quotaMaxAssert - self.quotaMinAssert) / contentHeigh;
}
if (subType == KlineSubKPITypeKD) {
NSMutableArray * KArray = [NSMutableArray array];
NSMutableArray * DArray = [NSMutableArray array];
for (NSInteger i = 0;i<self.currentDisplayArray.count;i++)
{
KLineModel *macdData = [self.currentDisplayArray objectAtIndex:i];
[KArray addObject:@(macdData.K)];
[DArray addObject:@(macdData.D)];
}
resultDic = [[KLineCalculate sharedInstance] calculateMaxAndMinValueWithDataArr:@[KArray,DArray]];
self.quotaMaxAssert = [resultDic[kMaxValue] floatValue];
self.quotaMinAssert = [resultDic[kMinValue] floatValue];
self.quotaHeightPerPoint = contentHeigh/(self.quotaMaxAssert-self.quotaMinAssert);
}
if (subType == KlineSubKPITypeW_R) {
NSMutableArray * WRArray = [NSMutableArray array];
for (NSInteger i = 0;i<self.currentDisplayArray.count;i++)
{
KLineModel *model = [self.currentDisplayArray objectAtIndex:i];
[WRArray addObject:@(model.WR)];
}
resultDic = [[KLineCalculate sharedInstance] calculateMaxAndMinValueWithDataArr:@[WRArray]];
self.quotaMaxAssert = [resultDic[kMaxValue] floatValue];
self.quotaMinAssert = [resultDic[kMinValue] floatValue];
self.quotaHeightPerPoint = contentHeigh/(self.quotaMaxAssert-self.quotaMinAssert);
}
if (self.delegate && [self.delegate respondsToSelector:@selector(reloadPriceViewWithQuotaMaxValue:MinValue:)]) {
[self.delegate reloadPriceViewWithQuotaMaxValue:self.quotaMaxAssert MinValue:self.quotaMinAssert];
}
}
- (void)removeSubSubLayers
{
if (self.macdLayer) {
[self.macdLayer removeFromSuperlayer];
self.macdLayer = nil;
}
if (self.deaLayer) {
[self.deaLayer removeFromSuperlayer];
self.deaLayer = nil;
}
if (self.diffLayer) {
[self.diffLayer removeFromSuperlayer];
self.diffLayer = nil;
}
if (self.kLineLayer) {
[self.kLineLayer removeFromSuperlayer];
self.kLineLayer = nil;
}
if (self.dLineLayer) {
[self.dLineLayer removeFromSuperlayer];
self.dLineLayer = nil;
}
if (self.wrLineLayer) {
[self.wrLineLayer removeFromSuperlayer];
self.wrLineLayer = nil;
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.x<0)
{
if (self.delegate && [self.delegate respondsToSelector:@selector(displayMoreData)])
{
self.previousOffsetX = _scrollView.contentSize.width -_scrollView.contentOffset.x;
[_delegate displayMoreData];
}
}
}
- (NSMutableArray *)currentDisplayArray
{
if (!_currentDisplayArray) {
_currentDisplayArray = [NSMutableArray array];
}
return _currentDisplayArray;
}
@end
| {
"pile_set_name": "Github"
} |
global
* false
* true
local
* false
* true
upvar
* false
* true
| {
"pile_set_name": "Github"
} |
The planes carried around 38,000 liters of kerosene (10,000 gallons), which had an energetic value of 1.6ร1012 J (1,6 TJ). During the impact the liquid explosion spread over 6 floors which equals average 67.2 MJ/m2.
The towers were designed to handle a theoretical fire load of 220 MJ/m2/hour. The towers were constructed to handle this amount of energy, spread during 4 hours (cumulative 880 MJ/m2). When a fire becomes hot enough almost anything starts to burn, from paint to even aluminium. An average office contains 600 MJ/m2 combustible materials.
The kerosene must have burned in less than 2 minutes (estimation), meaning that the permissible fire load of the towers could have been exceeded during the time the kerosene caught fire over 6 floors. With a short fire load of maximum 2,000 MJ/m2, the overload would be approximately 920%, assuming that all the kerosene burned inside the towers. But since a part of the kerosene exploded outside the towers means that it was less. How much less?
The volume of the fire ball around tower 1 during the hit was approximately 2,3x106 m3. The fire ball could freely expand since the windows were already blown out. The total volume of the affected 6 floors was 9x104 m3. This means that around 5% of the kerosene burned inside the tower. Kerosene is so inflammable that it doesn't burn up slowly. The perimeter of the explosion shows that there was no 'place' inside the building to burn this amount of kerosene.
Because only 5% of the kerosene burned inside the towers, means that the fire load was not more than 240 MJ/m2 during less than 2 minutes. The towers were able to handle this amount of energy easily. They were designed on this fire load, not just for 2 minutes but during 4 hours.
The heat of the fire after the impact was no problem. A kerosene fire of a few minutes doesn't develop more heat than 600 ยฐC - 700 ยฐC (1110 ยฐF - 1290 ยฐF). The steel construction was coated with a heat resistant material, designed and applied to handle this heat for at least 4 hours. Whether the main structure at the height of impact was unaffected by this first heat burst is unsure, since the thermal isolation might have been damaged by the impact.
The kerosene was a spark that ignited a larger fire. Additionally, the blast of the liquid explosion blew away part of the combustible materials. That means it didn't took part in the fire.
The total energetic value of the kerosene was a fraction of the energy necessary to bring the main structure in the danger zone. The kerosene plays hardly a role in the energetic balance, besides being the igniter of a much more dangerous fire - a burning office of 600 to 700 ยฐC.
The towers were designed to handle this heat and fire load. Although parts of the protective coating might have been damaged due to the impact, which made the main structure vulnerable for the heat that followed. | {
"pile_set_name": "Github"
} |
US_Nevada
1
-1.200050E+02 3.933952E+01
-1.200049E+02 3.934501E+01
-1.200044E+02 3.937491E+01
-1.200043E+02 3.937838E+01
-1.200043E+02 3.937991E+01
-1.200042E+02 3.938655E+01
-1.200039E+02 3.940351E+01
-1.200032E+02 3.944098E+01
-1.200032E+02 3.944514E+01
-1.200032E+02 3.944567E+01
-1.200031E+02 3.944762E+01
-1.200028E+02 3.946197E+01
-1.200028E+02 3.946290E+01
-1.200027E+02 3.946668E+01
-1.200027E+02 3.946780E+01
-1.200027E+02 3.946833E+01
-1.200027E+02 3.946894E+01
-1.200026E+02 3.947650E+01
-1.200025E+02 3.948667E+01
-1.200023E+02 3.949991E+01
-1.200022E+02 3.949991E+01
-1.200020E+02 3.951498E+01
-1.200017E+02 3.953439E+01
-1.200016E+02 3.954871E+01
-1.200016E+02 3.955429E+01
-1.200015E+02 3.957004E+01
-1.200014E+02 3.959034E+01
-1.200013E+02 3.962189E+01
-1.200013E+02 3.963579E+01
-1.200012E+02 3.966007E+01
-1.200012E+02 3.967452E+01
-1.200012E+02 3.967917E+01
-1.200013E+02 3.969193E+01
-1.200013E+02 3.969481E+01
-1.200014E+02 3.970804E+01
-1.200012E+02 3.972091E+01
-1.200012E+02 3.972245E+01
-1.200012E+02 3.972509E+01
-1.200011E+02 3.973398E+01
-1.200011E+02 3.973587E+01
-1.200011E+02 3.974319E+01
-1.200011E+02 3.974991E+01
-1.200007E+02 3.976639E+01
-1.200005E+02 3.979685E+01
-1.200005E+02 3.979686E+01
-1.200005E+02 3.979712E+01
-1.200000E+02 3.982775E+01
-1.199991E+02 3.987493E+01
-1.199991E+02 3.987491E+01
-1.199985E+02 3.994377E+01
-1.199979E+02 3.999988E+01
-1.199978E+02 3.999990E+01
-1.199976E+02 4.000553E+01
-1.199975E+02 4.001076E+01
-1.199974E+02 4.003424E+01
-1.199974E+02 4.003928E+01
-1.199973E+02 4.007107E+01
-1.199973E+02 4.008856E+01
-1.199973E+02 4.009901E+01
-1.199973E+02 4.011255E+01
-1.199992E+02 4.011453E+01
-1.199992E+02 4.011672E+01
-1.199992E+02 4.011673E+01
-1.199991E+02 4.011980E+01
-1.199991E+02 4.012004E+01
-1.199991E+02 4.012488E+01
-1.199992E+02 4.012603E+01
-1.199974E+02 4.012807E+01
-1.199971E+02 4.012810E+01
-1.199969E+02 4.015717E+01
-1.199969E+02 4.017002E+01
-1.199969E+02 4.018626E+01
-1.199968E+02 4.019647E+01
-1.199966E+02 4.021521E+01
-1.199965E+02 4.022317E+01
-1.199965E+02 4.022972E+01
-1.199964E+02 4.024201E+01
-1.199964E+02 4.024990E+01
-1.199964E+02 4.024990E+01
-1.199962E+02 4.024990E+01
-1.199962E+02 4.025622E+01
-1.199962E+02 4.027338E+01
-1.199963E+02 4.027993E+01
-1.199963E+02 4.029346E+01
-1.199966E+02 4.032371E+01
-1.199959E+02 4.037461E+01
-1.199959E+02 4.037492E+01
-1.199959E+02 4.037494E+01
-1.199956E+02 4.038163E+01
-1.199956E+02 4.041051E+01
-1.199956E+02 4.042680E+01
-1.199956E+02 4.042927E+01
-1.199957E+02 4.045415E+01
-1.199957E+02 4.046317E+01
-1.199957E+02 4.046862E+01
-1.199958E+02 4.048318E+01
-1.199959E+02 4.049524E+01
-1.199959E+02 4.049990E+01
-1.199958E+02 4.049990E+01
-1.199959E+02 4.051065E+01
-1.199958E+02 4.052324E+01
-1.199959E+02 4.055609E+01
-1.199959E+02 4.057051E+01
-1.199962E+02 4.058512E+01
-1.199966E+02 4.059949E+01
-1.199967E+02 4.061231E+01
-1.199967E+02 4.061377E+01
-1.199967E+02 4.061438E+01
-1.199968E+02 4.062490E+01
-1.199969E+02 4.062490E+01
-1.199971E+02 4.064234E+01
-1.199972E+02 4.064906E+01
-1.199973E+02 4.065675E+01
-1.199974E+02 4.066931E+01
-1.199976E+02 4.068346E+01
-1.199977E+02 4.069234E+01
-1.199978E+02 4.069802E+01
-1.199980E+02 4.071645E+01
-1.199982E+02 4.072951E+01
-1.199983E+02 4.073780E+01
-1.199985E+02 4.074990E+01
-1.199986E+02 4.075917E+01
-1.199986E+02 4.076536E+01
-1.199987E+02 4.077378E+01
-1.199987E+02 4.079042E+01
-1.199987E+02 4.080304E+01
-1.199989E+02 4.083031E+01
-1.199989E+02 4.083838E+01
-1.199992E+02 4.087490E+01
-1.199993E+02 4.087490E+01
-1.199993E+02 4.087490E+01
-1.199994E+02 4.089046E+01
-1.199994E+02 4.091075E+01
-1.199996E+02 4.094950E+01
-1.199997E+02 4.097701E+01
-1.199997E+02 4.099073E+01
-1.199998E+02 4.099990E+01
-1.199999E+02 4.099990E+01
-1.199998E+02 4.101988E+01
-1.199998E+02 4.103567E+01
-1.199998E+02 4.104110E+01
-1.199999E+02 4.105672E+01
-1.200000E+02 4.108609E+01
-1.200000E+02 4.112489E+01
-1.200001E+02 4.112988E+01
-1.200003E+02 4.113998E+01
-1.200002E+02 4.114426E+01
-1.199998E+02 4.115464E+01
-1.199998E+02 4.116260E+01
-1.199998E+02 4.116915E+01
-1.199998E+02 4.118363E+01
-1.199998E+02 4.118425E+01
-1.199999E+02 4.118638E+01
-1.199999E+02 4.118734E+01
-1.200000E+02 4.119117E+01
-1.200003E+02 4.119934E+01
-1.200002E+02 4.121636E+01
-1.199999E+02 4.128311E+01
-1.199998E+02 4.128522E+01
-1.199996E+02 4.133542E+01
-1.199996E+02 4.135568E+01
-1.199996E+02 4.136029E+01
-1.199996E+02 4.136524E+01
-1.199996E+02 4.140791E+01
-1.199996E+02 4.141476E+01
-1.199995E+02 4.142328E+01
-1.199995E+02 4.145223E+01
-1.199993E+02 4.149989E+01
-1.199995E+02 4.149989E+01
-1.199993E+02 4.151013E+01
-1.199993E+02 4.152454E+01
-1.199991E+02 4.154725E+01
-1.199992E+02 4.158259E+01
-1.199991E+02 4.159112E+01
-1.199990E+02 4.161144E+01
-1.199990E+02 4.162489E+01
-1.199990E+02 4.162798E+01
-1.199989E+02 4.164043E+01
-1.199989E+02 4.165240E+01
-1.199988E+02 4.165491E+01
-1.199988E+02 4.166953E+01
-1.199988E+02 4.168098E+01
-1.199987E+02 4.171163E+01
-1.199987E+02 4.171176E+01
-1.199987E+02 4.171327E+01
-1.199986E+02 4.172605E+01
-1.199987E+02 4.174680E+01
-1.199986E+02 4.174808E+01
-1.199986E+02 4.174989E+01
-1.199987E+02 4.174989E+01
-1.199986E+02 4.176982E+01
-1.199987E+02 4.178451E+01
-1.199988E+02 4.179422E+01
-1.199988E+02 4.179914E+01
-1.199989E+02 4.180086E+01
-1.199991E+02 4.181408E+01
-1.199992E+02 4.183682E+01
-1.199992E+02 4.184877E+01
-1.199993E+02 4.186339E+01
-1.199993E+02 4.187489E+01
-1.199994E+02 4.187489E+01
-1.199994E+02 4.187489E+01
-1.199995E+02 4.188748E+01
-1.199996E+02 4.189325E+01
-1.199995E+02 4.193684E+01
-1.199995E+02 4.194092E+01
-1.199996E+02 4.195134E+01
-1.199996E+02 4.196592E+01
-1.199994E+02 4.197397E+01
-1.199994E+02 4.197940E+01
-1.199994E+02 4.199489E+01
-1.199993E+02 4.199490E+01
-1.199867E+02 4.199584E+01
-1.199124E+02 4.199675E+01
-1.198761E+02 4.199720E+01
-1.198747E+02 4.199738E+01
-1.198729E+02 4.199764E+01
-1.198502E+02 4.199730E+01
-1.198489E+02 4.199728E+01
-1.198453E+02 4.199730E+01
-1.197901E+02 4.199754E+01
-1.197371E+02 4.199652E+01
-1.197257E+02 4.199630E+01
-1.196733E+02 4.199614E+01
-1.194446E+02 4.199548E+01
-1.193602E+02 4.199425E+01
-1.193244E+02 4.199360E+01
-1.192528E+02 4.199384E+01
-1.192510E+02 4.199384E+01
-1.192319E+02 4.199421E+01
-1.192292E+02 4.199409E+01
-1.192083E+02 4.199318E+01
-1.190010E+02 4.199379E+01
-1.187956E+02 4.199239E+01
-1.187923E+02 4.199244E+01
-1.187772E+02 4.199267E+01
-1.187769E+02 4.199268E+01
-1.187759E+02 4.199269E+01
-1.186964E+02 4.199179E+01
-1.186269E+02 4.199334E+01
-1.186018E+02 4.199390E+01
-1.185481E+02 4.199472E+01
-1.185010E+02 4.199545E+01
-1.184819E+02 4.199554E+01
-1.184698E+02 4.199561E+01
-1.184165E+02 4.199588E+01
-1.183973E+02 4.199597E+01
-1.183475E+02 4.199623E+01
-1.183003E+02 4.199632E+01
-1.182221E+02 4.199646E+01
-1.181972E+02 4.199651E+01
-1.181631E+02 4.199688E+01
-1.181240E+02 4.199730E+01
-1.181238E+02 4.199730E+01
-1.178914E+02 4.199826E+01
-1.178868E+02 4.199828E+01
-1.178735E+02 4.199833E+01
-1.178653E+02 4.199833E+01
-1.178633E+02 4.199833E+01
-1.178451E+02 4.199834E+01
-1.177229E+02 4.199841E+01
-1.176952E+02 4.199832E+01
-1.176315E+02 4.199811E+01
-1.176278E+02 4.199810E+01
-1.176260E+02 4.199810E+01
-1.176248E+02 4.199829E+01
-1.176238E+02 4.199845E+01
-1.176237E+02 4.199847E+01
-1.176172E+02 4.199851E+01
-1.175783E+02 4.199877E+01
-1.175302E+02 4.199908E+01
-1.174981E+02 4.199930E+01
-1.174431E+02 4.199966E+01
-1.174036E+02 4.199929E+01
-1.173966E+02 4.199931E+01
-1.172176E+02 4.199989E+01
-1.172081E+02 4.200012E+01
-1.172068E+02 4.200016E+01
-1.171978E+02 4.200038E+01
-1.171736E+02 4.200032E+01
-1.171669E+02 4.200030E+01
-1.170924E+02 4.200010E+01
-1.170807E+02 4.200007E+01
-1.170797E+02 4.200006E+01
-1.170686E+02 4.200003E+01
-1.170644E+02 4.199999E+01
-1.170554E+02 4.199989E+01
-1.170291E+02 4.200681E+01
-1.170175E+02 4.199972E+01
-1.170093E+02 4.199813E+01
-1.169692E+02 4.199899E+01
-1.166268E+02 4.199775E+01
-1.166259E+02 4.199738E+01
-1.165869E+02 4.199737E+01
-1.165822E+02 4.199783E+01
-1.165253E+02 4.199756E+01
-1.165105E+02 4.199710E+01
-1.165017E+02 4.199733E+01
-1.164998E+02 4.199674E+01
-1.164858E+02 4.199686E+01
-1.164831E+02 4.199688E+01
-1.164635E+02 4.199655E+01
-1.163782E+02 4.199631E+01
-1.163685E+02 4.199628E+01
-1.163328E+02 4.199728E+01
-1.161639E+02 4.199755E+01
-1.161608E+02 4.199752E+01
-1.160386E+02 4.199746E+01
-1.160386E+02 4.199741E+01
-1.160308E+02 4.199740E+01
-1.160308E+02 4.199738E+01
-1.160190E+02 4.199776E+01
-1.160189E+02 4.199772E+01
-1.160122E+02 4.199805E+01
-1.160122E+02 4.199804E+01
-1.159869E+02 4.199853E+01
-1.158876E+02 4.199805E+01
-1.158796E+02 4.199789E+01
-1.158702E+02 4.199677E+01
-1.157319E+02 4.199713E+01
-1.156259E+02 4.199741E+01
-1.156181E+02 4.199731E+01
-1.155868E+02 4.199688E+01
-1.155257E+02 4.199671E+01
-1.155246E+02 4.199482E+01
-1.155243E+02 4.199475E+01
-1.155243E+02 4.199473E+01
-1.155240E+02 4.199465E+01
-1.155239E+02 4.199461E+01
-1.155239E+02 4.199459E+01
-1.155233E+02 4.199440E+01
-1.155232E+02 4.199439E+01
-1.155228E+02 4.199436E+01
-1.155227E+02 4.199436E+01
-1.155220E+02 4.199453E+01
-1.155219E+02 4.199456E+01
-1.155216E+02 4.199471E+01
-1.155216E+02 4.199475E+01
-1.155215E+02 4.199482E+01
-1.155214E+02 4.199485E+01
-1.155212E+02 4.199491E+01
-1.155211E+02 4.199499E+01
-1.155210E+02 4.199503E+01
-1.155205E+02 4.199538E+01
-1.155205E+02 4.199541E+01
-1.155205E+02 4.199546E+01
-1.155203E+02 4.199561E+01
-1.155203E+02 4.199558E+01
-1.155202E+02 4.199565E+01
-1.155200E+02 4.199594E+01
-1.155200E+02 4.199597E+01
-1.155199E+02 4.199602E+01
-1.155196E+02 4.199660E+01
-1.155196E+02 4.199669E+01
-1.153635E+02 4.199624E+01
-1.153522E+02 4.199621E+01
-1.153400E+02 4.199618E+01
-1.153147E+02 4.199611E+01
-1.153143E+02 4.199779E+01
-1.153142E+02 4.199785E+01
-1.153140E+02 4.199798E+01
-1.153138E+02 4.199803E+01
-1.153134E+02 4.199816E+01
-1.153133E+02 4.199820E+01
-1.153130E+02 4.199824E+01
-1.153128E+02 4.199826E+01
-1.153127E+02 4.199826E+01
-1.153123E+02 4.199827E+01
-1.153122E+02 4.199827E+01
-1.153117E+02 4.199826E+01
-1.153116E+02 4.199826E+01
-1.153114E+02 4.199826E+01
-1.153112E+02 4.199827E+01
-1.153112E+02 4.199828E+01
-1.153108E+02 4.199830E+01
-1.153106E+02 4.199830E+01
-1.153105E+02 4.199829E+01
-1.153103E+02 4.199828E+01
-1.153101E+02 4.199826E+01
-1.153095E+02 4.199809E+01
-1.153092E+02 4.199795E+01
-1.153085E+02 4.199616E+01
-1.152549E+02 4.199671E+01
-1.152543E+02 4.199672E+01
-1.152508E+02 4.199616E+01
-1.152420E+02 4.199615E+01
-1.150387E+02 4.199603E+01
-1.150318E+02 4.199601E+01
-1.149890E+02 4.199743E+01
-1.149729E+02 4.199796E+01
-1.149142E+02 4.199991E+01
-1.148992E+02 4.199991E+01
-1.148759E+02 4.200132E+01
-1.148517E+02 4.200180E+01
-1.148439E+02 4.200195E+01
-1.148311E+02 4.200221E+01
-1.148083E+02 4.200185E+01
-1.148067E+02 4.200183E+01
-1.148064E+02 4.200182E+01
-1.147207E+02 4.199823E+01
-1.146692E+02 4.199667E+01
-1.145983E+02 4.199451E+01
-1.144983E+02 4.199460E+01
-1.144982E+02 4.199464E+01
-1.144676E+02 4.199549E+01
-1.143975E+02 4.199501E+01
-1.142819E+02 4.199421E+01
-1.141074E+02 4.199397E+01
-1.141073E+02 4.199383E+01
-1.140618E+02 4.199394E+01
-1.140618E+02 4.199380E+01
-1.140483E+02 4.199381E+01
-1.140482E+02 4.199372E+01
-1.140417E+02 4.199372E+01
-1.140396E+02 4.188482E+01
-1.140411E+02 4.185057E+01
-1.140412E+02 4.185059E+01
-1.140400E+02 4.176458E+01
-1.140408E+02 4.176448E+01
-1.140410E+02 4.176482E+01
-1.140411E+02 4.176477E+01
-1.140412E+02 4.176474E+01
-1.140415E+02 4.176459E+01
-1.140418E+02 4.176448E+01
-1.140419E+02 4.176441E+01
-1.140421E+02 4.176430E+01
-1.140421E+02 4.176428E+01
-1.140426E+02 4.176423E+01
-1.140427E+02 4.176420E+01
-1.140431E+02 4.176401E+01
-1.140432E+02 4.176400E+01
-1.140432E+02 4.176397E+01
-1.140437E+02 4.176360E+01
-1.140438E+02 4.176354E+01
-1.140442E+02 4.176294E+01
-1.140442E+02 4.176286E+01
-1.140442E+02 4.176266E+01
-1.140444E+02 4.176261E+01
-1.140445E+02 4.176257E+01
-1.140446E+02 4.176252E+01
-1.140448E+02 4.176242E+01
-1.140448E+02 4.176238E+01
-1.140449E+02 4.176237E+01
-1.140450E+02 4.176235E+01
-1.140453E+02 4.176224E+01
-1.140457E+02 4.176208E+01
-1.140458E+02 4.176202E+01
-1.140462E+02 4.176179E+01
-1.140463E+02 4.176170E+01
-1.140464E+02 4.176161E+01
-1.140466E+02 4.176141E+01
-1.140467E+02 4.176125E+01
-1.140468E+02 4.176118E+01
-1.140470E+02 4.176079E+01
-1.140471E+02 4.176062E+01
-1.140473E+02 4.176015E+01
-1.140473E+02 4.176000E+01
-1.140474E+02 4.175958E+01
-1.140474E+02 4.175949E+01
-1.140476E+02 4.175892E+01
-1.140476E+02 4.175887E+01
-1.140476E+02 4.175835E+01
-1.140476E+02 4.175825E+01
-1.140475E+02 4.175773E+01
-1.140474E+02 4.175763E+01
-1.140473E+02 4.175737E+01
-1.140473E+02 4.175724E+01
-1.140471E+02 4.175690E+01
-1.140470E+02 4.175666E+01
-1.140469E+02 4.175640E+01
-1.140468E+02 4.175617E+01
-1.140465E+02 4.175587E+01
-1.140463E+02 4.175568E+01
-1.140463E+02 4.175560E+01
-1.140462E+02 4.175553E+01
-1.140461E+02 4.175526E+01
-1.140460E+02 4.175518E+01
-1.140459E+02 4.175500E+01
-1.140458E+02 4.175492E+01
-1.140456E+02 4.175477E+01
-1.140455E+02 4.175470E+01
-1.140454E+02 4.175459E+01
-1.140453E+02 4.175453E+01
-1.140451E+02 4.175442E+01
-1.140450E+02 4.175436E+01
-1.140448E+02 4.175428E+01
-1.140448E+02 4.175427E+01
-1.140445E+02 4.175406E+01
-1.140444E+02 4.175397E+01
-1.140441E+02 4.175380E+01
-1.140440E+02 4.175374E+01
-1.140437E+02 4.175357E+01
-1.140435E+02 4.175342E+01
-1.140434E+02 4.175336E+01
-1.140433E+02 4.175326E+01
-1.140431E+02 4.175316E+01
-1.140427E+02 4.175301E+01
-1.140421E+02 4.175235E+01
-1.140420E+02 4.175224E+01
-1.140418E+02 4.175206E+01
-1.140415E+02 4.175186E+01
-1.140413E+02 4.175176E+01
-1.140411E+02 4.175162E+01
-1.140410E+02 4.175159E+01
-1.140408E+02 4.175151E+01
-1.140407E+02 4.175147E+01
-1.140406E+02 4.175147E+01
-1.140399E+02 4.175179E+01
-1.140400E+02 4.162492E+01
-1.140404E+02 4.161538E+01
-1.140409E+02 4.149992E+01
-1.140402E+02 4.149169E+01
-1.140414E+02 4.121996E+01
-1.140426E+02 4.121092E+01
-1.140414E+02 4.120775E+01
-1.140403E+02 4.099999E+01
-1.140438E+02 4.075558E+01
-1.140437E+02 4.074418E+01
-1.140436E+02 4.072617E+01
-1.140437E+02 4.069907E+01
-1.140443E+02 4.062824E+01
-1.140453E+02 4.050659E+01
-1.140456E+02 4.049580E+01
-1.140455E+02 4.049447E+01
-1.140456E+02 4.043027E+01
-1.140458E+02 4.042482E+01
-1.140462E+02 4.039831E+01
-1.140462E+02 4.024444E+01
-1.140462E+02 4.023197E+01
-1.140484E+02 4.011856E+01
-1.140467E+02 4.011359E+01
-1.140467E+02 4.010423E+01
-1.140467E+02 4.010324E+01
-1.140464E+02 4.009790E+01
-1.140466E+02 4.006061E+01
-1.140468E+02 4.003013E+01
-1.140466E+02 3.999690E+01
-1.140471E+02 3.990608E+01
-1.140472E+02 3.986922E+01
-1.140472E+02 3.982102E+01
-1.140478E+02 3.979416E+01
-1.140473E+02 3.975941E+01
-1.140473E+02 3.975439E+01
-1.140473E+02 3.975395E+01
-1.140477E+02 3.954306E+01
-1.140471E+02 3.949994E+01
-1.140491E+02 3.900551E+01
-1.140481E+02 3.887874E+01
-1.140485E+02 3.887620E+01
-1.140495E+02 3.887495E+01
-1.140492E+02 3.874995E+01
-1.140497E+02 3.872921E+01
-1.140491E+02 3.867939E+01
-1.140491E+02 3.867750E+01
-1.140502E+02 3.857292E+01
-1.140499E+02 3.854776E+01
-1.140498E+02 3.854378E+01
-1.140505E+02 3.849995E+01
-1.140501E+02 3.840467E+01
-1.140501E+02 3.840454E+01
-1.140494E+02 3.826470E+01
-1.140501E+02 3.824996E+01
-1.140493E+02 3.815028E+01
-1.140504E+02 3.799996E+01
-1.140497E+02 3.788137E+01
-1.140499E+02 3.785251E+01
-1.140497E+02 3.782364E+01
-1.140485E+02 3.780986E+01
-1.140499E+02 3.776559E+01
-1.140511E+02 3.775628E+01
-1.140517E+02 3.774696E+01
-1.140518E+02 3.774623E+01
-1.140517E+02 3.774596E+01
-1.140518E+02 3.772400E+01
-1.140539E+02 3.760754E+01
-1.140530E+02 3.759278E+01
-1.140527E+02 3.753352E+01
-1.140527E+02 3.753226E+01
-1.140527E+02 3.753103E+01
-1.140527E+02 3.751786E+01
-1.140527E+02 3.751726E+01
-1.140527E+02 3.750251E+01
-1.140527E+02 3.749201E+01
-1.140524E+02 3.743144E+01
-1.140518E+02 3.741808E+01
-1.140519E+02 3.737073E+01
-1.140519E+02 3.737046E+01
-1.140518E+02 3.729355E+01
-1.140518E+02 3.729304E+01
-1.140520E+02 3.728451E+01
-1.140520E+02 3.728385E+01
-1.140514E+02 3.723385E+01
-1.140517E+02 3.717237E+01
-1.140522E+02 3.714711E+01
-1.140519E+02 3.713429E+01
-1.140528E+02 3.710396E+01
-1.140518E+02 3.709098E+01
-1.140517E+02 3.708843E+01
-1.140510E+02 3.699999E+01
-1.140500E+02 3.684313E+01
-1.140500E+02 3.679924E+01
-1.140468E+02 3.619845E+01
-1.140477E+02 3.619712E+01
-1.140500E+02 3.619357E+01
-1.140603E+02 3.618936E+01
-1.140671E+02 3.618167E+01
-1.140680E+02 3.618066E+01
-1.140682E+02 3.618035E+01
-1.140747E+02 3.616902E+01
-1.140790E+02 3.616161E+01
-1.140890E+02 3.614438E+01
-1.140947E+02 3.613232E+01
-1.140999E+02 3.612165E+01
-1.141032E+02 3.612018E+01
-1.141110E+02 3.611988E+01
-1.141209E+02 3.611460E+01
-1.141231E+02 3.611158E+01
-1.141238E+02 3.610784E+01
-1.141240E+02 3.610652E+01
-1.141235E+02 3.610551E+01
-1.141232E+02 3.610475E+01
-1.141200E+02 3.610257E+01
-1.141194E+02 3.610216E+01
-1.141175E+02 3.610089E+01
-1.141156E+02 3.609873E+01
-1.141142E+02 3.609698E+01
-1.141143E+02 3.609620E+01
-1.141145E+02 3.609522E+01
-1.141279E+02 3.607383E+01
-1.141369E+02 3.605947E+01
-1.141371E+02 3.605843E+01
-1.141382E+02 3.605316E+01
-1.141372E+02 3.604678E+01
-1.141382E+02 3.604128E+01
-1.141388E+02 3.604047E+01
-1.141403E+02 3.603846E+01
-1.141454E+02 3.603169E+01
-1.141482E+02 3.602801E+01
-1.141517E+02 3.602456E+01
-1.141523E+02 3.602439E+01
-1.141541E+02 3.602386E+01
-1.141595E+02 3.602556E+01
-1.141631E+02 3.602668E+01
-1.141656E+02 3.602746E+01
-1.141665E+02 3.602774E+01
-1.141674E+02 3.602773E+01
-1.141768E+02 3.602765E+01
-1.141924E+02 3.602099E+01
-1.142090E+02 3.601680E+01
-1.142137E+02 3.601561E+01
-1.142156E+02 3.601548E+01
-1.142333E+02 3.601429E+01
-1.142372E+02 3.601448E+01
-1.142388E+02 3.601456E+01
-1.142444E+02 3.601683E+01
-1.142502E+02 3.601921E+01
-1.142527E+02 3.602019E+01
-1.142631E+02 3.602594E+01
-1.142649E+02 3.602757E+01
-1.142667E+02 3.602924E+01
-1.142706E+02 3.603572E+01
-1.142713E+02 3.603643E+01
-1.142802E+02 3.604636E+01
-1.142965E+02 3.605203E+01
-1.143140E+02 3.605817E+01
-1.143156E+02 3.605949E+01
-1.143161E+02 3.606311E+01
-1.143142E+02 3.606662E+01
-1.143141E+02 3.606673E+01
-1.143079E+02 3.607129E+01
-1.143070E+02 3.607275E+01
-1.143057E+02 3.607488E+01
-1.143084E+02 3.608244E+01
-1.143288E+02 3.610550E+01
-1.143373E+02 3.610802E+01
-1.143594E+02 3.612707E+01
-1.143631E+02 3.613025E+01
-1.143721E+02 3.614311E+01
-1.143779E+02 3.614385E+01
-1.144055E+02 3.614737E+01
-1.144124E+02 3.614725E+01
-1.144151E+02 3.614636E+01
-1.144169E+02 3.614576E+01
-1.144272E+02 3.613631E+01
-1.144466E+02 3.612597E+01
-1.144487E+02 3.612641E+01
-1.144493E+02 3.612704E+01
-1.144533E+02 3.613073E+01
-1.144584E+02 3.613859E+01
-1.144636E+02 3.613970E+01
-1.144702E+02 3.613880E+01
-1.144752E+02 3.613599E+01
-1.144870E+02 3.612940E+01
-1.144961E+02 3.612785E+01
-1.144977E+02 3.612809E+01
-1.145022E+02 3.612880E+01
-1.145044E+02 3.612974E+01
-1.145058E+02 3.613144E+01
-1.145060E+02 3.613356E+01
-1.145061E+02 3.613466E+01
-1.145054E+02 3.613750E+01
-1.145048E+02 3.614241E+01
-1.145047E+02 3.614447E+01
-1.145046E+02 3.614563E+01
-1.145067E+02 3.614828E+01
-1.145087E+02 3.614933E+01
-1.145117E+02 3.615096E+01
-1.145153E+02 3.615109E+01
-1.145158E+02 3.615111E+01
-1.145395E+02 3.615201E+01
-1.145420E+02 3.615211E+01
-1.145458E+02 3.615225E+01
-1.145546E+02 3.615203E+01
-1.145600E+02 3.615190E+01
-1.145676E+02 3.615172E+01
-1.145720E+02 3.615161E+01
-1.145750E+02 3.615048E+01
-1.145779E+02 3.614940E+01
-1.145972E+02 3.614210E+01
-1.146083E+02 3.613395E+01
-1.146134E+02 3.613162E+01
-1.146167E+02 3.613010E+01
-1.146199E+02 3.613134E+01
-1.146219E+02 3.613213E+01
-1.146279E+02 3.614101E+01
-1.146300E+02 3.614173E+01
-1.146317E+02 3.614231E+01
-1.146497E+02 3.613074E+01
-1.146526E+02 3.612888E+01
-1.146599E+02 3.612414E+01
-1.146615E+02 3.612186E+01
-1.146629E+02 3.611993E+01
-1.146665E+02 3.611734E+01
-1.146716E+02 3.611621E+01
-1.146741E+02 3.611565E+01
-1.146894E+02 3.611227E+01
-1.147020E+02 3.610947E+01
-1.147056E+02 3.610868E+01
-1.147098E+02 3.610774E+01
-1.147173E+02 3.610769E+01
-1.147346E+02 3.610465E+01
-1.147362E+02 3.610437E+01
-1.147471E+02 3.609701E+01
-1.147503E+02 3.609389E+01
-1.147536E+02 3.609070E+01
-1.147556E+02 3.608717E+01
-1.147556E+02 3.608531E+01
-1.147555E+02 3.608160E+01
-1.147553E+02 3.608133E+01
-1.147541E+02 3.607944E+01
-1.147477E+02 3.607413E+01
-1.147433E+02 3.607053E+01
-1.147401E+02 3.606222E+01
-1.147361E+02 3.605892E+01
-1.147350E+02 3.605469E+01
-1.147359E+02 3.605319E+01
-1.147383E+02 3.605140E+01
-1.147403E+02 3.604991E+01
-1.147435E+02 3.604484E+01
-1.147436E+02 3.604438E+01
-1.147445E+02 3.604128E+01
-1.147426E+02 3.603900E+01
-1.147351E+02 3.603844E+01
-1.147341E+02 3.603783E+01
-1.147300E+02 3.603545E+01
-1.147252E+02 3.603299E+01
-1.147232E+02 3.602691E+01
-1.147268E+02 3.602407E+01
-1.147347E+02 3.601765E+01
-1.147372E+02 3.601618E+01
-1.147378E+02 3.601536E+01
-1.147379E+02 3.601527E+01
-1.147379E+02 3.601527E+01
-1.147379E+02 3.601526E+01
-1.147383E+02 3.601504E+01
-1.147396E+02 3.601412E+01
-1.147400E+02 3.601384E+01
-1.147402E+02 3.601361E+01
-1.147405E+02 3.601307E+01
-1.147422E+02 3.601102E+01
-1.147432E+02 3.600883E+01
-1.147427E+02 3.600359E+01
-1.147409E+02 3.599825E+01
-1.147395E+02 3.599273E+01
-1.147399E+02 3.599086E+01
-1.147399E+02 3.599076E+01
-1.147402E+02 3.599047E+01
-1.147415E+02 3.598917E+01
-1.147433E+02 3.598739E+01
-1.147434E+02 3.598570E+01
-1.147435E+02 3.598504E+01
-1.147431E+02 3.598380E+01
-1.147406E+02 3.597566E+01
-1.147342E+02 3.596753E+01
-1.147299E+02 3.596218E+01
-1.147294E+02 3.596034E+01
-1.147283E+02 3.595629E+01
-1.147312E+02 3.594392E+01
-1.147308E+02 3.594345E+01
-1.147294E+02 3.594141E+01
-1.147157E+02 3.593471E+01
-1.147098E+02 3.592993E+01
-1.147075E+02 3.592806E+01
-1.147081E+02 3.591816E+01
-1.147085E+02 3.591231E+01
-1.147003E+02 3.590177E+01
-1.146903E+02 3.589326E+01
-1.146799E+02 3.588632E+01
-1.146788E+02 3.588537E+01
-1.146772E+02 3.588407E+01
-1.146748E+02 3.588134E+01
-1.146711E+02 3.587716E+01
-1.146673E+02 3.587538E+01
-1.146659E+02 3.587498E+01
-1.146635E+02 3.587427E+01
-1.146624E+02 3.587290E+01
-1.146619E+02 3.587225E+01
-1.146619E+02 3.587217E+01
-1.146621E+02 3.587009E+01
-1.146672E+02 3.586736E+01
-1.146695E+02 3.586634E+01
-1.146723E+02 3.586507E+01
-1.146737E+02 3.586471E+01
-1.146772E+02 3.586389E+01
-1.146820E+02 3.586328E+01
-1.146902E+02 3.585890E+01
-1.146918E+02 3.585806E+01
-1.146923E+02 3.585775E+01
-1.146978E+02 3.585484E+01
-1.146997E+02 3.584895E+01
-1.146998E+02 3.584837E+01
-1.146998E+02 3.584328E+01
-1.146964E+02 3.583378E+01
-1.146957E+02 3.583062E+01
-1.146957E+02 3.583060E+01
-1.146985E+02 3.582492E+01
-1.147029E+02 3.581622E+01
-1.147037E+02 3.581459E+01
-1.147099E+02 3.581018E+01
-1.147121E+02 3.580618E+01
-1.147072E+02 3.580027E+01
-1.147000E+02 3.579151E+01
-1.146989E+02 3.579019E+01
-1.147014E+02 3.576909E+01
-1.146957E+02 3.575599E+01
-1.146960E+02 3.575195E+01
-1.146973E+02 3.573369E+01
-1.147001E+02 3.572602E+01
-1.147053E+02 3.571159E+01
-1.147054E+02 3.570829E+01
-1.147052E+02 3.570793E+01
-1.147012E+02 3.570119E+01
-1.146941E+02 3.569519E+01
-1.146832E+02 3.568939E+01
-1.146815E+02 3.568683E+01
-1.146806E+02 3.568549E+01
-1.146822E+02 3.567819E+01
-1.146866E+02 3.567055E+01
-1.146881E+02 3.566803E+01
-1.146900E+02 3.566469E+01
-1.146898E+02 3.566038E+01
-1.146894E+02 3.565141E+01
-1.146891E+02 3.565113E+01
-1.146771E+02 3.564149E+01
-1.146672E+02 3.563001E+01
-1.146625E+02 3.562455E+01
-1.146602E+02 3.562161E+01
-1.146582E+02 3.561909E+01
-1.146534E+02 3.561079E+01
-1.146539E+02 3.560320E+01
-1.146543E+02 3.559759E+01
-1.146560E+02 3.559433E+01
-1.146596E+02 3.558749E+01
-1.146627E+02 3.558388E+01
-1.146656E+02 3.558043E+01
-1.146662E+02 3.557758E+01
-1.146630E+02 3.556369E+01
-1.146620E+02 3.554549E+01
-1.146610E+02 3.554188E+01
-1.146602E+02 3.553929E+01
-1.146594E+02 3.553850E+01
-1.146574E+02 3.553639E+01
-1.146569E+02 3.553439E+01
-1.146577E+02 3.553172E+01
-1.146580E+02 3.553049E+01
-1.146631E+02 3.552449E+01
-1.146681E+02 3.552138E+01
-1.146736E+02 3.551799E+01
-1.146738E+02 3.551789E+01
-1.146744E+02 3.551718E+01
-1.146772E+02 3.551349E+01
-1.146792E+02 3.549999E+01
-1.146776E+02 3.548974E+01
-1.146756E+02 3.548628E+01
-1.146729E+02 3.548171E+01
-1.146664E+02 3.546686E+01
-1.146656E+02 3.545974E+01
-1.146651E+02 3.545519E+01
-1.146646E+02 3.545084E+01
-1.146645E+02 3.544950E+01
-1.146621E+02 3.544424E+01
-1.146537E+02 3.543176E+01
-1.146537E+02 3.543163E+01
-1.146520E+02 3.542916E+01
-1.146498E+02 3.542741E+01
-1.146271E+02 3.540950E+01
-1.146199E+02 3.539078E+01
-1.146196E+02 3.539009E+01
-1.146114E+02 3.536906E+01
-1.146107E+02 3.536738E+01
-1.146043E+02 3.535358E+01
-1.145995E+02 3.533744E+01
-1.145959E+02 3.532523E+01
-1.145965E+02 3.531507E+01
-1.145966E+02 3.531354E+01
-1.145975E+02 3.529695E+01
-1.145881E+02 3.526569E+01
-1.145871E+02 3.526238E+01
-1.145831E+02 3.523809E+01
-1.145836E+02 3.522993E+01
-1.145829E+02 3.522603E+01
-1.145800E+02 3.520964E+01
-1.145791E+02 3.520899E+01
-1.145748E+02 3.520590E+01
-1.145736E+02 3.520343E+01
-1.145721E+02 3.520059E+01
-1.145720E+02 3.520007E+01
-1.145718E+02 3.519951E+01
-1.145715E+02 3.519408E+01
-1.145718E+02 3.519161E+01
-1.145697E+02 3.518650E+01
-1.145696E+02 3.518338E+01
-1.145693E+02 3.517219E+01
-1.145694E+02 3.516940E+01
-1.145695E+02 3.516269E+01
-1.145742E+02 3.514532E+01
-1.145732E+02 3.514186E+01
-1.145730E+02 3.514081E+01
-1.145730E+02 3.513849E+01
-1.145783E+02 3.512881E+01
-1.145821E+02 3.512656E+01
-1.145857E+02 3.512477E+01
-1.145877E+02 3.512373E+01
-1.145991E+02 3.512105E+01
-1.146040E+02 3.512119E+01
-1.146081E+02 3.512145E+01
-1.146095E+02 3.512144E+01
-1.146130E+02 3.512144E+01
-1.146167E+02 3.512154E+01
-1.146199E+02 3.512163E+01
-1.146214E+02 3.512119E+01
-1.146237E+02 3.512049E+01
-1.146285E+02 3.511896E+01
-1.146299E+02 3.511827E+01
-1.146323E+02 3.511709E+01
-1.146374E+02 3.511247E+01
-1.146382E+02 3.511166E+01
-1.146420E+02 3.510790E+01
-1.146444E+02 3.510590E+01
-1.146452E+02 3.510501E+01
-1.146462E+02 3.510296E+01
-1.146468E+02 3.510187E+01
-1.146428E+02 3.509650E+01
-1.146373E+02 3.509440E+01
-1.146323E+02 3.509246E+01
-1.146225E+02 3.508870E+01
-1.146196E+02 3.508693E+01
-1.146131E+02 3.508310E+01
-1.146073E+02 3.507842E+01
-1.146061E+02 3.507682E+01
-1.146046E+02 3.507482E+01
-1.146032E+02 3.507044E+01
-1.146029E+02 3.506887E+01
-1.146029E+02 3.506859E+01
-1.146030E+02 3.506654E+01
-1.146036E+02 3.506423E+01
-1.146046E+02 3.506171E+01
-1.146049E+02 3.506122E+01
-1.146067E+02 3.505863E+01
-1.146072E+02 3.505825E+01
-1.146110E+02 3.505534E+01
-1.146198E+02 3.505015E+01
-1.146202E+02 3.504984E+01
-1.146269E+02 3.504470E+01
-1.146273E+02 3.504414E+01
-1.146344E+02 3.503423E+01
-1.146351E+02 3.503260E+01
-1.146361E+02 3.503037E+01
-1.146375E+02 3.502592E+01
-1.146377E+02 3.502524E+01
-1.146380E+02 3.501651E+01
-1.146375E+02 3.501407E+01
-1.146367E+02 3.500981E+01
-1.146357E+02 3.500770E+01
-1.146330E+02 3.500188E+01
-1.146890E+02 3.504698E+01
-1.148241E+02 3.515575E+01
-1.148425E+02 3.517050E+01
-1.148758E+02 3.519720E+01
-1.149756E+02 3.527702E+01
-1.150008E+02 3.529722E+01
-1.150008E+02 3.529725E+01
-1.150201E+02 3.531265E+01
-1.150362E+02 3.532553E+01
-1.150395E+02 3.532821E+01
-1.150666E+02 3.534983E+01
-1.150833E+02 3.536307E+01
-1.150879E+02 3.536671E+01
-1.150982E+02 3.537499E+01
-1.150982E+02 3.537499E+01
-1.150980E+02 3.537499E+01
-1.150980E+02 3.537499E+01
-1.150980E+02 3.537499E+01
-1.151258E+02 3.539706E+01
-1.151376E+02 3.540633E+01
-1.151588E+02 3.542312E+01
-1.151608E+02 3.542475E+01
-1.151634E+02 3.542679E+01
-1.151852E+02 3.544417E+01
-1.152028E+02 3.545813E+01
-1.152199E+02 3.547175E+01
-1.152328E+02 3.548193E+01
-1.152460E+02 3.549248E+01
-1.152508E+02 3.549638E+01
-1.152508E+02 3.549637E+01
-1.152508E+02 3.549623E+01
-1.152555E+02 3.549999E+01
-1.152554E+02 3.549999E+01
-1.152826E+02 3.552132E+01
-1.153057E+02 3.553957E+01
-1.153224E+02 3.555281E+01
-1.153297E+02 3.555865E+01
-1.153531E+02 3.557720E+01
-1.153663E+02 3.558763E+01
-1.153911E+02 3.560713E+01
-1.153913E+02 3.560728E+01
-1.153914E+02 3.560739E+01
-1.156481E+02 3.580914E+01
-1.156562E+02 3.581552E+01
-1.157051E+02 3.585386E+01
-1.157273E+02 3.587115E+01
-1.157322E+02 3.587497E+01
-1.157322E+02 3.587497E+01
-1.157322E+02 3.587497E+01
-1.158466E+02 3.596177E+01
-1.159120E+02 3.601499E+01
-1.159339E+02 3.603208E+01
-1.160009E+02 3.608399E+01
-1.160122E+02 3.609266E+01
-1.160347E+02 3.611010E+01
-1.160538E+02 3.612496E+01
-1.160551E+02 3.612595E+01
-1.160645E+02 3.613318E+01
-1.160712E+02 3.613836E+01
-1.160812E+02 3.614618E+01
-1.160966E+02 3.615815E+01
-1.160981E+02 3.615935E+01
-1.161081E+02 3.616700E+01
-1.161137E+02 3.617131E+01
-1.161410E+02 3.619233E+01
-1.161465E+02 3.619651E+01
-1.161468E+02 3.619679E+01
-1.161813E+02 3.622339E+01
-1.162015E+02 3.623899E+01
-1.162051E+02 3.624173E+01
-1.162157E+02 3.624996E+01
-1.162248E+02 3.625697E+01
-1.162320E+02 3.626254E+01
-1.162509E+02 3.627693E+01
-1.162937E+02 3.630985E+01
-1.163228E+02 3.633218E+01
-1.163288E+02 3.633683E+01
-1.163502E+02 3.635320E+01
-1.163759E+02 3.637296E+01
-1.163769E+02 3.637371E+01
-1.163785E+02 3.637496E+01
-1.163937E+02 3.638659E+01
-1.164094E+02 3.639856E+01
-1.164194E+02 3.640630E+01
-1.164288E+02 3.641360E+01
-1.164434E+02 3.642460E+01
-1.164501E+02 3.642975E+01
-1.164679E+02 3.644337E+01
-1.164819E+02 3.645407E+01
-1.164835E+02 3.645534E+01
-1.164838E+02 3.645554E+01
-1.165009E+02 3.646840E+01
-1.165063E+02 3.647257E+01
-1.165229E+02 3.648527E+01
-1.165422E+02 3.649995E+01
-1.165421E+02 3.649995E+01
-1.165487E+02 3.650512E+01
-1.165709E+02 3.652202E+01
-1.165982E+02 3.654281E+01
-1.166468E+02 3.657996E+01
-1.166781E+02 3.660364E+01
-1.167509E+02 3.665869E+01
-1.167509E+02 3.665872E+01
-1.167509E+02 3.665874E+01
-1.167605E+02 3.666597E+01
-1.167788E+02 3.667983E+01
-1.168028E+02 3.669794E+01
-1.168100E+02 3.670334E+01
-1.168151E+02 3.670722E+01
-1.168418E+02 3.672743E+01
-1.168624E+02 3.674302E+01
-1.168716E+02 3.674995E+01
-1.168760E+02 3.675314E+01
-1.168901E+02 3.676393E+01
-1.169125E+02 3.678086E+01
-1.169217E+02 3.678773E+01
-1.169329E+02 3.679605E+01
-1.169598E+02 3.681634E+01
-1.169781E+02 3.683018E+01
-1.170224E+02 3.686341E+01
-1.170339E+02 3.687195E+01
-1.170379E+02 3.687494E+01
-1.170830E+02 3.690895E+01
-1.171019E+02 3.692313E+01
-1.171062E+02 3.692633E+01
-1.171259E+02 3.694108E+01
-1.171259E+02 3.694095E+01
-1.171639E+02 3.696944E+01
-1.171910E+02 3.698967E+01
-1.172047E+02 3.699994E+01
-1.172370E+02 3.702406E+01
-1.172492E+02 3.703324E+01
-1.172509E+02 3.703449E+01
-1.172696E+02 3.704839E+01
-1.172825E+02 3.705783E+01
-1.172830E+02 3.705822E+01
-1.172915E+02 3.706470E+01
-1.173174E+02 3.708382E+01
-1.173266E+02 3.709069E+01
-1.173331E+02 3.709558E+01
-1.173435E+02 3.710339E+01
-1.173505E+02 3.710867E+01
-1.173726E+02 3.712493E+01
-1.173759E+02 3.712746E+01
-1.173760E+02 3.712753E+01
-1.173908E+02 3.713859E+01
-1.174161E+02 3.715742E+01
-1.174577E+02 3.718818E+01
-1.174698E+02 3.719712E+01
-1.175229E+02 3.723629E+01
-1.175413E+02 3.724993E+01
-1.175412E+02 3.724993E+01
-1.175411E+02 3.724993E+01
-1.175502E+02 3.725666E+01
-1.175673E+02 3.726943E+01
-1.175718E+02 3.727274E+01
-1.175887E+02 3.728524E+01
-1.176074E+02 3.729900E+01
-1.176259E+02 3.731258E+01
-1.176259E+02 3.731261E+01
-1.176259E+02 3.731263E+01
-1.176404E+02 3.732315E+01
-1.176892E+02 3.735907E+01
-1.177107E+02 3.737493E+01
-1.177107E+02 3.737493E+01
-1.177107E+02 3.737493E+01
-1.177216E+02 3.738301E+01
-1.177248E+02 3.738531E+01
-1.177731E+02 3.742073E+01
-1.177756E+02 3.742260E+01
-1.177761E+02 3.742297E+01
-1.177842E+02 3.742892E+01
-1.178068E+02 3.744561E+01
-1.178200E+02 3.745521E+01
-1.178331E+02 3.746469E+01
-1.178404E+02 3.747000E+01
-1.178759E+02 3.749617E+01
-1.178759E+02 3.749611E+01
-1.178811E+02 3.749992E+01
-1.178961E+02 3.751079E+01
-1.179107E+02 3.752134E+01
-1.179638E+02 3.756021E+01
-1.179853E+02 3.757585E+01
-1.179883E+02 3.757802E+01
-1.180009E+02 3.758717E+01
-1.180009E+02 3.758726E+01
-1.180213E+02 3.760199E+01
-1.180342E+02 3.761154E+01
-1.180361E+02 3.761297E+01
-1.180421E+02 3.761727E+01
-1.180527E+02 3.762493E+01
-1.180527E+02 3.762493E+01
-1.180527E+02 3.762493E+01
-1.180646E+02 3.763356E+01
-1.180918E+02 3.765329E+01
-1.181256E+02 3.767782E+01
-1.181492E+02 3.769486E+01
-1.181873E+02 3.772255E+01
-1.181952E+02 3.772821E+01
-1.182047E+02 3.773512E+01
-1.182255E+02 3.775014E+01
-1.182493E+02 3.776739E+01
-1.182509E+02 3.776858E+01
-1.182509E+02 3.776858E+01
-1.182509E+02 3.776864E+01
-1.182624E+02 3.777685E+01
-1.182760E+02 3.778667E+01
-1.183062E+02 3.780848E+01
-1.183385E+02 3.783178E+01
-1.183418E+02 3.783416E+01
-1.183463E+02 3.783741E+01
-1.183760E+02 3.785879E+01
-1.183760E+02 3.785874E+01
-1.183985E+02 3.787493E+01
-1.183983E+02 3.787493E+01
-1.183983E+02 3.787493E+01
-1.183994E+02 3.787570E+01
-1.184124E+02 3.788510E+01
-1.184260E+02 3.789481E+01
-1.184275E+02 3.789591E+01
-1.184278E+02 3.789610E+01
-1.184294E+02 3.789729E+01
-1.184654E+02 3.792316E+01
-1.184776E+02 3.793193E+01
-1.184857E+02 3.793770E+01
-1.184920E+02 3.794221E+01
-1.185010E+02 3.794866E+01
-1.185010E+02 3.794861E+01
-1.185010E+02 3.794859E+01
-1.185111E+02 3.795585E+01
-1.185190E+02 3.796146E+01
-1.185223E+02 3.796386E+01
-1.185317E+02 3.797055E+01
-1.185516E+02 3.798490E+01
-1.185879E+02 3.801088E+01
-1.185953E+02 3.801617E+01
-1.186075E+02 3.802489E+01
-1.186245E+02 3.803697E+01
-1.186260E+02 3.803802E+01
-1.186276E+02 3.803922E+01
-1.186784E+02 3.807549E+01
-1.187375E+02 3.811770E+01
-1.187477E+02 3.812493E+01
-1.187510E+02 3.812712E+01
-1.187712E+02 3.814157E+01
-1.187975E+02 3.816039E+01
-1.188145E+02 3.817245E+01
-1.188384E+02 3.818944E+01
-1.188469E+02 3.819543E+01
-1.188589E+02 3.820398E+01
-1.188748E+02 3.821510E+01
-1.188846E+02 3.822192E+01
-1.189030E+02 3.823500E+01
-1.189173E+02 3.824506E+01
-1.189242E+02 3.824992E+01
-1.189333E+02 3.825640E+01
-1.190256E+02 3.832162E+01
-1.190589E+02 3.834507E+01
-1.190625E+02 3.834756E+01
-1.191154E+02 3.838520E+01
-1.191260E+02 3.839269E+01
-1.191546E+02 3.841274E+01
-1.191854E+02 3.843435E+01
-1.192293E+02 3.846520E+01
-1.192510E+02 3.848036E+01
-1.192560E+02 3.848389E+01
-1.192648E+02 3.849004E+01
-1.192732E+02 3.849592E+01
-1.192790E+02 3.849992E+01
-1.192879E+02 3.850621E+01
-1.193046E+02 3.851782E+01
-1.193230E+02 3.853064E+01
-1.193309E+02 3.853617E+01
-1.193425E+02 3.854428E+01
-1.193528E+02 3.855149E+01
-1.193589E+02 3.855577E+01
-1.193760E+02 3.856756E+01
-1.194474E+02 3.861747E+01
-1.194580E+02 3.862491E+01
-1.194596E+02 3.862592E+01
-1.194978E+02 3.865255E+01
-1.195010E+02 3.865478E+01
-1.195030E+02 3.865616E+01
-1.195205E+02 3.866831E+01
-1.195472E+02 3.868677E+01
-1.195503E+02 3.868895E+01
-1.195642E+02 3.869862E+01
-1.195802E+02 3.870971E+01
-1.195867E+02 3.871420E+01
-1.195938E+02 3.871914E+01
-1.196070E+02 3.872831E+01
-1.196214E+02 3.873819E+01
-1.196260E+02 3.874137E+01
-1.196382E+02 3.874991E+01
-1.196654E+02 3.876877E+01
-1.197250E+02 3.880993E+01
-1.197510E+02 3.882777E+01
-1.197646E+02 3.883716E+01
-1.197790E+02 3.884708E+01
-1.197868E+02 3.885244E+01
-1.198093E+02 3.886794E+01
-1.198289E+02 3.888144E+01
-1.198389E+02 3.888835E+01
-1.198438E+02 3.889178E+01
-1.198443E+02 3.889211E+01
-1.198458E+02 3.889314E+01
-1.198499E+02 3.889593E+01
-1.198517E+02 3.889713E+01
-1.198578E+02 3.890133E+01
-1.198582E+02 3.890160E+01
-1.198623E+02 3.890442E+01
-1.198659E+02 3.890696E+01
-1.198760E+02 3.891394E+01
-1.198760E+02 3.891396E+01
-1.198760E+02 3.891398E+01
-1.198896E+02 3.892325E+01
-1.198962E+02 3.892783E+01
-1.199004E+02 3.893068E+01
-1.199006E+02 3.893077E+01
-1.199006E+02 3.893082E+01
-1.199044E+02 3.893342E+01
-1.199048E+02 3.893370E+01
-1.199156E+02 3.894107E+01
-1.199233E+02 3.894635E+01
-1.199274E+02 3.894917E+01
-1.199333E+02 3.895316E+01
-1.199363E+02 3.895524E+01
-1.199373E+02 3.895593E+01
-1.199387E+02 3.895687E+01
-1.199387E+02 3.895689E+01
-1.199388E+02 3.895691E+01
-1.199514E+02 3.896557E+01
-1.199671E+02 3.897640E+01
-1.199908E+02 3.899262E+01
-1.200010E+02 3.899959E+01
-1.200015E+02 3.902520E+01
-1.200017E+02 3.903236E+01
-1.200025E+02 3.906748E+01
-1.200029E+02 3.908733E+01
-1.200034E+02 3.911269E+01
-1.200037E+02 3.912491E+01
-1.200042E+02 3.915129E+01
-1.200045E+02 3.916557E+01
-1.200051E+02 3.919019E+01
-1.200057E+02 3.922267E+01
-1.200057E+02 3.922270E+01
-1.200057E+02 3.922346E+01
-1.200055E+02 3.927306E+01
-1.200055E+02 3.928743E+01
-1.200054E+02 3.931642E+01
-1.200050E+02 3.933952E+01
END
END
| {
"pile_set_name": "Github"
} |
#pmlogconf-setup 2.0
ident all available interrupts per CPU
probe kernel.percpu.interrupts.LOC values ? include : exclude
delta 10 minutes
kernel.percpu.interrupts
| {
"pile_set_name": "Github"
} |
# 72. Edit Distance
**<font color=red>้พๅบฆHard</font>**
## ๅท้ขๅ
ๅฎน
> ๅ้ข่ฟๆฅ
* https://leetcode.com/problems/edit-distance/
> ๅ
ๅฎนๆ่ฟฐ
```
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.
Example 1:
Input:
s = "barfoothefoobarman",
words = ["foo","bar"]
Output: [0,9]
Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively.
The output order does not matter, returning [9,0] is fine too.
Example 2:
Input:
s = "wordgoodstudentgoodword",
words = ["word","student"]
Output: []
```
> ๆ่ทฏ
******- ๆถ้ดๅคๆๅบฆ: O(n^2)******- ็ฉบ้ดๅคๆๅบฆ: O(n^2)******
่ฟ้ขๅฏไปฅๅจๆ่งๅ็ๆๆณๅป่งฃๅณ๏ผ้ฆๅ
ๅฎไนไธคไธชๆ้ i ๅ j๏ผๅๅซๆๅๅญ็ฌฆไธฒ็ๆซๅฐพใไปไธคไธชๅญ็ฌฆไธฒ็ๆซๅฐพๅผๅงๆฏ่พ๏ผ็ธ็ญ๏ผๅ```--i,--j```ใ่ฅไธ็ธ็ญ๏ผๆไธ็งๆ
ๅต๏ผๅ ้ค i ๆๅ็ๅญ็ฌฆ๏ผๅจ i ๆๅ็ๅญ็ฌฆไนๅๅขๅ ไธไธชๅญ็ฌฆ๏ผๆฟๆข i ๆๅ็ๅญ็ฌฆ๏ผ ๆฅ็ๆฏ่พ่ฟไธๆฌก็ๆไฝ็ๆฌกๆฐ๏ผๅๆๅฐๅผๅณๅฏ๏ผไธ่ฟ่ฟ้่ฆๆณจๆ้ๅฝๆไฝๆถไผ้ๅค่ฎก็ฎ๏ผๆไปฅๆไปฌ็จไธไธชๆฐ็ป dp[i][j]๏ผ่กจ็คบ i ๅจwords1ไธญ็ไฝ็ฝฎ๏ผj ๅจ words2 ็ไฝ็ฝฎใ็ฑไบc++ๅฏนๅจๆๆฐ็ป็ๆฏๆไธๆฏๅพๅฅฝ๏ผ่ฟ้ๆ็จ vector ไปฃๆฟ๏ผๅจๆ็ไธๅฏ่ฝ่พๆฌ ็ผบใ
```cpp
class Solution {
public:
vector<vector<int> > dp;
int minLen(string& w1,string& w2,int i,int j)
{
if(i < 0)
return j + 1;
if(j < 0)
return i + 1;
if(dp[i][j])
return dp[i][j];
if(w1[i] == w2[j])
{
dp[i][j] = minLen(w1,w2,i - 1,j - 1);
return dp[i][j];
}
int temp1 = min(minLen(w1,w2,i - 1,j) + 1,minLen(w1,w2,i - 1,j - 1) + 1);
dp[i][j] = min(minLen(w1,w2,i,j - 1) + 1,temp1);
return dp[i][j];
}
int minDistance(string word1, string word2) {
int i = word1.length() - 1,j = word2.length() - 1;
for(int t1 = 0;t1 <= i;++t1)
{
vector<int> v1;
for(int t2 = 0;t2 <= j;++t2)
v1.push_back(0);
dp.push_back(v1);
}
int m = minLen(word1,word2,i,j);
return m;
}
};
```
| {
"pile_set_name": "Github"
} |
require_relative 'taggable_model'
class AlteredInheritingTaggableModel < TaggableModel
acts_as_taggable_on :parts
end
| {
"pile_set_name": "Github"
} |
// 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 BASE_MAC_SCOPED_MACH_VM_H_
#define BASE_MAC_SCOPED_MACH_VM_H_
#include <mach/mach.h>
#include <stddef.h>
#include <algorithm>
#include "base/base_export.h"
#include "base/check_op.h"
#include "base/macros.h"
// Use ScopedMachVM to supervise ownership of pages in the current process
// through the Mach VM subsystem. Pages allocated with vm_allocate can be
// released when exiting a scope with ScopedMachVM.
//
// The Mach VM subsystem operates on a page-by-page basis, and a single VM
// allocation managed by a ScopedMachVM object may span multiple pages. As far
// as Mach is concerned, allocated pages may be deallocated individually. This
// is in contrast to higher-level allocators such as malloc, where the base
// address of an allocation implies the size of an allocated block.
// Consequently, it is not sufficient to just pass the base address of an
// allocation to ScopedMachVM, it also needs to know the size of the
// allocation. To avoid any confusion, both the base address and size must
// be page-aligned.
//
// When dealing with Mach VM, base addresses will naturally be page-aligned,
// but user-specified sizes may not be. If there's a concern that a size is
// not page-aligned, use the mach_vm_round_page macro to correct it.
//
// Example:
//
// vm_address_t address = 0;
// vm_size_t size = 12345; // This requested size is not page-aligned.
// kern_return_t kr =
// vm_allocate(mach_task_self(), &address, size, VM_FLAGS_ANYWHERE);
// if (kr != KERN_SUCCESS) {
// return false;
// }
// ScopedMachVM vm_owner(address, mach_vm_round_page(size));
namespace base {
namespace mac {
class BASE_EXPORT ScopedMachVM {
public:
explicit ScopedMachVM(vm_address_t address = 0, vm_size_t size = 0)
: address_(address), size_(size) {
DCHECK_EQ(address % PAGE_SIZE, 0u);
DCHECK_EQ(size % PAGE_SIZE, 0u);
}
~ScopedMachVM() {
if (size_) {
vm_deallocate(mach_task_self(), address_, size_);
}
}
// Resets the scoper to manage a new memory region. Both |address| and |size|
// must be page-aligned. If the new region is a smaller subset of the
// existing region (i.e. the new and old regions overlap), the non-
// overlapping part of the old region is deallocated.
void reset(vm_address_t address = 0, vm_size_t size = 0);
// Like reset() but does not DCHECK that |address| and |size| are page-
// aligned.
void reset_unaligned(vm_address_t address, vm_size_t size);
vm_address_t address() const {
return address_;
}
vm_size_t size() const {
return size_;
}
void swap(ScopedMachVM& that) {
std::swap(address_, that.address_);
std::swap(size_, that.size_);
}
void release() {
address_ = 0;
size_ = 0;
}
private:
vm_address_t address_;
vm_size_t size_;
DISALLOW_COPY_AND_ASSIGN(ScopedMachVM);
};
} // namespace mac
} // namespace base
#endif // BASE_MAC_SCOPED_MACH_VM_H_
| {
"pile_set_name": "Github"
} |
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std_unsigned.all;
entity main_tb is
end main_tb;
architecture structural of main_tb is
-- Clock
signal main_clk : std_logic;
-- Generate pause signal
signal main_wait_cnt : std_logic_vector(1 downto 0) := (others => '0');
signal main_wait : std_logic;
begin
--------------------------------------------------
-- Generate clock
--------------------------------------------------
-- Generate clock
main_clk_proc : process
begin
main_clk <= '1', '0' after 5 ns; -- 100 MHz
wait for 10 ns;
end process main_clk_proc;
--------------------------------------------------
-- Generate wait signal
--------------------------------------------------
main_wait_cnt_proc : process (main_clk)
begin
if rising_edge(main_clk) then
main_wait_cnt <= main_wait_cnt + 1;
end if;
end process main_wait_cnt_proc;
-- Check for wrap around of counter.
main_wait <= '0' when main_wait_cnt = 0 else '1';
--------------------------------------------------
-- Instantiate MAIN
--------------------------------------------------
main_inst : entity work.main
generic map (
G_ROM_INIT_FILE => "main/mem/rom.txt",
G_OVERLAY_BITS => 160
)
port map (
clk_i => main_clk,
wait_i => main_wait,
overlay_o => open
); -- main_inst
end architecture structural;
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 5321756dbfdb4a84ca01779c753d5935
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<topology xmlns="http://www.cisco.com/VIRL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="0.9" simulationEngine="OPENSTACK" xsi:schemaLocation="http://www.cisco.com/VIRL https://raw.github.com/CiscoVIRL/schema/v0.9/virl.xsd">
<node name="R1" type="SIMPLE" subtype="IOSv" location="57,131"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R1
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:1:1::1/128
ip address 150.1.1.1 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.13
encapsulation dot1q 13
ip address 155.1.13.1 255.255.255.0
ipv6 address 2001:155:1:13::1/64
!
interface GigabitEthernet0/1.100
encapsulation dot1q 100
ip address 169.254.100.1 255.255.255.0
ipv6 address 2001:169:254:100::1/64
!
interface GigabitEthernet0/1.146
encapsulation dot1q 146
ip address 155.1.146.1 255.255.255.0
ipv6 address 2001:155:1:146::1/64
!
crypto isakmp policy 10
encr aes
authentication pre-share
group 5
hash md5
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set ESP_AES_SHA esp-aes esp-sha-hmac
!
crypto ipsec profile DMVPN_PROFILE
set transform-set ESP_AES_SHA
!
interface Tunnel0
ip address 155.1.0.1 255.255.255.0
ip mtu 1400
ip nhrp authentication NHRPPASS
ip nhrp map 155.1.0.5 169.254.100.5
ip nhrp map multicast 169.254.100.5
ip nhrp network-id 1
ip nhrp holdtime 300
ip nhrp nhs 155.1.0.5
ip tcp adjust-mss 1360
tunnel source GigabitEthernet0/1.100
tunnel mode gre multipoint
tunnel key 150
tunnel protection ipsec profile DMVPN_PROFILE
no shutdown
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R2" type="SIMPLE" subtype="IOSv" location="58,197"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R2
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:2:2::2/128
ip address 150.1.2.2 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.23
encapsulation dot1q 23
ip address 155.1.23.2 255.255.255.0
ipv6 address 2001:155:1:23::2/64
!
interface GigabitEthernet0/1.100
encapsulation dot1q 100
ip address 169.254.100.2 255.255.255.0
ipv6 address 2001:169:254:100::2/64
!
crypto isakmp policy 10
encr aes
authentication pre-share
group 5
hash md5
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set ESP_AES_SHA esp-aes esp-sha-hmac
!
crypto ipsec profile DMVPN_PROFILE
set transform-set ESP_AES_SHA
!
interface Tunnel0
ip address 155.1.0.2 255.255.255.0
ip mtu 1400
ip nhrp authentication NHRPPASS
ip nhrp map 155.1.0.5 169.254.100.5
ip nhrp map multicast 169.254.100.5
ip nhrp network-id 1
ip nhrp holdtime 300
ip nhrp nhs 155.1.0.5
ip tcp adjust-mss 1360
tunnel source GigabitEthernet0/1.100
tunnel mode gre multipoint
tunnel key 150
tunnel protection ipsec profile DMVPN_PROFILE
no shutdown
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R3" type="SIMPLE" subtype="IOSv" location="59,270"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R3
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:3:3::3/128
ip address 150.1.3.3 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.13
encapsulation dot1q 13
ip address 155.1.13.3 255.255.255.0
ipv6 address 2001:155:1:13::3/64
!
interface GigabitEthernet0/1.23
encapsulation dot1q 23
ip address 155.1.23.3 255.255.255.0
ipv6 address 2001:155:1:23::3/64
!
interface GigabitEthernet0/1.37
encapsulation dot1q 37
ip address 155.1.37.3 255.255.255.0
ipv6 address 2001:155:1:37::3/64
!
interface GigabitEthernet0/1.100
encapsulation dot1q 100
ip address 169.254.100.3 255.255.255.0
ipv6 address 2001:169:254:100::3/64
!
crypto isakmp policy 10
encr aes
authentication pre-share
group 5
hash md5
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set ESP_AES_SHA esp-aes esp-sha-hmac
!
crypto ipsec profile DMVPN_PROFILE
set transform-set ESP_AES_SHA
!
interface Tunnel0
ip address 155.1.0.3 255.255.255.0
ip mtu 1400
ip nhrp authentication NHRPPASS
ip nhrp map 155.1.0.5 169.254.100.5
ip nhrp map multicast 169.254.100.5
ip nhrp network-id 1
ip nhrp holdtime 300
ip nhrp nhs 155.1.0.5
ip tcp adjust-mss 1360
tunnel source GigabitEthernet0/1.100
tunnel mode gre multipoint
tunnel key 150
tunnel protection ipsec profile DMVPN_PROFILE
no shutdown
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R4" type="SIMPLE" subtype="IOSv" location="58,345"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R4
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:4:4::4/128
ip address 150.1.4.4 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.45
encapsulation dot1q 45
ip address 155.1.45.4 255.255.255.0
ipv6 address 2001:155:1:45::4/64
!
interface GigabitEthernet0/1.100
encapsulation dot1q 100
ip address 169.254.100.4 255.255.255.0
ipv6 address 2001:169:254:100::4/64
!
interface GigabitEthernet0/1.146
encapsulation dot1q 146
ip address 155.1.146.4 255.255.255.0
ipv6 address 2001:155:1:146::4/64
!
crypto isakmp policy 10
encr aes
authentication pre-share
group 5
hash md5
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set ESP_AES_SHA esp-aes esp-sha-hmac
!
crypto ipsec profile DMVPN_PROFILE
set transform-set ESP_AES_SHA
!
interface Tunnel0
ip address 155.1.0.4 255.255.255.0
ip mtu 1400
ip nhrp authentication NHRPPASS
ip nhrp map 155.1.0.5 169.254.100.5
ip nhrp map multicast 169.254.100.5
ip nhrp network-id 1
ip nhrp holdtime 300
ip nhrp nhs 155.1.0.5
ip tcp adjust-mss 1360
tunnel source GigabitEthernet0/1.100
tunnel mode gre multipoint
tunnel key 150
tunnel protection ipsec profile DMVPN_PROFILE
no shutdown
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R5" type="SIMPLE" subtype="IOSv" location="47,417"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R5
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:5:5::5/128
ip address 150.1.5.5 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.5
encapsulation dot1q 5
ip address 155.1.5.5 255.255.255.0
ipv6 address 2001:155:1:5::5/64
!
interface GigabitEthernet0/1.45
encapsulation dot1q 45
ip address 155.1.45.5 255.255.255.0
ipv6 address 2001:155:1:45::5/64
!
interface GigabitEthernet0/1.58
encapsulation dot1q 58
ip address 155.1.58.5 255.255.255.0
ipv6 address 2001:155:1:58::5/64
!
interface GigabitEthernet0/1.100
encapsulation dot1q 100
ip address 169.254.100.5 255.255.255.0
ipv6 address 2001:169:254:100::5/64
!
crypto isakmp policy 10
encr aes
authentication pre-share
group 5
hash md5
!
crypto isakmp key cisco address 0.0.0.0
!
crypto ipsec transform-set ESP_AES_SHA esp-aes esp-sha-hmac
!
crypto ipsec profile DMVPN_PROFILE
set transform-set ESP_AES_SHA
!
interface Tunnel0
ip address 155.1.0.5 255.255.255.0
ip mtu 1400
ip nhrp authentication NHRPPASS
ip nhrp map multicast dynamic
ip nhrp network-id 1
ip tcp adjust-mss 1360
delay 1000
tunnel source GigabitEthernet0/1.100
tunnel mode gre multipoint
tunnel key 150
tunnel protection ipsec profile DMVPN_PROFILE
no shutdown
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R6" type="SIMPLE" subtype="IOSv" location="49,474"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R6
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:6:6::6/128
ip address 150.1.6.6 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.67
encapsulation dot1q 67
ip address 155.1.67.6 255.255.255.0
ipv6 address 2001:155:1:67::6/64
!
interface GigabitEthernet0/1.146
encapsulation dot1q 146
ip address 155.1.146.6 255.255.255.0
ipv6 address 2001:155:1:146::6/64
!
router eigrp 100
no auto-summary
network 155.1.0.0 0.0.255.255
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R7" type="SIMPLE" subtype="IOSv" location="43,552"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R7
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:7:7::7/128
ip address 150.1.7.7 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.7
encapsulation dot1q 7
ip address 155.1.7.7 255.255.255.0
ipv6 address 2001:155:1:7::7/64
!
interface GigabitEthernet0/1.37
encapsulation dot1q 37
ip address 155.1.37.7 255.255.255.0
ipv6 address 2001:155:1:37::7/64
!
interface GigabitEthernet0/1.67
encapsulation dot1q 67
ip address 155.1.67.7 255.255.255.0
ipv6 address 2001:155:1:67::7/64
!
interface GigabitEthernet0/1.79
encapsulation dot1q 79
ip address 155.1.79.7 255.255.255.0
ipv6 address 2001:155:1:79::7/64
!
router eigrp 100
no auto-summary
network 155.1.7.7 0.0.0.0
network 155.1.37.7 0.0.0.0
network 155.1.67.7 0.0.0.0
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R8" type="SIMPLE" subtype="IOSv" location="43,618"><extensions><entry key="config" type="String">!
version 15.2
!
enable
configure terminal
no service timestamps debug uptime
no service timestamps log uptime
!
hostname R8
!
no ip domain lookup
ip routing
ipv6 unicast-routing
!
cdp run
!
interface Loopback0
ipv6 address 2001:150:8:8::8/128
ip address 150.1.8.8 255.255.255.255
!
interface GigabitEthernet0/1
cdp enable
no shutdown
!
interface GigabitEthernet0/1.8
encapsulation dot1q 8
ip address 155.1.8.8 255.255.255.0
ipv6 address 2001:155:1:8::8/64
!
interface GigabitEthernet0/1.58
encapsulation dot1q 58
ip address 155.1.58.8 255.255.255.0
ipv6 address 2001:155:1:58::8/64
!
interface GigabitEthernet0/1.108
encapsulation dot1q 108
ip address 155.1.108.8 255.255.255.0
ipv6 address 2001:155:1:108::8/64
!
router eigrp 100
no auto-summary
network 155.1.8.8 0.0.0.0
network 155.1.58.8 0.0.0.0
!
line con 0
exec-timeout 0 0
logging synchronous
privilege level 15
no login
!
line vty 0 4
privilege level 15
no login
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R9" type="SIMPLE" subtype="IOSv" location="37,675"><extensions><entry key="config" type="String">!
version 15.2
!
enable
conf t
version 15.4
no service timestamps debug uptime
no service timestamps log uptime
no platform punt-keepalive disable-kernel-core
platform console serial
!
hostname R9
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
!
!
!
!
!
!
no ip domain lookup
!
!
!
ipv6 unicast-routing
!
!
!
!
!
!
!
subscriber templating
!
multilink bundle-name authenticated
!
!
license udi pid CSR1000V sn 9Y9VCZ8B841
license boot level premium
spanning-tree extend system-id
!
!
redundancy
mode none
!
!
!
!
!
cdp run
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
ip address 150.1.9.9 255.255.255.255
ipv6 address 2001:150:9:9::9/128
!
interface Loopback112
ip address 112.0.0.1 255.0.0.0
ipv6 address 2001:254:0:112::1/64
!
interface Loopback113
ip address 113.0.0.1 255.0.0.0
ipv6 address 2001:254:0:113::1/64
!
interface Loopback114
ip address 114.0.0.1 255.0.0.0
ipv6 address 2001:254:0:114::1/64
!
interface Loopback115
ip address 115.0.0.1 255.0.0.0
ipv6 address 2001:254:0:115::1/96
!
interface Loopback116
ip address 116.0.0.1 255.0.0.0
!
interface Loopback117
ip address 117.0.0.1 255.0.0.0
!
interface Loopback118
ip address 118.0.0.1 255.0.0.0
!
interface Loopback119
ip address 119.0.0.1 255.0.0.0
!
interface Loopback51001
ip address 51.0.0.1 255.255.0.0
!
interface Loopback51101
ip address 51.1.0.1 255.255.0.0
!
interface Loopback51201
ip address 51.2.0.1 255.255.0.0
!
interface Loopback51301
ip address 51.3.0.1 255.255.0.0
!
interface Loopback51401
ip address 51.4.0.1 255.255.0.0
!
interface Loopback51501
ip address 51.5.0.1 255.255.0.0
!
interface Loopback51601
ip address 51.6.0.1 255.255.0.0
!
interface Loopback51701
ip address 51.7.0.1 255.255.0.0
!
interface Loopback200000
ip address 200.0.0.1 255.255.255.0
!
interface Loopback200010
ip address 200.0.1.1 255.255.255.0
!
interface Loopback200020
ip address 200.0.2.1 255.255.255.0
!
interface Loopback200030
ip address 200.0.3.1 255.255.255.0
!
interface Loopback2121801
ip address 212.18.0.1 255.255.255.0
!
interface Loopback2121811
ip address 212.18.1.1 255.255.255.0
!
interface Loopback2121821
ip address 212.18.2.1 255.255.255.0
!
interface Loopback2121831
ip address 212.18.3.1 255.255.255.0
!
interface GigabitEthernet0/1
no ip address
negotiation auto
cdp enable
no shut
!
interface GigabitEthernet0/1.9
encapsulation dot1Q 9
ip address 155.1.9.9 255.255.255.0
ipv6 address 2001:155:1:9::9/64
!
interface GigabitEthernet0/1.79
encapsulation dot1Q 79
ip address 155.1.79.9 255.255.255.0
ipv6 address 2001:155:1:79::9/64
!
interface GigabitEthernet0/1.109
encapsulation dot1Q 109
ip address 155.1.109.9 255.255.255.0
ipv6 address 2001:155:1:109::9/64
!
interface GigabitEthernet2
no ip address
shutdown
negotiation auto
!
interface GigabitEthernet3
no ip address
shutdown
negotiation auto
!
router bgp 54
bgp log-neighbor-changes
neighbor 155.1.79.7 remote-as 100
neighbor 155.1.109.10 remote-as 54
!
address-family ipv4
network 112.0.0.0
network 113.0.0.0
network 114.0.0.0 route-map SET_COMMUNITY_54
network 115.0.0.0 route-map SET_COMMUNITY_54
network 116.0.0.0
network 117.0.0.0
network 118.0.0.0
network 119.0.0.0
neighbor 155.1.79.7 activate
neighbor 155.1.79.7 send-community both
neighbor 155.1.79.7 route-map BGP_IN in
neighbor 155.1.79.7 route-map BGP_OUT out
neighbor 155.1.109.10 activate
neighbor 155.1.109.10 next-hop-self
exit-address-family
!
!
!
ip forward-protocol nd
!
ip as-path access-list 1 permit ^$
no ip http server
no ip http secure-server
ip route 155.1.108.0 255.255.255.0 155.1.109.10
ip route 204.12.8.8 255.255.255.255 155.1.79.7
!
!
ip prefix-list BGP_PREPEND_1 seq 5 permit 112.0.0.0/8
ip prefix-list BGP_PREPEND_1 seq 10 permit 113.0.0.0/8
!
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
!
ip prefix-list DENY_DEFAULT seq 5 deny 0.0.0.0/0
ip prefix-list DENY_DEFAULT seq 10 permit 0.0.0.0/0 le 32
!
route-map BGP_IN deny 10
match ip address prefix-list DEFAULT
!
route-map BGP_IN permit 10000
!
route-map SET_COMMUNITY_54 permit 10
set community 54
!
route-map BGP_OUT permit 10
match ip address prefix-list BGP_PREPEND_1
set as-path prepend 50 60
!
route-map BGP_OUT permit 10000
match as-path 1
!
!
!
control-plane
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
stopbits 1
line aux 0
stopbits 1
line vty 0 4
privilege level 15
no login
!
!
end
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="R10" type="SIMPLE" subtype="IOSv" location="32,741"><extensions><entry key="config" type="String">!
version 15.2
!
enable
conf t
version 15.4
no service timestamps debug uptime
no service timestamps log uptime
no platform punt-keepalive disable-kernel-core
platform console serial
!
hostname R10
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
!
!
!
!
!
!
no ip domain lookup
!
!
!
ipv6 unicast-routing
!
!
!
!
!
!
!
subscriber templating
!
multilink bundle-name authenticated
!
!
license udi pid CSR1000V sn 9Y9VCZ8B841
license boot level premium
spanning-tree extend system-id
!
!
redundancy
mode none
!
!
!
!
!
cdp run
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
ip address 28.119.16.1 255.255.255.0
ipv6 address 2001:28:119:16::1/64
ipv6 address 2001:150:10:10::10/128
!
interface Loopback1
ip address 28.119.17.1 255.255.255.0
ipv6 address 2001:28:119:17::1/64
!
interface Loopback10
ip address 30.0.0.1 255.255.0.0
ipv6 address 2001:30::1/64
!
interface Loopback11
ip address 30.1.0.1 255.255.0.0
ipv6 address 2001:30:1::1/64
!
interface Loopback12
ip address 30.2.0.1 255.255.0.0
ipv6 address 2001:30:2::1/64
!
interface Loopback13
ip address 30.3.0.1 255.255.0.0
ipv6 address 2001:30:3::1/64
!
interface Loopback14
ip address 31.0.0.1 255.255.0.0
ipv6 address 2001:31::1/64
!
interface Loopback15
ip address 31.1.0.1 255.255.0.0
ipv6 address 2001:31:1::1/64
!
interface Loopback16
ip address 31.2.0.1 255.255.0.0
ipv6 address 2001:31:2::1/64
!
interface Loopback17
ip address 31.3.0.1 255.255.0.0
ipv6 address 2001:31:3::1/64
!
interface GigabitEthernet0/1
no ip address
negotiation auto
cdp enable
no shut
!
interface GigabitEthernet0/1.10
encapsulation dot1Q 10
ip address 155.1.10.10 255.255.255.0
ipv6 address 2001:155:1:10::10/64
!
interface GigabitEthernet0/1.108
encapsulation dot1Q 108
ip address 155.1.108.10 255.255.255.0
ipv6 address 2001:155:1:108::10/64
!
interface GigabitEthernet0/1.109
encapsulation dot1Q 109
ip address 155.1.109.10 255.255.255.0
ipv6 address 2001:155:1:109::10/64
!
interface GigabitEthernet2
no ip address
shutdown
negotiation auto
!
interface GigabitEthernet3
no ip address
shutdown
negotiation auto
!
router bgp 54
bgp log-neighbor-changes
neighbor 155.1.0.2 remote-as 100
neighbor 155.1.0.2 ebgp-multihop 255
neighbor 155.1.108.8 remote-as 100
neighbor 155.1.109.9 remote-as 54
!
address-family ipv4
network 28.119.16.0 mask 255.255.255.0
network 28.119.17.0 mask 255.255.255.0
neighbor 155.1.0.2 activate
neighbor 155.1.108.8 activate
neighbor 155.1.108.8 send-community
neighbor 155.1.108.8 route-map BGP_IN in
neighbor 155.1.108.8 route-map BGP_OUT out
neighbor 155.1.109.9 activate
neighbor 155.1.109.9 next-hop-self
exit-address-family
!
!
virtual-service csr_mgmt
!
ip forward-protocol nd
!
no ip http server
no ip http secure-server
ip route 155.1.0.0 255.255.0.0 155.1.108.8
ip route 155.1.79.0 255.255.255.0 155.1.109.9
!
!
ip prefix-list BGP_PREPEND_1 seq 5 permit 112.0.0.0/8
ip prefix-list BGP_PREPEND_1 seq 10 permit 113.0.0.0/8
!
ip prefix-list DEFAULT seq 5 permit 0.0.0.0/0
!
ip prefix-list DENY_DEFAULT seq 5 deny 0.0.0.0/0
ip prefix-list DENY_DEFAULT seq 10 permit 0.0.0.0/0 le 32
!
route-map BGP_IN deny 10
match ip address prefix-list DEFAULT
!
route-map BGP_IN permit 1000
!
route-map BGP_OUT permit 10
match ip address prefix-list BGP_PREPEND_1
set as-path prepend 50 60
!
route-map BGP_OUT permit 10000
!
!
!
control-plane
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
stopbits 1
line aux 0
stopbits 1
line vty 0 4
privilege level 15
no login
!
!
end
R10#
!
end
</entry></extensions>
<interface id="0" name="GigabitEthernet0/1"/>
</node>
<node name="SW1" type="SIMPLE" subtype="IOSvL2" location="346,347">
<interface id="0" name="GigabitEthernet0/1"/>
<interface id="1" name="GigabitEthernet0/2"/>
<interface id="2" name="GigabitEthernet0/3"/>
<interface id="3" name="GigabitEthernet1/0"/>
<interface id="4" name="GigabitEthernet1/1"/>
<interface id="5" name="GigabitEthernet1/2"/>
<interface id="6" name="GigabitEthernet1/3"/>
</node>
<node name="SW2" type="SIMPLE" subtype="IOSvL2" location="580,343">
<interface id="0" name="GigabitEthernet0/1"/>
<interface id="1" name="GigabitEthernet0/2"/>
<interface id="2" name="GigabitEthernet0/3"/>
<interface id="3" name="GigabitEthernet1/0"/>
<interface id="4" name="GigabitEthernet1/1"/>
<interface id="5" name="GigabitEthernet1/2"/>
</node>
<node name="SW3" type="SIMPLE" subtype="IOSvL2" location="339,520">
<interface id="0" name="GigabitEthernet0/1"/>
<interface id="1" name="GigabitEthernet0/2"/>
<interface id="2" name="GigabitEthernet0/3"/>
<interface id="3" name="GigabitEthernet1/0"/>
<interface id="4" name="GigabitEthernet1/1"/>
<interface id="5" name="GigabitEthernet1/2"/>
</node>
<node name="SW4" type="SIMPLE" subtype="IOSvL2" location="580,519">
<interface id="0" name="GigabitEthernet0/1"/>
<interface id="1" name="GigabitEthernet0/2"/>
<interface id="2" name="GigabitEthernet0/3"/>
<interface id="3" name="GigabitEthernet1/0"/>
<interface id="4" name="GigabitEthernet1/1"/>
<interface id="5" name="GigabitEthernet1/2"/>
</node>
<node name="unmanagedswitch-1" type="SIMPLE" subtype="Unmanaged Switch" location="185,485">
<interface id="0" name="link1"/>
<interface id="1" name="link2"/>
<interface id="2" name="link3"/>
<interface id="3" name="link4"/>
<interface id="4" name="link5"/>
<interface id="5" name="link6"/>
<interface id="6" name="link7"/>
<interface id="7" name="link8"/>
<interface id="8" name="link9"/>
<interface id="9" name="link10"/>
<interface id="10" name="link11"/>
</node>
<connection dst="/virl:topology/virl:node[15]/virl:interface[1]" src="/virl:topology/virl:node[1]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[2]" src="/virl:topology/virl:node[2]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[3]" src="/virl:topology/virl:node[3]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[4]" src="/virl:topology/virl:node[4]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[5]" src="/virl:topology/virl:node[5]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[6]" src="/virl:topology/virl:node[6]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[7]" src="/virl:topology/virl:node[7]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[8]" src="/virl:topology/virl:node[8]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[9]" src="/virl:topology/virl:node[9]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[10]" src="/virl:topology/virl:node[10]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[13]/virl:interface[1]" src="/virl:topology/virl:node[11]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[13]/virl:interface[2]" src="/virl:topology/virl:node[11]/virl:interface[2]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[1]" src="/virl:topology/virl:node[12]/virl:interface[1]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[2]" src="/virl:topology/virl:node[12]/virl:interface[2]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[3]" src="/virl:topology/virl:node[11]/virl:interface[3]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[4]" src="/virl:topology/virl:node[11]/virl:interface[4]"/>
<connection dst="/virl:topology/virl:node[12]/virl:interface[3]" src="/virl:topology/virl:node[13]/virl:interface[3]"/>
<connection dst="/virl:topology/virl:node[12]/virl:interface[4]" src="/virl:topology/virl:node[13]/virl:interface[4]"/>
<connection dst="/virl:topology/virl:node[12]/virl:interface[5]" src="/virl:topology/virl:node[11]/virl:interface[5]"/>
<connection dst="/virl:topology/virl:node[12]/virl:interface[6]" src="/virl:topology/virl:node[11]/virl:interface[6]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[5]" src="/virl:topology/virl:node[13]/virl:interface[5]"/>
<connection dst="/virl:topology/virl:node[14]/virl:interface[6]" src="/virl:topology/virl:node[13]/virl:interface[6]"/>
<connection dst="/virl:topology/virl:node[15]/virl:interface[11]" src="/virl:topology/virl:node[11]/virl:interface[7]"/>
</topology>
| {
"pile_set_name": "Github"
} |
// Styling
import React from 'react'
const smallBox = (
<div className="box box--small" style={{backgroundColor: 'lightblue'}}>
small lightblue box
</div>
)
const mediumBox = (
<div className="box box--medium" style={{backgroundColor: 'pink'}}>
medium pink box
</div>
)
const largeBox = (
<div className="box box--large" style={{backgroundColor: 'orange'}}>
large orange box
</div>
)
function Usage() {
return (
<div>
{smallBox}
{mediumBox}
{largeBox}
</div>
)
}
Usage.title = 'Styling'
export default Usage
| {
"pile_set_name": "Github"
} |
/****************************************************************
* *
* curvyCorners *
* ------------ *
* *
* This script generates rounded corners for your divs. *
* *
* Version 1.2.9 *
* Copyright (c) 2006 Cameron Cooke *
* By: Cameron Cooke and Tim Hutchison. *
* *
* *
* Website: http://www.curvycorners.net *
* Email: [email protected] *
* Forum: http://www.curvycorners.net/forum/ *
* *
* *
* This library is free software; you can redistribute *
* it and/or modify it under the terms of the GNU *
* Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will *
* be useful, but WITHOUT ANY WARRANTY; without even the *
* implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU Lesser General Public *
* License for more details. *
* *
* You should have received a copy of the GNU Lesser *
* General Public License along with this library; *
* Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
****************************************************************/
var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > -1; var isMoz = document.implementation && document.implementation.createDocument; var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false; function curvyCorners()
{ if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object."); if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name."); if(typeof(arguments[1]) == "string")
{ var startIndex = 0; var boxCol = getElementsByClass(arguments[1]);}
else
{ var startIndex = 1; var boxCol = arguments;}
var curvyCornersCol = new Array(); if(arguments[0].validTags)
var validElements = arguments[0].validTags; else
var validElements = ["div"]; for(var i = startIndex, j = boxCol.length; i < j; i++)
{ var currentTag = boxCol[i].tagName.toLowerCase(); if(inArray(validElements, currentTag) !== false)
{ curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);}
}
this.objects = curvyCornersCol; this.applyCornersToAll = function()
{ for(var x = 0, k = this.objects.length; x < k; x++)
{ this.objects[x].applyCorners();}
}
}
function curvyObject()
{ this.box = arguments[1]; this.settings = arguments[0]; this.topContainer = null; this.bottomContainer = null; this.masterCorners = new Array(); this.contentDIV = null; var boxHeight = get_style(this.box, "height", "height"); var boxWidth = get_style(this.box, "width", "width"); var borderWidth = get_style(this.box, "borderTopWidth", "border-top-width"); var borderColour = get_style(this.box, "borderTopColor", "border-top-color"); var boxColour = get_style(this.box, "backgroundColor", "background-color"); var backgroundImage = get_style(this.box, "backgroundImage", "background-image"); var boxPosition = get_style(this.box, "position", "position"); var boxPadding = get_style(this.box, "paddingTop", "padding-top"); this.boxHeight = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight)); this.boxWidth = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth)); this.borderWidth = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0)); this.boxColour = format_colour(boxColour); this.boxPadding = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0)); this.borderColour = format_colour(borderColour); this.borderString = this.borderWidth + "px" + " solid " + this.borderColour; this.backgroundImage = ((backgroundImage != "none")? backgroundImage : ""); this.boxContent = this.box.innerHTML; if(boxPosition != "absolute") this.box.style.position = "relative"; this.box.style.padding = "0px"; if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%"; if(this.settings.autoPad == true && this.boxPadding > 0)
this.box.innerHTML = ""; this.applyCorners = function()
{ for(var t = 0; t < 2; t++)
{ switch(t)
{ case 0:
if(this.settings.tl || this.settings.tr)
{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0); newMainContainer.style.height = topMaxRadius + "px"; newMainContainer.style.top = 0 - topMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.topContainer = this.box.appendChild(newMainContainer);}
break; case 1:
if(this.settings.bl || this.settings.br)
{ var newMainContainer = document.createElement("DIV"); newMainContainer.style.width = "100%"; newMainContainer.style.fontSize = "1px"; newMainContainer.style.overflow = "hidden"; newMainContainer.style.position = "absolute"; newMainContainer.style.paddingLeft = this.borderWidth + "px"; newMainContainer.style.paddingRight = this.borderWidth + "px"; var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0); newMainContainer.style.height = botMaxRadius + "px"; newMainContainer.style.bottom = 0 - botMaxRadius + "px"; newMainContainer.style.left = 0 - this.borderWidth + "px"; this.bottomContainer = this.box.appendChild(newMainContainer);}
break;}
}
if(this.topContainer) this.box.style.borderTopWidth = "0px"; if(this.bottomContainer) this.box.style.borderBottomWidth = "0px"; var corners = ["tr", "tl", "br", "bl"]; for(var i in corners)
{ if(i > -1 < 4)
{ var cc = corners[i]; if(!this.settings[cc])
{ if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null))
{ var newCorner = document.createElement("DIV"); newCorner.style.position = "relative"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; if(this.backgroundImage == "")
newCorner.style.backgroundColor = this.boxColour; else
newCorner.style.backgroundImage = this.backgroundImage; switch(cc)
{ case "tl":
newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.left = -this.borderWidth + "px"; break; case "tr":
newCorner.style.height = topMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.tl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderTop = this.borderString; newCorner.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; newCorner.style.left = this.borderWidth + "px"; break; case "bl":
newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginRight = this.settings.br.radius - (this.borderWidth*2) + "px"; newCorner.style.borderLeft = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = -this.borderWidth + "px"; newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break; case "br":
newCorner.style.height = botMaxRadius - this.borderWidth + "px"; newCorner.style.marginLeft = this.settings.bl.radius - (this.borderWidth*2) + "px"; newCorner.style.borderRight = this.borderString; newCorner.style.borderBottom = this.borderString; newCorner.style.left = this.borderWidth + "px"
newCorner.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px"; break;}
}
}
else
{ if(this.masterCorners[this.settings[cc].radius])
{ var newCorner = this.masterCorners[this.settings[cc].radius].cloneNode(true);}
else
{ var newCorner = document.createElement("DIV"); newCorner.style.height = this.settings[cc].radius + "px"; newCorner.style.width = this.settings[cc].radius + "px"; newCorner.style.position = "absolute"; newCorner.style.fontSize = "1px"; newCorner.style.overflow = "hidden"; var borderRadius = parseInt(this.settings[cc].radius - this.borderWidth); for(var intx = 0, j = this.settings[cc].radius; intx < j; intx++)
{ if((intx +1) >= borderRadius)
var y1 = -1; else
var y1 = (Math.floor(Math.sqrt(Math.pow(borderRadius, 2) - Math.pow((intx+1), 2))) - 1); if(borderRadius != j)
{ if((intx) >= borderRadius)
var y2 = -1; else
var y2 = Math.ceil(Math.sqrt(Math.pow(borderRadius,2) - Math.pow(intx, 2))); if((intx+1) >= j)
var y3 = -1; else
var y3 = (Math.floor(Math.sqrt(Math.pow(j ,2) - Math.pow((intx+1), 2))) - 1);}
if((intx) >= j)
var y4 = -1; else
var y4 = Math.ceil(Math.sqrt(Math.pow(j ,2) - Math.pow(intx, 2))); if(y1 > -1) this.drawPixel(intx, 0, this.boxColour, 100, (y1+1), newCorner, -1, this.settings[cc].radius); if(borderRadius != j)
{ for(var inty = (y1 + 1); inty < y2; inty++)
{ if(this.settings.antiAlias)
{ if(this.backgroundImage != "")
{ var borderFract = (pixelFraction(intx, inty, borderRadius) * 100); if(borderFract < 30)
{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, 0, this.settings[cc].radius);}
else
{ this.drawPixel(intx, inty, this.borderColour, 100, 1, newCorner, -1, this.settings[cc].radius);}
}
else
{ var pixelcolour = BlendColour(this.boxColour, this.borderColour, pixelFraction(intx, inty, borderRadius)); this.drawPixel(intx, inty, pixelcolour, 100, 1, newCorner, 0, this.settings[cc].radius, cc);}
}
}
if(this.settings.antiAlias)
{ if(y3 >= y2)
{ if (y2 == -1) y2 = 0; this.drawPixel(intx, y2, this.borderColour, 100, (y3 - y2 + 1), newCorner, 0, 0);}
}
else
{ if(y3 >= y1)
{ this.drawPixel(intx, (y1 + 1), this.borderColour, 100, (y3 - y1), newCorner, 0, 0);}
}
var outsideColour = this.borderColour;}
else
{ var outsideColour = this.boxColour; var y3 = y1;}
if(this.settings.antiAlias)
{ for(var inty = (y3 + 1); inty < y4; inty++)
{ this.drawPixel(intx, inty, outsideColour, (pixelFraction(intx, inty , j) * 100), 1, newCorner, ((this.borderWidth > 0)? 0 : -1), this.settings[cc].radius);}
}
}
this.masterCorners[this.settings[cc].radius] = newCorner.cloneNode(true);}
if(cc != "br")
{ for(var t = 0, k = newCorner.childNodes.length; t < k; t++)
{ var pixelBar = newCorner.childNodes[t]; var pixelBarTop = parseInt(pixelBar.style.top.substring(0, pixelBar.style.top.indexOf("px"))); var pixelBarLeft = parseInt(pixelBar.style.left.substring(0, pixelBar.style.left.indexOf("px"))); var pixelBarHeight = parseInt(pixelBar.style.height.substring(0, pixelBar.style.height.indexOf("px"))); if(cc == "tl" || cc == "bl"){ pixelBar.style.left = this.settings[cc].radius -pixelBarLeft -1 + "px";}
if(cc == "tr" || cc == "tl"){ pixelBar.style.top = this.settings[cc].radius -pixelBarHeight -pixelBarTop + "px";}
switch(cc)
{ case "tr":
pixelBar.style.backgroundPosition = "-" + Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "tl":
pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs(this.settings[cc].radius -pixelBarHeight -pixelBarTop - this.borderWidth) + "px"; break; case "bl":
pixelBar.style.backgroundPosition = "-" + Math.abs((this.settings[cc].radius -pixelBarLeft -1) - this.borderWidth) + "px -" + Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) -this.borderWidth) + "px"; break;}
}
}
}
if(newCorner)
{ switch(cc)
{ case "tl":
if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "tr":
if(newCorner.style.position == "absolute") newCorner.style.top = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.topContainer) this.topContainer.appendChild(newCorner); break; case "bl":
if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.left = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break; case "br":
if(newCorner.style.position == "absolute") newCorner.style.bottom = "0px"; if(newCorner.style.position == "absolute") newCorner.style.right = "0px"; if(this.bottomContainer) this.bottomContainer.appendChild(newCorner); break;}
}
}
}
var radiusDiff = new Array(); radiusDiff["t"] = Math.abs(this.settings.tl.radius - this.settings.tr.radius)
radiusDiff["b"] = Math.abs(this.settings.bl.radius - this.settings.br.radius); for(z in radiusDiff)
{ if(z == "t" || z == "b")
{ if(radiusDiff[z])
{ var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius)? z +"l" : z +"r"); var newFiller = document.createElement("DIV"); newFiller.style.height = radiusDiff[z] + "px"; newFiller.style.width = this.settings[smallerCornerType].radius+ "px"
newFiller.style.position = "absolute"; newFiller.style.fontSize = "1px"; newFiller.style.overflow = "hidden"; newFiller.style.backgroundColor = this.boxColour; switch(smallerCornerType)
{ case "tl":
newFiller.style.bottom = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.topContainer.appendChild(newFiller); break; case "tr":
newFiller.style.bottom = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.topContainer.appendChild(newFiller); break; case "bl":
newFiller.style.top = "0px"; newFiller.style.left = "0px"; newFiller.style.borderLeft = this.borderString; this.bottomContainer.appendChild(newFiller); break; case "br":
newFiller.style.top = "0px"; newFiller.style.right = "0px"; newFiller.style.borderRight = this.borderString; this.bottomContainer.appendChild(newFiller); break;}
}
var newFillerBar = document.createElement("DIV"); newFillerBar.style.position = "relative"; newFillerBar.style.fontSize = "1px"; newFillerBar.style.overflow = "hidden"; newFillerBar.style.backgroundColor = this.boxColour; newFillerBar.style.backgroundImage = this.backgroundImage; switch(z)
{ case "t":
if(this.topContainer)
{ if(this.settings.tl.radius && this.settings.tr.radius)
{ newFillerBar.style.height = topMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.tl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.tr.radius - this.borderWidth + "px"; newFillerBar.style.borderTop = this.borderString; if(this.backgroundImage != "")
newFillerBar.style.backgroundPosition = "-" + (topMaxRadius + this.borderWidth) + "px 0px"; this.topContainer.appendChild(newFillerBar);}
this.box.style.backgroundPosition = "0px -" + (topMaxRadius - this.borderWidth) + "px";}
break; case "b":
if(this.bottomContainer)
{ if(this.settings.bl.radius && this.settings.br.radius)
{ newFillerBar.style.height = botMaxRadius - this.borderWidth + "px"; newFillerBar.style.marginLeft = this.settings.bl.radius - this.borderWidth + "px"; newFillerBar.style.marginRight = this.settings.br.radius - this.borderWidth + "px"; newFillerBar.style.borderBottom = this.borderString; if(this.backgroundImage != "")
newFillerBar.style.backgroundPosition = "-" + (botMaxRadius + this.borderWidth) + "px -" + (this.boxHeight + (topMaxRadius + this.borderWidth)) + "px"; this.bottomContainer.appendChild(newFillerBar);}
}
break;}
}
}
if(this.settings.autoPad == true && this.boxPadding > 0)
{ var contentContainer = document.createElement("DIV"); contentContainer.style.position = "relative"; contentContainer.innerHTML = this.boxContent; contentContainer.className = "autoPadDiv"; var topPadding = Math.abs(topMaxRadius - this.boxPadding); var botPadding = Math.abs(botMaxRadius - this.boxPadding); if(topMaxRadius < this.boxPadding)
contentContainer.style.paddingTop = topPadding + "px"; if(botMaxRadius < this.boxPadding)
contentContainer.style.paddingBottom = botMaxRadius + "px"; contentContainer.style.paddingLeft = this.boxPadding + "px"; contentContainer.style.paddingRight = this.boxPadding + "px"; this.contentDIV = this.box.appendChild(contentContainer);}
}
this.drawPixel = function(intx, inty, colour, transAmount, height, newCorner, image, cornerRadius)
{ var pixel = document.createElement("DIV"); pixel.style.height = height + "px"; pixel.style.width = "1px"; pixel.style.position = "absolute"; pixel.style.fontSize = "1px"; pixel.style.overflow = "hidden"; var topMaxRadius = Math.max(this.settings["tr"].radius, this.settings["tl"].radius); if(image == -1 && this.backgroundImage != "")
{ pixel.style.backgroundImage = this.backgroundImage; pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + topMaxRadius + inty) -this.borderWidth) + "px";}
else
{ pixel.style.backgroundColor = colour;}
if (transAmount != 100)
setOpacity(pixel, transAmount); pixel.style.top = inty + "px"; pixel.style.left = intx + "px"; newCorner.appendChild(pixel);}
}
function insertAfter(parent, node, referenceNode)
{ parent.insertBefore(node, referenceNode.nextSibling);}
function BlendColour(Col1, Col2, Col1Fraction)
{ var red1 = parseInt(Col1.substr(1,2),16); var green1 = parseInt(Col1.substr(3,2),16); var blue1 = parseInt(Col1.substr(5,2),16); var red2 = parseInt(Col2.substr(1,2),16); var green2 = parseInt(Col2.substr(3,2),16); var blue2 = parseInt(Col2.substr(5,2),16); if(Col1Fraction > 1 || Col1Fraction < 0) Col1Fraction = 1; var endRed = Math.round((red1 * Col1Fraction) + (red2 * (1 - Col1Fraction))); if(endRed > 255) endRed = 255; if(endRed < 0) endRed = 0; var endGreen = Math.round((green1 * Col1Fraction) + (green2 * (1 - Col1Fraction))); if(endGreen > 255) endGreen = 255; if(endGreen < 0) endGreen = 0; var endBlue = Math.round((blue1 * Col1Fraction) + (blue2 * (1 - Col1Fraction))); if(endBlue > 255) endBlue = 255; if(endBlue < 0) endBlue = 0; return "#" + IntToHex(endRed)+ IntToHex(endGreen)+ IntToHex(endBlue);}
function IntToHex(strNum)
{ base = strNum / 16; rem = strNum % 16; base = base - (rem / 16); baseS = MakeHex(base); remS = MakeHex(rem); return baseS + '' + remS;}
function MakeHex(x)
{ if((x >= 0) && (x <= 9))
{ return x;}
else
{ switch(x)
{ case 10: return "A"; case 11: return "B"; case 12: return "C"; case 13: return "D"; case 14: return "E"; case 15: return "F";}
}
}
function pixelFraction(x, y, r)
{ var pixelfraction = 0; var xvalues = new Array(1); var yvalues = new Array(1); var point = 0; var whatsides = ""; var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x,2))); if ((intersect >= y) && (intersect < (y+1)))
{ whatsides = "Left"; xvalues[point] = 0; yvalues[point] = intersect - y; point = point + 1;}
var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y+1,2))); if ((intersect >= x) && (intersect < (x+1)))
{ whatsides = whatsides + "Top"; xvalues[point] = intersect - x; yvalues[point] = 1; point = point + 1;}
var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(x+1,2))); if ((intersect >= y) && (intersect < (y+1)))
{ whatsides = whatsides + "Right"; xvalues[point] = 1; yvalues[point] = intersect - y; point = point + 1;}
var intersect = Math.sqrt((Math.pow(r,2) - Math.pow(y,2))); if ((intersect >= x) && (intersect < (x+1)))
{ whatsides = whatsides + "Bottom"; xvalues[point] = intersect - x; yvalues[point] = 0;}
switch (whatsides)
{ case "LeftRight":
pixelfraction = Math.min(yvalues[0],yvalues[1]) + ((Math.max(yvalues[0],yvalues[1]) - Math.min(yvalues[0],yvalues[1]))/2); break; case "TopRight":
pixelfraction = 1-(((1-xvalues[0])*(1-yvalues[1]))/2); break; case "TopBottom":
pixelfraction = Math.min(xvalues[0],xvalues[1]) + ((Math.max(xvalues[0],xvalues[1]) - Math.min(xvalues[0],xvalues[1]))/2); break; case "LeftBottom":
pixelfraction = (yvalues[0]*xvalues[1])/2; break; default:
pixelfraction = 1;}
return pixelfraction;}
function rgb2Hex(rgbColour)
{ try{ var rgbArray = rgb2Array(rgbColour); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); var hexColour = "#" + IntToHex(red) + IntToHex(green) + IntToHex(blue);}
catch(e){ alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");}
return hexColour;}
function rgb2Array(rgbColour)
{ var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")")); var rgbArray = rgbValues.split(", "); return rgbArray;}
function setOpacity(obj, opacity)
{ opacity = (opacity == 100)?99.999:opacity; if(isSafari && obj.tagName != "IFRAME")
{ var rgbArray = rgb2Array(obj.style.backgroundColor); var red = parseInt(rgbArray[0]); var green = parseInt(rgbArray[1]); var blue = parseInt(rgbArray[2]); obj.style.backgroundColor = "rgba(" + red + ", " + green + ", " + blue + ", " + opacity/100 + ")";}
else if(typeof(obj.style.opacity) != "undefined")
{ obj.style.opacity = opacity/100;}
else if(typeof(obj.style.MozOpacity) != "undefined")
{ obj.style.MozOpacity = opacity/100;}
else if(typeof(obj.style.filter) != "undefined")
{ obj.style.filter = "alpha(opacity:" + opacity + ")";}
else if(typeof(obj.style.KHTMLOpacity) != "undefined")
{ obj.style.KHTMLOpacity = opacity/100;}
}
function inArray(array, value)
{ for(var i = 0; i < array.length; i++){ if (array[i] === value) return i;}
return false;}
function inArrayKey(array, value)
{ for(key in array){ if(key === value) return true;}
return false;}
function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true;}
else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r;}
else { elm['on' + evType] = fn;}
}
function removeEvent(obj, evType, fn, useCapture){ if (obj.removeEventListener){ obj.removeEventListener(evType, fn, useCapture); return true;} else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed");}
}
function format_colour(colour)
{ var returnColour = "#ffffff"; if(colour != "" && colour != "transparent")
{ if(colour.substr(0, 3) == "rgb")
{ returnColour = rgb2Hex(colour);}
else if(colour.length == 4)
{ returnColour = "#" + colour.substring(1, 2) + colour.substring(1, 2) + colour.substring(2, 3) + colour.substring(2, 3) + colour.substring(3, 4) + colour.substring(3, 4);}
else
{ returnColour = colour;}
}
return returnColour;}
function get_style(obj, property, propertyNS)
{ try
{ if(obj.currentStyle)
{ var returnVal = eval("obj.currentStyle." + property);}
else
{ if(isSafari && obj.style.display == "none")
{ obj.style.display = ""; var wasHidden = true;}
var returnVal = document.defaultView.getComputedStyle(obj, '').getPropertyValue(propertyNS); if(isSafari && wasHidden)
{ obj.style.display = "none";}
}
}
catch(e)
{ }
return returnVal;}
function getElementsByClass(searchClass, node, tag)
{ var classElements = new Array(); if(node == null)
node = document; if(tag == null)
tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)"); for (i = 0, j = 0; i < elsLen; i++)
{ if(pattern.test(els[i].className))
{ classElements[j] = els[i]; j++;}
}
return classElements;}
function newCurvyError(errorMessage)
{ return new Error("curvyCorners Error:\n" + errorMessage)
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2016, Salesforce.com, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 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 Salesforce.com 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.
*/
package com.salesforce.dva.argus.sdk.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.Objects;
/**
* The base entity object.
*
* @author Tom Valine ([email protected])
*/
@SuppressWarnings("serial")
@JsonIgnoreProperties(ignoreUnknown = true)
abstract class Entity implements Serializable {
//~ Instance fields ******************************************************************************************************************************
private BigInteger id;
private BigInteger createdById;
private Date createdDate;
private BigInteger modifiedById;
private Date modifiedDate;
//~ Methods **************************************************************************************************************************************
/**
* Returns the entity ID.
*
* @return The entity ID.
*/
public BigInteger getId() {
return id;
}
/**
* Specifies the entity ID.
*
* @param id The entity ID.
*/
public void setId(BigInteger id) {
this.id = id;
}
/**
* Returns the created date.
*
* @return The created date.
*/
public Date getCreatedDate() {
return createdDate;
}
/**
* Specifies the created date.
*
* @param createdDate The created date.
*/
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
/**
* Returns the ID of the creator.
*
* @return The ID of the creator.
*/
public BigInteger getCreatedById() {
return createdById;
}
/**
* Specifies the ID of the creator.
*
* @param createdById The ID of the creator.
*/
public void setCreatedById(BigInteger createdById) {
this.createdById = createdById;
}
/**
* Returns the ID of the last person who modified the entity.
*
* @return The ID of the last person who modified the entity.
*/
public BigInteger getModifiedById() {
return modifiedById;
}
/**
* Specifies the ID of the person who most recently modified the entity.
*
* @param modifiedById The ID of the person who most recently modified the entity.
*/
public void setModifiedById(BigInteger modifiedById) {
this.modifiedById = modifiedById;
}
/**
* Returns the modified on date.
*
* @return The modified on date.
*/
public Date getModifiedDate() {
return modifiedDate;
}
/**
* Specifies the modified on date.
*
* @param modifiedDate The modified on date.
*/
public void setModifiedDate(Date modifiedDate) {
this.modifiedDate = modifiedDate;
}
@Override
public int hashCode() {
int hash = 5;
hash = 61 * hash + Objects.hashCode(this.id);
hash = 61 * hash + Objects.hashCode(this.createdById);
hash = 61 * hash + Objects.hashCode(this.createdDate);
hash = 61 * hash + Objects.hashCode(this.modifiedById);
hash = 61 * hash + Objects.hashCode(this.modifiedDate);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Entity other = (Entity) obj;
if (!Objects.equals(this.id, other.id)) {
return false;
}
if (!Objects.equals(this.createdById, other.createdById)) {
return false;
}
if (!Objects.equals(this.createdDate, other.createdDate)) {
return false;
}
if (!Objects.equals(this.modifiedById, other.modifiedById)) {
return false;
}
if (!Objects.equals(this.modifiedDate, other.modifiedDate)) {
return false;
}
return true;
}
}
/* Copyright (c) 2016, Salesforce.com, Inc. All rights reserved. */
| {
"pile_set_name": "Github"
} |
๏ปฟ<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration> | {
"pile_set_name": "Github"
} |
๏ปฟ// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Drawing;
using System.IO;
namespace ICSharpCode.SharpDevelop.Editor
{
/// <summary>
/// Description of TextNavigationPoint.
/// </summary>
public class TextNavigationPoint : DefaultNavigationPoint
{
const int THREASHOLD = 5;
#region constructor
public TextNavigationPoint() : this(String.Empty, 0, 0) {}
public TextNavigationPoint(string fileName) : this(fileName, 0, 0) {}
public TextNavigationPoint(string fileName, int lineNumber, int column) : this(fileName, lineNumber, column, String.Empty) {}
public TextNavigationPoint(string fileName, int lineNumber, int column, string content) : base(fileName, new Point(column, lineNumber))
{
if (String.IsNullOrEmpty(content)) {
this.content = String.Empty;
return;
}
this.content = content.Trim();
}
#endregion
// TODO: Navigation - eventually, we'll store a reference to the document
// itself so we can track filename changes, inserts (that affect
// line numbers), and dynamically retrieve the text at this.lineNumber
//
// what happens to the doc reference when the document is closed?
//
string content;
public int LineNumber {
get {return ((Point)this.NavigationData).Y;}
}
public int Column {
get {return ((Point)this.NavigationData).X;}
}
public override void JumpTo()
{
FileService.JumpToFilePosition(this.FileName,
this.LineNumber,
this.Column);
}
public override void ContentChanging(object sender, EventArgs e)
{
// TODO: Navigation - finish ContentChanging
// if (e is DocumentEventArgs) {
// DocumentEventArgs de = (DocumentEventArgs)e;
// if (this.LineNumber >=
// }
}
#region IComparable
public override int CompareTo(object obj)
{
int result = base.CompareTo(obj);
if (0!=result) {
return result;
}
TextNavigationPoint b = obj as TextNavigationPoint;
if (this.LineNumber==b.LineNumber) {
return 0;
} else if (this.LineNumber>b.LineNumber) {
return 1;
} else {
return -1;
}
}
#endregion
#region Equality
public override bool Equals(object obj)
{
TextNavigationPoint b = obj as TextNavigationPoint;
if (b==null) return false;
return this.FileName.Equals(b.FileName)
&& (Math.Abs(this.LineNumber - b.LineNumber)<=THREASHOLD);
}
public override int GetHashCode()
{
return this.FileName.GetHashCode() ^ this.LineNumber.GetHashCode();
}
#endregion
public override string Description {
get {
return String.Format(System.Globalization.CultureInfo.CurrentCulture,
"{0}: {1}",
this.LineNumber,
this.content);
}
}
public override string FullDescription {
get {
return String.Format(System.Globalization.CultureInfo.CurrentCulture,
"{0} - {1}",
Path.GetFileName(this.FileName),
this.Description);
}
}
}
}
| {
"pile_set_name": "Github"
} |
var convert = require('./convert'),
func = convert('mixin', require('../mixin'));
func.placeholder = require('./placeholder');
module.exports = func;
| {
"pile_set_name": "Github"
} |
#!/bin/bash
{{/*
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.
*/}}
set -ex
export HOME=/tmp
cd /tmp/images
{{ range .Values.bootstrap.structured.images }}
openstack image show {{ .name | quote }} || \
{ curl --fail -sSL -O {{ .source_url }}{{ .image_file }}; \
openstack image create {{ .name | quote }} \
{{ if .id -}} --id {{ .id }} {{ end -}} \
--min-disk {{ .min_disk }} \
--disk-format {{ .image_type }} \
--file {{ .image_file }} \
{{ if .properties -}} {{ range $key, $value := .properties }}--property {{$key}}={{$value}} {{ end }}{{ end -}} \
--container-format {{ .container_format | quote }} \
{{ if .private -}}
--private
{{- else -}}
--public
{{- end -}}; }
{{ end }}
{{ .Values.bootstrap.script | default "echo 'Not Enabled'" }}
| {
"pile_set_name": "Github"
} |
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/
#import "POPPropertyAnimationInternal.h"
@implementation POPPropertyAnimation
#pragma mark - Lifecycle
#undef __state
#define __state ((POPPropertyAnimationState *)_state)
- (void)_initState
{
_state = new POPPropertyAnimationState(self);
}
#pragma mark - Properties
DEFINE_RW_FLAG(POPPropertyAnimationState, additive, isAdditive, setAdditive:);
DEFINE_RW_PROPERTY(POPPropertyAnimationState, roundingFactor, setRoundingFactor:, CGFloat);
DEFINE_RW_PROPERTY(POPPropertyAnimationState, clampMode, setClampMode:, NSUInteger);
DEFINE_RW_PROPERTY_OBJ(POPPropertyAnimationState, property, setProperty:, POPAnimatableProperty*, ((POPPropertyAnimationState*)_state)->updatedDynamicsThreshold(););
DEFINE_RW_PROPERTY_OBJ_COPY(POPPropertyAnimationState, progressMarkers, setProgressMarkers:, NSArray*, ((POPPropertyAnimationState*)_state)->updatedProgressMarkers(););
- (id)fromValue
{
return POPBox(__state->fromVec, __state->valueType);
}
- (void)setFromValue:(id)aValue
{
POPPropertyAnimationState *s = __state;
VectorRef vec = POPUnbox(aValue, s->valueType, s->valueCount, YES);
if (!vec_equal(vec, s->fromVec)) {
s->fromVec = vec;
if (s->tracing) {
[s->tracer updateFromValue:aValue];
}
}
}
- (id)toValue
{
return POPBox(__state->toVec, __state->valueType);
}
- (void)setToValue:(id)aValue
{
POPPropertyAnimationState *s = __state;
VectorRef vec = POPUnbox(aValue, s->valueType, s->valueCount, YES);
if (!vec_equal(vec, s->toVec)) {
s->toVec = vec;
// invalidate to dependent state
s->didReachToValue = false;
s->distanceVec = NULL;
if (s->tracing) {
[s->tracer updateToValue:aValue];
}
// automatically unpause active animations
if (s->active && s->paused) {
s->setPaused(false);
}
}
}
- (id)currentValue
{
return POPBox(__state->currentValue(), __state->valueType);
}
#pragma mark - Utility
- (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug
{
[s appendFormat:@"; from = %@; to = %@", describe(__state->fromVec), describe(__state->toVec)];
if (_state->active)
[s appendFormat:@"; currentValue = %@", describe(__state->currentValue())];
if (__state->velocityVec && 0 != __state->velocityVec->norm())
[s appendFormat:@"; velocity = %@", describe(__state->velocityVec)];
if (!self.removedOnCompletion)
[s appendFormat:@"; removedOnCompletion = %@", POPStringFromBOOL(self.removedOnCompletion)];
if (__state->progressMarkers)
[s appendFormat:@"; progressMarkers = [%@]", [__state->progressMarkers componentsJoinedByString:@", "]];
if (_state->active)
[s appendFormat:@"; progress = %f", __state->progress];
}
@end
| {
"pile_set_name": "Github"
} |
// SPDX-License-Identifier: GPL-2.0-only
/*
* Clock driver for the ARM Integrator/IM-PD1 board
* Copyright (C) 2012-2013 Linus Walleij
*/
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/platform_data/clk-integrator.h>
#include "icst.h"
#include "clk-icst.h"
#define IMPD1_OSC1 0x00
#define IMPD1_OSC2 0x04
#define IMPD1_LOCK 0x08
struct impd1_clk {
char *pclkname;
struct clk *pclk;
char *vco1name;
struct clk *vco1clk;
char *vco2name;
struct clk *vco2clk;
struct clk *mmciclk;
char *uartname;
struct clk *uartclk;
char *spiname;
struct clk *spiclk;
char *scname;
struct clk *scclk;
struct clk_lookup *clks[15];
};
/* One entry for each connected IM-PD1 LM */
static struct impd1_clk impd1_clks[4];
/*
* There are two VCO's on the IM-PD1
*/
static const struct icst_params impd1_vco1_params = {
.ref = 24000000, /* 24 MHz */
.vco_max = ICST525_VCO_MAX_3V,
.vco_min = ICST525_VCO_MIN,
.vd_min = 12,
.vd_max = 519,
.rd_min = 3,
.rd_max = 120,
.s2div = icst525_s2div,
.idx2s = icst525_idx2s,
};
static const struct clk_icst_desc impd1_icst1_desc = {
.params = &impd1_vco1_params,
.vco_offset = IMPD1_OSC1,
.lock_offset = IMPD1_LOCK,
};
static const struct icst_params impd1_vco2_params = {
.ref = 24000000, /* 24 MHz */
.vco_max = ICST525_VCO_MAX_3V,
.vco_min = ICST525_VCO_MIN,
.vd_min = 12,
.vd_max = 519,
.rd_min = 3,
.rd_max = 120,
.s2div = icst525_s2div,
.idx2s = icst525_idx2s,
};
static const struct clk_icst_desc impd1_icst2_desc = {
.params = &impd1_vco2_params,
.vco_offset = IMPD1_OSC2,
.lock_offset = IMPD1_LOCK,
};
/**
* integrator_impd1_clk_init() - set up the integrator clock tree
* @base: base address of the logic module (LM)
* @id: the ID of this LM
*/
void integrator_impd1_clk_init(void __iomem *base, unsigned int id)
{
struct impd1_clk *imc;
struct clk *clk;
struct clk *pclk;
int i;
if (id > 3) {
pr_crit("no more than 4 LMs can be attached\n");
return;
}
imc = &impd1_clks[id];
/* Register the fixed rate PCLK */
imc->pclkname = kasprintf(GFP_KERNEL, "lm%x-pclk", id);
pclk = clk_register_fixed_rate(NULL, imc->pclkname, NULL, 0, 0);
imc->pclk = pclk;
imc->vco1name = kasprintf(GFP_KERNEL, "lm%x-vco1", id);
clk = icst_clk_register(NULL, &impd1_icst1_desc, imc->vco1name, NULL,
base);
imc->vco1clk = clk;
imc->clks[0] = clkdev_alloc(pclk, "apb_pclk", "lm%x:01000", id);
imc->clks[1] = clkdev_alloc(clk, NULL, "lm%x:01000", id);
/* VCO2 is also called "CLK2" */
imc->vco2name = kasprintf(GFP_KERNEL, "lm%x-vco2", id);
clk = icst_clk_register(NULL, &impd1_icst2_desc, imc->vco2name, NULL,
base);
imc->vco2clk = clk;
/* MMCI uses CLK2 right off */
imc->clks[2] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00700", id);
imc->clks[3] = clkdev_alloc(clk, NULL, "lm%x:00700", id);
/* UART reference clock divides CLK2 by a fixed factor 4 */
imc->uartname = kasprintf(GFP_KERNEL, "lm%x-uartclk", id);
clk = clk_register_fixed_factor(NULL, imc->uartname, imc->vco2name,
CLK_IGNORE_UNUSED, 1, 4);
imc->uartclk = clk;
imc->clks[4] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00100", id);
imc->clks[5] = clkdev_alloc(clk, NULL, "lm%x:00100", id);
imc->clks[6] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00200", id);
imc->clks[7] = clkdev_alloc(clk, NULL, "lm%x:00200", id);
/* SPI PL022 clock divides CLK2 by a fixed factor 64 */
imc->spiname = kasprintf(GFP_KERNEL, "lm%x-spiclk", id);
clk = clk_register_fixed_factor(NULL, imc->spiname, imc->vco2name,
CLK_IGNORE_UNUSED, 1, 64);
imc->clks[8] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00300", id);
imc->clks[9] = clkdev_alloc(clk, NULL, "lm%x:00300", id);
/* The GPIO blocks and AACI have only PCLK */
imc->clks[10] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00400", id);
imc->clks[11] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00500", id);
imc->clks[12] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00800", id);
/* Smart Card clock divides CLK2 by a fixed factor 4 */
imc->scname = kasprintf(GFP_KERNEL, "lm%x-scclk", id);
clk = clk_register_fixed_factor(NULL, imc->scname, imc->vco2name,
CLK_IGNORE_UNUSED, 1, 4);
imc->scclk = clk;
imc->clks[13] = clkdev_alloc(pclk, "apb_pclk", "lm%x:00600", id);
imc->clks[14] = clkdev_alloc(clk, NULL, "lm%x:00600", id);
for (i = 0; i < ARRAY_SIZE(imc->clks); i++)
clkdev_add(imc->clks[i]);
}
EXPORT_SYMBOL_GPL(integrator_impd1_clk_init);
void integrator_impd1_clk_exit(unsigned int id)
{
int i;
struct impd1_clk *imc;
if (id > 3)
return;
imc = &impd1_clks[id];
for (i = 0; i < ARRAY_SIZE(imc->clks); i++)
clkdev_drop(imc->clks[i]);
clk_unregister(imc->spiclk);
clk_unregister(imc->uartclk);
clk_unregister(imc->vco2clk);
clk_unregister(imc->vco1clk);
clk_unregister(imc->pclk);
kfree(imc->scname);
kfree(imc->spiname);
kfree(imc->uartname);
kfree(imc->vco2name);
kfree(imc->vco1name);
kfree(imc->pclkname);
}
EXPORT_SYMBOL_GPL(integrator_impd1_clk_exit);
| {
"pile_set_name": "Github"
} |
// Copyright Bruno Dutra 2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <brigand/sequences/front.hpp>
#include <brigand/sequences/list.hpp>
#include <brigand/types/integer.hpp>
template<int> struct x;
<% env[:k].times do |k| %>
using <%= "xs#{k}" %> = brigand::list<<%= ((k*n+1)..(k*n+n)).map { |i| "x<#{i}>" }.join(', ') %>>;
#if defined(METABENCH)
using <%= "result#{k}" %> = brigand::pop_front<<%= "xs#{k}" %>, brigand::int32_t<<%= k*n/env[:k] %>>>;
#endif
<% end %>
int main() {}
| {
"pile_set_name": "Github"
} |
/**
File Name: lexical-002.js
Corresponds To: ecma/LexicalConventions/7.2-3-n.js
ECMA Section: 7.2 Line Terminators
Description: - readability
- separate tokens
- may occur between any two tokens
- cannot occur within any token, not even a string
- affect the process of automatic semicolon insertion.
white space characters are:
unicode name formal name string representation
\u000A line feed <LF> \n
\u000D carriage return <CR> \r
this test uses onerror to capture line numbers. because
we use on error, we can only have one test case per file.
Author: [email protected]
Date: 11 september 1997
*/
var SECTION = "lexical-002";
var VERSION = "JS1_4";
var TITLE = "Line Terminators";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var tc = 0;
var testcases = new Array();
var result = "Failed";
var exception = "No exception thrown";
var expect = "Passed";
try {
result = eval("\r\n\expect");
} catch ( e ) {
exception = e.toString();
}
testcases[tc++] = new TestCase(
SECTION,
"result=eval(\"\r\nexpect\")" +
" (threw " + exception +")",
expect,
result );
test();
| {
"pile_set_name": "Github"
} |
/*
Test program for TinyXML.
*/
#ifdef TIXML_USE_STL
#include <iostream>
#include <sstream>
using namespace std;
#else
#include <stdio.h>
#endif
#if defined( WIN32 ) && defined( TUNE )
#include <crtdbg.h>
_CrtMemState startMemState;
_CrtMemState endMemState;
#endif
#include "tinyxml.h"
bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho = false);
bool XmlTest( const char* testString, int expected, int found, bool noEcho = false );
static int gPass = 0;
static int gFail = 0;
bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho )
{
bool pass = !strcmp( expected, found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%s][%s]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
bool XmlTest( const char* testString, int expected, int found, bool noEcho )
{
bool pass = ( expected == found );
if ( pass )
printf ("[pass]");
else
printf ("[fail]");
if ( noEcho )
printf (" %s\n", testString);
else
printf (" %s [%d][%d]\n", testString, expected, found);
if ( pass )
++gPass;
else
++gFail;
return pass;
}
void NullLineEndings( char* p )
{
while( p && *p ) {
if ( *p == '\n' || *p == '\r' ) {
*p = 0;
return;
}
++p;
}
}
//
// This file demonstrates some basic functionality of TinyXml.
// Note that the example is very contrived. It presumes you know
// what is in the XML file. But it does test the basic operations,
// and show how to add and remove nodes.
//
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
{
#ifdef TIXML_USE_STL
// What the todo list should look like after processing.
// In stream (no formatting) representation.
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Voel\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &startMemState );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
printf( "** Printing via doc.Print **\n" );
doc.Print( stdout );
{
printf( "** Printing via TiXmlPrinter **\n" );
TiXmlPrinter printer;
doc.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}
#ifdef TIXML_USE_STL
{
printf( "** Printing via operator<< **\n" );
std::cout << doc;
}
#endif
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
assert( node );
todoElement = node->ToElement();
assert( todoElement );
// Going to the toy store is now our second priority...
// So set the "priority" attribute of the first item in the list.
node = todoElement->FirstChildElement(); // This skips the "PDA" comment.
assert( node );
itemElement = node->ToElement();
assert( itemElement );
itemElement->SetAttribute( "priority", 2 );
// Change the distance to "doing bills" from
// "none" to "here". It's the next sibling element.
itemElement = itemElement->NextSiblingElement();
assert( itemElement );
itemElement->SetAttribute( "distance", "here" );
// Remove the "Look for Evil Dinosaurs!" item.
// It is 1 more sibling away. We ask the parent to remove
// a particular child.
itemElement = itemElement->NextSiblingElement();
todoElement->RemoveChild( itemElement );
itemElement = 0;
// --------------------------------------------------------
// What follows is an example of created elements and text
// nodes and adding them to the document.
// --------------------------------------------------------
// Add some meetings.
TiXmlElement item( "Item" );
item.SetAttribute( "priority", "1" );
item.SetAttribute( "distance", "far" );
TiXmlText text( "Talk to:" );
TiXmlElement meeting1( "Meeting" );
meeting1.SetAttribute( "where", "School" );
TiXmlElement meeting2( "Meeting" );
meeting2.SetAttribute( "where", "Lunch" );
TiXmlElement attendee1( "Attendee" );
attendee1.SetAttribute( "name", "Marple" );
attendee1.SetAttribute( "position", "teacher" );
TiXmlElement attendee2( "Attendee" );
attendee2.SetAttribute( "name", "Voel" );
attendee2.SetAttribute( "position", "counselor" );
// Assemble the nodes we've created:
meeting1.InsertEndChild( attendee1 );
meeting1.InsertEndChild( attendee2 );
item.InsertEndChild( text );
item.InsertEndChild( meeting1 );
item.InsertEndChild( meeting2 );
// And add the node to the existing list after the first child.
node = todoElement->FirstChild( "Item" );
assert( node );
itemElement = node->ToElement();
assert( itemElement );
todoElement->InsertAfterChild( itemElement, item );
printf( "\n** Demo doc processed: ** \n\n" );
doc.Print( stdout );
#ifdef TIXML_USE_STL
printf( "** Demo doc processed to stream: ** \n\n" );
cout << doc << endl << endl;
#endif
// --------------------------------------------------------
// Different tests...do we have what we expect?
// --------------------------------------------------------
int count = 0;
TiXmlElement* element;
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
cout << "** Basic structure. **\n";
ostringstream outputStream( ostringstream::out );
outputStream << doc;
XmlTest( "Output stream correct.", string( demoEnd ).c_str(),
outputStream.str().c_str(), true );
#endif
node = doc.RootElement();
assert( node );
XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Root element value is 'ToDo'.", "ToDo", node->Value());
node = node->FirstChild();
XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
node = node->NextSibling();
XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Value is 'Item'.", "Item", node->Value() );
node = node->FirstChild();
XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
//////////////////////////////////////////////////////
printf ("\n** Iterators. **\n");
// Walk all the top level nodes of the document.
count = 0;
for( node = doc.FirstChild();
node;
node = node->NextSibling() )
{
count++;
}
XmlTest( "Top level nodes, using First / Next.", 3, count );
count = 0;
for( node = doc.LastChild();
node;
node = node->PreviousSibling() )
{
count++;
}
XmlTest( "Top level nodes, using Last / Previous.", 3, count );
// Walk all the top level nodes of the document,
// using a different syntax.
count = 0;
for( node = doc.IterateChildren( 0 );
node;
node = doc.IterateChildren( node ) )
{
count++;
}
XmlTest( "Top level nodes, using IterateChildren.", 3, count );
// Walk all the elements in a node.
count = 0;
for( element = todoElement->FirstChildElement();
element;
element = element->NextSiblingElement() )
{
count++;
}
XmlTest( "Children of the 'ToDo' element, using First / Next.",
3, count );
// Walk all the elements in a node by value.
count = 0;
for( node = todoElement->FirstChild( "Item" );
node;
node = node->NextSibling( "Item" ) )
{
count++;
}
XmlTest( "'Item' children of the 'ToDo' element, using First/Next.", 3, count );
count = 0;
for( node = todoElement->LastChild( "Item" );
node;
node = node->PreviousSibling( "Item" ) )
{
count++;
}
XmlTest( "'Item' children of the 'ToDo' element, using Last/Previous.", 3, count );
#ifdef TIXML_USE_STL
{
cout << "\n** Parsing. **\n";
istringstream parse0( "<Element0 attribute0='foo0' attribute1= noquotes attribute2 = '>' />" );
TiXmlElement element0( "default" );
parse0 >> element0;
XmlTest ( "Element parsed, value is 'Element0'.", "Element0", element0.Value() );
XmlTest ( "Reads attribute 'attribute0=\"foo0\"'.", "foo0", element0.Attribute( "attribute0" ));
XmlTest ( "Reads incorrectly formatted 'attribute1=noquotes'.", "noquotes", element0.Attribute( "attribute1" ) );
XmlTest ( "Read attribute with entity value '>'.", ">", element0.Attribute( "attribute2" ) );
}
#endif
{
const char* error = "<?xml version=\"1.0\" standalone=\"no\" ?>\n"
"<passages count=\"006\" formatversion=\"20020620\">\n"
" <wrong error>\n"
"</passages>";
TiXmlDocument docTest;
docTest.Parse( error );
XmlTest( "Error row", docTest.ErrorRow(), 3 );
XmlTest( "Error column", docTest.ErrorCol(), 17 );
//printf( "error=%d id='%s' row %d col%d\n", (int) doc.Error(), doc.ErrorDesc(), doc.ErrorRow()+1, doc.ErrorCol() + 1 );
}
#ifdef TIXML_USE_STL
{
//////////////////////////////////////////////////////
cout << "\n** Streaming. **\n";
// Round trip check: stream in, then stream back out to verify. The stream
// out has already been checked, above. We use the output
istringstream inputStringStream( outputStream.str() );
TiXmlDocument document0;
inputStringStream >> document0;
ostringstream outputStream0( ostringstream::out );
outputStream0 << document0;
XmlTest( "Stream round trip correct.", string( demoEnd ).c_str(),
outputStream0.str().c_str(), true );
std::string str;
str << document0;
XmlTest( "String printing correct.", string( demoEnd ).c_str(),
str.c_str(), true );
}
#endif
}
{
const char* str = "<doc attr0='1' attr1='2.0' attr2='foo' />";
TiXmlDocument doc;
doc.Parse( str );
TiXmlElement* ele = doc.FirstChildElement();
int iVal, result;
double dVal;
result = ele->QueryDoubleAttribute( "attr0", &dVal );
XmlTest( "Query attribute: int as double", result, TIXML_SUCCESS );
XmlTest( "Query attribute: int as double", (int)dVal, 1 );
result = ele->QueryDoubleAttribute( "attr1", &dVal );
XmlTest( "Query attribute: double as double", (int)dVal, 2 );
result = ele->QueryIntAttribute( "attr1", &iVal );
XmlTest( "Query attribute: double as int", result, TIXML_SUCCESS );
XmlTest( "Query attribute: double as int", iVal, 2 );
result = ele->QueryIntAttribute( "attr2", &iVal );
XmlTest( "Query attribute: not a number", result, TIXML_WRONG_TYPE );
result = ele->QueryIntAttribute( "bar", &iVal );
XmlTest( "Query attribute: does not exist", result, TIXML_NO_ATTRIBUTE );
}
{
const char* str = "<doc/>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlElement* ele = doc.FirstChildElement();
int iVal;
double dVal;
ele->SetAttribute( "str", "strValue" );
ele->SetAttribute( "int", 1 );
ele->SetDoubleAttribute( "double", -1.0 );
const char* cStr = ele->Attribute( "str" );
ele->QueryIntAttribute( "int", &iVal );
ele->QueryDoubleAttribute( "double", &dVal );
XmlTest( "Attribute round trip. c-string.", "strValue", cStr );
XmlTest( "Attribute round trip. int.", 1, iVal );
XmlTest( "Attribute round trip. double.", -1, (int)dVal );
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
"</room>";
TiXmlDocument doc;
doc.SetTabSize( 8 );
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
assert( docHandle.Node() );
assert( roomHandle.Element() );
TiXmlElement* room = roomHandle.Element();
assert( room );
TiXmlAttribute* doors = room->FirstAttribute();
assert( doors );
XmlTest( "Location tracking: Tab 8: room row", room->Row(), 1 );
XmlTest( "Location tracking: Tab 8: room col", room->Column(), 49 );
XmlTest( "Location tracking: Tab 8: doors row", doors->Row(), 1 );
XmlTest( "Location tracking: Tab 8: doors col", doors->Column(), 55 );
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
" <!-- Silly example -->\n"
" <door wall='north'>A great door!</door>\n"
"\t<door wall='east'/>"
"</room>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
assert( docHandle.Node() );
assert( roomHandle.Element() );
assert( commentHandle.Node() );
assert( textHandle.Text() );
assert( door0Handle.Element() );
assert( door1Handle.Element() );
TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
assert( declaration );
TiXmlElement* room = roomHandle.Element();
assert( room );
TiXmlAttribute* doors = room->FirstAttribute();
assert( doors );
TiXmlText* text = textHandle.Text();
TiXmlComment* comment = commentHandle.Node()->ToComment();
assert( comment );
TiXmlElement* door0 = door0Handle.Element();
TiXmlElement* door1 = door1Handle.Element();
XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
XmlTest( "Location tracking: room row", room->Row(), 1 );
XmlTest( "Location tracking: room col", room->Column(), 45 );
XmlTest( "Location tracking: doors row", doors->Row(), 1 );
XmlTest( "Location tracking: doors col", doors->Column(), 51 );
XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
XmlTest( "Location tracking: text row", text->Row(), 3 );
XmlTest( "Location tracking: text col", text->Column(), 24 );
XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
}
// --------------------------------------------------------
// UTF-8 testing. It is important to test:
// 1. Making sure name, value, and text read correctly
// 2. Row, Col functionality
// 3. Correct output
// --------------------------------------------------------
printf ("\n** UTF-8 **\n");
{
TiXmlDocument doc( "utf8test.xml" );
doc.LoadFile();
if ( doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE ) {
printf( "WARNING: File 'utf8test.xml' not found.\n"
"(Are you running the test from the wrong directory?)\n"
"Could not test UTF-8 functionality.\n" );
}
else
{
TiXmlHandle docH( &doc );
// Get the attribute "value" from the "Russian" element and check it.
TiXmlElement* element = docH.FirstChildElement( "document" ).FirstChildElement( "Russian" ).Element();
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
XmlTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ), true );
XmlTest( "UTF-8: Russian value row.", 4, element->Row() );
XmlTest( "UTF-8: Russian value column.", 5, element->Column() );
const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
0xd1U, 0x81U, 0xd1U, 0x81U,
0xd0U, 0xbaU, 0xd0U, 0xb8U,
0xd0U, 0xb9U, 0 };
const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
TiXmlText* text = docH.FirstChildElement( "document" ).FirstChildElement( (const char*) russianElementName ).Child( 0 ).Text();
XmlTest( "UTF-8: Browsing russian element name.",
russianText,
text->Value(),
true );
XmlTest( "UTF-8: Russian element name row.", 7, text->Row() );
XmlTest( "UTF-8: Russian element name column.", 47, text->Column() );
TiXmlDeclaration* dec = docH.Child( 0 ).Node()->ToDeclaration();
XmlTest( "UTF-8: Declaration column.", 1, dec->Column() );
XmlTest( "UTF-8: Document column.", 1, doc.Column() );
// Now try for a round trip.
doc.SaveFile( "utf8testout.xml" );
// Check the round trip.
char savedBuf[256];
char verifyBuf[256];
int okay = 1;
FILE* saved = fopen( "utf8testout.xml", "r" );
FILE* verify = fopen( "utf8testverify.xml", "r" );
//bool firstLineBOM=true;
if ( saved && verify )
{
while ( fgets( verifyBuf, 256, verify ) )
{
fgets( savedBuf, 256, saved );
NullLineEndings( verifyBuf );
NullLineEndings( savedBuf );
if ( /*!firstLineBOM && */ strcmp( verifyBuf, savedBuf ) )
{
printf( "verify:%s<\n", verifyBuf );
printf( "saved :%s<\n", savedBuf );
okay = 0;
break;
}
//firstLineBOM = false;
}
}
if ( saved )
fclose( saved );
if ( verify )
fclose( verify );
XmlTest( "UTF-8: Verified multi-language round trip.", 1, okay );
// On most Western machines, this is an element that contains
// the word "resume" with the correct accents, in a latin encoding.
// It will be something else completely on non-wester machines,
// which is why TinyXml is switching to UTF-8.
const char latin[] = "<element>r\x82sum\x82</element>";
TiXmlDocument latinDoc;
latinDoc.Parse( latin, 0, TIXML_ENCODING_LEGACY );
text = latinDoc.FirstChildElement()->FirstChild()->ToText();
XmlTest( "Legacy encoding: Verify text element.", "r\x82sum\x82", text->Value() );
}
}
//////////////////////
// Copy and assignment
//////////////////////
printf ("\n** Copy and Assignment **\n");
{
TiXmlElement element( "foo" );
element.Parse( "<element name='value' />", 0, TIXML_ENCODING_UNKNOWN );
TiXmlElement elementCopy( element );
TiXmlElement elementAssign( "foo" );
elementAssign.Parse( "<incorrect foo='bar'/>", 0, TIXML_ENCODING_UNKNOWN );
elementAssign = element;
XmlTest( "Copy/Assign: element copy #1.", "element", elementCopy.Value() );
XmlTest( "Copy/Assign: element copy #2.", "value", elementCopy.Attribute( "name" ) );
XmlTest( "Copy/Assign: element assign #1.", "element", elementAssign.Value() );
XmlTest( "Copy/Assign: element assign #2.", "value", elementAssign.Attribute( "name" ) );
XmlTest( "Copy/Assign: element assign #3.", true, ( 0 == elementAssign.Attribute( "foo" )) );
TiXmlComment comment;
comment.Parse( "<!--comment-->", 0, TIXML_ENCODING_UNKNOWN );
TiXmlComment commentCopy( comment );
TiXmlComment commentAssign;
commentAssign = commentCopy;
XmlTest( "Copy/Assign: comment copy.", "comment", commentCopy.Value() );
XmlTest( "Copy/Assign: comment assign.", "comment", commentAssign.Value() );
TiXmlUnknown unknown;
unknown.Parse( "<[unknown]>", 0, TIXML_ENCODING_UNKNOWN );
TiXmlUnknown unknownCopy( unknown );
TiXmlUnknown unknownAssign;
unknownAssign.Parse( "incorrect", 0, TIXML_ENCODING_UNKNOWN );
unknownAssign = unknownCopy;
XmlTest( "Copy/Assign: unknown copy.", "[unknown]", unknownCopy.Value() );
XmlTest( "Copy/Assign: unknown assign.", "[unknown]", unknownAssign.Value() );
TiXmlText text( "TextNode" );
TiXmlText textCopy( text );
TiXmlText textAssign( "incorrect" );
textAssign = text;
XmlTest( "Copy/Assign: text copy.", "TextNode", textCopy.Value() );
XmlTest( "Copy/Assign: text assign.", "TextNode", textAssign.Value() );
TiXmlDeclaration dec;
dec.Parse( "<?xml version='1.0' encoding='UTF-8'?>", 0, TIXML_ENCODING_UNKNOWN );
TiXmlDeclaration decCopy( dec );
TiXmlDeclaration decAssign;
decAssign = dec;
XmlTest( "Copy/Assign: declaration copy.", "UTF-8", decCopy.Encoding() );
XmlTest( "Copy/Assign: text assign.", "UTF-8", decAssign.Encoding() );
TiXmlDocument doc;
elementCopy.InsertEndChild( textCopy );
doc.InsertEndChild( decAssign );
doc.InsertEndChild( elementCopy );
doc.InsertEndChild( unknownAssign );
TiXmlDocument docCopy( doc );
TiXmlDocument docAssign;
docAssign = docCopy;
#ifdef TIXML_USE_STL
std::string original, copy, assign;
original << doc;
copy << docCopy;
assign << docAssign;
XmlTest( "Copy/Assign: document copy.", original.c_str(), copy.c_str(), true );
XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true );
#endif
}
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
printf ("\n** Parsing, no Condense Whitespace **\n");
TiXmlBase::SetCondenseWhiteSpace( false );
{
istringstream parse1( "<start>This is \ntext</start>" );
TiXmlElement text1( "text" );
parse1 >> text1;
XmlTest ( "Condense white space OFF.", "This is \ntext",
text1.FirstChild()->Value(),
true );
}
TiXmlBase::SetCondenseWhiteSpace( true );
#endif
//////////////////////////////////////////////////////
// GetText();
{
const char* str = "<foo>This is text</foo>";
TiXmlDocument doc;
doc.Parse( str );
const TiXmlElement* element = doc.RootElement();
XmlTest( "GetText() normal use.", "This is text", element->GetText() );
str = "<foo><b>This is text</b></foo>";
doc.Clear();
doc.Parse( str );
element = doc.RootElement();
XmlTest( "GetText() contained element.", element->GetText() == 0, true );
str = "<foo>This is <b>text</b></foo>";
doc.Clear();
TiXmlBase::SetCondenseWhiteSpace( false );
doc.Parse( str );
TiXmlBase::SetCondenseWhiteSpace( true );
element = doc.RootElement();
XmlTest( "GetText() partial.", "This is ", element->GetText() );
}
//////////////////////////////////////////////////////
// CDATA
{
const char* str = "<xmlElement>"
"<![CDATA["
"I am > the rules!\n"
"...since I make symbolic puns"
"]]>"
"</xmlElement>";
TiXmlDocument doc;
doc.Parse( str );
doc.Print();
XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
"I am > the rules!\n...since I make symbolic puns",
true );
#ifdef TIXML_USE_STL
//cout << doc << '\n';
doc.Clear();
istringstream parse0( str );
parse0 >> doc;
//cout << doc << '\n';
XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(),
"I am > the rules!\n...since I make symbolic puns",
true );
#endif
TiXmlDocument doc1 = doc;
//doc.Print();
XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(),
"I am > the rules!\n...since I make symbolic puns",
true );
}
{
// [ 1482728 ] Wrong wide char parsing
char buf[256];
buf[255] = 0;
for( int i=0; i<255; ++i ) {
buf[i] = (char)((i>=32) ? i : 32);
}
TIXML_STRING str( "<xmlElement><![CDATA[" );
str += buf;
str += "]]></xmlElement>";
TiXmlDocument doc;
doc.Parse( str.c_str() );
TiXmlPrinter printer;
printer.SetStreamPrinting();
doc.Accept( &printer );
XmlTest( "CDATA with all bytes #1.", str.c_str(), printer.CStr(), true );
#ifdef TIXML_USE_STL
doc.Clear();
istringstream iss( printer.Str() );
iss >> doc;
std::string out;
out << doc;
XmlTest( "CDATA with all bytes #2.", out.c_str(), printer.CStr(), true );
#endif
}
{
// [ 1480107 ] Bug-fix for STL-streaming of CDATA that contains tags
// CDATA streaming had a couple of bugs, that this tests for.
const char* str = "<xmlElement>"
"<![CDATA["
"<b>I am > the rules!</b>\n"
"...since I make symbolic puns"
"]]>"
"</xmlElement>";
TiXmlDocument doc;
doc.Parse( str );
doc.Print();
XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
"<b>I am > the rules!</b>\n...since I make symbolic puns",
true );
#ifdef TIXML_USE_STL
doc.Clear();
istringstream parse0( str );
parse0 >> doc;
XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
"<b>I am > the rules!</b>\n...since I make symbolic puns",
true );
#endif
TiXmlDocument doc1 = doc;
//doc.Print();
XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(),
"<b>I am > the rules!</b>\n...since I make symbolic puns",
true );
}
//////////////////////////////////////////////////////
// Visit()
//////////////////////////////////////////////////////
printf( "\n** Fuzzing... **\n" );
const int FUZZ_ITERATION = 300;
// The only goal is not to crash on bad input.
int len = (int) strlen( demoStart );
for( int i=0; i<FUZZ_ITERATION; ++i )
{
char* demoCopy = new char[ len+1 ];
strcpy( demoCopy, demoStart );
demoCopy[ i%len ] = (char)((i+1)*3);
demoCopy[ (i*7)%len ] = '>';
demoCopy[ (i*11)%len ] = '<';
TiXmlDocument xml;
xml.Parse( demoCopy );
delete [] demoCopy;
}
printf( "** Fuzzing Complete. **\n" );
//////////////////////////////////////////////////////
printf ("\n** Bug regression tests **\n");
// InsertBeforeChild and InsertAfterChild causes crash.
{
TiXmlElement parent( "Parent" );
TiXmlElement childText0( "childText0" );
TiXmlElement childText1( "childText1" );
TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
TiXmlNode* childNode1 = parent.InsertBeforeChild( childNode0, childText1 );
XmlTest( "Test InsertBeforeChild on empty node.", ( childNode1 == parent.FirstChild() ), true );
}
{
// InsertBeforeChild and InsertAfterChild causes crash.
TiXmlElement parent( "Parent" );
TiXmlElement childText0( "childText0" );
TiXmlElement childText1( "childText1" );
TiXmlNode* childNode0 = parent.InsertEndChild( childText0 );
TiXmlNode* childNode1 = parent.InsertAfterChild( childNode0, childText1 );
XmlTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent.LastChild() ), true );
}
// Reports of missing constructors, irregular string problems.
{
// Missing constructor implementation. No test -- just compiles.
TiXmlText text( "Missing" );
#ifdef TIXML_USE_STL
// Missing implementation:
TiXmlDocument doc;
string name = "missing";
doc.LoadFile( name );
TiXmlText textSTL( name );
#else
// verifying some basic string functions:
TiXmlString a;
TiXmlString b( "Hello" );
TiXmlString c( "ooga" );
c = " World!";
a = b;
a += c;
a = a;
XmlTest( "Basic TiXmlString test. ", "Hello World!", a.c_str() );
#endif
}
// Long filenames crashing STL version
{
TiXmlDocument doc( "midsummerNightsDreamWithAVeryLongFilenameToConfuseTheStringHandlingRoutines.xml" );
bool loadOkay = doc.LoadFile();
loadOkay = true; // get rid of compiler warning.
// Won't pass on non-dev systems. Just a "no crash" check.
//XmlTest( "Long filename. ", true, loadOkay );
}
{
// Entities not being written correctly.
// From Lynn Allen
const char* passages =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<passages count=\"006\" formatversion=\"20020620\">"
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
"</passages>";
TiXmlDocument doc( "passages.xml" );
doc.Parse( passages );
TiXmlElement* psg = doc.RootElement()->FirstChildElement();
const char* context = psg->Attribute( "context" );
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
XmlTest( "Entity transformation: read. ", expected, context, true );
FILE* textfile = fopen( "textfile.txt", "w" );
if ( textfile )
{
psg->Print( textfile, 0 );
fclose( textfile );
}
textfile = fopen( "textfile.txt", "r" );
assert( textfile );
if ( textfile )
{
char buf[ 1024 ];
fgets( buf, 1024, textfile );
XmlTest( "Entity transformation: write. ",
"<psg context=\'Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright \xC2\xA9.' />",
buf,
true );
}
fclose( textfile );
}
{
FILE* textfile = fopen( "test5.xml", "w" );
if ( textfile )
{
fputs("<?xml version='1.0'?><a.elem xmi.version='2.0'/>", textfile);
fclose(textfile);
TiXmlDocument doc;
doc.LoadFile( "test5.xml" );
XmlTest( "dot in element attributes and names", doc.Error(), 0);
}
}
{
FILE* textfile = fopen( "test6.xml", "w" );
if ( textfile )
{
fputs("<element><Name>1.1 Start easy ignore fin thickness
</Name></element>", textfile );
fclose(textfile);
TiXmlDocument doc;
bool result = doc.LoadFile( "test6.xml" );
XmlTest( "Entity with one digit.", result, true );
TiXmlText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
XmlTest( "Entity with one digit.",
text->Value(), "1.1 Start easy ignore fin thickness\n" );
}
}
{
// DOCTYPE not preserved (950171)
//
const char* doctype =
"<?xml version=\"1.0\" ?>"
"<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
"<!ELEMENT title (#PCDATA)>"
"<!ELEMENT books (title,authors)>"
"<element />";
TiXmlDocument doc;
doc.Parse( doctype );
doc.SaveFile( "test7.xml" );
doc.Clear();
doc.LoadFile( "test7.xml" );
TiXmlHandle docH( &doc );
TiXmlUnknown* unknown = docH.Child( 1 ).Unknown();
XmlTest( "Correct value of unknown.", "!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->Value() );
#ifdef TIXML_USE_STL
TiXmlNode* node = docH.Child( 2 ).Node();
std::string str;
str << (*node);
XmlTest( "Correct streaming of unknown.", "<!ELEMENT title (#PCDATA)>", str.c_str() );
#endif
}
{
// [ 791411 ] Formatting bug
// Comments do not stream out correctly.
const char* doctype =
"<!-- Somewhat<evil> -->";
TiXmlDocument doc;
doc.Parse( doctype );
TiXmlHandle docH( &doc );
TiXmlComment* comment = docH.Child( 0 ).Node()->ToComment();
XmlTest( "Comment formatting.", " Somewhat<evil> ", comment->Value() );
#ifdef TIXML_USE_STL
std::string str;
str << (*comment);
XmlTest( "Comment streaming.", "<!-- Somewhat<evil> -->", str.c_str() );
#endif
}
{
// [ 870502 ] White space issues
TiXmlDocument doc;
TiXmlText* text;
TiXmlHandle docH( &doc );
const char* doctype0 = "<element> This has leading and trailing space </element>";
const char* doctype1 = "<element>This has internal space</element>";
const char* doctype2 = "<element> This has leading, trailing, and internal space </element>";
TiXmlBase::SetCondenseWhiteSpace( false );
doc.Clear();
doc.Parse( doctype0 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space kept.", " This has leading and trailing space ", text->Value() );
doc.Clear();
doc.Parse( doctype1 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space kept.", "This has internal space", text->Value() );
doc.Clear();
doc.Parse( doctype2 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space kept.", " This has leading, trailing, and internal space ", text->Value() );
TiXmlBase::SetCondenseWhiteSpace( true );
doc.Clear();
doc.Parse( doctype0 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space condensed.", "This has leading and trailing space", text->Value() );
doc.Clear();
doc.Parse( doctype1 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space condensed.", "This has internal space", text->Value() );
doc.Clear();
doc.Parse( doctype2 );
text = docH.FirstChildElement( "element" ).Child( 0 ).Text();
XmlTest( "White space condensed.", "This has leading, trailing, and internal space", text->Value() );
}
{
// Double attributes
const char* doctype = "<element attr='red' attr='blue' />";
TiXmlDocument doc;
doc.Parse( doctype );
XmlTest( "Parsing repeated attributes.", true, doc.Error() ); // is an error to tinyxml (didn't use to be, but caused issues)
//XmlTest( "Parsing repeated attributes.", "blue", doc.FirstChildElement( "element" )->Attribute( "attr" ) );
}
{
// Embedded null in stream.
const char* doctype = "<element att\0r='red' attr='blue' />";
TiXmlDocument doc;
doc.Parse( doctype );
XmlTest( "Embedded null throws error.", true, doc.Error() );
#ifdef TIXML_USE_STL
istringstream strm( doctype );
doc.Clear();
doc.ClearError();
strm >> doc;
XmlTest( "Embedded null throws error.", true, doc.Error() );
#endif
}
{
// Legacy mode test. (This test may only pass on a western system)
const char* str =
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"
"<รค>"
"Cรถntรคntรรครถรผรรร"
"</รค>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle aHandle = docHandle.FirstChildElement( "รค" );
TiXmlHandle tHandle = aHandle.Child( 0 );
assert( aHandle.Element() );
assert( tHandle.Text() );
XmlTest( "ISO-8859-1 Parsing.", "Cรถntรคntรรครถรผรรร", tHandle.Text()->Value() );
}
{
// Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717
const char* str = " ";
TiXmlDocument doc;
doc.Parse( str );
XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() );
}
#ifndef TIXML_USE_STL
{
// String equality. [ 1006409 ] string operator==/!= no worky in all cases
TiXmlString temp;
XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true );
TiXmlString foo;
TiXmlString bar( "" );
XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true );
}
#endif
{
// Bug [ 1195696 ] from marlonism
TiXmlBase::SetCondenseWhiteSpace(false);
TiXmlDocument xml;
xml.Parse("<text><break/>This hangs</text>");
XmlTest( "Test safe error return.", xml.Error(), false );
}
{
// Bug [ 1243992 ] - another infinite loop
TiXmlDocument doc;
doc.SetCondenseWhiteSpace(false);
doc.Parse("<p><pb></pb>test</p>");
}
{
// Low entities
TiXmlDocument xml;
xml.Parse( "<test></test>" );
const char result[] = { 0x0e, 0 };
XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result );
xml.Print();
}
{
// Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly
TiXmlDocument xml;
xml.Parse( "<foo attribute=bar\" />" );
XmlTest( "Throw error with bad end quotes.", xml.Error(), true );
}
#ifdef TIXML_USE_STL
{
// Bug [ 1449463 ] Consider generic query
TiXmlDocument xml;
xml.Parse( "<foo bar='3' barStr='a string'/>" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
float f;
bool b;
std::string str;
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE );
XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS );
XmlTest( "QueryValueAttribute", (d==3.0), true );
XmlTest( "QueryValueAttribute", (i==3), true );
XmlTest( "QueryValueAttribute", (f==3.0f), true );
XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true );
}
#endif
#ifdef TIXML_USE_STL
{
// [ 1505267 ] redundant malloc in TiXmlElement::Attribute
TiXmlDocument xml;
xml.Parse( "<foo bar='3' />" );
TiXmlElement* ele = xml.FirstChildElement();
double d;
int i;
std::string bar = "bar";
const std::string* atrrib = ele->Attribute( bar );
ele->Attribute( bar, &d );
ele->Attribute( bar, &i );
XmlTest( "Attribute", atrrib->empty(), false );
XmlTest( "Attribute", (d==3.0), true );
XmlTest( "Attribute", (i==3), true );
}
#endif
{
// [ 1356059 ] Allow TiXMLDocument to only be at the top level
TiXmlDocument xml, xml2;
xml.InsertEndChild( xml2 );
XmlTest( "Document only at top level.", xml.Error(), true );
XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY );
}
{
// [ 1663758 ] Failure to report error on bad XML
TiXmlDocument xml;
xml.Parse("<x>");
XmlTest("Missing end tag at end of input", xml.Error(), true);
xml.Parse("<x> ");
XmlTest("Missing end tag with trailing whitespace", xml.Error(), true);
}
{
// [ 1635701 ] fail to parse files with a tag separated into two lines
// I'm not sure this is a bug. Marked 'pending' for feedback.
TiXmlDocument xml;
xml.Parse( "<title><p>text</p\n><title>" );
//xml.Print();
//XmlTest( "Tag split by newline", xml.Error(), false );
}
#ifdef TIXML_USE_STL
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
istringstream parse1( "<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
parse1 >> xml;
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
#endif
{
// [ 1475201 ] TinyXML parses entities in comments
TiXmlDocument xml;
xml.Parse("<!-- declarations for <head> & <body> -->"
"<!-- far & away -->" );
TiXmlNode* e0 = xml.FirstChild();
TiXmlNode* e1 = e0->NextSibling();
TiXmlComment* c0 = e0->ToComment();
TiXmlComment* c1 = e1->ToComment();
XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true );
XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true );
}
{
TiXmlDocument xml;
xml.Parse( "<Parent>"
"<child1 att=''/>"
"<!-- With this comment, child2 will not be parsed! -->"
"<child2 att=''/>"
"</Parent>" );
int count = 0;
TiXmlNode* ele = 0;
while ( (ele = xml.FirstChildElement( "Parent" )->IterateChildren( ele ) ) != 0 ) {
++count;
}
XmlTest( "Comments iterate correctly.", 3, count );
}
{
// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.
unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";
buf[60] = 239;
buf[61] = 0;
TiXmlDocument doc;
doc.Parse( (const char*)buf);
}
{
// bug 1827248 Error while parsing a little bit malformed file
// Actually not malformed - should work.
TiXmlDocument xml;
xml.Parse( "<attributelist> </attributelist >" );
XmlTest( "Handle end tag whitespace", false, xml.Error() );
}
{
// This one must not result in an infinite loop
TiXmlDocument xml;
xml.Parse( "<infinite>loop" );
XmlTest( "Infinite loop test.", true, true );
}
{
// 1709904 - can not repro the crash
{
TiXmlDocument xml;
xml.Parse( "<tag>/</tag>" );
XmlTest( "Odd XML parsing.", xml.FirstChild()->Value(), "tag" );
}
/* Could not repro. {
TiXmlDocument xml;
xml.LoadFile( "EQUI_Inventory.xml" );
//XmlTest( "Odd XML parsing.", xml.FirstChildElement()->Value(), "XML" );
TiXmlPrinter printer;
xml.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}*/
}
/* 1417717 experiment
{
TiXmlDocument xml;
xml.Parse("<text>Dan & Tracie</text>");
xml.Print(stdout);
}
{
TiXmlDocument xml;
xml.Parse("<text>Dan &foo; Tracie</text>");
xml.Print(stdout);
}
*/
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &endMemState );
//_CrtMemDumpStatistics( &endMemState );
_CrtMemState diffMemState;
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState );
#endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);
return gFail;
}
| {
"pile_set_name": "Github"
} |
#include "tommath.h"
#ifdef BN_MP_TO_UNSIGNED_BIN_N_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
* LibTomMath is a library that provides multiple-precision
* integer arithmetic as well as number theoretic functionality.
*
* The library was designed directly after the MPI library by
* Michael Fromberger but has been written from scratch with
* additional optimizations in place.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, [email protected], http://libtom.org
*/
/* store in unsigned [big endian] format */
int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen)
{
if (*outlen < (unsigned long)mp_unsigned_bin_size(a)) {
return MP_VAL;
}
*outlen = mp_unsigned_bin_size(a);
return mp_to_unsigned_bin(a, b);
}
#endif
/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin_n.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/12/28 01:25:13 $ */ | {
"pile_set_name": "Github"
} |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package registry
//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go
| {
"pile_set_name": "Github"
} |
data class Point(var x: Int, var y: Int)
fun main(args: Array<String>) {
val p = Point(1, 2)
println(p)
p.x = 3
p.y = 4
println(p)
}
| {
"pile_set_name": "Github"
} |
/* ---------------------------------------------------------------------------- */
/* Atmel Microcontroller Software Support */
/* SAM Software Package License */
/* ---------------------------------------------------------------------------- */
/* Copyright (c) 2014, Atmel Corporation */
/* */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following condition is met: */
/* */
/* - Redistributions of source code must retain the above copyright notice, */
/* this list of conditions and the disclaimer below. */
/* */
/* Atmel's name may not be used to endorse or promote products derived from */
/* this software without specific prior written permission. */
/* */
/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
/* DISCLAIMED. IN NO EVENT SHALL ATMEL 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 _SAM_UART1_INSTANCE_
#define _SAM_UART1_INSTANCE_
/* ========== Register definition for UART1 peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_UART1_CR (0x400E0A00U) /**< \brief (UART1) Control Register */
#define REG_UART1_MR (0x400E0A04U) /**< \brief (UART1) Mode Register */
#define REG_UART1_IER (0x400E0A08U) /**< \brief (UART1) Interrupt Enable Register */
#define REG_UART1_IDR (0x400E0A0CU) /**< \brief (UART1) Interrupt Disable Register */
#define REG_UART1_IMR (0x400E0A10U) /**< \brief (UART1) Interrupt Mask Register */
#define REG_UART1_SR (0x400E0A14U) /**< \brief (UART1) Status Register */
#define REG_UART1_RHR (0x400E0A18U) /**< \brief (UART1) Receive Holding Register */
#define REG_UART1_THR (0x400E0A1CU) /**< \brief (UART1) Transmit Holding Register */
#define REG_UART1_BRGR (0x400E0A20U) /**< \brief (UART1) Baud Rate Generator Register */
#define REG_UART1_CMPR (0x400E0A24U) /**< \brief (UART1) Comparison Register */
#define REG_UART1_WPMR (0x400E0AE4U) /**< \brief (UART1) Write Protection Mode Register */
#else
#define REG_UART1_CR (*(__O uint32_t*)0x400E0A00U) /**< \brief (UART1) Control Register */
#define REG_UART1_MR (*(__IO uint32_t*)0x400E0A04U) /**< \brief (UART1) Mode Register */
#define REG_UART1_IER (*(__O uint32_t*)0x400E0A08U) /**< \brief (UART1) Interrupt Enable Register */
#define REG_UART1_IDR (*(__O uint32_t*)0x400E0A0CU) /**< \brief (UART1) Interrupt Disable Register */
#define REG_UART1_IMR (*(__I uint32_t*)0x400E0A10U) /**< \brief (UART1) Interrupt Mask Register */
#define REG_UART1_SR (*(__I uint32_t*)0x400E0A14U) /**< \brief (UART1) Status Register */
#define REG_UART1_RHR (*(__I uint32_t*)0x400E0A18U) /**< \brief (UART1) Receive Holding Register */
#define REG_UART1_THR (*(__O uint32_t*)0x400E0A1CU) /**< \brief (UART1) Transmit Holding Register */
#define REG_UART1_BRGR (*(__IO uint32_t*)0x400E0A20U) /**< \brief (UART1) Baud Rate Generator Register */
#define REG_UART1_CMPR (*(__IO uint32_t*)0x400E0A24U) /**< \brief (UART1) Comparison Register */
#define REG_UART1_WPMR (*(__IO uint32_t*)0x400E0AE4U) /**< \brief (UART1) Write Protection Mode Register */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
#endif /* _SAM_UART1_INSTANCE_ */
| {
"pile_set_name": "Github"
} |
//
// Copyright ยฉ 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "SubtractionLayer.hpp"
#include "LayerCloneBase.hpp"
#include <armnn/TypesUtils.hpp>
#include <backendsCommon/WorkloadData.hpp>
#include <backendsCommon/WorkloadFactory.hpp>
namespace armnn
{
SubtractionLayer::SubtractionLayer(const char* name)
: ElementwiseBaseLayer(2, 1, LayerType::Subtraction, name)
{
}
std::unique_ptr<IWorkload> SubtractionLayer::CreateWorkload(const IWorkloadFactory& factory) const
{
SubtractionQueueDescriptor descriptor;
return factory.CreateSubtraction(descriptor, PrepInfoAndDesc(descriptor));
}
SubtractionLayer* SubtractionLayer::Clone(Graph& graph) const
{
return CloneBase<SubtractionLayer>(graph, GetName());
}
void SubtractionLayer::Accept(ILayerVisitor& visitor) const
{
visitor.VisitSubtractionLayer(this, GetName());
}
} // namespace armnn
| {
"pile_set_name": "Github"
} |
// Safe sequence implementation -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file debug/safe_sequence.h
* This file is a GNU debug extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H
#define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1
#include <debug/debug.h>
#include <debug/macros.h>
#include <debug/functions.h>
#include <debug/safe_base.h>
namespace __gnu_debug
{
template<typename _Iterator, typename _Sequence>
class _Safe_iterator;
/** A simple function object that returns true if the passed-in
* value is not equal to the stored value. It saves typing over
* using both bind1st and not_equal.
*/
template<typename _Type>
class _Not_equal_to
{
_Type __value;
public:
explicit _Not_equal_to(const _Type& __v) : __value(__v) { }
bool
operator()(const _Type& __x) const
{ return __value != __x; }
};
/** A function object that returns true when the given random access
iterator is at least @c n steps away from the given iterator. */
template<typename _Iterator>
class _After_nth_from
{
typedef typename std::iterator_traits<_Iterator>::difference_type
difference_type;
_Iterator _M_base;
difference_type _M_n;
public:
_After_nth_from(const difference_type& __n, const _Iterator& __base)
: _M_base(__base), _M_n(__n) { }
bool
operator()(const _Iterator& __x) const
{ return __x - _M_base >= _M_n; }
};
/**
* @brief Base class for constructing a @a safe sequence type that
* tracks iterators that reference it.
*
* The class template %_Safe_sequence simplifies the construction of
* @a safe sequences that track the iterators that reference the
* sequence, so that the iterators are notified of changes in the
* sequence that may affect their operation, e.g., if the container
* invalidates its iterators or is destructed. This class template
* may only be used by deriving from it and passing the name of the
* derived class as its template parameter via the curiously
* recurring template pattern. The derived class must have @c
* iterator and @const_iterator types that are instantiations of
* class template _Safe_iterator for this sequence. Iterators will
* then be tracked automatically.
*/
template<typename _Sequence>
class _Safe_sequence : public _Safe_sequence_base
{
public:
/** Invalidates all iterators @c x that reference this sequence,
are not singular, and for which @c pred(x) returns @c
true. The user of this routine should be careful not to make
copies of the iterators passed to @p pred, as the copies may
interfere with the invalidation. */
template<typename _Predicate>
void
_M_invalidate_if(_Predicate __pred);
/** Transfers all iterators that reference this memory location
to this sequence from whatever sequence they are attached
to. */
template<typename _Iterator>
void
_M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x);
};
template<typename _Sequence>
template<typename _Predicate>
void
_Safe_sequence<_Sequence>::
_M_invalidate_if(_Predicate __pred)
{
typedef typename _Sequence::iterator iterator;
typedef typename _Sequence::const_iterator const_iterator;
__gnu_cxx::__scoped_lock sentry(this->_M_get_mutex());
for (_Safe_iterator_base* __iter = _M_iterators; __iter;)
{
iterator* __victim = static_cast<iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular())
{
if (__pred(__victim->base()))
__victim->_M_invalidate_single();
}
}
for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;)
{
const_iterator* __victim = static_cast<const_iterator*>(__iter2);
__iter2 = __iter2->_M_next;
if (!__victim->_M_singular())
{
if (__pred(__victim->base()))
__victim->_M_invalidate_single();
}
}
}
template<typename _Sequence>
template<typename _Iterator>
void
_Safe_sequence<_Sequence>::
_M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x)
{
_Safe_sequence_base* __from = __x._M_sequence;
if (!__from)
return;
typedef typename _Sequence::iterator iterator;
typedef typename _Sequence::const_iterator const_iterator;
__gnu_cxx::__scoped_lock sentry(this->_M_get_mutex());
for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter;)
{
iterator* __victim = static_cast<iterator*>(__iter);
__iter = __iter->_M_next;
if (!__victim->_M_singular() && __victim->base() == __x.base())
__victim->_M_attach_single(static_cast<_Sequence*>(this));
}
for (_Safe_iterator_base* __iter2 = __from->_M_const_iterators;
__iter2;)
{
const_iterator* __victim = static_cast<const_iterator*>(__iter2);
__iter2 = __iter2->_M_next;
if (!__victim->_M_singular() && __victim->base() == __x.base())
__victim->_M_attach_single(static_cast<_Sequence*>(this));
}
}
} // namespace __gnu_debug
#endif
| {
"pile_set_name": "Github"
} |
<!-- ko if: visible -->
<div class="h3">
<img class="encounter-section-img" data-bind="attr: { src: sectionIcon }">
<span data-bind="text: name"></span><br />
<small data-bind="text: tagline"></small>
</div>
<table class="table table-responsive table-ac-bordered table-hover">
<thead>
<tr>
<th data-bind="click: function(){sortBy('name');}" class="col-md-3 col-sm-9">
Name
<span data-bind="css: sortArrow('name')"></span>
</th>
<th data-bind="click: function(){sortBy('description');}" class="col-md-6 hidden-xs hidden-sm">
Description
<span data-bind="css: sortArrow('description')"></span>
</th>
<th class="text-right col-md-1">Send</th>
<th class="text-right col-md-1">Exhibit</th>
<th class="text-right col-md-1">
<a data-bind="click: toggleAddModal" href="#">
<i class="fa fa-plus fa-color"></i>
</a>
</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: filteredAndSortedMapsAndImages -->
<tr class="clickable">
<td data-bind="text: name, click: $parent.editMapOrImage"
class="col-md-3 col-xs-9"
href="#"></td>
<td data-bind="html: shortDescription, click: $parent.editMapOrImage"
class="col-md-6 hidden-sm hidden-xs"
href="#"></td>
<!-- ko if: $parent.shouldShowPushButton -->
<td class="text-right col-md-1">
<a data-bind="click: $parent.pushModalToPlayerButtonWasPressed" href="#" title="Send image to Player's Chat">
<i class="fa fa-paper-plane-o fa-color-hover">
</i>
</a>
</td>
<td class="text-right col-md-1">
<a data-bind="click: $parent.toggleMapOrImageExhibit" href="#" title="Send Player's Exhibit">
<i data-bind="css: { exhibitActiveIcon: isExhibited }" class="fa fa-desktop fa-color-hover">
</i>
</a>
</td>
<!-- /ko -->
<!-- ko ifnot: $parent.shouldShowPushButton -->
<td class="text-right col-md-1">
<span class="fa fa-paper-plane-o fa-disabled" style="cursor:pointer;"
data-bind="popover: { content: 'Join a Party to send image to Player\'s Chat' }">
</span>
</td>
<td class="text-right col-md-1">
<span class="fa fa-desktop fa-disabled" style="cursor:pointer;"
data-bind="popover: { content: 'Join a Party send Player\'s Exhibit' }">
</span>
</td>
<!-- /ko -->
<td class="text-right col-md-1">
<a data-bind="click: $parent.removeMapOrImage" href="#">
<i class="fa fa-trash-o fa-color-hover">
</i>
</a>
</td>
</tr>
<!-- /ko -->
<!-- ko if: filteredAndSortedMapsAndImages().length == 0 -->
<tr class="clickable">
<td data-toggle="modal" data-bind="click: toggleAddModal"
colspan="12" class="text-center">
<i class="fa fa-plus fa-color"></i>
Add a new Map or Image.
</td>
</tr>
<!-- /ko -->
</tbody>
</table>
<!-- The visibility is managed internally -->
<full-screen-image params="imageSource: convertedDisplayUrl, fullScreenStatus: fullScreen">
</full-screen-image>
<!-- Add Modal -->
<div class="modal fade"
id="addMapOrImage"
tabindex="-1"
role="dialog" data-bind="modal: {
onopen: modalFinishedOpening,
open: addModalOpen,
onclose: closeAddModal }">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title"
id="addMapOrImageLabel">Add a new Map or Image.</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" data-bind="element: _addForm, validate: validation">
<div class="form-group">
<label class="col-sm-2 control-label">
Name<i class="required"></i>
</label>
<div class="col-sm-9">
<input type="text"
class="form-control"
name="name"
placeholder="A really cool place or image"
data-bind="textInput: blankMapOrImage().name,
hasFocus: firstElementInModalHasFocus">
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Image Link<i class="required"></i>
</label>
<div class="col-sm-9">
<input type="text"
class="form-control"
name="sourceUrl"
placeholder="http://myurl.com/image.jpg"
data-bind="textInput: blankMapOrImage().sourceUrl">
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-padded control-label">
Description
</label>
<div class="col-sm-9 col-padded">
<textarea type="text"
class="form-control" rows="4"
name="description"
data-bind="value: blankMapOrImage().description">
</textarea>
<small class="text-muted">
Text in this panel can be styled using Markdown. Click
<a target="_blank"
href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet">here</a> to see a guide.
</small>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Player Text
</label>
<div class="col-sm-9">
<textarea type="text"
class="form-control" rows="4"
name="playerText"
placeholder="This is the description that your players will see when sent via the chat."
data-bind="value: blankMapOrImage().playerText"></textarea>
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="modal-footer">
<small class="text-center">
<p>
Fields marked with <i class="fa fa-paper-plane-o"></i> will be sent to the players via the chat.
</p>
</small>
<button type="submit"
class="btn btn-primary">
Add</button>
</div>
</form>
</div> <!-- Modal Body -->
</div> <!-- Modal Content -->
</div> <!-- Modal Dialog -->
</div> <!-- Modal Fade -->
<!-- /ko -->
<!-- ViewEdit Modal -->
<div class="modal fade"
id="viewMapOrImage"
tabindex="-1"
role="dialog"
data-bind="modal: {
open: openModal,
onopen: modalFinishedOpening,
onclose: closeModal
}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Edit a Map or Image.</h4>
</div>
<div class="modal-body">
<!-- Begin Tabs -->
<ul class="nav nav-tabs tabs">
<li role="presentation" data-bind="click: selectPreviewTab, css: previewTabStatus">
<a href="#" aria-controls="mapsAndImagesModalPreview" role="tab" data-toggle="tab">
<b>Preview</b>
</a>
</li>
<li role="presentation" data-bind="click: selectEditTab, css: editTabStatus">
<a href="#" aria-controls="mapsAndImagesModalEdit" role="tab" data-toggle="tab">
<b>Edit</b>
</a>
</li>
</ul>
<div class="tab-content" data-bind="with: currentEditItem">
<div role="tabpanel" data-bind="css: $parent.previewTabStatus" class="tab-pane">
<div class="h3">
<span data-bind="text: name"></span>
</div>
<div class="row row-padded">
<div class="col-xs-12 col-padded text-center">
<img data-bind="attr: { src: $parent.convertedDisplayUrl },
click: $parent.toggleFullScreen" class="clickable preview-modal-image" />
<small>
<em class="text-muted">Click on the image to view it in Full Screen.</em>
</small>
</div>
</div>
<hr />
<span class="h4">
Description
</span>
<div class="row row-padded">
<div class="col-xs-12 col-padded">
<div data-bind="markdownPreview: description"
class="preview-modal-overflow">
</div>
</div>
</div>
<span class="h4">
Player Text
</span>
<div class="row row-padded">
<div class="col-xs-12 col-padded">
<div data-bind="markdownPreview: playerText"
class="preview-modal-overflow light-blue-left-highlight">
</div>
</div>
</div>
</div> <!-- End Preview Tab -->
<div role="tabpanel" data-bind="css: $parent.editTabStatus" class="tab-pane">
<form class="form-horizontal" data-bind="element: $parent._editForm, validate: $parent.updateValidation">
<div class="form-group">
<label for="mapOrImageName"
class="col-sm-2 control-label">
Name<i class="required"></i>
</label>
<div class="col-sm-9">
<input type="text"
class="form-control"
name="name"
data-bind="textInput: name, hasFocus: $parent.editFirstModalElementHasFocus">
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Image Link<i class="required"></i>
</label>
<div class="col-sm-9">
<input type="text"
name="sourceUrl"
class="form-control"
data-bind="textInput: sourceUrl">
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="form-group">
<label for="mapOrImageDescription"
class="col-sm-2 col-padded control-label">Description</label>
<div class="col-sm-9 col-padded">
<textarea type="text" rows="6"
class="form-control"
name="description"
data-bind="value: description, markdownEditor: true"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
Player Text
</label>
<div class="col-sm-9">
<textarea type="text"
rows="6"
class="form-control"
name="playerText"
placeholder="This is the description that your players will see when sent via the chat."
data-bind="value: playerText, markdownEditor: true">
</textarea>
<small class="text-muted">
Text in this panel can be styled using Markdown. Click
<a target="_blank"
href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet">here</a> to see a guide.
</small>
</div>
<div class="col-sm-1 control-label">
<span class="fa fa-paper-plane-o" style="cursor:pointer;"
title="This field will be sent to the players via the chat.">
</span>
</div>
</div>
<div class="modal-footer">
<small class="text-center">
<p>
Fields marked with <i class="fa fa-paper-plane-o"></i> will be sent to the players via the chat.
</p>
</small>
<button type="submit"
class="btn btn-primary">Done</button>
</div>
</form>
</div>
</div>
</div> <!-- Modal Body -->
</div> <!-- Modal Content -->
</div> <!-- Modal Dialog -->
</div> <!-- Modal Fade -->
<player-push-modal params="isOpen: openPushModal, type: pushType, payload: selectedMapOrImageToPush, onclose: pushModalFinishedClosing"></player-push-modal>
| {
"pile_set_name": "Github"
} |
/*
* SonarAnalyzer for .NET
* Copyright (C) 2015-2020 SonarSource SA
* mailto: contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
namespace SonarAnalyzer.Helpers
{
internal class ReportingContext : IReportingContext
{
private readonly Action<Diagnostic> contextSpecificReport;
public ReportingContext(SyntaxNodeAnalysisContext context, Diagnostic diagnostic)
{
SyntaxTree = context.GetSyntaxTree();
Compilation = context.Compilation;
Diagnostic = diagnostic;
this.contextSpecificReport = context.ReportDiagnostic;
}
public ReportingContext(SyntaxTreeAnalysisContext context, Diagnostic diagnostic)
{
SyntaxTree = context.GetSyntaxTree();
Compilation = null;
Diagnostic = diagnostic;
this.contextSpecificReport = context.ReportDiagnostic;
}
public ReportingContext(CompilationAnalysisContext context, Diagnostic diagnostic)
{
SyntaxTree = context.GetFirstSyntaxTree();
Compilation = context.Compilation;
Diagnostic = diagnostic;
this.contextSpecificReport = context.ReportDiagnostic;
}
public ReportingContext(SymbolAnalysisContext context, Diagnostic diagnostic)
{
SyntaxTree = context.GetFirstSyntaxTree();
Compilation = context.Compilation;
Diagnostic = diagnostic;
this.contextSpecificReport = context.ReportDiagnostic;
}
public ReportingContext(CodeBlockAnalysisContext context, Diagnostic diagnostic)
{
SyntaxTree = context.GetSyntaxTree();
Compilation = context.SemanticModel.Compilation;
Diagnostic = diagnostic;
this.contextSpecificReport = context.ReportDiagnostic;
}
public SyntaxTree SyntaxTree { get; }
public Diagnostic Diagnostic { get; }
public Compilation Compilation { get; }
public void ReportDiagnostic(Diagnostic diagnostic) => this.contextSpecificReport(diagnostic);
}
}
| {
"pile_set_name": "Github"
} |
:103E000001C0B0C011248FE594E09EBF8DBF84B780
:103E1000882361F0982F9A70923041F081FF02C0A0
:103E200097EF94BF282E80E0B8D0EAC085E08EBD21
:103E300082E08BB998E19AB996E890BD89B98EE095
:103E4000ACD0B89A84E028E43AEF44E051E03DBDBC
:103E50002CBD48BF08B602FEFDCF98B3952798BB8E
:103E6000A8955F9902C0815091F790D0813479F480
:103E70008DD0182F96D0123811F480E004C088E05D
:103E8000113809F083E07ED080E17CD0EECF82341F
:103E900019F484E18ED0F8CF853411F485E0FACF9F
:103EA000853541F473D0C82F71D0D82FCC0FDD1FCA
:103EB00078D0EACF863519F484E07BD0DECF843623
:103EC00099F564D063D0182F61D0D82E012F90E6D9
:103ED000E92EF12C57018FEFA81AB80A57D0F70135
:103EE000808301507501B1F75CD0F5E4DF1201C0A9
:103EF000FFCF50E040E063E0CE0134D07E0180E6A9
:103F0000C82ED12CF601419151916F0161E0C7019A
:103F100029D0F2E0EF0EF11C1250A1F750E040E082
:103F200065E0CE011FD0B0CF843771F42FD02ED0F2
:103F3000F82E2CD036D08E01F80185918F0122D039
:103F4000FA94F110F9CFA0CF853731F42AD08EE161
:103F500019D084E917D096CF813509F0A9CF88E030
:103F60001CD0A6CFFC010A0167BFE895112407B653
:103F700000FCFDCF667029F0452B19F481E187BF65
:103F8000E89508955D9BFECF8CB908955F9BFECFA9
:103F90005C9901C0A8958CB1089598E191BD81BD4F
:103FA0000895F4DF803219F088E0F7DFFFCF84E175
:103FB000E9CFCF93C82FEADFC150E9F7CF91F1CF16
:023FFE000008B9
:0400000300003E00BB
:00000001FF
| {
"pile_set_name": "Github"
} |
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.ambientweather.internal.processor;
import static org.openhab.binding.ambientweather.internal.AmbientWeatherBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
/**
* The {@link Ws0900ipProcessor} is responsible for updating
* the channels associated with the WS-0900-IP weather stations in
* response to the receipt of a weather data update from the Ambient
* Weather real-time API.
*
* @author Mark Hilbush - Initial contribution
*/
@NonNullByDefault
public class Ws0900ipProcessor extends AbstractProcessor {
@Override
public void setChannelGroupId() {
channelGroupId = CHGRP_WS0900IP;
}
@Override
public void setNumberOfSensors() {
// This station doesn't support remote sensors
}
@Override
public void processInfoUpdate(AmbientWeatherStationHandler handler, String station, String name, String location) {
// Update name and location channels
handler.updateString(CHGRP_STATION, CH_NAME, name);
handler.updateString(CHGRP_STATION, CH_LOCATION, location);
}
@Override
public void processWeatherData(AmbientWeatherStationHandler handler, String station, String jsonData) {
EventDataJson data = parseEventData(station, jsonData);
if (data == null) {
return;
}
// Update the weather data channels
handler.updateDate(channelGroupId, CH_OBSERVATION_TIME, data.date);
handler.updateString(channelGroupId, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_DEW_POINT, data.dewPoint, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_PRESSURE_ABSOLUTE, data.baromabsin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_PRESSURE_RELATIVE, data.baromrelin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_WIND_SPEED, data.windspeedmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, SmartHomeUnits.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_GUST, data.windgustmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_GUST_MAX_DAILY, data.maxdailygust, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, SmartHomeUnits.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_DAY, data.dailyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_WEEK, data.weeklyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_MONTH, data.monthlyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_YEAR, data.yearlyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_TOTAL, data.totalrainin, ImperialUnits.INCH);
handler.updateDate(channelGroupId, CH_RAIN_LAST_TIME, data.lastRain);
// Update calculated channels
if (data.baromrelin != null) {
pressureTrend.put(data.baromrelin);
handler.updateString(channelGroupId, CH_PRESSURE_TREND, pressureTrend.getPressureTrend());
}
if (data.winddir != null) {
handler.updateString(channelGroupId, CH_WIND_DIRECTION, convertWindDirectionToString(data.winddir));
}
// Update indoor sensor channels
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateString(CHGRP_INDOOR_SENSOR, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
}
}
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.