code stringlengths 3 1.01M | repo_name stringlengths 5 116 | path stringlengths 3 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 3 1.01M |
|---|---|---|---|---|---|
/****************************************************************************
* *
* GNAT COMPILER COMPONENTS *
* *
* A D A I N T *
* *
* C Implementation File *
* *
* Copyright (C) 1992-2015, Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
* ware Foundation; either version 3, or (at your option) any later ver- *
* sion. GNAT is distributed in the hope that it will be useful, but WITH- *
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* As a special exception 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/>. *
* *
* GNAT was originally developed by the GNAT team at New York University. *
* Extensive contributions were provided by Ada Core Technologies Inc. *
* *
****************************************************************************/
/* This file contains those routines named by Import pragmas in
packages in the GNAT hierarchy (especially GNAT.OS_Lib) and in
package Osint. Many of the subprograms in OS_Lib import standard
library calls directly. This file contains all other routines. */
/* Ensure access to errno is thread safe. */
#define _REENTRANT
#define _THREAD_SAFE
#ifdef __vxworks
/* No need to redefine exit here. */
#undef exit
/* We want to use the POSIX variants of include files. */
#define POSIX
#include "vxWorks.h"
#if defined (__mips_vxworks)
#include "cacheLib.h"
#endif /* __mips_vxworks */
/* If SMP, access vxCpuConfiguredGet */
#ifdef _WRS_CONFIG_SMP
#include <vxCpuLib.h>
#endif /* _WRS_CONFIG_SMP */
/* We need to know the VxWorks version because some file operations
(such as chmod) are only available on VxWorks 6. */
#include "version.h"
#endif /* VxWorks */
#if defined (__APPLE__)
#include <unistd.h>
#endif
#if defined (__hpux__)
#include <sys/param.h>
#include <sys/pstat.h>
#endif
#ifdef __PikeOS__
#define __BSD_VISIBLE 1
#endif
#ifdef IN_RTS
#include "tconfig.h"
#include "tsystem.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#if defined (__vxworks) || defined (__ANDROID__)
/* S_IREAD and S_IWRITE are not defined in VxWorks or Android */
#ifndef S_IREAD
#define S_IREAD (S_IRUSR | S_IRGRP | S_IROTH)
#endif
#ifndef S_IWRITE
#define S_IWRITE (S_IWUSR)
#endif
#endif
/* We don't have libiberty, so use malloc. */
#define xmalloc(S) malloc (S)
#define xrealloc(V,S) realloc (V,S)
#else
#include "config.h"
#include "system.h"
#include "version.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined (__MINGW32__) || defined (__CYGWIN__)
#include "mingw32.h"
/* Current code page and CCS encoding to use, set in initialize.c. */
UINT CurrentCodePage;
UINT CurrentCCSEncoding;
#include <sys/utime.h>
/* For isalpha-like tests in the compiler, we're expected to resort to
safe-ctype.h/ISALPHA. This isn't available for the runtime library
build, so we fallback on ctype.h/isalpha there. */
#ifdef IN_RTS
#include <ctype.h>
#define ISALPHA isalpha
#endif
#elif defined (__Lynx__)
/* Lynx utime.h only defines the entities of interest to us if
defined (VMOS_DEV), so ... */
#define VMOS_DEV
#include <utime.h>
#undef VMOS_DEV
#else
#include <utime.h>
#endif
/* wait.h processing */
#ifdef __MINGW32__
# if OLD_MINGW
# include <sys/wait.h>
# endif
#elif defined (__vxworks) && defined (__RTP__)
# include <wait.h>
#elif defined (__Lynx__)
/* ??? We really need wait.h and it includes resource.h on Lynx. GCC
has a resource.h header as well, included instead of the lynx
version in our setup, causing lots of errors. We don't really need
the lynx contents of this file, so just workaround the issue by
preventing the inclusion of the GCC header from doing anything. */
# define GCC_RESOURCE_H
# include <sys/wait.h>
#elif defined (__PikeOS__)
/* No wait() or waitpid() calls available. */
#else
/* Default case. */
#include <sys/wait.h>
#endif
#if defined (_WIN32)
#include <process.h>
#include <dir.h>
#include <windows.h>
#include <accctrl.h>
#include <aclapi.h>
#undef DIR_SEPARATOR
#define DIR_SEPARATOR '\\'
#else
#include <utime.h>
#endif
#include "adaint.h"
/* Define symbols O_BINARY and O_TEXT as harmless zeroes if they are not
defined in the current system. On DOS-like systems these flags control
whether the file is opened/created in text-translation mode (CR/LF in
external file mapped to LF in internal file), but in Unix-like systems,
no text translation is required, so these flags have no effect. */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_TEXT
#define O_TEXT 0
#endif
#ifndef HOST_EXECUTABLE_SUFFIX
#define HOST_EXECUTABLE_SUFFIX ""
#endif
#ifndef HOST_OBJECT_SUFFIX
#define HOST_OBJECT_SUFFIX ".o"
#endif
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR ':'
#endif
#ifndef DIR_SEPARATOR
#define DIR_SEPARATOR '/'
#endif
/* Check for cross-compilation. */
#if defined (CROSS_COMPILE) || defined (CROSS_DIRECTORY_STRUCTURE)
#define IS_CROSS 1
int __gnat_is_cross_compiler = 1;
#else
#undef IS_CROSS
int __gnat_is_cross_compiler = 0;
#endif
char __gnat_dir_separator = DIR_SEPARATOR;
char __gnat_path_separator = PATH_SEPARATOR;
/* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define
the base filenames that libraries specified with -lsomelib options
may have. This is used by GNATMAKE to check whether an executable
is up-to-date or not. The syntax is
library_template ::= { pattern ; } pattern NUL
pattern ::= [ prefix ] * [ postfix ]
These should only specify names of static libraries as it makes
no sense to determine at link time if dynamic-link libraries are
up to date or not. Any libraries that are not found are supposed
to be up-to-date:
* if they are needed but not present, the link
will fail,
* otherwise they are libraries in the system paths and so
they are considered part of the system and not checked
for that reason.
??? This should be part of a GNAT host-specific compiler
file instead of being included in all user applications
as well. This is only a temporary work-around for 3.11b. */
#ifndef GNAT_LIBRARY_TEMPLATE
#define GNAT_LIBRARY_TEMPLATE "lib*.a"
#endif
const char *__gnat_library_template = GNAT_LIBRARY_TEMPLATE;
#if defined (__vxworks)
#define GNAT_MAX_PATH_LEN PATH_MAX
#else
#if defined (__MINGW32__)
#include "mingw32.h"
#if OLD_MINGW
#include <sys/param.h>
#endif
#else
#include <sys/param.h>
#endif
#ifdef MAXPATHLEN
#define GNAT_MAX_PATH_LEN MAXPATHLEN
#else
#define GNAT_MAX_PATH_LEN 256
#endif
#endif
/* Used for runtime check that Ada constant File_Attributes_Size is no
less than the actual size of struct file_attributes (see Osint
initialization). */
int __gnat_size_of_file_attributes = sizeof (struct file_attributes);
void __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr);
/* The __gnat_max_path_len variable is used to export the maximum
length of a path name to Ada code. max_path_len is also provided
for compatibility with older GNAT versions, please do not use
it. */
int __gnat_max_path_len = GNAT_MAX_PATH_LEN;
int max_path_len = GNAT_MAX_PATH_LEN;
/* Control whether we can use ACL on Windows. */
int __gnat_use_acl = 1;
/* The following macro HAVE_READDIR_R should be defined if the
system provides the routine readdir_r.
... but we never define it anywhere??? */
#undef HAVE_READDIR_R
#define MAYBE_TO_PTR32(argv) argv
static const char ATTR_UNSET = 127;
/* Reset the file attributes as if no system call had been performed */
void
__gnat_reset_attributes (struct file_attributes* attr)
{
attr->exists = ATTR_UNSET;
attr->error = EINVAL;
attr->writable = ATTR_UNSET;
attr->readable = ATTR_UNSET;
attr->executable = ATTR_UNSET;
attr->regular = ATTR_UNSET;
attr->symbolic_link = ATTR_UNSET;
attr->directory = ATTR_UNSET;
attr->timestamp = (OS_Time)-2;
attr->file_length = -1;
}
int
__gnat_error_attributes (struct file_attributes *attr) {
return attr->error;
}
OS_Time
__gnat_current_time (void)
{
time_t res = time (NULL);
return (OS_Time) res;
}
/* Return the current local time as a string in the ISO 8601 format of
"YYYY-MM-DD HH:MM:SS.SS". The returned string is 22 + 1 (NULL) characters
long. */
void
__gnat_current_time_string (char *result)
{
const char *format = "%Y-%m-%d %H:%M:%S";
/* Format string necessary to describe the ISO 8601 format */
const time_t t_val = time (NULL);
strftime (result, 22, format, localtime (&t_val));
/* Convert the local time into a string following the ISO format, copying
at most 22 characters into the result string. */
result [19] = '.';
result [20] = '0';
result [21] = '0';
/* The sub-seconds are manually set to zero since type time_t lacks the
precision necessary for nanoseconds. */
}
void
__gnat_to_gm_time (OS_Time *p_time, int *p_year, int *p_month, int *p_day,
int *p_hours, int *p_mins, int *p_secs)
{
struct tm *res;
time_t time = (time_t) *p_time;
#ifdef _WIN32
/* On Windows systems, the time is sometimes rounded up to the nearest
even second, so if the number of seconds is odd, increment it. */
if (time & 1)
time++;
#endif
res = gmtime (&time);
if (res)
{
*p_year = res->tm_year;
*p_month = res->tm_mon;
*p_day = res->tm_mday;
*p_hours = res->tm_hour;
*p_mins = res->tm_min;
*p_secs = res->tm_sec;
}
else
*p_year = *p_month = *p_day = *p_hours = *p_mins = *p_secs = 0;
}
void
__gnat_to_os_time (OS_Time *p_time, int year, int month, int day,
int hours, int mins, int secs)
{
struct tm v;
v.tm_year = year;
v.tm_mon = month;
v.tm_mday = day;
v.tm_hour = hours;
v.tm_min = mins;
v.tm_sec = secs;
v.tm_isdst = -1;
/* returns -1 of failing, this is s-os_lib Invalid_Time */
*p_time = (OS_Time) mktime (&v);
}
/* Place the contents of the symbolic link named PATH in the buffer BUF,
which has size BUFSIZ. If PATH is a symbolic link, then return the number
of characters of its content in BUF. Otherwise, return -1.
For systems not supporting symbolic links, always return -1. */
int
__gnat_readlink (char *path ATTRIBUTE_UNUSED,
char *buf ATTRIBUTE_UNUSED,
size_t bufsiz ATTRIBUTE_UNUSED)
{
#if defined (_WIN32) \
|| defined(__vxworks) || defined (__PikeOS__)
return -1;
#else
return readlink (path, buf, bufsiz);
#endif
}
/* Creates a symbolic link named NEWPATH which contains the string OLDPATH.
If NEWPATH exists it will NOT be overwritten.
For systems not supporting symbolic links, always return -1. */
int
__gnat_symlink (char *oldpath ATTRIBUTE_UNUSED,
char *newpath ATTRIBUTE_UNUSED)
{
#if defined (_WIN32) \
|| defined(__vxworks) || defined (__PikeOS__)
return -1;
#else
return symlink (oldpath, newpath);
#endif
}
/* Try to lock a file, return 1 if success. */
#if defined (__vxworks) \
|| defined (_WIN32) || defined (__PikeOS__)
/* Version that does not use link. */
int
__gnat_try_lock (char *dir, char *file)
{
int fd;
#ifdef __MINGW32__
TCHAR wfull_path[GNAT_MAX_PATH_LEN];
TCHAR wfile[GNAT_MAX_PATH_LEN];
TCHAR wdir[GNAT_MAX_PATH_LEN];
S2WSC (wdir, dir, GNAT_MAX_PATH_LEN);
S2WSC (wfile, file, GNAT_MAX_PATH_LEN);
/* ??? the code below crash on MingW64 for obscure reasons, a ticket
has been opened here:
https://sourceforge.net/p/mingw-w64/bugs/414/
As a workaround an equivalent set of code has been put in place below.
_stprintf (wfull_path, _T("%s%c%s"), wdir, _T(DIR_SEPARATOR), wfile);
*/
_tcscpy (wfull_path, wdir);
_tcscat (wfull_path, L"\\");
_tcscat (wfull_path, wfile);
fd = _topen (wfull_path, O_CREAT | O_EXCL, 0600);
#else
char full_path[256];
sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file);
fd = open (full_path, O_CREAT | O_EXCL, 0600);
#endif
if (fd < 0)
return 0;
close (fd);
return 1;
}
#else
/* Version using link(), more secure over NFS. */
/* See TN 6913-016 for discussion ??? */
int
__gnat_try_lock (char *dir, char *file)
{
char full_path[256];
char temp_file[256];
GNAT_STRUCT_STAT stat_result;
int fd;
sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file);
sprintf (temp_file, "%s%cTMP-%ld-%ld",
dir, DIR_SEPARATOR, (long)getpid(), (long)getppid ());
/* Create the temporary file and write the process number. */
fd = open (temp_file, O_CREAT | O_WRONLY, 0600);
if (fd < 0)
return 0;
close (fd);
/* Link it with the new file. */
link (temp_file, full_path);
/* Count the references on the old one. If we have a count of two, then
the link did succeed. Remove the temporary file before returning. */
__gnat_stat (temp_file, &stat_result);
unlink (temp_file);
return stat_result.st_nlink == 2;
}
#endif
/* Return the maximum file name length. */
int
__gnat_get_maximum_file_name_length (void)
{
return -1;
}
/* Return nonzero if file names are case sensitive. */
static int file_names_case_sensitive_cache = -1;
int
__gnat_get_file_names_case_sensitive (void)
{
if (file_names_case_sensitive_cache == -1)
{
const char *sensitive = getenv ("GNAT_FILE_NAME_CASE_SENSITIVE");
if (sensitive != NULL
&& (sensitive[0] == '0' || sensitive[0] == '1')
&& sensitive[1] == '\0')
file_names_case_sensitive_cache = sensitive[0] - '0';
else
{
/* By default, we suppose filesystems aren't case sensitive on
Windows and Darwin (but they are on arm-darwin). */
#if defined (WINNT) || (defined (__APPLE__) && !defined (__arm__))
file_names_case_sensitive_cache = 0;
#else
file_names_case_sensitive_cache = 1;
#endif
}
}
return file_names_case_sensitive_cache;
}
/* Return nonzero if environment variables are case sensitive. */
int
__gnat_get_env_vars_case_sensitive (void)
{
#if defined (WINNT)
return 0;
#else
return 1;
#endif
}
char
__gnat_get_default_identifier_character_set (void)
{
return '1';
}
/* Return the current working directory. */
void
__gnat_get_current_dir (char *dir, int *length)
{
#if defined (__MINGW32__)
TCHAR wdir[GNAT_MAX_PATH_LEN];
_tgetcwd (wdir, *length);
WS2SC (dir, wdir, GNAT_MAX_PATH_LEN);
#else
getcwd (dir, *length);
#endif
*length = strlen (dir);
if (dir [*length - 1] != DIR_SEPARATOR)
{
dir [*length] = DIR_SEPARATOR;
++(*length);
}
dir[*length] = '\0';
}
/* Return the suffix for object files. */
void
__gnat_get_object_suffix_ptr (int *len, const char **value)
{
*value = HOST_OBJECT_SUFFIX;
if (*value == 0)
*len = 0;
else
*len = strlen (*value);
return;
}
/* Return the suffix for executable files. */
void
__gnat_get_executable_suffix_ptr (int *len, const char **value)
{
*value = HOST_EXECUTABLE_SUFFIX;
if (!*value)
*len = 0;
else
*len = strlen (*value);
return;
}
/* Return the suffix for debuggable files. Usually this is the same as the
executable extension. */
void
__gnat_get_debuggable_suffix_ptr (int *len, const char **value)
{
*value = HOST_EXECUTABLE_SUFFIX;
if (*value == 0)
*len = 0;
else
*len = strlen (*value);
return;
}
/* Returns the OS filename and corresponding encoding. */
void
__gnat_os_filename (char *filename ATTRIBUTE_UNUSED,
char *w_filename ATTRIBUTE_UNUSED,
char *os_name, int *o_length,
char *encoding ATTRIBUTE_UNUSED, int *e_length)
{
#if defined (_WIN32) && ! defined (__vxworks) && ! defined (IS_CROSS)
WS2SC (os_name, (TCHAR *)w_filename, (DWORD)*o_length);
*o_length = strlen (os_name);
strcpy (encoding, "encoding=utf8");
*e_length = strlen (encoding);
#else
strcpy (os_name, filename);
*o_length = strlen (filename);
*e_length = 0;
#endif
}
/* Delete a file. */
int
__gnat_unlink (char *path)
{
#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (IS_CROSS)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
return _tunlink (wpath);
}
#else
return unlink (path);
#endif
}
/* Rename a file. */
int
__gnat_rename (char *from, char *to)
{
#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (IS_CROSS)
{
TCHAR wfrom[GNAT_MAX_PATH_LEN], wto[GNAT_MAX_PATH_LEN];
S2WSC (wfrom, from, GNAT_MAX_PATH_LEN);
S2WSC (wto, to, GNAT_MAX_PATH_LEN);
return _trename (wfrom, wto);
}
#else
return rename (from, to);
#endif
}
/* Changing directory. */
int
__gnat_chdir (char *path)
{
#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (IS_CROSS)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
return _tchdir (wpath);
}
#else
return chdir (path);
#endif
}
/* Removing a directory. */
int
__gnat_rmdir (char *path)
{
#if defined (__MINGW32__) && ! defined (__vxworks) && ! defined (IS_CROSS)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
return _trmdir (wpath);
}
#elif defined (VTHREADS)
/* rmdir not available */
return -1;
#else
return rmdir (path);
#endif
}
#if defined (_WIN32) || defined (linux) || defined (sun) \
|| defined (__FreeBSD__)
#define HAS_TARGET_WCHAR_T
#endif
#ifdef HAS_TARGET_WCHAR_T
#include <wchar.h>
#endif
int
__gnat_fputwc(int c, FILE *stream)
{
#ifdef HAS_TARGET_WCHAR_T
return fputwc ((wchar_t)c, stream);
#else
return fputc (c, stream);
#endif
}
FILE *
__gnat_fopen (char *path, char *mode, int encoding ATTRIBUTE_UNUSED)
{
#if defined (_WIN32) && ! defined (__vxworks) && ! defined (IS_CROSS)
TCHAR wpath[GNAT_MAX_PATH_LEN];
TCHAR wmode[10];
S2WS (wmode, mode, 10);
if (encoding == Encoding_Unspecified)
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
else if (encoding == Encoding_UTF8)
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
else
S2WS (wpath, path, GNAT_MAX_PATH_LEN);
return _tfopen (wpath, wmode);
#else
return GNAT_FOPEN (path, mode);
#endif
}
FILE *
__gnat_freopen (char *path,
char *mode,
FILE *stream,
int encoding ATTRIBUTE_UNUSED)
{
#if defined (_WIN32) && ! defined (__vxworks) && ! defined (IS_CROSS)
TCHAR wpath[GNAT_MAX_PATH_LEN];
TCHAR wmode[10];
S2WS (wmode, mode, 10);
if (encoding == Encoding_Unspecified)
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
else if (encoding == Encoding_UTF8)
S2WSU (wpath, path, GNAT_MAX_PATH_LEN);
else
S2WS (wpath, path, GNAT_MAX_PATH_LEN);
return _tfreopen (wpath, wmode, stream);
#else
return freopen (path, mode, stream);
#endif
}
int
__gnat_open_read (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
if (fmode)
o_fmode = O_TEXT;
#if defined (__vxworks)
fd = open (path, O_RDONLY | o_fmode, 0444);
#elif defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_RDONLY | o_fmode, 0444);
}
#else
fd = GNAT_OPEN (path, O_RDONLY | o_fmode);
#endif
return fd < 0 ? -1 : fd;
}
#if defined (__MINGW32__)
#define PERM (S_IREAD | S_IWRITE)
#else
#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#endif
int
__gnat_open_rw (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
if (fmode)
o_fmode = O_TEXT;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_RDWR | o_fmode, PERM);
}
#else
fd = GNAT_OPEN (path, O_RDWR | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
}
int
__gnat_open_create (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
if (fmode)
o_fmode = O_TEXT;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
}
#else
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
}
int
__gnat_create_output_file (char *path)
{
int fd;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
}
#else
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
#endif
return fd < 0 ? -1 : fd;
}
int
__gnat_create_output_file_new (char *path)
{
int fd;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_EXCL, PERM);
}
#else
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_EXCL, PERM);
#endif
return fd < 0 ? -1 : fd;
}
int
__gnat_open_append (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
if (fmode)
o_fmode = O_TEXT;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
}
#else
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
}
/* Open a new file. Return error (-1) if the file already exists. */
int
__gnat_open_new (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
if (fmode)
o_fmode = O_TEXT;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
}
#else
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
}
/* Open a new temp file. Return error (-1) if the file already exists. */
int
__gnat_open_new_temp (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
strcpy (path, "GNAT-XXXXXX");
#if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) \
|| defined (linux) || defined(__GLIBC__)) && !defined (__vxworks)
return mkstemp (path);
#elif defined (__Lynx__)
mktemp (path);
#else
if (mktemp (path) == NULL)
return -1;
#endif
if (fmode)
o_fmode = O_TEXT;
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
return fd < 0 ? -1 : fd;
}
int
__gnat_open (char *path, int fmode)
{
int fd;
#if defined (__MINGW32__)
{
TCHAR wpath[GNAT_MAX_PATH_LEN];
S2WSC (wpath, path, GNAT_MAX_PATH_LEN);
fd = _topen (wpath, fmode, PERM);
}
#else
fd = GNAT_OPEN (path, fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
}
/****************************************************************
** Perform a call to GNAT_STAT or GNAT_FSTAT, and extract as much information
** as possible from it, storing the result in a cache for later reuse
****************************************************************/
void
__gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr)
{
GNAT_STRUCT_STAT statbuf;
int ret, error;
if (fd != -1) {
/* GNAT_FSTAT returns -1 and sets errno for failure */
ret = GNAT_FSTAT (fd, &statbuf);
error = ret ? errno : 0;
} else {
/* __gnat_stat returns errno value directly */
error = __gnat_stat (name, &statbuf);
ret = error ? -1 : 0;
}
/*
* A missing file is reported as an attr structure with error == 0 and
* exists == 0.
*/
if (error == 0 || error == ENOENT)
attr->error = 0;
else
attr->error = error;
attr->regular = (!ret && S_ISREG (statbuf.st_mode));
attr->directory = (!ret && S_ISDIR (statbuf.st_mode));
if (!attr->regular)
attr->file_length = 0;
else
/* st_size may be 32 bits, or 64 bits which is converted to long. We
don't return a useful value for files larger than 2 gigabytes in
either case. */
attr->file_length = statbuf.st_size; /* all systems */
attr->exists = !ret;
#if !defined (_WIN32)
/* on Windows requires extra system call, see __gnat_is_readable_file_attr */
attr->readable = (!ret && (statbuf.st_mode & S_IRUSR));
attr->writable = (!ret && (statbuf.st_mode & S_IWUSR));
attr->executable = (!ret && (statbuf.st_mode & S_IXUSR));
#endif
if (ret != 0) {
attr->timestamp = (OS_Time)-1;
} else {
attr->timestamp = (OS_Time)statbuf.st_mtime;
}
}
/****************************************************************
** Return the number of bytes in the specified file
****************************************************************/
__int64
__gnat_file_length_attr (int fd, char* name, struct file_attributes* attr)
{
if (attr->file_length == -1) {
__gnat_stat_to_attr (fd, name, attr);
}
return attr->file_length;
}
__int64
__gnat_file_length (int fd)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_file_length_attr (fd, NULL, &attr);
}
long
__gnat_file_length_long (int fd)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return (long)__gnat_file_length_attr (fd, NULL, &attr);
}
__int64
__gnat_named_file_length (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_file_length_attr (-1, name, &attr);
}
/* Create a temporary filename and put it in string pointed to by
TMP_FILENAME. */
void
__gnat_tmp_name (char *tmp_filename)
{
#if defined (__MINGW32__)
{
char *pname;
char prefix[25];
/* tempnam tries to create a temporary file in directory pointed to by
TMP environment variable, in c:\temp if TMP is not set, and in
directory specified by P_tmpdir in stdio.h if c:\temp does not
exist. The filename will be created with the prefix "gnat-". */
sprintf (prefix, "gnat-%d-", (int)getpid());
pname = (char *) _tempnam ("c:\\temp", prefix);
/* if pname is NULL, the file was not created properly, the disk is full
or there is no more free temporary files */
if (pname == NULL)
*tmp_filename = '\0';
/* If pname start with a back slash and not path information it means that
the filename is valid for the current working directory. */
else if (pname[0] == '\\')
{
strcpy (tmp_filename, ".\\");
strcat (tmp_filename, pname+1);
}
else
strcpy (tmp_filename, pname);
free (pname);
}
#elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \
|| defined (__OpenBSD__) || defined(__GLIBC__) || defined (__ANDROID__)
#define MAX_SAFE_PATH 1000
char *tmpdir = getenv ("TMPDIR");
/* If tmpdir is longer than MAX_SAFE_PATH, revert to default value to avoid
a buffer overflow. */
if (tmpdir == NULL || strlen (tmpdir) > MAX_SAFE_PATH)
#ifdef __ANDROID__
strcpy (tmp_filename, "/cache/gnat-XXXXXX");
#else
strcpy (tmp_filename, "/tmp/gnat-XXXXXX");
#endif
else
sprintf (tmp_filename, "%s/gnat-XXXXXX", tmpdir);
close (mkstemp(tmp_filename));
#elif defined (__vxworks) && !(defined (__RTP__) || defined (VTHREADS))
int index;
char * pos;
ushort_t t;
static ushort_t seed = 0; /* used to generate unique name */
/* generate unique name */
strcpy (tmp_filename, "tmp");
/* fill up the name buffer from the last position */
index = 5;
pos = tmp_filename + strlen (tmp_filename) + index;
*pos = '\0';
seed++;
for (t = seed; 0 <= --index; t >>= 3)
*--pos = '0' + (t & 07);
#else
tmpnam (tmp_filename);
#endif
}
/* Open directory and returns a DIR pointer. */
DIR* __gnat_opendir (char *name)
{
#if defined (__MINGW32__)
TCHAR wname[GNAT_MAX_PATH_LEN];
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
return (DIR*)_topendir (wname);
#else
return opendir (name);
#endif
}
/* Read the next entry in a directory. The returned string points somewhere
in the buffer. */
#if defined (sun) && defined (__SVR4)
/* For Solaris, be sure to use the 64-bit version, otherwise NFS reads may
fail with EOVERFLOW if the server uses 64-bit cookies. */
#define dirent dirent64
#define readdir readdir64
#endif
char *
__gnat_readdir (DIR *dirp, char *buffer, int *len)
{
#if defined (__MINGW32__)
struct _tdirent *dirent = _treaddir ((_TDIR*)dirp);
if (dirent != NULL)
{
WS2SC (buffer, dirent->d_name, GNAT_MAX_PATH_LEN);
*len = strlen (buffer);
return buffer;
}
else
return NULL;
#elif defined (HAVE_READDIR_R)
/* If possible, try to use the thread-safe version. */
if (readdir_r (dirp, buffer) != NULL)
{
*len = strlen (((struct dirent*) buffer)->d_name);
return ((struct dirent*) buffer)->d_name;
}
else
return NULL;
#else
struct dirent *dirent = (struct dirent *) readdir (dirp);
if (dirent != NULL)
{
strcpy (buffer, dirent->d_name);
*len = strlen (buffer);
return buffer;
}
else
return NULL;
#endif
}
/* Close a directory entry. */
int __gnat_closedir (DIR *dirp)
{
#if defined (__MINGW32__)
return _tclosedir ((_TDIR*)dirp);
#else
return closedir (dirp);
#endif
}
/* Returns 1 if readdir is thread safe, 0 otherwise. */
int
__gnat_readdir_is_thread_safe (void)
{
#ifdef HAVE_READDIR_R
return 1;
#else
return 0;
#endif
}
#if defined (_WIN32)
/* Number of seconds between <Jan 1st 1601> and <Jan 1st 1970>. */
static const unsigned long long w32_epoch_offset = 11644473600ULL;
/* Returns the file modification timestamp using Win32 routines which are
immune against daylight saving time change. It is in fact not possible to
use fstat for this purpose as the DST modify the st_mtime field of the
stat structure. */
static time_t
win32_filetime (HANDLE h)
{
union
{
FILETIME ft_time;
unsigned long long ull_time;
} t_write;
/* GetFileTime returns FILETIME data which are the number of 100 nanosecs
since <Jan 1st 1601>. This function must return the number of seconds
since <Jan 1st 1970>. */
if (GetFileTime (h, NULL, NULL, &t_write.ft_time))
return (time_t) (t_write.ull_time / 10000000ULL - w32_epoch_offset);
return (time_t) 0;
}
/* As above but starting from a FILETIME. */
static void
f2t (const FILETIME *ft, __time64_t *t)
{
union
{
FILETIME ft_time;
unsigned long long ull_time;
} t_write;
t_write.ft_time = *ft;
*t = (__time64_t) (t_write.ull_time / 10000000ULL - w32_epoch_offset);
}
#endif
/* Return a GNAT time stamp given a file name. */
OS_Time
__gnat_file_time_name_attr (char* name, struct file_attributes* attr)
{
if (attr->timestamp == (OS_Time)-2) {
#if defined (_WIN32)
BOOL res;
WIN32_FILE_ATTRIBUTE_DATA fad;
__time64_t ret = -1;
TCHAR wname[GNAT_MAX_PATH_LEN];
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
if ((res = GetFileAttributesEx (wname, GetFileExInfoStandard, &fad)))
f2t (&fad.ftLastWriteTime, &ret);
attr->timestamp = (OS_Time) ret;
#else
__gnat_stat_to_attr (-1, name, attr);
#endif
}
return attr->timestamp;
}
OS_Time
__gnat_file_time_name (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_file_time_name_attr (name, &attr);
}
/* Return a GNAT time stamp given a file descriptor. */
OS_Time
__gnat_file_time_fd_attr (int fd, struct file_attributes* attr)
{
if (attr->timestamp == (OS_Time)-2) {
#if defined (_WIN32)
HANDLE h = (HANDLE) _get_osfhandle (fd);
time_t ret = win32_filetime (h);
attr->timestamp = (OS_Time) ret;
#else
__gnat_stat_to_attr (fd, NULL, attr);
#endif
}
return attr->timestamp;
}
OS_Time
__gnat_file_time_fd (int fd)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_file_time_fd_attr (fd, &attr);
}
/* Set the file time stamp. */
void
__gnat_set_file_time_name (char *name, time_t time_stamp)
{
#if defined (__vxworks)
/* Code to implement __gnat_set_file_time_name for these systems. */
#elif defined (_WIN32)
union
{
FILETIME ft_time;
unsigned long long ull_time;
} t_write;
TCHAR wname[GNAT_MAX_PATH_LEN];
S2WSC (wname, name, GNAT_MAX_PATH_LEN);
HANDLE h = CreateFile
(wname, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (h == INVALID_HANDLE_VALUE)
return;
/* Add number of seconds between <Jan 1st 1601> and <Jan 1st 1970> */
t_write.ull_time = ((unsigned long long)time_stamp + w32_epoch_offset);
/* Convert to 100 nanosecond units */
t_write.ull_time *= 10000000ULL;
SetFileTime(h, NULL, NULL, &t_write.ft_time);
CloseHandle (h);
return;
#else
struct utimbuf utimbuf;
time_t t;
/* Set modification time to requested time. */
utimbuf.modtime = time_stamp;
/* Set access time to now in local time. */
t = time ((time_t) 0);
utimbuf.actime = mktime (localtime (&t));
utime (name, &utimbuf);
#endif
}
/* Get the list of installed standard libraries from the
HKEY_LOCAL_MACHINE\SOFTWARE\Ada Core Technologies\GNAT\Standard Libraries
key. */
char *
__gnat_get_libraries_from_registry (void)
{
char *result = (char *) xmalloc (1);
result[0] = '\0';
#if defined (_WIN32) && ! defined (__vxworks) && ! defined (IS_CROSS)
HKEY reg_key;
DWORD name_size, value_size;
char name[256];
char value[256];
DWORD type;
DWORD index;
LONG res;
/* First open the key. */
res = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ, ®_key);
if (res == ERROR_SUCCESS)
res = RegOpenKeyExA (reg_key, "Ada Core Technologies", 0,
KEY_READ, ®_key);
if (res == ERROR_SUCCESS)
res = RegOpenKeyExA (reg_key, "GNAT", 0, KEY_READ, ®_key);
if (res == ERROR_SUCCESS)
res = RegOpenKeyExA (reg_key, "Standard Libraries", 0, KEY_READ, ®_key);
/* If the key exists, read out all the values in it and concatenate them
into a path. */
for (index = 0; res == ERROR_SUCCESS; index++)
{
value_size = name_size = 256;
res = RegEnumValueA (reg_key, index, name, &name_size, 0,
&type, (LPBYTE)value, &value_size);
if (res == ERROR_SUCCESS && type == REG_SZ)
{
char *old_result = result;
result = (char *) xmalloc (strlen (old_result) + value_size + 2);
strcpy (result, old_result);
strcat (result, value);
strcat (result, ";");
free (old_result);
}
}
/* Remove the trailing ";". */
if (result[0] != 0)
result[strlen (result) - 1] = 0;
#endif
return result;
}
/* Query information for the given file NAME and return it in STATBUF.
* Returns 0 for success, or errno value for failure.
*/
int
__gnat_stat (char *name, GNAT_STRUCT_STAT *statbuf)
{
#ifdef __MINGW32__
WIN32_FILE_ATTRIBUTE_DATA fad;
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
int name_len;
BOOL res;
DWORD error;
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
name_len = _tcslen (wname);
if (name_len > GNAT_MAX_PATH_LEN)
return EINVAL;
ZeroMemory (statbuf, sizeof(GNAT_STRUCT_STAT));
res = GetFileAttributesEx (wname, GetFileExInfoStandard, &fad);
if (res == FALSE) {
error = GetLastError();
/* Check file existence using GetFileAttributes() which does not fail on
special Windows files like con:, aux:, nul: etc... */
if (GetFileAttributes(wname) != INVALID_FILE_ATTRIBUTES) {
/* Just pretend that it is a regular and readable file */
statbuf->st_mode = S_IFREG | S_IREAD | S_IWRITE;
return 0;
}
switch (error) {
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
case ERROR_SHARING_BUFFER_EXCEEDED:
return EACCES;
case ERROR_BUFFER_OVERFLOW:
return ENAMETOOLONG;
case ERROR_NOT_ENOUGH_MEMORY:
return ENOMEM;
default:
return ENOENT;
}
}
f2t (&fad.ftCreationTime, &statbuf->st_ctime);
f2t (&fad.ftLastWriteTime, &statbuf->st_mtime);
f2t (&fad.ftLastAccessTime, &statbuf->st_atime);
statbuf->st_size =
(__int64)fad.nFileSizeLow | (__int64)fad.nFileSizeHigh << 32;
/* We do not have the S_IEXEC attribute, but this is not used on GNAT. */
statbuf->st_mode = S_IREAD;
if (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
statbuf->st_mode |= S_IFDIR;
else
statbuf->st_mode |= S_IFREG;
if (!(fad.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
statbuf->st_mode |= S_IWRITE;
return 0;
#else
return GNAT_STAT (name, statbuf) == 0 ? 0 : errno;
#endif
}
/*************************************************************************
** Check whether a file exists
*************************************************************************/
int
__gnat_file_exists_attr (char* name, struct file_attributes* attr)
{
if (attr->exists == ATTR_UNSET)
__gnat_stat_to_attr (-1, name, attr);
return attr->exists;
}
int
__gnat_file_exists (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_file_exists_attr (name, &attr);
}
/**********************************************************************
** Whether name is an absolute path
**********************************************************************/
int
__gnat_is_absolute_path (char *name, int length)
{
#ifdef __vxworks
/* On VxWorks systems, an absolute path can be represented (depending on
the host platform) as either /dir/file, or device:/dir/file, or
device:drive_letter:/dir/file. */
int index;
if (name[0] == '/')
return 1;
for (index = 0; index < length; index++)
{
if (name[index] == ':' &&
((name[index + 1] == '/') ||
(isalpha (name[index + 1]) && index + 2 <= length &&
name[index + 2] == '/')))
return 1;
else if (name[index] == '/')
return 0;
}
return 0;
#else
return (length != 0) &&
(*name == '/' || *name == DIR_SEPARATOR
#if defined (WINNT)
|| (length > 1 && ISALPHA (name[0]) && name[1] == ':')
#endif
);
#endif
}
int
__gnat_is_regular_file_attr (char* name, struct file_attributes* attr)
{
if (attr->regular == ATTR_UNSET)
__gnat_stat_to_attr (-1, name, attr);
return attr->regular;
}
int
__gnat_is_regular_file (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_regular_file_attr (name, &attr);
}
int
__gnat_is_regular_file_fd (int fd)
{
int ret;
GNAT_STRUCT_STAT statbuf;
ret = GNAT_FSTAT (fd, &statbuf);
return (!ret && S_ISREG (statbuf.st_mode));
}
int
__gnat_is_directory_attr (char* name, struct file_attributes* attr)
{
if (attr->directory == ATTR_UNSET)
__gnat_stat_to_attr (-1, name, attr);
return attr->directory;
}
int
__gnat_is_directory (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_directory_attr (name, &attr);
}
#if defined (_WIN32)
/* Returns the same constant as GetDriveType but takes a pathname as
argument. */
static UINT
GetDriveTypeFromPath (TCHAR *wfullpath)
{
TCHAR wdrv[MAX_PATH];
TCHAR wpath[MAX_PATH];
TCHAR wfilename[MAX_PATH];
TCHAR wext[MAX_PATH];
_tsplitpath (wfullpath, wdrv, wpath, wfilename, wext);
if (_tcslen (wdrv) != 0)
{
/* we have a drive specified. */
_tcscat (wdrv, _T("\\"));
return GetDriveType (wdrv);
}
else
{
/* No drive specified. */
/* Is this a relative path, if so get current drive type. */
if (wpath[0] != _T('\\') ||
(_tcslen (wpath) > 2 && wpath[0] == _T('\\')
&& wpath[1] != _T('\\')))
return GetDriveType (NULL);
UINT result = GetDriveType (wpath);
/* Cannot guess the drive type, is this \\.\ ? */
if (result == DRIVE_NO_ROOT_DIR &&
_tcslen (wpath) >= 4 && wpath[0] == _T('\\') && wpath[1] == _T('\\')
&& wpath[2] == _T('.') && wpath[3] == _T('\\'))
{
if (_tcslen (wpath) == 4)
_tcscat (wpath, wfilename);
LPTSTR p = &wpath[4];
LPTSTR b = _tcschr (p, _T('\\'));
if (b != NULL)
{
/* logical drive \\.\c\dir\file */
*b++ = _T(':');
*b++ = _T('\\');
*b = _T('\0');
}
else
_tcscat (p, _T(":\\"));
return GetDriveType (p);
}
return result;
}
}
/* This MingW section contains code to work with ACL. */
static int
__gnat_check_OWNER_ACL (TCHAR *wname,
DWORD CheckAccessDesired,
GENERIC_MAPPING CheckGenericMapping)
{
DWORD dwAccessDesired, dwAccessAllowed;
PRIVILEGE_SET PrivilegeSet;
DWORD dwPrivSetSize = sizeof (PRIVILEGE_SET);
BOOL fAccessGranted = FALSE;
HANDLE hToken = NULL;
DWORD nLength = 0;
PSECURITY_DESCRIPTOR pSD = NULL;
GetFileSecurity
(wname, OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
NULL, 0, &nLength);
if ((pSD = (SECURITY_DESCRIPTOR *) HeapAlloc
(GetProcessHeap (), HEAP_ZERO_MEMORY, nLength)) == NULL)
return 0;
/* Obtain the security descriptor. */
if (!GetFileSecurity
(wname, OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
pSD, nLength, &nLength))
goto error;
if (!ImpersonateSelf (SecurityImpersonation))
goto error;
if (!OpenThreadToken
(GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken))
goto error;
/* Undoes the effect of ImpersonateSelf. */
RevertToSelf ();
/* We want to test for write permissions. */
dwAccessDesired = CheckAccessDesired;
MapGenericMask (&dwAccessDesired, &CheckGenericMapping);
if (!AccessCheck
(pSD , /* security descriptor to check */
hToken, /* impersonation token */
dwAccessDesired, /* requested access rights */
&CheckGenericMapping, /* pointer to GENERIC_MAPPING */
&PrivilegeSet, /* receives privileges used in check */
&dwPrivSetSize, /* size of PrivilegeSet buffer */
&dwAccessAllowed, /* receives mask of allowed access rights */
&fAccessGranted))
goto error;
CloseHandle (hToken);
HeapFree (GetProcessHeap (), 0, pSD);
return fAccessGranted;
error:
if (hToken)
CloseHandle (hToken);
HeapFree (GetProcessHeap (), 0, pSD);
return 0;
}
static void
__gnat_set_OWNER_ACL (TCHAR *wname,
ACCESS_MODE AccessMode,
DWORD AccessPermissions)
{
PACL pOldDACL = NULL;
PACL pNewDACL = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
EXPLICIT_ACCESS ea;
TCHAR username [100];
DWORD unsize = 100;
/* Get current user, he will act as the owner */
if (!GetUserName (username, &unsize))
return;
if (GetNamedSecurityInfo
(wname,
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
NULL, NULL, &pOldDACL, NULL, &pSD) != ERROR_SUCCESS)
return;
BuildExplicitAccessWithName
(&ea, username, AccessPermissions, (ACCESS_MODE) AccessMode, NO_INHERITANCE);
if (AccessMode == SET_ACCESS)
{
/* SET_ACCESS, we want to set an explicte set of permissions, do not
merge with current DACL. */
if (SetEntriesInAcl (1, &ea, NULL, &pNewDACL) != ERROR_SUCCESS)
return;
}
else
if (SetEntriesInAcl (1, &ea, pOldDACL, &pNewDACL) != ERROR_SUCCESS)
return;
if (SetNamedSecurityInfo
(wname, SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION, NULL, NULL, pNewDACL, NULL) != ERROR_SUCCESS)
return;
LocalFree (pSD);
LocalFree (pNewDACL);
}
/* Check if it is possible to use ACL for wname, the file must not be on a
network drive. */
static int
__gnat_can_use_acl (TCHAR *wname)
{
return __gnat_use_acl && GetDriveTypeFromPath (wname) != DRIVE_REMOTE;
}
#endif /* defined (_WIN32) */
int
__gnat_is_readable_file_attr (char* name, struct file_attributes* attr)
{
if (attr->readable == ATTR_UNSET)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
GENERIC_MAPPING GenericMapping;
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
{
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
GenericMapping.GenericRead = GENERIC_READ;
attr->readable =
__gnat_check_OWNER_ACL (wname, FILE_READ_DATA, GenericMapping);
}
else
attr->readable = GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES;
#else
__gnat_stat_to_attr (-1, name, attr);
#endif
}
return attr->readable;
}
int
__gnat_is_readable_file (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_readable_file_attr (name, &attr);
}
int
__gnat_is_writable_file_attr (char* name, struct file_attributes* attr)
{
if (attr->writable == ATTR_UNSET)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
GENERIC_MAPPING GenericMapping;
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
{
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
GenericMapping.GenericWrite = GENERIC_WRITE;
attr->writable = __gnat_check_OWNER_ACL
(wname, FILE_WRITE_DATA | FILE_APPEND_DATA, GenericMapping)
&& !(GetFileAttributes (wname) & FILE_ATTRIBUTE_READONLY);
}
else
attr->writable =
!(GetFileAttributes (wname) & FILE_ATTRIBUTE_READONLY);
#else
__gnat_stat_to_attr (-1, name, attr);
#endif
}
return attr->writable;
}
int
__gnat_is_writable_file (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_writable_file_attr (name, &attr);
}
int
__gnat_is_executable_file_attr (char* name, struct file_attributes* attr)
{
if (attr->executable == ATTR_UNSET)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
GENERIC_MAPPING GenericMapping;
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
{
ZeroMemory (&GenericMapping, sizeof (GENERIC_MAPPING));
GenericMapping.GenericExecute = GENERIC_EXECUTE;
attr->executable =
__gnat_check_OWNER_ACL (wname, FILE_EXECUTE, GenericMapping);
}
else
{
TCHAR *l, *last = _tcsstr(wname, _T(".exe"));
/* look for last .exe */
if (last)
while ((l = _tcsstr(last+1, _T(".exe"))))
last = l;
attr->executable =
GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES
&& (last - wname) == (int) (_tcslen (wname) - 4);
}
#else
__gnat_stat_to_attr (-1, name, attr);
#endif
}
return attr->regular && attr->executable;
}
int
__gnat_is_executable_file (char *name)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_executable_file_attr (name, &attr);
}
void
__gnat_set_writable (char *name)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_WRITE);
SetFileAttributes
(wname, GetFileAttributes (wname) & ~FILE_ATTRIBUTE_READONLY);
#elif ! (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
GNAT_STRUCT_STAT statbuf;
if (GNAT_STAT (name, &statbuf) == 0)
{
statbuf.st_mode = statbuf.st_mode | S_IWUSR;
chmod (name, statbuf.st_mode);
}
#endif
}
/* must match definition in s-os_lib.ads */
#define S_OWNER 1
#define S_GROUP 2
#define S_OTHERS 4
void
__gnat_set_executable (char *name, int mode ATTRIBUTE_UNUSED)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_EXECUTE);
#elif ! (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
GNAT_STRUCT_STAT statbuf;
if (GNAT_STAT (name, &statbuf) == 0)
{
if (mode & S_OWNER)
statbuf.st_mode = statbuf.st_mode | S_IXUSR;
if (mode & S_GROUP)
statbuf.st_mode = statbuf.st_mode | S_IXGRP;
if (mode & S_OTHERS)
statbuf.st_mode = statbuf.st_mode | S_IXOTH;
chmod (name, statbuf.st_mode);
}
#endif
}
void
__gnat_set_non_writable (char *name)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
__gnat_set_OWNER_ACL
(wname, DENY_ACCESS,
FILE_WRITE_DATA | FILE_APPEND_DATA |
FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES);
SetFileAttributes
(wname, GetFileAttributes (wname) | FILE_ATTRIBUTE_READONLY);
#elif ! (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
GNAT_STRUCT_STAT statbuf;
if (GNAT_STAT (name, &statbuf) == 0)
{
statbuf.st_mode = statbuf.st_mode & 07577;
chmod (name, statbuf.st_mode);
}
#endif
}
void
__gnat_set_readable (char *name)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
__gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_READ);
#elif ! (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
GNAT_STRUCT_STAT statbuf;
if (GNAT_STAT (name, &statbuf) == 0)
{
chmod (name, statbuf.st_mode | S_IREAD);
}
#endif
}
void
__gnat_set_non_readable (char *name)
{
#if defined (_WIN32)
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
if (__gnat_can_use_acl (wname))
__gnat_set_OWNER_ACL (wname, DENY_ACCESS, FILE_GENERIC_READ);
#elif ! (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
GNAT_STRUCT_STAT statbuf;
if (GNAT_STAT (name, &statbuf) == 0)
{
chmod (name, statbuf.st_mode & (~S_IREAD));
}
#endif
}
int
__gnat_is_symbolic_link_attr (char* name ATTRIBUTE_UNUSED,
struct file_attributes* attr)
{
if (attr->symbolic_link == ATTR_UNSET)
{
#if defined (__vxworks)
attr->symbolic_link = 0;
#elif defined (_AIX) || defined (__APPLE__) || defined (__unix__)
int ret;
GNAT_STRUCT_STAT statbuf;
ret = GNAT_LSTAT (name, &statbuf);
attr->symbolic_link = (!ret && S_ISLNK (statbuf.st_mode));
#else
attr->symbolic_link = 0;
#endif
}
return attr->symbolic_link;
}
int
__gnat_is_symbolic_link (char *name ATTRIBUTE_UNUSED)
{
struct file_attributes attr;
__gnat_reset_attributes (&attr);
return __gnat_is_symbolic_link_attr (name, &attr);
}
#if defined (sun) && defined (__SVR4)
/* Using fork on Solaris will duplicate all the threads. fork1, which
duplicates only the active thread, must be used instead, or spawning
subprocess from a program with tasking will lead into numerous problems. */
#define fork fork1
#endif
int
__gnat_portable_spawn (char *args[] ATTRIBUTE_UNUSED)
{
int status ATTRIBUTE_UNUSED = 0;
int finished ATTRIBUTE_UNUSED;
int pid ATTRIBUTE_UNUSED;
#if defined (__vxworks) || defined(__PikeOS__)
return -1;
#elif defined (_WIN32)
/* args[0] must be quotes as it could contain a full pathname with spaces */
char *args_0 = args[0];
args[0] = (char *)xmalloc (strlen (args_0) + 3);
strcpy (args[0], "\"");
strcat (args[0], args_0);
strcat (args[0], "\"");
status = spawnvp (P_WAIT, args_0, (char ** const)args);
/* restore previous value */
free (args[0]);
args[0] = (char *)args_0;
if (status < 0)
return -1;
else
return status;
#else
pid = fork ();
if (pid < 0)
return -1;
if (pid == 0)
{
/* The child. */
if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0)
_exit (1);
}
/* The parent. */
finished = waitpid (pid, &status, 0);
if (finished != pid || WIFEXITED (status) == 0)
return -1;
return WEXITSTATUS (status);
#endif
return 0;
}
/* Create a copy of the given file descriptor.
Return -1 if an error occurred. */
int
__gnat_dup (int oldfd)
{
#if defined (__vxworks) && !defined (__RTP__)
/* Not supported on VxWorks 5.x, but supported on VxWorks 6.0 when using
RTPs. */
return -1;
#else
return dup (oldfd);
#endif
}
/* Make newfd be the copy of oldfd, closing newfd first if necessary.
Return -1 if an error occurred. */
int
__gnat_dup2 (int oldfd ATTRIBUTE_UNUSED, int newfd ATTRIBUTE_UNUSED)
{
#if defined (__vxworks) && !defined (__RTP__)
/* Not supported on VxWorks 5.x, but supported on VxWorks 6.0 when using
RTPs. */
return -1;
#elif defined (__PikeOS__)
/* Not supported. */
return -1;
#elif defined (_WIN32)
/* Special case when oldfd and newfd are identical and are the standard
input, output or error as this makes Windows XP hangs. Note that we
do that only for standard file descriptors that are known to be valid. */
if (oldfd == newfd && newfd >= 0 && newfd <= 2)
return newfd;
else
return dup2 (oldfd, newfd);
#else
return dup2 (oldfd, newfd);
#endif
}
int
__gnat_number_of_cpus (void)
{
int cores = 1;
#if defined (linux) || defined (sun) || defined (AIX) || defined (__APPLE__)
cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
#elif defined (__hpux__)
struct pst_dynamic psd;
if (pstat_getdynamic (&psd, sizeof (psd), 1, 0) != -1)
cores = (int) psd.psd_proc_cnt;
#elif defined (_WIN32)
SYSTEM_INFO sysinfo;
GetSystemInfo (&sysinfo);
cores = (int) sysinfo.dwNumberOfProcessors;
#elif defined (_WRS_CONFIG_SMP)
unsigned int vxCpuConfiguredGet (void);
cores = vxCpuConfiguredGet ();
#endif
return cores;
}
/* WIN32 code to implement a wait call that wait for any child process. */
#if defined (_WIN32)
/* Synchronization code, to be thread safe. */
#ifdef CERT
/* For the Cert run times on native Windows we use dummy functions
for locking and unlocking tasks since we do not support multiple
threads on this configuration (Cert run time on native Windows). */
static void EnterCS (void) {}
static void LeaveCS (void) {}
static void SignalListChanged (void) {}
#else
CRITICAL_SECTION ProcListCS;
HANDLE ProcListEvt = NULL;
static void EnterCS (void)
{
EnterCriticalSection(&ProcListCS);
}
static void LeaveCS (void)
{
LeaveCriticalSection(&ProcListCS);
}
static void SignalListChanged (void)
{
SetEvent (ProcListEvt);
}
#endif
static HANDLE *HANDLES_LIST = NULL;
static int *PID_LIST = NULL, plist_length = 0, plist_max_length = 0;
static void
add_handle (HANDLE h, int pid)
{
/* -------------------- critical section -------------------- */
EnterCS();
if (plist_length == plist_max_length)
{
plist_max_length += 100;
HANDLES_LIST =
(HANDLE *) xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length);
PID_LIST =
(int *) xrealloc (PID_LIST, sizeof (int) * plist_max_length);
}
HANDLES_LIST[plist_length] = h;
PID_LIST[plist_length] = pid;
++plist_length;
SignalListChanged();
LeaveCS();
/* -------------------- critical section -------------------- */
}
int
__gnat_win32_remove_handle (HANDLE h, int pid)
{
int j;
int found = 0;
/* -------------------- critical section -------------------- */
EnterCS();
for (j = 0; j < plist_length; j++)
{
if ((HANDLES_LIST[j] == h) || (PID_LIST[j] == pid))
{
CloseHandle (h);
--plist_length;
HANDLES_LIST[j] = HANDLES_LIST[plist_length];
PID_LIST[j] = PID_LIST[plist_length];
found = 1;
break;
}
}
LeaveCS();
/* -------------------- critical section -------------------- */
if (found)
SignalListChanged();
return found;
}
static void
win32_no_block_spawn (char *command, char *args[], HANDLE *h, int *pid)
{
BOOL result;
STARTUPINFO SI;
PROCESS_INFORMATION PI;
SECURITY_ATTRIBUTES SA;
int csize = 1;
char *full_command;
int k;
/* compute the total command line length */
k = 0;
while (args[k])
{
csize += strlen (args[k]) + 1;
k++;
}
full_command = (char *) xmalloc (csize);
/* Startup info. */
SI.cb = sizeof (STARTUPINFO);
SI.lpReserved = NULL;
SI.lpReserved2 = NULL;
SI.lpDesktop = NULL;
SI.cbReserved2 = 0;
SI.lpTitle = NULL;
SI.dwFlags = 0;
SI.wShowWindow = SW_HIDE;
/* Security attributes. */
SA.nLength = sizeof (SECURITY_ATTRIBUTES);
SA.bInheritHandle = TRUE;
SA.lpSecurityDescriptor = NULL;
/* Prepare the command string. */
strcpy (full_command, command);
strcat (full_command, " ");
k = 1;
while (args[k])
{
strcat (full_command, args[k]);
strcat (full_command, " ");
k++;
}
{
int wsize = csize * 2;
TCHAR *wcommand = (TCHAR *) xmalloc (wsize);
S2WSC (wcommand, full_command, wsize);
free (full_command);
result = CreateProcess
(NULL, wcommand, &SA, NULL, TRUE,
GetPriorityClass (GetCurrentProcess()), NULL, NULL, &SI, &PI);
free (wcommand);
}
if (result == TRUE)
{
CloseHandle (PI.hThread);
*h = PI.hProcess;
*pid = PI.dwProcessId;
}
else
{
*h = NULL;
*pid = 0;
}
}
static int
win32_wait (int *status)
{
DWORD exitcode, pid;
HANDLE *hl;
HANDLE h;
int *pidl;
DWORD res;
int hl_len;
int found;
START_WAIT:
if (plist_length == 0)
{
errno = ECHILD;
return -1;
}
/* -------------------- critical section -------------------- */
EnterCS();
hl_len = plist_length;
#ifdef CERT
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len);
memmove (hl, HANDLES_LIST, sizeof (HANDLE) * hl_len);
pidl = (int *) xmalloc (sizeof (int) * hl_len);
memmove (pidl, PID_LIST, sizeof (int) * hl_len);
#else
/* Note that index 0 contains the event handle that is signaled when the
process list has changed */
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len + 1);
hl[0] = ProcListEvt;
memmove (&hl[1], HANDLES_LIST, sizeof (HANDLE) * hl_len);
pidl = (int *) xmalloc (sizeof (int) * hl_len + 1);
memmove (&pidl[1], PID_LIST, sizeof (int) * hl_len);
hl_len++;
#endif
LeaveCS();
/* -------------------- critical section -------------------- */
res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE);
/* if the ProcListEvt has been signaled then the list of processes has been
updated to add or remove a handle, just loop over */
if (res - WAIT_OBJECT_0 == 0)
{
free (hl);
free (pidl);
goto START_WAIT;
}
h = hl[res - WAIT_OBJECT_0];
GetExitCodeProcess (h, &exitcode);
pid = pidl [res - WAIT_OBJECT_0];
found = __gnat_win32_remove_handle (h, -1);
free (hl);
free (pidl);
/* if not found another process waiting has already handled this process */
if (!found)
{
goto START_WAIT;
}
*status = (int) exitcode;
return (int) pid;
}
#endif
int
__gnat_portable_no_block_spawn (char *args[] ATTRIBUTE_UNUSED)
{
#if defined (__vxworks) || defined (__PikeOS__)
/* Not supported. */
return -1;
#elif defined (_WIN32)
HANDLE h = NULL;
int pid;
win32_no_block_spawn (args[0], args, &h, &pid);
if (h != NULL)
{
add_handle (h, pid);
return pid;
}
else
return -1;
#else
int pid = fork ();
if (pid == 0)
{
/* The child. */
if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0)
_exit (1);
}
return pid;
#endif
}
int
__gnat_portable_wait (int *process_status)
{
int status = 0;
int pid = 0;
#if defined (__vxworks) || defined (__PikeOS__)
/* Not sure what to do here, so do nothing but return zero. */
#elif defined (_WIN32)
pid = win32_wait (&status);
#else
pid = waitpid (-1, &status, 0);
status = status & 0xffff;
#endif
*process_status = status;
return pid;
}
void
__gnat_os_exit (int status)
{
exit (status);
}
/* Locate file on path, that matches a predicate */
char *
__gnat_locate_file_with_predicate (char *file_name, char *path_val,
int (*predicate)(char *))
{
char *ptr;
char *file_path = (char *) alloca (strlen (file_name) + 1);
int absolute;
/* Return immediately if file_name is empty */
if (*file_name == '\0')
return 0;
/* Remove quotes around file_name if present */
ptr = file_name;
if (*ptr == '"')
ptr++;
strcpy (file_path, ptr);
ptr = file_path + strlen (file_path) - 1;
if (*ptr == '"')
*ptr = '\0';
/* Handle absolute pathnames. */
absolute = __gnat_is_absolute_path (file_path, strlen (file_name));
if (absolute)
{
if (predicate (file_path))
return xstrdup (file_path);
return 0;
}
/* If file_name include directory separator(s), try it first as
a path name relative to the current directory */
for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR; ptr++)
;
if (*ptr != 0)
{
if (predicate (file_name))
return xstrdup (file_name);
}
if (path_val == 0)
return 0;
{
/* The result has to be smaller than path_val + file_name. */
char *file_path =
(char *) alloca (strlen (path_val) + strlen (file_name) + 2);
for (;;)
{
/* Skip the starting quote */
if (*path_val == '"')
path_val++;
for (ptr = file_path; *path_val && *path_val != PATH_SEPARATOR; )
*ptr++ = *path_val++;
/* If directory is empty, it is the current directory*/
if (ptr == file_path)
{
*ptr = '.';
}
else
ptr--;
/* Skip the ending quote */
if (*ptr == '"')
ptr--;
if (*ptr != '/' && *ptr != DIR_SEPARATOR)
*++ptr = DIR_SEPARATOR;
strcpy (++ptr, file_name);
if (predicate (file_path))
return xstrdup (file_path);
if (*path_val == 0)
return 0;
/* Skip path separator */
path_val++;
}
}
return 0;
}
/* Locate an executable file, give a Path value. */
char *
__gnat_locate_executable_file (char *file_name, char *path_val)
{
return __gnat_locate_file_with_predicate
(file_name, path_val, &__gnat_is_executable_file);
}
/* Locate a regular file, give a Path value. */
char *
__gnat_locate_regular_file (char *file_name, char *path_val)
{
return __gnat_locate_file_with_predicate
(file_name, path_val, &__gnat_is_regular_file);
}
/* Locate an executable given a Path argument. This routine is only used by
gnatbl and should not be used otherwise. Use locate_exec_on_path
instead. */
char *
__gnat_locate_exec (char *exec_name, char *path_val)
{
char *ptr;
if (!strstr (exec_name, HOST_EXECUTABLE_SUFFIX))
{
char *full_exec_name =
(char *) alloca
(strlen (exec_name) + strlen (HOST_EXECUTABLE_SUFFIX) + 1);
strcpy (full_exec_name, exec_name);
strcat (full_exec_name, HOST_EXECUTABLE_SUFFIX);
ptr = __gnat_locate_executable_file (full_exec_name, path_val);
if (ptr == 0)
return __gnat_locate_executable_file (exec_name, path_val);
return ptr;
}
else
return __gnat_locate_executable_file (exec_name, path_val);
}
/* Locate an executable using the Systems default PATH. */
char *
__gnat_locate_exec_on_path (char *exec_name)
{
char *apath_val;
#if defined (_WIN32)
TCHAR *wpath_val = _tgetenv (_T("PATH"));
TCHAR *wapath_val;
/* In Win32 systems we expand the PATH as for XP environment
variables are not automatically expanded. We also prepend the
".;" to the path to match normal NT path search semantics */
#define EXPAND_BUFFER_SIZE 32767
wapath_val = (TCHAR *) alloca (EXPAND_BUFFER_SIZE);
wapath_val [0] = '.';
wapath_val [1] = ';';
DWORD res = ExpandEnvironmentStrings
(wpath_val, &wapath_val[2], EXPAND_BUFFER_SIZE - 2);
if (!res) wapath_val [0] = _T('\0');
apath_val = (char *) alloca (EXPAND_BUFFER_SIZE);
WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE);
return __gnat_locate_exec (exec_name, apath_val);
#else
char *path_val = getenv ("PATH");
if (path_val == NULL) return NULL;
apath_val = (char *) alloca (strlen (path_val) + 1);
strcpy (apath_val, path_val);
return __gnat_locate_exec (exec_name, apath_val);
#endif
}
/* Dummy functions for Osint import for non-VMS systems.
??? To be removed. */
int
__gnat_to_canonical_file_list_init (char *dirspec ATTRIBUTE_UNUSED,
int onlydirs ATTRIBUTE_UNUSED)
{
return 0;
}
char *
__gnat_to_canonical_file_list_next (void)
{
static char empty[] = "";
return empty;
}
void
__gnat_to_canonical_file_list_free (void)
{
}
char *
__gnat_to_canonical_dir_spec (char *dirspec, int prefixflag ATTRIBUTE_UNUSED)
{
return dirspec;
}
char *
__gnat_to_canonical_file_spec (char *filespec)
{
return filespec;
}
char *
__gnat_to_canonical_path_spec (char *pathspec)
{
return pathspec;
}
char *
__gnat_to_host_dir_spec (char *dirspec, int prefixflag ATTRIBUTE_UNUSED)
{
return dirspec;
}
char *
__gnat_to_host_file_spec (char *filespec)
{
return filespec;
}
void
__gnat_adjust_os_resource_limits (void)
{
}
#if defined (__mips_vxworks)
int
_flush_cache (void)
{
CACHE_USER_FLUSH (0, ENTIRE_CACHE);
}
#endif
#if defined (_WIN32)
int __gnat_argument_needs_quote = 1;
#else
int __gnat_argument_needs_quote = 0;
#endif
/* This option is used to enable/disable object files handling from the
binder file by the GNAT Project module. For example, this is disabled on
Windows (prior to GCC 3.4) as it is already done by the mdll module.
Stating with GCC 3.4 the shared libraries are not based on mdll
anymore as it uses the GCC's -shared option */
#if defined (_WIN32) \
&& ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)))
int __gnat_prj_add_obj_files = 0;
#else
int __gnat_prj_add_obj_files = 1;
#endif
/* char used as prefix/suffix for environment variables */
#if defined (_WIN32)
char __gnat_environment_char = '%';
#else
char __gnat_environment_char = '$';
#endif
/* This functions copy the file attributes from a source file to a
destination file.
mode = 0 : In this mode copy only the file time stamps (last access and
last modification time stamps).
mode = 1 : In this mode, time stamps and read/write/execute attributes are
copied.
Returns 0 if operation was successful and -1 in case of error. */
int
__gnat_copy_attribs (char *from ATTRIBUTE_UNUSED, char *to ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{
#if (defined (__vxworks) && _WRS_VXWORKS_MAJOR < 6)
return -1;
#elif defined (_WIN32)
TCHAR wfrom [GNAT_MAX_PATH_LEN + 2];
TCHAR wto [GNAT_MAX_PATH_LEN + 2];
BOOL res;
FILETIME fct, flat, flwt;
HANDLE hfrom, hto;
S2WSC (wfrom, from, GNAT_MAX_PATH_LEN + 2);
S2WSC (wto, to, GNAT_MAX_PATH_LEN + 2);
/* retrieve from times */
hfrom = CreateFile
(wfrom, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hfrom == INVALID_HANDLE_VALUE)
return -1;
res = GetFileTime (hfrom, &fct, &flat, &flwt);
CloseHandle (hfrom);
if (res == 0)
return -1;
/* retrieve from times */
hto = CreateFile
(wto, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hto == INVALID_HANDLE_VALUE)
return -1;
res = SetFileTime (hto, NULL, &flat, &flwt);
CloseHandle (hto);
if (res == 0)
return -1;
/* Set file attributes in full mode. */
if (mode == 1)
{
DWORD attribs = GetFileAttributes (wfrom);
if (attribs == INVALID_FILE_ATTRIBUTES)
return -1;
res = SetFileAttributes (wto, attribs);
if (res == 0)
return -1;
}
return 0;
#else
GNAT_STRUCT_STAT fbuf;
struct utimbuf tbuf;
if (GNAT_STAT (from, &fbuf) == -1)
{
return -1;
}
tbuf.actime = fbuf.st_atime;
tbuf.modtime = fbuf.st_mtime;
if (utime (to, &tbuf) == -1)
{
return -1;
}
if (mode == 1)
{
if (chmod (to, fbuf.st_mode) == -1)
{
return -1;
}
}
return 0;
#endif
}
int
__gnat_lseek (int fd, long offset, int whence)
{
return (int) lseek (fd, offset, whence);
}
/* This function returns the major version number of GCC being used. */
int
get_gcc_version (void)
{
#ifdef IN_RTS
return __GNUC__;
#else
return (int) (version_string[0] - '0');
#endif
}
/*
* Set Close_On_Exec as indicated.
* Note: this is used for both GNAT.OS_Lib and GNAT.Sockets.
*/
int
__gnat_set_close_on_exec (int fd ATTRIBUTE_UNUSED,
int close_on_exec_p ATTRIBUTE_UNUSED)
{
#if defined (F_GETFD) && defined (FD_CLOEXEC) && ! defined (__vxworks)
int flags = fcntl (fd, F_GETFD, 0);
if (flags < 0)
return flags;
if (close_on_exec_p)
flags |= FD_CLOEXEC;
else
flags &= ~FD_CLOEXEC;
return fcntl (fd, F_SETFD, flags);
#elif defined(_WIN32)
HANDLE h = (HANDLE) _get_osfhandle (fd);
if (h == (HANDLE) -1)
return -1;
if (close_on_exec_p)
return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0);
return ! SetHandleInformation (h, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT);
#else
/* TODO: Unimplemented. */
return -1;
#endif
}
/* Indicates if platforms supports automatic initialization through the
constructor mechanism */
int
__gnat_binder_supports_auto_init (void)
{
return 1;
}
/* Indicates that Stand-Alone Libraries are automatically initialized through
the constructor mechanism */
int
__gnat_sals_init_using_constructors (void)
{
#if defined (__vxworks) || defined (__Lynx__)
return 0;
#else
return 1;
#endif
}
#if defined (__ANDROID__)
#include <pthread.h>
void *
__gnat_lwp_self (void)
{
return (void *) pthread_self ();
}
#elif defined (linux)
/* There is no function in the glibc to retrieve the LWP of the current
thread. We need to do a system call in order to retrieve this
information. */
#include <sys/syscall.h>
void *
__gnat_lwp_self (void)
{
return (void *) syscall (__NR_gettid);
}
#include <sched.h>
/* glibc versions earlier than 2.7 do not define the routines to handle
dynamically allocated CPU sets. For these targets, we use the static
versions. */
#ifdef CPU_ALLOC
/* Dynamic cpu sets */
cpu_set_t *
__gnat_cpu_alloc (size_t count)
{
return CPU_ALLOC (count);
}
size_t
__gnat_cpu_alloc_size (size_t count)
{
return CPU_ALLOC_SIZE (count);
}
void
__gnat_cpu_free (cpu_set_t *set)
{
CPU_FREE (set);
}
void
__gnat_cpu_zero (size_t count, cpu_set_t *set)
{
CPU_ZERO_S (count, set);
}
void
__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
{
/* Ada handles CPU numbers starting from 1, while C identifies the first
CPU by a 0, so we need to adjust. */
CPU_SET_S (cpu - 1, count, set);
}
#else /* !CPU_ALLOC */
/* Static cpu sets */
cpu_set_t *
__gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
{
return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
}
size_t
__gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED)
{
return sizeof (cpu_set_t);
}
void
__gnat_cpu_free (cpu_set_t *set)
{
free (set);
}
void
__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
{
CPU_ZERO (set);
}
void
__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
{
/* Ada handles CPU numbers starting from 1, while C identifies the first
CPU by a 0, so we need to adjust. */
CPU_SET (cpu - 1, set);
}
#endif /* !CPU_ALLOC */
#endif /* linux */
/* Return the load address of the executable, or 0 if not known. In the
specific case of error, (void *)-1 can be returned. Beware: this unit may
be in a shared library. As low-level units are needed, we allow #include
here. */
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#elif 0 && defined (__linux__)
#include <link.h>
#endif
const void *
__gnat_get_executable_load_address (void)
{
#if defined (__APPLE__)
return _dyld_get_image_header (0);
#elif 0 && defined (__linux__)
/* Currently disabled as it needs at least -ldl. */
struct link_map *map = _r_debug.r_map;
return (const void *)map->l_addr;
#else
return NULL;
#endif
}
#ifdef __cplusplus
}
#endif
| KubaKaszycki/kubux | gcc/gcc/ada/adaint.c | C | gpl-3.0 | 72,852 |
# (c) 2014 Michael DeHaan, <michael@ansible.com>
#
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from ansible.errors import AnsibleParserError, AnsibleError
from ansible.module_utils._text import to_native
from ansible.module_utils.six import iteritems, string_types
from ansible.playbook.attribute import Attribute, FieldAttribute
from ansible.playbook.base import Base
from ansible.playbook.helpers import load_list_of_roles
from ansible.playbook.role.include import RoleInclude
from ansible.playbook.role.requirement import RoleRequirement
__all__ = ['RoleMetadata']
class RoleMetadata(Base):
'''
This class wraps the parsing and validation of the optional metadata
within each Role (meta/main.yml).
'''
_allow_duplicates = FieldAttribute(isa='bool', default=False)
_dependencies = FieldAttribute(isa='list', default=list)
_galaxy_info = FieldAttribute(isa='GalaxyInfo')
def __init__(self, owner=None):
self._owner = owner
super(RoleMetadata, self).__init__()
@staticmethod
def load(data, owner, variable_manager=None, loader=None):
'''
Returns a new RoleMetadata object based on the datastructure passed in.
'''
if not isinstance(data, dict):
raise AnsibleParserError("the 'meta/main.yml' for role %s is not a dictionary" % owner.get_name())
m = RoleMetadata(owner=owner).load_data(data, variable_manager=variable_manager, loader=loader)
return m
def _load_dependencies(self, attr, ds):
'''
This is a helper loading function for the dependencies list,
which returns a list of RoleInclude objects
'''
roles = []
if ds:
if not isinstance(ds, list):
raise AnsibleParserError("Expected role dependencies to be a list.", obj=self._ds)
for role_def in ds:
if isinstance(role_def, string_types) or 'role' in role_def or 'name' in role_def:
roles.append(role_def)
continue
try:
# role_def is new style: { src: 'galaxy.role,version,name', other_vars: "here" }
def_parsed = RoleRequirement.role_yaml_parse(role_def)
if def_parsed.get('name'):
role_def['name'] = def_parsed['name']
roles.append(role_def)
except AnsibleError as exc:
raise AnsibleParserError(to_native(exc), obj=role_def, orig_exc=exc)
current_role_path = None
if self._owner:
current_role_path = os.path.dirname(self._owner._role_path)
try:
return load_list_of_roles(roles, play=self._owner._play, current_role_path=current_role_path, variable_manager=self._variable_manager,
loader=self._loader)
except AssertionError as e:
raise AnsibleParserError("A malformed list of role dependencies was encountered.", obj=self._ds, orig_exc=e)
def _load_galaxy_info(self, attr, ds):
'''
This is a helper loading function for the galaxy info entry
in the metadata, which returns a GalaxyInfo object rather than
a simple dictionary.
'''
return ds
def serialize(self):
return dict(
allow_duplicates=self._allow_duplicates,
dependencies=self._dependencies,
)
def deserialize(self, data):
setattr(self, 'allow_duplicates', data.get('allow_duplicates', False))
setattr(self, 'dependencies', data.get('dependencies', []))
| andmos/ansible | lib/ansible/playbook/role/metadata.py | Python | gpl-3.0 | 4,362 |
CKEDITOR.plugins.setLang("elementspath","de",{eleLabel:"Elementepfad",eleTitle:"%1 Element"}); | mburggraf/otrs | var/httpd/htdocs/js/thirdparty/ckeditor-4.7.0/plugins/elementspath/lang/de.js | JavaScript | agpl-3.0 | 97 |
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import abc
import importlib
from django.core.exceptions import ImproperlyConfigured
from django.conf import settings
class BaseEventsPushBackend(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def emit_event(self, message:str, *, routing_key:str, channel:str="events"):
pass
def load_class(path):
"""
Load class from path.
"""
mod_name, klass_name = path.rsplit('.', 1)
try:
mod = importlib.import_module(mod_name)
except AttributeError as e:
raise ImproperlyConfigured('Error importing {0}: "{1}"'.format(mod_name, e))
try:
klass = getattr(mod, klass_name)
except AttributeError:
raise ImproperlyConfigured('Module "{0}" does not define a "{1}" class'.format(mod_name, klass_name))
return klass
def get_events_backend(path:str=None, options:dict=None):
if path is None:
path = getattr(settings, "EVENTS_PUSH_BACKEND", None)
if path is None:
raise ImproperlyConfigured("Events push system not configured")
if options is None:
options = getattr(settings, "EVENTS_PUSH_BACKEND_OPTIONS", {})
cls = load_class(path)
return cls(**options)
| WALR/taiga-back | taiga/events/backends/base.py | Python | agpl-3.0 | 1,894 |
kvast
=====
KeyValue storage for AST
To optimize serialized storage use a concatenated
string array and use the sdb array string api
eax=33
------
0.op=set []0=set,eax,33
0.a=eax
0.b=33
ebx=(8*(eax+4))
---------------
0.op=set []0=set,ebx,$1
0.a=ebx
0.b=$1
1.op=mul []1=mul,8,$2
1.a=8
1.b=$2
2.op=add []2=add,eax,4
2.a=eax
2.b=4
ebx=8*(eax+4)+3
---------------
0.op=set []0=set,ebx,$3
0.a=ebx
0.b=$3
1.op=mul []1=mul,8,$2
1.a=8
1.b=$2
2.op=add []2=add,eax,4
2.a=eax
2.b=4
3.op=add []3=add,$1,3
3.a=$1
3.b=3
ebx=8*(eax+4+ecx+2)+1
---------------------
0.op=set
0.a=ebx
0.b=$5
1.op=mul
1.a=8
1.b=$4
(
2.op=add
2.a=eax
2.b=4
// update toplevel b reference
3.op=add
3.a=$2
3.b=ecx
// update toplevel b reference
4.op=add
4.a=$3
4.b=2
}
// update toplevel b reference
5.op=add
5.a=$1
5.b=1
Parsing
=======
Parsing is done by a state machine which reads the expression string and creates a keyvalue string that represents the ESIL instruction.
This is an example
```
switch (ch) {
case '+':
case '-':
case '*':
case '/':
if (expect_arg) {
expect_arg = ch;
}
break;
}
```
| bigendiansmalls/radare2 | doc/kvast.md | Markdown | lgpl-3.0 | 1,178 |
/* zsyt02.f -- translated by f2c (version 20061008).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
#include "blaswrap.h"
/* Table of constant values */
static doublecomplex c_b1 = {1.,0.};
static integer c__1 = 1;
/* Subroutine */ int zsyt02_(char *uplo, integer *n, integer *nrhs,
doublecomplex *a, integer *lda, doublecomplex *x, integer *ldx,
doublecomplex *b, integer *ldb, doublereal *rwork, doublereal *resid)
{
/* System generated locals */
integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
doublereal d__1, d__2;
doublecomplex z__1;
/* Local variables */
integer j;
doublereal eps, anorm, bnorm, xnorm;
extern /* Subroutine */ int zsymm_(char *, char *, integer *, integer *,
doublecomplex *, doublecomplex *, integer *, doublecomplex *,
integer *, doublecomplex *, doublecomplex *, integer *);
extern doublereal dlamch_(char *), dzasum_(integer *,
doublecomplex *, integer *), zlansy_(char *, char *, integer *,
doublecomplex *, integer *, doublereal *);
/* -- LAPACK test routine (version 3.1) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* ZSYT02 computes the residual for a solution to a complex symmetric */
/* system of linear equations A*x = b: */
/* RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ), */
/* where EPS is the machine epsilon. */
/* Arguments */
/* ========= */
/* UPLO (input) CHARACTER*1 */
/* Specifies whether the upper or lower triangular part of the */
/* symmetric matrix A is stored: */
/* = 'U': Upper triangular */
/* = 'L': Lower triangular */
/* N (input) INTEGER */
/* The number of rows and columns of the matrix A. N >= 0. */
/* NRHS (input) INTEGER */
/* The number of columns of B, the matrix of right hand sides. */
/* NRHS >= 0. */
/* A (input) COMPLEX*16 array, dimension (LDA,N) */
/* The original complex symmetric matrix A. */
/* LDA (input) INTEGER */
/* The leading dimension of the array A. LDA >= max(1,N) */
/* X (input) COMPLEX*16 array, dimension (LDX,NRHS) */
/* The computed solution vectors for the system of linear */
/* equations. */
/* LDX (input) INTEGER */
/* The leading dimension of the array X. LDX >= max(1,N). */
/* B (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */
/* On entry, the right hand side vectors for the system of */
/* linear equations. */
/* On exit, B is overwritten with the difference B - A*X. */
/* LDB (input) INTEGER */
/* The leading dimension of the array B. LDB >= max(1,N). */
/* RWORK (workspace) DOUBLE PRECISION array, dimension (N) */
/* RESID (output) DOUBLE PRECISION */
/* The maximum over the number of right hand sides of */
/* norm(B - A*X) / ( norm(A) * norm(X) * EPS ). */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. Executable Statements .. */
/* Quick exit if N = 0 or NRHS = 0 */
/* Parameter adjustments */
a_dim1 = *lda;
a_offset = 1 + a_dim1;
a -= a_offset;
x_dim1 = *ldx;
x_offset = 1 + x_dim1;
x -= x_offset;
b_dim1 = *ldb;
b_offset = 1 + b_dim1;
b -= b_offset;
--rwork;
/* Function Body */
if (*n <= 0 || *nrhs <= 0) {
*resid = 0.;
return 0;
}
/* Exit with RESID = 1/EPS if ANORM = 0. */
eps = dlamch_("Epsilon");
anorm = zlansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
if (anorm <= 0.) {
*resid = 1. / eps;
return 0;
}
/* Compute B - A*X (or B - A'*X ) and store in B . */
z__1.r = -1., z__1.i = -0.;
zsymm_("Left", uplo, n, nrhs, &z__1, &a[a_offset], lda, &x[x_offset], ldx,
&c_b1, &b[b_offset], ldb);
/* Compute the maximum over the number of right hand sides of */
/* norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) . */
*resid = 0.;
i__1 = *nrhs;
for (j = 1; j <= i__1; ++j) {
bnorm = dzasum_(n, &b[j * b_dim1 + 1], &c__1);
xnorm = dzasum_(n, &x[j * x_dim1 + 1], &c__1);
if (xnorm <= 0.) {
*resid = 1. / eps;
} else {
/* Computing MAX */
d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
*resid = max(d__1,d__2);
}
/* L10: */
}
return 0;
/* End of ZSYT02 */
} /* zsyt02_ */
| mfine/libswiftnav | clapack-3.2.1-CMAKE/TESTING/LIN/zsyt02.c | C | lgpl-3.0 | 5,162 |
/*
* Copyright 2004 The Apache Software Foundation
*
* 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 net.sf.cglib.proxy;
import org.objectweb.asm.Type;
class CallbackInfo
{
public static Type[] determineTypes(Class[] callbackTypes) {
Type[] types = new Type[callbackTypes.length];
for (int i = 0; i < types.length; i++) {
types[i] = determineType(callbackTypes[i]);
}
return types;
}
public static Type[] determineTypes(Callback[] callbacks) {
Type[] types = new Type[callbacks.length];
for (int i = 0; i < types.length; i++) {
types[i] = determineType(callbacks[i]);
}
return types;
}
public static CallbackGenerator[] getGenerators(Type[] callbackTypes) {
CallbackGenerator[] generators = new CallbackGenerator[callbackTypes.length];
for (int i = 0; i < generators.length; i++) {
generators[i] = getGenerator(callbackTypes[i]);
}
return generators;
}
//////////////////// PRIVATE ////////////////////
private Class cls;
private CallbackGenerator generator;
private Type type;
private static final CallbackInfo[] CALLBACKS = {
new CallbackInfo(NoOp.class, NoOpGenerator.INSTANCE),
new CallbackInfo(MethodInterceptor.class, MethodInterceptorGenerator.INSTANCE),
new CallbackInfo(InvocationHandler.class, InvocationHandlerGenerator.INSTANCE),
new CallbackInfo(LazyLoader.class, LazyLoaderGenerator.INSTANCE),
new CallbackInfo(Dispatcher.class, DispatcherGenerator.INSTANCE),
new CallbackInfo(FixedValue.class, FixedValueGenerator.INSTANCE),
new CallbackInfo(ProxyRefDispatcher.class, DispatcherGenerator.PROXY_REF_INSTANCE),
};
private CallbackInfo(Class cls, CallbackGenerator generator) {
this.cls = cls;
this.generator = generator;
type = Type.getType(cls);
}
private static Type determineType(Callback callback) {
if (callback == null) {
throw new IllegalStateException("Callback is null");
}
return determineType(callback.getClass());
}
private static Type determineType(Class callbackType) {
Class cur = null;
for (int i = 0; i < CALLBACKS.length; i++) {
CallbackInfo info = CALLBACKS[i];
if (info.cls.isAssignableFrom(callbackType)) {
if (cur != null) {
throw new IllegalStateException("Callback implements both " + cur + " and " + info.cls);
}
cur = info.cls;
}
}
if (cur == null) {
throw new IllegalStateException("Unknown callback type " + callbackType);
}
return Type.getType(cur);
}
private static CallbackGenerator getGenerator(Type callbackType) {
for (int i = 0; i < CALLBACKS.length; i++) {
CallbackInfo info = CALLBACKS[i];
if (info.type.equals(callbackType)) {
return info.generator;
}
}
throw new IllegalStateException("Unknown callback type " + callbackType);
}
}
| vongosling/cglib-ext | src/proxy/net/sf/cglib/proxy/CallbackInfo.java | Java | apache-2.0 | 3,696 |
/*!
* GMaps.js v0.2.30
* http://hpneo.github.com/gmaps/
*
* Copyright 2012, Gustavo Leon
* Released under the MIT License.
*/
if(window.google && window.google.maps){
var GMaps = (function(global) {
"use strict";
var doc = document;
var getElementById = function(id, context) {
var ele
if('jQuery' in global && context){
ele = $("#"+id.replace('#', ''), context)[0]
}else{
ele = doc.getElementById(id.replace('#', ''));
};
return ele;
};
var GMaps = function(options) {
var self = this;
var events_that_hide_context_menu = ['bounds_changed', 'center_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed'];
var events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'];
window.context_menu = {};
if (typeof(options.el) === 'string' || typeof(options.div) === 'string') {
this.el = getElementById(options.el || options.div, options.context);
} else {
this.el = options.el || options.div;
};
this.el.style.width = options.width || this.el.scrollWidth || this.el.offsetWidth;
this.el.style.height = options.height || this.el.scrollHeight || this.el.offsetHeight;
this.controls = [];
this.overlays = [];
this.layers = []; // array with kml and ft layers, can be as many
this.singleLayers = {}; // object with the other layers, only one per layer
this.markers = [];
this.polylines = [];
this.routes = [];
this.polygons = [];
this.infoWindow = null;
this.overlay_el = null;
this.zoom = options.zoom || 15;
var markerClusterer = options.markerClusterer;
//'Hybrid', 'Roadmap', 'Satellite' or 'Terrain'
var mapType;
if (options.mapType) {
mapType = google.maps.MapTypeId[options.mapType.toUpperCase()];
}
else {
mapType = google.maps.MapTypeId.ROADMAP;
}
var map_center = new google.maps.LatLng(options.lat, options.lng);
delete options.el;
delete options.lat;
delete options.lng;
delete options.mapType;
delete options.width;
delete options.height;
delete options.markerClusterer;
var zoomControlOpt = options.zoomControlOpt || {
style: 'DEFAULT',
position: 'TOP_LEFT'
};
var zoomControl = options.zoomControl || true,
zoomControlStyle = zoomControlOpt.style || 'DEFAULT',
zoomControlPosition = zoomControlOpt.position || 'TOP_LEFT',
panControl = options.panControl || true,
mapTypeControl = options.mapTypeControl || true,
scaleControl = options.scaleControl || true,
streetViewControl = options.streetViewControl || true,
overviewMapControl = overviewMapControl || true;
var map_options = {};
var map_base_options = {
zoom: this.zoom,
center: map_center,
mapTypeId: mapType
};
var map_controls_options = {
panControl: panControl,
zoomControl: zoomControl,
zoomControlOptions: {
style: google.maps.ZoomControlStyle[zoomControlStyle], // DEFAULT LARGE SMALL
position: google.maps.ControlPosition[zoomControlPosition]
},
mapTypeControl: mapTypeControl,
scaleControl: scaleControl,
streetViewControl: streetViewControl,
overviewMapControl: overviewMapControl
}
if(options.disableDefaultUI != true)
map_base_options = extend_object(map_base_options, map_controls_options);
map_options = extend_object(map_base_options, options);
for(var i = 0; i < events_that_hide_context_menu.length; i++) {
delete map_options[events_that_hide_context_menu[i]];
}
for(var i = 0; i < events_that_doesnt_hide_context_menu.length; i++) {
delete map_options[events_that_doesnt_hide_context_menu[i]];
}
this.map = new google.maps.Map(this.el, map_options);
if(markerClusterer) {
this.markerClusterer = markerClusterer.apply(this, [this.map]);
}
// Context menus
var buildContextMenuHTML = function(control, e) {
var html = '';
var options = window.context_menu[control];
for (var i in options){
if (options.hasOwnProperty(i)){
var option = options[i];
html += '<li><a id="' + control + '_' + i + '" href="#">' +
option.title + '</a></li>';
}
}
if(!getElementById('gmaps_context_menu')) return;
var context_menu_element = getElementById('gmaps_context_menu');
context_menu_element.innerHTML = html;
var context_menu_items = context_menu_element.getElementsByTagName('a');
var context_menu_items_count = context_menu_items.length;
for(var i = 0; i < context_menu_items_count; i++){
var context_menu_item = context_menu_items[i];
var assign_menu_item_action = function(ev){
ev.preventDefault();
options[this.id.replace(control + '_', '')].action.apply(self, [e]);
self.hideContextMenu();
};
google.maps.event.clearListeners(context_menu_item, 'click');
google.maps.event.addDomListenerOnce(context_menu_item, 'click', assign_menu_item_action, false);
}
var left = self.el.offsetLeft + e.pixel.x - 15;
var top = self.el.offsetTop + e.pixel.y - 15;
context_menu_element.style.left = left + "px";
context_menu_element.style.top = top + "px";
context_menu_element.style.display = 'block';
};
var buildContextMenu = function(control, e) {
if (control === 'marker') {
e.pixel = {};
var overlay = new google.maps.OverlayView();
overlay.setMap(self.map);
overlay.draw = function() {
var projection = overlay.getProjection();
var position = e.marker.getPosition();
e.pixel = projection.fromLatLngToContainerPixel(position);
buildContextMenuHTML(control, e);
};
}
else {
buildContextMenuHTML(control, e);
}
};
this.setContextMenu = function(options) {
window.context_menu[options.control] = {};
for (var i in options.options){
if (options.options.hasOwnProperty(i)){
var option = options.options[i];
window.context_menu[options.control][option.name] = {
title: option.title,
action: option.action
};
}
}
var ul = doc.createElement('ul');
ul.id = 'gmaps_context_menu';
ul.style.display = 'none';
ul.style.position = 'absolute';
ul.style.minWidth = '100px';
ul.style.background = 'white';
ul.style.listStyle = 'none';
ul.style.padding = '8px';
ul.style.boxShadow = '2px 2px 6px #ccc';
doc.body.appendChild(ul);
var context_menu_element = getElementById('gmaps_context_menu');
google.maps.event.addDomListener(context_menu_element, 'mouseout', function(ev) {
if(!ev.relatedTarget || !this.contains(ev.relatedTarget)){
window.setTimeout(function(){
context_menu_element.style.display = 'none';
}, 400);
}
}, false);
};
this.hideContextMenu = function() {
var context_menu_element = getElementById('gmaps_context_menu');
if(context_menu_element)
context_menu_element.style.display = 'none';
};
//Events
var setupListener = function(object, name) {
google.maps.event.addListener(object, name, function(e){
if(e == undefined) {
e = this;
}
options[name].apply(this, [e]);
self.hideContextMenu();
});
}
for (var ev = 0; ev < events_that_hide_context_menu.length; ev++) {
var name = events_that_hide_context_menu[ev];
if (name in options) {
setupListener(this.map, name);
}
}
for (var ev = 0; ev < events_that_doesnt_hide_context_menu.length; ev++) {
var name = events_that_doesnt_hide_context_menu[ev];
if (name in options) {
setupListener(this.map, name);
}
}
google.maps.event.addListener(this.map, 'rightclick', function(e) {
if (options.rightclick) {
options.rightclick.apply(this, [e]);
}
if(window.context_menu['map'] != undefined) {
buildContextMenu('map', e);
}
});
this.refresh = function() {
google.maps.event.trigger(this.map, 'resize');
};
this.fitZoom = function() {
var latLngs = [];
var markers_length = this.markers.length;
for(var i=0; i < markers_length; i++) {
latLngs.push(this.markers[i].getPosition());
}
this.fitLatLngBounds(latLngs);
};
this.fitLatLngBounds = function(latLngs) {
var total = latLngs.length;
var bounds = new google.maps.LatLngBounds();
for(var i=0; i < total; i++) {
bounds.extend(latLngs[i]);
}
this.map.fitBounds(bounds);
};
// Map methods
this.setCenter = function(lat, lng, callback) {
this.map.panTo(new google.maps.LatLng(lat, lng));
if (callback) {
callback();
}
};
this.getElement = function() {
return this.el;
};
this.zoomIn = function(value) {
this.zoom = this.map.getZoom() + value;
this.map.setZoom(this.zoom);
};
this.zoomOut = function(value) {
this.zoom = this.map.getZoom() - value;
this.map.setZoom(this.zoom);
};
var native_methods = [];
for(var method in this.map){
if(typeof(this.map[method]) == 'function' && !this[method]){
native_methods.push(method);
}
}
for(var i=0; i < native_methods.length; i++){
(function(gmaps, scope, method_name) {
gmaps[method_name] = function(){
return scope[method_name].apply(scope, arguments);
};
})(this, this.map, native_methods[i]);
}
this.createControl = function(options) {
var control = doc.createElement('div');
control.style.cursor = 'pointer';
control.style.fontFamily = 'Arial, sans-serif';
control.style.fontSize = '13px';
control.style.boxShadow = 'rgba(0, 0, 0, 0.398438) 0px 2px 4px';
for(var option in options.style)
control.style[option] = options.style[option];
if(options.id) {
control.id = options.id;
}
if(options.classes) {
control.className = options.classes;
}
if(options.content) {
control.innerHTML = options.content;
}
for (var ev in options.events) {
(function(object, name) {
google.maps.event.addDomListener(object, name, function(){
options.events[name].apply(this, [this]);
});
})(control, ev);
}
control.index = 1;
return control;
};
this.addControl = function(options) {
var position = google.maps.ControlPosition[options.position.toUpperCase()];
delete options.position;
var control = this.createControl(options);
this.controls.push(control);
this.map.controls[position].push(control);
return control;
};
// Markers
this.createMarker = function(options) {
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
var self = this;
var details = options.details;
var fences = options.fences;
var outside = options.outside;
var base_options = {
position: new google.maps.LatLng(options.lat, options.lng),
map: null
};
delete options.lat;
delete options.lng;
delete options.fences;
delete options.outside;
var marker_options = extend_object(base_options, options);
var marker = new google.maps.Marker(marker_options);
marker.fences = fences;
if (options.infoWindow) {
marker.infoWindow = new google.maps.InfoWindow(options.infoWindow);
var info_window_events = ['closeclick', 'content_changed', 'domready', 'position_changed', 'zindex_changed'];
for (var ev = 0; ev < info_window_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options.infoWindow[name])
options.infoWindow[name].apply(this, [e]);
});
})(marker.infoWindow, info_window_events[ev]);
}
}
var marker_events = ['animation_changed', 'clickable_changed', 'cursor_changed', 'draggable_changed', 'flat_changed', 'icon_changed', 'position_changed', 'shadow_changed', 'shape_changed', 'title_changed', 'visible_changed', 'zindex_changed'];
var marker_events_with_mouse = ['dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mouseout', 'mouseover', 'mouseup'];
for (var ev = 0; ev < marker_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(){
if (options[name])
options[name].apply(this, [this]);
});
})(marker, marker_events[ev]);
}
for (var ev = 0; ev < marker_events_with_mouse.length; ev++) {
(function(map, object, name) {
google.maps.event.addListener(object, name, function(me){
if(!me.pixel){
me.pixel = map.getProjection().fromLatLngToPoint(me.latLng)
}
if (options[name])
options[name].apply(this, [me]);
});
})(this.map, marker, marker_events_with_mouse[ev]);
}
google.maps.event.addListener(marker, 'click', function() {
this.details = details;
if (options.click) {
options.click.apply(this, [this]);
}
if (marker.infoWindow) {
self.hideInfoWindows();
marker.infoWindow.open(self.map, marker);
}
});
google.maps.event.addListener(marker, 'rightclick', function(e) {
e.marker = this;
if (options.rightclick) {
options.rightclick.apply(this, [e]);
}
if (window.context_menu['marker'] != undefined) {
buildContextMenu('marker', e);
}
});
if (options.dragend || marker.fences) {
google.maps.event.addListener(marker, 'dragend', function() {
if (marker.fences) {
self.checkMarkerGeofence(marker, function(m, f) {
outside(m, f);
});
}
});
}
return marker;
}
else {
throw 'No latitude or longitude defined';
}
};
this.addMarker = function(options) {
var marker;
if(options.hasOwnProperty('gm_accessors_')) {
// Native google.maps.Marker object
marker = options;
}
else {
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
marker = this.createMarker(options);
}
else {
throw 'No latitude or longitude defined';
}
}
marker.setMap(this.map);
if(this.markerClusterer)
this.markerClusterer.addMarker(marker);
this.markers.push(marker);
return marker;
};
this.addMarkers = function(array) {
for (var i=0, marker; marker=array[i]; i++) {
this.addMarker(marker);
}
return this.markers;
};
this.hideInfoWindows = function() {
for (var i=0, marker; marker=this.markers[i]; i++){
if (marker.infoWindow){
marker.infoWindow.close();
}
}
};
this.removeMarker = function(marker) {
for(var i = 0; i < this.markers.length; i++) {
if(this.markers[i] === marker) {
this.markers[i].setMap(null);
this.markers.splice(i, 1);
break;
}
}
return marker;
};
this.removeMarkers = function(collection) {
var collection = (collection || this.markers);
for(var i=0;i < this.markers.length; i++){
if(this.markers[i] === collection[i])
this.markers[i].setMap(null);
}
var new_markers = [];
for(var i=0;i < this.markers.length; i++){
if(this.markers[i].getMap() != null)
new_markers.push(this.markers[i]);
}
this.markers = new_markers;
};
// Overlays
this.drawOverlay = function(options) {
var overlay = new google.maps.OverlayView();
overlay.setMap(self.map);
var auto_show = true;
if(options.auto_show != null)
auto_show = options.auto_show;
overlay.onAdd = function() {
var el = doc.createElement('div');
el.style.borderStyle = "none";
el.style.borderWidth = "0px";
el.style.position = "absolute";
el.style.zIndex = 100;
el.innerHTML = options.content;
overlay.el = el;
var panes = this.getPanes();
if (!options.layer) {
options.layer = 'overlayLayer';
}
var overlayLayer = panes[options.layer];
overlayLayer.appendChild(el);
var stop_overlay_events = ['contextmenu', 'DOMMouseScroll', 'dblclick', 'mousedown'];
for (var ev = 0; ev < stop_overlay_events.length; ev++) {
(function(object, name) {
google.maps.event.addDomListener(object, name, function(e){
if(navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) {
e.cancelBubble = true;
e.returnValue = false;
}
else {
e.stopPropagation();
}
});
})(el, stop_overlay_events[ev]);
}
google.maps.event.trigger(this, 'ready');
};
overlay.draw = function() {
var projection = this.getProjection();
var pixel = projection.fromLatLngToDivPixel(new google.maps.LatLng(options.lat, options.lng));
options.horizontalOffset = options.horizontalOffset || 0;
options.verticalOffset = options.verticalOffset || 0;
var el = overlay.el;
var content = el.children[0];
var content_height = content.clientHeight;
var content_width = content.clientWidth;
switch (options.verticalAlign) {
case 'top':
el.style.top = (pixel.y - content_height + options.verticalOffset) + 'px';
break;
default:
case 'middle':
el.style.top = (pixel.y - (content_height / 2) + options.verticalOffset) + 'px';
break;
case 'bottom':
el.style.top = (pixel.y + options.verticalOffset) + 'px';
break;
}
switch (options.horizontalAlign) {
case 'left':
el.style.left = (pixel.x - content_width + options.horizontalOffset) + 'px';
break;
default:
case 'center':
el.style.left = (pixel.x - (content_width / 2) + options.horizontalOffset) + 'px';
break;
case 'right':
el.style.left = (pixel.x + options.horizontalOffset) + 'px';
break;
}
el.style.display = auto_show ? 'block' : 'none';
if(!auto_show){
options.show.apply(this, [el]);
}
};
overlay.onRemove = function() {
var el = overlay.el;
if(options.remove){
options.remove.apply(this, [el]);
}
else{
overlay.el.parentNode.removeChild(overlay.el);
overlay.el = null;
}
};
self.overlays.push(overlay);
return overlay;
};
this.removeOverlay = function(overlay) {
for(var i = 0; i < this.overlays.length; i++) {
if(this.overlays[i] === overlay) {
this.overlays[i].setMap(null);
this.overlays.splice(i, 1);
break;
}
}
};
this.removeOverlays = function() {
for (var i=0, item; item=self.overlays[i]; i++){
item.setMap(null);
}
self.overlays = [];
};
// Geometry
this.drawPolyline = function(options) {
var path = [];
var points = options.path;
if (points.length){
if (points[0][0] === undefined){
path = points;
}
else {
for (var i=0, latlng; latlng=points[i]; i++){
path.push(new google.maps.LatLng(latlng[0], latlng[1]));
}
}
}
var polyline_options = {
map: this.map,
path: path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight,
geodesic: options.geodesic,
clickable: true,
editable: false,
visible: true
};
if(options.hasOwnProperty("clickable"))
polyline_options.clickable = options.clickable;
if(options.hasOwnProperty("editable"))
polyline_options.editable = options.editable;
if(options.hasOwnProperty("icons"))
polyline_options.icons = options.icons;
if(options.hasOwnProperty("zIndex"))
polyline_options.zIndex = options.zIndex;
var polyline = new google.maps.Polyline(polyline_options);
var polyline_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polyline_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polyline, polyline_events[ev]);
}
this.polylines.push(polyline);
return polyline;
};
this.removePolyline = function(polyline) {
for(var i = 0; i < this.polylines.length; i++) {
if(this.polylines[i] === polyline) {
this.polylines[i].setMap(null);
this.polylines.splice(i, 1);
break;
}
}
};
this.removePolylines = function() {
for (var i=0, item; item=self.polylines[i]; i++){
item.setMap(null);
}
self.polylines = [];
};
this.drawCircle = function(options) {
options = extend_object({
map: this.map,
center: new google.maps.LatLng(options.lat, options.lng)
}, options);
delete options.lat;
delete options.lng;
var polygon = new google.maps.Circle(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.drawRectangle = function(options) {
options = extend_object({
map: this.map
}, options);
var latLngBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(options.bounds[0][0], options.bounds[0][1]),
new google.maps.LatLng(options.bounds[1][0], options.bounds[1][1])
);
options.bounds = latLngBounds;
var polygon = new google.maps.Rectangle(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.drawPolygon = function(options) {
var useGeoJSON = false;
if(options.hasOwnProperty("useGeoJSON"))
useGeoJSON = options.useGeoJSON;
delete options.useGeoJSON;
options = extend_object({
map: this.map
}, options);
if(useGeoJSON == false)
options.paths = [options.paths.slice(0)];
if(options.paths.length > 0) {
if(options.paths[0].length > 0) {
options.paths = array_flat(array_map(options.paths, arrayToLatLng, useGeoJSON));
}
}
var polygon = new google.maps.Polygon(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.removePolygon = function(polygon) {
for(var i = 0; i < this.polygons.length; i++) {
if(this.polygons[i] === polygon) {
this.polygons[i].setMap(null);
this.polygons.splice(i, 1);
break;
}
}
};
this.removePolygons = function() {
for (var i=0, item; item=self.polygons[i]; i++){
item.setMap(null);
}
self.polygons = [];
};
// Fusion Tables
this.getFromFusionTables = function(options) {
var events = options.events;
delete options.events;
var fusion_tables_options = options;
var layer = new google.maps.FusionTablesLayer(fusion_tables_options);
for (var ev in events) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
events[name].apply(this, [e]);
});
})(layer, ev);
}
this.layers.push(layer);
return layer;
};
this.loadFromFusionTables = function(options) {
var layer = this.getFromFusionTables(options);
layer.setMap(this.map);
return layer;
};
// KML
this.getFromKML = function(options) {
var url = options.url;
var events = options.events;
delete options.url;
delete options.events;
var kml_options = options;
var layer = new google.maps.KmlLayer(url, kml_options);
for (var ev in events) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
events[name].apply(this, [e]);
});
})(layer, ev);
}
this.layers.push(layer);
return layer;
};
this.loadFromKML = function(options) {
var layer = this.getFromKML(options);
layer.setMap(this.map);
return layer;
};
// Routes
var travelMode, unitSystem;
this.getRoutes = function(options) {
switch (options.travelMode) {
case 'bicycling':
travelMode = google.maps.TravelMode.BICYCLING;
break;
case 'transit':
travelMode = google.maps.TravelMode.TRANSIT;
break;
case 'driving':
travelMode = google.maps.TravelMode.DRIVING;
break;
// case 'walking':
default:
travelMode = google.maps.TravelMode.WALKING;
break;
}
if (options.unitSystem === 'imperial') {
unitSystem = google.maps.UnitSystem.IMPERIAL;
}
else {
unitSystem = google.maps.UnitSystem.METRIC;
}
var base_options = {
avoidHighways: false,
avoidTolls: false,
optimizeWaypoints: false,
waypoints: []
};
var request_options = extend_object(base_options, options);
request_options.origin = new google.maps.LatLng(options.origin[0], options.origin[1]);
request_options.destination = new google.maps.LatLng(options.destination[0], options.destination[1]);
request_options.travelMode = travelMode;
request_options.unitSystem = unitSystem;
delete request_options.callback;
var self = this;
var service = new google.maps.DirectionsService();
service.route(request_options, function(result, status) {
if (status === google.maps.DirectionsStatus.OK) {
for (var r in result.routes) {
if (result.routes.hasOwnProperty(r)) {
self.routes.push(result.routes[r]);
}
}
}
if (options.callback) {
options.callback(self.routes);
}
});
};
this.removeRoutes = function() {
this.routes = [];
};
this.getElevations = function(options) {
options = extend_object({
locations: [],
path : false,
samples : 256
}, options);
if(options.locations.length > 0) {
if(options.locations[0].length > 0) {
options.locations = array_flat(array_map([options.locations], arrayToLatLng, false));
}
}
var callback = options.callback;
delete options.callback;
var service = new google.maps.ElevationService();
//location request
if (!options.path) {
delete options.path;
delete options.samples;
service.getElevationForLocations(options, function(result, status){
if (callback && typeof(callback) === "function") {
callback(result, status);
}
});
//path request
} else {
var pathRequest = {
path : options.locations,
samples : options.samples
};
service.getElevationAlongPath(pathRequest, function(result, status){
if (callback && typeof(callback) === "function") {
callback(result, status);
}
});
}
};
// Alias for the method "drawRoute"
this.cleanRoute = this.removePolylines;
this.drawRoute = function(options) {
var self = this;
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints: options.waypoints,
unitSystem: options.unitSystem,
callback: function(e) {
if (e.length > 0) {
self.drawPolyline({
path: e[e.length - 1].overview_path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
if (options.callback) {
options.callback(e[e.length - 1]);
}
}
}
});
};
this.travelRoute = function(options) {
if (options.origin && options.destination) {
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints : options.waypoints,
callback: function(e) {
//start callback
if (e.length > 0 && options.start) {
options.start(e[e.length - 1]);
}
//step callback
if (e.length > 0 && options.step) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
options.step(step, (route.legs[0].steps.length - 1));
}
}
}
//end callback
if (e.length > 0 && options.end) {
options.end(e[e.length - 1]);
}
}
});
}
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
options.step(step);
}
}
}
};
this.drawSteppedRoute = function(options) {
if (options.origin && options.destination) {
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints : options.waypoints,
callback: function(e) {
//start callback
if (e.length > 0 && options.start) {
options.start(e[e.length - 1]);
}
//step callback
if (e.length > 0 && options.step) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
options.step(step, (route.legs[0].steps.length - 1));
}
}
}
//end callback
if (e.length > 0 && options.end) {
options.end(e[e.length - 1]);
}
}
});
}
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
options.step(step);
}
}
}
};
// Geofence
this.checkGeofence = function(lat, lng, fence) {
return fence.containsLatLng(new google.maps.LatLng(lat, lng));
};
this.checkMarkerGeofence = function(marker, outside_callback) {
if (marker.fences) {
for (var i=0, fence; fence=marker.fences[i]; i++) {
var pos = marker.getPosition();
if (!self.checkGeofence(pos.lat(), pos.lng(), fence)) {
outside_callback(marker, fence);
}
}
}
};
// Layers
this.addLayer = function(layerName, options) {
//var default_layers = ['weather', 'clouds', 'traffic', 'transit', 'bicycling', 'panoramio', 'places'];
options = options || {};
var layer;
switch(layerName) {
case 'weather': this.singleLayers.weather = layer = new google.maps.weather.WeatherLayer();
break;
case 'clouds': this.singleLayers.clouds = layer = new google.maps.weather.CloudLayer();
break;
case 'traffic': this.singleLayers.traffic = layer = new google.maps.TrafficLayer();
break;
case 'transit': this.singleLayers.transit = layer = new google.maps.TransitLayer();
break;
case 'bicycling': this.singleLayers.bicycling = layer = new google.maps.BicyclingLayer();
break;
case 'panoramio':
this.singleLayers.panoramio = layer = new google.maps.panoramio.PanoramioLayer();
layer.setTag(options.filter);
delete options.filter;
//click event
if(options.click) {
google.maps.event.addListener(layer, 'click', function(event) {
options.click(event);
delete options.click;
});
}
break;
case 'places':
this.singleLayers.places = layer = new google.maps.places.PlacesService(this.map);
//search and nearbySearch callback, Both are the same
if(options.search || options.nearbySearch) {
var placeSearchRequest = {
bounds : options.bounds || null,
keyword : options.keyword || null,
location : options.location || null,
name : options.name || null,
radius : options.radius || null,
rankBy : options.rankBy || null,
types : options.types || null
};
if(options.search) {
layer.search(placeSearchRequest, options.search);
}
if(options.nearbySearch) {
layer.nearbySearch(placeSearchRequest, options.nearbySearch);
}
}
//textSearch callback
if(options.textSearch) {
var textSearchRequest = {
bounds : options.bounds || null,
location : options.location || null,
query : options.query || null,
radius : options.radius || null
};
layer.textSearch(textSearchRequest, options.textSearch);
}
break;
}
if(layer !== undefined) {
if(typeof layer.setOptions == 'function') {
layer.setOptions(options);
}
if(typeof layer.setMap == 'function') {
layer.setMap(this.map);
}
return layer;
}
};
this.removeLayer = function(layerName) {
if(this.singleLayers[layerName] !== undefined) {
this.singleLayers[layerName].setMap(null);
delete this.singleLayers[layerName];
}
};
// Static Maps
this.toImage = function(options) {
var options = options || {};
var static_map_options = {};
static_map_options['size'] = options['size'] || [this.el.clientWidth, this.el.clientHeight];
static_map_options['lat'] = this.getCenter().lat();
static_map_options['lng'] = this.getCenter().lng();
if(this.markers.length > 0) {
static_map_options['markers'] = [];
for(var i=0; i < this.markers.length; i++) {
static_map_options['markers'].push({
lat: this.markers[i].getPosition().lat(),
lng: this.markers[i].getPosition().lng()
});
}
}
if(this.polylines.length > 0) {
var polyline = this.polylines[0];
static_map_options['polyline'] = {};
static_map_options['polyline']['path'] = google.maps.geometry.encoding.encodePath(polyline.getPath());
static_map_options['polyline']['strokeColor'] = polyline.strokeColor
static_map_options['polyline']['strokeOpacity'] = polyline.strokeOpacity
static_map_options['polyline']['strokeWeight'] = polyline.strokeWeight
}
return GMaps.staticMapURL(static_map_options);
};
// Map Types
this.addMapType = function(mapTypeId, options) {
if(options.hasOwnProperty("getTileUrl") && typeof(options["getTileUrl"]) == "function") {
options.tileSize = options.tileSize || new google.maps.Size(256, 256);
var mapType = new google.maps.ImageMapType(options);
this.map.mapTypes.set(mapTypeId, mapType);
}
else {
throw "'getTileUrl' function required";
}
};
this.addOverlayMapType = function(options) {
if(options.hasOwnProperty("getTile") && typeof(options["getTile"]) == "function") {
var overlayMapTypeIndex = options.index;
delete options.index;
this.map.overlayMapTypes.insertAt(overlayMapTypeIndex, options);
}
else {
throw "'getTile' function required";
}
};
this.removeOverlayMapType = function(overlayMapTypeIndex) {
this.map.overlayMapTypes.removeAt(overlayMapTypeIndex);
};
// Styles
this.addStyle = function(options) {
var styledMapType = new google.maps.StyledMapType(options.styles, options.styledMapName);
this.map.mapTypes.set(options.mapTypeId, styledMapType);
};
this.setStyle = function(mapTypeId) {
this.map.setMapTypeId(mapTypeId);
};
// StreetView
this.createPanorama = function(streetview_options) {
if (!streetview_options.hasOwnProperty('lat') || !streetview_options.hasOwnProperty('lng')) {
streetview_options.lat = this.getCenter().lat();
streetview_options.lng = this.getCenter().lng();
}
this.panorama = GMaps.createPanorama(streetview_options);
this.map.setStreetView(this.panorama);
return this.panorama;
};
};
GMaps.createPanorama = function(options) {
var el = getElementById(options.el, options.context);
options.position = new google.maps.LatLng(options.lat, options.lng);
delete options.el;
delete options.context;
delete options.lat;
delete options.lng;
var streetview_events = ['closeclick', 'links_changed', 'pano_changed', 'position_changed', 'pov_changed', 'resize', 'visible_changed'];
var streetview_options = extend_object({visible : true}, options);
for(var i = 0; i < streetview_events.length; i++) {
delete streetview_options[streetview_events[i]];
}
var panorama = new google.maps.StreetViewPanorama(el, streetview_options);
for(var i = 0; i < streetview_events.length; i++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(){
if (options[name]) {
options[name].apply(this);
}
});
})(panorama, streetview_events[i]);
}
return panorama;
};
GMaps.Route = function(options) {
this.map = options.map;
this.route = options.route;
this.step_count = 0;
this.steps = this.route.legs[0].steps;
this.steps_length = this.steps.length;
this.polyline = this.map.drawPolyline({
path: new google.maps.MVCArray(),
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
}).getPath();
this.back = function() {
if (this.step_count > 0) {
this.step_count--;
var path = this.route.legs[0].steps[this.step_count].path;
for (var p in path){
if (path.hasOwnProperty(p)){
this.polyline.pop();
}
}
}
};
this.forward = function() {
if (this.step_count < this.steps_length) {
var path = this.route.legs[0].steps[this.step_count].path;
for (var p in path){
if (path.hasOwnProperty(p)){
this.polyline.push(path[p]);
}
}
this.step_count++;
}
};
};
// Geolocation (Modern browsers only)
GMaps.geolocate = function(options) {
var complete_callback = options.always || options.complete;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
options.success(position);
if (complete_callback) {
complete_callback();
}
}, function(error) {
options.error(error);
if (complete_callback) {
complete_callback();
}
}, options.options);
}
else {
options.not_supported();
if (complete_callback) {
complete_callback();
}
}
};
// Geocoding
GMaps.geocode = function(options) {
this.geocoder = new google.maps.Geocoder();
var callback = options.callback;
if (options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) {
options.latLng = new google.maps.LatLng(options.lat, options.lng);
}
delete options.lat;
delete options.lng;
delete options.callback;
this.geocoder.geocode(options, function(results, status) {
callback(results, status);
});
};
// Static maps
GMaps.staticMapURL = function(options){
var parameters = [];
var data;
var static_root = 'http://maps.googleapis.com/maps/api/staticmap';
if (options.url){
static_root = options.url;
delete options.url;
}
static_root += '?';
var markers = options.markers;
delete options.markers;
if (!markers && options.marker){
markers = [options.marker];
delete options.marker;
}
var polyline = options.polyline;
delete options.polyline;
/** Map options **/
if (options.center){
parameters.push('center=' + options.center);
delete options.center;
}
else if (options.address){
parameters.push('center=' + options.address);
delete options.address;
}
else if (options.lat){
parameters.push(['center=', options.lat, ',', options.lng].join(''));
delete options.lat;
delete options.lng;
}
else if (options.visible){
var visible = encodeURI(options.visible.join('|'));
parameters.push('visible=' + visible);
}
var size = options.size;
if (size){
if (size.join){
size = size.join('x');
}
delete options.size;
}
else {
size = '630x300';
}
parameters.push('size=' + size);
if (!options.zoom){
options.zoom = 15;
}
var sensor = options.hasOwnProperty('sensor') ? !!options.sensor : true;
delete options.sensor;
parameters.push('sensor=' + sensor);
for (var param in options){
if (options.hasOwnProperty(param)){
parameters.push(param + '=' + options[param]);
}
}
/** Markers **/
if (markers){
var marker, loc;
for (var i=0; data=markers[i]; i++){
marker = [];
if (data.size && data.size !== 'normal'){
marker.push('size:' + data.size);
}
else if (data.icon){
marker.push('icon:' + encodeURI(data.icon));
}
if (data.color){
marker.push('color:' + data.color.replace('#', '0x'));
}
if (data.label){
marker.push('label:' + data.label[0].toUpperCase());
}
loc = (data.address ? data.address : data.lat + ',' + data.lng);
if (marker.length || i === 0){
marker.push(loc);
marker = marker.join('|');
parameters.push('markers=' + encodeURI(marker));
}
// New marker without styles
else {
marker = parameters.pop() + encodeURI('|' + loc);
parameters.push(marker);
}
}
}
/** Polylines **/
function parseColor(color, opacity){
if (color[0] === '#'){
color = color.replace('#', '0x');
if (opacity){
opacity = parseFloat(opacity);
opacity = Math.min(1, Math.max(opacity, 0));
if (opacity === 0){
return '0x00000000';
}
opacity = (opacity * 255).toString(16);
if (opacity.length === 1){
opacity += opacity;
}
color = color.slice(0,8) + opacity;
}
}
return color;
}
if (polyline){
data = polyline;
polyline = [];
if (data.strokeWeight){
polyline.push('weight:' + parseInt(data.strokeWeight, 10));
}
if (data.strokeColor){
var color = parseColor(data.strokeColor, data.strokeOpacity);
polyline.push('color:' + color);
}
if (data.fillColor){
var fillcolor = parseColor(data.fillColor, data.fillOpacity);
polyline.push('fillcolor:' + fillcolor);
}
var path = data.path;
if (path.join){
for (var j=0, pos; pos=path[j]; j++){
polyline.push(pos.join(','));
}
}
else {
polyline.push('enc:' + path);
}
polyline = polyline.join('|');
parameters.push('path=' + encodeURI(polyline));
}
parameters = parameters.join('&');
return static_root + parameters;
};
//==========================
// Polygon containsLatLng
// https://github.com/tparkin/Google-Maps-Point-in-Polygon
// Poygon getBounds extension - google-maps-extensions
// http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
if (!google.maps.Polygon.prototype.getBounds) {
google.maps.Polygon.prototype.getBounds = function(latLng) {
var bounds = new google.maps.LatLngBounds();
var paths = this.getPaths();
var path;
for (var p = 0; p < paths.getLength(); p++) {
path = paths.getAt(p);
for (var i = 0; i < path.getLength(); i++) {
bounds.extend(path.getAt(i));
}
}
return bounds;
};
}
if (!google.maps.Polygon.prototype.containsLatLng) {
// Polygon containsLatLng - method to determine if a latLng is within a polygon
google.maps.Polygon.prototype.containsLatLng = function(latLng) {
// Exclude points outside of bounds as there is no way they are in the poly
var bounds = this.getBounds();
if (bounds !== null && !bounds.contains(latLng)) {
return false;
}
// Raycast point in polygon method
var inPoly = false;
var numPaths = this.getPaths().getLength();
for (var p = 0; p < numPaths; p++) {
var path = this.getPaths().getAt(p);
var numPoints = path.getLength();
var j = numPoints - 1;
for (var i = 0; i < numPoints; i++) {
var vertex1 = path.getAt(i);
var vertex2 = path.getAt(j);
if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng()) {
if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
inPoly = !inPoly;
}
}
j = i;
}
}
return inPoly;
};
}
google.maps.LatLngBounds.prototype.containsLatLng = function(latLng) {
return this.contains(latLng);
};
google.maps.Marker.prototype.setFences = function(fences) {
this.fences = fences;
};
google.maps.Marker.prototype.addFence = function(fence) {
this.fences.push(fence);
};
return GMaps;
}(this));
var coordsToLatLngs = function(coords, useGeoJSON) {
var first_coord = coords[0];
var second_coord = coords[1];
if(useGeoJSON) {
first_coord = coords[1];
second_coord = coords[0];
}
return new google.maps.LatLng(first_coord, second_coord);
};
var arrayToLatLng = function(coords, useGeoJSON) {
for(var i=0; i < coords.length; i++) {
if(coords[i].length > 0 && typeof(coords[i][0]) != "number") {
coords[i] = arrayToLatLng(coords[i], useGeoJSON);
}
else {
coords[i] = coordsToLatLngs(coords[i], useGeoJSON);
}
}
return coords;
};
var extend_object = function(obj, new_obj) {
if(obj === new_obj) return obj;
for(var name in new_obj) {
obj[name] = new_obj[name];
}
return obj;
};
var replace_object = function(obj, replace) {
if(obj === replace) return obj;
for(var name in replace) {
if(obj[name] != undefined)
obj[name] = replace[name];
}
return obj;
};
var array_map = function(array, callback) {
var original_callback_params = Array.prototype.slice.call(arguments, 2);
if (Array.prototype.map && array.map === Array.prototype.map) {
return Array.prototype.map.call(array, function(item) {
callback_params = original_callback_params;
callback_params.splice(0, 0, item);
return callback.apply(this, callback_params);
});
}
else {
var array_return = [];
var array_length = array.length;
for(var i = 0; i < array_length; i++) {
callback_params = original_callback_params;
callback_params = callback_params.splice(0, 0, array[i]);
array_return.push(callback.apply(this, callback_params));
}
return array_return;
}
};
var array_flat = function(array) {
new_array = [];
for(var i=0; i < array.length; i++) {
new_array = new_array.concat(array[i]);
}
return new_array;
};
} | zhiwehu/zhiwehu | zhiwehu/themes/unify/static/plugins/gmap/gmap.js | JavaScript | apache-2.0 | 54,758 |
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, STMicroelectronics
* 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 STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
*/
#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H
// STM32L151CB
// CORE: 16 vectors = 64 bytes from 0x00 to 0x3F
// MCU Peripherals: 45 vectors = 180 bytes from 0x40 to 0xF3
// Total: 61 vectors = 244 bytes (0xF4) to be reserved in RAM
#define NVIC_NUM_VECTORS 61
#define NVIC_RAM_VECTOR_ADDRESS 0x20000000 // Vectors positioned at start of RAM
#endif
| c1728p9/mbed-os | targets/TARGET_STM/TARGET_STM32L1/TARGET_MTB_RAK811/device/cmsis_nvic.h | C | apache-2.0 | 2,138 |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
namespace Microsoft.Azure.Management.Logic.Models
{
using Azure;
using Management;
using Logic;
using Rest;
using Newtonsoft.Json;
using System.Linq;
/// <summary>
/// The Edifact schema reference.
/// </summary>
public partial class EdifactSchemaReference
{
/// <summary>
/// Initializes a new instance of the EdifactSchemaReference class.
/// </summary>
public EdifactSchemaReference() { }
/// <summary>
/// Initializes a new instance of the EdifactSchemaReference class.
/// </summary>
/// <param name="messageId">The message id.</param>
/// <param name="messageVersion">The message version.</param>
/// <param name="messageRelease">The message release version.</param>
/// <param name="schemaName">The schema name.</param>
/// <param name="senderApplicationId">The sender application
/// id.</param>
/// <param name="senderApplicationQualifier">The sender application
/// qualifier.</param>
/// <param name="associationAssignedCode">The association assigned
/// code.</param>
public EdifactSchemaReference(string messageId, string messageVersion, string messageRelease, string schemaName, string senderApplicationId = default(string), string senderApplicationQualifier = default(string), string associationAssignedCode = default(string))
{
MessageId = messageId;
MessageVersion = messageVersion;
MessageRelease = messageRelease;
SenderApplicationId = senderApplicationId;
SenderApplicationQualifier = senderApplicationQualifier;
AssociationAssignedCode = associationAssignedCode;
SchemaName = schemaName;
}
/// <summary>
/// Gets or sets the message id.
/// </summary>
[JsonProperty(PropertyName = "messageId")]
public string MessageId { get; set; }
/// <summary>
/// Gets or sets the message version.
/// </summary>
[JsonProperty(PropertyName = "messageVersion")]
public string MessageVersion { get; set; }
/// <summary>
/// Gets or sets the message release version.
/// </summary>
[JsonProperty(PropertyName = "messageRelease")]
public string MessageRelease { get; set; }
/// <summary>
/// Gets or sets the sender application id.
/// </summary>
[JsonProperty(PropertyName = "senderApplicationId")]
public string SenderApplicationId { get; set; }
/// <summary>
/// Gets or sets the sender application qualifier.
/// </summary>
[JsonProperty(PropertyName = "senderApplicationQualifier")]
public string SenderApplicationQualifier { get; set; }
/// <summary>
/// Gets or sets the association assigned code.
/// </summary>
[JsonProperty(PropertyName = "associationAssignedCode")]
public string AssociationAssignedCode { get; set; }
/// <summary>
/// Gets or sets the schema name.
/// </summary>
[JsonProperty(PropertyName = "schemaName")]
public string SchemaName { get; set; }
/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (MessageId == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "MessageId");
}
if (MessageVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "MessageVersion");
}
if (MessageRelease == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "MessageRelease");
}
if (SchemaName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "SchemaName");
}
}
}
}
| SiddharthChatrolaMs/azure-sdk-for-net | src/SDKs/Logic/Management.Logic/Generated/Models/EdifactSchemaReference.cs | C# | apache-2.0 | 4,471 |
/**
******************************************************************************
* @file lcd_log_conf_template.h
* @author MCD Application Team
* @version V5.0.2
* @date 05-March-2012
* @brief lcd_log configuration template file.
* This file should be copied to the application folder and modified
* as follows:
* - Rename it to 'lcd_log_conf.h'.
* - Update the name of the LCD header file depending on the EVAL board
* you are using (see line32 below).
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LCD_LOG_CONF_H__
#define __LCD_LOG_CONF_H__
/* Includes ------------------------------------------------------------------*/
#include "stm32xxx_eval_lcd.h" /* replace 'stm32xxx' with your EVAL board name, ex: stm3210c_eval_lcd.h */
#include <stdio.h>
/** @addtogroup LCD_LOG
* @{
*/
/** @defgroup LCD_LOG
* @brief This file is the
* @{
*/
/** @defgroup LCD_LOG_CONF_Exported_Defines
* @{
*/
/* Comment the line below to disable the scroll back and forward features */
#define LCD_SCROLL_ENABLED
/* Define the LCD default text color */
#define LCD_LOG_DEFAULT_COLOR LCD_COLOR_WHITE
/* Define the display window settings */
#define YWINDOW_MIN 3
#define YWINDOW_SIZE 12
#define XWINDOW_MAX 50
/* Define the cache depth */
#define CACHE_SIZE 50
/** @defgroup LCD_LOG_CONF_Exported_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LCD_LOG_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LCD_LOG_CONF_Exported_Variables
* @{
*/
/**
* @}
*/
/** @defgroup LCD_LOG_CONF_Exported_FunctionsPrototype
* @{
*/
/**
* @}
*/
#endif /* __LCD_LOG_H__ */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| dancollins/libnarm | vendor/STM32F0xx_StdPeriph_Lib_V1.3.1/Utilities/STM32_EVAL/Common/lcd_log_conf_template.h | C | apache-2.0 | 2,899 |
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Collections.Generic;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
internal abstract partial class ConversionsBase
{
private const int MaximumRecursionDepth = 50;
protected readonly AssemblySymbol corLibrary;
private readonly int _currentRecursionDepth;
protected ConversionsBase(AssemblySymbol corLibrary, int currentRecursionDepth)
{
Debug.Assert((object)corLibrary != null);
this.corLibrary = corLibrary;
_currentRecursionDepth = currentRecursionDepth;
}
protected abstract ConversionsBase CreateInstance(int currentRecursionDepth);
public abstract Conversion GetMethodGroupConversion(BoundMethodGroup source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics);
protected abstract Conversion GetInterpolatedStringConversion(BoundInterpolatedString source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics);
/// <summary>
/// Attempt a quick classification of builtin conversions. As result of "no conversion"
/// means that there is no built-in conversion, though there still may be a user-defined
/// conversion if compiling against a custom mscorlib.
/// </summary>
public static Conversion FastClassifyConversion(TypeSymbol source, TypeSymbol target)
{
ConversionKind convKind = ConversionEasyOut.ClassifyConversion(source, target);
return new Conversion(convKind);
}
/// <summary>
/// IsBaseInterface returns true if baseType is on the base interface list of derivedType or
/// any base class of derivedType. It may be on the base interface list either directly or
/// indirectly.
/// * baseType must be an interface.
/// * type parameters do not have base interfaces. (They have an "effective interface list".)
/// * an interface is not a base of itself.
/// * this does not check for variance conversions; if a type inherits from
/// IEnumerable<string> then IEnumerable<object> is not a base interface.
/// </summary>
public static bool IsBaseInterface(TypeSymbol baseType, TypeSymbol derivedType, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)baseType != null);
Debug.Assert((object)derivedType != null);
if (!baseType.IsInterfaceType())
{
return false;
}
var d = derivedType as NamedTypeSymbol;
if ((object)d == null)
{
return false;
}
foreach (var iface in d.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasIdentityConversion(iface, baseType))
{
return true;
}
}
return false;
}
// IsBaseClassOfClass determines whether the purported derived type is a class, and if so,
// if the purported base type is one of its base classes.
public static bool IsBaseClassOfClass(TypeSymbol baseType, TypeSymbol derivedType, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)baseType != null);
Debug.Assert((object)derivedType != null);
return derivedType.IsClassType() && IsBaseClass(derivedType, baseType, ref useSiteDiagnostics);
}
// IsBaseClass returns true if and only if baseType is a base class of derivedType, period.
//
// * interfaces do not have base classes. (Structs, enums and classes other than object do.)
// * a class is not a base class of itself
// * type parameters do not have base classes. (They have "effective base classes".)
// * all base classes must be classes
// * dynamics are removed; if we have class D : B<dynamic> then B<object> is a
// base class of D. However, dynamic is never a base class of anything.
public static bool IsBaseClass(TypeSymbol derivedType, TypeSymbol baseType, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)derivedType != null);
Debug.Assert((object)baseType != null);
// A base class has got to be a class. The derived type might be a struct, enum, or delegate.
if (!baseType.IsClassType())
{
return false;
}
for (TypeSymbol b = derivedType.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics); (object)b != null; b = b.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasIdentityConversion(b, baseType))
{
return true;
}
}
return false;
}
/// <summary>
/// Determines if the source type is convertible to the destination type via
/// any conversion: implicit, explicit, user-defined or built-in.
/// </summary>
/// <remarks>
/// It is rare but possible for a source type to be convertible to a destination type
/// by both an implicit user-defined conversion and a built-in explicit conversion.
/// In that circumstance, this method classifies the conversion as the implicit conversion.
/// </remarks>
public Conversion ClassifyConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics, bool builtinOnly = false)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// Try using the short-circuit "fast-conversion" path.
Conversion fastConversion = FastClassifyConversion(source, destination);
if (fastConversion.Exists)
{
return fastConversion;
}
else
{
Conversion conversion1 = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteDiagnostics);
if (conversion1.Exists)
{
return conversion1;
}
}
if (!builtinOnly)
{
Conversion conversion1 = GetImplicitUserDefinedConversion(null, source, destination, ref useSiteDiagnostics);
if (conversion1.Exists)
{
return conversion1;
}
}
var conversion = ClassifyExplicitBuiltInOnlyConversion(source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
return builtinOnly ? conversion : GetExplicitUserDefinedConversion(null, source, destination, ref useSiteDiagnostics);
}
/// <summary>
/// Determines if the source type is convertible to the destination type via
/// any conversion: implicit, explicit, user-defined or built-in.
/// </summary>
/// <remarks>
/// It is rare but possible for a source type to be convertible to a destination type
/// by both an implicit user-defined conversion and a built-in explicit conversion.
/// In that circumstance, this method classifies the conversion as the built-in conversion.
/// </remarks>
public Conversion ClassifyConversionForCast(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// Try using the short-circuit "fast-conversion" path.
Conversion fastConversion = FastClassifyConversion(source, destination);
if (fastConversion.Exists)
{
return fastConversion;
}
else
{
Conversion conversion1 = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteDiagnostics);
if (conversion1.Exists)
{
return conversion1;
}
}
Conversion conversion = ClassifyExplicitBuiltInOnlyConversion(source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
// It is possible for a user-defined conversion to be unambiguous when considered as
// an implicit conversion and ambiguous when considered as an explicit conversion.
// The native compiler does not check to see if a cast could be successfully bound as
// an unambiguous user-defined implicit conversion; it goes right to the ambiguous
// user-defined explicit conversion and produces an error. This means that in
// C# 5 it is possible to have:
//
// Y y = new Y();
// Z z1 = y;
//
// succeed but
//
// Z z2 = (Z)y;
//
// fail.
conversion = GetExplicitUserDefinedConversion(null, source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
return GetImplicitUserDefinedConversion(null, source, destination, ref useSiteDiagnostics);
}
/// <summary>
/// Determines if the source type is convertible to the destination type via
/// any standard implicit or standard explicit conversion.
/// </summary>
/// <remarks>
/// Not all built-in explicit conversions are standard explicit conversions.
/// </remarks>
public Conversion ClassifyStandardConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert(sourceExpression != null || (object)source != null);
Debug.Assert((object)destination != null);
// Note that the definition of explicit standard conversion does not include all explicit
// reference conversions! There is a standard implicit reference conversion from
// Action<Object> to Action<Exception>, thanks to contravariance. There is a standard
// implicit reference conversion from Action<Object> to Action<String> for the same reason.
// Therefore there is an explicit reference conversion from Action<Exception> to
// Action<String>; a given Action<Exception> might be an Action<Object>, and hence
// convertible to Action<String>. However, this is not a *standard* explicit conversion. The
// standard explicit conversions are all the standard implicit conversions and their
// opposites. Therefore Action<Object>-->Action<String> and Action<String>-->Action<Object>
// are both standard conversions. But Action<String>-->Action<Exception> is not a standard
// explicit conversion because neither it nor its opposite is a standard implicit
// conversion.
//
// Similarly, there is no standard explicit conversion from double to decimal, because
// there is no standard implicit conversion between the two types.
// SPEC: The standard explicit conversions are all standard implicit conversions plus
// SPEC: the subset of the explicit conversions for which an opposite standard implicit
// SPEC: conversion exists. In other words, if a standard implicit conversion exists from
// SPEC: a type A to a type B, then a standard explicit conversion exists from type A to
// SPEC: type B and from type B to type A.
Conversion conversion = ClassifyStandardImplicitConversion(sourceExpression, source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
if ((object)source != null)
{
conversion = ClassifyStandardImplicitConversion(destination, source, ref useSiteDiagnostics);
switch (conversion.Kind)
{
case ConversionKind.ImplicitNumeric:
return Conversion.ExplicitNumeric;
case ConversionKind.ImplicitNullable:
return Conversion.ExplicitNullable;
case ConversionKind.ImplicitReference:
return Conversion.ExplicitReference;
case ConversionKind.Boxing:
return Conversion.Unboxing;
case ConversionKind.NoConversion:
return Conversion.NoConversion;
case ConversionKind.PointerToVoid:
return Conversion.PointerToPointer;
default:
throw ExceptionUtilities.UnexpectedValue(conversion.Kind);
}
}
return Conversion.NoConversion;
}
internal Conversion ClassifyStandardImplicitConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert(sourceExpression != null || (object)source != null);
Debug.Assert(sourceExpression == null || (object)sourceExpression.Type == (object)source);
Debug.Assert((object)destination != null);
// SPEC: The following implicit conversions are classified as standard implicit conversions:
// SPEC: Identity conversions
// SPEC: Implicit numeric conversions
// SPEC: Implicit nullable conversions
// SPEC: Implicit reference conversions
// SPEC: Boxing conversions
// SPEC: Implicit constant expression conversions
// SPEC: Implicit conversions involving type parameters
//
// and in unsafe code:
//
// SPEC: From any pointer type to void*
//
// SPEC ERROR:
// The specification does not say to take into account the conversion from
// the *expression*, only its *type*. But the expression may not have a type
// (because it is null, a method group, or a lambda), or the expression might
// be convertible to the destination type via a constant numeric conversion.
// For example, the native compiler allows "C c = 1;" to work if C is a class which
// has an implicit conversion from byte to C, despite the fact that there is
// obviously no standard implicit conversion from *int* to *byte*.
// Similarly, if a struct S has an implicit conversion from string to S, then
// "S s = null;" should be allowed.
//
// We extend the definition of standard implicit conversions to include
// all of the implicit conversions that are allowed based on an expression.
Conversion conversion = ClassifyImplicitBuiltInConversionFromExpression(sourceExpression, source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
if ((object)source != null)
{
return ClassifyStandardImplicitConversion(source, destination, ref useSiteDiagnostics);
}
return Conversion.NoConversion;
}
internal Conversion ClassifyStandardImplicitConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (HasIdentityConversion(source, destination))
{
return Conversion.Identity;
}
if (HasImplicitNumericConversion(source, destination))
{
return Conversion.ImplicitNumeric;
}
if (HasImplicitNullableConversion(source, destination))
{
return Conversion.ImplicitNullable;
}
if (HasImplicitReferenceConversion(source, destination, ref useSiteDiagnostics))
{
return Conversion.ImplicitReference;
}
if (HasBoxingConversion(source, destination, ref useSiteDiagnostics))
{
return Conversion.Boxing;
}
if (HasImplicitPointerConversion(source, destination))
{
return Conversion.PointerToVoid;
}
return Conversion.NoConversion;
}
private Conversion ClassifyImplicitBuiltInConversionSlow(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (source.SpecialType == SpecialType.System_Void || destination.SpecialType == SpecialType.System_Void)
{
return Conversion.NoConversion;
}
Conversion conversion = ClassifyStandardImplicitConversion(source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
//if (HasImplicitDynamicConversion(source, destination))
//{
// return Conversion.Dynamic;
//}
return Conversion.NoConversion;
}
private Conversion GetImplicitUserDefinedConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
var conversionResult = AnalyzeImplicitUserDefinedConversions(sourceExpression, source, destination, ref useSiteDiagnostics);
return new Conversion(conversionResult, isImplicit: true);
}
/// <summary>
/// Determines if the source type is convertible to the destination type via
/// any user-defined or built-in implicit conversion.
/// </summary>
/// <remarks>
/// Not all built-in explicit conversions are standard explicit conversions.
/// </remarks>
public Conversion ClassifyImplicitConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
//PERF: identity conversions are very common, check for that first.
if (HasIdentityConversion(source, destination))
{
return Conversion.Identity;
}
// Try using the short-circuit "fast-conversion" path.
Conversion fastConversion = FastClassifyConversion(source, destination);
if (fastConversion.Exists)
{
return fastConversion.IsImplicit ? fastConversion : Conversion.NoConversion;
}
else
{
Conversion conversion = ClassifyImplicitBuiltInConversionSlow(source, destination, ref useSiteDiagnostics);
if (conversion.Exists)
{
return conversion;
}
}
return GetImplicitUserDefinedConversion(null, source, destination, ref useSiteDiagnostics);
}
private Conversion ClassifyExplicitBuiltInOnlyConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// The call to HasExplicitNumericConversion isn't necessary, because it is always tested
// already by the "FastConversion" code.
Debug.Assert(!HasExplicitNumericConversion(source, destination));
if (source.SpecialType == SpecialType.System_Void || destination.SpecialType == SpecialType.System_Void)
{
return Conversion.NoConversion;
}
//if (HasExplicitNumericConversion(source, specialTypeSource, destination, specialTypeDest))
//{
// return Conversion.ExplicitNumeric;
//}
if (HasSpecialIntPtrConversion(source, destination))
{
return Conversion.IntPtr;
}
if (HasExplicitEnumerationConversion(source, destination))
{
return Conversion.ExplicitEnumeration;
}
if (HasExplicitNullableConversion(source, destination))
{
return Conversion.ExplicitNullable;
}
if (HasExplicitReferenceConversion(source, destination, ref useSiteDiagnostics))
{
return (source.Kind == SymbolKind.DynamicType) ? Conversion.ExplicitDynamic : Conversion.ExplicitReference;
}
if (HasUnboxingConversion(source, destination, ref useSiteDiagnostics))
{
return Conversion.Unboxing;
}
if (HasPointerToPointerConversion(source, destination))
{
return Conversion.PointerToPointer;
}
if (HasPointerToIntegerConversion(source, destination))
{
return Conversion.PointerToInteger;
}
if (HasIntegerToPointerConversion(source, destination))
{
return Conversion.IntegerToPointer;
}
if (HasExplicitDynamicConversion(source, destination))
{
return Conversion.ExplicitDynamic;
}
return Conversion.NoConversion;
}
private Conversion GetExplicitUserDefinedConversion(BoundExpression sourceExpression, TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
UserDefinedConversionResult conversionResult = AnalyzeExplicitUserDefinedConversions(sourceExpression, source, destination, ref useSiteDiagnostics);
return new Conversion(conversionResult, isImplicit: false);
}
public static bool HasIdentityConversion(TypeSymbol type1, TypeSymbol type2)
{
// Spec (6.1.1):
// An identity conversion converts from any type to the same type. This conversion exists
// such that an entity that already has a required type can be said to be convertible to
// that type.
//
// Because object and dynamic are considered equivalent there is an identity conversion
// between object and dynamic, and between constructed types that are the same when replacing
// all occurrences of dynamic with object.
Debug.Assert((object)type1 != null);
Debug.Assert((object)type2 != null);
return type1.Equals(type2, ignoreCustomModifiersAndArraySizesAndLowerBounds: true, ignoreDynamic: true);
}
public static bool HasIdentityConversionToAny<T>(T type, ArrayBuilder<T> targetTypes)
where T : TypeSymbol
{
for (int i = 0, n = targetTypes.Count; i < n; i++)
{
if (HasIdentityConversion(type, targetTypes[i]))
{
return true;
}
}
return false;
}
public Conversion ConvertExtensionMethodThisArg(TypeSymbol parameterType, TypeSymbol thisType, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)thisType != null);
var conversion = this.ClassifyImplicitConversion(thisType, parameterType, ref useSiteDiagnostics);
return IsValidExtensionMethodThisArgConversion(conversion) ? conversion : Conversion.NoConversion;
}
// Spec 7.6.5.2: "An extension method ... is eligible if ... [an] implicit identity, reference,
// or boxing conversion exists from expr to the type of the first parameter"
public static bool IsValidExtensionMethodThisArgConversion(Conversion conversion)
{
switch (conversion.Kind)
{
case ConversionKind.Identity:
case ConversionKind.Boxing:
case ConversionKind.ImplicitReference:
return true;
default:
return false;
}
}
private enum NumericType
{
SByte,
Byte,
Short,
UShort,
Int,
UInt,
Long,
ULong,
Char,
Float,
Double,
Decimal
}
private const bool F = false;
private const bool T = true;
// Notice that there is no implicit numeric conversion from a type to itself. That's an
// identity conversion.
private static readonly bool[,] s_implicitNumericConversions =
{
// to sb b s us i ui l ul c f d m
// from
/* sb */
{ F, F, T, F, T, F, T, F, F, T, T, T },
/* b */
{ F, F, T, T, T, T, T, T, F, T, T, T },
/* s */
{ F, F, F, F, T, F, T, F, F, T, T, T },
/* us */
{ F, F, F, F, T, T, T, T, F, T, T, T },
/* i */
{ F, F, F, F, F, F, T, F, F, T, T, T },
/* ui */
{ F, F, F, F, F, F, T, T, F, T, T, T },
/* l */
{ F, F, F, F, F, F, F, F, F, T, T, T },
/* ul */
{ F, F, F, F, F, F, F, F, F, T, T, T },
/* c */
{ F, F, F, T, T, T, T, T, F, T, T, T },
/* f */
{ F, F, F, F, F, F, F, F, F, F, T, F },
/* d */
{ F, F, F, F, F, F, F, F, F, F, F, F },
/* m */
{ F, F, F, F, F, F, F, F, F, F, F, F }
};
private static readonly bool[,] s_explicitNumericConversions =
{
// to sb b s us i ui l ul c f d m
// from
/* sb */
{ F, T, F, T, F, T, F, T, T, F, F, F },
/* b */
{ T, F, F, F, F, F, F, F, T, F, F, F },
/* s */
{ T, T, F, T, F, T, F, T, T, F, F, F },
/* us */
{ T, T, T, F, F, F, F, F, T, F, F, F },
/* i */
{ T, T, T, T, F, T, F, T, T, F, F, F },
/* ui */
{ T, T, T, T, T, F, F, F, T, F, F, F },
/* l */
{ T, T, T, T, T, T, F, T, T, F, F, F },
/* ul */
{ T, T, T, T, T, T, T, F, T, F, F, F },
/* c */
{ T, T, T, F, F, F, F, F, F, F, F, F },
/* f */
{ T, T, T, T, T, T, T, T, T, F, F, T },
/* d */
{ T, T, T, T, T, T, T, T, T, T, F, T },
/* m */
{ T, T, T, T, T, T, T, T, T, T, T, F }
};
private static int GetNumericTypeIndex(SpecialType specialType)
{
switch (specialType)
{
case SpecialType.System_SByte: return 0;
case SpecialType.System_Byte: return 1;
case SpecialType.System_Int16: return 2;
case SpecialType.System_UInt16: return 3;
case SpecialType.System_Int32: return 4;
case SpecialType.System_UInt32: return 5;
case SpecialType.System_Int64: return 6;
case SpecialType.System_UInt64: return 7;
case SpecialType.System_Char: return 8;
case SpecialType.System_Single: return 9;
case SpecialType.System_Double: return 10;
case SpecialType.System_Decimal: return 11;
default: return -1;
}
}
private static bool HasImplicitNumericConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
int sourceIndex = GetNumericTypeIndex(source.SpecialType);
if (sourceIndex < 0)
{
return false;
}
int destinationIndex = GetNumericTypeIndex(destination.SpecialType);
if (destinationIndex < 0)
{
return false;
}
return s_implicitNumericConversions[sourceIndex, destinationIndex];
}
private static bool HasExplicitNumericConversion(TypeSymbol source, TypeSymbol destination)
{
// SPEC: The explicit numeric conversions are the conversions from a numeric-type to another
// SPEC: numeric-type for which an implicit numeric conversion does not already exist.
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
int sourceIndex = GetNumericTypeIndex(source.SpecialType);
if (sourceIndex < 0)
{
return false;
}
int destinationIndex = GetNumericTypeIndex(destination.SpecialType);
if (destinationIndex < 0)
{
return false;
}
return s_explicitNumericConversions[sourceIndex, destinationIndex];
}
public static bool IsConstantNumericZero(ConstantValue value)
{
switch (value.Discriminator)
{
case ConstantValueTypeDiscriminator.SByte:
return value.SByteValue == 0;
case ConstantValueTypeDiscriminator.Byte:
return value.ByteValue == 0;
case ConstantValueTypeDiscriminator.Int16:
return value.Int16Value == 0;
case ConstantValueTypeDiscriminator.Int32:
return value.Int32Value == 0;
case ConstantValueTypeDiscriminator.Int64:
return value.Int64Value == 0;
case ConstantValueTypeDiscriminator.UInt16:
return value.UInt16Value == 0;
case ConstantValueTypeDiscriminator.UInt32:
return value.UInt32Value == 0;
case ConstantValueTypeDiscriminator.UInt64:
return value.UInt64Value == 0;
case ConstantValueTypeDiscriminator.Single:
case ConstantValueTypeDiscriminator.Double:
return value.DoubleValue == 0;
case ConstantValueTypeDiscriminator.Decimal:
return value.DecimalValue == 0;
}
return false;
}
public static bool IsNumericType(SpecialType specialType)
{
switch (specialType)
{
case SpecialType.System_Char:
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64:
case SpecialType.System_Single:
case SpecialType.System_Double:
case SpecialType.System_Decimal:
return true;
default:
return false;
}
}
private static bool HasSpecialIntPtrConversion(TypeSymbol source, TypeSymbol target)
{
Debug.Assert((object)source != null);
Debug.Assert((object)target != null);
// There are only a total of twelve user-defined explicit conversions on IntPtr and UIntPtr:
//
// IntPtr <---> int
// IntPtr <---> long
// IntPtr <---> void*
// UIntPtr <---> uint
// UIntPtr <---> ulong
// UIntPtr <---> void*
//
// The specification says that you can put any *standard* implicit or explicit conversion
// on "either side" of a user-defined explicit conversion, so the specification allows, say,
// UIntPtr --> byte because the conversion UIntPtr --> uint is user-defined and the
// conversion uint --> byte is "standard". It is "standard" because the conversion
// byte --> uint is an implicit numeric conversion.
// This means that certain conversions should be illegal. For example, IntPtr --> ulong
// should be illegal because none of int --> ulong, long --> ulong and void* --> ulong
// are "standard" conversions.
// Similarly, some conversions involving IntPtr should be illegal because they are
// ambiguous. byte --> IntPtr?, for example, is ambiguous. (There are four possible
// UD operators: int --> IntPtr and long --> IntPtr, and their lifted versions. The
// best possible source type is int, the best possible target type is IntPtr?, and
// there is an ambiguity between the unlifted int --> IntPtr, and the lifted
// int? --> IntPtr? conversions.)
// In practice, the native compiler, and hence, the Roslyn compiler, allows all
// these conversions. Any conversion from a numeric type to IntPtr, or from an IntPtr
// to a numeric type, is allowed. Also, any conversion from a pointer type to IntPtr
// or vice versa is allowed.
var s0 = source.StrippedType();
var t0 = target.StrippedType();
if (s0.SpecialType != SpecialType.System_UIntPtr &&
s0.SpecialType != SpecialType.System_IntPtr &&
t0.SpecialType != SpecialType.System_UIntPtr &&
t0.SpecialType != SpecialType.System_IntPtr)
{
return false;
}
TypeSymbol otherType = (s0.SpecialType == SpecialType.System_UIntPtr || s0.SpecialType == SpecialType.System_IntPtr) ? t0 : s0;
if (otherType.TypeKind == TypeKind.Pointer)
{
return true;
}
if (otherType.TypeKind == TypeKind.Enum)
{
return true;
}
switch (otherType.SpecialType)
{
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Char:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64:
case SpecialType.System_Double:
case SpecialType.System_Single:
case SpecialType.System_Decimal:
return true;
}
return false;
}
private static bool HasExplicitEnumerationConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: The explicit enumeration conversions are:
// SPEC: From sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal to any enum-type.
// SPEC: From any enum-type to sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal.
// SPEC: From any enum-type to any other enum-type.
if (IsNumericType(source.SpecialType) && destination.IsEnumType())
{
return true;
}
if (IsNumericType(destination.SpecialType) && source.IsEnumType())
{
return true;
}
if (source.IsEnumType() && destination.IsEnumType())
{
return true;
}
return false;
}
private static bool HasImplicitNullableConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: Predefined implicit conversions that operate on non-nullable value types can also be used with
// SPEC: nullable forms of those types. For each of the predefined implicit identity and numeric conversions
// SPEC: that convert from a non-nullable value type S to a non-nullable value type T, the following implicit
// SPEC: nullable conversions exist:
// SPEC: * An implicit conversion from S? to T?.
// SPEC: * An implicit conversion from S to T?.
if (!destination.IsNullableType())
{
return false;
}
TypeSymbol unwrappedDestination = destination.GetNullableUnderlyingType();
TypeSymbol unwrappedSource = source.StrippedType();
if (!unwrappedSource.IsValueType)
{
return false;
}
if (HasIdentityConversion(unwrappedSource, unwrappedDestination))
{
return true;
}
if (HasImplicitNumericConversion(unwrappedSource, unwrappedDestination))
{
return true;
}
return false;
}
private static bool HasExplicitNullableConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: Explicit nullable conversions permit predefined explicit conversions that operate on
// SPEC: non-nullable value types to also be used with nullable forms of those types. For
// SPEC: each of the predefined explicit conversions that convert from a non-nullable value type
// SPEC: S to a non-nullable value type T, the following nullable conversions exist:
// SPEC: An explicit conversion from S? to T?.
// SPEC: An explicit conversion from S to T?.
// SPEC: An explicit conversion from S? to T.
if (!source.IsNullableType() && !destination.IsNullableType())
{
return false;
}
TypeSymbol sourceUnderlying = source.StrippedType();
TypeSymbol destinationUnderlying = destination.StrippedType();
if (HasIdentityConversion(sourceUnderlying, destinationUnderlying))
{
return true;
}
if (HasImplicitNumericConversion(sourceUnderlying, destinationUnderlying))
{
return true;
}
if (HasExplicitNumericConversion(sourceUnderlying, destinationUnderlying))
{
return true;
}
if (HasExplicitEnumerationConversion(sourceUnderlying, destinationUnderlying))
{
return true;
}
if (HasPointerToIntegerConversion(sourceUnderlying, destinationUnderlying))
{
return true;
}
return false;
}
private bool HasCovariantArrayConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
var s = source as ArrayTypeSymbol;
var d = destination as ArrayTypeSymbol;
if ((object)s == null || (object)d == null)
{
return false;
}
// * S and T differ only in element type. In other words, S and T have the same number of dimensions.
// * Both SE and TE are reference types.
// * An implicit reference conversion exists from SE to TE.
return
s.HasSameShapeAs(d) &&
HasImplicitReferenceConversion(s.ElementType, d.ElementType, ref useSiteDiagnostics);
}
public bool HasIdentityOrImplicitReferenceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (HasIdentityConversion(source, destination))
{
return true;
}
return HasImplicitReferenceConversion(source, destination, ref useSiteDiagnostics);
}
private static bool HasImplicitDynamicConversionFromExpression(TypeSymbol expressionType, TypeSymbol destination)
{
// Spec (§6.1.8)
// An implicit dynamic conversion exists from an expression of type dynamic to any type T.
Debug.Assert((object)destination != null);
return (object)expressionType != null && expressionType.Kind == SymbolKind.DynamicType && !destination.IsPointerType();
}
private static bool HasExplicitDynamicConversion(TypeSymbol source, TypeSymbol destination)
{
// SPEC: An explicit dynamic conversion exists from an expression of type dynamic to any type T.
// ISSUE: Note that this is exactly the same as an implicit dynamic conversion. Conversion of
// ISSUE: dynamic to int is both an explicit dynamic conversion and an implicit dynamic conversion.
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
return source.Kind == SymbolKind.DynamicType && !destination.IsPointerType();
}
private bool HasArrayConversionToInterface(ArrayTypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (!source.IsSZArray)
{
return false;
}
if (!destination.IsInterfaceType())
{
return false;
}
// The specification says that there is a conversion:
// * From a single-dimensional array type S[] to IList<T> and its base
// interfaces, provided that there is an implicit identity or reference
// conversion from S to T.
//
// Newer versions of the framework also have arrays be convertible to
// IReadOnlyList<T> and IReadOnlyCollection<T>; we honor that as well.
//
// Therefore we must check for:
//
// IList<T>
// ICollection<T>
// IEnumerable<T>
// IEnumerable
// IReadOnlyList<T>
// IReadOnlyCollection<T>
if (destination.SpecialType == SpecialType.System_Collections_IEnumerable)
{
return true;
}
NamedTypeSymbol destinationAgg = (NamedTypeSymbol)destination;
if (destinationAgg.AllTypeArgumentCount() != 1)
{
return false;
}
if (!destinationAgg.IsPossibleArrayGenericInterface())
{
return false;
}
TypeSymbol argument0 = destinationAgg.TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteDiagnostics);
return HasIdentityOrImplicitReferenceConversion(source.ElementType, argument0, ref useSiteDiagnostics);
}
private bool HasImplicitReferenceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (source.IsErrorType())
{
return false;
}
if (!source.IsReferenceType)
{
return false;
}
// SPEC: The implicit reference conversions are:
// SPEC: UNDONE: From any reference-type to a reference-type T if it has an implicit identity
// SPEC: UNDONE: or reference conversion to a reference-type T0 and T0 has an identity conversion to T.
// UNDONE: Is the right thing to do here to strip dynamic off and check for convertibility?
// SPEC: From any reference type to object and dynamic.
if (destination.SpecialType == SpecialType.System_Object || destination.Kind == SymbolKind.DynamicType)
{
return true;
}
switch (source.TypeKind)
{
case TypeKind.Class:
// SPEC: From any class type S to any class type T provided S is derived from T.
if (destination.IsClassType() && IsBaseClass(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasImplicitConversionToInterface(source, destination, ref useSiteDiagnostics))
{
return true;
}
break;
case TypeKind.Interface:
// SPEC: From any interface-type S to any interface-type T, provided S is derived from T.
// NOTE: This handles variance conversions
if (HasImplicitConversionToInterface(source, destination, ref useSiteDiagnostics))
{
return true;
}
break;
case TypeKind.Delegate:
// SPEC: From any delegate-type to System.Delegate and the interfaces it implements.
// NOTE: This handles variance conversions.
if (HasImplicitConversionFromDelegate(source, destination, ref useSiteDiagnostics))
{
return true;
}
break;
case TypeKind.TypeParameter:
if (HasImplicitReferenceTypeParameterConversion((TypeParameterSymbol)source, destination, ref useSiteDiagnostics))
{
return true;
}
break;
case TypeKind.Array:
// SPEC: From an array-type S ... to an array-type T, provided ...
// SPEC: From any array-type to System.Array and the interfaces it implements.
// SPEC: From a single-dimensional array type S[] to IList<T>, provided ...
if (HasImplicitConversionFromArray(source, destination, ref useSiteDiagnostics))
{
return true;
}
break;
}
// UNDONE: Implicit conversions involving type parameters that are known to be reference types.
return false;
}
private bool HasImplicitConversionToInterface(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (!destination.IsInterfaceType())
{
return false;
}
// * From any class type S to any interface type T provided S implements an interface
// convertible to T.
// * From any interface type S to any interface type T provided S implements an interface
// convertible to T.
// * From any interface type S to any interface type T provided S is not T and S is
// an interface convertible to T.
if (source.IsClassType() && HasAnyBaseInterfaceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (source.IsInterfaceType() && HasAnyBaseInterfaceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (source.IsInterfaceType() && source != destination && HasInterfaceVarianceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private bool HasImplicitConversionFromArray(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
ArrayTypeSymbol s = source as ArrayTypeSymbol;
if ((object)s == null)
{
return false;
}
// * From an array type S with an element type SE to an array type T with element type TE
// provided that all of the following are true:
// * S and T differ only in element type. In other words, S and T have the same number of dimensions.
// * Both SE and TE are reference types.
// * An implicit reference conversion exists from SE to TE.
if (HasCovariantArrayConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// * From any array type to System.Array or any interface implemented by System.Array.
if (destination.GetSpecialTypeSafe() == SpecialType.System_Array)
{
return true;
}
if (IsBaseInterface(destination, this.corLibrary.GetDeclaredSpecialType(SpecialType.System_Array), ref useSiteDiagnostics))
{
return true;
}
// * From a single-dimensional array type S[] to IList<T> and its base
// interfaces, provided that there is an implicit identity or reference
// conversion from S to T.
if (HasArrayConversionToInterface(s, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private bool HasImplicitConversionFromDelegate(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (!source.IsDelegateType())
{
return false;
}
// * From any delegate type to System.Delegate
//
// SPEC OMISSION:
//
// The spec should actually say
//
// * From any delegate type to System.Delegate
// * From any delegate type to System.MulticastDelegate
// * From any delegate type to any interface implemented by System.MulticastDelegate
var specialDestination = destination.GetSpecialTypeSafe();
if (specialDestination == SpecialType.System_MulticastDelegate ||
specialDestination == SpecialType.System_Delegate ||
IsBaseInterface(destination, this.corLibrary.GetDeclaredSpecialType(SpecialType.System_MulticastDelegate), ref useSiteDiagnostics))
{
return true;
}
// * From any delegate type S to a delegate type T provided S is not T and
// S is a delegate convertible to T
if (HasDelegateVarianceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
public bool HasImplicitTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (HasImplicitReferenceTypeParameterConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasImplicitBoxingTypeParameterConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if ((destination.TypeKind == TypeKind.TypeParameter) &&
source.DependsOn((TypeParameterSymbol)destination))
{
return true;
}
return false;
}
private bool HasImplicitReferenceTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (source.IsValueType)
{
return false; // Not a reference conversion.
}
// The following implicit conversions exist for a given type parameter T:
//
// * From T to its effective base class C.
// * From T to any base class of C.
// * From T to any interface implemented by C (or any interface variance-compatible with such)
if (HasImplicitEffectiveBaseConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// * From T to any interface type I in T's effective interface set, and
// from T to any base interface of I (or any interface variance-compatible with such)
if (HasImplicitEffectiveInterfaceSetConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// * From T to a type parameter U, provided T depends on U.
if ((destination.TypeKind == TypeKind.TypeParameter) &&
source.DependsOn((TypeParameterSymbol)destination))
{
return true;
}
return false;
}
// Spec 6.1.10: Implicit conversions involving type parameters
private bool HasImplicitEffectiveBaseConversion(TypeParameterSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
// * From T to its effective base class C.
var effectiveBaseClass = source.EffectiveBaseClass(ref useSiteDiagnostics);
if (HasIdentityConversion(effectiveBaseClass, destination))
{
return true;
}
// * From T to any base class of C.
if (IsBaseClass(effectiveBaseClass, destination, ref useSiteDiagnostics))
{
return true;
}
// * From T to any interface implemented by C (or any interface variance-compatible with such)
if (HasAnyBaseInterfaceConversion(effectiveBaseClass, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private bool HasImplicitEffectiveInterfaceSetConversion(TypeParameterSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if (!destination.IsInterfaceType())
{
return false;
}
// * From T to any interface type I in T's effective interface set, and
// from T to any base interface of I (or any interface variance-compatible with such)
foreach (var i in source.AllEffectiveInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasInterfaceVarianceConversion(i, destination, ref useSiteDiagnostics))
{
return true;
}
}
return false;
}
private bool HasAnyBaseInterfaceConversion(TypeSymbol derivedType, TypeSymbol baseType, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)derivedType != null);
Debug.Assert((object)baseType != null);
if (!baseType.IsInterfaceType())
{
return false;
}
var d = derivedType as NamedTypeSymbol;
if ((object)d == null)
{
return false;
}
foreach (var i in d.AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasInterfaceVarianceConversion(i, baseType, ref useSiteDiagnostics))
{
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// The rules for variant interface and delegate conversions are the same:
//
// An interface/delegate type S is convertible to an interface/delegate type T
// if and only if T is U<S1, ... Sn> and T is U<T1, ... Tn> such that for all
// parameters of U:
//
// * if the ith parameter of U is invariant then Si is exactly equal to Ti.
// * if the ith parameter of U is covariant then either Si is exactly equal
// to Ti, or there is an implicit reference conversion from Si to Ti.
// * if the ith parameter of U is contravariant then either Si is exactly
// equal to Ti, or there is an implicit reference conversion from Ti to Si.
private bool HasInterfaceVarianceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
NamedTypeSymbol s = source as NamedTypeSymbol;
NamedTypeSymbol d = destination as NamedTypeSymbol;
if ((object)s == null || (object)d == null)
{
return false;
}
if (!s.IsInterfaceType() || !d.IsInterfaceType())
{
return false;
}
return HasVariantConversion(s, d, ref useSiteDiagnostics);
}
private bool HasDelegateVarianceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
NamedTypeSymbol s = source as NamedTypeSymbol;
NamedTypeSymbol d = destination as NamedTypeSymbol;
if ((object)s == null || (object)d == null)
{
return false;
}
if (!s.IsDelegateType() || !d.IsDelegateType())
{
return false;
}
return HasVariantConversion(s, d, ref useSiteDiagnostics);
}
private bool HasVariantConversion(NamedTypeSymbol source, NamedTypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
// We check for overflows in HasVariantConversion, because they are only an issue
// in the presence of contravariant type parameters, which are not involved in
// most conversions.
// See VarianceTests for examples (e.g. TestVarianceConversionCycle,
// TestVarianceConversionInfiniteExpansion).
//
// CONSIDER: A more rigorous solution would mimic the CLI approach, which uses
// a combination of requiring finite instantiation closures (see section 9.2 of
// the CLI spec) and records previous conversion steps to check for cycles.
if (_currentRecursionDepth >= MaximumRecursionDepth)
{
// NOTE: The spec doesn't really address what happens if there's an overflow
// in our conversion check. It's sort of implied that the conversion "proof"
// should be finite, so we'll just say that no conversion is possible.
return false;
}
// Do a quick check up front to avoid instantiating a new Conversions object,
// if possible.
var quickResult = HasVariantConversionQuick(source, destination);
if (quickResult.HasValue())
{
return quickResult.Value();
}
return this.CreateInstance(_currentRecursionDepth + 1).
HasVariantConversionNoCycleCheck(source, destination, ref useSiteDiagnostics);
}
private static ThreeState HasVariantConversionQuick(NamedTypeSymbol source, NamedTypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (HasIdentityConversion(source, destination))
{
return ThreeState.True;
}
NamedTypeSymbol typeSymbol = source.OriginalDefinition;
if (typeSymbol != destination.OriginalDefinition)
{
return ThreeState.False;
}
return ThreeState.Unknown;
}
private bool HasVariantConversionNoCycleCheck(NamedTypeSymbol source, NamedTypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
var typeParameters = ArrayBuilder<TypeSymbol>.GetInstance();
var sourceTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
var destinationTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
try
{
source.OriginalDefinition.GetAllTypeArguments(typeParameters, ref useSiteDiagnostics);
source.GetAllTypeArguments(sourceTypeArguments, ref useSiteDiagnostics);
destination.GetAllTypeArguments(destinationTypeArguments, ref useSiteDiagnostics);
Debug.Assert(typeParameters.Count == sourceTypeArguments.Count);
Debug.Assert(typeParameters.Count == destinationTypeArguments.Count);
for (int paramIndex = 0; paramIndex < typeParameters.Count; ++paramIndex)
{
TypeSymbol sourceTypeArgument = sourceTypeArguments[paramIndex];
TypeSymbol destinationTypeArgument = destinationTypeArguments[paramIndex];
// If they're identical then this one is automatically good, so skip it.
if (HasIdentityConversion(sourceTypeArgument, destinationTypeArgument))
{
continue;
}
TypeParameterSymbol typeParameterSymbol = (TypeParameterSymbol)typeParameters[paramIndex];
if (typeParameterSymbol.Variance == VarianceKind.None)
{
return false;
}
if (typeParameterSymbol.Variance == VarianceKind.Out && !HasImplicitReferenceConversion(sourceTypeArgument, destinationTypeArgument, ref useSiteDiagnostics))
{
return false;
}
if (typeParameterSymbol.Variance == VarianceKind.In && !HasImplicitReferenceConversion(destinationTypeArgument, sourceTypeArgument, ref useSiteDiagnostics))
{
return false;
}
}
}
finally
{
typeParameters.Free();
sourceTypeArguments.Free();
destinationTypeArguments.Free();
}
return true;
}
// Spec 6.1.10
private bool HasImplicitBoxingTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (source.IsReferenceType)
{
return false; // Not a boxing conversion; both source and destination are references.
}
// The following implicit conversions exist for a given type parameter T:
//
// * From T to its effective base class C.
// * From T to any base class of C.
// * From T to any interface implemented by C (or any interface variance-compatible with such)
if (HasImplicitEffectiveBaseConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// * From T to any interface type I in T's effective interface set, and
// from T to any base interface of I (or any interface variance-compatible with such)
if (HasImplicitEffectiveInterfaceSetConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: From T to a type parameter U, provided T depends on U
if ((destination.TypeKind == TypeKind.TypeParameter) &&
source.DependsOn((TypeParameterSymbol)destination))
{
return true;
}
// SPEC: From T to a reference type I if it has an implicit conversion to a reference
// SPEC: type S0 and S0 has an identity conversion to S. At run-time the conversion
// SPEC: is executed the same way as the conversion to S0.
// REVIEW: If T is not known to be a reference type then the only way this clause can
// REVIEW: come into effect is if the target type is dynamic. Is that correct?
if (destination.Kind == SymbolKind.DynamicType)
{
return true;
}
return false;
}
public bool HasBoxingConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// Certain type parameter conversions are classified as boxing conversions.
if ((source.TypeKind == TypeKind.TypeParameter) &&
HasImplicitBoxingTypeParameterConversion((TypeParameterSymbol)source, destination, ref useSiteDiagnostics))
{
return true;
}
// The rest of the boxing conversions only operate when going from a value type to a
// reference type.
if (!source.IsValueType || !destination.IsReferenceType)
{
return false;
}
// A boxing conversion exists from a nullable type to a reference type if and only if a
// boxing conversion exists from the underlying type.
if (source.IsNullableType())
{
return HasBoxingConversion(source.GetNullableUnderlyingType(), destination, ref useSiteDiagnostics);
}
// A boxing conversion exists from any non-nullable value type to object and dynamic, to
// System.ValueType, and to any interface type variance-compatible with one implemented
// by the non-nullable value type.
// Furthermore, an enum type can be converted to the type System.Enum.
// We set the base class of the structs to System.ValueType, System.Enum, etc, so we can
// just check here.
// There are a couple of exceptions. The very special types ArgIterator, ArgumentHandle and
// TypedReference are not boxable:
if (source.IsRestrictedType())
{
return false;
}
if (destination.Kind == SymbolKind.DynamicType)
{
return !source.IsPointerType();
}
if (IsBaseClass(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasAnyBaseInterfaceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private static bool HasImplicitPointerConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: The set of implicit conversions is extended to include...
// SPEC: ... from any pointer type to the type void*.
PointerTypeSymbol pd = destination as PointerTypeSymbol;
PointerTypeSymbol ps = source as PointerTypeSymbol;
return (object)pd != null && (object)ps != null && pd.PointedAtType.SpecialType == SpecialType.System_Void;
}
private bool HasIdentityOrReferenceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (HasIdentityConversion(source, destination))
{
return true;
}
if (HasImplicitReferenceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasExplicitReferenceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private bool HasExplicitReferenceConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: The explicit reference conversions are:
// SPEC: From object and dynamic to any other reference type.
if (source.SpecialType == SpecialType.System_Object)
{
if (destination.IsReferenceType)
{
return true;
}
}
else if (source.Kind == SymbolKind.DynamicType && destination.IsReferenceType)
{
return true;
}
// SPEC: From any class-type S to any class-type T, provided S is a base class of T.
if (IsBaseClassOfClass(source, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T.
// ISSUE: class C : IEnumerable<Mammal> { } converting this to IEnumerable<Animal> is not an explicit conversion,
// ISSUE: it is an implicit conversion.
if (source.IsClassType() && destination.IsInterfaceType() && !source.IsSealed && !HasAnyBaseInterfaceConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: From any interface-type S to any class-type T, provided T is not sealed or provided T implements S.
// ISSUE: What if T is sealed and implements an interface variance-convertible to S?
// ISSUE: eg, sealed class C : IEnum<Mammal> { ... } you should be able to cast an IEnum<Animal> to C.
if (source.IsInterfaceType() && destination.IsClassType() && (!destination.IsSealed || HasAnyBaseInterfaceConversion(destination, source, ref useSiteDiagnostics)))
{
return true;
}
// SPEC: From any interface-type S to any interface-type T, provided S is not derived from T.
// ISSUE: This does not rule out identity conversions, which ought not to be classified as
// ISSUE: explicit reference conversions.
// ISSUE: IEnumerable<Mammal> and IEnumerable<Animal> do not derive from each other but this is
// ISSUE: not an explicit reference conversion, this is an implicit reference conversion.
if (source.IsInterfaceType() && destination.IsInterfaceType() && !HasImplicitConversionToInterface(source, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: UNDONE: From a reference type to a reference type T if it has an explicit reference conversion to a reference type T0 and T0 has an identity conversion T.
// SPEC: UNDONE: From a reference type to an interface or delegate type T if it has an explicit reference conversion to an interface or delegate type T0 and either T0 is variance-convertible to T or T is variance-convertible to T0 (§13.1.3.2).
if (HasExplicitArrayConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasExplicitDelegateConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
if (HasExplicitReferenceTypeParameterConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
// Spec 6.2.7 Explicit conversions involving type parameters
private bool HasExplicitReferenceTypeParameterConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
TypeParameterSymbol s = source as TypeParameterSymbol;
TypeParameterSymbol t = destination as TypeParameterSymbol;
// SPEC: The following explicit conversions exist for a given type parameter T:
// SPEC: If T is known to be a reference type, the conversions are all classified as explicit reference conversions.
// SPEC: If T is not known to be a reference type, the conversions are classified as unboxing conversions.
// SPEC: From the effective base class C of T to T and from any base class of C to T.
if ((object)t != null && t.IsReferenceType)
{
for (var type = t.EffectiveBaseClass(ref useSiteDiagnostics); (object)type != null; type = type.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasIdentityConversion(type, source))
{
return true;
}
}
}
// SPEC: From any interface type to T.
if ((object)t != null && source.IsInterfaceType() && t.IsReferenceType)
{
return true;
}
// SPEC: From T to any interface-type I provided there is not already an implicit conversion from T to I.
if ((object)s != null && s.IsReferenceType && destination.IsInterfaceType() && !HasImplicitReferenceTypeParameterConversion(s, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: From a type parameter U to T, provided T depends on U (§10.1.5)
if ((object)s != null && (object)t != null && t.IsReferenceType && t.DependsOn(s))
{
return true;
}
return false;
}
// Spec 6.2.7 Explicit conversions involving type parameters
private bool HasUnboxingTypeParameterConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
TypeParameterSymbol s = source as TypeParameterSymbol;
TypeParameterSymbol t = destination as TypeParameterSymbol;
// SPEC: The following explicit conversions exist for a given type parameter T:
// SPEC: If T is known to be a reference type, the conversions are all classified as explicit reference conversions.
// SPEC: If T is not known to be a reference type, the conversions are classified as unboxing conversions.
// SPEC: From the effective base class C of T to T and from any base class of C to T.
if ((object)t != null && !t.IsReferenceType)
{
for (var type = t.EffectiveBaseClass(ref useSiteDiagnostics); (object)type != null; type = type.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (type == source)
{
return true;
}
}
}
// SPEC: From any interface type to T.
if (source.IsInterfaceType() && (object)t != null && !t.IsReferenceType)
{
return true;
}
// SPEC: From T to any interface-type I provided there is not already an implicit conversion from T to I.
if ((object)s != null && !s.IsReferenceType && destination.IsInterfaceType() && !HasImplicitReferenceTypeParameterConversion(s, destination, ref useSiteDiagnostics))
{
return true;
}
// SPEC: From a type parameter U to T, provided T depends on U (§10.1.5)
if ((object)s != null && (object)t != null && !t.IsReferenceType && t.DependsOn(s))
{
return true;
}
return false;
}
private bool HasExplicitDelegateConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
// SPEC: From System.Delegate and the interfaces it implements to any delegate-type.
// We also support System.MulticastDelegate in the implementation, in spite of it not being mentioned in the spec.
if (destination.IsDelegateType())
{
if (source.SpecialType == SpecialType.System_Delegate || source.SpecialType == SpecialType.System_MulticastDelegate)
{
return true;
}
if (HasImplicitConversionToInterface(this.corLibrary.GetDeclaredSpecialType(SpecialType.System_Delegate), source, ref useSiteDiagnostics))
{
return true;
}
}
// SPEC: From D<S1...Sn> to a D<T1...Tn> where D<X1...Xn> is a generic delegate type, D<S1...Sn> is not compatible with or identical to D<T1...Tn>,
// SPEC: and for each type parameter Xi of D the following holds:
// SPEC: If Xi is invariant, then Si is identical to Ti.
// SPEC: If Xi is covariant, then there is an implicit or explicit identity or reference conversion from Si to Ti.
// SPECL If Xi is contravariant, then Si and Ti are either identical or both reference types.
if (!source.IsDelegateType() || !destination.IsDelegateType())
{
return false;
}
if (source.OriginalDefinition != destination.OriginalDefinition)
{
return false;
}
var sourceType = (NamedTypeSymbol)source;
var destinationType = (NamedTypeSymbol)destination;
var original = sourceType.OriginalDefinition;
if (HasIdentityConversion(source, destination))
{
return false;
}
if (HasDelegateVarianceConversion(source, destination, ref useSiteDiagnostics))
{
return false;
}
var sourceTypeArguments = sourceType.TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
var destinationTypeArguments = destinationType.TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
for (int i = 0; i < sourceTypeArguments.Length; ++i)
{
var sourceArg = sourceTypeArguments[i];
var destinationArg = destinationTypeArguments[i];
switch (original.TypeParameters[i].Variance)
{
case VarianceKind.None:
if (!HasIdentityConversion(sourceArg, destinationArg))
{
return false;
}
break;
case VarianceKind.Out:
if (!HasIdentityOrReferenceConversion(sourceArg, destinationArg, ref useSiteDiagnostics))
{
return false;
}
break;
case VarianceKind.In:
bool hasIdentityConversion = HasIdentityConversion(sourceArg, destinationArg);
bool bothAreReferenceTypes = sourceArg.IsReferenceType && destinationArg.IsReferenceType;
if (!(hasIdentityConversion || bothAreReferenceTypes))
{
return false;
}
break;
}
}
return true;
}
private bool HasExplicitArrayConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
var sourceArray = source as ArrayTypeSymbol;
var destinationArray = destination as ArrayTypeSymbol;
// SPEC: From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true:
// SPEC: S and T differ only in element type. (In other words, S and T have the same number of dimensions.)
// SPEC: Both SE and TE are reference-types.
// SPEC: An explicit reference conversion exists from SE to TE.
if ((object)sourceArray != null && (object)destinationArray != null)
{
// HasExplicitReferenceConversion checks that SE and TE are reference types so
// there's no need for that check here. Moreover, it's not as simple as checking
// IsReferenceType, at least not in the case of type parameters, since SE will be
// considered a reference type implicitly in the case of "where TE : class, SE" even
// though SE.IsReferenceType may be false. Again, HasExplicitReferenceConversion
// already handles these cases.
return sourceArray.HasSameShapeAs(destinationArray) &&
HasExplicitReferenceConversion(sourceArray.ElementType, destinationArray.ElementType, ref useSiteDiagnostics);
}
// SPEC: From System.Array and the interfaces it implements to any array-type.
if ((object)destinationArray != null)
{
if (source.SpecialType == SpecialType.System_Array)
{
return true;
}
foreach (var iface in this.corLibrary.GetDeclaredSpecialType(SpecialType.System_Array).AllInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
if (HasIdentityConversion(iface, source))
{
return true;
}
}
}
// SPEC: From a single-dimensional array type S[] to System.Collections.Generic.IList<T> and its base interfaces
// SPEC: provided that there is an explicit reference conversion from S to T.
// The framework now also allows arrays to be converted to IReadOnlyList<T> and IReadOnlyCollection<T>; we
// honor that as well.
if ((object)sourceArray != null && sourceArray.IsSZArray && destination.IsPossibleArrayGenericInterface())
{
if (HasExplicitReferenceConversion(sourceArray.ElementType, ((NamedTypeSymbol)destination).TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteDiagnostics), ref useSiteDiagnostics))
{
return true;
}
}
// SPEC: From System.Collections.Generic.IList<S> and its base interfaces to a single-dimensional array type T[],
// provided that there is an explicit identity or reference conversion from S to T.
// Similarly, we honor IReadOnlyList<S> and IReadOnlyCollection<S> in the same way.
if ((object)destinationArray != null && destinationArray.IsSZArray)
{
var specialDefinition = ((TypeSymbol)source.OriginalDefinition).SpecialType;
if (specialDefinition == SpecialType.System_Collections_Generic_IList_T ||
specialDefinition == SpecialType.System_Collections_Generic_ICollection_T ||
specialDefinition == SpecialType.System_Collections_Generic_IEnumerable_T ||
specialDefinition == SpecialType.System_Collections_Generic_IReadOnlyList_T ||
specialDefinition == SpecialType.System_Collections_Generic_IReadOnlyCollection_T)
{
var sourceElement = ((NamedTypeSymbol)source).TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteDiagnostics);
var destinationElement = destinationArray.ElementType;
if (HasIdentityConversion(sourceElement, destinationElement))
{
return true;
}
if (HasImplicitReferenceConversion(sourceElement, destinationElement, ref useSiteDiagnostics))
{
return true;
}
if (HasExplicitReferenceConversion(sourceElement, destinationElement, ref useSiteDiagnostics))
{
return true;
}
}
}
return false;
}
private bool HasUnboxingConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (destination.IsPointerType())
{
return false;
}
// SPEC: An unboxing conversion permits a reference type to be explicitly converted to a value-type.
// SPEC: An unboxing conversion exists from the types object and System.ValueType to any non-nullable-value-type,
var specialTypeSource = source.SpecialType;
if (specialTypeSource == SpecialType.System_Object || specialTypeSource == SpecialType.System_ValueType)
{
if (destination.IsValueType && !destination.IsNullableType())
{
return true;
}
}
// SPEC: and from any interface-type to any non-nullable-value-type that implements the interface-type.
if (source.IsInterfaceType() &&
destination.IsValueType &&
!destination.IsNullableType() &&
HasBoxingConversion(destination, source, ref useSiteDiagnostics))
{
return true;
}
// SPEC: Furthermore type System.Enum can be unboxed to any enum-type.
if (source.SpecialType == SpecialType.System_Enum && destination.IsEnumType())
{
return true;
}
// SPEC: An unboxing conversion exists from a reference type to a nullable-type if an unboxing
// SPEC: conversion exists from the reference type to the underlying non-nullable-value-type
// SPEC: of the nullable-type.
if (source.IsReferenceType &&
destination.IsNullableType() &&
HasUnboxingConversion(source, destination.GetNullableUnderlyingType(), ref useSiteDiagnostics))
{
return true;
}
// SPEC: UNDONE A value type S has an unboxing conversion from an interface type I if it has an unboxing
// SPEC: UNDONE conversion from an interface type I0 and I0 has an identity conversion to I.
// SPEC: UNDONE A value type S has an unboxing conversion from an interface type I if it has an unboxing conversion
// SPEC: UNDONE from an interface or delegate type I0 and either I0 is variance-convertible to I or I is variance-convertible to I0.
if (HasUnboxingTypeParameterConversion(source, destination, ref useSiteDiagnostics))
{
return true;
}
return false;
}
private static bool HasPointerToPointerConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
return source is PointerTypeSymbol && destination is PointerTypeSymbol;
}
private static bool HasPointerToIntegerConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (!(source is PointerTypeSymbol))
{
return false;
}
// SPEC OMISSION:
//
// The spec should state that any pointer type is convertible to
// sbyte, byte, ... etc, or any corresponding nullable type.
switch (destination.StrippedType().SpecialType)
{
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64:
return true;
}
return false;
}
private static bool HasIntegerToPointerConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
if (!(destination is PointerTypeSymbol))
{
return false;
}
// Note that void* is convertible to int?, but int? is not convertible to void*.
switch (source.SpecialType)
{
case SpecialType.System_SByte:
case SpecialType.System_Byte:
case SpecialType.System_Int16:
case SpecialType.System_UInt16:
case SpecialType.System_Int32:
case SpecialType.System_UInt32:
case SpecialType.System_Int64:
case SpecialType.System_UInt64:
return true;
}
return false;
}
}
}
| VPashkov/roslyn | src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs | C# | apache-2.0 | 92,300 |
# Copyright 2013 Google Inc. 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.
# Sets up ssh keys on the master and then uploads them to a GCS CONFIGBUCKET
# for worker to later download.
set -e
mkdir -p /home/hadoop/.ssh/
chmod 700 /home/hadoop/.ssh
PRIVATE_KEY_NAME='hadoop_master_id_rsa'
PUBLIC_KEY_NAME="${PRIVATE_KEY_NAME}.pub"
LOCAL_PUBLIC_KEY="/home/hadoop/.ssh/${PUBLIC_KEY_NAME}"
REMOTE_PUBLIC_KEY="${BDUTIL_GCS_STAGING_DIR}/${PUBLIC_KEY_NAME}"
LOCAL_PRIVATE_KEY="/home/hadoop/.ssh/${PRIVATE_KEY_NAME}"
ssh-keygen -N "" -f ${LOCAL_PRIVATE_KEY}
# Authorize ssh into self as well, in case the master is also a worker node.
cat ${LOCAL_PUBLIC_KEY} >> /home/hadoop/.ssh/authorized_keys
echo "Host ${PREFIX}*" >> /home/hadoop/.ssh/config
echo " IdentityFile ${LOCAL_PRIVATE_KEY}" >> /home/hadoop/.ssh/config
echo ' UserKnownHostsFile /dev/null' >> /home/hadoop/.ssh/config
echo ' CheckHostIP no' >> /home/hadoop/.ssh/config
echo ' StrictHostKeyChecking no' >> /home/hadoop/.ssh/config
gsutil cp ${LOCAL_PUBLIC_KEY} ${REMOTE_PUBLIC_KEY}
| gruter/bdutil | libexec/setup_master_ssh.sh | Shell | apache-2.0 | 1,570 |
<!DOCTYPE html>
<title>FileReader: starting new reads while one is in progress</title>
<link rel="author" title="Yinkan Li" href="mailto:liyinkan.biz@gmail.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#MultipleReads">
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
var reader = new FileReader();
reader.readAsText(blob_1)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
assert_throws("InvalidStateError", function () {
reader.readAsText(blob_2)
})
}, 'test FileReader InvalidStateError exception for readAsText');
test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
var reader = new FileReader();
reader.readAsDataURL(blob_1)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
assert_throws("InvalidStateError", function () {
reader.readAsDataURL(blob_2)
})
}, 'test FileReader InvalidStateError exception for readAsDataURL');
test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
var reader = new FileReader();
reader.readAsArrayBuffer(blob_1)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
assert_throws("InvalidStateError", function () {
reader.readAsArrayBuffer(blob_2)
})
}, 'test FileReader InvalidStateError exception for readAsArrayBuffer');
async_test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
var reader = new FileReader();
var triggered = false;
reader.onloadstart = this.step_func_done(function() {
assert_false(triggered, "Only one loadstart event should be dispatched");
triggered = true;
assert_equals(reader.readyState, FileReader.LOADING,
"readyState must be LOADING")
assert_throws("InvalidStateError", function () {
reader.readAsArrayBuffer(blob_2)
})
});
reader.readAsArrayBuffer(blob_1)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
}, 'test FileReader InvalidStateError exception in onloadstart event for readAsArrayBuffer');
async_test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
var reader = new FileReader();
reader.onloadend = this.step_func_done(function() {
assert_equals(reader.readyState, FileReader.LOADING,
"readyState must be LOADING")
reader.readAsArrayBuffer(blob_2)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
});
reader.readAsArrayBuffer(blob_1)
assert_equals(reader.readyState, FileReader.LOADING, "readyState Must be LOADING")
}, 'test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer');
</script>
| axinging/chromium-crosswalk | third_party/WebKit/LayoutTests/imported/wpt/FileAPI/reading-data-section/FileReader-multiple-reads.html | HTML | bsd-3-clause | 3,048 |
<BODY>
Demo/Test SVG area. Tiny line is integrated to render-to-texture - however a full implementation is
to follow rendering SVG to OpenGL geometric shapes.
</BODY> | TomyLobo/Slick | src/main/java/org/newdawn/slick/svg/package.html | HTML | bsd-3-clause | 166 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/window_animations.h"
#include <math.h>
#include <algorithm>
#include <vector>
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/time/time.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/geometry/vector3d_f.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/screen.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/window_util.h"
namespace ash {
namespace {
const int kLayerAnimationsForMinimizeDurationMS = 200;
// Durations for the cross-fade animation, in milliseconds.
const float kCrossFadeDurationMinMs = 200.f;
const float kCrossFadeDurationMaxMs = 400.f;
// Durations for the brightness/grayscale fade animation, in milliseconds.
const int kBrightnessGrayscaleFadeDurationMs = 1000;
// Brightness/grayscale values for hide/show window animations.
const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
const float kWindowAnimation_HideOpacity = 0.f;
const float kWindowAnimation_ShowOpacity = 1.f;
// Scales for AshWindow above/below current workspace.
const float kLayerScaleAboveSize = 1.1f;
const float kLayerScaleBelowSize = .9f;
int64 Round64(float f) {
return static_cast<int64>(f + 0.5f);
}
base::TimeDelta GetCrossFadeDuration(aura::Window* window,
const gfx::RectF& old_bounds,
const gfx::Rect& new_bounds) {
if (::wm::WindowAnimationsDisabled(window))
return base::TimeDelta();
int old_area = static_cast<int>(old_bounds.width() * old_bounds.height());
int new_area = new_bounds.width() * new_bounds.height();
int max_area = std::max(old_area, new_area);
// Avoid divide by zero.
if (max_area == 0)
return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
int delta_area = std::abs(old_area - new_area);
// If the area didn't change, the animation is instantaneous.
if (delta_area == 0)
return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
float factor =
static_cast<float>(delta_area) / static_cast<float>(max_area);
const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs;
return base::TimeDelta::FromMilliseconds(
Round64(kCrossFadeDurationMinMs + (factor * kRange)));
}
} // namespace
const int kCrossFadeDurationMS = 200;
void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// Recalculate the transform at restore time since the launcher item may have
// moved while the window was minimized.
gfx::Rect bounds = window->bounds();
gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window);
target_bounds =
ScreenUtil::ConvertRectFromScreen(window->parent(), target_bounds);
float scale_x = static_cast<float>(target_bounds.width()) / bounds.width();
float scale_y = static_cast<float>(target_bounds.height()) / bounds.height();
scoped_ptr<ui::InterpolatedTransform> scale(
new ui::InterpolatedScale(gfx::Point3F(1, 1, 1),
gfx::Point3F(scale_x, scale_y, 1)));
scoped_ptr<ui::InterpolatedTransform> translation(
new ui::InterpolatedTranslation(
gfx::Point(),
gfx::Point(target_bounds.x() - bounds.x(),
target_bounds.y() - bounds.y())));
scale->SetChild(translation.release());
scale->SetReversed(show);
base::TimeDelta duration = window->layer()->GetAnimator()->
GetTransitionDuration();
scoped_ptr<ui::LayerAnimationElement> transition(
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
scale.release(), duration));
transition->set_tween_type(
show ? gfx::Tween::EASE_IN : gfx::Tween::EASE_IN_OUT);
window->layer()->GetAnimator()->ScheduleAnimation(
new ui::LayerAnimationSequence(transition.release()));
// When hiding a window, turn off blending until the animation is 3 / 4 done
// to save bandwidth and reduce jank.
if (!show) {
window->layer()->GetAnimator()->SchedulePauseForProperties(
(duration * 3) / 4, ui::LayerAnimationElement::OPACITY);
}
// Fade in and out quickly when the window is small to reduce jank.
float opacity = show ? 1.0f : 0.0f;
window->layer()->GetAnimator()->ScheduleAnimation(
new ui::LayerAnimationSequence(
ui::LayerAnimationElement::CreateOpacityElement(
opacity, duration / 4)));
// Reset the transform to identity when the minimize animation is completed.
window->layer()->GetAnimator()->ScheduleAnimation(
new ui::LayerAnimationSequence(
ui::LayerAnimationElement::CreateTransformElement(
gfx::Transform(),
base::TimeDelta())));
}
void AnimateShowWindow_Minimize(aura::Window* window) {
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
kLayerAnimationsForMinimizeDurationMS);
settings.SetTransitionDuration(duration);
AddLayerAnimationsForMinimize(window, true);
// Now that the window has been restored, we need to clear its animation style
// to default so that normal animation applies.
::wm::SetWindowVisibilityAnimationType(
window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
}
void AnimateHideWindow_Minimize(aura::Window* window) {
// Property sets within this scope will be implicitly animated.
::wm::ScopedHidingAnimationSettings hiding_settings(window);
base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
kLayerAnimationsForMinimizeDurationMS);
hiding_settings.layer_animation_settings()->SetTransitionDuration(duration);
window->layer()->SetVisible(false);
AddLayerAnimationsForMinimize(window, false);
}
void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
bool show) {
float start_value, end_value;
if (show) {
start_value = kWindowAnimation_HideBrightnessGrayscale;
end_value = kWindowAnimation_ShowBrightnessGrayscale;
} else {
start_value = kWindowAnimation_ShowBrightnessGrayscale;
end_value = kWindowAnimation_HideBrightnessGrayscale;
}
window->layer()->SetLayerBrightness(start_value);
window->layer()->SetLayerGrayscale(start_value);
if (show) {
window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
window->layer()->SetVisible(true);
}
base::TimeDelta duration =
base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
if (show) {
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
window->layer()->GetAnimator()->
ScheduleTogether(
CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
} else {
::wm::ScopedHidingAnimationSettings hiding_settings(window);
window->layer()->GetAnimator()->
ScheduleTogether(
CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
window->layer()->SetVisible(false);
}
}
void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
}
void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
}
bool AnimateShowWindow(aura::Window* window) {
if (!::wm::HasWindowVisibilityAnimationTransition(
window, ::wm::ANIMATE_SHOW)) {
return false;
}
switch (::wm::GetWindowVisibilityAnimationType(window)) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateShowWindow_Minimize(window);
return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
AnimateShowWindow_BrightnessGrayscale(window);
return true;
default:
NOTREACHED();
return false;
}
}
bool AnimateHideWindow(aura::Window* window) {
if (!::wm::HasWindowVisibilityAnimationTransition(
window, ::wm::ANIMATE_HIDE)) {
return false;
}
switch (::wm::GetWindowVisibilityAnimationType(window)) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateHideWindow_Minimize(window);
return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
AnimateHideWindow_BrightnessGrayscale(window);
return true;
default:
NOTREACHED();
return false;
}
}
// Observer for a window cross-fade animation. If either the window closes or
// the layer's animation completes or compositing is aborted due to GPU crash,
// it deletes the layer and removes itself as an observer.
class CrossFadeObserver : public ui::CompositorObserver,
public aura::WindowObserver,
public ui::ImplicitAnimationObserver {
public:
// Observes |window| for destruction, but does not take ownership.
// Takes ownership of |layer| and its child layers.
CrossFadeObserver(aura::Window* window,
scoped_ptr<ui::LayerTreeOwner> layer_owner)
: window_(window),
layer_owner_(layer_owner.Pass()) {
window_->AddObserver(this);
layer_owner_->root()->GetCompositor()->AddObserver(this);
}
~CrossFadeObserver() override {
window_->RemoveObserver(this);
window_ = NULL;
layer_owner_->root()->GetCompositor()->RemoveObserver(this);
}
// ui::CompositorObserver overrides:
void OnCompositingDidCommit(ui::Compositor* compositor) override {}
void OnCompositingStarted(ui::Compositor* compositor,
base::TimeTicks start_time) override {}
void OnCompositingEnded(ui::Compositor* compositor) override {}
void OnCompositingAborted(ui::Compositor* compositor) override {
// Triggers OnImplicitAnimationsCompleted() to be called and deletes us.
layer_owner_->root()->GetAnimator()->StopAnimating();
}
void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
// aura::WindowObserver overrides:
void OnWindowDestroying(aura::Window* window) override {
// Triggers OnImplicitAnimationsCompleted() to be called and deletes us.
layer_owner_->root()->GetAnimator()->StopAnimating();
}
void OnWindowRemovingFromRootWindow(aura::Window* window,
aura::Window* new_root) override {
layer_owner_->root()->GetAnimator()->StopAnimating();
}
// ui::ImplicitAnimationObserver overrides:
void OnImplicitAnimationsCompleted() override { delete this; }
private:
aura::Window* window_; // not owned
scoped_ptr<ui::LayerTreeOwner> layer_owner_;
DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver);
};
base::TimeDelta CrossFadeAnimation(
aura::Window* window,
scoped_ptr<ui::LayerTreeOwner> old_layer_owner,
gfx::Tween::Type tween_type) {
DCHECK(old_layer_owner->root());
const gfx::Rect old_bounds(old_layer_owner->root()->bounds());
gfx::RectF old_transformed_bounds(old_bounds);
gfx::Transform old_transform(old_layer_owner->root()->transform());
gfx::Transform old_transform_in_root;
old_transform_in_root.Translate(old_bounds.x(), old_bounds.y());
old_transform_in_root.PreconcatTransform(old_transform);
old_transform_in_root.Translate(-old_bounds.x(), -old_bounds.y());
old_transform_in_root.TransformRect(&old_transformed_bounds);
const gfx::Rect new_bounds(window->bounds());
const bool old_on_top = (old_bounds.width() > new_bounds.width());
// Shorten the animation if there's not much visual movement.
const base::TimeDelta duration = GetCrossFadeDuration(window,
old_transformed_bounds, new_bounds);
// Scale up the old layer while translating to new position.
{
ui::Layer* old_layer = old_layer_owner->root();
old_layer->GetAnimator()->StopAnimating();
old_layer->SetTransform(old_transform);
ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator());
// Animation observer owns the old layer and deletes itself.
settings.AddObserver(new CrossFadeObserver(window, old_layer_owner.Pass()));
settings.SetTransitionDuration(duration);
settings.SetTweenType(tween_type);
gfx::Transform out_transform;
float scale_x = static_cast<float>(new_bounds.width()) /
static_cast<float>(old_bounds.width());
float scale_y = static_cast<float>(new_bounds.height()) /
static_cast<float>(old_bounds.height());
out_transform.Translate(new_bounds.x() - old_bounds.x(),
new_bounds.y() - old_bounds.y());
out_transform.Scale(scale_x, scale_y);
old_layer->SetTransform(out_transform);
if (old_on_top) {
// The old layer is on top, and should fade out. The new layer below will
// stay opaque to block the desktop.
old_layer->SetOpacity(kWindowAnimation_HideOpacity);
}
// In tests |old_layer| is deleted here, as animations have zero duration.
old_layer = NULL;
}
// Set the new layer's current transform, such that the user sees a scaled
// version of the window with the original bounds at the original position.
gfx::Transform in_transform;
const float scale_x = old_transformed_bounds.width() /
static_cast<float>(new_bounds.width());
const float scale_y = old_transformed_bounds.height() /
static_cast<float>(new_bounds.height());
in_transform.Translate(old_transformed_bounds.x() - new_bounds.x(),
old_transformed_bounds.y() - new_bounds.y());
in_transform.Scale(scale_x, scale_y);
window->layer()->SetTransform(in_transform);
if (!old_on_top) {
// The new layer is on top and should fade in. The old layer below will
// stay opaque and block the desktop.
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
}
{
// Animate the new layer to the identity transform, so the window goes to
// its newly set bounds.
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
settings.SetTransitionDuration(duration);
settings.SetTweenType(tween_type);
window->layer()->SetTransform(gfx::Transform());
if (!old_on_top) {
// New layer is on top, fade it in.
window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
}
}
return duration;
}
bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {
if (::wm::WindowAnimationsDisabled(window))
return false;
// Attempt to run CoreWm supplied animation types.
if (::wm::AnimateOnChildWindowVisibilityChanged(window, visible))
return true;
// Otherwise try to run an Ash-specific animation.
if (visible)
return AnimateShowWindow(window);
// Don't start hiding the window again if it's already being hidden.
return window->layer()->GetTargetOpacity() != 0.0f &&
AnimateHideWindow(window);
}
std::vector<ui::LayerAnimationSequence*>
CreateBrightnessGrayscaleAnimationSequence(float target_value,
base::TimeDelta duration) {
gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT;
scoped_ptr<ui::LayerAnimationSequence> brightness_sequence(
new ui::LayerAnimationSequence());
scoped_ptr<ui::LayerAnimationSequence> grayscale_sequence(
new ui::LayerAnimationSequence());
scoped_ptr<ui::LayerAnimationElement> brightness_element(
ui::LayerAnimationElement::CreateBrightnessElement(
target_value, duration));
brightness_element->set_tween_type(animation_type);
brightness_sequence->AddElement(brightness_element.release());
scoped_ptr<ui::LayerAnimationElement> grayscale_element(
ui::LayerAnimationElement::CreateGrayscaleElement(
target_value, duration));
grayscale_element->set_tween_type(animation_type);
grayscale_sequence->AddElement(grayscale_element.release());
std::vector<ui::LayerAnimationSequence*> animations;
animations.push_back(brightness_sequence.release());
animations.push_back(grayscale_sequence.release());
return animations;
}
// Returns scale related to the specified AshWindowScaleType.
void SetTransformForScaleAnimation(ui::Layer* layer,
LayerScaleAnimationDirection type) {
const float scale =
type == LAYER_SCALE_ANIMATION_ABOVE ? kLayerScaleAboveSize :
kLayerScaleBelowSize;
gfx::Transform transform;
transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2,
-layer->bounds().height() * (scale - 1.0f) / 2);
transform.Scale(scale, scale);
layer->SetTransform(transform);
}
gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
Shelf* shelf = Shelf::ForWindow(window);
// Shelf is created lazily and can be NULL.
if (!shelf)
return gfx::Rect();
gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(window);
// The launcher item is visible and has an icon.
if (!item_rect.IsEmpty())
return item_rect;
// If both the icon width and height are 0, then there is no icon in the
// launcher for |window|. If the launcher is auto hidden, one of the height or
// width will be 0 but the position in the launcher and the major dimension
// are still reported correctly and the window can be animated to the launcher
// item's light bar.
ShelfLayoutManager* layout_manager = ShelfLayoutManager::ForShelf(window);
if (item_rect.width() != 0 || item_rect.height() != 0) {
if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) {
gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen();
switch (layout_manager->GetAlignment()) {
case SHELF_ALIGNMENT_BOTTOM:
item_rect.set_y(shelf_bounds.y());
break;
case SHELF_ALIGNMENT_LEFT:
item_rect.set_x(shelf_bounds.right());
break;
case SHELF_ALIGNMENT_RIGHT:
item_rect.set_x(shelf_bounds.x());
break;
case SHELF_ALIGNMENT_TOP:
item_rect.set_y(shelf_bounds.bottom());
break;
}
return item_rect;
}
}
// Coming here, there is no visible icon of that shelf item and we zoom back
// to the location of the application launcher (which is fixed as first item
// of the shelf).
gfx::Rect work_area =
Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x();
switch (layout_manager->GetAlignment()) {
case SHELF_ALIGNMENT_BOTTOM:
return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0);
case SHELF_ALIGNMENT_TOP:
return gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0);
case SHELF_ALIGNMENT_LEFT:
return gfx::Rect(work_area.x(), work_area.y(), 0, 0);
case SHELF_ALIGNMENT_RIGHT:
return gfx::Rect(work_area.right(), work_area.y(), 0, 0);
}
NOTREACHED();
return gfx::Rect();
}
} // namespace ash
| Chilledheart/chromium | ash/wm/window_animations.cc | C++ | bsd-3-clause | 19,933 |
// Copyright 2013 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 "content/shell/app/shell_breakpad_client.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/content_switches.h"
#include "content/shell/common/shell_switches.h"
#if defined(OS_ANDROID)
#include "content/shell/android/shell_descriptors.h"
#endif
namespace content {
ShellBreakpadClient::ShellBreakpadClient() {}
ShellBreakpadClient::~ShellBreakpadClient() {}
#if defined(OS_WIN)
void ShellBreakpadClient::GetProductNameAndVersion(
const base::FilePath& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build,
base::string16* channel_name) {
*product_name = base::ASCIIToUTF16("content_shell");
*version = base::ASCIIToUTF16(CONTENT_SHELL_VERSION);
*special_build = base::string16();
*channel_name = base::string16();
}
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
void ShellBreakpadClient::GetProductNameAndVersion(std::string* product_name,
std::string* version) {
*product_name = "content_shell";
*version = CONTENT_SHELL_VERSION;
}
base::FilePath ShellBreakpadClient::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
}
#endif
bool ShellBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir))
return false;
*crash_dir = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kCrashDumpsDir);
return true;
}
#if defined(OS_ANDROID)
int ShellBreakpadClient::GetAndroidMinidumpDescriptor() {
return kAndroidMinidumpDescriptor;
}
#endif
bool ShellBreakpadClient::EnableBreakpadForProcess(
const std::string& process_type) {
return process_type == switches::kRendererProcess ||
process_type == switches::kPluginProcess ||
process_type == switches::kPpapiPluginProcess ||
process_type == switches::kZygoteProcess ||
process_type == switches::kGpuProcess;
}
} // namespace content
| 7kbird/chrome | content/shell/app/shell_breakpad_client.cc | C++ | bsd-3-clause | 2,337 |
<?php
/**
* CancelTaxRequest.class.php
*/
/**
* Data to pass to CancelTax indicating
* the document that should be cancelled and the reason for the operation.
* <p>
* A document can be indicated solely by the DocId if it is known.
* Otherwise the request must specify all of CompanyCode,
* DocCode, and
* DocType in order to uniquely identify the document.
* </p>
*
* @see CancelTaxResult, DocumentType
*
* @author Avalara
* @copyright © 2004 - 2011 Avalara, Inc. All rights reserved.
* @package Tax
*/
class CancelTaxRequest extends TaxRequest
{
private $CancelCode; //Unspecified or PostFailed or DocDeleted or DocVoided or AdjustmentCancelled
public function __construct()
{
$this->DocType = DocumentType::$SalesInvoice; // this is right Document
$this->CancelCode = CancelCode::$Unspecified;
}
/**
* A code indicating the reason the document is getting canceled.
*
* @return string
* @see CancelCode
*/
public function getCancelCode() { return $this->CancelCode; }
/**
* A code indicating the reason the document is getting canceled.
*
* @var string
* @see CancelCode
*/
public function setCancelCode($value) { CancelCode::Validate($value); $this->CancelCode = $value; return $this; }
}
?> | yaelduckwen/lo_imaginario | web2/plugins/vmcalculation/avalara/classes/CancelTaxRequest.class.php | PHP | mit | 1,320 |
class ConstructorsConfiguration {
int x;
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public ConstructorsConfiguration(final int x) {
this.x = x;
}
}
class ConstructorsConfigurationExplicit {
int x;
@java.beans.ConstructorProperties({"x"})
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public ConstructorsConfigurationExplicit(final int x) {
this.x = x;
}
}
| Arvoreen/lombok | test/transform/resource/after-delombok/ConstructorsConfiguration.java | Java | mit | 428 |
import { EarthFilled24 } from "../../";
export = EarthFilled24;
| markogresak/DefinitelyTyped | types/carbon__icons-react/lib/earth--filled/24.d.ts | TypeScript | mit | 65 |
module Spree
class ProductDuplicator
attr_accessor :product
def initialize(product)
@product = product
end
def duplicate
new_product = duplicate_product
# don't dup the actual variants, just the characterising types
new_product.option_types = product.option_types if product.has_variants?
# allow site to do some customization
new_product.send(:duplicate_extra, product) if new_product.respond_to?(:duplicate_extra)
new_product.save!
new_product
end
protected
def duplicate_product
product.dup.tap do |new_product|
new_product.name = "COPY OF #{product.name}"
new_product.taxons = product.taxons
new_product.created_at = nil
new_product.deleted_at = nil
new_product.updated_at = nil
new_product.product_properties = reset_properties
new_product.master = duplicate_master
end
end
def duplicate_master
master = product.master
master.dup.tap do |new_master|
new_master.sku = "COPY OF #{master.sku}"
new_master.deleted_at = nil
new_master.images = master.images.map { |image| duplicate_image image }
new_master.price = master.price
new_master.currency = master.currency
end
end
def duplicate_image(image)
new_image = image.dup
new_image.assign_attributes(:attachment => image.attachment.clone)
new_image
end
def reset_properties
product.product_properties.map do |prop|
prop.dup.tap do |new_prop|
new_prop.created_at = nil
new_prop.updated_at = nil
end
end
end
end
end
| Leonavas/ruido | spree-master/core/lib/spree/core/product_duplicator.rb | Ruby | mit | 1,674 |
// Type definitions for jui-core 2.0
// Project: https://github.com/juijs/jui-core
// Definitions by: JinHo Park <https://github.com/easylogic>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
export const jui: JuiStatic;
export interface UtilBase {
/**
* @property browser check browser agent
* @property {Boolean} browser.webkit Webkit 브라우저 체크
* @property {Boolean} browser.mozilla Mozilla 브라우저 체크
* @property {Boolean} browser.msie IE 브라우저 체크
*/
browser: {
webkit: boolean,
mozilla: boolean,
msie: boolean
};
/**
* @property {Boolean} isTouch
* check touch device
*/
isTouch: boolean;
/**
* @method inherit
*
* 프로토타입 기반의 상속 제공
*
* @param {Function} ctor base Class
* @param {Function} superCtor super Class
*/
inherit(ctor: ((...args: any[]) => any), superCtor: ((...args: any[]) => any)): void;
/**
* @method extend
*
* implements object extend
*
* @param {Object|Function} origin
* @param {Object|Function} add
* @param {Boolean} skip
* @return {Object}
*/
extend(origin: any, add: any, skip: boolean): any;
/**
* convert px to integer
* @param {String or Number} px
* @return {Number}
*/
pxToInt(px: string | number): number;
/**
* @method clone
* implements object clone
* @param {Array/Object} obj 복사할 객체
* @return {Array}
*/
clone(obj: any): any[];
/**
* @method deepClone
* implements object deep clone
* @param obj
* @param emit
* @return {*}
*/
deepClone(obj: any, emit: any): any[];
/**
* @method sort
* use QuickSort
* @param {Array} array
* @return {QuickSort}
*/
sort(array: any[]): UtilQuickSort;
/**
* @method runtime
*
* caculate callback runtime
*
* @param {String} name
* @param {Function} callback
*/
runtime(name: string, callback: ((...args: any[]) => void)): void;
/**
* @method template
* parsing template string
* @param html
* @param obj
*/
template(html: string, obj?: any): ((obj: any) => string) | string;
/**
* @method resize
* add event in window resize event
* @param {Function} callback
* @param {Number} ms delay time
*/
resize(callback: ((...args: any[]) => void), ms: number): void;
/**
* @method index
*
* IndexParser 객체 생성
*
* @return {KeyParser}
*/
index(): UtilKeyParser;
/**
* @method chunk
* split array by length
* @param {Array} arr
* @param {Number} len
* @return {Array}
*/
chunk(arr: any[], len: number): any[];
/**
* @method typeCheck
* check data type
* @param {String} t type string
* @param {Object} v value object
* @return {Boolean}
*/
typeCheck(typeName: string, value: any): boolean;
typeCheckObj(uiObj: any, list: any): void;
/**
* @method dataToCsv
*
* data 를 csv 로 변환한다.
*
* @param {Array} keys
* @param {Array} dataList
* @param {Number} dataSize
* @return {String} 변환된 csv 문자열
*/
dataToCsv(keys: string[], dataList: any[], dataSize: number): string;
/**
* @method dataToCsv2
*
* @param {Object} options
* @return {String}
*/
dataToCsv2(options: any): string;
/**
* @method fileToCsv
*
* file 에서 csv 컨텐츠 로드
*
* @param {File} file
* @param {Function} callback
*/
fileToCsv(fileText: string, callback: ((data: any) => void)): void;
/**
* @method csvToBase64
*
* csv 다운로드 링크로 변환
*
* @param {String} csv
* @return {String} data uri string
*/
csvToBase64(csv: string): string;
/**
* @method csvToData
*
* @param {Array} keys
* @param {String} csv
* @param {Number} csvNumber
* @return {Array}
*/
csvToData(keys: string[], csv: string, csvNumber: number): any[];
/**
* @method getCsvFields
*
* csv 에서 필드 얻어오기
*
* @param {Array} fields
* @param {Array} csvFields
* @return {Array}
*/
getCsvFields(fields: string[], csvFields: string[]): string[];
/**
* @method svgToBase64
*
* xml 문자열로 svg datauri 생성
*
* @param {String} xml
* @return {String} 변환된 data uri 링크
*/
svgToBase64(xml: string): string;
/**
* @method dateFormat
*
* implements date format function
*
* yyyy : 4 digits year
* yy : 2 digits year
* y : 1 digit year
*
* @param {Date} date
* @param {String} format date format string
* @param {Boolean} utc
* @return {string}
*/
dateFormat(date: Date, format: string, utc?: boolean): string;
/**
* @method createId
*
* 유니크 아이디 생성
*
* @param {String} key prefix string
* @return {String} 생성된 아이디 문자열
*/
createId(key: string): string;
/**
* @method btoa
*
* Base64 인코딩
*
* @return {String}
*/
btoa(input: any): string;
/**
* @method atob
*
* Base64 디코딩
*
* @return {Any}
*/
atob(input: string): any;
/**
* implement async loop without blocking ui
*
* @param {Number} total loop count
* @param {Object} context
* @returns {Function}
*/
timeLoop(total: number, context?: any): ((index: number) => void);
/**
* @method loop
*
* 최적화된 루프 생성 (5단계로 나눔)
*
* @param {Number} total loop count
* @param {Object} [context=null]
* @return {Function} 최적화된 루프 콜백 (index, groupIndex 2가지 파라미터를 받는다.)
*/
loop(total: number, context?: any): ((index: number, groupIndex: number) => void);
/**
* @method loopArray
*
* 배열을 사용해서 최적화된 루프로 생성한다.
*
*
* @param {Array} data 루프로 생성될 배열
* @param {Object} [context=null]
* @return {Function} 최적화된 루프 콜백 (data, index, groupIndex 3가지 파라미터를 받는다.)
*/
loopArray(data: any[], context?: any): ((data: any, index: number, groupIndex: number) => void);
/**
* @method makeIndex
*
* 배열의 키 기반 인덱스를 생성한다.
*
* 개별 값 별로 멀티 인덱스를 생성한다.
*
* @param {Array} data
* @param {String} keyField
* @return {Object} 생성된 인덱스
*/
makeIndex(data: any[], keyField: string): any;
/**
* @method startsWith
* Check that it matches the starting string search string.
*
* @param {String} string
* @param {String} searchString
* @param {Number} [position=0]
* @return {Number} position
*/
startsWith(str: string, searchString: string, position?: number): number;
/**
* @method endsWith
* Check that it matches the end of a string search string.
*
* @param {String} string
* @param {String} searchString
* @return {Number} position
*/
endsWith(str: string, searchString: string, position?: number): number;
inArray(target: any, list: any[]): number;
trim(text: string): string;
ready: ((...args: any[]) => void);
param(data: any): string;
ajax(data: any): void;
scrollWidth(): number;
}
export interface JuiStatic {
/**
* @method ready
*
* ready 타임에 실행될 callback 정의
*
* @param {Function} callback
*/
ready(depends?: string[], callback?: (...args: any[]) => void): void;
/**
* @method defineUI
*
* 사용자가 실제로 사용할 수 있는 UI 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
*/
defineUI(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* @method define
*
* UI 클래스에서 사용될 클래스를 정의하고, 자유롭게 상속할 수 있는 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
* @param {String} parent 상속받을 클래스
*/
define(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* @method redefine
*
* UI 클래스에서 사용될 클래스를 정의하고, 자유롭게 상속할 수 있는 클래스를 정의
*
* @param {String} name 모듈 로드와 상속에 사용될 이름을 정한다.
* @param {Array} depends 'define'이나 'defineUI'로 정의된 클래스나 객체를 인자로 받을 수 있다.
* @param {Function} callback UI 클래스를 해당 콜백 함수 내에서 클래스 형태로 구현하고 리턴해야 한다.
* @param {String} parent 상속받을 클래스
*/
redefine(name: string, depends: string[], callback: () => void, parent?: string): void;
/**
* define과 defineUI로 정의된 클래스 또는 객체를 가져온다.
*
* @param name 가져온 클래스 또는 객체의 이름
* @return {*}
*/
include(name: string): any;
/**
* define과 defineUI로 정의된 모든 클래스와 객체를 가져온다.
*
* @return {Array}
*/
includeAll(): any[];
/**
* @method add
* Adds a component object created
*
* @param {Object} ui UI instance
*/
add(uiIns: any): void;
/**
* @method emit
* Generates a custom event to an applicable component
*
* @param {String} key Selector or UI type
* @param {String} type Event type
* @param {Array} args Event arguments
*/
emit(key: string, type: string, args: any[]): void;
/**
* @method get
* Gets a component currently created
*
* @param {Integer/String} key
* @returns {Object/Array} UI instance
*/
get(key: number | string): any;
/**
* @method getAll
* Gets all components currently created
*
* @return {Array} UI instances
*/
getAll(): any[];
/**
* @method create
* It is possible to create a component dynamically after the ready point
*
* @param {String} type UI type
* @param {String/DOMElement} selector
* @param {Object} options
* @return {Object}
*/
create(type: string, selector: any, options?: {}): any;
}
export interface UICollection {
destroy(): void;
}
export interface UICore {
tpl?: any;
event?: any;
root?: any;
/**
* @method emit
* Generates a custom event. The first parameter is the type of a custom event. A function defined as an option or on method is called
*
* @param {String} type Event type
* @param {Function} args Event Arguments
* @return {Mixed}
*/
emit(type: string, args: () => void): any;
/**
* @method on
* A callback function defined as an on method is run when an emit method is called
*
* @param {String} type Event type
* @param {Function} callback
*/
on(type: string, callback: () => void): void;
/**
* @method off
* Removes a custom event of an applicable type or callback handler
*
* @param {String} type Event type
*/
off(type: string): void;
/**
* @method addValid
* Check the parameter type of a UI method and generates an alarm when a wrong value is entered
*
* @param {String} name Method name
* @param {Array} params Parameters
*/
addValid(name: string, params: any[]): void;
/**
* @method callBefore
* Sets a callback function that is called before a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
* @return {Mixed}
*/
callBefore(name: string, callback: () => void): void;
/**
* @method callAfter
* Sets a callback function that is called after a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
* @return {Mixed}
*/
callAfter(name: string, callback: () => void): void;
/**
* @method callDelay
* Sets a callback function and the delay time before/after a UI method is run
*
* @param {String} name Method name
* @param {Function} callback
*/
callDelay(name: string, callObj: () => void): void;
/**
* @method setTpl
* Dynamically defines the template method of a UI
*
* @param {String} name Template name
* @param {String} html Template markup
*/
setTpl(name: string, html: string): void;
/**
* @method setOption
* Dynamically defines the options of a UI
*
* @param {String} key
* @param {Mixed} value
*/
setOption(key: string, value: any): void;
/**
* @method destroy
* Removes all events set in a UI obejct and the DOM element
*
*/
destroy(): void;
}
//noinspection TypeScriptUnresolvedVariable
export interface UIEvent extends UICore {
root?: any;
/**
* @method find
* Get the child element of the root element
*
* @param {String/HTMLElement} Selector
* @returns {*|jQuery}
*/
find(selector: any): JQuery;
}
export class ColorScale {
domain(color: string, color2: string): this;
ticks(max: number): this;
}
export interface UtilColor {
/**
* @method format
*
* convert color to format string
*
* // hex
* color.format({ r : 255, g : 255, b : 255 }, 'hex') // #FFFFFF
*
* // rgb
* color.format({ r : 255, g : 255, b : 255 }, 'rgb') // rgba(255, 255, 255, 0.5);
*
* // rgba
* color.format({ r : 255, g : 255, b : 255, a : 0.5 }, 'rgb') // rgba(255, 255, 255, 0.5);
*
* @param {Object} obj obj has r, g, b and a attributes
* @param {"hex"/"rgb"} type format string type
* @returns {*}
*/
format(obj: any, type: string): string;
/**
* @method scale
*
* get color scale
*
* var c = color.scale().domain('#FF0000', '#00FF00');
*
* // get middle color
* c(0.5) == #808000
*
* // get middle color list
* c.ticks(20); // return array , [startColor, ......, endColor ]
*
* @returns {func} scale function
*/
scale(): ColorScale;
/**
* @method map
*
* create color map
*
* var colorList = color.map(['#352a87', '#0f5cdd', '#00b5a6', '#ffc337', '#fdff00'], count)
*
* @param {Array} color_list
* @param {Number} count a divide number
* @returns {Array} converted color list
*/
map(color_list: string[], count: number): string[];
/**
* @method rgb
*
* parse string to rgb color
*
* color.rgb("#FF0000") === { r : 255, g : 0, b : 0 }
*
* color.rgb("rgb(255, 0, 0)") == { r : 255, g : 0, b : }
*
* @param {String} str color string
* @returns {Object} rgb object
*/
rgb(str: string): any;
/**
* @method HSVtoRGB
*
* convert hsv to rgb
*
* color.HSVtoRGB(0,0,1) === #FFFFF === { r : 255, g : 0, b : 0 }
*
* @param {Number} H hue color number (min : 0, max : 360)
* @param {Number} S Saturation number (min : 0, max : 1)
* @param {Number} V Value number (min : 0, max : 1 )
* @returns {Object}
*/
HSVtoRGB(H: number, S: number, V: number): any;
/**
* @method RGBtoHSV
*
* convert rgb to hsv
*
* color.RGBtoHSV(0, 0, 255) === { h : 240, s : 1, v : 1 } === '#FFFF00'
*
* @param {Number} R red color value
* @param {Number} G green color value
* @param {Number} B blue color value
* @return {Object} hsv color code
*/
RGBtoHSV(R: number, G: number, B: number): any;
/**
* @method lighten
*
* rgb 컬러 밝은 농도로 변환
*
* @param {String} color RGB color code
* @param {Number} rate 밝은 농도
* @return {String}
*/
lighten(color: string, rate: number): string;
/**
* @method darken
*
* rgb 컬러 어두운 농도로 변환
*
* @param {String} color RGB color code
* @param {Number} rate 어두운 농도
* @return {String}
*/
darken(color: string, rate: number): string;
}
export interface UtilBase64 {
encode(input: string): string;
decode(input: string): string;
}
export interface UtilKeyParser {
/**
* @method isIndexDepth
*
* @param {String} index
* @return {Boolean}
*/
isIndexDepth(index: string): boolean;
/**
* @method getIndexList
*
* @param {String} index
* @return {Array}
*/
getIndexList(index: string): boolean;
/**
* @method changeIndex
*
*
* @param {String} index
* @param {String} targetIndex
* @param {String} rootIndex
* @return {String}
*/
changeIndex(index: string, targetIndex: string, rootIndex: string): string;
/**
* @method getNextIndex
*
* @param {String} index
* @return {String}
*/
getNextIndex(index: string): string;
/**
* @method getParentIndex
*
*
* @param {String} index
* @returns {*}
*/
getParentIndex(index: string): string;
}
export interface UtilMath {
/**
* @method rotate
*
* 2d rotate
*
* @param {Number} x
* @param {Number} y
* @param {Number} radian roate 할 radian
* @return {Object}
* @return {Number} return.x 변환된 x
* @return {Number} return.y 변환된 y
*
*/
rotate(x: number, y: number, radian: number): any;
resize(maxWidth: number, maxHeight: number, objectWidth: number, objectHeight: number): any;
/**
* @method radian
*
* convert degree to radian
*
* @param {Number} degree
* @return {Number} radian
*/
radian(degree: number): number;
/**
* @method degree
*
* convert radian to degree
*
* @param {Number} radian
* @return {Number} degree
*/
degree(radian: number): number;
angle(x1: number, y1: number, x2: number, y2: number): number;
/**
* @method interpolateNumber
*
* a, b 의 중간값 계산을 위한 callback 함수 만들기
*
* @param {Number} a first value
* @param {Number} b second value
* @return {Function}
*/
interpolateNumber(a: number, b: number): () => void;
// 중간값 round 해서 계산하기
interpolateRound(a: number, b: number): () => void;
round(num: number, fixed: number): number;
plus(a: number, b: number): number;
minus(a: number, b: number): number;
multi(a: number, b: number): number;
div(a: number, b: number): number;
remain(a: number, b: number): number;
/**
* 특정 구간의 값을 자동으로 계산
*
* @param {Object} min
* @param {Object} max
* @param {Object} ticks
* @param {Object} isNice
*/
nice(min: number, max: number, ticks: number, isNice: boolean): any;
matrix<T>(a: T[], b: T[]): T[];
matrix3d<T>(a: T[], b: T[]): T[];
inverseMatrix3d(a: any[]): any[];
}
export interface UtilScaleOrdinal extends Function {
(x: number): number;
domain(values: any[]): UtilScaleOrdinal;
range(values: any[]): UtilScaleOrdinal;
rangePoints(interval: number, padding?: number): () => void;
rangeBands(interval: number, padding?: number, outerPadding?: number): () => void;
invert(x: number): number;
}
export type UtilQuickSort = (array: number[], isClone: boolean) => this;
| GiedriusGrabauskas/DefinitelyTyped | types/jui-core/index.d.ts | TypeScript | mit | 20,802 |
/*****************************************************************************
* dbus_root.h : dbus control module (mpris v1.0) - root object
*****************************************************************************
* Copyright © 2006-2008 Rafaël Carré
* Copyright © 2007-2010 Mirsal Ennaime
* Copyright © 2009-2010 The VideoLAN team
* $Id$
*
* Authors: Mirsal Ennaime <mirsal at mirsal fr>
* Rafaël Carré <funman at videolanorg>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _VLC_DBUS_ROOT_H
#define _VLC_DBUS_ROOT_H
#include "dbus_common.h"
/* DBUS IDENTIFIERS */
#define DBUS_MPRIS_ROOT_INTERFACE "org.mpris.MediaPlayer2"
/* Handle incoming dbus messages */
DBusHandlerResult handle_root ( DBusConnection *p_conn,
DBusMessage *p_from,
void *p_this );
int RootPropertiesChangedEmit ( intf_thread_t *,
vlc_dictionary_t * );
#endif //dbus-root.h
| DDTChen/CookieVLC | vlc/modules/control/dbus/dbus_root.h | C | gpl-2.0 | 1,747 |
#! /usr/bin/env python
# -*- mode: python; indent-tabs-mode: nil; -*-
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
#
# Copyright (C) 2010,2011 Patrick Crews
#
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
""" drizzled.py: code to allow a serverManager
to provision and start up a drizzled server object
for test execution
"""
# imports
import os
from lib.server_mgmt.server import Server
class drizzleServer(Server):
""" represents a drizzle server, its possessions
(datadir, ports, etc), and methods for controlling
and querying it
TODO: create a base server class that contains
standard methods from which we can inherit
Currently there are definitely methods / attr
which are general
"""
def __init__( self, name, server_manager, code_tree, default_storage_engine
, server_options, requester, test_executor, workdir_root):
super(drizzleServer, self).__init__( name
, server_manager
, code_tree
, default_storage_engine
, server_options
, requester
, test_executor
, workdir_root)
self.preferred_base_port = 9306
# client files
self.drizzledump = self.code_tree.drizzledump
self.drizzle_client = self.code_tree.drizzle_client
self.drizzleimport = self.code_tree.drizzleimport
self.drizzleslap = self.code_tree.drizzleslap
self.server_path = self.code_tree.drizzle_server
self.drizzle_client_path = self.code_tree.drizzle_client
self.schemawriter = self.code_tree.schemawriter
self.trx_reader = self.code_tree.trx_reader
# Get our ports
self.port_block = self.system_manager.port_manager.get_port_block( self.name
, self.preferred_base_port
, 6 )
self.master_port = self.port_block[0]
self.drizzle_tcp_port = self.port_block[1]
self.mc_port = self.port_block[2]
self.pbms_port = self.port_block[3]
self.rabbitmq_node_port = self.port_block[4]
self.json_server_port = self.port_block[5]
# Generate our working directories
self.dirset = {'var_%s' %(self.name): {'std_data_ln':( os.path.join(self.code_tree.testdir,'std_data'))
,'log':None
,'run':None
,'tmp':None
,'master-data': {'local': { 'test':None
, 'mysql':None
}
}
}
}
self.workdir = self.system_manager.create_dirset( workdir_root
, self.dirset)
self.vardir = self.workdir
self.tmpdir = os.path.join(self.vardir,'tmp')
self.rundir = os.path.join(self.vardir,'run')
self.logdir = os.path.join(self.vardir,'log')
self.datadir = os.path.join(self.vardir,'master-data')
self.error_log = os.path.join(self.logdir,'error.log')
self.pid_file = os.path.join(self.rundir,('%s.pid' %(self.name)))
self.socket_file = os.path.join(self.vardir, ('%s.sock' %(self.name)))
if len(self.socket_file) > 107:
# MySQL has a limitation of 107 characters for socket file path
# we copy the mtr workaround of creating one in /tmp
self.logging.verbose("Default socket file path: %s" %(self.socket_file))
self.socket_file = "/tmp/%s_%s.%s.sock" %(self.system_manager.uuid
,self.owner
,self.name)
self.logging.verbose("Changing to alternate: %s" %(self.socket_file))
self.timer_file = os.path.join(self.logdir,('timer'))
# Do magic to create a config file for use with the slave
# plugin
self.slave_config_file = os.path.join(self.logdir,'slave.cnf')
self.create_slave_config_file()
self.snapshot_path = os.path.join(self.tmpdir,('snapshot_%s' %(self.master_port)))
# We want to use --secure-file-priv = $vardir by default
# but there are times / tools when we need to shut this off
if self.no_secure_file_priv:
self.secure_file_string = ''
else:
self.secure_file_string = "--secure-file-priv='%s'" %(self.vardir)
self.user_string = '--user=root'
self.initialize_databases()
self.take_db_snapshot()
self.logging.debug_class(self)
def report(self):
""" We print out some general useful info """
report_values = [ 'name'
, 'master_port'
, 'drizzle_tcp_port'
, 'mc_port'
, 'pbms_port'
, 'rabbitmq_node_port'
, 'vardir'
, 'status'
]
self.logging.info("%s server:" %(self.owner))
for key in report_values:
value = vars(self)[key]
self.logging.info("%s: %s" %(key.upper(), value))
def get_start_cmd(self):
""" Return the command string that will start up the server
as desired / intended
"""
server_args = [ self.process_server_options()
, "--mysql-protocol.port=%d" %(self.master_port)
, "--mysql-protocol.connect-timeout=60"
, "--innodb.data-file-path=ibdata1:20M:autoextend"
, "--sort-buffer-size=256K"
, "--max-heap-table-size=1M"
, "--mysql-unix-socket-protocol.path=%s" %(self.socket_file)
, "--pid-file=%s" %(self.pid_file)
, "--drizzle-protocol.port=%d" %(self.drizzle_tcp_port)
, "--default-storage-engine=%s" %(self.default_storage_engine)
, "--datadir=%s" %(self.datadir)
, "--tmpdir=%s" %(self.tmpdir)
, self.secure_file_string
, self.user_string
]
if self.gdb:
server_args.append('--gdb')
return self.system_manager.handle_gdb_reqs(self, server_args)
else:
return "%s %s %s & " % ( self.cmd_prefix
, self.server_path
, " ".join(server_args)
)
def get_stop_cmd(self):
""" Return the command that will shut us down """
return "%s --user=root --port=%d --connect-timeout=5 --silent --password= --shutdown " %(self.drizzle_client_path, self.master_port)
def get_ping_cmd(self):
"""Return the command string that will
ping / check if the server is alive
"""
return "%s --ping --port=%d --user=root" % (self.drizzle_client_path, self.master_port)
def is_started(self):
""" Determine if the server is up and running -
this may vary from server type to server type
"""
# We experiment with waiting for a pid file to be created vs. pinging
# This is what test-run.pl does and it helps us pass logging_stats tests
# while not self.ping_server(server, quiet=True) and timer != timeout:
return self.system_manager.find_path( [self.pid_file]
, required=0)
def create_slave_config_file(self):
""" Create a config file suitable for use
with the slave-plugin. This allows
us to tie other servers in easily
"""
config_data = [ "[master1]"
, "master-host=127.0.0.1"
, "master-port=%d" %self.master_port
, "master-user=root"
, "master-pass=''"
, "max-reconnects=100"
#, "seconds-between-reconnects=20"
]
outfile = open(self.slave_config_file,'w')
for line in config_data:
outfile.write("%s\n" %(line))
outfile.close()
| kraziegent/mysql-5.6 | xtrabackup/test/kewpie/lib/server_mgmt/drizzled.py | Python | gpl-2.0 | 9,584 |
UPDATE `creature_template_addon` SET `auras`='29266 28559' WHERE `entry`=55464; -- NPC: Hozen Corpse; AURA: Permanent Feign Death, Untrackable;
UPDATE `creature_template_addon` SET `auras`='29266 28559' WHERE `entry`=58533; -- NPC: Dustback Mushan; AURA: Permanent Feign Death, Untrackable;
UPDATE `creature_template_addon` SET `auras`='29266 28559' WHERE `entry`=61806; -- NPC: Liu of the Thousand Blows; AURA: Permanent Feign Death, Untrackable;
UPDATE `creature_template_addon` SET `auras`='29266 28559' WHERE `entry`=61808; -- NPC: Shado-Master Zhiyao; AURA: Permanent Feign Death, Untrackable;
UPDATE `creature_template_addon` SET `auras`='29266 28559' WHERE `entry`=61810; -- NPC: Shiya Boldblade; AURA: Permanent Feign Death, Untrackable;
UPDATE `creature_template_addon` SET `auras`='131531 8279' WHERE `entry`=66928; -- NPC: Sha Shooter; AURA: Sha Shooter Spawn [DNT], Stealth Detection; | Natureknight/BAMoP | sql/old/5.x.x/Release_4/2014_06_25_07_world_creature_template_addon.sql | SQL | gpl-2.0 | 896 |
/*
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. 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.
* 4. Neither the name of the University 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 REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
* $FreeBSD: src/sys/net/if.h,v 1.95 2005/02/25 19:46:41 brooks Exp $
*/
#ifndef _NET_IF_H_
#define _NET_IF_H_
#include <sys/cdefs.h>
#if defined(__rtems__)
/*
* FIXME - HACK: BSD defines __BSD_VISIBLE in sys/cdefs.h
* RTEMS sys/cdefs.h doesn't, so we enforce it here.
*/
#ifndef __BSD_VISIBLE
#define __BSD_VISIBLE 1
#endif
#include <inttypes.h>
#include <sys/socket.h> /* struct sockaddr */
#endif
#ifdef _KERNEL
#include <sys/queue.h>
#endif
#if __BSD_VISIBLE
/*
* <net/if.h> does not depend on <sys/time.h> on most other systems. This
* helps userland compatibility. (struct timeval ifi_lastchange)
*/
#ifndef _KERNEL
#include <sys/time.h>
#endif
struct ifnet;
struct ether_header;
#endif
/*
* Length of interface external name, including terminating '\0'.
* Note: this is the same size as a generic device's external name.
*/
#define IF_NAMESIZE 16
#if __BSD_VISIBLE
#define IFNAMSIZ IF_NAMESIZE
#define IF_MAXUNIT 0x7fff /* historical value */
#endif
#if __BSD_VISIBLE
/*
* Structure used to query names of interface cloners.
*/
struct if_clonereq {
int ifcr_total; /* total cloners (out) */
int ifcr_count; /* room for this many in user buffer */
char *ifcr_buffer; /* buffer for cloner names */
};
/*
* Structure describing information about an interface
* which may be of interest to management entities.
*/
struct if_data {
/* generic interface information */
u_char ifi_type; /* ethernet, tokenring, etc */
u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */
u_char ifi_addrlen; /* media address length */
u_char ifi_hdrlen; /* media header length */
u_char ifi_recvquota; /* polling quota for receive intrs */
u_char ifi_xmitquota; /* polling quota for xmit intrs */
u_long ifi_mtu; /* maximum transmission unit */
u_long ifi_metric; /* routing metric (external only) */
u_long ifi_baudrate; /* linespeed */
/* volatile statistics */
u_long ifi_ipackets; /* packets received on interface */
u_long ifi_ierrors; /* input errors on interface */
u_long ifi_opackets; /* packets sent on interface */
u_long ifi_oerrors; /* output errors on interface */
u_long ifi_collisions; /* collisions on csma interfaces */
u_long ifi_ibytes; /* total number of octets received */
u_long ifi_obytes; /* total number of octets sent */
u_long ifi_imcasts; /* packets received via multicast */
u_long ifi_omcasts; /* packets sent via multicast */
u_long ifi_iqdrops; /* dropped on input, this interface */
u_long ifi_noproto; /* destined for unsupported protocol */
u_long ifi_recvtiming; /* usec spent receiving when timing */
u_long ifi_xmittiming; /* usec spent xmitting when timing */
struct timeval ifi_lastchange; /* time of last administrative change */
};
#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
#define IFF_DEBUG 0x4 /* turn on debugging */
#define IFF_LOOPBACK 0x8 /* is a loopback net */
#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
#define IFF_SMART 0x20 /* interface manages own routes */
#define IFF_RUNNING 0x40 /* resources allocated */
#define IFF_NOARP 0x80 /* no address resolution protocol */
#define IFF_PROMISC 0x100 /* receive all packets */
#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
#define IFF_OACTIVE 0x400 /* tx hardware queue is full */
#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
#define IFF_LINK0 0x1000 /* per link layer defined bit */
#define IFF_LINK1 0x2000 /* per link layer defined bit */
#define IFF_LINK2 0x4000 /* per link layer defined bit */
#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */
#define IFF_MULTICAST 0x8000 /* supports multicast */
#define IFF_POLLING 0x10000 /* Interface is in polling mode. */
#define IFF_PPROMISC 0x20000 /* user-requested promisc mode */
#define IFF_MONITOR 0x40000 /* user-requested monitor mode */
#define IFF_STATICARP 0x80000 /* static ARP */
#define IFF_NEEDSGIANT 0x100000 /* hold Giant over if_start calls */
/* flags set internally only: */
#define IFF_CANTCHANGE \
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
IFF_POLLING)
/*
* Values for if_link_state.
*/
#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */
#define LINK_STATE_DOWN 1 /* link is down */
#define LINK_STATE_UP 2 /* link is up */
/*
* Some convenience macros used for setting ifi_baudrate.
* XXX 1000 vs. 1024? --thorpej@netbsd.org
*/
#define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */
#define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */
#define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */
#define IFQ_MAXLEN 50
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
/*
* Message format for use in obtaining information about interfaces
* from getkerninfo and the routing socket
*/
struct if_msghdr {
u_short ifm_msglen; /* to skip over non-understood messages */
u_char ifm_version; /* future binary compatibility */
u_char ifm_type; /* message type */
int ifm_addrs; /* like rtm_addrs */
int ifm_flags; /* value of if_flags */
u_short ifm_index; /* index for associated ifp */
struct if_data ifm_data;/* statistics and other data about if */
};
/*
* Message format for use in obtaining information about interface addresses
* from getkerninfo and the routing socket
*/
struct ifa_msghdr {
u_short ifam_msglen; /* to skip over non-understood messages */
u_char ifam_version; /* future binary compatibility */
u_char ifam_type; /* message type */
int ifam_addrs; /* like rtm_addrs */
int ifam_flags; /* value of ifa_flags */
u_short ifam_index; /* index for associated ifp */
int ifam_metric; /* value of ifa_metric */
};
/* forward declaration */
struct mbuf;
/*
* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
* definitions which begin with ifr_name. The
* remainder may be interface specific.
*/
struct ifreq {
char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
short ifru_flags[2];
int32_t ifru_metric;
int32_t ifru_mtu;
int ifru_phys;
int ifru_media;
caddr_t ifru_data;
int (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *);
} ifr_ifru;
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */
#define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
#define ifr_phys ifr_ifru.ifru_phys /* physical wire */
#define ifr_media ifr_ifru.ifru_media /* physical media */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_tap ifr_ifru.ifru_tap /* tap function */
};
struct ifaliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
struct sockaddr ifra_addr;
struct sockaddr ifra_broadaddr;
struct sockaddr ifra_mask;
};
struct ifmediareq {
char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
int ifm_current; /* current media options */
int ifm_mask; /* don't care mask */
int ifm_status; /* media status */
int ifm_active; /* active options */
int ifm_count; /* # entries in ifm_ulist array */
int *ifm_ulist; /* media words */
};
/*
* Structure used to retrieve aux status data from interfaces.
* Kernel suppliers to this interface should respect the formatting
* needed by ifconfig(8): each line starts with a TAB and ends with
* a newline. The canonical example to copy and paste is in if_tun.c.
*/
#define IFSTATMAX 800 /* 10 lines of text */
struct ifstat {
char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */
char ascii[IFSTATMAX + 1];
};
/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int ifc_len; /* size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};
#endif /* __BSD_VISIBLE */
#ifndef _KERNEL
struct if_nameindex {
unsigned int if_index; /* 1, 2, ... */
char *if_name; /* null terminated name: "le0", ... */
};
__BEGIN_DECLS
void if_freenameindex(struct if_nameindex *);
char *if_indextoname(unsigned int, char *);
struct if_nameindex *if_nameindex(void);
__END_DECLS
#endif
#ifdef _KERNEL
/* XXX - this should go away soon. */
#include <net/if_var.h>
void ifafree(struct ifaddr *);
int looutput(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
#endif
#endif /* !_NET_IF_H_ */
| anandkp92/waf | include/net/if.h | C | gpl-2.0 | 10,636 |
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
#include "common/logging/log.h"
#include "common/scope_exit.h"
#include "common/string_util.h"
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/fs/fs_user.h"
#include "core/settings.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace FS_User
using Kernel::SharedPtr;
using Kernel::Session;
namespace Service {
namespace FS {
static u32 priority = -1; ///< For SetPriority and GetPriority service functions
static ArchiveHandle MakeArchiveHandle(u32 low_word, u32 high_word) {
return (u64)low_word | ((u64)high_word << 32);
}
static void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per
// http://3dbrew.org/wiki/FS:Initialize#Request
cmd_buff[1] = RESULT_SUCCESS.raw;
}
/**
* FS_User::OpenFile service function
* Inputs:
* 1 : Transaction
* 2 : Archive handle lower word
* 3 : Archive handle upper word
* 4 : Low path type
* 5 : Low path size
* 6 : Open flags
* 7 : Attributes
* 8 : (LowPathSize << 14) | 2
* 9 : Low path data pointer
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 3 : File handle
*/
static void OpenFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
FileSys::Mode mode; mode.hex = cmd_buff[6];
u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes.
u32 filename_ptr = cmd_buff[9];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes);
ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode);
cmd_buff[1] = file_res.Code().raw;
if (file_res.Succeeded()) {
cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom();
} else {
cmd_buff[3] = 0;
LOG_ERROR(Service_FS, "failed to get a handle for file %s", file_path.DebugStr().c_str());
}
}
/**
* FS_User::OpenFileDirectly service function
* Inputs:
* 1 : Transaction
* 2 : Archive ID
* 3 : Archive low path type
* 4 : Archive low path size
* 5 : File low path type
* 6 : File low path size
* 7 : Flags
* 8 : Attributes
* 9 : (ArchiveLowPathSize << 14) | 0x802
* 10 : Archive low path
* 11 : (FileLowPathSize << 14) | 2
* 12 : File low path
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 3 : File handle
*/
static void OpenFileDirectly(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
u32 archivename_size = cmd_buff[4];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
u32 filename_size = cmd_buff[6];
FileSys::Mode mode; mode.hex = cmd_buff[7];
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
u32 archivename_ptr = cmd_buff[10];
u32 filename_ptr = cmd_buff[12];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%d",
archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex, attributes);
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
if (archive_handle.Failed()) {
LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
cmd_buff[1] = archive_handle.Code().raw;
cmd_buff[3] = 0;
return;
}
SCOPE_EXIT({ CloseArchive(*archive_handle); });
ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(*archive_handle, file_path, mode);
cmd_buff[1] = file_res.Code().raw;
if (file_res.Succeeded()) {
cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom();
} else {
cmd_buff[3] = 0;
LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%d",
file_path.DebugStr().c_str(), mode.hex, attributes);
}
}
/*
* FS_User::DeleteFile service function
* Inputs:
* 2 : Archive handle lower word
* 3 : Archive handle upper word
* 4 : File path string type
* 5 : File path string size
* 7 : File path string data
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void DeleteFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u32 filename_ptr = cmd_buff[7];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
filename_type, filename_size, file_path.DebugStr().c_str());
cmd_buff[1] = DeleteFileFromArchive(archive_handle, file_path).raw;
}
/*
* FS_User::RenameFile service function
* Inputs:
* 2 : Source archive handle lower word
* 3 : Source archive handle upper word
* 4 : Source file path type
* 5 : Source file path size
* 6 : Dest archive handle lower word
* 7 : Dest archive handle upper word
* 8 : Dest file path type
* 9 : Dest file path size
* 11: Source file path string data
* 13: Dest file path string
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void RenameFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_filename_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);;
auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_filename_size = cmd_buff[9];
u32 src_filename_ptr = cmd_buff[11];
u32 dest_filename_ptr = cmd_buff[13];
FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr);
FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path).raw;
}
/*
* FS_User::DeleteDirectory service function
* Inputs:
* 2 : Archive handle lower word
* 3 : Archive handle upper word
* 4 : Directory path string type
* 5 : Directory path string size
* 7 : Directory path string data
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void DeleteDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 dirname_size = cmd_buff[5];
u32 dirname_ptr = cmd_buff[7];
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s",
dirname_type, dirname_size, dir_path.DebugStr().c_str());
cmd_buff[1] = DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
}
/*
* FS_User::CreateFile service function
* Inputs:
* 0 : Command header 0x08080202
* 2 : Archive handle lower word
* 3 : Archive handle upper word
* 4 : File path string type
* 5 : File path string size
* 7 : File size (filled with zeroes)
* 10: File path string data
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void CreateFile(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 filename_size = cmd_buff[5];
u32 file_size = cmd_buff[7];
u32 filename_ptr = cmd_buff[10];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", filename_type, filename_size, file_path.DebugStr().c_str());
cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw;
}
/*
* FS_User::CreateDirectory service function
* Inputs:
* 2 : Archive handle lower word
* 3 : Archive handle upper word
* 4 : Directory path string type
* 5 : Directory path string size
* 8 : Directory path string data
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void CreateDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 dirname_size = cmd_buff[5];
u32 dirname_ptr = cmd_buff[8];
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
cmd_buff[1] = CreateDirectoryFromArchive(archive_handle, dir_path).raw;
}
/*
* FS_User::RenameDirectory service function
* Inputs:
* 2 : Source archive handle lower word
* 3 : Source archive handle upper word
* 4 : Source dir path type
* 5 : Source dir path size
* 6 : Dest archive handle lower word
* 7 : Dest archive handle upper word
* 8 : Dest dir path type
* 9 : Dest dir path size
* 11: Source dir path string data
* 13: Dest dir path string
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void RenameDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle src_archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
u32 src_dirname_size = cmd_buff[5];
ArchiveHandle dest_archive_handle = MakeArchiveHandle(cmd_buff[6], cmd_buff[7]);
auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]);
u32 dest_dirname_size = cmd_buff[9];
u32 src_dirname_ptr = cmd_buff[11];
u32 dest_dirname_ptr = cmd_buff[13];
FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
LOG_DEBUG(Service_FS, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path).raw;
}
/**
* FS_User::OpenDirectory service function
* Inputs:
* 1 : Archive handle low word
* 2 : Archive handle high word
* 3 : Low path type
* 4 : Low path size
* 7 : (LowPathSize << 14) | 2
* 8 : Low path data pointer
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 3 : Directory handle
*/
static void OpenDirectory(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]);
auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
u32 dirname_size = cmd_buff[4];
u32 dirname_ptr = cmd_buff[6];
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str());
ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path);
cmd_buff[1] = dir_res.Code().raw;
if (dir_res.Succeeded()) {
cmd_buff[3] = Kernel::g_handle_table.Create(*dir_res).MoveFrom();
} else {
LOG_ERROR(Service_FS, "failed to get a handle for directory type=%d size=%d data=%s",
dirname_type, dirname_size, dir_path.DebugStr().c_str());
}
}
/**
* FS_User::OpenArchive service function
* Inputs:
* 1 : Archive ID
* 2 : Archive low path type
* 3 : Archive low path size
* 4 : (LowPathSize << 14) | 2
* 5 : Archive low path
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Archive handle lower word (unused)
* 3 : Archive handle upper word (same as file handle)
*/
static void OpenArchive(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
u32 archivename_size = cmd_buff[3];
u32 archivename_ptr = cmd_buff[5];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id, archive_path.DebugStr().c_str());
ResultVal<ArchiveHandle> handle = OpenArchive(archive_id, archive_path);
cmd_buff[1] = handle.Code().raw;
if (handle.Succeeded()) {
cmd_buff[2] = *handle & 0xFFFFFFFF;
cmd_buff[3] = (*handle >> 32) & 0xFFFFFFFF;
} else {
cmd_buff[2] = cmd_buff[3] = 0;
LOG_ERROR(Service_FS, "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
archive_id, archive_path.DebugStr().c_str());
}
}
/**
* FS_User::CloseArchive service function
* Inputs:
* 0 : 0x080E0080
* 1 : Archive handle low word
* 2 : Archive handle high word
* Outputs:
* 0 : ??? TODO(yuriks): Verify return header
* 1 : Result of function, 0 on success, otherwise error code
*/
static void CloseArchive(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]);
cmd_buff[1] = CloseArchive(archive_handle).raw;
}
/*
* FS_User::IsSdmcDetected service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Whether the Sdmc could be detected
*/
static void IsSdmcDetected(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = 0;
cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
}
/**
* FS_User::IsSdmcWriteable service function
* Outputs:
* 0 : Command header 0x08180000
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Whether the Sdmc is currently writeable
*/
static void IsSdmcWriteable(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
// If the SD isn't enabled, it can't be writeable...else, stubbed true
cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
LOG_DEBUG(Service_FS, " (STUBBED)");
}
/**
* FS_User::FormatSaveData service function,
* formats the SaveData specified by the input path.
* Inputs:
* 0 : 0x084C0242
* 1 : Archive ID
* 2 : Archive low path type
* 3 : Archive low path size
* 10 : (LowPathSize << 14) | 2
* 11 : Archive low path
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void FormatSaveData(Service::Interface* self) {
// TODO(Subv): Find out what the other inputs and outputs of this function are
u32* cmd_buff = Kernel::GetCommandBuffer();
LOG_DEBUG(Service_FS, "(STUBBED)");
auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
u32 archivename_size = cmd_buff[3];
u32 archivename_ptr = cmd_buff[11];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str());
if (archive_id != FS::ArchiveIdCode::SaveData) {
// TODO(Subv): What should happen if somebody attempts to format a different archive?
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", cmd_buff[1]);
cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw;
return;
}
if (archive_path.GetType() != FileSys::LowPathType::Empty) {
// TODO(Subv): Implement formatting the SaveData of other games
LOG_ERROR(Service_FS, "archive LowPath type other than empty is currently unsupported");
cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw;
return;
}
cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
}
/**
* FS_User::FormatThisUserSaveData service function
* Inputs:
* 0: 0x080F0180
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void FormatThisUserSaveData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
LOG_DEBUG(Service_FS, "(STUBBED)");
// TODO(Subv): Find out what the inputs and outputs of this function are
cmd_buff[1] = FormatArchive(ArchiveIdCode::SaveData).raw;
}
/**
* FS_User::CreateExtSaveData service function
* Inputs:
* 0 : 0x08510242
* 1 : Media type (NAND / SDMC)
* 2 : Low word of the saveid to create
* 3 : High word of the saveid to create
* 4 : Unknown
* 5 : Unknown
* 6 : Unknown
* 7 : Unknown
* 8 : Unknown
* 9 : Size of the SMDH icon
* 10: (SMDH Size << 4) | 0x0000000A
* 11: Pointer to the SMDH icon for the new ExtSaveData
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void CreateExtSaveData(Service::Interface* self) {
// TODO(Subv): Figure out the other parameters.
u32* cmd_buff = Kernel::GetCommandBuffer();
MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF);
u32 save_low = cmd_buff[2];
u32 save_high = cmd_buff[3];
u32 icon_size = cmd_buff[9];
VAddr icon_buffer = cmd_buff[11];
LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"icon_size=%08X icon_descriptor=%08X icon_buffer=%08X", save_high, save_low,
cmd_buff[3], cmd_buff[4], cmd_buff[5], cmd_buff[6], cmd_buff[7], cmd_buff[8], icon_size,
cmd_buff[10], icon_buffer);
cmd_buff[1] = CreateExtSaveData(media_type, save_high, save_low, icon_buffer, icon_size).raw;
}
/**
* FS_User::DeleteExtSaveData service function
* Inputs:
* 0 : 0x08520100
* 1 : Media type (NAND / SDMC)
* 2 : Low word of the saveid to create
* 3 : High word of the saveid to create
* 4 : Unknown
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void DeleteExtSaveData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
MediaType media_type = static_cast<MediaType>(cmd_buff[1] & 0xFF);
u32 save_low = cmd_buff[2];
u32 save_high = cmd_buff[3];
u32 unknown = cmd_buff[4]; // TODO(Subv): Figure out what this is
LOG_WARNING(Service_FS, "(STUBBED) save_low=%08X save_high=%08X media_type=%08X unknown=%08X",
save_low, save_high, cmd_buff[1] & 0xFF, unknown);
cmd_buff[1] = DeleteExtSaveData(media_type, save_high, save_low).raw;
}
/**
* FS_User::CardSlotIsInserted service function.
* Inputs:
* 0 : 0x08210000
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Whether there is a game card inserted into the slot or not.
*/
static void CardSlotIsInserted(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = 0;
LOG_WARNING(Service_FS, "(STUBBED) called");
}
/**
* FS_User::DeleteSystemSaveData service function.
* Inputs:
* 0 : 0x08570080
* 1 : High word of the SystemSaveData id to delete
* 2 : Low word of the SystemSaveData id to delete
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void DeleteSystemSaveData(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 savedata_high = cmd_buff[1];
u32 savedata_low = cmd_buff[2];
cmd_buff[1] = DeleteSystemSaveData(savedata_high, savedata_low).raw;
}
/**
* FS_User::CreateSystemSaveData service function.
* Inputs:
* 0 : 0x08560240
* 1 : High word of the SystemSaveData id to create
* 2 : Low word of the SystemSaveData id to create
* 3 : Unknown
* 4 : Unknown
* 5 : Unknown
* 6 : Unknown
* 7 : Unknown
* 8 : Unknown
* 9 : Unknown (Memory address)
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void CreateSystemSaveData(Service::Interface* self) {
// TODO(Subv): Figure out the other parameters.
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 savedata_high = cmd_buff[1];
u32 savedata_low = cmd_buff[2];
LOG_WARNING(Service_FS, "(STUBBED) savedata_high=%08X savedata_low=%08X cmd_buff[3]=%08X "
"cmd_buff[4]=%08X cmd_buff[5]=%08X cmd_buff[6]=%08X cmd_buff[7]=%08X cmd_buff[8]=%08X "
"cmd_buff[9]=%08X", savedata_high, savedata_low, cmd_buff[3], cmd_buff[4], cmd_buff[5],
cmd_buff[6], cmd_buff[7], cmd_buff[8], cmd_buff[9]);
cmd_buff[1] = CreateSystemSaveData(savedata_high, savedata_low).raw;
}
/**
* FS_User::InitializeWithSdkVersion service function.
* Inputs:
* 0 : 0x08610042
* 1 : Unknown
* 2 : Unknown
* 3 : Unknown
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void InitializeWithSdkVersion(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 unk1 = cmd_buff[1];
u32 unk2 = cmd_buff[2];
u32 unk3 = cmd_buff[3];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X",
unk1, unk2, unk3);
}
/**
* FS_User::SetPriority service function.
* Inputs:
* 0 : 0x08620040
* 1 : priority
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
static void SetPriority(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
priority = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_FS, "called priority=0x%X", priority);
}
/**
* FS_User::GetPriority service function.
* Inputs:
* 0 : 0x08630000
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : priority
*/
static void GetPriority(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
if (priority == -1) {
LOG_INFO(Service_FS, "priority was not set, priority=0x%X", priority);
}
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = priority;
LOG_DEBUG(Service_FS, "called priority=0x%X", priority);
}
const Interface::FunctionInfo FunctionTable[] = {
{0x000100C6, nullptr, "Dummy1"},
{0x040100C4, nullptr, "Control"},
{0x08010002, Initialize, "Initialize"},
{0x080201C2, OpenFile, "OpenFile"},
{0x08030204, OpenFileDirectly, "OpenFileDirectly"},
{0x08040142, DeleteFile, "DeleteFile"},
{0x08050244, RenameFile, "RenameFile"},
{0x08060142, DeleteDirectory, "DeleteDirectory"},
{0x08070142, nullptr, "DeleteDirectoryRecursively"},
{0x08080202, CreateFile, "CreateFile"},
{0x08090182, CreateDirectory, "CreateDirectory"},
{0x080A0244, RenameDirectory, "RenameDirectory"},
{0x080B0102, OpenDirectory, "OpenDirectory"},
{0x080C00C2, OpenArchive, "OpenArchive"},
{0x080D0144, nullptr, "ControlArchive"},
{0x080E0080, CloseArchive, "CloseArchive"},
{0x080F0180, FormatThisUserSaveData,"FormatThisUserSaveData"},
{0x08100200, nullptr, "CreateSystemSaveData"},
{0x08110040, nullptr, "DeleteSystemSaveData"},
{0x08120080, nullptr, "GetFreeBytes"},
{0x08130000, nullptr, "GetCardType"},
{0x08140000, nullptr, "GetSdmcArchiveResource"},
{0x08150000, nullptr, "GetNandArchiveResource"},
{0x08160000, nullptr, "GetSdmcFatfsErro"},
{0x08170000, IsSdmcDetected, "IsSdmcDetected"},
{0x08180000, IsSdmcWriteable, "IsSdmcWritable"},
{0x08190042, nullptr, "GetSdmcCid"},
{0x081A0042, nullptr, "GetNandCid"},
{0x081B0000, nullptr, "GetSdmcSpeedInfo"},
{0x081C0000, nullptr, "GetNandSpeedInfo"},
{0x081D0042, nullptr, "GetSdmcLog"},
{0x081E0042, nullptr, "GetNandLog"},
{0x081F0000, nullptr, "ClearSdmcLog"},
{0x08200000, nullptr, "ClearNandLog"},
{0x08210000, CardSlotIsInserted, "CardSlotIsInserted"},
{0x08220000, nullptr, "CardSlotPowerOn"},
{0x08230000, nullptr, "CardSlotPowerOff"},
{0x08240000, nullptr, "CardSlotGetCardIFPowerStatus"},
{0x08250040, nullptr, "CardNorDirectCommand"},
{0x08260080, nullptr, "CardNorDirectCommandWithAddress"},
{0x08270082, nullptr, "CardNorDirectRead"},
{0x082800C2, nullptr, "CardNorDirectReadWithAddress"},
{0x08290082, nullptr, "CardNorDirectWrite"},
{0x082A00C2, nullptr, "CardNorDirectWriteWithAddress"},
{0x082B00C2, nullptr, "CardNorDirectRead_4xIO"},
{0x082C0082, nullptr, "CardNorDirectCpuWriteWithoutVerify"},
{0x082D0040, nullptr, "CardNorDirectSectorEraseWithoutVerify"},
{0x082E0040, nullptr, "GetProductInfo"},
{0x082F0040, nullptr, "GetProgramLaunchInfo"},
{0x08300182, nullptr, "CreateExtSaveData"},
{0x08310180, nullptr, "CreateSharedExtSaveData"},
{0x08320102, nullptr, "ReadExtSaveDataIcon"},
{0x08330082, nullptr, "EnumerateExtSaveData"},
{0x08340082, nullptr, "EnumerateSharedExtSaveData"},
{0x08350080, nullptr, "DeleteExtSaveData"},
{0x08360080, nullptr, "DeleteSharedExtSaveData"},
{0x08370040, nullptr, "SetCardSpiBaudRate"},
{0x08380040, nullptr, "SetCardSpiBusMode"},
{0x08390000, nullptr, "SendInitializeInfoTo9"},
{0x083A0100, nullptr, "GetSpecialContentIndex"},
{0x083B00C2, nullptr, "GetLegacyRomHeader"},
{0x083C00C2, nullptr, "GetLegacyBannerData"},
{0x083D0100, nullptr, "CheckAuthorityToAccessExtSaveData"},
{0x083E00C2, nullptr, "QueryTotalQuotaSize"},
{0x083F00C0, nullptr, "GetExtDataBlockSize"},
{0x08400040, nullptr, "AbnegateAccessRight"},
{0x08410000, nullptr, "DeleteSdmcRoot"},
{0x08420040, nullptr, "DeleteAllExtSaveDataOnNand"},
{0x08430000, nullptr, "InitializeCtrFileSystem"},
{0x08440000, nullptr, "CreateSeed"},
{0x084500C2, nullptr, "GetFormatInfo"},
{0x08460102, nullptr, "GetLegacyRomHeader2"},
{0x08470180, nullptr, "FormatCtrCardUserSaveData"},
{0x08480042, nullptr, "GetSdmcCtrRootPath"},
{0x08490040, nullptr, "GetArchiveResource"},
{0x084A0002, nullptr, "ExportIntegrityVerificationSeed"},
{0x084B0002, nullptr, "ImportIntegrityVerificationSeed"},
{0x084C0242, FormatSaveData, "FormatSaveData"},
{0x084D0102, nullptr, "GetLegacySubBannerData"},
{0x084E0342, nullptr, "UpdateSha256Context"},
{0x084F0102, nullptr, "ReadSpecialFile"},
{0x08500040, nullptr, "GetSpecialFileSize"},
{0x08510242, CreateExtSaveData, "CreateExtSaveData"},
{0x08520100, DeleteExtSaveData, "DeleteExtSaveData"},
{0x08560240, CreateSystemSaveData, "CreateSystemSaveData"},
{0x08570080, DeleteSystemSaveData, "DeleteSystemSaveData"},
{0x08580000, nullptr, "GetMovableSedHashedKeyYRandomData"},
{0x08610042, InitializeWithSdkVersion, "InitializeWithSdkVersion"},
{0x08620040, SetPriority, "SetPriority"},
{0x08630000, GetPriority, "GetPriority"},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interface class
Interface::Interface() {
priority = -1;
Register(FunctionTable);
}
} // namespace FS
} // namespace Service
| enler/citra | src/core/hle/service/fs/fs_user.cpp | C++ | gpl-2.0 | 30,659 |
// license:GPL-2.0+
// copyright-holders:Raphael Nabet, Brett Wyer
/*****************************************************************************
*
* includes/concept.h
*
* Corvus Concept driver
*
* Raphael Nabet, 2003
*
****************************************************************************/
#ifndef MAME_INCLUDES_CONCEPT_H
#define MAME_INCLUDES_CONCEPT_H
#include "cpu/m68000/m68000.h"
#include "machine/6522via.h"
#include "machine/mos6551.h"
#include "machine/mm58174.h"
#include "sound/spkrdev.h"
#include "bus/a2bus/a2bus.h"
#define ACIA_0_TAG "acia0"
#define ACIA_1_TAG "acia1"
#define VIA_0_TAG "via6522_0"
#define KBD_ACIA_TAG "kbacia"
class concept_state : public driver_device
{
public:
concept_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_acia0(*this, ACIA_0_TAG),
m_acia1(*this, ACIA_1_TAG),
m_via0(*this, VIA_0_TAG),
m_kbdacia(*this, KBD_ACIA_TAG),
m_speaker(*this, "spkr"),
m_mm58174(*this, "mm58174"),
m_a2bus(*this, "a2bus"),
m_videoram(*this,"videoram")
{ }
void concept(machine_config &config);
private:
required_device<cpu_device> m_maincpu;
required_device<mos6551_device> m_acia0;
required_device<mos6551_device> m_acia1;
required_device<via6522_device> m_via0;
required_device<mos6551_device> m_kbdacia;
required_device<speaker_sound_device> m_speaker;
required_device<mm58174_device> m_mm58174;
required_device<a2bus_device> m_a2bus;
required_shared_ptr<uint16_t> m_videoram;
uint8_t m_pending_interrupts;
bool m_clock_enable;
uint8_t m_clock_address;
uint8_t io_r(offs_t offset);
void io_w(offs_t offset, uint8_t data);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint8_t via_in_a();
void via_out_a(uint8_t data);
uint8_t via_in_b();
void via_out_b(uint8_t data);
DECLARE_WRITE_LINE_MEMBER(via_out_cb2);
DECLARE_WRITE_LINE_MEMBER(via_irq_func);
DECLARE_WRITE_LINE_MEMBER(ioc_interrupt);
void concept_set_interrupt(int level, int state);
void concept_memmap(address_map &map);
};
#endif // MAME_INCLUDES_CONCEPT_H
| johnparker007/mame | src/mame/includes/concept.h | C | gpl-2.0 | 2,281 |
/*
* Copyright (c) 2015, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 build.tools.cldrconverter;
class AliasEntry extends StringEntry {
AliasEntry(String qName, Container parent, String key) {
super(qName, parent, key);
}
AliasEntry(String qName, Container parent, String key, String value) {
super(qName, parent, key, value);
}
}
| FauxFaux/jdk9-jdk | make/src/classes/build/tools/cldrconverter/AliasEntry.java | Java | gpl-2.0 | 1,511 |
/*
* Copyright (c) 2016, 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.
*/
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.PaintContext;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.TexturePaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
/**
* @test
* @bug 8148886
* @summary Verifies that Marlin supports reentrant operations (ThreadLocal)
* like in custom Paint or custom Composite
* @run main CrashPaintTest
*/
public class CrashPaintTest {
static final boolean SAVE_IMAGE = false;
public static void main(String argv[]) {
Locale.setDefault(Locale.US);
// initialize j.u.l Looger:
final Logger log = Logger.getLogger("sun.java2d.marlin");
log.addHandler(new Handler() {
@Override
public void publish(LogRecord record) {
Throwable th = record.getThrown();
// detect any Throwable:
if (th != null) {
System.out.println("Test failed:\n" + record.getMessage());
th.printStackTrace(System.out);
throw new RuntimeException("Test failed: ", th);
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
// enable Marlin logging & internal checks:
System.setProperty("sun.java2d.renderer.log", "true");
System.setProperty("sun.java2d.renderer.useLogger", "true");
System.setProperty("sun.java2d.renderer.doChecks", "true");
// Force using thread-local storage:
System.setProperty("sun.java2d.renderer.useThreadLocal", "true");
// Force smaller pixelsize to force using array caches:
System.setProperty("sun.java2d.renderer.pixelsize", "256");
final int width = 300;
final int height = 300;
final BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = (Graphics2D) image.getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setBackground(Color.WHITE);
g2d.clearRect(0, 0, width, height);
final Ellipse2D.Double ellipse
= new Ellipse2D.Double(0, 0, width, height);
final Paint paint = new CustomPaint(100);
for (int i = 0; i < 20; i++) {
final long start = System.nanoTime();
g2d.setPaint(paint);
g2d.fill(ellipse);
g2d.setColor(Color.GREEN);
g2d.draw(ellipse);
final long time = System.nanoTime() - start;
System.out.println("paint: duration= " + (1e-6 * time) + " ms.");
}
if (SAVE_IMAGE) {
try {
final File file = new File("CrashPaintTest.png");
System.out.println("Writing file: "
+ file.getAbsolutePath());
ImageIO.write(image, "PNG", file);
} catch (IOException ex) {
System.out.println("Writing file failure:");
ex.printStackTrace();
}
}
// Check image on few pixels:
final Raster raster = image.getData();
// 170, 175 = blue
checkPixel(raster, 170, 175, Color.BLUE.getRGB());
// 50, 50 = blue
checkPixel(raster, 50, 50, Color.BLUE.getRGB());
// 190, 110 = pink
checkPixel(raster, 190, 110, Color.PINK.getRGB());
// 280, 210 = pink
checkPixel(raster, 280, 210, Color.PINK.getRGB());
} finally {
g2d.dispose();
}
}
private static void checkPixel(final Raster raster,
final int x, final int y,
final int expected) {
final int[] rgb = (int[]) raster.getDataElements(x, y, null);
if (rgb[0] != expected) {
throw new IllegalStateException("bad pixel at (" + x + ", " + y
+ ") = " + rgb[0] + " expected: " + expected);
}
}
private static class CustomPaint extends TexturePaint {
private int size;
CustomPaint(final int size) {
super(new BufferedImage(size, size,
BufferedImage.TYPE_INT_ARGB),
new Rectangle2D.Double(0, 0, size, size)
);
this.size = size;
}
@Override
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform at,
RenderingHints hints) {
// Fill bufferedImage using
final Graphics2D g2d = (Graphics2D) getImage().getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setBackground(Color.PINK);
g2d.clearRect(0, 0, size, size);
g2d.setColor(Color.BLUE);
g2d.drawRect(0, 0, size, size);
g2d.fillOval(size / 10, size / 10,
size * 8 / 10, size * 8 / 10);
} finally {
g2d.dispose();
}
return super.createContext(cm, deviceBounds, userBounds, at, hints);
}
}
}
| FauxFaux/jdk9-jdk | test/sun/java2d/marlin/CrashPaintTest.java | Java | gpl-2.0 | 7,149 |
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
*
* Authors: AMD
*
*/
#include "dm_services.h"
#include "resource.h"
#include "include/irq_service_interface.h"
#include "link_encoder.h"
#include "stream_encoder.h"
#include "opp.h"
#include "timing_generator.h"
#include "transform.h"
#include "dccg.h"
#include "dchubbub.h"
#include "dpp.h"
#include "core_types.h"
#include "set_mode_types.h"
#include "virtual/virtual_stream_encoder.h"
#include "dpcd_defs.h"
#include "dce80/dce80_resource.h"
#include "dce100/dce100_resource.h"
#include "dce110/dce110_resource.h"
#include "dce112/dce112_resource.h"
#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
#include "dcn10/dcn10_resource.h"
#endif
#include "dce120/dce120_resource.h"
#define DC_LOGGER_INIT(logger)
enum dce_version resource_parse_asic_id(struct hw_asic_id asic_id)
{
enum dce_version dc_version = DCE_VERSION_UNKNOWN;
switch (asic_id.chip_family) {
case FAMILY_CI:
dc_version = DCE_VERSION_8_0;
break;
case FAMILY_KV:
if (ASIC_REV_IS_KALINDI(asic_id.hw_internal_rev) ||
ASIC_REV_IS_BHAVANI(asic_id.hw_internal_rev) ||
ASIC_REV_IS_GODAVARI(asic_id.hw_internal_rev))
dc_version = DCE_VERSION_8_3;
else
dc_version = DCE_VERSION_8_1;
break;
case FAMILY_CZ:
dc_version = DCE_VERSION_11_0;
break;
case FAMILY_VI:
if (ASIC_REV_IS_TONGA_P(asic_id.hw_internal_rev) ||
ASIC_REV_IS_FIJI_P(asic_id.hw_internal_rev)) {
dc_version = DCE_VERSION_10_0;
break;
}
if (ASIC_REV_IS_POLARIS10_P(asic_id.hw_internal_rev) ||
ASIC_REV_IS_POLARIS11_M(asic_id.hw_internal_rev) ||
ASIC_REV_IS_POLARIS12_V(asic_id.hw_internal_rev)) {
dc_version = DCE_VERSION_11_2;
}
if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev))
dc_version = DCE_VERSION_11_22;
break;
case FAMILY_AI:
if (ASICREV_IS_VEGA20_P(asic_id.hw_internal_rev))
dc_version = DCE_VERSION_12_1;
else
dc_version = DCE_VERSION_12_0;
break;
#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
case FAMILY_RV:
dc_version = DCN_VERSION_1_0;
#if defined(CONFIG_DRM_AMD_DC_DCN1_01)
if (ASICREV_IS_RAVEN2(asic_id.hw_internal_rev))
dc_version = DCN_VERSION_1_01;
#endif
break;
#endif
default:
dc_version = DCE_VERSION_UNKNOWN;
break;
}
return dc_version;
}
struct resource_pool *dc_create_resource_pool(struct dc *dc,
const struct dc_init_data *init_data,
enum dce_version dc_version)
{
struct resource_pool *res_pool = NULL;
switch (dc_version) {
case DCE_VERSION_8_0:
res_pool = dce80_create_resource_pool(
init_data->num_virtual_links, dc);
break;
case DCE_VERSION_8_1:
res_pool = dce81_create_resource_pool(
init_data->num_virtual_links, dc);
break;
case DCE_VERSION_8_3:
res_pool = dce83_create_resource_pool(
init_data->num_virtual_links, dc);
break;
case DCE_VERSION_10_0:
res_pool = dce100_create_resource_pool(
init_data->num_virtual_links, dc);
break;
case DCE_VERSION_11_0:
res_pool = dce110_create_resource_pool(
init_data->num_virtual_links, dc,
init_data->asic_id);
break;
case DCE_VERSION_11_2:
case DCE_VERSION_11_22:
res_pool = dce112_create_resource_pool(
init_data->num_virtual_links, dc);
break;
case DCE_VERSION_12_0:
case DCE_VERSION_12_1:
res_pool = dce120_create_resource_pool(
init_data->num_virtual_links, dc);
break;
#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
case DCN_VERSION_1_0:
#if defined(CONFIG_DRM_AMD_DC_DCN1_01)
case DCN_VERSION_1_01:
#endif
res_pool = dcn10_create_resource_pool(init_data, dc);
break;
#endif
default:
break;
}
if (res_pool != NULL) {
struct dc_firmware_info fw_info = { { 0 } };
if (dc->ctx->dc_bios->funcs->get_firmware_info(
dc->ctx->dc_bios, &fw_info) == BP_RESULT_OK) {
res_pool->ref_clocks.xtalin_clock_inKhz = fw_info.pll_info.crystal_frequency;
if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
// On FPGA these dividers are currently not configured by GDB
res_pool->ref_clocks.dccg_ref_clock_inKhz = res_pool->ref_clocks.xtalin_clock_inKhz;
res_pool->ref_clocks.dchub_ref_clock_inKhz = res_pool->ref_clocks.xtalin_clock_inKhz;
} else if (res_pool->dccg && res_pool->hubbub) {
// If DCCG reference frequency cannot be determined (usually means not set to xtalin) then this is a critical error
// as this value must be known for DCHUB programming
(res_pool->dccg->funcs->get_dccg_ref_freq)(res_pool->dccg,
fw_info.pll_info.crystal_frequency,
&res_pool->ref_clocks.dccg_ref_clock_inKhz);
// Similarly, if DCHUB reference frequency cannot be determined, then it is also a critical error
(res_pool->hubbub->funcs->get_dchub_ref_freq)(res_pool->hubbub,
res_pool->ref_clocks.dccg_ref_clock_inKhz,
&res_pool->ref_clocks.dchub_ref_clock_inKhz);
} else {
// Not all ASICs have DCCG sw component
res_pool->ref_clocks.dccg_ref_clock_inKhz = res_pool->ref_clocks.xtalin_clock_inKhz;
res_pool->ref_clocks.dchub_ref_clock_inKhz = res_pool->ref_clocks.xtalin_clock_inKhz;
}
} else
ASSERT_CRITICAL(false);
}
return res_pool;
}
void dc_destroy_resource_pool(struct dc *dc)
{
if (dc) {
if (dc->res_pool)
dc->res_pool->funcs->destroy(&dc->res_pool);
kfree(dc->hwseq);
}
}
static void update_num_audio(
const struct resource_straps *straps,
unsigned int *num_audio,
struct audio_support *aud_support)
{
aud_support->dp_audio = true;
aud_support->hdmi_audio_native = false;
aud_support->hdmi_audio_on_dongle = false;
if (straps->hdmi_disable == 0) {
if (straps->dc_pinstraps_audio & 0x2) {
aud_support->hdmi_audio_on_dongle = true;
aud_support->hdmi_audio_native = true;
}
}
switch (straps->audio_stream_number) {
case 0: /* multi streams supported */
break;
case 1: /* multi streams not supported */
*num_audio = 1;
break;
default:
DC_ERR("DC: unexpected audio fuse!\n");
}
}
bool resource_construct(
unsigned int num_virtual_links,
struct dc *dc,
struct resource_pool *pool,
const struct resource_create_funcs *create_funcs)
{
struct dc_context *ctx = dc->ctx;
const struct resource_caps *caps = pool->res_cap;
int i;
unsigned int num_audio = caps->num_audio;
struct resource_straps straps = {0};
if (create_funcs->read_dce_straps)
create_funcs->read_dce_straps(dc->ctx, &straps);
pool->audio_count = 0;
if (create_funcs->create_audio) {
/* find the total number of streams available via the
* AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_CONFIGURATION_DEFAULT
* registers (one for each pin) starting from pin 1
* up to the max number of audio pins.
* We stop on the first pin where
* PORT_CONNECTIVITY == 1 (as instructed by HW team).
*/
update_num_audio(&straps, &num_audio, &pool->audio_support);
for (i = 0; i < pool->pipe_count && i < num_audio; i++) {
struct audio *aud = create_funcs->create_audio(ctx, i);
if (aud == NULL) {
DC_ERR("DC: failed to create audio!\n");
return false;
}
if (!aud->funcs->endpoint_valid(aud)) {
aud->funcs->destroy(&aud);
break;
}
pool->audios[i] = aud;
pool->audio_count++;
}
}
pool->stream_enc_count = 0;
if (create_funcs->create_stream_encoder) {
for (i = 0; i < caps->num_stream_encoder; i++) {
pool->stream_enc[i] = create_funcs->create_stream_encoder(i, ctx);
if (pool->stream_enc[i] == NULL)
DC_ERR("DC: failed to create stream_encoder!\n");
pool->stream_enc_count++;
}
}
dc->caps.dynamic_audio = false;
if (pool->audio_count < pool->stream_enc_count) {
dc->caps.dynamic_audio = true;
}
for (i = 0; i < num_virtual_links; i++) {
pool->stream_enc[pool->stream_enc_count] =
virtual_stream_encoder_create(
ctx, ctx->dc_bios);
if (pool->stream_enc[pool->stream_enc_count] == NULL) {
DC_ERR("DC: failed to create stream_encoder!\n");
return false;
}
pool->stream_enc_count++;
}
dc->hwseq = create_funcs->create_hwseq(ctx);
return true;
}
static int find_matching_clock_source(
const struct resource_pool *pool,
struct clock_source *clock_source)
{
int i;
for (i = 0; i < pool->clk_src_count; i++) {
if (pool->clock_sources[i] == clock_source)
return i;
}
return -1;
}
void resource_unreference_clock_source(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source)
{
int i = find_matching_clock_source(pool, clock_source);
if (i > -1)
res_ctx->clock_source_ref_count[i]--;
if (pool->dp_clock_source == clock_source)
res_ctx->dp_clock_source_ref_count--;
}
void resource_reference_clock_source(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source)
{
int i = find_matching_clock_source(pool, clock_source);
if (i > -1)
res_ctx->clock_source_ref_count[i]++;
if (pool->dp_clock_source == clock_source)
res_ctx->dp_clock_source_ref_count++;
}
int resource_get_clock_source_reference(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source)
{
int i = find_matching_clock_source(pool, clock_source);
if (i > -1)
return res_ctx->clock_source_ref_count[i];
if (pool->dp_clock_source == clock_source)
return res_ctx->dp_clock_source_ref_count;
return -1;
}
bool resource_are_streams_timing_synchronizable(
struct dc_stream_state *stream1,
struct dc_stream_state *stream2)
{
if (stream1->timing.h_total != stream2->timing.h_total)
return false;
if (stream1->timing.v_total != stream2->timing.v_total)
return false;
if (stream1->timing.h_addressable
!= stream2->timing.h_addressable)
return false;
if (stream1->timing.v_addressable
!= stream2->timing.v_addressable)
return false;
if (stream1->timing.pix_clk_100hz
!= stream2->timing.pix_clk_100hz)
return false;
if (stream1->clamping.c_depth != stream2->clamping.c_depth)
return false;
if (stream1->phy_pix_clk != stream2->phy_pix_clk
&& (!dc_is_dp_signal(stream1->signal)
|| !dc_is_dp_signal(stream2->signal)))
return false;
if (stream1->view_format != stream2->view_format)
return false;
return true;
}
static bool is_dp_and_hdmi_sharable(
struct dc_stream_state *stream1,
struct dc_stream_state *stream2)
{
if (stream1->ctx->dc->caps.disable_dp_clk_share)
return false;
if (stream1->clamping.c_depth != COLOR_DEPTH_888 ||
stream2->clamping.c_depth != COLOR_DEPTH_888)
return false;
return true;
}
static bool is_sharable_clk_src(
const struct pipe_ctx *pipe_with_clk_src,
const struct pipe_ctx *pipe)
{
if (pipe_with_clk_src->clock_source == NULL)
return false;
if (pipe_with_clk_src->stream->signal == SIGNAL_TYPE_VIRTUAL)
return false;
if (dc_is_dp_signal(pipe_with_clk_src->stream->signal) ||
(dc_is_dp_signal(pipe->stream->signal) &&
!is_dp_and_hdmi_sharable(pipe_with_clk_src->stream,
pipe->stream)))
return false;
if (dc_is_hdmi_signal(pipe_with_clk_src->stream->signal)
&& dc_is_dual_link_signal(pipe->stream->signal))
return false;
if (dc_is_hdmi_signal(pipe->stream->signal)
&& dc_is_dual_link_signal(pipe_with_clk_src->stream->signal))
return false;
if (!resource_are_streams_timing_synchronizable(
pipe_with_clk_src->stream, pipe->stream))
return false;
return true;
}
struct clock_source *resource_find_used_clk_src_for_sharing(
struct resource_context *res_ctx,
struct pipe_ctx *pipe_ctx)
{
int i;
for (i = 0; i < MAX_PIPES; i++) {
if (is_sharable_clk_src(&res_ctx->pipe_ctx[i], pipe_ctx))
return res_ctx->pipe_ctx[i].clock_source;
}
return NULL;
}
static enum pixel_format convert_pixel_format_to_dalsurface(
enum surface_pixel_format surface_pixel_format)
{
enum pixel_format dal_pixel_format = PIXEL_FORMAT_UNKNOWN;
switch (surface_pixel_format) {
case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
dal_pixel_format = PIXEL_FORMAT_INDEX8;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
dal_pixel_format = PIXEL_FORMAT_RGB565;
break;
case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
dal_pixel_format = PIXEL_FORMAT_RGB565;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
dal_pixel_format = PIXEL_FORMAT_ARGB8888;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
dal_pixel_format = PIXEL_FORMAT_ARGB8888;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
dal_pixel_format = PIXEL_FORMAT_ARGB2101010;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
dal_pixel_format = PIXEL_FORMAT_ARGB2101010;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
dal_pixel_format = PIXEL_FORMAT_ARGB2101010_XRBIAS;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
dal_pixel_format = PIXEL_FORMAT_FP16;
break;
case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
dal_pixel_format = PIXEL_FORMAT_420BPP8;
break;
case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
dal_pixel_format = PIXEL_FORMAT_420BPP10;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
default:
dal_pixel_format = PIXEL_FORMAT_UNKNOWN;
break;
}
return dal_pixel_format;
}
static inline void get_vp_scan_direction(
enum dc_rotation_angle rotation,
bool horizontal_mirror,
bool *orthogonal_rotation,
bool *flip_vert_scan_dir,
bool *flip_horz_scan_dir)
{
*orthogonal_rotation = false;
*flip_vert_scan_dir = false;
*flip_horz_scan_dir = false;
if (rotation == ROTATION_ANGLE_180) {
*flip_vert_scan_dir = true;
*flip_horz_scan_dir = true;
} else if (rotation == ROTATION_ANGLE_90) {
*orthogonal_rotation = true;
*flip_horz_scan_dir = true;
} else if (rotation == ROTATION_ANGLE_270) {
*orthogonal_rotation = true;
*flip_vert_scan_dir = true;
}
if (horizontal_mirror)
*flip_horz_scan_dir = !*flip_horz_scan_dir;
}
static void calculate_viewport(struct pipe_ctx *pipe_ctx)
{
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
const struct dc_stream_state *stream = pipe_ctx->stream;
struct scaler_data *data = &pipe_ctx->plane_res.scl_data;
struct rect surf_src = plane_state->src_rect;
struct rect clip, dest;
int vpc_div = (data->format == PIXEL_FORMAT_420BPP8
|| data->format == PIXEL_FORMAT_420BPP10) ? 2 : 1;
bool pri_split = pipe_ctx->bottom_pipe &&
pipe_ctx->bottom_pipe->plane_state == pipe_ctx->plane_state;
bool sec_split = pipe_ctx->top_pipe &&
pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;
bool orthogonal_rotation, flip_y_start, flip_x_start;
if (stream->view_format == VIEW_3D_FORMAT_SIDE_BY_SIDE ||
stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM) {
pri_split = false;
sec_split = false;
}
/* The actual clip is an intersection between stream
* source and surface clip
*/
dest = plane_state->dst_rect;
clip.x = stream->src.x > plane_state->clip_rect.x ?
stream->src.x : plane_state->clip_rect.x;
clip.width = stream->src.x + stream->src.width <
plane_state->clip_rect.x + plane_state->clip_rect.width ?
stream->src.x + stream->src.width - clip.x :
plane_state->clip_rect.x + plane_state->clip_rect.width - clip.x ;
clip.y = stream->src.y > plane_state->clip_rect.y ?
stream->src.y : plane_state->clip_rect.y;
clip.height = stream->src.y + stream->src.height <
plane_state->clip_rect.y + plane_state->clip_rect.height ?
stream->src.y + stream->src.height - clip.y :
plane_state->clip_rect.y + plane_state->clip_rect.height - clip.y ;
/*
* Need to calculate how scan origin is shifted in vp space
* to correctly rotate clip and dst
*/
get_vp_scan_direction(
plane_state->rotation,
plane_state->horizontal_mirror,
&orthogonal_rotation,
&flip_y_start,
&flip_x_start);
if (orthogonal_rotation) {
swap(clip.x, clip.y);
swap(clip.width, clip.height);
swap(dest.x, dest.y);
swap(dest.width, dest.height);
}
if (flip_x_start) {
clip.x = dest.x + dest.width - clip.x - clip.width;
dest.x = 0;
}
if (flip_y_start) {
clip.y = dest.y + dest.height - clip.y - clip.height;
dest.y = 0;
}
/* offset = surf_src.ofs + (clip.ofs - surface->dst_rect.ofs) * scl_ratio
* num_pixels = clip.num_pix * scl_ratio
*/
data->viewport.x = surf_src.x + (clip.x - dest.x) * surf_src.width / dest.width;
data->viewport.width = clip.width * surf_src.width / dest.width;
data->viewport.y = surf_src.y + (clip.y - dest.y) * surf_src.height / dest.height;
data->viewport.height = clip.height * surf_src.height / dest.height;
/* Handle split */
if (pri_split || sec_split) {
if (orthogonal_rotation) {
if (flip_y_start != pri_split)
data->viewport.height /= 2;
else {
data->viewport.y += data->viewport.height / 2;
/* Ceil offset pipe */
data->viewport.height = (data->viewport.height + 1) / 2;
}
} else {
if (flip_x_start != pri_split)
data->viewport.width /= 2;
else {
data->viewport.x += data->viewport.width / 2;
/* Ceil offset pipe */
data->viewport.width = (data->viewport.width + 1) / 2;
}
}
}
/* Round down, compensate in init */
data->viewport_c.x = data->viewport.x / vpc_div;
data->viewport_c.y = data->viewport.y / vpc_div;
data->inits.h_c = (data->viewport.x % vpc_div) != 0 ? dc_fixpt_half : dc_fixpt_zero;
data->inits.v_c = (data->viewport.y % vpc_div) != 0 ? dc_fixpt_half : dc_fixpt_zero;
/* Round up, assume original video size always even dimensions */
data->viewport_c.width = (data->viewport.width + vpc_div - 1) / vpc_div;
data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div;
}
static void calculate_recout(struct pipe_ctx *pipe_ctx)
{
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
const struct dc_stream_state *stream = pipe_ctx->stream;
struct rect surf_clip = plane_state->clip_rect;
bool pri_split = pipe_ctx->bottom_pipe &&
pipe_ctx->bottom_pipe->plane_state == pipe_ctx->plane_state;
bool sec_split = pipe_ctx->top_pipe &&
pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;
bool top_bottom_split = stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM;
pipe_ctx->plane_res.scl_data.recout.x = stream->dst.x;
if (stream->src.x < surf_clip.x)
pipe_ctx->plane_res.scl_data.recout.x += (surf_clip.x
- stream->src.x) * stream->dst.width
/ stream->src.width;
pipe_ctx->plane_res.scl_data.recout.width = surf_clip.width *
stream->dst.width / stream->src.width;
if (pipe_ctx->plane_res.scl_data.recout.width + pipe_ctx->plane_res.scl_data.recout.x >
stream->dst.x + stream->dst.width)
pipe_ctx->plane_res.scl_data.recout.width =
stream->dst.x + stream->dst.width
- pipe_ctx->plane_res.scl_data.recout.x;
pipe_ctx->plane_res.scl_data.recout.y = stream->dst.y;
if (stream->src.y < surf_clip.y)
pipe_ctx->plane_res.scl_data.recout.y += (surf_clip.y
- stream->src.y) * stream->dst.height
/ stream->src.height;
pipe_ctx->plane_res.scl_data.recout.height = surf_clip.height *
stream->dst.height / stream->src.height;
if (pipe_ctx->plane_res.scl_data.recout.height + pipe_ctx->plane_res.scl_data.recout.y >
stream->dst.y + stream->dst.height)
pipe_ctx->plane_res.scl_data.recout.height =
stream->dst.y + stream->dst.height
- pipe_ctx->plane_res.scl_data.recout.y;
/* Handle h & v split, handle rotation using viewport */
if (sec_split && top_bottom_split) {
pipe_ctx->plane_res.scl_data.recout.y +=
pipe_ctx->plane_res.scl_data.recout.height / 2;
/* Floor primary pipe, ceil 2ndary pipe */
pipe_ctx->plane_res.scl_data.recout.height =
(pipe_ctx->plane_res.scl_data.recout.height + 1) / 2;
} else if (pri_split && top_bottom_split)
pipe_ctx->plane_res.scl_data.recout.height /= 2;
else if (sec_split) {
pipe_ctx->plane_res.scl_data.recout.x +=
pipe_ctx->plane_res.scl_data.recout.width / 2;
/* Ceil offset pipe */
pipe_ctx->plane_res.scl_data.recout.width =
(pipe_ctx->plane_res.scl_data.recout.width + 1) / 2;
} else if (pri_split)
pipe_ctx->plane_res.scl_data.recout.width /= 2;
}
static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx)
{
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
const struct dc_stream_state *stream = pipe_ctx->stream;
struct rect surf_src = plane_state->src_rect;
const int in_w = stream->src.width;
const int in_h = stream->src.height;
const int out_w = stream->dst.width;
const int out_h = stream->dst.height;
/*Swap surf_src height and width since scaling ratios are in recout rotation*/
if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 ||
pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270)
swap(surf_src.height, surf_src.width);
pipe_ctx->plane_res.scl_data.ratios.horz = dc_fixpt_from_fraction(
surf_src.width,
plane_state->dst_rect.width);
pipe_ctx->plane_res.scl_data.ratios.vert = dc_fixpt_from_fraction(
surf_src.height,
plane_state->dst_rect.height);
if (stream->view_format == VIEW_3D_FORMAT_SIDE_BY_SIDE)
pipe_ctx->plane_res.scl_data.ratios.horz.value *= 2;
else if (stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM)
pipe_ctx->plane_res.scl_data.ratios.vert.value *= 2;
pipe_ctx->plane_res.scl_data.ratios.vert.value = div64_s64(
pipe_ctx->plane_res.scl_data.ratios.vert.value * in_h, out_h);
pipe_ctx->plane_res.scl_data.ratios.horz.value = div64_s64(
pipe_ctx->plane_res.scl_data.ratios.horz.value * in_w, out_w);
pipe_ctx->plane_res.scl_data.ratios.horz_c = pipe_ctx->plane_res.scl_data.ratios.horz;
pipe_ctx->plane_res.scl_data.ratios.vert_c = pipe_ctx->plane_res.scl_data.ratios.vert;
if (pipe_ctx->plane_res.scl_data.format == PIXEL_FORMAT_420BPP8
|| pipe_ctx->plane_res.scl_data.format == PIXEL_FORMAT_420BPP10) {
pipe_ctx->plane_res.scl_data.ratios.horz_c.value /= 2;
pipe_ctx->plane_res.scl_data.ratios.vert_c.value /= 2;
}
pipe_ctx->plane_res.scl_data.ratios.horz = dc_fixpt_truncate(
pipe_ctx->plane_res.scl_data.ratios.horz, 19);
pipe_ctx->plane_res.scl_data.ratios.vert = dc_fixpt_truncate(
pipe_ctx->plane_res.scl_data.ratios.vert, 19);
pipe_ctx->plane_res.scl_data.ratios.horz_c = dc_fixpt_truncate(
pipe_ctx->plane_res.scl_data.ratios.horz_c, 19);
pipe_ctx->plane_res.scl_data.ratios.vert_c = dc_fixpt_truncate(
pipe_ctx->plane_res.scl_data.ratios.vert_c, 19);
}
static inline void adjust_vp_and_init_for_seamless_clip(
bool flip_scan_dir,
int recout_skip,
int src_size,
int taps,
struct fixed31_32 ratio,
struct fixed31_32 *init,
int *vp_offset,
int *vp_size)
{
if (!flip_scan_dir) {
/* Adjust for viewport end clip-off */
if ((*vp_offset + *vp_size) < src_size) {
int vp_clip = src_size - *vp_size - *vp_offset;
int int_part = dc_fixpt_floor(dc_fixpt_sub(*init, ratio));
int_part = int_part > 0 ? int_part : 0;
*vp_size += int_part < vp_clip ? int_part : vp_clip;
}
/* Adjust for non-0 viewport offset */
if (*vp_offset) {
int int_part;
*init = dc_fixpt_add(*init, dc_fixpt_mul_int(ratio, recout_skip));
int_part = dc_fixpt_floor(*init) - *vp_offset;
if (int_part < taps) {
int int_adj = *vp_offset >= (taps - int_part) ?
(taps - int_part) : *vp_offset;
*vp_offset -= int_adj;
*vp_size += int_adj;
int_part += int_adj;
} else if (int_part > taps) {
*vp_offset += int_part - taps;
*vp_size -= int_part - taps;
int_part = taps;
}
init->value &= 0xffffffff;
*init = dc_fixpt_add_int(*init, int_part);
}
} else {
/* Adjust for non-0 viewport offset */
if (*vp_offset) {
int int_part = dc_fixpt_floor(dc_fixpt_sub(*init, ratio));
int_part = int_part > 0 ? int_part : 0;
*vp_size += int_part < *vp_offset ? int_part : *vp_offset;
*vp_offset -= int_part < *vp_offset ? int_part : *vp_offset;
}
/* Adjust for viewport end clip-off */
if ((*vp_offset + *vp_size) < src_size) {
int int_part;
int end_offset = src_size - *vp_offset - *vp_size;
/*
* this is init if vp had no offset, keep in mind this is from the
* right side of vp due to scan direction
*/
*init = dc_fixpt_add(*init, dc_fixpt_mul_int(ratio, recout_skip));
/*
* this is the difference between first pixel of viewport available to read
* and init position, takning into account scan direction
*/
int_part = dc_fixpt_floor(*init) - end_offset;
if (int_part < taps) {
int int_adj = end_offset >= (taps - int_part) ?
(taps - int_part) : end_offset;
*vp_size += int_adj;
int_part += int_adj;
} else if (int_part > taps) {
*vp_size += int_part - taps;
int_part = taps;
}
init->value &= 0xffffffff;
*init = dc_fixpt_add_int(*init, int_part);
}
}
}
static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx)
{
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
const struct dc_stream_state *stream = pipe_ctx->stream;
struct scaler_data *data = &pipe_ctx->plane_res.scl_data;
struct rect src = pipe_ctx->plane_state->src_rect;
int recout_skip_h, recout_skip_v, surf_size_h, surf_size_v;
int vpc_div = (data->format == PIXEL_FORMAT_420BPP8
|| data->format == PIXEL_FORMAT_420BPP10) ? 2 : 1;
bool orthogonal_rotation, flip_vert_scan_dir, flip_horz_scan_dir;
/*
* Need to calculate the scan direction for viewport to make adjustments
*/
get_vp_scan_direction(
plane_state->rotation,
plane_state->horizontal_mirror,
&orthogonal_rotation,
&flip_vert_scan_dir,
&flip_horz_scan_dir);
/* Calculate src rect rotation adjusted to recout space */
surf_size_h = src.x + src.width;
surf_size_v = src.y + src.height;
if (flip_horz_scan_dir)
src.x = 0;
if (flip_vert_scan_dir)
src.y = 0;
if (orthogonal_rotation) {
swap(src.x, src.y);
swap(src.width, src.height);
}
/* Recout matching initial vp offset = recout_offset - (stream dst offset +
* ((surf dst offset - stream src offset) * 1/ stream scaling ratio)
* - (surf surf_src offset * 1/ full scl ratio))
*/
recout_skip_h = data->recout.x - (stream->dst.x + (plane_state->dst_rect.x - stream->src.x)
* stream->dst.width / stream->src.width -
src.x * plane_state->dst_rect.width / src.width
* stream->dst.width / stream->src.width);
recout_skip_v = data->recout.y - (stream->dst.y + (plane_state->dst_rect.y - stream->src.y)
* stream->dst.height / stream->src.height -
src.y * plane_state->dst_rect.height / src.height
* stream->dst.height / stream->src.height);
if (orthogonal_rotation)
swap(recout_skip_h, recout_skip_v);
/*
* Init calculated according to formula:
* init = (scaling_ratio + number_of_taps + 1) / 2
* init_bot = init + scaling_ratio
* init_c = init + truncated_vp_c_offset(from calculate viewport)
*/
data->inits.h = dc_fixpt_truncate(dc_fixpt_div_int(
dc_fixpt_add_int(data->ratios.horz, data->taps.h_taps + 1), 2), 19);
data->inits.h_c = dc_fixpt_truncate(dc_fixpt_add(data->inits.h_c, dc_fixpt_div_int(
dc_fixpt_add_int(data->ratios.horz_c, data->taps.h_taps_c + 1), 2)), 19);
data->inits.v = dc_fixpt_truncate(dc_fixpt_div_int(
dc_fixpt_add_int(data->ratios.vert, data->taps.v_taps + 1), 2), 19);
data->inits.v_c = dc_fixpt_truncate(dc_fixpt_add(data->inits.v_c, dc_fixpt_div_int(
dc_fixpt_add_int(data->ratios.vert_c, data->taps.v_taps_c + 1), 2)), 19);
/*
* Taps, inits and scaling ratios are in recout space need to rotate
* to viewport rotation before adjustment
*/
adjust_vp_and_init_for_seamless_clip(
flip_horz_scan_dir,
recout_skip_h,
surf_size_h,
orthogonal_rotation ? data->taps.v_taps : data->taps.h_taps,
orthogonal_rotation ? data->ratios.vert : data->ratios.horz,
orthogonal_rotation ? &data->inits.v : &data->inits.h,
&data->viewport.x,
&data->viewport.width);
adjust_vp_and_init_for_seamless_clip(
flip_horz_scan_dir,
recout_skip_h,
surf_size_h / vpc_div,
orthogonal_rotation ? data->taps.v_taps_c : data->taps.h_taps_c,
orthogonal_rotation ? data->ratios.vert_c : data->ratios.horz_c,
orthogonal_rotation ? &data->inits.v_c : &data->inits.h_c,
&data->viewport_c.x,
&data->viewport_c.width);
adjust_vp_and_init_for_seamless_clip(
flip_vert_scan_dir,
recout_skip_v,
surf_size_v,
orthogonal_rotation ? data->taps.h_taps : data->taps.v_taps,
orthogonal_rotation ? data->ratios.horz : data->ratios.vert,
orthogonal_rotation ? &data->inits.h : &data->inits.v,
&data->viewport.y,
&data->viewport.height);
adjust_vp_and_init_for_seamless_clip(
flip_vert_scan_dir,
recout_skip_v,
surf_size_v / vpc_div,
orthogonal_rotation ? data->taps.h_taps_c : data->taps.v_taps_c,
orthogonal_rotation ? data->ratios.horz_c : data->ratios.vert_c,
orthogonal_rotation ? &data->inits.h_c : &data->inits.v_c,
&data->viewport_c.y,
&data->viewport_c.height);
/* Interlaced inits based on final vert inits */
data->inits.v_bot = dc_fixpt_add(data->inits.v, data->ratios.vert);
data->inits.v_c_bot = dc_fixpt_add(data->inits.v_c, data->ratios.vert_c);
}
bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
{
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
struct dc_crtc_timing *timing = &pipe_ctx->stream->timing;
bool res = false;
DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
/* Important: scaling ratio calculation requires pixel format,
* lb depth calculation requires recout and taps require scaling ratios.
* Inits require viewport, taps, ratios and recout of split pipe
*/
pipe_ctx->plane_res.scl_data.format = convert_pixel_format_to_dalsurface(
pipe_ctx->plane_state->format);
calculate_scaling_ratios(pipe_ctx);
calculate_viewport(pipe_ctx);
if (pipe_ctx->plane_res.scl_data.viewport.height < 16 || pipe_ctx->plane_res.scl_data.viewport.width < 16)
return false;
calculate_recout(pipe_ctx);
/**
* Setting line buffer pixel depth to 24bpp yields banding
* on certain displays, such as the Sharp 4k
*/
pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP;
pipe_ctx->plane_res.scl_data.recout.x += timing->h_border_left;
pipe_ctx->plane_res.scl_data.recout.y += timing->v_border_top;
pipe_ctx->plane_res.scl_data.h_active = timing->h_addressable + timing->h_border_left + timing->h_border_right;
pipe_ctx->plane_res.scl_data.v_active = timing->v_addressable + timing->v_border_top + timing->v_border_bottom;
/* Taps calculations */
if (pipe_ctx->plane_res.xfm != NULL)
res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
pipe_ctx->plane_res.xfm, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
if (pipe_ctx->plane_res.dpp != NULL)
res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
if (!res) {
/* Try 24 bpp linebuffer */
pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_24BPP;
if (pipe_ctx->plane_res.xfm != NULL)
res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
pipe_ctx->plane_res.xfm,
&pipe_ctx->plane_res.scl_data,
&plane_state->scaling_quality);
if (pipe_ctx->plane_res.dpp != NULL)
res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
pipe_ctx->plane_res.dpp,
&pipe_ctx->plane_res.scl_data,
&plane_state->scaling_quality);
}
if (res)
/* May need to re-check lb size after this in some obscure scenario */
calculate_inits_and_adj_vp(pipe_ctx);
DC_LOG_SCALER(
"%s: Viewport:\nheight:%d width:%d x:%d "
"y:%d\n dst_rect:\nheight:%d width:%d x:%d "
"y:%d\n",
__func__,
pipe_ctx->plane_res.scl_data.viewport.height,
pipe_ctx->plane_res.scl_data.viewport.width,
pipe_ctx->plane_res.scl_data.viewport.x,
pipe_ctx->plane_res.scl_data.viewport.y,
plane_state->dst_rect.height,
plane_state->dst_rect.width,
plane_state->dst_rect.x,
plane_state->dst_rect.y);
return res;
}
enum dc_status resource_build_scaling_params_for_context(
const struct dc *dc,
struct dc_state *context)
{
int i;
for (i = 0; i < MAX_PIPES; i++) {
if (context->res_ctx.pipe_ctx[i].plane_state != NULL &&
context->res_ctx.pipe_ctx[i].stream != NULL)
if (!resource_build_scaling_params(&context->res_ctx.pipe_ctx[i]))
return DC_FAIL_SCALING;
}
return DC_OK;
}
struct pipe_ctx *find_idle_secondary_pipe(
struct resource_context *res_ctx,
const struct resource_pool *pool,
const struct pipe_ctx *primary_pipe)
{
int i;
struct pipe_ctx *secondary_pipe = NULL;
/*
* We add a preferred pipe mapping to avoid the chance that
* MPCCs already in use will need to be reassigned to other trees.
* For example, if we went with the strict, assign backwards logic:
*
* (State 1)
* Display A on, no surface, top pipe = 0
* Display B on, no surface, top pipe = 1
*
* (State 2)
* Display A on, no surface, top pipe = 0
* Display B on, surface enable, top pipe = 1, bottom pipe = 5
*
* (State 3)
* Display A on, surface enable, top pipe = 0, bottom pipe = 5
* Display B on, surface enable, top pipe = 1, bottom pipe = 4
*
* The state 2->3 transition requires remapping MPCC 5 from display B
* to display A.
*
* However, with the preferred pipe logic, state 2 would look like:
*
* (State 2)
* Display A on, no surface, top pipe = 0
* Display B on, surface enable, top pipe = 1, bottom pipe = 4
*
* This would then cause 2->3 to not require remapping any MPCCs.
*/
if (primary_pipe) {
int preferred_pipe_idx = (pool->pipe_count - 1) - primary_pipe->pipe_idx;
if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) {
secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx];
secondary_pipe->pipe_idx = preferred_pipe_idx;
}
}
/*
* search backwards for the second pipe to keep pipe
* assignment more consistent
*/
if (!secondary_pipe)
for (i = pool->pipe_count - 1; i >= 0; i--) {
if (res_ctx->pipe_ctx[i].stream == NULL) {
secondary_pipe = &res_ctx->pipe_ctx[i];
secondary_pipe->pipe_idx = i;
break;
}
}
return secondary_pipe;
}
struct pipe_ctx *resource_get_head_pipe_for_stream(
struct resource_context *res_ctx,
struct dc_stream_state *stream)
{
int i;
for (i = 0; i < MAX_PIPES; i++) {
if (res_ctx->pipe_ctx[i].stream == stream &&
!res_ctx->pipe_ctx[i].top_pipe) {
return &res_ctx->pipe_ctx[i];
break;
}
}
return NULL;
}
static struct pipe_ctx *resource_get_tail_pipe_for_stream(
struct resource_context *res_ctx,
struct dc_stream_state *stream)
{
struct pipe_ctx *head_pipe, *tail_pipe;
head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);
if (!head_pipe)
return NULL;
tail_pipe = head_pipe->bottom_pipe;
while (tail_pipe) {
head_pipe = tail_pipe;
tail_pipe = tail_pipe->bottom_pipe;
}
return head_pipe;
}
/*
* A free_pipe for a stream is defined here as a pipe
* that has no surface attached yet
*/
static struct pipe_ctx *acquire_free_pipe_for_stream(
struct dc_state *context,
const struct resource_pool *pool,
struct dc_stream_state *stream)
{
int i;
struct resource_context *res_ctx = &context->res_ctx;
struct pipe_ctx *head_pipe = NULL;
/* Find head pipe, which has the back end set up*/
head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);
if (!head_pipe) {
ASSERT(0);
return NULL;
}
if (!head_pipe->plane_state)
return head_pipe;
/* Re-use pipe already acquired for this stream if available*/
for (i = pool->pipe_count - 1; i >= 0; i--) {
if (res_ctx->pipe_ctx[i].stream == stream &&
!res_ctx->pipe_ctx[i].plane_state) {
return &res_ctx->pipe_ctx[i];
}
}
/*
* At this point we have no re-useable pipe for this stream and we need
* to acquire an idle one to satisfy the request
*/
if (!pool->funcs->acquire_idle_pipe_for_layer)
return NULL;
return pool->funcs->acquire_idle_pipe_for_layer(context, pool, stream);
}
#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
static int acquire_first_split_pipe(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream)
{
int i;
for (i = 0; i < pool->pipe_count; i++) {
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
if (pipe_ctx->top_pipe &&
pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state) {
pipe_ctx->top_pipe->bottom_pipe = pipe_ctx->bottom_pipe;
if (pipe_ctx->bottom_pipe)
pipe_ctx->bottom_pipe->top_pipe = pipe_ctx->top_pipe;
memset(pipe_ctx, 0, sizeof(*pipe_ctx));
pipe_ctx->stream_res.tg = pool->timing_generators[i];
pipe_ctx->plane_res.hubp = pool->hubps[i];
pipe_ctx->plane_res.ipp = pool->ipps[i];
pipe_ctx->plane_res.dpp = pool->dpps[i];
pipe_ctx->stream_res.opp = pool->opps[i];
pipe_ctx->plane_res.mpcc_inst = pool->dpps[i]->inst;
pipe_ctx->pipe_idx = i;
pipe_ctx->stream = stream;
return i;
}
}
return -1;
}
#endif
bool dc_add_plane_to_context(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_plane_state *plane_state,
struct dc_state *context)
{
int i;
struct resource_pool *pool = dc->res_pool;
struct pipe_ctx *head_pipe, *tail_pipe, *free_pipe;
struct dc_stream_status *stream_status = NULL;
for (i = 0; i < context->stream_count; i++)
if (context->streams[i] == stream) {
stream_status = &context->stream_status[i];
break;
}
if (stream_status == NULL) {
dm_error("Existing stream not found; failed to attach surface!\n");
return false;
}
if (stream_status->plane_count == MAX_SURFACE_NUM) {
dm_error("Surface: can not attach plane_state %p! Maximum is: %d\n",
plane_state, MAX_SURFACE_NUM);
return false;
}
head_pipe = resource_get_head_pipe_for_stream(&context->res_ctx, stream);
if (!head_pipe) {
dm_error("Head pipe not found for stream_state %p !\n", stream);
return false;
}
tail_pipe = resource_get_tail_pipe_for_stream(&context->res_ctx, stream);
ASSERT(tail_pipe);
free_pipe = acquire_free_pipe_for_stream(context, pool, stream);
#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
if (!free_pipe) {
int pipe_idx = acquire_first_split_pipe(&context->res_ctx, pool, stream);
if (pipe_idx >= 0)
free_pipe = &context->res_ctx.pipe_ctx[pipe_idx];
}
#endif
if (!free_pipe)
return false;
/* retain new surfaces */
dc_plane_state_retain(plane_state);
free_pipe->plane_state = plane_state;
if (head_pipe != free_pipe) {
free_pipe->stream_res.tg = tail_pipe->stream_res.tg;
free_pipe->stream_res.abm = tail_pipe->stream_res.abm;
free_pipe->stream_res.opp = tail_pipe->stream_res.opp;
free_pipe->stream_res.stream_enc = tail_pipe->stream_res.stream_enc;
free_pipe->stream_res.audio = tail_pipe->stream_res.audio;
free_pipe->clock_source = tail_pipe->clock_source;
free_pipe->top_pipe = tail_pipe;
tail_pipe->bottom_pipe = free_pipe;
} else if (free_pipe->bottom_pipe && free_pipe->bottom_pipe->plane_state == NULL) {
ASSERT(free_pipe->bottom_pipe->stream_res.opp != free_pipe->stream_res.opp);
free_pipe->bottom_pipe->plane_state = plane_state;
}
/* assign new surfaces*/
stream_status->plane_states[stream_status->plane_count] = plane_state;
stream_status->plane_count++;
return true;
}
struct pipe_ctx *dc_res_get_odm_bottom_pipe(struct pipe_ctx *pipe_ctx)
{
struct pipe_ctx *bottom_pipe = pipe_ctx->bottom_pipe;
/* ODM should only be updated once per otg */
if (pipe_ctx->top_pipe)
return NULL;
while (bottom_pipe) {
if (bottom_pipe->stream_res.opp != pipe_ctx->stream_res.opp)
break;
bottom_pipe = bottom_pipe->bottom_pipe;
}
return bottom_pipe;
}
bool dc_res_is_odm_head_pipe(struct pipe_ctx *pipe_ctx)
{
struct pipe_ctx *top_pipe = pipe_ctx->top_pipe;
if (!top_pipe)
return false;
if (top_pipe && top_pipe->stream_res.opp == pipe_ctx->stream_res.opp)
return false;
return true;
}
bool dc_remove_plane_from_context(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_plane_state *plane_state,
struct dc_state *context)
{
int i;
struct dc_stream_status *stream_status = NULL;
struct resource_pool *pool = dc->res_pool;
for (i = 0; i < context->stream_count; i++)
if (context->streams[i] == stream) {
stream_status = &context->stream_status[i];
break;
}
if (stream_status == NULL) {
dm_error("Existing stream not found; failed to remove plane.\n");
return false;
}
/* release pipe for plane*/
for (i = pool->pipe_count - 1; i >= 0; i--) {
struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
if (pipe_ctx->plane_state == plane_state) {
if (dc_res_is_odm_head_pipe(pipe_ctx)) {
pipe_ctx->plane_state = NULL;
pipe_ctx->bottom_pipe = NULL;
continue;
}
if (pipe_ctx->top_pipe)
pipe_ctx->top_pipe->bottom_pipe = pipe_ctx->bottom_pipe;
/* Second condition is to avoid setting NULL to top pipe
* of tail pipe making it look like head pipe in subsequent
* deletes
*/
if (pipe_ctx->bottom_pipe && pipe_ctx->top_pipe)
pipe_ctx->bottom_pipe->top_pipe = pipe_ctx->top_pipe;
/*
* For head pipe detach surfaces from pipe for tail
* pipe just zero it out
*/
if (!pipe_ctx->top_pipe) {
pipe_ctx->plane_state = NULL;
if (!dc_res_get_odm_bottom_pipe(pipe_ctx))
pipe_ctx->bottom_pipe = NULL;
} else {
memset(pipe_ctx, 0, sizeof(*pipe_ctx));
}
}
}
for (i = 0; i < stream_status->plane_count; i++) {
if (stream_status->plane_states[i] == plane_state) {
dc_plane_state_release(stream_status->plane_states[i]);
break;
}
}
if (i == stream_status->plane_count) {
dm_error("Existing plane_state not found; failed to detach it!\n");
return false;
}
stream_status->plane_count--;
/* Start at the plane we've just released, and move all the planes one index forward to "trim" the array */
for (; i < stream_status->plane_count; i++)
stream_status->plane_states[i] = stream_status->plane_states[i + 1];
stream_status->plane_states[stream_status->plane_count] = NULL;
return true;
}
bool dc_rem_all_planes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_state *context)
{
int i, old_plane_count;
struct dc_stream_status *stream_status = NULL;
struct dc_plane_state *del_planes[MAX_SURFACE_NUM] = { 0 };
for (i = 0; i < context->stream_count; i++)
if (context->streams[i] == stream) {
stream_status = &context->stream_status[i];
break;
}
if (stream_status == NULL) {
dm_error("Existing stream %p not found!\n", stream);
return false;
}
old_plane_count = stream_status->plane_count;
for (i = 0; i < old_plane_count; i++)
del_planes[i] = stream_status->plane_states[i];
for (i = 0; i < old_plane_count; i++)
if (!dc_remove_plane_from_context(dc, stream, del_planes[i], context))
return false;
return true;
}
static bool add_all_planes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
const struct dc_validation_set set[],
int set_count,
struct dc_state *context)
{
int i, j;
for (i = 0; i < set_count; i++)
if (set[i].stream == stream)
break;
if (i == set_count) {
dm_error("Stream %p not found in set!\n", stream);
return false;
}
for (j = 0; j < set[i].plane_count; j++)
if (!dc_add_plane_to_context(dc, stream, set[i].plane_states[j], context))
return false;
return true;
}
bool dc_add_all_planes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_plane_state * const *plane_states,
int plane_count,
struct dc_state *context)
{
struct dc_validation_set set;
int i;
set.stream = stream;
set.plane_count = plane_count;
for (i = 0; i < plane_count; i++)
set.plane_states[i] = plane_states[i];
return add_all_planes_for_stream(dc, stream, &set, 1, context);
}
static bool is_hdr_static_meta_changed(struct dc_stream_state *cur_stream,
struct dc_stream_state *new_stream)
{
if (cur_stream == NULL)
return true;
if (memcmp(&cur_stream->hdr_static_metadata,
&new_stream->hdr_static_metadata,
sizeof(struct dc_info_packet)) != 0)
return true;
return false;
}
static bool is_vsc_info_packet_changed(struct dc_stream_state *cur_stream,
struct dc_stream_state *new_stream)
{
if (cur_stream == NULL)
return true;
if (memcmp(&cur_stream->vsc_infopacket,
&new_stream->vsc_infopacket,
sizeof(struct dc_info_packet)) != 0)
return true;
return false;
}
static bool is_timing_changed(struct dc_stream_state *cur_stream,
struct dc_stream_state *new_stream)
{
if (cur_stream == NULL)
return true;
/* If sink pointer changed, it means this is a hotplug, we should do
* full hw setting.
*/
if (cur_stream->sink != new_stream->sink)
return true;
/* If output color space is changed, need to reprogram info frames */
if (cur_stream->output_color_space != new_stream->output_color_space)
return true;
return memcmp(
&cur_stream->timing,
&new_stream->timing,
sizeof(struct dc_crtc_timing)) != 0;
}
static bool are_stream_backends_same(
struct dc_stream_state *stream_a, struct dc_stream_state *stream_b)
{
if (stream_a == stream_b)
return true;
if (stream_a == NULL || stream_b == NULL)
return false;
if (is_timing_changed(stream_a, stream_b))
return false;
if (is_hdr_static_meta_changed(stream_a, stream_b))
return false;
if (stream_a->dpms_off != stream_b->dpms_off)
return false;
if (is_vsc_info_packet_changed(stream_a, stream_b))
return false;
return true;
}
/**
* dc_is_stream_unchanged() - Compare two stream states for equivalence.
*
* Checks if there a difference between the two states
* that would require a mode change.
*
* Does not compare cursor position or attributes.
*/
bool dc_is_stream_unchanged(
struct dc_stream_state *old_stream, struct dc_stream_state *stream)
{
if (!are_stream_backends_same(old_stream, stream))
return false;
return true;
}
/**
* dc_is_stream_scaling_unchanged() - Compare scaling rectangles of two streams.
*/
bool dc_is_stream_scaling_unchanged(
struct dc_stream_state *old_stream, struct dc_stream_state *stream)
{
if (old_stream == stream)
return true;
if (old_stream == NULL || stream == NULL)
return false;
if (memcmp(&old_stream->src,
&stream->src,
sizeof(struct rect)) != 0)
return false;
if (memcmp(&old_stream->dst,
&stream->dst,
sizeof(struct rect)) != 0)
return false;
return true;
}
static void update_stream_engine_usage(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct stream_encoder *stream_enc,
bool acquired)
{
int i;
for (i = 0; i < pool->stream_enc_count; i++) {
if (pool->stream_enc[i] == stream_enc)
res_ctx->is_stream_enc_acquired[i] = acquired;
}
}
/* TODO: release audio object */
void update_audio_usage(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct audio *audio,
bool acquired)
{
int i;
for (i = 0; i < pool->audio_count; i++) {
if (pool->audios[i] == audio)
res_ctx->is_audio_acquired[i] = acquired;
}
}
static int acquire_first_free_pipe(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream)
{
int i;
for (i = 0; i < pool->pipe_count; i++) {
if (!res_ctx->pipe_ctx[i].stream) {
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
pipe_ctx->stream_res.tg = pool->timing_generators[i];
pipe_ctx->plane_res.mi = pool->mis[i];
pipe_ctx->plane_res.hubp = pool->hubps[i];
pipe_ctx->plane_res.ipp = pool->ipps[i];
pipe_ctx->plane_res.xfm = pool->transforms[i];
pipe_ctx->plane_res.dpp = pool->dpps[i];
pipe_ctx->stream_res.opp = pool->opps[i];
if (pool->dpps[i])
pipe_ctx->plane_res.mpcc_inst = pool->dpps[i]->inst;
pipe_ctx->pipe_idx = i;
pipe_ctx->stream = stream;
return i;
}
}
return -1;
}
static struct stream_encoder *find_first_free_match_stream_enc_for_link(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream)
{
int i;
int j = -1;
struct dc_link *link = stream->link;
for (i = 0; i < pool->stream_enc_count; i++) {
if (!res_ctx->is_stream_enc_acquired[i] &&
pool->stream_enc[i]) {
/* Store first available for MST second display
* in daisy chain use case */
j = i;
if (pool->stream_enc[i]->id ==
link->link_enc->preferred_engine)
return pool->stream_enc[i];
}
}
/*
* below can happen in cases when stream encoder is acquired:
* 1) for second MST display in chain, so preferred engine already
* acquired;
* 2) for another link, which preferred engine already acquired by any
* MST configuration.
*
* If signal is of DP type and preferred engine not found, return last available
*
* TODO - This is just a patch up and a generic solution is
* required for non DP connectors.
*/
if (j >= 0 && link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT)
return pool->stream_enc[j];
return NULL;
}
static struct audio *find_first_free_audio(
struct resource_context *res_ctx,
const struct resource_pool *pool,
enum engine_id id)
{
int i;
for (i = 0; i < pool->audio_count; i++) {
if ((res_ctx->is_audio_acquired[i] == false) && (res_ctx->is_stream_enc_acquired[i] == true)) {
/*we have enough audio endpoint, find the matching inst*/
if (id != i)
continue;
return pool->audios[i];
}
}
/*not found the matching one, first come first serve*/
for (i = 0; i < pool->audio_count; i++) {
if (res_ctx->is_audio_acquired[i] == false) {
return pool->audios[i];
}
}
return 0;
}
bool resource_is_stream_unchanged(
struct dc_state *old_context, struct dc_stream_state *stream)
{
int i;
for (i = 0; i < old_context->stream_count; i++) {
struct dc_stream_state *old_stream = old_context->streams[i];
if (are_stream_backends_same(old_stream, stream))
return true;
}
return false;
}
/**
* dc_add_stream_to_ctx() - Add a new dc_stream_state to a dc_state.
*/
enum dc_status dc_add_stream_to_ctx(
struct dc *dc,
struct dc_state *new_ctx,
struct dc_stream_state *stream)
{
enum dc_status res;
DC_LOGGER_INIT(dc->ctx->logger);
if (new_ctx->stream_count >= dc->res_pool->timing_generator_count) {
DC_LOG_WARNING("Max streams reached, can't add stream %p !\n", stream);
return DC_ERROR_UNEXPECTED;
}
new_ctx->streams[new_ctx->stream_count] = stream;
dc_stream_retain(stream);
new_ctx->stream_count++;
res = dc->res_pool->funcs->add_stream_to_ctx(dc, new_ctx, stream);
if (res != DC_OK)
DC_LOG_WARNING("Adding stream %p to context failed with err %d!\n", stream, res);
return res;
}
/**
* dc_remove_stream_from_ctx() - Remove a stream from a dc_state.
*/
enum dc_status dc_remove_stream_from_ctx(
struct dc *dc,
struct dc_state *new_ctx,
struct dc_stream_state *stream)
{
int i;
struct dc_context *dc_ctx = dc->ctx;
struct pipe_ctx *del_pipe = NULL;
/* Release primary pipe */
for (i = 0; i < MAX_PIPES; i++) {
if (new_ctx->res_ctx.pipe_ctx[i].stream == stream &&
!new_ctx->res_ctx.pipe_ctx[i].top_pipe) {
struct pipe_ctx *odm_pipe =
dc_res_get_odm_bottom_pipe(&new_ctx->res_ctx.pipe_ctx[i]);
del_pipe = &new_ctx->res_ctx.pipe_ctx[i];
ASSERT(del_pipe->stream_res.stream_enc);
update_stream_engine_usage(
&new_ctx->res_ctx,
dc->res_pool,
del_pipe->stream_res.stream_enc,
false);
if (del_pipe->stream_res.audio)
update_audio_usage(
&new_ctx->res_ctx,
dc->res_pool,
del_pipe->stream_res.audio,
false);
resource_unreference_clock_source(&new_ctx->res_ctx,
dc->res_pool,
del_pipe->clock_source);
if (dc->res_pool->funcs->remove_stream_from_ctx)
dc->res_pool->funcs->remove_stream_from_ctx(dc, new_ctx, stream);
memset(del_pipe, 0, sizeof(*del_pipe));
if (odm_pipe)
memset(odm_pipe, 0, sizeof(*odm_pipe));
break;
}
}
if (!del_pipe) {
DC_ERROR("Pipe not found for stream %p !\n", stream);
return DC_ERROR_UNEXPECTED;
}
for (i = 0; i < new_ctx->stream_count; i++)
if (new_ctx->streams[i] == stream)
break;
if (new_ctx->streams[i] != stream) {
DC_ERROR("Context doesn't have stream %p !\n", stream);
return DC_ERROR_UNEXPECTED;
}
dc_stream_release(new_ctx->streams[i]);
new_ctx->stream_count--;
/* Trim back arrays */
for (; i < new_ctx->stream_count; i++) {
new_ctx->streams[i] = new_ctx->streams[i + 1];
new_ctx->stream_status[i] = new_ctx->stream_status[i + 1];
}
new_ctx->streams[new_ctx->stream_count] = NULL;
memset(
&new_ctx->stream_status[new_ctx->stream_count],
0,
sizeof(new_ctx->stream_status[0]));
return DC_OK;
}
static struct dc_stream_state *find_pll_sharable_stream(
struct dc_stream_state *stream_needs_pll,
struct dc_state *context)
{
int i;
for (i = 0; i < context->stream_count; i++) {
struct dc_stream_state *stream_has_pll = context->streams[i];
/* We are looking for non dp, non virtual stream */
if (resource_are_streams_timing_synchronizable(
stream_needs_pll, stream_has_pll)
&& !dc_is_dp_signal(stream_has_pll->signal)
&& stream_has_pll->link->connector_signal
!= SIGNAL_TYPE_VIRTUAL)
return stream_has_pll;
}
return NULL;
}
static int get_norm_pix_clk(const struct dc_crtc_timing *timing)
{
uint32_t pix_clk = timing->pix_clk_100hz;
uint32_t normalized_pix_clk = pix_clk;
if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
pix_clk /= 2;
if (timing->pixel_encoding != PIXEL_ENCODING_YCBCR422) {
switch (timing->display_color_depth) {
case COLOR_DEPTH_888:
normalized_pix_clk = pix_clk;
break;
case COLOR_DEPTH_101010:
normalized_pix_clk = (pix_clk * 30) / 24;
break;
case COLOR_DEPTH_121212:
normalized_pix_clk = (pix_clk * 36) / 24;
break;
case COLOR_DEPTH_161616:
normalized_pix_clk = (pix_clk * 48) / 24;
break;
default:
ASSERT(0);
break;
}
}
return normalized_pix_clk;
}
static void calculate_phy_pix_clks(struct dc_stream_state *stream)
{
/* update actual pixel clock on all streams */
if (dc_is_hdmi_signal(stream->signal))
stream->phy_pix_clk = get_norm_pix_clk(
&stream->timing) / 10;
else
stream->phy_pix_clk =
stream->timing.pix_clk_100hz / 10;
if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
stream->phy_pix_clk *= 2;
}
static int acquire_resource_from_hw_enabled_state(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream)
{
struct dc_link *link = stream->link;
unsigned int inst;
/* Check for enabled DIG to identify enabled display */
if (!link->link_enc->funcs->is_dig_enabled(link->link_enc))
return -1;
/* Check for which front end is used by this encoder.
* Note the inst is 1 indexed, where 0 is undefined.
* Note that DIG_FE can source from different OTG but our
* current implementation always map 1-to-1, so this code makes
* the same assumption and doesn't check OTG source.
*/
inst = link->link_enc->funcs->get_dig_frontend(link->link_enc) - 1;
/* Instance should be within the range of the pool */
if (inst >= pool->pipe_count)
return -1;
if (!res_ctx->pipe_ctx[inst].stream) {
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[inst];
pipe_ctx->stream_res.tg = pool->timing_generators[inst];
pipe_ctx->plane_res.mi = pool->mis[inst];
pipe_ctx->plane_res.hubp = pool->hubps[inst];
pipe_ctx->plane_res.ipp = pool->ipps[inst];
pipe_ctx->plane_res.xfm = pool->transforms[inst];
pipe_ctx->plane_res.dpp = pool->dpps[inst];
pipe_ctx->stream_res.opp = pool->opps[inst];
if (pool->dpps[inst])
pipe_ctx->plane_res.mpcc_inst = pool->dpps[inst]->inst;
pipe_ctx->pipe_idx = inst;
pipe_ctx->stream = stream;
return inst;
}
return -1;
}
enum dc_status resource_map_pool_resources(
const struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream)
{
const struct resource_pool *pool = dc->res_pool;
int i;
struct dc_context *dc_ctx = dc->ctx;
struct pipe_ctx *pipe_ctx = NULL;
int pipe_idx = -1;
struct dc_bios *dcb = dc->ctx->dc_bios;
/* TODO Check if this is needed */
/*if (!resource_is_stream_unchanged(old_context, stream)) {
if (stream != NULL && old_context->streams[i] != NULL) {
stream->bit_depth_params =
old_context->streams[i]->bit_depth_params;
stream->clamping = old_context->streams[i]->clamping;
continue;
}
}
*/
calculate_phy_pix_clks(stream);
/* TODO: Check Linux */
if (dc->config.allow_seamless_boot_optimization &&
!dcb->funcs->is_accelerated_mode(dcb)) {
if (dc_validate_seamless_boot_timing(dc, stream->sink, &stream->timing))
stream->apply_seamless_boot_optimization = true;
}
if (stream->apply_seamless_boot_optimization)
pipe_idx = acquire_resource_from_hw_enabled_state(
&context->res_ctx,
pool,
stream);
if (pipe_idx < 0)
/* acquire new resources */
pipe_idx = acquire_first_free_pipe(&context->res_ctx, pool, stream);
#ifdef CONFIG_DRM_AMD_DC_DCN1_0
if (pipe_idx < 0)
pipe_idx = acquire_first_split_pipe(&context->res_ctx, pool, stream);
#endif
if (pipe_idx < 0 || context->res_ctx.pipe_ctx[pipe_idx].stream_res.tg == NULL)
return DC_NO_CONTROLLER_RESOURCE;
pipe_ctx = &context->res_ctx.pipe_ctx[pipe_idx];
pipe_ctx->stream_res.stream_enc =
find_first_free_match_stream_enc_for_link(
&context->res_ctx, pool, stream);
if (!pipe_ctx->stream_res.stream_enc)
return DC_NO_STREAM_ENC_RESOURCE;
update_stream_engine_usage(
&context->res_ctx, pool,
pipe_ctx->stream_res.stream_enc,
true);
/* TODO: Add check if ASIC support and EDID audio */
if (!stream->converter_disable_audio &&
dc_is_audio_capable_signal(pipe_ctx->stream->signal) &&
stream->audio_info.mode_count) {
pipe_ctx->stream_res.audio = find_first_free_audio(
&context->res_ctx, pool, pipe_ctx->stream_res.stream_enc->id);
/*
* Audio assigned in order first come first get.
* There are asics which has number of audio
* resources less then number of pipes
*/
if (pipe_ctx->stream_res.audio)
update_audio_usage(&context->res_ctx, pool,
pipe_ctx->stream_res.audio, true);
}
/* Add ABM to the resource if on EDP */
if (pipe_ctx->stream && dc_is_embedded_signal(pipe_ctx->stream->signal))
pipe_ctx->stream_res.abm = pool->abm;
for (i = 0; i < context->stream_count; i++)
if (context->streams[i] == stream) {
context->stream_status[i].primary_otg_inst = pipe_ctx->stream_res.tg->inst;
context->stream_status[i].stream_enc_inst = pipe_ctx->stream_res.stream_enc->id;
return DC_OK;
}
DC_ERROR("Stream %p not found in new ctx!\n", stream);
return DC_ERROR_UNEXPECTED;
}
/**
* dc_resource_state_copy_construct_current() - Creates a new dc_state from existing state
* Is a shallow copy. Increments refcounts on existing streams and planes.
* @dc: copy out of dc->current_state
* @dst_ctx: copy into this
*/
void dc_resource_state_copy_construct_current(
const struct dc *dc,
struct dc_state *dst_ctx)
{
dc_resource_state_copy_construct(dc->current_state, dst_ctx);
}
void dc_resource_state_construct(
const struct dc *dc,
struct dc_state *dst_ctx)
{
dst_ctx->clk_mgr = dc->res_pool->clk_mgr;
}
/**
* dc_validate_global_state() - Determine if HW can support a given state
* Checks HW resource availability and bandwidth requirement.
* @dc: dc struct for this driver
* @new_ctx: state to be validated
* @fast_validate: set to true if only yes/no to support matters
*
* Return: DC_OK if the result can be programmed. Otherwise, an error code.
*/
enum dc_status dc_validate_global_state(
struct dc *dc,
struct dc_state *new_ctx,
bool fast_validate)
{
enum dc_status result = DC_ERROR_UNEXPECTED;
int i, j;
if (!new_ctx)
return DC_ERROR_UNEXPECTED;
if (dc->res_pool->funcs->validate_global) {
result = dc->res_pool->funcs->validate_global(dc, new_ctx);
if (result != DC_OK)
return result;
}
for (i = 0; i < new_ctx->stream_count; i++) {
struct dc_stream_state *stream = new_ctx->streams[i];
for (j = 0; j < dc->res_pool->pipe_count; j++) {
struct pipe_ctx *pipe_ctx = &new_ctx->res_ctx.pipe_ctx[j];
if (pipe_ctx->stream != stream)
continue;
if (dc->res_pool->funcs->get_default_swizzle_mode &&
pipe_ctx->plane_state &&
pipe_ctx->plane_state->tiling_info.gfx9.swizzle == DC_SW_UNKNOWN) {
result = dc->res_pool->funcs->get_default_swizzle_mode(pipe_ctx->plane_state);
if (result != DC_OK)
return result;
}
/* Switch to dp clock source only if there is
* no non dp stream that shares the same timing
* with the dp stream.
*/
if (dc_is_dp_signal(pipe_ctx->stream->signal) &&
!find_pll_sharable_stream(stream, new_ctx)) {
resource_unreference_clock_source(
&new_ctx->res_ctx,
dc->res_pool,
pipe_ctx->clock_source);
pipe_ctx->clock_source = dc->res_pool->dp_clock_source;
resource_reference_clock_source(
&new_ctx->res_ctx,
dc->res_pool,
pipe_ctx->clock_source);
}
}
}
result = resource_build_scaling_params_for_context(dc, new_ctx);
if (result == DC_OK)
if (!dc->res_pool->funcs->validate_bandwidth(dc, new_ctx, fast_validate))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result;
}
static void patch_gamut_packet_checksum(
struct dc_info_packet *gamut_packet)
{
/* For gamut we recalc checksum */
if (gamut_packet->valid) {
uint8_t chk_sum = 0;
uint8_t *ptr;
uint8_t i;
/*start of the Gamut data. */
ptr = &gamut_packet->sb[3];
for (i = 0; i <= gamut_packet->sb[1]; i++)
chk_sum += ptr[i];
gamut_packet->sb[2] = (uint8_t) (0x100 - chk_sum);
}
}
static void set_avi_info_frame(
struct dc_info_packet *info_packet,
struct pipe_ctx *pipe_ctx)
{
struct dc_stream_state *stream = pipe_ctx->stream;
enum dc_color_space color_space = COLOR_SPACE_UNKNOWN;
uint32_t pixel_encoding = 0;
enum scanning_type scan_type = SCANNING_TYPE_NODATA;
enum dc_aspect_ratio aspect = ASPECT_RATIO_NO_DATA;
bool itc = false;
uint8_t itc_value = 0;
uint8_t cn0_cn1 = 0;
unsigned int cn0_cn1_value = 0;
uint8_t *check_sum = NULL;
uint8_t byte_index = 0;
union hdmi_info_packet hdmi_info;
union display_content_support support = {0};
unsigned int vic = pipe_ctx->stream->timing.vic;
enum dc_timing_3d_format format;
memset(&hdmi_info, 0, sizeof(union hdmi_info_packet));
color_space = pipe_ctx->stream->output_color_space;
if (color_space == COLOR_SPACE_UNKNOWN)
color_space = (stream->timing.pixel_encoding == PIXEL_ENCODING_RGB) ?
COLOR_SPACE_SRGB:COLOR_SPACE_YCBCR709;
/* Initialize header */
hdmi_info.bits.header.info_frame_type = HDMI_INFOFRAME_TYPE_AVI;
/* InfoFrameVersion_3 is defined by CEA861F (Section 6.4), but shall
* not be used in HDMI 2.0 (Section 10.1) */
hdmi_info.bits.header.version = 2;
hdmi_info.bits.header.length = HDMI_AVI_INFOFRAME_SIZE;
/*
* IDO-defined (Y2,Y1,Y0 = 1,1,1) shall not be used by devices built
* according to HDMI 2.0 spec (Section 10.1)
*/
switch (stream->timing.pixel_encoding) {
case PIXEL_ENCODING_YCBCR422:
pixel_encoding = 1;
break;
case PIXEL_ENCODING_YCBCR444:
pixel_encoding = 2;
break;
case PIXEL_ENCODING_YCBCR420:
pixel_encoding = 3;
break;
case PIXEL_ENCODING_RGB:
default:
pixel_encoding = 0;
}
/* Y0_Y1_Y2 : The pixel encoding */
/* H14b AVI InfoFrame has extension on Y-field from 2 bits to 3 bits */
hdmi_info.bits.Y0_Y1_Y2 = pixel_encoding;
/* A0 = 1 Active Format Information valid */
hdmi_info.bits.A0 = ACTIVE_FORMAT_VALID;
/* B0, B1 = 3; Bar info data is valid */
hdmi_info.bits.B0_B1 = BAR_INFO_BOTH_VALID;
hdmi_info.bits.SC0_SC1 = PICTURE_SCALING_UNIFORM;
/* S0, S1 : Underscan / Overscan */
/* TODO: un-hardcode scan type */
scan_type = SCANNING_TYPE_UNDERSCAN;
hdmi_info.bits.S0_S1 = scan_type;
/* C0, C1 : Colorimetry */
if (color_space == COLOR_SPACE_YCBCR709 ||
color_space == COLOR_SPACE_YCBCR709_LIMITED)
hdmi_info.bits.C0_C1 = COLORIMETRY_ITU709;
else if (color_space == COLOR_SPACE_YCBCR601 ||
color_space == COLOR_SPACE_YCBCR601_LIMITED)
hdmi_info.bits.C0_C1 = COLORIMETRY_ITU601;
else {
hdmi_info.bits.C0_C1 = COLORIMETRY_NO_DATA;
}
if (color_space == COLOR_SPACE_2020_RGB_FULLRANGE ||
color_space == COLOR_SPACE_2020_RGB_LIMITEDRANGE ||
color_space == COLOR_SPACE_2020_YCBCR) {
hdmi_info.bits.EC0_EC2 = COLORIMETRYEX_BT2020RGBYCBCR;
hdmi_info.bits.C0_C1 = COLORIMETRY_EXTENDED;
} else if (color_space == COLOR_SPACE_ADOBERGB) {
hdmi_info.bits.EC0_EC2 = COLORIMETRYEX_ADOBERGB;
hdmi_info.bits.C0_C1 = COLORIMETRY_EXTENDED;
}
/* TODO: un-hardcode aspect ratio */
aspect = stream->timing.aspect_ratio;
switch (aspect) {
case ASPECT_RATIO_4_3:
case ASPECT_RATIO_16_9:
hdmi_info.bits.M0_M1 = aspect;
break;
case ASPECT_RATIO_NO_DATA:
case ASPECT_RATIO_64_27:
case ASPECT_RATIO_256_135:
default:
hdmi_info.bits.M0_M1 = 0;
}
/* Active Format Aspect ratio - same as Picture Aspect Ratio. */
hdmi_info.bits.R0_R3 = ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE;
/* TODO: un-hardcode cn0_cn1 and itc */
cn0_cn1 = 0;
cn0_cn1_value = 0;
itc = true;
itc_value = 1;
support = stream->content_support;
if (itc) {
if (!support.bits.valid_content_type) {
cn0_cn1_value = 0;
} else {
if (cn0_cn1 == DISPLAY_CONTENT_TYPE_GRAPHICS) {
if (support.bits.graphics_content == 1) {
cn0_cn1_value = 0;
}
} else if (cn0_cn1 == DISPLAY_CONTENT_TYPE_PHOTO) {
if (support.bits.photo_content == 1) {
cn0_cn1_value = 1;
} else {
cn0_cn1_value = 0;
itc_value = 0;
}
} else if (cn0_cn1 == DISPLAY_CONTENT_TYPE_CINEMA) {
if (support.bits.cinema_content == 1) {
cn0_cn1_value = 2;
} else {
cn0_cn1_value = 0;
itc_value = 0;
}
} else if (cn0_cn1 == DISPLAY_CONTENT_TYPE_GAME) {
if (support.bits.game_content == 1) {
cn0_cn1_value = 3;
} else {
cn0_cn1_value = 0;
itc_value = 0;
}
}
}
hdmi_info.bits.CN0_CN1 = cn0_cn1_value;
hdmi_info.bits.ITC = itc_value;
}
/* TODO : We should handle YCC quantization */
/* but we do not have matrix calculation */
if (stream->qs_bit == 1 &&
stream->qy_bit == 1) {
if (color_space == COLOR_SPACE_SRGB ||
color_space == COLOR_SPACE_2020_RGB_FULLRANGE) {
hdmi_info.bits.Q0_Q1 = RGB_QUANTIZATION_FULL_RANGE;
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_FULL_RANGE;
} else if (color_space == COLOR_SPACE_SRGB_LIMITED ||
color_space == COLOR_SPACE_2020_RGB_LIMITEDRANGE) {
hdmi_info.bits.Q0_Q1 = RGB_QUANTIZATION_LIMITED_RANGE;
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
} else {
hdmi_info.bits.Q0_Q1 = RGB_QUANTIZATION_DEFAULT_RANGE;
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
}
} else {
hdmi_info.bits.Q0_Q1 = RGB_QUANTIZATION_DEFAULT_RANGE;
hdmi_info.bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
}
///VIC
format = stream->timing.timing_3d_format;
/*todo, add 3DStereo support*/
if (format != TIMING_3D_FORMAT_NONE) {
// Based on HDMI specs hdmi vic needs to be converted to cea vic when 3D is enabled
switch (pipe_ctx->stream->timing.hdmi_vic) {
case 1:
vic = 95;
break;
case 2:
vic = 94;
break;
case 3:
vic = 93;
break;
case 4:
vic = 98;
break;
default:
break;
}
}
hdmi_info.bits.VIC0_VIC7 = vic;
/* pixel repetition
* PR0 - PR3 start from 0 whereas pHwPathMode->mode.timing.flags.pixel
* repetition start from 1 */
hdmi_info.bits.PR0_PR3 = 0;
/* Bar Info
* barTop: Line Number of End of Top Bar.
* barBottom: Line Number of Start of Bottom Bar.
* barLeft: Pixel Number of End of Left Bar.
* barRight: Pixel Number of Start of Right Bar. */
hdmi_info.bits.bar_top = stream->timing.v_border_top;
hdmi_info.bits.bar_bottom = (stream->timing.v_total
- stream->timing.v_border_bottom + 1);
hdmi_info.bits.bar_left = stream->timing.h_border_left;
hdmi_info.bits.bar_right = (stream->timing.h_total
- stream->timing.h_border_right + 1);
/* check_sum - Calculate AFMT_AVI_INFO0 ~ AFMT_AVI_INFO3 */
check_sum = &hdmi_info.packet_raw_data.sb[0];
*check_sum = HDMI_INFOFRAME_TYPE_AVI + HDMI_AVI_INFOFRAME_SIZE + 2;
for (byte_index = 1; byte_index <= HDMI_AVI_INFOFRAME_SIZE; byte_index++)
*check_sum += hdmi_info.packet_raw_data.sb[byte_index];
/* one byte complement */
*check_sum = (uint8_t) (0x100 - *check_sum);
/* Store in hw_path_mode */
info_packet->hb0 = hdmi_info.packet_raw_data.hb0;
info_packet->hb1 = hdmi_info.packet_raw_data.hb1;
info_packet->hb2 = hdmi_info.packet_raw_data.hb2;
for (byte_index = 0; byte_index < sizeof(hdmi_info.packet_raw_data.sb); byte_index++)
info_packet->sb[byte_index] = hdmi_info.packet_raw_data.sb[byte_index];
info_packet->valid = true;
}
static void set_vendor_info_packet(
struct dc_info_packet *info_packet,
struct dc_stream_state *stream)
{
/* SPD info packet for FreeSync */
/* Check if Freesync is supported. Return if false. If true,
* set the corresponding bit in the info packet
*/
if (!stream->vsp_infopacket.valid)
return;
*info_packet = stream->vsp_infopacket;
}
static void set_spd_info_packet(
struct dc_info_packet *info_packet,
struct dc_stream_state *stream)
{
/* SPD info packet for FreeSync */
/* Check if Freesync is supported. Return if false. If true,
* set the corresponding bit in the info packet
*/
if (!stream->vrr_infopacket.valid)
return;
*info_packet = stream->vrr_infopacket;
}
static void set_dp_sdp_info_packet(
struct dc_info_packet *info_packet,
struct dc_stream_state *stream)
{
/* SPD info packet for custom sdp message */
/* Return if false. If true,
* set the corresponding bit in the info packet
*/
if (!stream->dpsdp_infopacket.valid)
return;
*info_packet = stream->dpsdp_infopacket;
}
static void set_hdr_static_info_packet(
struct dc_info_packet *info_packet,
struct dc_stream_state *stream)
{
/* HDR Static Metadata info packet for HDR10 */
if (!stream->hdr_static_metadata.valid ||
stream->use_dynamic_meta)
return;
*info_packet = stream->hdr_static_metadata;
}
static void set_vsc_info_packet(
struct dc_info_packet *info_packet,
struct dc_stream_state *stream)
{
if (!stream->vsc_infopacket.valid)
return;
*info_packet = stream->vsc_infopacket;
}
void dc_resource_state_destruct(struct dc_state *context)
{
int i, j;
for (i = 0; i < context->stream_count; i++) {
for (j = 0; j < context->stream_status[i].plane_count; j++)
dc_plane_state_release(
context->stream_status[i].plane_states[j]);
context->stream_status[i].plane_count = 0;
dc_stream_release(context->streams[i]);
context->streams[i] = NULL;
}
}
void dc_resource_state_copy_construct(
const struct dc_state *src_ctx,
struct dc_state *dst_ctx)
{
int i, j;
struct kref refcount = dst_ctx->refcount;
*dst_ctx = *src_ctx;
for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *cur_pipe = &dst_ctx->res_ctx.pipe_ctx[i];
if (cur_pipe->top_pipe)
cur_pipe->top_pipe = &dst_ctx->res_ctx.pipe_ctx[cur_pipe->top_pipe->pipe_idx];
if (cur_pipe->bottom_pipe)
cur_pipe->bottom_pipe = &dst_ctx->res_ctx.pipe_ctx[cur_pipe->bottom_pipe->pipe_idx];
}
for (i = 0; i < dst_ctx->stream_count; i++) {
dc_stream_retain(dst_ctx->streams[i]);
for (j = 0; j < dst_ctx->stream_status[i].plane_count; j++)
dc_plane_state_retain(
dst_ctx->stream_status[i].plane_states[j]);
}
/* context refcount should not be overridden */
dst_ctx->refcount = refcount;
}
struct clock_source *dc_resource_find_first_free_pll(
struct resource_context *res_ctx,
const struct resource_pool *pool)
{
int i;
for (i = 0; i < pool->clk_src_count; ++i) {
if (res_ctx->clock_source_ref_count[i] == 0)
return pool->clock_sources[i];
}
return NULL;
}
void resource_build_info_frame(struct pipe_ctx *pipe_ctx)
{
enum signal_type signal = SIGNAL_TYPE_NONE;
struct encoder_info_frame *info = &pipe_ctx->stream_res.encoder_info_frame;
/* default all packets to invalid */
info->avi.valid = false;
info->gamut.valid = false;
info->vendor.valid = false;
info->spd.valid = false;
info->hdrsmd.valid = false;
info->vsc.valid = false;
info->dpsdp.valid = false;
signal = pipe_ctx->stream->signal;
/* HDMi and DP have different info packets*/
if (dc_is_hdmi_signal(signal)) {
set_avi_info_frame(&info->avi, pipe_ctx);
set_vendor_info_packet(&info->vendor, pipe_ctx->stream);
set_spd_info_packet(&info->spd, pipe_ctx->stream);
set_hdr_static_info_packet(&info->hdrsmd, pipe_ctx->stream);
} else if (dc_is_dp_signal(signal)) {
set_vsc_info_packet(&info->vsc, pipe_ctx->stream);
set_spd_info_packet(&info->spd, pipe_ctx->stream);
set_hdr_static_info_packet(&info->hdrsmd, pipe_ctx->stream);
set_dp_sdp_info_packet(&info->dpsdp, pipe_ctx->stream);
}
patch_gamut_packet_checksum(&info->gamut);
}
enum dc_status resource_map_clock_resources(
const struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream)
{
/* acquire new resources */
const struct resource_pool *pool = dc->res_pool;
struct pipe_ctx *pipe_ctx = resource_get_head_pipe_for_stream(
&context->res_ctx, stream);
if (!pipe_ctx)
return DC_ERROR_UNEXPECTED;
if (dc_is_dp_signal(pipe_ctx->stream->signal)
|| pipe_ctx->stream->signal == SIGNAL_TYPE_VIRTUAL)
pipe_ctx->clock_source = pool->dp_clock_source;
else {
pipe_ctx->clock_source = NULL;
if (!dc->config.disable_disp_pll_sharing)
pipe_ctx->clock_source = resource_find_used_clk_src_for_sharing(
&context->res_ctx,
pipe_ctx);
if (pipe_ctx->clock_source == NULL)
pipe_ctx->clock_source =
dc_resource_find_first_free_pll(
&context->res_ctx,
pool);
}
if (pipe_ctx->clock_source == NULL)
return DC_NO_CLOCK_SOURCE_RESOURCE;
resource_reference_clock_source(
&context->res_ctx, pool,
pipe_ctx->clock_source);
return DC_OK;
}
/*
* Note: We need to disable output if clock sources change,
* since bios does optimization and doesn't apply if changing
* PHY when not already disabled.
*/
bool pipe_need_reprogram(
struct pipe_ctx *pipe_ctx_old,
struct pipe_ctx *pipe_ctx)
{
if (!pipe_ctx_old->stream)
return false;
if (pipe_ctx_old->stream->sink != pipe_ctx->stream->sink)
return true;
if (pipe_ctx_old->stream->signal != pipe_ctx->stream->signal)
return true;
if (pipe_ctx_old->stream_res.audio != pipe_ctx->stream_res.audio)
return true;
if (pipe_ctx_old->clock_source != pipe_ctx->clock_source
&& pipe_ctx_old->stream != pipe_ctx->stream)
return true;
if (pipe_ctx_old->stream_res.stream_enc != pipe_ctx->stream_res.stream_enc)
return true;
if (is_timing_changed(pipe_ctx_old->stream, pipe_ctx->stream))
return true;
if (is_hdr_static_meta_changed(pipe_ctx_old->stream, pipe_ctx->stream))
return true;
if (pipe_ctx_old->stream->dpms_off != pipe_ctx->stream->dpms_off)
return true;
if (is_vsc_info_packet_changed(pipe_ctx_old->stream, pipe_ctx->stream))
return true;
return false;
}
void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
struct bit_depth_reduction_params *fmt_bit_depth)
{
enum dc_dither_option option = stream->dither_option;
enum dc_pixel_encoding pixel_encoding =
stream->timing.pixel_encoding;
memset(fmt_bit_depth, 0, sizeof(*fmt_bit_depth));
if (option == DITHER_OPTION_DEFAULT) {
switch (stream->timing.display_color_depth) {
case COLOR_DEPTH_666:
option = DITHER_OPTION_SPATIAL6;
break;
case COLOR_DEPTH_888:
option = DITHER_OPTION_SPATIAL8;
break;
case COLOR_DEPTH_101010:
option = DITHER_OPTION_SPATIAL10;
break;
default:
option = DITHER_OPTION_DISABLE;
}
}
if (option == DITHER_OPTION_DISABLE)
return;
if (option == DITHER_OPTION_TRUN6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 0;
} else if (option == DITHER_OPTION_TRUN8 ||
option == DITHER_OPTION_TRUN8_SPATIAL6 ||
option == DITHER_OPTION_TRUN8_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 1;
} else if (option == DITHER_OPTION_TRUN10 ||
option == DITHER_OPTION_TRUN10_SPATIAL6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8 ||
option == DITHER_OPTION_TRUN10_FM8 ||
option == DITHER_OPTION_TRUN10_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
}
/* special case - Formatter can only reduce by 4 bits at most.
* When reducing from 12 to 6 bits,
* HW recommends we use trunc with round mode
* (if we did nothing, trunc to 10 bits would be used)
* note that any 12->10 bit reduction is ignored prior to DCE8,
* as the input was 10 bits.
*/
if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_FM6) {
fmt_bit_depth->flags.TRUNCATE_ENABLED = 1;
fmt_bit_depth->flags.TRUNCATE_DEPTH = 2;
fmt_bit_depth->flags.TRUNCATE_MODE = 1;
}
/* spatial dither
* note that spatial modes 1-3 are never used
*/
if (option == DITHER_OPTION_SPATIAL6_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_TRUN10_SPATIAL6 ||
option == DITHER_OPTION_TRUN8_SPATIAL6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 0;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
} else if (option == DITHER_OPTION_SPATIAL8_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL8 ||
option == DITHER_OPTION_SPATIAL8_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 1;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
} else if (option == DITHER_OPTION_SPATIAL10_FRAME_RANDOM ||
option == DITHER_OPTION_SPATIAL10 ||
option == DITHER_OPTION_SPATIAL10_FM8 ||
option == DITHER_OPTION_SPATIAL10_FM6) {
fmt_bit_depth->flags.SPATIAL_DITHER_ENABLED = 1;
fmt_bit_depth->flags.SPATIAL_DITHER_DEPTH = 2;
fmt_bit_depth->flags.HIGHPASS_RANDOM = 1;
fmt_bit_depth->flags.RGB_RANDOM =
(pixel_encoding == PIXEL_ENCODING_RGB) ? 1 : 0;
}
if (option == DITHER_OPTION_SPATIAL6 ||
option == DITHER_OPTION_SPATIAL8 ||
option == DITHER_OPTION_SPATIAL10) {
fmt_bit_depth->flags.FRAME_RANDOM = 0;
} else {
fmt_bit_depth->flags.FRAME_RANDOM = 1;
}
//////////////////////
//// temporal dither
//////////////////////
if (option == DITHER_OPTION_FM6 ||
option == DITHER_OPTION_SPATIAL8_FM6 ||
option == DITHER_OPTION_SPATIAL10_FM6 ||
option == DITHER_OPTION_TRUN10_FM6 ||
option == DITHER_OPTION_TRUN8_FM6 ||
option == DITHER_OPTION_TRUN10_SPATIAL8_FM6) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 0;
} else if (option == DITHER_OPTION_FM8 ||
option == DITHER_OPTION_SPATIAL10_FM8 ||
option == DITHER_OPTION_TRUN10_FM8) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 1;
} else if (option == DITHER_OPTION_FM10) {
fmt_bit_depth->flags.FRAME_MODULATION_ENABLED = 1;
fmt_bit_depth->flags.FRAME_MODULATION_DEPTH = 2;
}
fmt_bit_depth->pixel_encoding = pixel_encoding;
}
enum dc_status dc_validate_stream(struct dc *dc, struct dc_stream_state *stream)
{
struct dc *core_dc = dc;
struct dc_link *link = stream->link;
struct timing_generator *tg = core_dc->res_pool->timing_generators[0];
enum dc_status res = DC_OK;
calculate_phy_pix_clks(stream);
if (!tg->funcs->validate_timing(tg, &stream->timing))
res = DC_FAIL_CONTROLLER_VALIDATE;
if (res == DC_OK) {
if (!link->link_enc->funcs->validate_output_with_stream(
link->link_enc, stream))
res = DC_FAIL_ENC_VALIDATE;
}
/* TODO: validate audio ASIC caps, encoder */
if (res == DC_OK)
res = dc_link_validate_mode_timing(stream,
link,
&stream->timing);
return res;
}
enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state)
{
enum dc_status res = DC_OK;
/* TODO For now validates pixel format only */
if (dc->res_pool->funcs->validate_plane)
return dc->res_pool->funcs->validate_plane(plane_state, &dc->caps);
return res;
}
unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format)
{
switch (format) {
case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
return 8;
case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
return 12;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
return 16;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
return 32;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
return 64;
default:
ASSERT_CRITICAL(false);
return -1;
}
}
| gazoo74/linux | drivers/gpu/drm/amd/display/dc/core/dc_resource.c | C | gpl-2.0 | 82,175 |
<?php
/**
* @file
* Display Suite 4 column template.
*/
?>
<div class="<?php print $classes;?> clearfix">
<?php if (isset($title_suffix['contextual_links'])): ?>
<?php print render($title_suffix['contextual_links']); ?>
<?php endif; ?>
<?php if ($first): ?>
<div class="group-first<?php print $first_classes; ?>">
<?php print $first; ?>
</div>
<?php endif; ?>
<?php if ($second): ?>
<div class="group-second<?php print $second_classes; ?>">
<?php print $second; ?>
</div>
<?php endif; ?>
<?php if ($third): ?>
<div class="group-third<?php print $third_classes; ?>">
<?php print $third; ?>
</div>
<?php endif; ?>
<?php if ($fourth): ?>
<div class="group-fourth<?php print $fourth_classes; ?>">
<?php print $fourth; ?>
</div>
<?php endif; ?>
</div> | 404pnf/d7sites | sites/viaton.fltrp.com/modules/standard/ds/layouts/ds_4col/ds-4col.tpl.php | PHP | gpl-2.0 | 833 |
using SmartStore.Web.Framework.Mvc;
namespace SmartStore.Web.Models.Catalog
{
public partial class SearchBoxModel : ModelBase
{
public bool AutoCompleteEnabled { get; set; }
public bool ShowProductImagesInSearchAutoComplete { get; set; }
public int SearchTermMinimumLength { get; set; }
}
} | mohamedabdlaal/SmartStoreNET | src/Presentation/SmartStore.Web/Models/Catalog/SearchBoxModel.cs | C# | gpl-3.0 | 330 |
#ifndef QEMU_AUDIO_PT_INT_H
#define QEMU_AUDIO_PT_INT_H
#include <pthread.h>
struct audio_pt {
const char *drv;
pthread_t thread;
pthread_cond_t cond;
pthread_mutex_t mutex;
};
int audio_pt_init (struct audio_pt *, void *(*) (void *), void *,
const char *, const char *);
int audio_pt_fini (struct audio_pt *, const char *);
int audio_pt_lock (struct audio_pt *, const char *);
int audio_pt_unlock (struct audio_pt *, const char *);
int audio_pt_wait (struct audio_pt *, const char *);
int audio_pt_unlock_and_signal (struct audio_pt *, const char *);
int audio_pt_join (struct audio_pt *, void **, const char *);
#endif /* QEMU_AUDIO_PT_INT_H */
| SurajAnil/KernelVirtualMachine | qemu/audio/audio_pt_int.h | C | gpl-3.0 | 686 |
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import flt
from frappe import _
from frappe.model.document import Document
class CForm(Document):
def validate(self):
"""Validate invoice that c-form is applicable
and no other c-form is received for that"""
for d in self.get('invoice_details'):
if d.invoice_no:
inv = frappe.db.sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
if inv and inv[0][0] != 'Yes':
frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no)
elif inv and inv[0][1] and inv[0][1] != self.name:
frappe.throw("""Invoice %s is tagged in another C-form: %s.
If you want to change C-form no for this invoice,
please remove invoice no from the previous c-form and then try again""" %
(d.invoice_no, inv[0][1]))
elif not inv:
frappe.throw("Row %s: Invoice %s is invalid, it might be cancelled / does not exist. \
Please enter a valid Invoice" % d.idx, d.invoice_no)
def on_update(self):
""" Update C-Form No on invoices"""
self.set_total_invoiced_amount()
def on_submit(self):
self.set_cform_in_sales_invoices()
def before_cancel(self):
# remove cform reference
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null where c_form_no=%s""", self.name)
def set_cform_in_sales_invoices(self):
inv = [d.invoice_no for d in self.get('invoice_details')]
if inv:
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s where name in (%s)""" %
('%s', '%s', ', '.join(['%s'] * len(inv))), tuple([self.name, self.modified] + inv))
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
('%s', ', '.join(['%s']*len(inv)), '%s'), tuple([self.modified] + inv + [self.name]))
else:
frappe.throw(_("Please enter atleast 1 invoice in the table"))
def set_total_invoiced_amount(self):
total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
frappe.db.set(self, 'total_invoiced_amount', total)
def get_invoice_details(self, invoice_no):
""" Pull details from invoices for referrence """
if invoice_no:
inv = frappe.db.get_value("Sales Invoice", invoice_no,
["posting_date", "territory", "net_total", "grand_total"], as_dict=True)
return {
'invoice_date' : inv.posting_date,
'territory' : inv.territory,
'net_total' : inv.net_total,
'grand_total' : inv.grand_total
}
| suyashphadtare/sajil-final-erp | erpnext/erpnext/accounts/doctype/c_form/c_form.py | Python | agpl-3.0 | 2,694 |
# encoding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
float_or_none,
parse_age_limit,
)
class TvigleIE(InfoExtractor):
IE_NAME = 'tvigle'
IE_DESC = 'Интернет-телевидение Tvigle.ru'
_VALID_URL = r'http://(?:www\.)?tvigle\.ru/(?:[^/]+/)+(?P<id>[^/]+)/$'
_TESTS = [
{
'url': 'http://www.tvigle.ru/video/sokrat/',
'md5': '36514aed3657d4f70b4b2cef8eb520cd',
'info_dict': {
'id': '1848932',
'display_id': 'sokrat',
'ext': 'flv',
'title': 'Сократ',
'description': 'md5:a05bd01be310074d5833efc6743be95e',
'duration': 6586,
'age_limit': 0,
},
},
{
'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/',
'md5': 'd9012d7c7c598fe7a11d7fb46dc1f574',
'info_dict': {
'id': '5142516',
'ext': 'mp4',
'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
'description': 'md5:027f7dc872948f14c96d19b4178428a4',
'duration': 186.080,
'age_limit': 0,
},
},
]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
video_id = self._html_search_regex(
r'<li class="video-preview current_playing" id="(\d+)">', webpage, 'video id')
video_data = self._download_json(
'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
item = video_data['playlist']['items'][0]
title = item['title']
description = item['description']
thumbnail = item['thumbnail']
duration = float_or_none(item.get('durationMilliseconds'), 1000)
age_limit = parse_age_limit(item.get('ageRestrictions'))
formats = []
for vcodec, fmts in item['videos'].items():
for quality, video_url in fmts.items():
formats.append({
'url': video_url,
'format_id': '%s-%s' % (vcodec, quality),
'vcodec': vcodec,
'height': int(quality[:-1]),
'filesize': item['video_files_size'][vcodec][quality],
})
self._sort_formats(formats)
return {
'id': video_id,
'display_id': display_id,
'title': title,
'description': description,
'thumbnail': thumbnail,
'duration': duration,
'age_limit': age_limit,
'formats': formats,
}
| 0x7678/youtube-dl | youtube_dl/extractor/tvigle.py | Python | unlicense | 2,889 |
/*
* Copyright 2010-2012 Luca Molino (molino.luca--at--gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.orientechnologies.orient.object.enumerations;
import java.io.Serializable;
import java.util.Iterator;
import com.orientechnologies.orient.core.record.ORecord;
/**
* Lazy implementation of Iterator that load the records only when accessed. It keep also track of changes to the source record
* avoiding to call setDirty() by hand.
*
* @author Luca Molino (molino.luca--at--gmail.com)
*
*/
@SuppressWarnings({ "unchecked" })
public class OObjectEnumLazyIterator<TYPE extends Enum> implements Iterator<TYPE>, Serializable {
private static final long serialVersionUID = -4012483076050044405L;
private final ORecord sourceRecord;
private final Iterator<? extends Object> underlying;
private final Class<Enum> enumClass;
public OObjectEnumLazyIterator(final Class<Enum> iEnumClass, final ORecord iSourceRecord,
final Iterator<? extends Object> iIterator) {
this.sourceRecord = iSourceRecord;
this.underlying = iIterator;
this.enumClass = iEnumClass;
}
public TYPE next() {
final Object value = underlying.next();
if (value instanceof Number)
return (TYPE) enumClass.getEnumConstants()[((Number) value).intValue()];
else
return (TYPE) Enum.valueOf(enumClass, value.toString());
}
public boolean hasNext() {
return underlying.hasNext();
}
public void remove() {
underlying.remove();
if (sourceRecord != null)
sourceRecord.setDirty();
}
}
| cstamas/orientdb | object/src/main/java/com/orientechnologies/orient/object/enumerations/OObjectEnumLazyIterator.java | Java | apache-2.0 | 2,116 |
import $ from 'jquery'
import Popper from 'popper.js'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.1.3): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
const Tooltip = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'tooltip'
const VERSION = '4.1.3'
const DATA_KEY = 'bs.tooltip'
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const CLASS_PREFIX = 'bs-tooltip'
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
const DefaultType = {
animation : 'boolean',
template : 'string',
title : '(string|element|function)',
trigger : 'string',
delay : '(number|object)',
html : 'boolean',
selector : '(string|boolean)',
placement : '(string|function)',
offset : '(number|string)',
container : '(string|element|boolean)',
fallbackPlacement : '(string|array)',
boundary : '(string|element)'
}
const AttachmentMap = {
AUTO : 'auto',
TOP : 'top',
RIGHT : 'right',
BOTTOM : 'bottom',
LEFT : 'left'
}
const Default = {
animation : true,
template : '<div class="tooltip" role="tooltip">' +
'<div class="arrow"></div>' +
'<div class="tooltip-inner"></div></div>',
trigger : 'hover focus',
title : '',
delay : 0,
html : false,
selector : false,
placement : 'top',
offset : 0,
container : false,
fallbackPlacement : 'flip',
boundary : 'scrollParent'
}
const HoverState = {
SHOW : 'show',
OUT : 'out'
}
const Event = {
HIDE : `hide${EVENT_KEY}`,
HIDDEN : `hidden${EVENT_KEY}`,
SHOW : `show${EVENT_KEY}`,
SHOWN : `shown${EVENT_KEY}`,
INSERTED : `inserted${EVENT_KEY}`,
CLICK : `click${EVENT_KEY}`,
FOCUSIN : `focusin${EVENT_KEY}`,
FOCUSOUT : `focusout${EVENT_KEY}`,
MOUSEENTER : `mouseenter${EVENT_KEY}`,
MOUSELEAVE : `mouseleave${EVENT_KEY}`
}
const ClassName = {
FADE : 'fade',
SHOW : 'show'
}
const Selector = {
TOOLTIP : '.tooltip',
TOOLTIP_INNER : '.tooltip-inner',
ARROW : '.arrow'
}
const Trigger = {
HOVER : 'hover',
FOCUS : 'focus',
CLICK : 'click',
MANUAL : 'manual'
}
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Tooltip {
constructor(element, config) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new TypeError('Bootstrap tooltips require Popper.js (https://popper.js.org)')
}
// private
this._isEnabled = true
this._timeout = 0
this._hoverState = ''
this._activeTrigger = {}
this._popper = null
// Protected
this.element = element
this.config = this._getConfig(config)
this.tip = null
this._setListeners()
}
// Getters
static get VERSION() {
return VERSION
}
static get Default() {
return Default
}
static get NAME() {
return NAME
}
static get DATA_KEY() {
return DATA_KEY
}
static get Event() {
return Event
}
static get EVENT_KEY() {
return EVENT_KEY
}
static get DefaultType() {
return DefaultType
}
// Public
enable() {
this._isEnabled = true
}
disable() {
this._isEnabled = false
}
toggleEnabled() {
this._isEnabled = !this._isEnabled
}
toggle(event) {
if (!this._isEnabled) {
return
}
if (event) {
const dataKey = this.constructor.DATA_KEY
let context = $(event.currentTarget).data(dataKey)
if (!context) {
context = new this.constructor(
event.currentTarget,
this._getDelegateConfig()
)
$(event.currentTarget).data(dataKey, context)
}
context._activeTrigger.click = !context._activeTrigger.click
if (context._isWithActiveTrigger()) {
context._enter(null, context)
} else {
context._leave(null, context)
}
} else {
if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
this._leave(null, this)
return
}
this._enter(null, this)
}
}
dispose() {
clearTimeout(this._timeout)
$.removeData(this.element, this.constructor.DATA_KEY)
$(this.element).off(this.constructor.EVENT_KEY)
$(this.element).closest('.modal').off('hide.bs.modal')
if (this.tip) {
$(this.tip).remove()
}
this._isEnabled = null
this._timeout = null
this._hoverState = null
this._activeTrigger = null
if (this._popper !== null) {
this._popper.destroy()
}
this._popper = null
this.element = null
this.config = null
this.tip = null
}
show() {
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements')
}
const showEvent = $.Event(this.constructor.Event.SHOW)
if (this.isWithContent() && this._isEnabled) {
$(this.element).trigger(showEvent)
const isInTheDom = $.contains(
this.element.ownerDocument.documentElement,
this.element
)
if (showEvent.isDefaultPrevented() || !isInTheDom) {
return
}
const tip = this.getTipElement()
const tipId = Util.getUID(this.constructor.NAME)
tip.setAttribute('id', tipId)
this.element.setAttribute('aria-describedby', tipId)
this.setContent()
if (this.config.animation) {
$(tip).addClass(ClassName.FADE)
}
const placement = typeof this.config.placement === 'function'
? this.config.placement.call(this, tip, this.element)
: this.config.placement
const attachment = this._getAttachment(placement)
this.addAttachmentClass(attachment)
const container = this.config.container === false ? document.body : $(document).find(this.config.container)
$(tip).data(this.constructor.DATA_KEY, this)
if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
$(tip).appendTo(container)
}
$(this.element).trigger(this.constructor.Event.INSERTED)
this._popper = new Popper(this.element, tip, {
placement: attachment,
modifiers: {
offset: {
offset: this.config.offset
},
flip: {
behavior: this.config.fallbackPlacement
},
arrow: {
element: Selector.ARROW
},
preventOverflow: {
boundariesElement: this.config.boundary
}
},
onCreate: (data) => {
if (data.originalPlacement !== data.placement) {
this._handlePopperPlacementChange(data)
}
},
onUpdate: (data) => {
this._handlePopperPlacementChange(data)
}
})
$(tip).addClass(ClassName.SHOW)
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement) {
$(document.body).children().on('mouseover', null, $.noop)
}
const complete = () => {
if (this.config.animation) {
this._fixTransition()
}
const prevHoverState = this._hoverState
this._hoverState = null
$(this.element).trigger(this.constructor.Event.SHOWN)
if (prevHoverState === HoverState.OUT) {
this._leave(null, this)
}
}
if ($(this.tip).hasClass(ClassName.FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(this.tip)
$(this.tip)
.one(Util.TRANSITION_END, complete)
.emulateTransitionEnd(transitionDuration)
} else {
complete()
}
}
}
hide(callback) {
const tip = this.getTipElement()
const hideEvent = $.Event(this.constructor.Event.HIDE)
const complete = () => {
if (this._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip)
}
this._cleanTipClass()
this.element.removeAttribute('aria-describedby')
$(this.element).trigger(this.constructor.Event.HIDDEN)
if (this._popper !== null) {
this._popper.destroy()
}
if (callback) {
callback()
}
}
$(this.element).trigger(hideEvent)
if (hideEvent.isDefaultPrevented()) {
return
}
$(tip).removeClass(ClassName.SHOW)
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$(document.body).children().off('mouseover', null, $.noop)
}
this._activeTrigger[Trigger.CLICK] = false
this._activeTrigger[Trigger.FOCUS] = false
this._activeTrigger[Trigger.HOVER] = false
if ($(this.tip).hasClass(ClassName.FADE)) {
const transitionDuration = Util.getTransitionDurationFromElement(tip)
$(tip)
.one(Util.TRANSITION_END, complete)
.emulateTransitionEnd(transitionDuration)
} else {
complete()
}
this._hoverState = ''
}
update() {
if (this._popper !== null) {
this._popper.scheduleUpdate()
}
}
// Protected
isWithContent() {
return Boolean(this.getTitle())
}
addAttachmentClass(attachment) {
$(this.getTipElement()).addClass(`${CLASS_PREFIX}-${attachment}`)
}
getTipElement() {
this.tip = this.tip || $(this.config.template)[0]
return this.tip
}
setContent() {
const tip = this.getTipElement()
this.setElementContent($(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle())
$(tip).removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
}
setElementContent($element, content) {
const html = this.config.html
if (typeof content === 'object' && (content.nodeType || content.jquery)) {
// Content is a DOM node or a jQuery
if (html) {
if (!$(content).parent().is($element)) {
$element.empty().append(content)
}
} else {
$element.text($(content).text())
}
} else {
$element[html ? 'html' : 'text'](content)
}
}
getTitle() {
let title = this.element.getAttribute('data-original-title')
if (!title) {
title = typeof this.config.title === 'function'
? this.config.title.call(this.element)
: this.config.title
}
return title
}
// Private
_getAttachment(placement) {
return AttachmentMap[placement.toUpperCase()]
}
_setListeners() {
const triggers = this.config.trigger.split(' ')
triggers.forEach((trigger) => {
if (trigger === 'click') {
$(this.element).on(
this.constructor.Event.CLICK,
this.config.selector,
(event) => this.toggle(event)
)
} else if (trigger !== Trigger.MANUAL) {
const eventIn = trigger === Trigger.HOVER
? this.constructor.Event.MOUSEENTER
: this.constructor.Event.FOCUSIN
const eventOut = trigger === Trigger.HOVER
? this.constructor.Event.MOUSELEAVE
: this.constructor.Event.FOCUSOUT
$(this.element)
.on(
eventIn,
this.config.selector,
(event) => this._enter(event)
)
.on(
eventOut,
this.config.selector,
(event) => this._leave(event)
)
}
$(this.element).closest('.modal').on(
'hide.bs.modal',
() => this.hide()
)
})
if (this.config.selector) {
this.config = {
...this.config,
trigger: 'manual',
selector: ''
}
} else {
this._fixTitle()
}
}
_fixTitle() {
const titleType = typeof this.element.getAttribute('data-original-title')
if (this.element.getAttribute('title') ||
titleType !== 'string') {
this.element.setAttribute(
'data-original-title',
this.element.getAttribute('title') || ''
)
this.element.setAttribute('title', '')
}
}
_enter(event, context) {
const dataKey = this.constructor.DATA_KEY
context = context || $(event.currentTarget).data(dataKey)
if (!context) {
context = new this.constructor(
event.currentTarget,
this._getDelegateConfig()
)
$(event.currentTarget).data(dataKey, context)
}
if (event) {
context._activeTrigger[
event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER
] = true
}
if ($(context.getTipElement()).hasClass(ClassName.SHOW) ||
context._hoverState === HoverState.SHOW) {
context._hoverState = HoverState.SHOW
return
}
clearTimeout(context._timeout)
context._hoverState = HoverState.SHOW
if (!context.config.delay || !context.config.delay.show) {
context.show()
return
}
context._timeout = setTimeout(() => {
if (context._hoverState === HoverState.SHOW) {
context.show()
}
}, context.config.delay.show)
}
_leave(event, context) {
const dataKey = this.constructor.DATA_KEY
context = context || $(event.currentTarget).data(dataKey)
if (!context) {
context = new this.constructor(
event.currentTarget,
this._getDelegateConfig()
)
$(event.currentTarget).data(dataKey, context)
}
if (event) {
context._activeTrigger[
event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER
] = false
}
if (context._isWithActiveTrigger()) {
return
}
clearTimeout(context._timeout)
context._hoverState = HoverState.OUT
if (!context.config.delay || !context.config.delay.hide) {
context.hide()
return
}
context._timeout = setTimeout(() => {
if (context._hoverState === HoverState.OUT) {
context.hide()
}
}, context.config.delay.hide)
}
_isWithActiveTrigger() {
for (const trigger in this._activeTrigger) {
if (this._activeTrigger[trigger]) {
return true
}
}
return false
}
_getConfig(config) {
config = {
...this.constructor.Default,
...$(this.element).data(),
...typeof config === 'object' && config ? config : {}
}
if (typeof config.delay === 'number') {
config.delay = {
show: config.delay,
hide: config.delay
}
}
if (typeof config.title === 'number') {
config.title = config.title.toString()
}
if (typeof config.content === 'number') {
config.content = config.content.toString()
}
Util.typeCheckConfig(
NAME,
config,
this.constructor.DefaultType
)
return config
}
_getDelegateConfig() {
const config = {}
if (this.config) {
for (const key in this.config) {
if (this.constructor.Default[key] !== this.config[key]) {
config[key] = this.config[key]
}
}
}
return config
}
_cleanTipClass() {
const $tip = $(this.getTipElement())
const tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX)
if (tabClass !== null && tabClass.length) {
$tip.removeClass(tabClass.join(''))
}
}
_handlePopperPlacementChange(popperData) {
const popperInstance = popperData.instance
this.tip = popperInstance.popper
this._cleanTipClass()
this.addAttachmentClass(this._getAttachment(popperData.placement))
}
_fixTransition() {
const tip = this.getTipElement()
const initConfigAnimation = this.config.animation
if (tip.getAttribute('x-placement') !== null) {
return
}
$(tip).removeClass(ClassName.FADE)
this.config.animation = false
this.hide()
this.show()
this.config.animation = initConfigAnimation
}
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
const _config = typeof config === 'object' && config
if (!data && /dispose|hide/.test(config)) {
return
}
if (!data) {
data = new Tooltip(this, _config)
$(this).data(DATA_KEY, data)
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
})
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Tooltip._jQueryInterface
$.fn[NAME].Constructor = Tooltip
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Tooltip._jQueryInterface
}
return Tooltip
})($, Popper)
export default Tooltip
| google/gvisor-website | themes/docsy/assets/vendor/bootstrap/js/src/tooltip.js | JavaScript | apache-2.0 | 18,796 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.tinkerpop.gremlin.structure.util.wrapped;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public interface WrappedProperty<P> {
public P getBaseProperty();
}
| gdelafosse/incubator-tinkerpop | gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/wrapped/WrappedProperty.java | Java | apache-2.0 | 1,007 |
extern crate messengerdep;
pub struct Messenger {
message: String,
}
impl Messenger {
pub fn new(message: &str) -> Messenger {
Messenger { message: message.to_string(), }
}
pub fn deliver(&self) {
println!("I have a message to deliver to you: {}", &self.message);
messengerdep::handler();
}
}
| marcinkwiatkowski/buck | test/com/facebook/buck/rust/testdata/binary_with_library_with_dep/messenger/lib.rs | Rust | apache-2.0 | 340 |
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package poddisruptionbudget
import (
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/policy"
"k8s.io/kubernetes/pkg/util/intstr"
)
func TestPodDisruptionBudgetStrategy(t *testing.T) {
ctx := api.NewDefaultContext()
if !Strategy.NamespaceScoped() {
t.Errorf("PodDisruptionBudget must be namespace scoped")
}
if Strategy.AllowCreateOnUpdate() {
t.Errorf("PodDisruptionBudget should not allow create on update")
}
validSelector := map[string]string{"a": "b"}
pdb := &policy.PodDisruptionBudget{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: policy.PodDisruptionBudgetSpec{
MinAvailable: intstr.FromInt(3),
Selector: &unversioned.LabelSelector{MatchLabels: validSelector},
},
}
Strategy.PrepareForCreate(ctx, pdb)
errs := Strategy.Validate(ctx, pdb)
if len(errs) != 0 {
t.Errorf("Unexpected error validating %v", errs)
}
newPdb := &policy.PodDisruptionBudget{
ObjectMeta: api.ObjectMeta{Name: pdb.Name, Namespace: pdb.Namespace},
Spec: pdb.Spec,
Status: policy.PodDisruptionBudgetStatus{
PodDisruptionsAllowed: 1,
CurrentHealthy: 3,
DesiredHealthy: 3,
ExpectedPods: 3,
},
}
// Nothing in Spec changes: OK
Strategy.PrepareForUpdate(ctx, newPdb, pdb)
errs = Strategy.ValidateUpdate(ctx, newPdb, pdb)
if len(errs) != 0 {
t.Errorf("Unexpected error updating PodDisruptionBudget.")
}
// Changing the selector? No.
newPdb.Spec.Selector = &unversioned.LabelSelector{MatchLabels: map[string]string{"a": "bar"}}
Strategy.PrepareForUpdate(ctx, newPdb, pdb)
errs = Strategy.ValidateUpdate(ctx, newPdb, pdb)
if len(errs) == 0 {
t.Errorf("Expected a validation error since updates are disallowed on poddisruptionbudgets.")
}
newPdb.Spec.Selector = pdb.Spec.Selector
// Changing MinAvailable? Also no.
newPdb.Spec.MinAvailable = intstr.FromString("28%")
Strategy.PrepareForUpdate(ctx, newPdb, pdb)
errs = Strategy.ValidateUpdate(ctx, newPdb, pdb)
if len(errs) == 0 {
t.Errorf("Expected a validation error since updates are disallowed on poddisruptionbudgets.")
}
}
func TestPodDisruptionBudgetStatusStrategy(t *testing.T) {
ctx := api.NewDefaultContext()
if !StatusStrategy.NamespaceScoped() {
t.Errorf("PodDisruptionBudgetStatus must be namespace scoped")
}
if StatusStrategy.AllowCreateOnUpdate() {
t.Errorf("PodDisruptionBudgetStatus should not allow create on update")
}
validSelector := map[string]string{"a": "b"}
oldPdb := &policy.PodDisruptionBudget{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault, ResourceVersion: "10"},
Spec: policy.PodDisruptionBudgetSpec{
Selector: &unversioned.LabelSelector{MatchLabels: validSelector},
MinAvailable: intstr.FromInt(3),
},
Status: policy.PodDisruptionBudgetStatus{
PodDisruptionsAllowed: 1,
CurrentHealthy: 3,
DesiredHealthy: 3,
ExpectedPods: 3,
},
}
newPdb := &policy.PodDisruptionBudget{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault, ResourceVersion: "9"},
Spec: policy.PodDisruptionBudgetSpec{
Selector: &unversioned.LabelSelector{MatchLabels: validSelector},
MinAvailable: intstr.FromInt(2),
},
Status: policy.PodDisruptionBudgetStatus{
PodDisruptionsAllowed: 0,
CurrentHealthy: 2,
DesiredHealthy: 3,
ExpectedPods: 3,
},
}
StatusStrategy.PrepareForUpdate(ctx, newPdb, oldPdb)
if newPdb.Status.CurrentHealthy != 2 {
t.Errorf("PodDisruptionBudget status updates should allow change of CurrentHealthy: %v", newPdb.Status.CurrentHealthy)
}
if newPdb.Spec.MinAvailable.IntValue() != 3 {
t.Errorf("PodDisruptionBudget status updates should not clobber spec: %v", newPdb.Spec)
}
errs := StatusStrategy.ValidateUpdate(ctx, newPdb, oldPdb)
if len(errs) != 0 {
t.Errorf("Unexpected error %v", errs)
}
}
| rawlingsj/gofabric8 | vendor/k8s.io/kubernetes/pkg/registry/policy/poddisruptionbudget/strategy_test.go | GO | apache-2.0 | 4,506 |
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SUBPROCESS
#include <grpc/support/subprocess.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
struct gpr_subprocess {
int pid;
bool joined;
};
const char* gpr_subprocess_binary_extension() { return ""; }
gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
gpr_subprocess* r;
int pid;
char** exec_args;
pid = fork();
if (pid == -1) {
return nullptr;
} else if (pid == 0) {
exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*));
memcpy(exec_args, argv, (size_t)argc * sizeof(char*));
exec_args[argc] = nullptr;
execv(exec_args[0], exec_args);
/* if we reach here, an error has occurred */
gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno));
_exit(1);
return nullptr;
} else {
r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess));
r->pid = pid;
return r;
}
}
void gpr_subprocess_destroy(gpr_subprocess* p) {
if (!p->joined) {
kill(p->pid, SIGKILL);
gpr_subprocess_join(p);
}
gpr_free(p);
}
int gpr_subprocess_join(gpr_subprocess* p) {
int status;
retry:
if (waitpid(p->pid, &status, 0) == -1) {
if (errno == EINTR) {
goto retry;
}
gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid,
strerror(errno));
return -1;
}
p->joined = true;
return status;
}
void gpr_subprocess_interrupt(gpr_subprocess* p) {
if (!p->joined) {
kill(p->pid, SIGINT);
}
}
#endif /* GPR_POSIX_SUBPROCESS */
| daniel-j-born/grpc | src/core/lib/support/subprocess_posix.cc | C++ | apache-2.0 | 2,367 |
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
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)
==============================================================================*/
#include <vector>
#include <string>
#include <map>
#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace std;
int
main()
{
{
int x = 123;
BOOST_TEST((&arg1)(x) == &x);
BOOST_TEST((*&arg1)(x) == 123);
int y = 968;
(ref(x) = arg1)(y);
BOOST_TEST(x == y);
(arg1 = 456)(x);
BOOST_TEST(x == 456);
int& r = (arg1 = 456)(x); // must be an lvalue
BOOST_TEST(&r == &x);
int c[] = { 1, 2, 3, 4, 5 };
BOOST_TEST((arg1[3])(c) == 4);
int& r2 = (arg1[3])(c); // must be an lvalue
BOOST_TEST(&r2 == &c[3]);
vector<string> v;
v.push_back("a");
v.push_back("b");
v.push_back("c");
v.push_back("d");
BOOST_TEST((arg1[3])(v) == "d");
map<string, int> m;
(arg1["Kimpo"] = arg2)(m, x);
BOOST_TEST(m["Kimpo"] == x);
}
return boost::report_errors();
}
| NixaSoftware/CVis | venv/bin/libs/spirit/phoenix/test/operator/self_tests.cpp | C++ | apache-2.0 | 1,480 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sling.scripting.freemarker.it.app;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import static org.apache.sling.models.annotations.injectorspecific.InjectionStrategy.OPTIONAL;
@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
public class Page {
@SlingObject
protected Resource resource;
@SlingObject(injectionStrategy = OPTIONAL)
protected SlingHttpServletRequest request;
public Page() {
}
public String getName() {
return resource.getName();
}
public String getPath() {
return resource.getPath();
}
public String getTitle() {
return resource.getValueMap().get("title", String.class);
}
}
| Nimco/sling | contrib/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/it/app/Page.java | Java | apache-2.0 | 1,696 |
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
Oak - The big picture
--------------------------------------------------------------------------------
TODO: Explain concepts: MVCC, Oak modules and plugins, key APIs, ...

## Main Concepts
* [Node State Model](nodestate.html)
* [Transactional Model](transactional-model.html)
## The APIs
* [JCR](http://www.day.com/specs/jcr/2.0/index.html)
* [Oak API](../oak_api/overview.html)
* [NodeStore API](../nodestore/overview.html)
## Readmes
* [Oak](https://github.com/apache/jackrabbit-oak/blob/trunk/README.md)
* [Oak core](https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/README.md)
* [Oak run](https://github.com/apache/jackrabbit-oak/blob/trunk/oak-run/README.md)
| AndreasAbdi/jackrabbit-oak | oak-doc/src/site/markdown/architecture/overview.md | Markdown | apache-2.0 | 1,531 |
// Copyright (c) 2014 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "xwalk/runtime/browser/runtime_platform_util.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
#include "url/gurl.h"
namespace platform_util {
namespace {
// The system default web browser path.
// In some Tizen releases, there exists a system browser called 'MiniBrowser',
// which we can use to open an external link from a web app.
const char kWebBrowserPath[] = "/usr/bin/MiniBrowser";
typedef base::Callback<void (const GURL&, dbus::MessageWriter*)> ParamsWriter;
struct ProtocolDBusServiceInfo {
const char* scheme;
const char* service;
const char* interface;
const char* method;
const char* object_path;
ParamsWriter params_writer;
};
void ParseAndWriteTelParams(const GURL& url,
dbus::MessageWriter* dbus_writer) {
// Phone number
dbus_writer->AppendString(url.GetContent());
// Always don't auto dial
dbus_writer->AppendBool(false);
}
void ParseAndWriteMailParams(const GURL& uri,
dbus::MessageWriter* dbus_writer) {
}
void ParseAndWriteSmsParams(const GURL& url,
dbus::MessageWriter* dbus_writer) {
// Support the case sms:12345678?body=Hello
std::string query = url.query();
std::string content = url.GetContent();
// Extract the phone number
const std::string number = content.substr(0, content.find(query) - 1);
// Remove "body="
const std::string body = query.erase(0, 5);
dbus_writer->AppendString(number);
dbus_writer->AppendString(body);
// Always don't auto dial
dbus_writer->AppendBool(false);
}
const ProtocolDBusServiceInfo protocol_dbus_services[] = {
{"tel", "org.tizen.dialer", "org.tizen.dialer.Control", "Dial", "/",
base::Bind(ParseAndWriteTelParams)},
{"mailto", "org.tizen.email_service", "org.tizen.email_service", "Launch",
"/org/tizen/email_service",
base::Bind(ParseAndWriteMailParams)},
{"sms", "org.tizen.dialer", "org.tizen.dialer.Control", "Send", "/",
base::Bind(ParseAndWriteSmsParams)},
};
bool CallDbusService(const ProtocolDBusServiceInfo& info,
const GURL& url) {
const dbus::ObjectPath dbus_path(info.object_path);
dbus::Bus::Options options;
scoped_refptr<dbus::Bus> bus(new dbus::Bus(options));
dbus::ObjectProxy* app_proxy =
bus->GetObjectProxy(info.service, dbus_path);
if (!app_proxy) {
VLOG(1) << "app_proxy failed.";
return false;
}
dbus::MethodCall method_call(info.interface, info.method);
dbus::MessageWriter writer(&method_call);
info.params_writer.Run(url, &writer);
app_proxy->CallMethod(&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
dbus::ObjectProxy::EmptyResponseCallback());
return true;
}
} // namespace
bool HandleExternalProtocol(const GURL& url) {
for (size_t i = 0; i < arraysize(protocol_dbus_services); ++i) {
const ProtocolDBusServiceInfo& info = protocol_dbus_services[i];
if (url.SchemeIs(info.scheme)) {
return CallDbusService(info, url);
}
}
return false;
}
void OpenExternal(const GURL& url) {
if (url.SchemeIsHTTPOrHTTPS()) {
LOG(INFO) << "Open in WebBrowser.";
std::vector<std::string> argv;
if (base::PathExists(base::FilePath(kWebBrowserPath)))
argv.push_back(kWebBrowserPath);
else
argv.push_back("xwalk-launcher");
argv.push_back(url.spec());
base::Process process = base::LaunchProcess(argv, base::LaunchOptions());
if (process.IsValid())
base::EnsureProcessGetsReaped(process.Handle());
} else if (!HandleExternalProtocol(url)) {
LOG(ERROR) << "Can not handle url: " << url.spec();
}
}
} // namespace platform_util
| pk-sam/crosswalk | runtime/browser/runtime_platform_util_tizen.cc | C++ | bsd-3-clause | 4,022 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/codec/audio_encoder_verbatim.h"
#include "base/logging.h"
#include "remoting/proto/audio.pb.h"
namespace remoting {
AudioEncoderVerbatim::AudioEncoderVerbatim() {}
AudioEncoderVerbatim::~AudioEncoderVerbatim() {}
scoped_ptr<AudioPacket> AudioEncoderVerbatim::Encode(
scoped_ptr<AudioPacket> packet) {
DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
DCHECK_EQ(1, packet->data_size());
DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
DCHECK_NE(AudioPacket::BYTES_PER_SAMPLE_INVALID, packet->bytes_per_sample());
DCHECK_NE(AudioPacket::CHANNELS_INVALID, packet->channels());
return packet.Pass();
}
int AudioEncoderVerbatim::GetBitrate() {
return AudioPacket::SAMPLING_RATE_48000 * AudioPacket::BYTES_PER_SAMPLE_2 *
AudioPacket::CHANNELS_STEREO * 8;
}
} // namespace remoting
| guorendong/iridium-browser-ubuntu | remoting/codec/audio_encoder_verbatim.cc | C++ | bsd-3-clause | 1,031 |
/* dget10.f -- translated by f2c (version 20061008).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
#include "blaswrap.h"
/* Table of constant values */
static integer c__1 = 1;
static doublereal c_b7 = -1.;
/* Subroutine */ int dget10_(integer *m, integer *n, doublereal *a, integer *
lda, doublereal *b, integer *ldb, doublereal *work, doublereal *
result)
{
/* System generated locals */
integer a_dim1, a_offset, b_dim1, b_offset, i__1;
doublereal d__1, d__2;
/* Local variables */
integer j;
doublereal eps, unfl;
extern doublereal dasum_(integer *, doublereal *, integer *);
doublereal anorm;
extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
doublereal *, integer *), daxpy_(integer *, doublereal *,
doublereal *, integer *, doublereal *, integer *);
doublereal wnorm;
extern doublereal dlamch_(char *), dlange_(char *, integer *,
integer *, doublereal *, integer *, doublereal *);
/* -- LAPACK test routine (version 3.1) -- */
/* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/* November 2006 */
/* .. Scalar Arguments .. */
/* .. */
/* .. Array Arguments .. */
/* .. */
/* Purpose */
/* ======= */
/* DGET10 compares two matrices A and B and computes the ratio */
/* RESULT = norm( A - B ) / ( norm(A) * M * EPS ) */
/* Arguments */
/* ========= */
/* M (input) INTEGER */
/* The number of rows of the matrices A and B. */
/* N (input) INTEGER */
/* The number of columns of the matrices A and B. */
/* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
/* The m by n matrix A. */
/* LDA (input) INTEGER */
/* The leading dimension of the array A. LDA >= max(1,M). */
/* B (input) DOUBLE PRECISION array, dimension (LDB,N) */
/* The m by n matrix B. */
/* LDB (input) INTEGER */
/* The leading dimension of the array B. LDB >= max(1,M). */
/* WORK (workspace) DOUBLE PRECISION array, dimension (M) */
/* RESULT (output) DOUBLE PRECISION */
/* RESULT = norm( A - B ) / ( norm(A) * M * EPS ) */
/* ===================================================================== */
/* .. Parameters .. */
/* .. */
/* .. Local Scalars .. */
/* .. */
/* .. External Functions .. */
/* .. */
/* .. External Subroutines .. */
/* .. */
/* .. Intrinsic Functions .. */
/* .. */
/* .. Executable Statements .. */
/* Quick return if possible */
/* Parameter adjustments */
a_dim1 = *lda;
a_offset = 1 + a_dim1;
a -= a_offset;
b_dim1 = *ldb;
b_offset = 1 + b_dim1;
b -= b_offset;
--work;
/* Function Body */
if (*m <= 0 || *n <= 0) {
*result = 0.;
return 0;
}
unfl = dlamch_("Safe minimum");
eps = dlamch_("Precision");
wnorm = 0.;
i__1 = *n;
for (j = 1; j <= i__1; ++j) {
dcopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
daxpy_(m, &c_b7, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
/* Computing MAX */
d__1 = wnorm, d__2 = dasum_(n, &work[1], &c__1);
wnorm = max(d__1,d__2);
/* L10: */
}
/* Computing MAX */
d__1 = dlange_("1", m, n, &a[a_offset], lda, &work[1]);
anorm = max(d__1,unfl);
if (anorm > wnorm) {
*result = wnorm / anorm / (*m * eps);
} else {
if (anorm < 1.) {
/* Computing MIN */
d__1 = wnorm, d__2 = *m * anorm;
*result = min(d__1,d__2) / anorm / (*m * eps);
} else {
/* Computing MIN */
d__1 = wnorm / anorm, d__2 = (doublereal) (*m);
*result = min(d__1,d__2) / (*m * eps);
}
}
return 0;
/* End of DGET10 */
} /* dget10_ */
| juanjosegarciaripoll/cblapack | test/EIG/dget10.c | C | bsd-3-clause | 4,069 |
/****************************************************************************
* include/sys/types.h
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_SYS_TYPES_H
#define __INCLUDE_SYS_TYPES_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Alternative values for type bool (for historic reasons) */
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
/* NULL is usually defined in stddef.h (which includes this file) */
#ifndef NULL
/* SDCC is sensitive to NULL pointer type conversions, and C++ defines
* NULL as zero
*/
# if defined(SDCC) || defined(__cplusplus)
# define NULL (0)
# else
# define NULL ((void*)0)
# endif
#endif
/* POSIX-like OS return values: */
#if !defined(__cplusplus)
# undef ERROR
# define ERROR -1
#endif
#undef OK
#define OK 0
/* HPUX-like MIN/MAX value */
#define PRIOR_RR_MIN 0
#define PRIOR_RR_MAX 255
#define PRIOR_FIFO_MIN 0
#define PRIOR_FIFO_MAX 255
#define PRIOR_OTHER_MIN 0
#define PRIOR_OTHER_MAX 255
/* Scheduling Priorities. NOTE: Only the idle task can take
* the true minimum priority. */
#define SCHED_PRIORITY_MAX 255
#define SCHED_PRIORITY_DEFAULT 100
#define SCHED_PRIORITY_MIN 1
#define SCHED_PRIORITY_IDLE 0
/****************************************************************************
* Type Declarations
****************************************************************************/
#ifndef __ASSEMBLY__
/* Floating point types */
typedef float float32;
#ifndef CONFIG_HAVE_DOUBLE
typedef float double_t;
typedef float float64;
#else
typedef double double_t;
typedef double float64;
#endif
/* Misc. scalar types */
/* mode_t is an integer type used for file attributes. mode_t needs
* to be at least 16-bits but, in fact must be sizeof(int) because it is
* pased via varargs.
*/
typedef unsigned int mode_t;
/* size_t is used for sizes of memory objects.
* ssize_t is used for a count of bytes or an error indication.
*/
#ifdef CONFIG_SMALL_MEMORY
typedef uint16_t size_t;
typedef int16_t ssize_t;
#else
typedef uint32_t size_t;
typedef int32_t ssize_t;
#endif
/* uid_t is used for user IDs
* gid_t is used for group IDs.
*/
typedef int16_t uid_t;
typedef int16_t gid_t;
/* dev_t is used for device IDs */
typedef uint16_t dev_t;
/* ino_t is used for file serial numbers */
typedef uint16_t ino_t;
/* pid_t is used for process IDs and process group IDs. It must be signed because
* negative PID values are used to represent invalid PIDs.
*/
typedef int16_t pid_t;
/* id_t is a general identifier that can be used to contain at least a pid_t,
* uid_t, or gid_t.
*/
typedef int16_t id_t;
/* Signed integral type of the result of subtracting two pointers */
typedef intptr_t ptrdiff_t;
/* Wide, 16-bit character types. wchar_t is a built-in type in C++ and
* its declaration here may cause compilation errors on some compilers
* if -DCONFIG_WCHAR_BUILTIN is not included in the CXXFLAGS.
*/
#ifndef CONFIG_WCHAR_BUILTIN
typedef uint16_t wchar_t;
#endif
/* blkcnt_t and off_t are signed integer types.
*
* blkcnt_t is used for file block counts.
* off_t is used for file offsets and sizes.
* fpos_t is used for file positions.
*
* Hence, all should be independent of processor architecture.
*/
typedef uint32_t blkcnt_t;
typedef int32_t off_t;
typedef off_t fpos_t;
/* Large file versions */
#ifdef CONFIG_HAVE_LONG_LONG
typedef int64_t off64_t;
typedef int64_t fpos64_t;
#endif
/* blksize_t is a signed integer value used for file block sizes */
typedef int16_t blksize_t;
/* Network related */
typedef unsigned int socklen_t;
typedef uint16_t sa_family_t;
/* Used for system times in clock ticks */
typedef uint32_t clock_t;
/* The type useconds_t shall be an unsigned integer type capable of storing
* values at least in the range [0, 1000000]. The type suseconds_t shall be
* a signed integer type capable of storing values at least in the range
* [-1, 1000000].
*/
typedef uint32_t useconds_t;
typedef int32_t suseconds_t;
/* Task entry point */
typedef int (*main_t)(int argc, char *argv[]);
#endif
/****************************************************************************
* Global Function Prototypes
****************************************************************************/
#endif /* __INCLUDE_SYS_TYPES_H */
| gcds/project_xxx | nuttx/include/sys/types.h | C | bsd-3-clause | 6,548 |
package app.config;
import net.javapla.jawn.core.ApplicationConfig;
import net.javapla.jawn.core.api.ApplicationBootstrap;
import app.db.DbModule;
public class Bootstrap implements ApplicationBootstrap {
@Override
public void bootstrap(ApplicationConfig config) {
config.registerModules(new DbModule());
}
@Override
public void destroy() {}
}
| grob/FrameworkBenchmarks | frameworks/Java/jawn/src/main/java/app/config/Bootstrap.java | Java | bsd-3-clause | 376 |
/*
* Copyright (c) 2008, 2011, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 java.lang.invoke;
import java.lang.reflect.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
/**
* These adapters apply arbitrary conversions to arguments
* on the way to a ultimate target.
* For simplicity, these are all generically typed.
* @author jrose
*/
class FilterGeneric {
// type for the incoming call (will be generic)
private final MethodType entryType;
// prototype adapters (clone and customize for each new target & conversion!)
private final Adapter[] adapters;
/** Compute and cache information common to all filtering adapters
* with the given generic type
*/
FilterGeneric(MethodType entryType) {
this.entryType = entryType;
int tableSize = Kind.LIMIT.invokerIndex(1 + entryType.parameterCount());
this.adapters = new Adapter[tableSize];
}
Adapter getAdapter(Kind kind, int pos) {
int index = kind.invokerIndex(pos);
Adapter ad = adapters[index];
if (ad != null) return ad;
ad = findAdapter(entryType, kind, pos);
if (ad == null)
ad = buildAdapterFromBytecodes(entryType, kind, pos);
adapters[index] = ad;
return ad;
}
static {
assert(MethodHandleNatives.workaroundWithoutRicochetFrames()); // this class is deprecated
}
Adapter makeInstance(Kind kind, int pos, MethodHandle filter, MethodHandle target) {
Adapter ad = getAdapter(kind, pos);
return ad.makeInstance(ad.prototypeEntryPoint(), filter, target);
}
/** Build an adapter of the given generic type, which invokes filter
* on the selected incoming argument before passing it to the target.
* @param pos the argument to filter
* @param filter the function to call on the argument
* @param target the target to call with the modified argument list
* @return an adapter method handle
*/
public static MethodHandle makeArgumentFilter(int pos, MethodHandle filter, MethodHandle target) {
return make(Kind.value, pos, filter, target);
}
/** Build an adapter of the given generic type, which invokes a combiner
* on a selected group of leading arguments.
* The result of the combiner is prepended before all those arguments.
* @param combiner the function to call on the selected leading arguments
* @param target the target to call with the modified argument list
* @return an adapter method handle
*/
public static MethodHandle makeArgumentFolder(MethodHandle combiner, MethodHandle target) {
int num = combiner.type().parameterCount();
return make(Kind.fold, num, combiner, target);
}
/** Build an adapter of the given generic type, which invokes a filter
* on the incoming arguments, reified as a group.
* The argument may be modified (by side effects in the filter).
* The arguments, possibly modified, are passed on to the target.
* @param filter the function to call on the arguments
* @param target the target to call with the possibly-modified argument list
* @return an adapter method handle
*/
public static MethodHandle makeFlyby(MethodHandle filter, MethodHandle target) {
return make(Kind.flyby, 0, filter, target);
}
/** Build an adapter of the given generic type, which invokes a collector
* on the selected incoming argument and all following arguments.
* The result of the collector replaces all those arguments.
* @param collector the function to call on the selected trailing arguments
* @param target the target to call with the modified argument list
* @return an adapter method handle
*/
public static MethodHandle makeArgumentCollector(MethodHandle collector, MethodHandle target) {
int pos = target.type().parameterCount() - 1;
return make(Kind.collect, pos, collector, target);
}
static MethodHandle make(Kind kind, int pos, MethodHandle filter, MethodHandle target) {
FilterGeneric fgen = of(kind, pos, filter.type(), target.type());
return fgen.makeInstance(kind, pos, filter, target);
}
/** Return the adapter information for this target and filter type. */
static FilterGeneric of(Kind kind, int pos, MethodType filterType, MethodType targetType) {
MethodType entryType = entryType(kind, pos, filterType, targetType);
if (entryType.generic() != entryType)
throw newIllegalArgumentException("must be generic: "+entryType);
MethodTypeForm form = entryType.form();
FilterGeneric filterGen = form.filterGeneric;
if (filterGen == null)
form.filterGeneric = filterGen = new FilterGeneric(entryType);
return filterGen;
}
public String toString() {
return "FilterGeneric/"+entryType;
}
static MethodType targetType(MethodType entryType, Kind kind, int pos, MethodType filterType) {
MethodType type = entryType;
switch (kind) {
case value:
case flyby:
break; // no change
case fold:
type = type.insertParameterTypes(0, filterType.returnType());
break;
case collect:
type = type.dropParameterTypes(pos, type.parameterCount());
type = type.insertParameterTypes(pos, filterType.returnType());
break;
default:
throw new InternalError();
}
return type;
}
static MethodType entryType(Kind kind, int pos, MethodType filterType, MethodType targetType) {
MethodType type = targetType;
switch (kind) {
case value:
case flyby:
break; // no change
case fold:
type = type.dropParameterTypes(0, 1);
break;
case collect:
type = type.dropParameterTypes(pos, pos+1);
type = type.insertParameterTypes(pos, filterType.parameterList());
break;
default:
throw new InternalError();
}
return type;
}
/* Create an adapter that handles spreading calls for the given type. */
static Adapter findAdapter(MethodType entryType, Kind kind, int pos) {
int argc = entryType.parameterCount();
String cname0 = "F"+argc;
String cname1 = "F"+argc+kind.key;
String[] cnames = { cname0, cname1 };
String iname = kind.invokerName(pos);
// e.g., F5; invoke_C3
for (String cname : cnames) {
Class<? extends Adapter> acls = Adapter.findSubClass(cname);
if (acls == null) continue;
// see if it has the required invoke method
MethodHandle entryPoint = null;
try {
entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
} catch (ReflectiveOperationException ex) {
}
if (entryPoint == null) continue;
Constructor<? extends Adapter> ctor = null;
try {
ctor = acls.getDeclaredConstructor(MethodHandle.class);
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) {
}
if (ctor == null) continue;
try {
// Produce an instance configured as a prototype.
return ctor.newInstance(entryPoint);
} catch (IllegalArgumentException ex) {
} catch (InvocationTargetException wex) {
Throwable ex = wex.getTargetException();
if (ex instanceof Error) throw (Error)ex;
if (ex instanceof RuntimeException) throw (RuntimeException)ex;
} catch (InstantiationException ex) {
} catch (IllegalAccessException ex) {
}
}
return null;
}
static Adapter buildAdapterFromBytecodes(MethodType entryType, Kind kind, int pos) {
throw new UnsupportedOperationException("NYI");
}
/**
* This adapter takes some untyped arguments, and returns an untyped result.
* Internally, it applies the invoker to the target, which causes the
* objects to be unboxed; the result is a raw type in L/I/J/F/D.
* This result is passed to convert, which is responsible for
* converting the raw result into a boxed object.
* The invoker is kept separate from the target because it can be
* generated once per type erasure family, and reused across adapters.
*/
static abstract class Adapter extends BoundMethodHandle {
protected final MethodHandle filter; // transforms one or more arguments
protected final MethodHandle target; // ultimate target
@Override
String debugString() {
return addTypeString(target, this);
}
protected boolean isPrototype() { return target == null; }
protected Adapter(MethodHandle entryPoint) {
this(entryPoint, entryPoint, null);
assert(isPrototype());
}
protected MethodHandle prototypeEntryPoint() {
if (!isPrototype()) throw new InternalError();
return filter;
}
protected Adapter(MethodHandle entryPoint,
MethodHandle filter, MethodHandle target) {
super(entryPoint);
this.filter = filter;
this.target = target;
}
/** Make a copy of self, with new fields. */
protected abstract Adapter makeInstance(MethodHandle entryPoint,
MethodHandle filter, MethodHandle target);
// { return new ThisType(entryPoint, filter, target); }
static private final String CLASS_PREFIX; // "java.lang.invoke.FilterGeneric$"
static {
String aname = Adapter.class.getName();
String sname = Adapter.class.getSimpleName();
if (!aname.endsWith(sname)) throw new InternalError();
CLASS_PREFIX = aname.substring(0, aname.length() - sname.length());
}
/** Find a sibing class of Adapter. */
static Class<? extends Adapter> findSubClass(String name) {
String cname = Adapter.CLASS_PREFIX + name;
try {
return Class.forName(cname).asSubclass(Adapter.class);
} catch (ClassNotFoundException ex) {
return null;
} catch (ClassCastException ex) {
return null;
}
}
}
static enum Kind {
value('V'), // filter and replace Nth argument value
fold('F'), // fold first N arguments, prepend result
collect('C'), // collect last N arguments, replace with result
flyby('Y'), // reify entire argument list, filter, pass to target
LIMIT('?');
static final int COUNT = LIMIT.ordinal();
final char key;
Kind(char key) { this.key = key; }
String invokerName(int pos) { return "invoke_"+key+""+pos; }
int invokerIndex(int pos) { return pos * COUNT + ordinal(); }
}
/* generated classes follow this pattern:
static class F1X extends Adapter {
protected F1X(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F1X(MethodHandle e, MethodHandle f, MethodHandle t)
{ super(e, f, t); }
protected F1X makeInstance(MethodHandle e, MethodHandle f, MethodHandle t)
{ return new F1X(e, f, t); }
protected Object invoke_V0(Object a0) { return target.invokeExact(filter.invokeExact(a0)); }
protected Object invoke_F0(Object a0) { return target.invokeExact(filter.invokeExact(), a0); }
protected Object invoke_F1(Object a0) { return target.invokeExact(filter.invokeExact(a0), a0); }
protected Object invoke_C0(Object a0) { return target.invokeExact(filter.invokeExact(a0)); }
protected Object invoke_C1(Object a0) { return target.invokeExact(a0, filter.invokeExact()); }
protected Object invoke_Y0(Object a0) { Object[] av = { a0 };
filter.invokeExact(av); return target.invokeExact(av[0]); }
}
static class F2X extends Adapter {
protected F2X(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F2X(MethodHandle e, MethodHandle f, MethodHandle t)
{ super(e, f, t); }
protected F2X makeInstance(MethodHandle e, MethodHandle f, MethodHandle t)
{ return new F2X(e, f, t); }
protected Object invoke_V0(Object a0, Object a1) { return target.invokeExact(filter.invokeExact(a0), a1); }
protected Object invoke_V1(Object a0, Object a1) { return target.invokeExact(a0, filter.invokeExact(a1)); }
protected Object invoke_F0(Object a0, Object a1) { return target.invokeExact(filter.invokeExact(), a0, a1); }
protected Object invoke_F1(Object a0, Object a1) { return target.invokeExact(filter.invokeExact(a0), a0, a1); }
protected Object invoke_F2(Object a0, Object a1) { return target.invokeExact(filter.invokeExact(a0, a1), a0, a1); }
protected Object invoke_C0(Object a0, Object a1) { return target.invokeExact(filter.invokeExact(a0, a1)); }
protected Object invoke_C1(Object a0, Object a1) { return target.invokeExact(a0, filter.invokeExact(a1)); }
protected Object invoke_C2(Object a0, Object a1) { return target.invokeExact(a0, a1, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1) { Object[] av = { a0, a1 };
filter.invokeExact(av); return target.invokeExact(av[0], av[1]); }
}
// */
// This one is written by hand:
static class F0 extends Adapter {
protected F0(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F0(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F0 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F0(e, f, t); }
protected Object invoke_F0() throws Throwable {
return target.invokeExact(filter.invokeExact()); }
protected Object invoke_C0() throws Throwable {
return target.invokeExact(filter.invokeExact()); }
static final Object[] NO_ARGS = { };
protected Object invoke_Y0() throws Throwable {
filter.invokeExact(NO_ARGS); // make the flyby
return target.invokeExact(); }
}
/*
: SHELL; n=FilterGeneric; cp -p $n.java $n.java-; sed < $n.java- > $n.java+ -e '/{{*{{/,/}}*}}/w /tmp/genclasses.java' -e '/}}*}}/q'; (cd /tmp; javac -d . genclasses.java; java -ea -cp . genclasses | sed 's| *[/]/ *$||') >> $n.java+; echo '}' >> $n.java+; mv $n.java+ $n.java; mv $n.java- $n.java~
//{{{
import java.util.*;
class genclasses {
static String[][] TEMPLATES = { {
"@for@ N=1..20",
" //@each-cat@",
" static class @cat@ extends Adapter {",
" protected @cat@(MethodHandle entryPoint) { super(entryPoint); } // to build prototype",
" protected @cat@(MethodHandle e, MethodHandle f, MethodHandle t) {",
" super(e, f, t); }",
" protected @cat@ makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {",
" return new @cat@(e, f, t); }",
" //@each-P@",
" protected Object invoke_V@P@(@Tvav@) throws Throwable {",
" return target.invokeExact(@a0_@@Psp@filter.invokeExact(a@P@)@_aN@); }",
" //@end-P@",
" //@each-P@",
" protected Object invoke_F@P@(@Tvav@) throws Throwable {",
" return target.invokeExact(filter.invokeExact(@a0@),",
" @av@); }",
" //@end-P@",
" protected Object invoke_F@N@(@Tvav@) throws Throwable {",
" return target.invokeExact(filter.invokeExact(@av@),",
" @av@); }",
" //@each-P@",
" protected Object invoke_C@P@(@Tvav@) throws Throwable {",
" return target.invokeExact(@a0_@filter.invokeExact(a@P@@_aN@)); }",
" //@end-P@",
" protected Object invoke_C@N@(@Tvav@) throws Throwable {",
" return target.invokeExact(@av@, filter.invokeExact()); }",
" protected Object invoke_Y0(@Tvav@) throws Throwable {",
" Object[] av = { @av@ };",
" filter.invokeExact(av); // make the flyby",
" return target.invokeExact(@av[i]@); }",
" }",
} };
static final String NEWLINE_INDENT = " //\n ";
enum VAR {
cat, N, P, Tvav, av, a0, a0_, _aN, Psp, av_i_;
public final String pattern = "@"+toString().replace('_','.')+"@";
public String binding = toString();
static void makeBindings(boolean topLevel, int inargs, int pos) {
assert(-1 <= pos && pos < inargs);
VAR.cat.binding = "F"+inargs;
VAR.N.binding = String.valueOf(inargs); // incoming arg count
VAR.P.binding = String.valueOf(pos); // selected arg position
String[] av = new String[inargs];
String[] Tvav = new String[inargs];
String[] av_i_ = new String[inargs];
for (int i = 0; i < inargs; i++) {
av[i] = arg(i);
av_i_[i] = "av["+i+"]";
String spc = "";
if (i > 0 && i % 4 == 0) spc = NEWLINE_INDENT+(pos>9?" ":"")+" ";
Tvav[i] = spc+param("Object", av[i]);
}
VAR.av.binding = comma(av);
VAR.av_i_.binding = comma(av_i_);
VAR.Tvav.binding = comma(Tvav);
if (pos >= 0) {
VAR.Psp.binding = (pos > 0 && pos % 10 == 0) ? NEWLINE_INDENT : "";
String[] a0 = new String[pos];
String[] aN = new String[inargs - (pos+1)];
for (int i = 0; i < pos; i++) {
String spc = "";
if (i > 0 && i % 10 == 0) spc = NEWLINE_INDENT;
a0[i] = spc+av[i];
}
VAR.a0.binding = comma(a0);
VAR.a0_.binding = comma(a0, ", ");
for (int i = pos+1; i < inargs; i++) {
String spc = "";
if (i > 0 && i % 10 == 0) spc = NEWLINE_INDENT;
aN[i - (pos+1)] = spc+av[i];
}
VAR._aN.binding = comma(", ", aN);
}
}
static String arg(int i) { return "a"+i; }
static String param(String t, String a) { return t+" "+a; }
static String comma(String[] v) { return comma(v, ""); }
static String comma(String[] v, String sep) { return comma("", v, sep); }
static String comma(String sep, String[] v) { return comma(sep, v, ""); }
static String comma(String sep1, String[] v, String sep2) {
if (v.length == 0) return "";
String res = v[0];
for (int i = 1; i < v.length; i++) res += ", "+v[i];
return sep1 + res + sep2;
}
static String transform(String string) {
for (VAR var : values())
string = string.replaceAll(var.pattern, var.binding);
return string;
}
}
static String[] stringsIn(String[] strings, int beg, int end) {
return Arrays.copyOfRange(strings, beg, Math.min(end, strings.length));
}
static String[] stringsBefore(String[] strings, int pos) {
return stringsIn(strings, 0, pos);
}
static String[] stringsAfter(String[] strings, int pos) {
return stringsIn(strings, pos, strings.length);
}
static int indexAfter(String[] strings, int pos, String tag) {
return Math.min(indexBefore(strings, pos, tag) + 1, strings.length);
}
static int indexBefore(String[] strings, int pos, String tag) {
for (int i = pos, end = strings.length; ; i++) {
if (i == end || strings[i].endsWith(tag)) return i;
}
}
static int MIN_ARITY, MAX_ARITY;
public static void main(String... av) {
for (String[] template : TEMPLATES) {
int forLinesLimit = indexBefore(template, 0, "@each-cat@");
String[] forLines = stringsBefore(template, forLinesLimit);
template = stringsAfter(template, forLinesLimit);
for (String forLine : forLines)
expandTemplate(forLine, template);
}
}
static void expandTemplate(String forLine, String[] template) {
String[] params = forLine.split("[^0-9]+");
if (params[0].length() == 0) params = stringsAfter(params, 1);
System.out.println("//params="+Arrays.asList(params));
int pcur = 0;
MIN_ARITY = Integer.valueOf(params[pcur++]);
MAX_ARITY = Integer.valueOf(params[pcur++]);
if (pcur != params.length) throw new RuntimeException("bad extra param: "+forLine);
for (int inargs = MIN_ARITY; inargs <= MAX_ARITY; inargs++) {
expandTemplate(template, true, inargs, -1);
}
}
static void expandTemplate(String[] template, boolean topLevel, int inargs, int pos) {
VAR.makeBindings(topLevel, inargs, pos);
for (int i = 0; i < template.length; i++) {
String line = template[i];
if (line.endsWith("@each-cat@")) {
// ignore
} else if (line.endsWith("@each-P@")) {
int blockEnd = indexAfter(template, i, "@end-P@");
String[] block = stringsIn(template, i+1, blockEnd-1);
for (int pos1 = Math.max(0,pos); pos1 < inargs; pos1++)
expandTemplate(block, false, inargs, pos1);
VAR.makeBindings(topLevel, inargs, pos);
i = blockEnd-1; continue;
} else {
System.out.println(VAR.transform(line));
}
}
}
}
//}}} */
//params=[1, 20]
static class F1 extends Adapter {
protected F1(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F1(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F1 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F1(e, f, t); }
protected Object invoke_V0(Object a0) throws Throwable {
return target.invokeExact(filter.invokeExact(a0)); }
protected Object invoke_F0(Object a0) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0); }
protected Object invoke_F1(Object a0) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0); }
protected Object invoke_C0(Object a0) throws Throwable {
return target.invokeExact(filter.invokeExact(a0)); }
protected Object invoke_C1(Object a0) throws Throwable {
return target.invokeExact(a0, filter.invokeExact()); }
protected Object invoke_Y0(Object a0) throws Throwable {
Object[] av = { a0 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0]); }
}
static class F2 extends Adapter {
protected F2(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F2(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F2 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F2(e, f, t); }
protected Object invoke_V0(Object a0, Object a1) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1); }
protected Object invoke_V1(Object a0, Object a1) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1)); }
protected Object invoke_F0(Object a0, Object a1) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1); }
protected Object invoke_F1(Object a0, Object a1) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1); }
protected Object invoke_F2(Object a0, Object a1) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1); }
protected Object invoke_C0(Object a0, Object a1) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1)); }
protected Object invoke_C1(Object a0, Object a1) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1)); }
protected Object invoke_C2(Object a0, Object a1) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1) throws Throwable {
Object[] av = { a0, a1 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1]); }
}
static class F3 extends Adapter {
protected F3(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F3(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F3 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F3(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2); }
protected Object invoke_V1(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2); }
protected Object invoke_V2(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2)); }
protected Object invoke_F0(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2); }
protected Object invoke_F1(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2); }
protected Object invoke_F2(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2); }
protected Object invoke_F3(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2); }
protected Object invoke_C0(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2)); }
protected Object invoke_C1(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2)); }
protected Object invoke_C2(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2)); }
protected Object invoke_C3(Object a0, Object a1, Object a2) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2) throws Throwable {
Object[] av = { a0, a1, a2 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2]); }
}
static class F4 extends Adapter {
protected F4(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F4(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F4 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F4(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3) throws Throwable {
Object[] av = { a0, a1, a2, a3 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3]); }
}
static class F5 extends Adapter {
protected F5(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F5(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F5 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F5(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4]); }
}
static class F6 extends Adapter {
protected F6(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F6(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F6 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F6(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5]); }
}
static class F7 extends Adapter {
protected F7(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F7(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F7 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F7(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6]); }
}
static class F8 extends Adapter {
protected F8(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F8(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F8 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F8(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7]); }
}
static class F9 extends Adapter {
protected F9(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F9(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F9 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F9(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8]); }
}
static class F10 extends Adapter {
protected F10(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F10(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F10 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F10(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9]); }
}
static class F11 extends Adapter {
protected F11(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F11(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F11 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F11(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10]); }
}
static class F12 extends Adapter {
protected F12(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F12(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F12 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F12(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11]); }
}
static class F13 extends Adapter {
protected F13(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F13(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F13 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F13(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12]); }
}
static class F14 extends Adapter {
protected F14(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F14(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F14 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F14(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13]); }
}
static class F15 extends Adapter {
protected F15(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F15(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F15 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F15(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14]); }
}
static class F16 extends Adapter {
protected F16(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F16(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F16 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F16(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14, a15); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14, a15); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14, a15); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14, a15); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14, a15); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14), a15); }
protected Object invoke_V15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_F16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14, a15)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14, a15)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14, a15)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14, a15)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14, a15)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15)); }
protected Object invoke_C16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15]); }
}
static class F17 extends Adapter {
protected F17(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F17(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F17 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F17(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14, a15, a16); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14, a15, a16); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14, a15, a16); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14, a15, a16); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14), a15, a16); }
protected Object invoke_V15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15), a16); }
protected Object invoke_V16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_F17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14, a15, a16)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14, a15, a16)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14, a15, a16)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14, a15, a16)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15, a16)); }
protected Object invoke_C16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16)); }
protected Object invoke_C17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15], av[16]); }
}
static class F18 extends Adapter {
protected F18(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F18(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F18 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F18(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14, a15, a16, a17); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14, a15, a16, a17); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14, a15, a16, a17); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14), a15, a16, a17); }
protected Object invoke_V15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15), a16, a17); }
protected Object invoke_V16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16), a17); }
protected Object invoke_V17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_F18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14, a15, a16, a17)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14, a15, a16, a17)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14, a15, a16, a17)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15, a16, a17)); }
protected Object invoke_C16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16, a17)); }
protected Object invoke_C17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17)); }
protected Object invoke_C18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15], av[16], av[17]); }
}
static class F19 extends Adapter {
protected F19(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F19(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F19 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F19(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14, a15, a16, a17, a18); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14, a15, a16, a17, a18); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14), a15, a16, a17, a18); }
protected Object invoke_V15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15), a16, a17, a18); }
protected Object invoke_V16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16), a17, a18); }
protected Object invoke_V17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17), a18); }
protected Object invoke_V18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, filter.invokeExact(a18)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_F19(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14, a15, a16, a17, a18)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14, a15, a16, a17, a18)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15, a16, a17, a18)); }
protected Object invoke_C16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16, a17, a18)); }
protected Object invoke_C17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17, a18)); }
protected Object invoke_C18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, filter.invokeExact(a18)); }
protected Object invoke_C19(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15], av[16], av[17], av[18]); }
}
static class F20 extends Adapter {
protected F20(MethodHandle entryPoint) { super(entryPoint); } // to build prototype
protected F20(MethodHandle e, MethodHandle f, MethodHandle t) {
super(e, f, t); }
protected F20 makeInstance(MethodHandle e, MethodHandle f, MethodHandle t) {
return new F20(e, f, t); }
protected Object invoke_V0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0), a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1), a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2), a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3), a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4), a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5), a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6), a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7), a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8), a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9),
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
filter.invokeExact(a10), a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11), a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12), a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_V13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13), a14, a15, a16, a17, a18, a19); }
protected Object invoke_V14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14), a15, a16, a17, a18, a19); }
protected Object invoke_V15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15), a16, a17, a18, a19); }
protected Object invoke_V16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16), a17, a18, a19); }
protected Object invoke_V17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17), a18, a19); }
protected Object invoke_V18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, filter.invokeExact(a18), a19); }
protected Object invoke_V19(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, filter.invokeExact(a19)); }
protected Object invoke_F0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F19(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_F20(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19),
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); }
protected Object invoke_C0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(filter.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C1(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, filter.invokeExact(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C2(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, filter.invokeExact(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C3(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, filter.invokeExact(a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C4(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, filter.invokeExact(a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C5(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, filter.invokeExact(a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C6(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, filter.invokeExact(a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C7(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, filter.invokeExact(a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C8(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, filter.invokeExact(a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C9(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, filter.invokeExact(a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C10(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, filter.invokeExact(a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C11(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, filter.invokeExact(a11, a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C12(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, filter.invokeExact(a12, a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C13(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, filter.invokeExact(a13, a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C14(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, filter.invokeExact(a14, a15, a16, a17, a18, a19)); }
protected Object invoke_C15(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, filter.invokeExact(a15, a16, a17, a18, a19)); }
protected Object invoke_C16(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, filter.invokeExact(a16, a17, a18, a19)); }
protected Object invoke_C17(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, filter.invokeExact(a17, a18, a19)); }
protected Object invoke_C18(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, filter.invokeExact(a18, a19)); }
protected Object invoke_C19(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15, a16, a17, a18, filter.invokeExact(a19)); }
protected Object invoke_C20(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
return target.invokeExact(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, filter.invokeExact()); }
protected Object invoke_Y0(Object a0, Object a1, Object a2, Object a3,
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9, Object a10, Object a11,
Object a12, Object a13, Object a14, Object a15,
Object a16, Object a17, Object a18, Object a19) throws Throwable {
Object[] av = { a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19 };
filter.invokeExact(av); // make the flyby
return target.invokeExact(av[0], av[1], av[2], av[3], av[4], av[5], av[6], av[7], av[8], av[9], av[10], av[11], av[12], av[13], av[14], av[15], av[16], av[17], av[18], av[19]); }
}
}
| rokn/Count_Words_2015 | testing/openjdk/jdk/src/share/classes/java/lang/invoke/FilterGeneric.java | Java | mit | 348,803 |
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\User\Security;
use Sylius\Component\User\Model\CredentialsHolderInterface;
/**
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
*/
class PasswordUpdater implements PasswordUpdaterInterface
{
/**
* @var UserPasswordEncoderInterface
*/
private $userPasswordEncoder;
public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{
$this->userPasswordEncoder = $passwordEncoder;
}
/**
* {@inheritdoc}
*/
public function updatePassword(CredentialsHolderInterface $user)
{
if ('' !== $password = $user->getPlainPassword()) {
$user->setPassword($this->userPasswordEncoder->encode($user));
$user->eraseCredentials();
}
}
}
| axelvnk/Sylius | src/Sylius/Component/User/Security/PasswordUpdater.php | PHP | mit | 1,060 |
export * from './src/forum';
| flarum/akismet | js/forum.ts | TypeScript | mit | 29 |
// OCHamcrest by Jon Reid, http://qualitycoding.org/about/
// Copyright 2014 hamcrest.org. See LICENSE.txt
#import "HCReturnValueGetter.h"
@interface HCUnsignedLongReturnGetter : HCReturnValueGetter
- (instancetype)initWithSuccessor:(HCReturnValueGetter *)successor;
@end
| caoer/FXModelValidation | Tests/Pods/OCHamcrest/Source/Core/Helpers/ReturnValueGetters/HCUnsignedLongReturnGetter.h | C | mit | 279 |
package librato
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"regexp"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/serializers/graphite"
)
// Librato structure for configuration and client
type Librato struct {
APIUser string `toml:"api_user"`
APIToken string `toml:"api_token"`
Debug bool
SourceTag string // Deprecated, keeping for backward-compatibility
Timeout internal.Duration
Template string
APIUrl string
client *http.Client
}
// https://www.librato.com/docs/kb/faq/best_practices/naming_convention_metrics_sources.html#naming-limitations-for-sources-and-metrics
var reUnacceptedChar = regexp.MustCompile("[^.a-zA-Z0-9_-]")
var sampleConfig = `
## Librator API Docs
## http://dev.librato.com/v1/metrics-authentication
## Librato API user
api_user = "telegraf@influxdb.com" # required.
## Librato API token
api_token = "my-secret-token" # required.
## Debug
# debug = false
## Connection timeout.
# timeout = "5s"
## Output source Template (same as graphite buckets)
## see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md#graphite
## This template is used in librato's source (not metric's name)
template = "host"
`
// LMetrics is the default struct for Librato's API fromat
type LMetrics struct {
Gauges []*Gauge `json:"gauges"`
}
// Gauge is the gauge format for Librato's API fromat
type Gauge struct {
Name string `json:"name"`
Value float64 `json:"value"`
Source string `json:"source"`
MeasureTime int64 `json:"measure_time"`
}
const libratoAPI = "https://metrics-api.librato.com/v1/metrics"
// NewLibrato is the main constructor for librato output plugins
func NewLibrato(apiURL string) *Librato {
return &Librato{
APIUrl: apiURL,
Template: "host",
}
}
// Connect is the default output plugin connection function who make sure it
// can connect to the endpoint
func (l *Librato) Connect() error {
if l.APIUser == "" || l.APIToken == "" {
return fmt.Errorf(
"api_user and api_token are required fields for librato output")
}
l.client = &http.Client{
Timeout: l.Timeout.Duration,
}
return nil
}
func (l *Librato) Write(metrics []telegraf.Metric) error {
if len(metrics) == 0 {
return nil
}
if l.Template == "" {
l.Template = "host"
}
if l.SourceTag != "" {
l.Template = l.SourceTag
}
tempGauges := []*Gauge{}
for _, m := range metrics {
if gauges, err := l.buildGauges(m); err == nil {
for _, gauge := range gauges {
tempGauges = append(tempGauges, gauge)
log.Printf("D! Got a gauge: %v\n", gauge)
}
} else {
log.Printf("I! unable to build Gauge for %s, skipping\n", m.Name())
log.Printf("D! Couldn't build gauge: %v\n", err)
}
}
metricCounter := len(tempGauges)
// make sur we send a batch of maximum 300
sizeBatch := 300
for start := 0; start < metricCounter; start += sizeBatch {
lmetrics := LMetrics{}
end := start + sizeBatch
if end > metricCounter {
end = metricCounter
sizeBatch = end - start
}
lmetrics.Gauges = make([]*Gauge, sizeBatch)
copy(lmetrics.Gauges, tempGauges[start:end])
metricsBytes, err := json.Marshal(lmetrics)
if err != nil {
return fmt.Errorf("unable to marshal Metrics, %s\n", err.Error())
}
log.Printf("D! Librato request: %v\n", string(metricsBytes))
req, err := http.NewRequest(
"POST",
l.APIUrl,
bytes.NewBuffer(metricsBytes))
if err != nil {
return fmt.Errorf(
"unable to create http.Request, %s\n",
err.Error())
}
req.Header.Add("Content-Type", "application/json")
req.SetBasicAuth(l.APIUser, l.APIToken)
resp, err := l.client.Do(req)
if err != nil {
log.Printf("D! Error POSTing metrics: %v\n", err.Error())
return fmt.Errorf("error POSTing metrics, %s\n", err.Error())
}
defer resp.Body.Close()
if resp.StatusCode != 200 || l.Debug {
htmlData, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Printf("D! Couldn't get response! (%v)\n", err)
}
if resp.StatusCode != 200 {
return fmt.Errorf(
"received bad status code, %d\n %s",
resp.StatusCode,
string(htmlData))
}
log.Printf("D! Librato response: %v\n", string(htmlData))
}
}
return nil
}
// SampleConfig is function who return the default configuration for this
// output
func (l *Librato) SampleConfig() string {
return sampleConfig
}
// Description is function who return the Description of this output
func (l *Librato) Description() string {
return "Configuration for Librato API to send metrics to."
}
func (l *Librato) buildGauges(m telegraf.Metric) ([]*Gauge, error) {
gauges := []*Gauge{}
if m.Time().Unix() == 0 {
return gauges, fmt.Errorf(
"Measure time must not be zero\n <%s> \n",
m.String())
}
metricSource := graphite.InsertField(
graphite.SerializeBucketName("", m.Tags(), l.Template, ""),
"value")
if metricSource == "" {
return gauges,
fmt.Errorf("undeterminable Source type from Field, %s\n",
l.Template)
}
for fieldName, value := range m.Fields() {
metricName := m.Name()
if fieldName != "value" {
metricName = fmt.Sprintf("%s.%s", m.Name(), fieldName)
}
gauge := &Gauge{
Source: reUnacceptedChar.ReplaceAllString(metricSource, "-"),
Name: reUnacceptedChar.ReplaceAllString(metricName, "-"),
MeasureTime: m.Time().Unix(),
}
if !verifyValue(value) {
continue
}
if err := gauge.setValue(value); err != nil {
return gauges, fmt.Errorf(
"unable to extract value from Fields, %s\n",
err.Error())
}
gauges = append(gauges, gauge)
}
log.Printf("D! Built gauges: %v\n", gauges)
return gauges, nil
}
func verifyValue(v interface{}) bool {
switch v.(type) {
case string:
return false
}
return true
}
func (g *Gauge) setValue(v interface{}) error {
switch d := v.(type) {
case int:
g.Value = float64(int(d))
case int32:
g.Value = float64(int32(d))
case int64:
g.Value = float64(int64(d))
case float32:
g.Value = float64(d)
case float64:
g.Value = float64(d)
default:
return fmt.Errorf("undeterminable type %+v", d)
}
return nil
}
//Close is used to close the connection to librato Output
func (l *Librato) Close() error {
return nil
}
func init() {
outputs.Add("librato", func() telegraf.Output {
return NewLibrato(libratoAPI)
})
}
| ingosus/telegraf | plugins/outputs/librato/librato.go | GO | mit | 6,441 |
<?php
/**
* @file
* Contains \Drupal\Tests\user\Unit\Plugin\views\field\UserBulkFormTest.
*/
namespace Drupal\Tests\user\Unit\Plugin\views\field;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
use Drupal\user\Plugin\views\field\UserBulkForm;
/**
* @coversDefaultClass \Drupal\user\Plugin\views\field\UserBulkForm
* @group user
*/
class UserBulkFormTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
$actions = array();
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('node'));
$actions[] = $action;
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValue($actions));
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
->getMock();
$views_data->expects($this->any())
->method('get')
->with('users')
->will($this->returnValue(array('table' => array('entity type' => 'user'))));
$container = new ContainerBuilder();
$container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
$storage->expects($this->any())
->method('get')
->with('base_table')
->will($this->returnValue('users'));
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$executable->storage = $storage;
$display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$definition['title'] = '';
$options = array();
$user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_storage);
$user_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);
}
}
| casivaagustin/drupalcon-mentoring | src/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php | PHP | mit | 2,721 |
/*!v3.2.1*/.u-high,.u-higher,.u-highest{border:0}.u-high{box-shadow:0 0 1px hsla(0,0%,7%,.6),0 5px 10px -3px hsla(0,0%,7%,.4)}.u-higher{box-shadow:0 0 1px hsla(0,0%,7%,.6),0 10px 25px -4px hsla(0,0%,7%,.4)}.u-highest{box-shadow:0 0 1px hsla(0,0%,7%,.6),0 20px 55px -8px hsla(0,0%,7%,.4)} | Asaf-S/jsdelivr | files/blazecss/3.2.1/utilities.elevation.min.css | CSS | mit | 287 |
UPDATE creature_template SET ScriptName='' WHERE entry=10307;
| mangosArchives/serverOneRel18 | src/scripts/sql/updates/0.6/r2445_mangos.sql | SQL | gpl-2.0 | 62 |
/* mpz_powm_sec(res,base,exp,mod) -- Set R to (U^E) mod M.
Contributed to the GNU project by Torbjorn Granlund.
Copyright 1991, 1993, 1994, 1996, 1997, 2000-2002, 2005, 2008, 2009, 2012 Free
Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of either:
* 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.
or
* 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.
or both in parallel, as here.
The GNU MP 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.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp.h"
#include "gmp-impl.h"
void
mpz_powm_sec (mpz_ptr r, mpz_srcptr b, mpz_srcptr e, mpz_srcptr m)
{
mp_size_t n;
mp_ptr rp, tp;
mp_srcptr bp, ep, mp;
mp_size_t rn, bn, es, en;
TMP_DECL;
n = ABSIZ(m);
mp = PTR(m);
if (UNLIKELY ((n == 0) || (mp[0] % 2 == 0)))
DIVIDE_BY_ZERO;
es = SIZ(e);
if (UNLIKELY (es <= 0))
{
if (es == 0)
{
/* b^0 mod m, b is anything and m is non-zero.
Result is 1 mod m, i.e., 1 or 0 depending on if m = 1. */
SIZ(r) = n != 1 || mp[0] != 1;
PTR(r)[0] = 1;
return;
}
DIVIDE_BY_ZERO;
}
en = es;
bn = ABSIZ(b);
if (UNLIKELY (bn == 0))
{
SIZ(r) = 0;
return;
}
TMP_MARK;
tp = TMP_ALLOC_LIMBS (n + mpn_sec_powm_itch (bn, en * GMP_NUMB_BITS, n));
rp = tp; tp += n;
bp = PTR(b);
ep = PTR(e);
mpn_sec_powm (rp, bp, bn, ep, en * GMP_NUMB_BITS, mp, n, tp);
rn = n;
MPN_NORMALIZE (rp, rn);
if ((ep[0] & 1) && SIZ(b) < 0 && rn != 0)
{
mpn_sub (rp, PTR(m), n, rp, rn);
rn = n;
MPN_NORMALIZE (rp, rn);
}
MPZ_REALLOC (r, rn);
SIZ(r) = rn;
MPN_COPY (PTR(r), rp, rn);
TMP_FREE;
}
| GarethNelson/BearLang | vendor/gmp-6.1.2/mpz/powm_sec.c | C | gpl-2.0 | 2,327 |
/*
* Code to handle IP32 IRQs
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2000 Harald Koerfgen
* Copyright (C) 2001 Keith M Wesolowski
*/
#include <linux/init.h>
#include <linux/kernel_stat.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/random.h>
#include <linux/sched.h>
#include <asm/irq_cpu.h>
#include <asm/mipsregs.h>
#include <asm/signal.h>
#include <asm/system.h>
#include <asm/time.h>
#include <asm/ip32/crime.h>
#include <asm/ip32/mace.h>
#include <asm/ip32/ip32_ints.h>
/* issue a PIO read to make sure no PIO writes are pending */
static void inline flush_crime_bus(void)
{
crime->control;
}
static void inline flush_mace_bus(void)
{
mace->perif.ctrl.misc;
}
/*
* O2 irq map
*
* IP0 -> software (ignored)
* IP1 -> software (ignored)
* IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ???
* IP3 -> (irq1) X unknown
* IP4 -> (irq2) X unknown
* IP5 -> (irq3) X unknown
* IP6 -> (irq4) X unknown
* IP7 -> (irq5) 7 CPU count/compare timer (system timer)
*
* crime: (C)
*
* CRIME_INT_STAT 31:0:
*
* 0 -> 8 Video in 1
* 1 -> 9 Video in 2
* 2 -> 10 Video out
* 3 -> 11 Mace ethernet
* 4 -> S SuperIO sub-interrupt
* 5 -> M Miscellaneous sub-interrupt
* 6 -> A Audio sub-interrupt
* 7 -> 15 PCI bridge errors
* 8 -> 16 PCI SCSI aic7xxx 0
* 9 -> 17 PCI SCSI aic7xxx 1
* 10 -> 18 PCI slot 0
* 11 -> 19 unused (PCI slot 1)
* 12 -> 20 unused (PCI slot 2)
* 13 -> 21 unused (PCI shared 0)
* 14 -> 22 unused (PCI shared 1)
* 15 -> 23 unused (PCI shared 2)
* 16 -> 24 GBE0 (E)
* 17 -> 25 GBE1 (E)
* 18 -> 26 GBE2 (E)
* 19 -> 27 GBE3 (E)
* 20 -> 28 CPU errors
* 21 -> 29 Memory errors
* 22 -> 30 RE empty edge (E)
* 23 -> 31 RE full edge (E)
* 24 -> 32 RE idle edge (E)
* 25 -> 33 RE empty level
* 26 -> 34 RE full level
* 27 -> 35 RE idle level
* 28 -> 36 unused (software 0) (E)
* 29 -> 37 unused (software 1) (E)
* 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E)
* 31 -> 39 VICE
*
* S, M, A: Use the MACE ISA interrupt register
* MACE_ISA_INT_STAT 31:0
*
* 0-7 -> 40-47 Audio
* 8 -> 48 RTC
* 9 -> 49 Keyboard
* 10 -> X Keyboard polled
* 11 -> 51 Mouse
* 12 -> X Mouse polled
* 13-15 -> 53-55 Count/compare timers
* 16-19 -> 56-59 Parallel (16 E)
* 20-25 -> 60-62 Serial 1 (22 E)
* 26-31 -> 66-71 Serial 2 (28 E)
*
* Note that this means IRQs 12-14, 50, and 52 do not exist. This is a
* different IRQ map than IRIX uses, but that's OK as Linux irq handling
* is quite different anyway.
*/
/* Some initial interrupts to set up */
extern irqreturn_t crime_memerr_intr(int irq, void *dev_id);
extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id);
struct irqaction memerr_irq = {
.handler = crime_memerr_intr,
.flags = IRQF_DISABLED,
.mask = CPU_MASK_NONE,
.name = "CRIME memory error",
};
struct irqaction cpuerr_irq = {
.handler = crime_cpuerr_intr,
.flags = IRQF_DISABLED,
.mask = CPU_MASK_NONE,
.name = "CRIME CPU error",
};
/*
* This is for pure CRIME interrupts - ie not MACE. The advantage?
* We get to split the register in half and do faster lookups.
*/
static uint64_t crime_mask;
static inline void crime_enable_irq(unsigned int irq)
{
unsigned int bit = irq - CRIME_IRQ_BASE;
crime_mask |= 1 << bit;
crime->imask = crime_mask;
}
static inline void crime_disable_irq(unsigned int irq)
{
unsigned int bit = irq - CRIME_IRQ_BASE;
crime_mask &= ~(1 << bit);
crime->imask = crime_mask;
flush_crime_bus();
}
static void crime_level_mask_and_ack_irq(unsigned int irq)
{
crime_disable_irq(irq);
}
static void crime_level_end_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
crime_enable_irq(irq);
}
static struct irq_chip crime_level_interrupt = {
.name = "IP32 CRIME",
.ack = crime_level_mask_and_ack_irq,
.mask = crime_disable_irq,
.mask_ack = crime_level_mask_and_ack_irq,
.unmask = crime_enable_irq,
.end = crime_level_end_irq,
};
static void crime_edge_mask_and_ack_irq(unsigned int irq)
{
unsigned int bit = irq - CRIME_IRQ_BASE;
uint64_t crime_int;
/* Edge triggered interrupts must be cleared. */
crime_int = crime->hard_int;
crime_int &= ~(1 << bit);
crime->hard_int = crime_int;
crime_disable_irq(irq);
}
static void crime_edge_end_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
crime_enable_irq(irq);
}
static struct irq_chip crime_edge_interrupt = {
.name = "IP32 CRIME",
.ack = crime_edge_mask_and_ack_irq,
.mask = crime_disable_irq,
.mask_ack = crime_edge_mask_and_ack_irq,
.unmask = crime_enable_irq,
.end = crime_edge_end_irq,
};
/*
* This is for MACE PCI interrupts. We can decrease bus traffic by masking
* as close to the source as possible. This also means we can take the
* next chunk of the CRIME register in one piece.
*/
static unsigned long macepci_mask;
static void enable_macepci_irq(unsigned int irq)
{
macepci_mask |= MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ);
mace->pci.control = macepci_mask;
crime_mask |= 1 << (irq - CRIME_IRQ_BASE);
crime->imask = crime_mask;
}
static void disable_macepci_irq(unsigned int irq)
{
crime_mask &= ~(1 << (irq - CRIME_IRQ_BASE));
crime->imask = crime_mask;
flush_crime_bus();
macepci_mask &= ~MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ);
mace->pci.control = macepci_mask;
flush_mace_bus();
}
static void end_macepci_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
enable_macepci_irq(irq);
}
static struct irq_chip ip32_macepci_interrupt = {
.name = "IP32 MACE PCI",
.ack = disable_macepci_irq,
.mask = disable_macepci_irq,
.mask_ack = disable_macepci_irq,
.unmask = enable_macepci_irq,
.end = end_macepci_irq,
};
/* This is used for MACE ISA interrupts. That means bits 4-6 in the
* CRIME register.
*/
#define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \
MACEISA_AUDIO_SC_INT | \
MACEISA_AUDIO1_DMAT_INT | \
MACEISA_AUDIO1_OF_INT | \
MACEISA_AUDIO2_DMAT_INT | \
MACEISA_AUDIO2_MERR_INT | \
MACEISA_AUDIO3_DMAT_INT | \
MACEISA_AUDIO3_MERR_INT)
#define MACEISA_MISC_INT (MACEISA_RTC_INT | \
MACEISA_KEYB_INT | \
MACEISA_KEYB_POLL_INT | \
MACEISA_MOUSE_INT | \
MACEISA_MOUSE_POLL_INT | \
MACEISA_TIMER0_INT | \
MACEISA_TIMER1_INT | \
MACEISA_TIMER2_INT)
#define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \
MACEISA_PAR_CTXA_INT | \
MACEISA_PAR_CTXB_INT | \
MACEISA_PAR_MERR_INT | \
MACEISA_SERIAL1_INT | \
MACEISA_SERIAL1_TDMAT_INT | \
MACEISA_SERIAL1_TDMAPR_INT | \
MACEISA_SERIAL1_TDMAME_INT | \
MACEISA_SERIAL1_RDMAT_INT | \
MACEISA_SERIAL1_RDMAOR_INT | \
MACEISA_SERIAL2_INT | \
MACEISA_SERIAL2_TDMAT_INT | \
MACEISA_SERIAL2_TDMAPR_INT | \
MACEISA_SERIAL2_TDMAME_INT | \
MACEISA_SERIAL2_RDMAT_INT | \
MACEISA_SERIAL2_RDMAOR_INT)
static unsigned long maceisa_mask;
static void enable_maceisa_irq(unsigned int irq)
{
unsigned int crime_int = 0;
pr_debug("maceisa enable: %u\n", irq);
switch (irq) {
case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ:
crime_int = MACE_AUDIO_INT;
break;
case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ:
crime_int = MACE_MISC_INT;
break;
case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ:
crime_int = MACE_SUPERIO_INT;
break;
}
pr_debug("crime_int %08x enabled\n", crime_int);
crime_mask |= crime_int;
crime->imask = crime_mask;
maceisa_mask |= 1 << (irq - MACEISA_AUDIO_SW_IRQ);
mace->perif.ctrl.imask = maceisa_mask;
}
static void disable_maceisa_irq(unsigned int irq)
{
unsigned int crime_int = 0;
maceisa_mask &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ));
if (!(maceisa_mask & MACEISA_AUDIO_INT))
crime_int |= MACE_AUDIO_INT;
if (!(maceisa_mask & MACEISA_MISC_INT))
crime_int |= MACE_MISC_INT;
if (!(maceisa_mask & MACEISA_SUPERIO_INT))
crime_int |= MACE_SUPERIO_INT;
crime_mask &= ~crime_int;
crime->imask = crime_mask;
flush_crime_bus();
mace->perif.ctrl.imask = maceisa_mask;
flush_mace_bus();
}
static void mask_and_ack_maceisa_irq(unsigned int irq)
{
unsigned long mace_int;
switch (irq) {
case MACEISA_PARALLEL_IRQ:
case MACEISA_SERIAL1_TDMAPR_IRQ:
case MACEISA_SERIAL2_TDMAPR_IRQ:
/* edge triggered */
mace_int = mace->perif.ctrl.istat;
mace_int &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ));
mace->perif.ctrl.istat = mace_int;
break;
}
disable_maceisa_irq(irq);
}
static void end_maceisa_irq(unsigned irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
enable_maceisa_irq(irq);
}
static struct irq_chip ip32_maceisa_interrupt = {
.name = "IP32 MACE ISA",
.ack = mask_and_ack_maceisa_irq,
.mask = disable_maceisa_irq,
.mask_ack = mask_and_ack_maceisa_irq,
.unmask = enable_maceisa_irq,
.end = end_maceisa_irq,
};
/* This is used for regular non-ISA, non-PCI MACE interrupts. That means
* bits 0-3 and 7 in the CRIME register.
*/
static void enable_mace_irq(unsigned int irq)
{
unsigned int bit = irq - CRIME_IRQ_BASE;
crime_mask |= (1 << bit);
crime->imask = crime_mask;
}
static void disable_mace_irq(unsigned int irq)
{
unsigned int bit = irq - CRIME_IRQ_BASE;
crime_mask &= ~(1 << bit);
crime->imask = crime_mask;
flush_crime_bus();
}
static void end_mace_irq(unsigned int irq)
{
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
enable_mace_irq(irq);
}
static struct irq_chip ip32_mace_interrupt = {
.name = "IP32 MACE",
.ack = disable_mace_irq,
.mask = disable_mace_irq,
.mask_ack = disable_mace_irq,
.unmask = enable_mace_irq,
.end = end_mace_irq,
};
static void ip32_unknown_interrupt(void)
{
printk("Unknown interrupt occurred!\n");
printk("cp0_status: %08x\n", read_c0_status());
printk("cp0_cause: %08x\n", read_c0_cause());
printk("CRIME intr mask: %016lx\n", crime->imask);
printk("CRIME intr status: %016lx\n", crime->istat);
printk("CRIME hardware intr register: %016lx\n", crime->hard_int);
printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask);
printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat);
printk("MACE PCI control register: %08x\n", mace->pci.control);
printk("Register dump:\n");
show_regs(get_irq_regs());
printk("Please mail this report to linux-mips@linux-mips.org\n");
printk("Spinning...");
while(1) ;
}
/* CRIME 1.1 appears to deliver all interrupts to this one pin. */
/* change this to loop over all edge-triggered irqs, exception masked out ones */
static void ip32_irq0(void)
{
uint64_t crime_int;
int irq = 0;
/*
* Sanity check interrupt numbering enum.
* MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy
* chained.
*/
BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31);
BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31);
crime_int = crime->istat & crime_mask;
irq = MACE_VID_IN1_IRQ + __ffs(crime_int);
if (crime_int & CRIME_MACEISA_INT_MASK) {
unsigned long mace_int = mace->perif.ctrl.istat;
irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ;
}
pr_debug("*irq %u*\n", irq);
do_IRQ(irq);
}
static void ip32_irq1(void)
{
ip32_unknown_interrupt();
}
static void ip32_irq2(void)
{
ip32_unknown_interrupt();
}
static void ip32_irq3(void)
{
ip32_unknown_interrupt();
}
static void ip32_irq4(void)
{
ip32_unknown_interrupt();
}
static void ip32_irq5(void)
{
do_IRQ(MIPS_CPU_IRQ_BASE + 7);
}
asmlinkage void plat_irq_dispatch(void)
{
unsigned int pending = read_c0_status() & read_c0_cause();
if (likely(pending & IE_IRQ0))
ip32_irq0();
else if (unlikely(pending & IE_IRQ1))
ip32_irq1();
else if (unlikely(pending & IE_IRQ2))
ip32_irq2();
else if (unlikely(pending & IE_IRQ3))
ip32_irq3();
else if (unlikely(pending & IE_IRQ4))
ip32_irq4();
else if (likely(pending & IE_IRQ5))
ip32_irq5();
}
void __init arch_init_irq(void)
{
unsigned int irq;
/* Install our interrupt handler, then clear and disable all
* CRIME and MACE interrupts. */
crime->imask = 0;
crime->hard_int = 0;
crime->soft_int = 0;
mace->perif.ctrl.istat = 0;
mace->perif.ctrl.imask = 0;
mips_cpu_irq_init();
for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) {
switch (irq) {
case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ:
set_irq_chip(irq, &ip32_mace_interrupt);
break;
case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ:
set_irq_chip(irq, &ip32_macepci_interrupt);
break;
case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ:
set_irq_chip(irq, &crime_edge_interrupt);
break;
case CRIME_CPUERR_IRQ:
case CRIME_MEMERR_IRQ:
set_irq_chip(irq, &crime_level_interrupt);
break;
case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ:
case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ:
set_irq_chip(irq, &crime_edge_interrupt);
break;
case CRIME_VICE_IRQ:
set_irq_chip(irq, &crime_edge_interrupt);
break;
default:
set_irq_chip(irq, &ip32_maceisa_interrupt);
break;
}
}
setup_irq(CRIME_MEMERR_IRQ, &memerr_irq);
setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq);
#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
change_c0_status(ST0_IM, ALLINTS);
}
| janrinze/loox7xxport.loox2624 | arch/mips/sgi-ip32/ip32-irq.c | C | gpl-2.0 | 13,417 |
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU 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, USA
*
*
******************************************************************************/
#define _RTW_MP_C_
#include <drv_types.h>
#ifdef PLATFORM_FREEBSD
#include <sys/unistd.h> /* for RFHIGHPID */
#endif
#ifdef CONFIG_RTL8712
#include <rtw_mp_phy_regdef.h>
#endif
#ifdef CONFIG_RTL8192C
#include <rtl8192c_hal.h>
#endif
#ifdef CONFIG_RTL8192D
#include <rtl8192d_hal.h>
#endif
#ifdef CONFIG_RTL8723A
#include <rtl8723a_hal.h>
#include "rtw_bt_mp.h"
#endif
#ifdef CONFIG_RTL8188E
#include "../hal/OUTSRC/odm_precomp.h"
#include "rtl8188e_hal.h"
#endif
#ifdef CONFIG_MP_INCLUDED
u32 read_macreg(_adapter *padapter, u32 addr, u32 sz)
{
u32 val = 0;
switch(sz)
{
case 1:
val = rtw_read8(padapter, addr);
break;
case 2:
val = rtw_read16(padapter, addr);
break;
case 4:
val = rtw_read32(padapter, addr);
break;
default:
val = 0xffffffff;
break;
}
return val;
}
void write_macreg(_adapter *padapter, u32 addr, u32 val, u32 sz)
{
switch(sz)
{
case 1:
rtw_write8(padapter, addr, (u8)val);
break;
case 2:
rtw_write16(padapter, addr, (u16)val);
break;
case 4:
rtw_write32(padapter, addr, val);
break;
default:
break;
}
}
u32 read_bbreg(_adapter *padapter, u32 addr, u32 bitmask)
{
return rtw_hal_read_bbreg(padapter, addr, bitmask);
}
void write_bbreg(_adapter *padapter, u32 addr, u32 bitmask, u32 val)
{
rtw_hal_write_bbreg(padapter, addr, bitmask, val);
}
u32 _read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask)
{
return rtw_hal_read_rfreg(padapter, (RF_RADIO_PATH_E)rfpath, addr, bitmask);
}
void _write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val)
{
rtw_hal_write_rfreg(padapter, (RF_RADIO_PATH_E)rfpath, addr, bitmask, val);
}
u32 read_rfreg(PADAPTER padapter, u8 rfpath, u32 addr)
{
return _read_rfreg(padapter, (RF_RADIO_PATH_E)rfpath, addr, bRFRegOffsetMask);
}
void write_rfreg(PADAPTER padapter, u8 rfpath, u32 addr, u32 val)
{
_write_rfreg(padapter, (RF_RADIO_PATH_E)rfpath, addr, bRFRegOffsetMask, val);
}
static void _init_mp_priv_(struct mp_priv *pmp_priv)
{
WLAN_BSSID_EX *pnetwork;
_rtw_memset(pmp_priv, 0, sizeof(struct mp_priv));
pmp_priv->mode = MP_OFF;
pmp_priv->channel = 1;
pmp_priv->bandwidth = HT_CHANNEL_WIDTH_20;
pmp_priv->prime_channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
pmp_priv->rateidx = MPT_RATE_1M;
pmp_priv->txpoweridx = 0x2A;
pmp_priv->antenna_tx = ANTENNA_A;
pmp_priv->antenna_rx = ANTENNA_AB;
pmp_priv->check_mp_pkt = 0;
pmp_priv->tx_pktcount = 0;
pmp_priv->rx_pktcount = 0;
pmp_priv->rx_crcerrpktcount = 0;
pmp_priv->network_macaddr[0] = 0x00;
pmp_priv->network_macaddr[1] = 0xE0;
pmp_priv->network_macaddr[2] = 0x4C;
pmp_priv->network_macaddr[3] = 0x87;
pmp_priv->network_macaddr[4] = 0x66;
pmp_priv->network_macaddr[5] = 0x55;
pnetwork = &pmp_priv->mp_network.network;
_rtw_memcpy(pnetwork->MacAddress, pmp_priv->network_macaddr, ETH_ALEN);
pnetwork->Ssid.SsidLength = 8;
_rtw_memcpy(pnetwork->Ssid.Ssid, "mp_871x", pnetwork->Ssid.SsidLength);
}
#ifdef PLATFORM_WINDOWS
/*
void mp_wi_callback(
IN NDIS_WORK_ITEM* pwk_item,
IN PVOID cntx
)
{
_adapter* padapter =(_adapter *)cntx;
struct mp_priv *pmppriv=&padapter->mppriv;
struct mp_wi_cntx *pmp_wi_cntx=&pmppriv->wi_cntx;
// Execute specified action.
if(pmp_wi_cntx->curractfunc != NULL)
{
LARGE_INTEGER cur_time;
ULONGLONG start_time, end_time;
NdisGetCurrentSystemTime(&cur_time); // driver version
start_time = cur_time.QuadPart/10; // The return value is in microsecond
pmp_wi_cntx->curractfunc(padapter);
NdisGetCurrentSystemTime(&cur_time); // driver version
end_time = cur_time.QuadPart/10; // The return value is in microsecond
RT_TRACE(_module_mp_, _drv_info_,
("WorkItemActType: %d, time spent: %I64d us\n",
pmp_wi_cntx->param.act_type, (end_time-start_time)));
}
NdisAcquireSpinLock(&(pmp_wi_cntx->mp_wi_lock));
pmp_wi_cntx->bmp_wi_progress= _FALSE;
NdisReleaseSpinLock(&(pmp_wi_cntx->mp_wi_lock));
if (pmp_wi_cntx->bmpdrv_unload)
{
NdisSetEvent(&(pmp_wi_cntx->mp_wi_evt));
}
}
*/
static int init_mp_priv_by_os(struct mp_priv *pmp_priv)
{
struct mp_wi_cntx *pmp_wi_cntx;
if (pmp_priv == NULL) return _FAIL;
pmp_priv->rx_testcnt = 0;
pmp_priv->rx_testcnt1 = 0;
pmp_priv->rx_testcnt2 = 0;
pmp_priv->tx_testcnt = 0;
pmp_priv->tx_testcnt1 = 0;
pmp_wi_cntx = &pmp_priv->wi_cntx
pmp_wi_cntx->bmpdrv_unload = _FALSE;
pmp_wi_cntx->bmp_wi_progress = _FALSE;
pmp_wi_cntx->curractfunc = NULL;
return _SUCCESS;
}
#endif
#ifdef PLATFORM_LINUX
static int init_mp_priv_by_os(struct mp_priv *pmp_priv)
{
int i, res;
struct mp_xmit_frame *pmp_xmitframe;
if (pmp_priv == NULL) return _FAIL;
_rtw_init_queue(&pmp_priv->free_mp_xmitqueue);
pmp_priv->pallocated_mp_xmitframe_buf = NULL;
pmp_priv->pallocated_mp_xmitframe_buf = rtw_zmalloc(NR_MP_XMITFRAME * sizeof(struct mp_xmit_frame) + 4);
if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) {
res = _FAIL;
goto _exit_init_mp_priv;
}
pmp_priv->pmp_xmtframe_buf = pmp_priv->pallocated_mp_xmitframe_buf + 4 - ((SIZE_PTR) (pmp_priv->pallocated_mp_xmitframe_buf) & 3);
pmp_xmitframe = (struct mp_xmit_frame*)pmp_priv->pmp_xmtframe_buf;
for (i = 0; i < NR_MP_XMITFRAME; i++)
{
_rtw_init_listhead(&pmp_xmitframe->list);
rtw_list_insert_tail(&pmp_xmitframe->list, &pmp_priv->free_mp_xmitqueue.queue);
pmp_xmitframe->pkt = NULL;
pmp_xmitframe->frame_tag = MP_FRAMETAG;
pmp_xmitframe->padapter = pmp_priv->papdater;
pmp_xmitframe++;
}
pmp_priv->free_mp_xmitframe_cnt = NR_MP_XMITFRAME;
res = _SUCCESS;
_exit_init_mp_priv:
return res;
}
#endif
static void mp_init_xmit_attrib(struct mp_tx *pmptx, PADAPTER padapter)
{
struct pkt_attrib *pattrib;
struct tx_desc *desc;
// init xmitframe attribute
pattrib = &pmptx->attrib;
_rtw_memset(pattrib, 0, sizeof(struct pkt_attrib));
desc = &pmptx->desc;
_rtw_memset(desc, 0, TXDESC_SIZE);
pattrib->ether_type = 0x8712;
//_rtw_memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN);
// _rtw_memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
_rtw_memset(pattrib->dst, 0xFF, ETH_ALEN);
// pattrib->pctrl = 0;
// pattrib->dhcp_pkt = 0;
// pattrib->pktlen = 0;
pattrib->ack_policy = 0;
// pattrib->pkt_hdrlen = ETH_HLEN;
pattrib->hdrlen = WLAN_HDR_A3_LEN;
pattrib->subtype = WIFI_DATA;
pattrib->priority = 0;
pattrib->qsel = pattrib->priority;
// do_queue_select(padapter, pattrib);
pattrib->nr_frags = 1;
pattrib->encrypt = 0;
pattrib->bswenc = _FALSE;
pattrib->qos_en = _FALSE;
}
s32 init_mp_priv(PADAPTER padapter)
{
struct mp_priv *pmppriv = &padapter->mppriv;
_init_mp_priv_(pmppriv);
pmppriv->papdater = padapter;
pmppriv->tx.stop = 1;
mp_init_xmit_attrib(&pmppriv->tx, padapter);
switch (padapter->registrypriv.rf_config) {
case RF_1T1R:
pmppriv->antenna_tx = ANTENNA_A;
pmppriv->antenna_rx = ANTENNA_A;
break;
case RF_1T2R:
default:
pmppriv->antenna_tx = ANTENNA_A;
pmppriv->antenna_rx = ANTENNA_AB;
break;
case RF_2T2R:
case RF_2T2R_GREEN:
pmppriv->antenna_tx = ANTENNA_AB;
pmppriv->antenna_rx = ANTENNA_AB;
break;
case RF_2T4R:
pmppriv->antenna_tx = ANTENNA_AB;
pmppriv->antenna_rx = ANTENNA_ABCD;
break;
}
return _SUCCESS;
}
void free_mp_priv(struct mp_priv *pmp_priv)
{
if (pmp_priv->pallocated_mp_xmitframe_buf) {
rtw_mfree(pmp_priv->pallocated_mp_xmitframe_buf, 0);
pmp_priv->pallocated_mp_xmitframe_buf = NULL;
}
pmp_priv->pmp_xmtframe_buf = NULL;
}
#if defined (CONFIG_RTL8192C) || defined (CONFIG_RTL8723A)
#define PHY_IQCalibrate(a,b) rtl8192c_PHY_IQCalibrate(a,b)
#define PHY_LCCalibrate(a) rtl8192c_PHY_LCCalibrate(a)
//#define dm_CheckTXPowerTracking(a) rtl8192c_odm_CheckTXPowerTracking(a)
#define PHY_SetRFPathSwitch(a,b) rtl8192c_PHY_SetRFPathSwitch(a,b)
#endif
#ifdef CONFIG_RTL8192D
#define PHY_IQCalibrate(a,b) rtl8192d_PHY_IQCalibrate(a)
#define PHY_LCCalibrate(a) rtl8192d_PHY_LCCalibrate(a)
//#define dm_CheckTXPowerTracking(a) rtl8192d_odm_CheckTXPowerTracking(a)
#define PHY_SetRFPathSwitch(a,b) rtl8192d_PHY_SetRFPathSwitch(a,b)
#endif
#ifdef CONFIG_RTL8188E
#define PHY_IQCalibrate(a,b) PHY_IQCalibrate_8188E(a,b)
#define PHY_LCCalibrate(a) PHY_LCCalibrate_8188E(a)
#define PHY_SetRFPathSwitch(a,b) PHY_SetRFPathSwitch_8188E(a,b)
#endif
s32
MPT_InitializeAdapter(
IN PADAPTER pAdapter,
IN u8 Channel
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
s32 rtStatus = _SUCCESS;
PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
u32 ledsetting;
struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv;
//-------------------------------------------------------------------------
// HW Initialization for 8190 MPT.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// SW Initialization for 8190 MP.
//-------------------------------------------------------------------------
pMptCtx->bMptDrvUnload = _FALSE;
pMptCtx->bMassProdTest = _FALSE;
pMptCtx->bMptIndexEven = _TRUE; //default gain index is -6.0db
pMptCtx->h2cReqNum = 0x0;
/* Init mpt event. */
#if 0 // for Windows
NdisInitializeEvent( &(pMptCtx->MptWorkItemEvent) );
NdisAllocateSpinLock( &(pMptCtx->MptWorkItemSpinLock) );
PlatformInitializeWorkItem(
Adapter,
&(pMptCtx->MptWorkItem),
(RT_WORKITEM_CALL_BACK)MPT_WorkItemCallback,
(PVOID)Adapter,
"MptWorkItem");
#endif
//init for BT MP
#ifdef CONFIG_RTL8723A
pMptCtx->bMPh2c_timeout = _FALSE;
pMptCtx->MptH2cRspEvent = _FALSE;
pMptCtx->MptBtC2hEvent = _FALSE;
_rtw_init_sema(&pMptCtx->MPh2c_Sema, 0);
_init_timer( &pMptCtx->MPh2c_timeout_timer, pAdapter->pnetdev, MPh2c_timeout_handle, pAdapter );
//before the reset bt patch command,set the wifi page 0's IO to BT mac reboot.
#endif
pMptCtx->bMptWorkItemInProgress = _FALSE;
pMptCtx->CurrMptAct = NULL;
//-------------------------------------------------------------------------
#if 1
// Don't accept any packets
rtw_write32(pAdapter, REG_RCR, 0);
#else
// Accept CRC error and destination address
//pHalData->ReceiveConfig |= (RCR_ACRC32|RCR_AAP);
//rtw_write32(pAdapter, REG_RCR, pHalData->ReceiveConfig);
rtw_write32(pAdapter, REG_RCR, 0x70000101);
#endif
#if 0
// If EEPROM or EFUSE is empty,we assign as RF 2T2R for MP.
if (pHalData->AutoloadFailFlag == TRUE)
{
pHalData->RF_Type = RF_2T2R;
}
#endif
//ledsetting = rtw_read32(pAdapter, REG_LEDCFG0);
//rtw_write32(pAdapter, REG_LEDCFG0, ledsetting & ~LED0DIS);
if(IS_HARDWARE_TYPE_8192DU(pAdapter))
{
rtw_write32(pAdapter, REG_LEDCFG0, 0x8888);
}
else
{
//rtw_write32(pAdapter, REG_LEDCFG0, 0x08080);
ledsetting = rtw_read32(pAdapter, REG_LEDCFG0);
#if defined (CONFIG_RTL8192C) || defined( CONFIG_RTL8192D )
rtw_write32(pAdapter, REG_LEDCFG0, ledsetting & ~LED0DIS);
#endif
}
PHY_IQCalibrate(pAdapter, _FALSE);
dm_CheckTXPowerTracking(&pHalData->odmpriv); //trigger thermal meter
PHY_LCCalibrate(pAdapter);
#ifdef CONFIG_PCI_HCI
PHY_SetRFPathSwitch(pAdapter, 1/*pHalData->bDefaultAntenna*/); //Wifi default use Main
#else
#ifdef CONFIG_RTL8192C
if (pHalData->BoardType == BOARD_MINICARD)
PHY_SetRFPathSwitch(pAdapter, 1/*pHalData->bDefaultAntenna*/); //default use Main
#endif
#endif
pMptCtx->backup0xc50 = (u1Byte)PHY_QueryBBReg(pAdapter, rOFDM0_XAAGCCore1, bMaskByte0);
pMptCtx->backup0xc58 = (u1Byte)PHY_QueryBBReg(pAdapter, rOFDM0_XBAGCCore1, bMaskByte0);
pMptCtx->backup0xc30 = (u1Byte)PHY_QueryBBReg(pAdapter, rOFDM0_RxDetector1, bMaskByte0);
#ifdef CONFIG_RTL8188E
pMptCtx->backup0x52_RF_A = (u1Byte)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0);
pMptCtx->backup0x52_RF_B = (u1Byte)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0);
#endif
//set ant to wifi side in mp mode
#ifdef CONFIG_RTL8723A
rtl8723a_InitAntenna_Selection(pAdapter);
#endif //CONFIG_RTL8723A
//set ant to wifi side in mp mode
rtw_write16(pAdapter, 0x870, 0x300);
rtw_write16(pAdapter, 0x860, 0x110);
if (pAdapter->registrypriv.mp_mode == 1)
pmlmepriv->fw_state = WIFI_MP_STATE;
return rtStatus;
}
/*-----------------------------------------------------------------------------
* Function: MPT_DeInitAdapter()
*
* Overview: Extra DeInitialization for Mass Production Test.
*
* Input: PADAPTER pAdapter
*
* Output: NONE
*
* Return: NONE
*
* Revised History:
* When Who Remark
* 05/08/2007 MHC Create Version 0.
* 05/18/2007 MHC Add normal driver MPHalt code.
*
*---------------------------------------------------------------------------*/
VOID
MPT_DeInitAdapter(
IN PADAPTER pAdapter
)
{
PMPT_CONTEXT pMptCtx = &pAdapter->mppriv.MptCtx;
pMptCtx->bMptDrvUnload = _TRUE;
#ifdef CONFIG_RTL8723A
_rtw_free_sema(&(pMptCtx->MPh2c_Sema));
_cancel_timer_ex( &pMptCtx->MPh2c_timeout_timer);
rtw_write32(pAdapter, 0xcc, (rtw_read32(pAdapter, 0xcc)& 0xFFFFFFFD)| 0x00000002);
rtw_write32(pAdapter, 0x6b, (rtw_read32(pAdapter, 0x6b)& 0xFFFFFFFB));
rtw_msleep_os(500);
rtw_write32(pAdapter, 0x6b, (rtw_read32(pAdapter, 0x6b)& 0xFFFFFFFB)| 0x00000004);
rtw_write32(pAdapter, 0xcc, (rtw_read32(pAdapter, 0xcc)& 0xFFFFFFFD));
rtw_msleep_os(1000);
DBG_871X("_rtw_mp_xmit_priv reinit for normal mode\n");
_rtw_mp_xmit_priv(&pAdapter->xmitpriv);
#endif
#if 0 // for Windows
PlatformFreeWorkItem( &(pMptCtx->MptWorkItem) );
while(pMptCtx->bMptWorkItemInProgress)
{
if(NdisWaitEvent(&(pMptCtx->MptWorkItemEvent), 50))
{
break;
}
}
NdisFreeSpinLock( &(pMptCtx->MptWorkItemSpinLock) );
#endif
}
static u8 mpt_ProStartTest(PADAPTER padapter)
{
PMPT_CONTEXT pMptCtx = &padapter->mppriv.MptCtx;
pMptCtx->bMassProdTest = _TRUE;
pMptCtx->bStartContTx = _FALSE;
pMptCtx->bCckContTx = _FALSE;
pMptCtx->bOfdmContTx = _FALSE;
pMptCtx->bSingleCarrier = _FALSE;
pMptCtx->bCarrierSuppression = _FALSE;
pMptCtx->bSingleTone = _FALSE;
return _SUCCESS;
}
/*
* General use
*/
s32 SetPowerTracking(PADAPTER padapter, u8 enable)
{
Hal_SetPowerTracking( padapter, enable );
return 0;
}
void GetPowerTracking(PADAPTER padapter, u8 *enable)
{
Hal_GetPowerTracking( padapter, enable );
}
static void disable_dm(PADAPTER padapter)
{
#ifndef CONFIG_RTL8723A
u8 v8;
#endif
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
struct dm_priv *pdmpriv = &pHalData->dmpriv;
//3 1. disable firmware dynamic mechanism
// disable Power Training, Rate Adaptive
#ifdef CONFIG_RTL8723A
SetBcnCtrlReg(padapter, 0, EN_BCN_FUNCTION);
#else
v8 = rtw_read8(padapter, REG_BCN_CTRL);
v8 &= ~EN_BCN_FUNCTION;
rtw_write8(padapter, REG_BCN_CTRL, v8);
#endif
//3 2. disable driver dynamic mechanism
// disable Dynamic Initial Gain
// disable High Power
// disable Power Tracking
Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, _FALSE);
// enable APK, LCK and IQK but disable power tracking
#ifndef CONFIG_RTL8188E
pdmpriv->TxPowerTrackControl = _FALSE;
#endif
Switch_DM_Func(padapter, DYNAMIC_RF_CALIBRATION, _TRUE);
}
void MPT_PwrCtlDM(PADAPTER padapter, u32 bstart)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
struct dm_priv *pdmpriv = &pHalData->dmpriv;
//Switch_DM_Func(padapter, DYNAMIC_RF_CALIBRATION, bstart);
if (bstart==1){
DBG_871X("in MPT_PwrCtlDM start \n");
Switch_DM_Func(padapter, DYNAMIC_RF_TX_PWR_TRACK, _TRUE);
pdmpriv->InitODMFlag |= ODM_RF_TX_PWR_TRACK ;
pdmpriv->InitODMFlag |= ODM_RF_CALIBRATION ;
pdmpriv->TxPowerTrackControl = _TRUE;
}else{
DBG_871X("in MPT_PwrCtlDM stop \n");
disable_dm(padapter);
pdmpriv->TxPowerTrackControl = _FALSE;
}
}
//This function initializes the DUT to the MP test mode
s32 mp_start_test(PADAPTER padapter)
{
WLAN_BSSID_EX bssid;
struct sta_info *psta;
u32 length;
u8 val8;
_irqL irqL;
s32 res = _SUCCESS;
struct mp_priv *pmppriv = &padapter->mppriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
padapter->registrypriv.mp_mode = 1;
pmppriv->bSetTxPower=0; //for manually set tx power
//3 disable dynamic mechanism
disable_dm(padapter);
//3 0. update mp_priv
if (padapter->registrypriv.rf_config == RF_819X_MAX_TYPE) {
// switch (phal->rf_type) {
switch (GET_RF_TYPE(padapter)) {
case RF_1T1R:
pmppriv->antenna_tx = ANTENNA_A;
pmppriv->antenna_rx = ANTENNA_A;
break;
case RF_1T2R:
default:
pmppriv->antenna_tx = ANTENNA_A;
pmppriv->antenna_rx = ANTENNA_AB;
break;
case RF_2T2R:
case RF_2T2R_GREEN:
pmppriv->antenna_tx = ANTENNA_AB;
pmppriv->antenna_rx = ANTENNA_AB;
break;
case RF_2T4R:
pmppriv->antenna_tx = ANTENNA_AB;
pmppriv->antenna_rx = ANTENNA_ABCD;
break;
}
}
mpt_ProStartTest(padapter);
//3 1. initialize a new WLAN_BSSID_EX
// _rtw_memset(&bssid, 0, sizeof(WLAN_BSSID_EX));
_rtw_memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN);
bssid.Ssid.SsidLength = strlen("mp_pseudo_adhoc");
_rtw_memcpy(bssid.Ssid.Ssid, (u8*)"mp_pseudo_adhoc", bssid.Ssid.SsidLength);
bssid.InfrastructureMode = Ndis802_11IBSS;
bssid.NetworkTypeInUse = Ndis802_11DS;
bssid.IELength = 0;
length = get_WLAN_BSSID_EX_sz(&bssid);
if (length % 4)
bssid.Length = ((length >> 2) + 1) << 2; //round up to multiple of 4 bytes.
else
bssid.Length = length;
_enter_critical_bh(&pmlmepriv->lock, &irqL);
if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == _TRUE)
goto end_of_mp_start_test;
//init mp_start_test status
if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) {
rtw_disassoc_cmd(padapter, 500, _TRUE);
rtw_indicate_disconnect(padapter);
rtw_free_assoc_resources(padapter, 1);
}
pmppriv->prev_fw_state = get_fwstate(pmlmepriv);
if (padapter->registrypriv.mp_mode == 1)
pmlmepriv->fw_state = WIFI_MP_STATE;
#if 0
if (pmppriv->mode == _LOOPBOOK_MODE_) {
set_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE); //append txdesc
RT_TRACE(_module_mp_, _drv_notice_, ("+start mp in Lookback mode\n"));
} else {
RT_TRACE(_module_mp_, _drv_notice_, ("+start mp in normal mode\n"));
}
#endif
set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
//3 2. create a new psta for mp driver
//clear psta in the cur_network, if any
psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress);
if (psta) rtw_free_stainfo(padapter, psta);
psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress);
if (psta == NULL) {
RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n"));
pmlmepriv->fw_state = pmppriv->prev_fw_state;
res = _FAIL;
goto end_of_mp_start_test;
}
//3 3. join psudo AdHoc
tgt_network->join_res = 1;
tgt_network->aid = psta->aid = 1;
_rtw_memcpy(&tgt_network->network, &bssid, length);
rtw_indicate_connect(padapter);
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
end_of_mp_start_test:
_exit_critical_bh(&pmlmepriv->lock, &irqL);
if (res == _SUCCESS)
{
// set MSR to WIFI_FW_ADHOC_STATE
#if !defined (CONFIG_RTL8712)
val8 = rtw_read8(padapter, MSR) & 0xFC; // 0x0102
val8 |= WIFI_FW_ADHOC_STATE;
rtw_write8(padapter, MSR, val8); // Link in ad hoc network
#endif
#if defined (CONFIG_RTL8712)
rtw_write8(padapter, MSR, 1); // Link in ad hoc network
rtw_write8(padapter, RCR, 0); // RCR : disable all pkt, 0x10250048
rtw_write8(padapter, RCR+2, 0x57); // RCR disable Check BSSID, 0x1025004a
// disable RX filter map , mgt frames will put in RX FIFO 0
rtw_write16(padapter, RXFLTMAP0, 0x0); // 0x10250116
val8 = rtw_read8(padapter, EE_9346CR); // 0x1025000A
if (!(val8 & _9356SEL))//boot from EFUSE
efuse_change_max_size(padapter);
#endif
}
return res;
}
//------------------------------------------------------------------------------
//This function change the DUT from the MP test mode into normal mode
void mp_stop_test(PADAPTER padapter)
{
struct mp_priv *pmppriv = &padapter->mppriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
struct sta_info *psta;
_irqL irqL;
if(pmppriv->mode==MP_ON)
{
pmppriv->bSetTxPower=0;
_enter_critical_bh(&pmlmepriv->lock, &irqL);
if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == _FALSE)
goto end_of_mp_stop_test;
//3 1. disconnect psudo AdHoc
rtw_indicate_disconnect(padapter);
//3 2. clear psta used in mp test mode.
// rtw_free_assoc_resources(padapter, 1);
psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress);
if (psta) rtw_free_stainfo(padapter, psta);
//3 3. return to normal state (default:station mode)
pmlmepriv->fw_state = pmppriv->prev_fw_state; // WIFI_STATION_STATE;
//flush the cur_network
_rtw_memset(tgt_network, 0, sizeof(struct wlan_network));
_clr_fwstate_(pmlmepriv, WIFI_MP_STATE);
end_of_mp_stop_test:
_exit_critical_bh(&pmlmepriv->lock, &irqL);
}
}
/*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/
#if 0
//#ifdef CONFIG_USB_HCI
static VOID mpt_AdjustRFRegByRateByChan92CU(PADAPTER pAdapter, u8 RateIdx, u8 Channel, u8 BandWidthID)
{
u8 eRFPath;
u32 rfReg0x26;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
if (RateIdx < MPT_RATE_6M) { // CCK rate,for 88cu
rfReg0x26 = 0xf400;
}
else if ((RateIdx >= MPT_RATE_6M) && (RateIdx <= MPT_RATE_54M)) {// OFDM rate,for 88cu
if ((4 == Channel) || (8 == Channel) || (12 == Channel))
rfReg0x26 = 0xf000;
else if ((5 == Channel) || (7 == Channel) || (13 == Channel) || (14 == Channel))
rfReg0x26 = 0xf400;
else
rfReg0x26 = 0x4f200;
}
else if ((RateIdx >= MPT_RATE_MCS0) && (RateIdx <= MPT_RATE_MCS15)) {// MCS 20M ,for 88cu // MCS40M rate,for 88cu
if (HT_CHANNEL_WIDTH_20 == BandWidthID) {
if ((4 == Channel) || (8 == Channel))
rfReg0x26 = 0xf000;
else if ((5 == Channel) || (7 == Channel) || (13 == Channel) || (14 == Channel))
rfReg0x26 = 0xf400;
else
rfReg0x26 = 0x4f200;
}
else{
if ((4 == Channel) || (8 == Channel))
rfReg0x26 = 0xf000;
else if ((5 == Channel) || (7 == Channel))
rfReg0x26 = 0xf400;
else
rfReg0x26 = 0x4f200;
}
}
// RT_TRACE(COMP_CMD, DBG_LOUD, ("\n mpt_AdjustRFRegByRateByChan92CU():Chan:%d Rate=%d rfReg0x26:0x%08x\n",Channel, RateIdx,rfReg0x26));
for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) {
write_rfreg(pAdapter, eRFPath, RF_SYN_G2, rfReg0x26);
}
}
#endif
/*-----------------------------------------------------------------------------
* Function: mpt_SwitchRfSetting
*
* Overview: Change RF Setting when we siwthc channel/rate/BW for MP.
*
* Input: IN PADAPTER pAdapter
*
* Output: NONE
*
* Return: NONE
*
* Revised History:
* When Who Remark
* 01/08/2009 MHC Suggestion from SD3 Willis for 92S series.
* 01/09/2009 MHC Add CCK modification for 40MHZ. Suggestion from SD3.
*
*---------------------------------------------------------------------------*/
static void mpt_SwitchRfSetting(PADAPTER pAdapter)
{
Hal_mpt_SwitchRfSetting(pAdapter);
}
/*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/
/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/
static void MPT_CCKTxPowerAdjust(PADAPTER Adapter, BOOLEAN bInCH14)
{
Hal_MPT_CCKTxPowerAdjust(Adapter,bInCH14);
}
static void MPT_CCKTxPowerAdjustbyIndex(PADAPTER pAdapter, BOOLEAN beven)
{
Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter,beven);
}
/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/
/*
* SetChannel
* Description
* Use H2C command to change channel,
* not only modify rf register, but also other setting need to be done.
*/
void SetChannel(PADAPTER pAdapter)
{
Hal_SetChannel(pAdapter);
}
/*
* Notice
* Switch bandwitdth may change center frequency(channel)
*/
void SetBandwidth(PADAPTER pAdapter)
{
Hal_SetBandwidth(pAdapter);
}
static void SetCCKTxPower(PADAPTER pAdapter, u8 *TxPower)
{
Hal_SetCCKTxPower(pAdapter,TxPower);
}
static void SetOFDMTxPower(PADAPTER pAdapter, u8 *TxPower)
{
Hal_SetOFDMTxPower(pAdapter,TxPower);
}
void SetAntenna(PADAPTER pAdapter)
{
Hal_SetAntenna(pAdapter);
}
void SetAntennaPathPower(PADAPTER pAdapter)
{
Hal_SetAntennaPathPower(pAdapter);
}
void SetTxPower(PADAPTER pAdapter)
{
Hal_SetTxPower(pAdapter);
}
void SetTxAGCOffset(PADAPTER pAdapter, u32 ulTxAGCOffset)
{
u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D,tmpAGC;
TxAGCOffset_B = (ulTxAGCOffset&0x000000ff);
TxAGCOffset_C = ((ulTxAGCOffset&0x0000ff00)>>8);
TxAGCOffset_D = ((ulTxAGCOffset&0x00ff0000)>>16);
tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B);
write_bbreg(pAdapter, rFPGA0_TxGainStage,
(bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC);
}
void SetDataRate(PADAPTER pAdapter)
{
Hal_SetDataRate(pAdapter);
}
void MP_PHY_SetRFPathSwitch(PADAPTER pAdapter ,BOOLEAN bMain)
{
PHY_SetRFPathSwitch(pAdapter,bMain);
}
#if defined (CONFIG_RTL8712)
/*------------------------------Define structure----------------------------*/
typedef struct _R_ANTENNA_SELECT_OFDM {
u32 r_tx_antenna:4;
u32 r_ant_l:4;
u32 r_ant_non_ht:4;
u32 r_ant_ht1:4;
u32 r_ant_ht2:4;
u32 r_ant_ht_s1:4;
u32 r_ant_non_ht_s1:4;
u32 OFDM_TXSC:2;
u32 Reserved:2;
}R_ANTENNA_SELECT_OFDM;
typedef struct _R_ANTENNA_SELECT_CCK {
u8 r_cckrx_enable_2:2;
u8 r_cckrx_enable:2;
u8 r_ccktx_enable:4;
}R_ANTENNA_SELECT_CCK;
#endif
s32 SetThermalMeter(PADAPTER pAdapter, u8 target_ther)
{
return Hal_SetThermalMeter( pAdapter, target_ther);
}
static void TriggerRFThermalMeter(PADAPTER pAdapter)
{
Hal_TriggerRFThermalMeter(pAdapter);
}
static u8 ReadRFThermalMeter(PADAPTER pAdapter)
{
return Hal_ReadRFThermalMeter(pAdapter);
}
void GetThermalMeter(PADAPTER pAdapter, u8 *value)
{
Hal_GetThermalMeter(pAdapter,value);
}
void SetSingleCarrierTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetSingleCarrierTx(pAdapter,bStart);
}
void SetSingleToneTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetSingleToneTx(pAdapter,bStart);
}
void SetCarrierSuppressionTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetCarrierSuppressionTx(pAdapter, bStart);
}
void SetCCKContinuousTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetCCKContinuousTx(pAdapter,bStart);
}
void SetOFDMContinuousTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetOFDMContinuousTx( pAdapter, bStart);
}/* mpt_StartOfdmContTx */
void SetContinuousTx(PADAPTER pAdapter, u8 bStart)
{
PhySetTxPowerLevel(pAdapter);
Hal_SetContinuousTx(pAdapter,bStart);
}
void PhySetTxPowerLevel(PADAPTER pAdapter)
{
struct mp_priv *pmp_priv = &pAdapter->mppriv;
if (pmp_priv->bSetTxPower==0) // for NO manually set power index
{
#ifdef CONFIG_RTL8188E
PHY_SetTxPowerLevel8188E(pAdapter,pmp_priv->channel);
#elif defined(CONFIG_RTL8192D)
PHY_SetTxPowerLevel8192D(pAdapter,pmp_priv->channel);
#else
PHY_SetTxPowerLevel8192C(pAdapter,pmp_priv->channel);
#endif
}
}
//------------------------------------------------------------------------------
static void dump_mpframe(PADAPTER padapter, struct xmit_frame *pmpframe)
{
rtw_hal_mgnt_xmit(padapter, pmpframe);
}
static struct xmit_frame *alloc_mp_xmitframe(struct xmit_priv *pxmitpriv)
{
struct xmit_frame *pmpframe;
struct xmit_buf *pxmitbuf;
if ((pmpframe = rtw_alloc_xmitframe(pxmitpriv)) == NULL)
{
return NULL;
}
if ((pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv)) == NULL)
{
rtw_free_xmitframe(pxmitpriv, pmpframe);
return NULL;
}
pmpframe->frame_tag = MP_FRAMETAG;
pmpframe->pxmitbuf = pxmitbuf;
pmpframe->buf_addr = pxmitbuf->pbuf;
pxmitbuf->priv_data = pmpframe;
return pmpframe;
}
static thread_return mp_xmit_packet_thread(thread_context context)
{
struct xmit_frame *pxmitframe;
struct mp_tx *pmptx;
struct mp_priv *pmp_priv;
struct xmit_priv *pxmitpriv;
PADAPTER padapter;
pmp_priv = (struct mp_priv *)context;
pmptx = &pmp_priv->tx;
padapter = pmp_priv->papdater;
pxmitpriv = &(padapter->xmitpriv);
thread_enter("RTW_MP_THREAD");
//DBG_871X("%s:pkTx Start\n", __func__);
while (1) {
pxmitframe = alloc_mp_xmitframe(pxmitpriv);
if (pxmitframe == NULL) {
if (pmptx->stop ||
padapter->bSurpriseRemoved ||
padapter->bDriverStopped) {
goto exit;
}
else {
rtw_msleep_os(1);
continue;
}
}
_rtw_memcpy((u8 *)(pxmitframe->buf_addr+TXDESC_OFFSET), pmptx->buf, pmptx->write_size);
_rtw_memcpy(&(pxmitframe->attrib), &(pmptx->attrib), sizeof(struct pkt_attrib));
dump_mpframe(padapter, pxmitframe);
pmptx->sended++;
pmp_priv->tx_pktcount++;
if (pmptx->stop ||
padapter->bSurpriseRemoved ||
padapter->bDriverStopped)
goto exit;
if ((pmptx->count != 0) &&
(pmptx->count == pmptx->sended))
goto exit;
flush_signals_thread();
}
exit:
//DBG_871X("%s:pkTx Exit\n", __func__);
rtw_mfree(pmptx->pallocated_buf, pmptx->buf_size);
pmptx->pallocated_buf = NULL;
pmptx->stop = 1;
thread_exit();
}
void fill_txdesc_for_mp(PADAPTER padapter, struct tx_desc *ptxdesc)
{
struct mp_priv *pmp_priv = &padapter->mppriv;
_rtw_memcpy(ptxdesc, &(pmp_priv->tx.desc), TXDESC_SIZE);
}
void SetPacketTx(PADAPTER padapter)
{
u8 *ptr, *pkt_start, *pkt_end;
u32 pkt_size,offset;
struct tx_desc *desc;
struct rtw_ieee80211_hdr *hdr;
u8 payload;
s32 bmcast;
struct pkt_attrib *pattrib;
struct mp_priv *pmp_priv;
pmp_priv = &padapter->mppriv;
if (pmp_priv->tx.stop) return;
pmp_priv->tx.sended = 0;
pmp_priv->tx.stop = 0;
pmp_priv->tx_pktcount = 0;
//3 1. update_attrib()
pattrib = &pmp_priv->tx.attrib;
_rtw_memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN);
_rtw_memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
_rtw_memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
bmcast = IS_MCAST(pattrib->ra);
if (bmcast) {
pattrib->mac_id = 1;
pattrib->psta = rtw_get_bcmc_stainfo(padapter);
} else {
pattrib->mac_id = 0;
pattrib->psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
}
pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->pktlen;
//3 2. allocate xmit buffer
pkt_size = pattrib->last_txcmdsz;
if (pmp_priv->tx.pallocated_buf)
rtw_mfree(pmp_priv->tx.pallocated_buf, pmp_priv->tx.buf_size);
pmp_priv->tx.write_size = pkt_size;
pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ;
pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size);
if (pmp_priv->tx.pallocated_buf == NULL) {
DBG_871X("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size);
return;
}
pmp_priv->tx.buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pmp_priv->tx.pallocated_buf), XMITBUF_ALIGN_SZ);
ptr = pmp_priv->tx.buf;
desc = &(pmp_priv->tx.desc);
_rtw_memset(desc, 0, TXDESC_SIZE);
pkt_start = ptr;
pkt_end = pkt_start + pkt_size;
//3 3. init TX descriptor
// offset 0
#if defined(CONFIG_RTL8188E) && !defined(CONFIG_RTL8188E_SDIO)
desc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
desc->txdw0 |= cpu_to_le32(pkt_size & 0x0000FFFF); // packet size
desc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00FF0000); //32 bytes for TX Desc
if (bmcast) desc->txdw0 |= cpu_to_le32(BMC); // broadcast packet
desc->txdw1 |= cpu_to_le32((0x01 << 26) & 0xff000000);
#endif
// offset 4
#ifndef CONFIG_RTL8188E
desc->txdw1 |= cpu_to_le32(BK); // don't aggregate(AMPDU)
desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x1F); //CAM_ID(MAC_ID)
#else
desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); //CAM_ID(MAC_ID)
#endif
desc->txdw1 |= cpu_to_le32((pattrib->qsel << QSEL_SHT) & 0x00001F00); // Queue Select, TID
#ifdef CONFIG_RTL8188E
desc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); // Rate Adaptive ID
#else
desc->txdw1 |= cpu_to_le32((pattrib->raid << Rate_ID_SHT) & 0x000F0000); // Rate Adaptive ID
#endif
// offset 8
// desc->txdw2 |= cpu_to_le32(AGG_BK);//AGG BK
// offset 12
desc->txdw3 |= cpu_to_le32((pattrib->seqnum<<16)&0x0fff0000);
// desc->txdw3 |= cpu_to_le32((pattrib->seqnum & 0xFFF) << SEQ_SHT);
//desc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0xffff0000);
// offset 16
//desc->txdw4 |= cpu_to_le32(QoS)
#ifdef CONFIG_RTL8188E
desc->txdw4 |= cpu_to_le32(HW_SSN);
#else
desc->txdw4 |= cpu_to_le32(HW_SEQ_EN);
#endif
desc->txdw4 |= cpu_to_le32(USERATE);
desc->txdw4 |= cpu_to_le32(DISDATAFB);
if( pmp_priv->preamble ){
if (pmp_priv->rateidx <= MPT_RATE_54M)
desc->txdw4 |= cpu_to_le32(DATA_SHORT); // CCK Short Preamble
}
if (pmp_priv->bandwidth == HT_CHANNEL_WIDTH_40)
desc->txdw4 |= cpu_to_le32(DATA_BW);
// offset 20
desc->txdw5 |= cpu_to_le32(pmp_priv->rateidx & 0x0000001F);
if( pmp_priv->preamble ){
if (pmp_priv->rateidx > MPT_RATE_54M)
desc->txdw5 |= cpu_to_le32(SGI); // MCS Short Guard Interval
}
#ifdef CONFIG_RTL8188E
desc->txdw5 |= cpu_to_le32(RTY_LMT_EN); // retry limit enable
desc->txdw5 |= cpu_to_le32(0x00180000); // DATA/RTS Rate Fallback Limit
#else
desc->txdw5 |= cpu_to_le32(0x0001FF00); // DATA/RTS Rate Fallback Limit
#endif
//3 4. make wlan header, make_wlanhdr()
hdr = (struct rtw_ieee80211_hdr *)pkt_start;
SetFrameSubType(&hdr->frame_ctl, pattrib->subtype);
_rtw_memcpy(hdr->addr1, pattrib->dst, ETH_ALEN); // DA
_rtw_memcpy(hdr->addr2, pattrib->src, ETH_ALEN); // SA
_rtw_memcpy(hdr->addr3, get_bssid(&padapter->mlmepriv), ETH_ALEN); // RA, BSSID
//3 5. make payload
ptr = pkt_start + pattrib->hdrlen;
switch (pmp_priv->tx.payload) {
case 0:
payload = 0x00;
break;
case 1:
payload = 0x5a;
break;
case 2:
payload = 0xa5;
break;
case 3:
payload = 0xff;
break;
default:
payload = 0x00;
break;
}
_rtw_memset(ptr, payload, pkt_end - ptr);
//3 6. start thread
#ifdef PLATFORM_LINUX
pmp_priv->tx.PktTxThread = kthread_run(mp_xmit_packet_thread, pmp_priv, "RTW_MP_THREAD");
if (IS_ERR(pmp_priv->tx.PktTxThread))
DBG_871X("Create PktTx Thread Fail !!!!!\n");
#endif
#ifdef PLATFORM_FREEBSD
{
struct proc *p;
struct thread *td;
pmp_priv->tx.PktTxThread = kproc_kthread_add(mp_xmit_packet_thread, pmp_priv,
&p, &td, RFHIGHPID, 0, "MPXmitThread", "MPXmitThread");
if (pmp_priv->tx.PktTxThread < 0)
DBG_871X("Create PktTx Thread Fail !!!!!\n");
}
#endif
}
void SetPacketRx(PADAPTER pAdapter, u8 bStartRx)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
if(bStartRx)
{
#ifdef CONFIG_RTL8723A
rtl8723a_InitAntenna_Selection(pAdapter);
#endif //CONFIG_RTL8723A
// Accept CRC error and destination address
#if 1
//ndef CONFIG_RTL8723A
pHalData->ReceiveConfig = AAP | APM | AM | AB | APP_ICV | ADF | AMF | HTC_LOC_CTRL | APP_MIC | APP_PHYSTS;
pHalData->ReceiveConfig |= ACRC32;
rtw_write32(pAdapter, REG_RCR, pHalData->ReceiveConfig);
// Accept all data frames
rtw_write16(pAdapter, REG_RXFLTMAP2, 0xFFFF);
#else
rtw_write32(pAdapter, REG_RCR, 0x70000101);
#endif
}
else
{
rtw_write32(pAdapter, REG_RCR, 0);
}
}
void ResetPhyRxPktCount(PADAPTER pAdapter)
{
u32 i, phyrx_set = 0;
for (i = 0; i <= 0xF; i++) {
phyrx_set = 0;
phyrx_set |= _RXERR_RPT_SEL(i); //select
phyrx_set |= RXERR_RPT_RST; // set counter to zero
rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set);
}
}
static u32 GetPhyRxPktCounts(PADAPTER pAdapter, u32 selbit)
{
//selection
u32 phyrx_set = 0, count = 0;
phyrx_set = _RXERR_RPT_SEL(selbit & 0xF);
rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set);
//Read packet count
count = rtw_read32(pAdapter, REG_RXERR_RPT) & RXERR_COUNTER_MASK;
return count;
}
u32 GetPhyRxPktReceived(PADAPTER pAdapter)
{
u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_OK);
CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_OK);
HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_OK);
return OFDM_cnt + CCK_cnt + HT_cnt;
}
u32 GetPhyRxPktCRC32Error(PADAPTER pAdapter)
{
u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_FAIL);
CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_FAIL);
HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_FAIL);
return OFDM_cnt + CCK_cnt + HT_cnt;
}
//reg 0x808[9:0]: FFT data x
//reg 0x808[22]: 0 --> 1 to get 1 FFT data y
//reg 0x8B4[15:0]: FFT data y report
static u32 rtw_GetPSDData(PADAPTER pAdapter, u32 point)
{
int psd_val;
psd_val = rtw_read32(pAdapter, 0x808);
psd_val &= 0xFFBFFC00;
psd_val |= point;
rtw_write32(pAdapter, 0x808, psd_val);
rtw_mdelay_os(1);
psd_val |= 0x00400000;
rtw_write32(pAdapter, 0x808, psd_val);
rtw_mdelay_os(1);
psd_val = rtw_read32(pAdapter, 0x8B4);
psd_val &= 0x0000FFFF;
return psd_val;
}
/*
* pts start_point_min stop_point_max
* 128 64 64 + 128 = 192
* 256 128 128 + 256 = 384
* 512 256 256 + 512 = 768
* 1024 512 512 + 1024 = 1536
*
*/
u32 mp_query_psd(PADAPTER pAdapter, u8 *data)
{
u32 i, psd_pts=0, psd_start=0, psd_stop=0;
u32 psd_data=0;
#ifdef PLATFORM_LINUX
if (!netif_running(pAdapter->pnetdev)) {
RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! interface not opened!\n"));
return 0;
}
#endif
if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == _FALSE) {
RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! not in MP mode!\n"));
return 0;
}
if (strlen(data) == 0) { //default value
psd_pts = 128;
psd_start = 64;
psd_stop = 128;
} else {
sscanf(data, "pts=%d,start=%d,stop=%d", &psd_pts, &psd_start, &psd_stop);
}
_rtw_memset(data, '\0', sizeof(data));
i = psd_start;
while (i < psd_stop)
{
if (i >= psd_pts) {
psd_data = rtw_GetPSDData(pAdapter, i-psd_pts);
} else {
psd_data = rtw_GetPSDData(pAdapter, i);
}
sprintf(data, "%s%x ", data, psd_data);
i++;
}
#ifdef CONFIG_LONG_DELAY_ISSUE
rtw_msleep_os(100);
#else
rtw_mdelay_os(100);
#endif
return strlen(data)+1;
}
void _rtw_mp_xmit_priv (struct xmit_priv *pxmitpriv)
{
int i,res;
_adapter *padapter = pxmitpriv->adapter;
struct xmit_frame *pxmitframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf;
struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
if(padapter->registrypriv.mp_mode ==0)
{
max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
num_xmit_extbuf = NR_XMIT_EXTBUFF;
}
else
{
max_xmit_extbuf_size = 6000;
num_xmit_extbuf = 8;
}
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
for(i=0; i<num_xmit_extbuf; i++)
{
rtw_os_xmit_resource_free(padapter, pxmitbuf,(max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
pxmitbuf++;
}
if(pxmitpriv->pallocated_xmit_extbuf) {
rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
}
if(padapter->registrypriv.mp_mode ==0)
{
max_xmit_extbuf_size = 6000;
num_xmit_extbuf = 8;
}
else
{
max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
num_xmit_extbuf = NR_XMIT_EXTBUFF;
}
// Init xmit extension buff
_rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
if (pxmitpriv->pallocated_xmit_extbuf == NULL){
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("alloc xmit_extbuf fail!\n"));
res= _FAIL;
goto exit;
}
pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_xmit_extbuf), 4);
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
for (i = 0; i < num_xmit_extbuf; i++)
{
_rtw_init_listhead(&pxmitbuf->list);
pxmitbuf->priv_data = NULL;
pxmitbuf->padapter = padapter;
pxmitbuf->ext_tag = _TRUE;
/*
pxmitbuf->pallocated_buf = rtw_zmalloc(max_xmit_extbuf_size);
if (pxmitbuf->pallocated_buf == NULL)
{
res = _FAIL;
goto exit;
}
pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), 4);
*/
if((res=rtw_os_xmit_resource_alloc(padapter, pxmitbuf,max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)) == _FAIL) {
res= _FAIL;
goto exit;
}
#if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
pxmitbuf->phead = pxmitbuf->pbuf;
pxmitbuf->pend = pxmitbuf->pbuf + max_xmit_extbuf_size;
pxmitbuf->len = 0;
pxmitbuf->pdata = pxmitbuf->ptail = pxmitbuf->phead;
#endif
rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue));
#ifdef DBG_XMIT_BUF_EXT
pxmitbuf->no=i;
#endif
pxmitbuf++;
}
pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
exit:
;
}
void Hal_ProSetCrystalCap (PADAPTER pAdapter , u32 CrystalCapVal)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
CrystalCapVal = CrystalCapVal & 0x3F;
if(IS_HARDWARE_TYPE_8192D(pAdapter))
{
PHY_SetBBReg(pAdapter, REG_AFE_XTAL_CTRL, 0xF0, CrystalCapVal & 0x0F);
PHY_SetBBReg(pAdapter, REG_AFE_PLL_CTRL, 0xF0000000, (CrystalCapVal & 0xF0) >> 4);
}
else if(IS_HARDWARE_TYPE_8188E(pAdapter))
{
// write 0x24[16:11] = 0x24[22:17] = CrystalCap
PHY_SetBBReg(pAdapter, REG_AFE_XTAL_CTRL, 0x7FF800, (CrystalCapVal | (CrystalCapVal << 6)));
}
else
{
DBG_871X(" not as 88E and 92D Hal_ProSetCrystalCap 0x2c !!!!!\n");
PHY_SetBBReg(pAdapter, 0x2c, 0xFFF000, (CrystalCapVal | (CrystalCapVal << 6)));
}
}
#endif
| advx9600/kernel-rp4412 | rtl8188EUS/core/rtw_mp.c | C | gpl-2.0 | 41,919 |
/* poppler-document.cc: qt interface to poppler
* Copyright (C) 2005, 2008, 2009, 2012, 2013, Albert Astals Cid <aacid@kde.org>
* Copyright (C) 2005, Brad Hards <bradh@frogmouth.net>
* Copyright (C) 2008, 2011, Pino Toscano <pino@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poppler-qt4.h"
#include <QtCore/QString>
#include <QtCore/QDateTime>
#include "Object.h"
#include "Stream.h"
#include "Catalog.h"
#include "FileSpec.h"
#include "poppler-private.h"
#include "poppler-embeddedfile-private.h"
namespace Poppler
{
EmbeddedFileData::EmbeddedFileData(FileSpec *fs)
: filespec(fs)
{
}
EmbeddedFileData::~EmbeddedFileData()
{
delete filespec;
}
EmbFile *EmbeddedFileData::embFile() const
{
return filespec->isOk() ? filespec->getEmbeddedFile() : NULL;
}
EmbeddedFile::EmbeddedFile(EmbFile *embfile)
: m_embeddedFile(0)
{
assert(!"You must not use this private constructor!");
}
EmbeddedFile::EmbeddedFile(EmbeddedFileData &dd)
: m_embeddedFile(&dd)
{
}
EmbeddedFile::~EmbeddedFile()
{
delete m_embeddedFile;
}
QString EmbeddedFile::name() const
{
GooString *goo = m_embeddedFile->filespec->getFileName();
return goo ? UnicodeParsedString(goo) : QString();
}
QString EmbeddedFile::description() const
{
GooString *goo = m_embeddedFile->filespec->getDescription();
return goo ? UnicodeParsedString(goo) : QString();
}
int EmbeddedFile::size() const
{
return m_embeddedFile->embFile() ? m_embeddedFile->embFile()->size() : -1;
}
QDateTime EmbeddedFile::modDate() const
{
GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->modDate() : NULL;
return goo ? convertDate(goo->getCString()) : QDateTime();
}
QDateTime EmbeddedFile::createDate() const
{
GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->createDate() : NULL;
return goo ? convertDate(goo->getCString()) : QDateTime();
}
QByteArray EmbeddedFile::checksum() const
{
GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->checksum() : NULL;
return goo ? QByteArray::fromRawData(goo->getCString(), goo->getLength()) : QByteArray();
}
QString EmbeddedFile::mimeType() const
{
GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->mimeType() : NULL;
return goo ? QString(goo->getCString()) : QString();
}
QByteArray EmbeddedFile::data()
{
if (!isValid())
return QByteArray();
Stream *stream = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->stream() : NULL;
if (!stream)
return QByteArray();
stream->reset();
int dataLen = 0;
QByteArray fileArray;
int i;
while ( (i = stream->getChar()) != EOF) {
fileArray[dataLen] = (char)i;
++dataLen;
}
fileArray.resize(dataLen);
return fileArray;
}
bool EmbeddedFile::isValid() const
{
return m_embeddedFile->filespec->isOk();
}
}
| aardvarkawesome/frosted-poppler-tart | qt4/src/poppler-embeddedfile.cc | C++ | gpl-2.0 | 3,455 |
/*
* Memory merging support.
*
* This code enables dynamic sharing of identical pages found in different
* memory areas, even if they are not shared by fork()
*
* Copyright (C) 2008-2009 Red Hat, Inc.
* Authors:
* Izik Eidus
* Andrea Arcangeli
* Chris Wright
* Hugh Dickins
*
* This work is licensed under the terms of the GNU GPL, version 2.
*/
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/mman.h>
#include <linux/sched.h>
#include <linux/rwsem.h>
#include <linux/pagemap.h>
#include <linux/rmap.h>
#include <linux/spinlock.h>
#include <linux/jhash.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/rbtree.h>
#include <linux/memory.h>
#include <linux/mmu_notifier.h>
#include <linux/swap.h>
#include <linux/ksm.h>
#include <linux/hash.h>
#include <linux/freezer.h>
#include <linux/oom.h>
#include <asm/tlbflush.h>
#include "internal.h"
/*
* A few notes about the KSM scanning process,
* to make it easier to understand the data structures below:
*
* In order to reduce excessive scanning, KSM sorts the memory pages by their
* contents into a data structure that holds pointers to the pages' locations.
*
* Since the contents of the pages may change at any moment, KSM cannot just
* insert the pages into a normal sorted tree and expect it to find anything.
* Therefore KSM uses two data structures - the stable and the unstable tree.
*
* The stable tree holds pointers to all the merged pages (ksm pages), sorted
* by their contents. Because each such page is write-protected, searching on
* this tree is fully assured to be working (except when pages are unmapped),
* and therefore this tree is called the stable tree.
*
* In addition to the stable tree, KSM uses a second data structure called the
* unstable tree: this tree holds pointers to pages which have been found to
* be "unchanged for a period of time". The unstable tree sorts these pages
* by their contents, but since they are not write-protected, KSM cannot rely
* upon the unstable tree to work correctly - the unstable tree is liable to
* be corrupted as its contents are modified, and so it is called unstable.
*
* KSM solves this problem by several techniques:
*
* 1) The unstable tree is flushed every time KSM completes scanning all
* memory areas, and then the tree is rebuilt again from the beginning.
* 2) KSM will only insert into the unstable tree, pages whose hash value
* has not changed since the previous scan of all memory areas.
* 3) The unstable tree is a RedBlack Tree - so its balancing is based on the
* colors of the nodes and not on their contents, assuring that even when
* the tree gets "corrupted" it won't get out of balance, so scanning time
* remains the same (also, searching and inserting nodes in an rbtree uses
* the same algorithm, so we have no overhead when we flush and rebuild).
* 4) KSM never flushes the stable tree, which means that even if it were to
* take 10 attempts to find a page in the unstable tree, once it is found,
* it is secured in the stable tree. (When we scan a new page, we first
* compare it against the stable tree, and then against the unstable tree.)
*/
/**
* struct mm_slot - ksm information per mm that is being scanned
* @link: link to the mm_slots hash list
* @mm_list: link into the mm_slots list, rooted in ksm_mm_head
* @rmap_list: head for this mm_slot's singly-linked list of rmap_items
* @mm: the mm that this information is valid for
*/
struct mm_slot {
struct hlist_node link;
struct list_head mm_list;
struct rmap_item *rmap_list;
struct mm_struct *mm;
};
/**
* struct ksm_scan - cursor for scanning
* @mm_slot: the current mm_slot we are scanning
* @address: the next address inside that to be scanned
* @rmap_list: link to the next rmap to be scanned in the rmap_list
* @seqnr: count of completed full scans (needed when removing unstable node)
*
* There is only the one ksm_scan instance of this cursor structure.
*/
struct ksm_scan {
struct mm_slot *mm_slot;
unsigned long address;
struct rmap_item **rmap_list;
unsigned long seqnr;
};
/**
* struct stable_node - node of the stable rbtree
* @node: rb node of this ksm page in the stable tree
* @hlist: hlist head of rmap_items using this ksm page
* @kpfn: page frame number of this ksm page
*/
struct stable_node {
struct rb_node node;
struct hlist_head hlist;
unsigned long kpfn;
};
/**
* struct rmap_item - reverse mapping item for virtual addresses
* @rmap_list: next rmap_item in mm_slot's singly-linked rmap_list
* @anon_vma: pointer to anon_vma for this mm,address, when in stable tree
* @mm: the memory structure this rmap_item is pointing into
* @address: the virtual address this rmap_item tracks (+ flags in low bits)
* @oldchecksum: previous checksum of the page at that virtual address
* @node: rb node of this rmap_item in the unstable tree
* @head: pointer to stable_node heading this list in the stable tree
* @hlist: link into hlist of rmap_items hanging off that stable_node
*/
struct rmap_item {
struct rmap_item *rmap_list;
struct anon_vma *anon_vma; /* when stable */
struct mm_struct *mm;
unsigned long address; /* + low bits used for flags below */
unsigned int oldchecksum; /* when unstable */
union {
struct rb_node node; /* when node of unstable tree */
struct { /* when listed from stable tree */
struct stable_node *head;
struct hlist_node hlist;
};
};
};
#define SEQNR_MASK 0x0ff /* low bits of unstable tree seqnr */
#define UNSTABLE_FLAG 0x100 /* is a node of the unstable tree */
#define STABLE_FLAG 0x200 /* is listed from the stable tree */
/* The stable and unstable tree heads */
static struct rb_root root_stable_tree = RB_ROOT;
static struct rb_root root_unstable_tree = RB_ROOT;
#define MM_SLOTS_HASH_SHIFT 10
#define MM_SLOTS_HASH_HEADS (1 << MM_SLOTS_HASH_SHIFT)
static struct hlist_head mm_slots_hash[MM_SLOTS_HASH_HEADS];
static struct mm_slot ksm_mm_head = {
.mm_list = LIST_HEAD_INIT(ksm_mm_head.mm_list),
};
static struct ksm_scan ksm_scan = {
.mm_slot = &ksm_mm_head,
};
static struct kmem_cache *rmap_item_cache;
static struct kmem_cache *stable_node_cache;
static struct kmem_cache *mm_slot_cache;
/* The number of nodes in the stable tree */
static unsigned long ksm_pages_shared;
/* The number of page slots additionally sharing those nodes */
static unsigned long ksm_pages_sharing;
/* The number of nodes in the unstable tree */
static unsigned long ksm_pages_unshared;
/* The number of rmap_items in use: to calculate pages_volatile */
static unsigned long ksm_rmap_items;
/* Number of pages ksmd should scan in one batch */
static unsigned int ksm_thread_pages_to_scan = 100;
/* Milliseconds ksmd should sleep between batches */
static unsigned int ksm_thread_sleep_millisecs = 20;
/* Boolean to indicate whether to use deferred timer or not */
static bool use_deferred_timer;
#define KSM_RUN_STOP 0
#define KSM_RUN_MERGE 1
#define KSM_RUN_UNMERGE 2
static unsigned int ksm_run = KSM_RUN_STOP;
static DECLARE_WAIT_QUEUE_HEAD(ksm_thread_wait);
static DEFINE_MUTEX(ksm_thread_mutex);
static DEFINE_SPINLOCK(ksm_mmlist_lock);
#define KSM_KMEM_CACHE(__struct, __flags) kmem_cache_create("ksm_"#__struct,\
sizeof(struct __struct), __alignof__(struct __struct),\
(__flags), NULL)
static int __init ksm_slab_init(void)
{
rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0);
if (!rmap_item_cache)
goto out;
stable_node_cache = KSM_KMEM_CACHE(stable_node, 0);
if (!stable_node_cache)
goto out_free1;
mm_slot_cache = KSM_KMEM_CACHE(mm_slot, 0);
if (!mm_slot_cache)
goto out_free2;
return 0;
out_free2:
kmem_cache_destroy(stable_node_cache);
out_free1:
kmem_cache_destroy(rmap_item_cache);
out:
return -ENOMEM;
}
static void __init ksm_slab_free(void)
{
kmem_cache_destroy(mm_slot_cache);
kmem_cache_destroy(stable_node_cache);
kmem_cache_destroy(rmap_item_cache);
mm_slot_cache = NULL;
}
static inline struct rmap_item *alloc_rmap_item(void)
{
struct rmap_item *rmap_item;
rmap_item = kmem_cache_zalloc(rmap_item_cache, GFP_KERNEL);
if (rmap_item)
ksm_rmap_items++;
return rmap_item;
}
static inline void free_rmap_item(struct rmap_item *rmap_item)
{
ksm_rmap_items--;
rmap_item->mm = NULL; /* debug safety */
kmem_cache_free(rmap_item_cache, rmap_item);
}
static inline struct stable_node *alloc_stable_node(void)
{
return kmem_cache_alloc(stable_node_cache, GFP_KERNEL);
}
static inline void free_stable_node(struct stable_node *stable_node)
{
kmem_cache_free(stable_node_cache, stable_node);
}
static inline struct mm_slot *alloc_mm_slot(void)
{
if (!mm_slot_cache) /* initialization failed */
return NULL;
return kmem_cache_zalloc(mm_slot_cache, GFP_KERNEL);
}
static inline void free_mm_slot(struct mm_slot *mm_slot)
{
kmem_cache_free(mm_slot_cache, mm_slot);
}
static struct mm_slot *get_mm_slot(struct mm_struct *mm)
{
struct mm_slot *mm_slot;
struct hlist_head *bucket;
struct hlist_node *node;
bucket = &mm_slots_hash[hash_ptr(mm, MM_SLOTS_HASH_SHIFT)];
hlist_for_each_entry(mm_slot, node, bucket, link) {
if (mm == mm_slot->mm)
return mm_slot;
}
return NULL;
}
static void insert_to_mm_slots_hash(struct mm_struct *mm,
struct mm_slot *mm_slot)
{
struct hlist_head *bucket;
bucket = &mm_slots_hash[hash_ptr(mm, MM_SLOTS_HASH_SHIFT)];
mm_slot->mm = mm;
hlist_add_head(&mm_slot->link, bucket);
}
static inline int in_stable_tree(struct rmap_item *rmap_item)
{
return rmap_item->address & STABLE_FLAG;
}
/*
* ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's
* page tables after it has passed through ksm_exit() - which, if necessary,
* takes mmap_sem briefly to serialize against them. ksm_exit() does not set
* a special flag: they can just back out as soon as mm_users goes to zero.
* ksm_test_exit() is used throughout to make this test for exit: in some
* places for correctness, in some places just to avoid unnecessary work.
*/
static inline bool ksm_test_exit(struct mm_struct *mm)
{
return atomic_read(&mm->mm_users) == 0;
}
/*
* We use break_ksm to break COW on a ksm page: it's a stripped down
*
* if (get_user_pages(current, mm, addr, 1, 1, 1, &page, NULL) == 1)
* put_page(page);
*
* but taking great care only to touch a ksm page, in a VM_MERGEABLE vma,
* in case the application has unmapped and remapped mm,addr meanwhile.
* Could a ksm page appear anywhere else? Actually yes, in a VM_PFNMAP
* mmap of /dev/mem or /dev/kmem, where we would not want to touch it.
*/
static int break_ksm(struct vm_area_struct *vma, unsigned long addr)
{
struct page *page;
int ret = 0;
do {
cond_resched();
page = follow_page(vma, addr, FOLL_GET);
if (IS_ERR_OR_NULL(page))
break;
if (PageKsm(page))
ret = handle_mm_fault(vma->vm_mm, vma, addr,
FAULT_FLAG_WRITE);
else
ret = VM_FAULT_WRITE;
put_page(page);
} while (!(ret & (VM_FAULT_WRITE | VM_FAULT_SIGBUS | VM_FAULT_OOM)));
/*
* We must loop because handle_mm_fault() may back out if there's
* any difficulty e.g. if pte accessed bit gets updated concurrently.
*
* VM_FAULT_WRITE is what we have been hoping for: it indicates that
* COW has been broken, even if the vma does not permit VM_WRITE;
* but note that a concurrent fault might break PageKsm for us.
*
* VM_FAULT_SIGBUS could occur if we race with truncation of the
* backing file, which also invalidates anonymous pages: that's
* okay, that truncation will have unmapped the PageKsm for us.
*
* VM_FAULT_OOM: at the time of writing (late July 2009), setting
* aside mem_cgroup limits, VM_FAULT_OOM would only be set if the
* current task has TIF_MEMDIE set, and will be OOM killed on return
* to user; and ksmd, having no mm, would never be chosen for that.
*
* But if the mm is in a limited mem_cgroup, then the fault may fail
* with VM_FAULT_OOM even if the current task is not TIF_MEMDIE; and
* even ksmd can fail in this way - though it's usually breaking ksm
* just to undo a merge it made a moment before, so unlikely to oom.
*
* That's a pity: we might therefore have more kernel pages allocated
* than we're counting as nodes in the stable tree; but ksm_do_scan
* will retry to break_cow on each pass, so should recover the page
* in due course. The important thing is to not let VM_MERGEABLE
* be cleared while any such pages might remain in the area.
*/
return (ret & VM_FAULT_OOM) ? -ENOMEM : 0;
}
static struct vm_area_struct *find_mergeable_vma(struct mm_struct *mm,
unsigned long addr)
{
struct vm_area_struct *vma;
if (ksm_test_exit(mm))
return NULL;
vma = find_vma(mm, addr);
if (!vma || vma->vm_start > addr)
return NULL;
if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
return NULL;
return vma;
}
static void break_cow(struct rmap_item *rmap_item)
{
struct mm_struct *mm = rmap_item->mm;
unsigned long addr = rmap_item->address;
struct vm_area_struct *vma;
/*
* It is not an accident that whenever we want to break COW
* to undo, we also need to drop a reference to the anon_vma.
*/
put_anon_vma(rmap_item->anon_vma);
down_read(&mm->mmap_sem);
vma = find_mergeable_vma(mm, addr);
if (vma)
break_ksm(vma, addr);
up_read(&mm->mmap_sem);
}
static struct page *page_trans_compound_anon(struct page *page)
{
if (PageTransCompound(page)) {
struct page *head = compound_trans_head(page);
/*
* head may actually be splitted and freed from under
* us but it's ok here.
*/
if (PageAnon(head))
return head;
}
return NULL;
}
static struct page *get_mergeable_page(struct rmap_item *rmap_item)
{
struct mm_struct *mm = rmap_item->mm;
unsigned long addr = rmap_item->address;
struct vm_area_struct *vma;
struct page *page;
down_read(&mm->mmap_sem);
vma = find_mergeable_vma(mm, addr);
if (!vma)
goto out;
page = follow_page(vma, addr, FOLL_GET);
if (IS_ERR_OR_NULL(page))
goto out;
if (PageAnon(page) || page_trans_compound_anon(page)) {
flush_anon_page(vma, page, addr);
flush_dcache_page(page);
} else {
put_page(page);
out: page = NULL;
}
up_read(&mm->mmap_sem);
return page;
}
static void remove_node_from_stable_tree(struct stable_node *stable_node)
{
struct rmap_item *rmap_item;
struct hlist_node *hlist;
hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
if (rmap_item->hlist.next)
ksm_pages_sharing--;
else
ksm_pages_shared--;
put_anon_vma(rmap_item->anon_vma);
rmap_item->address &= PAGE_MASK;
cond_resched();
}
rb_erase(&stable_node->node, &root_stable_tree);
free_stable_node(stable_node);
}
/*
* get_ksm_page: checks if the page indicated by the stable node
* is still its ksm page, despite having held no reference to it.
* In which case we can trust the content of the page, and it
* returns the gotten page; but if the page has now been zapped,
* remove the stale node from the stable tree and return NULL.
*
* You would expect the stable_node to hold a reference to the ksm page.
* But if it increments the page's count, swapping out has to wait for
* ksmd to come around again before it can free the page, which may take
* seconds or even minutes: much too unresponsive. So instead we use a
* "keyhole reference": access to the ksm page from the stable node peeps
* out through its keyhole to see if that page still holds the right key,
* pointing back to this stable node. This relies on freeing a PageAnon
* page to reset its page->mapping to NULL, and relies on no other use of
* a page to put something that might look like our key in page->mapping.
*
* include/linux/pagemap.h page_cache_get_speculative() is a good reference,
* but this is different - made simpler by ksm_thread_mutex being held, but
* interesting for assuming that no other use of the struct page could ever
* put our expected_mapping into page->mapping (or a field of the union which
* coincides with page->mapping). The RCU calls are not for KSM at all, but
* to keep the page_count protocol described with page_cache_get_speculative.
*
* Note: it is possible that get_ksm_page() will return NULL one moment,
* then page the next, if the page is in between page_freeze_refs() and
* page_unfreeze_refs(): this shouldn't be a problem anywhere, the page
* is on its way to being freed; but it is an anomaly to bear in mind.
*/
static struct page *get_ksm_page(struct stable_node *stable_node)
{
struct page *page;
void *expected_mapping;
page = pfn_to_page(stable_node->kpfn);
expected_mapping = (void *)stable_node +
(PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
rcu_read_lock();
if (page->mapping != expected_mapping)
goto stale;
if (!get_page_unless_zero(page))
goto stale;
if (page->mapping != expected_mapping) {
put_page(page);
goto stale;
}
rcu_read_unlock();
return page;
stale:
rcu_read_unlock();
remove_node_from_stable_tree(stable_node);
return NULL;
}
/*
* Removing rmap_item from stable or unstable tree.
* This function will clean the information from the stable/unstable tree.
*/
static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
{
if (rmap_item->address & STABLE_FLAG) {
struct stable_node *stable_node;
struct page *page;
stable_node = rmap_item->head;
page = get_ksm_page(stable_node);
if (!page)
goto out;
lock_page(page);
hlist_del(&rmap_item->hlist);
unlock_page(page);
put_page(page);
if (stable_node->hlist.first)
ksm_pages_sharing--;
else
ksm_pages_shared--;
put_anon_vma(rmap_item->anon_vma);
rmap_item->address &= PAGE_MASK;
} else if (rmap_item->address & UNSTABLE_FLAG) {
unsigned char age;
/*
* Usually ksmd can and must skip the rb_erase, because
* root_unstable_tree was already reset to RB_ROOT.
* But be careful when an mm is exiting: do the rb_erase
* if this rmap_item was inserted by this scan, rather
* than left over from before.
*/
age = (unsigned char)(ksm_scan.seqnr - rmap_item->address);
#ifndef CONFIG_KSM_CHECK_PAGE
BUG_ON(age > 1);
#endif
if (!age)
rb_erase(&rmap_item->node, &root_unstable_tree);
ksm_pages_unshared--;
rmap_item->address &= PAGE_MASK;
}
out:
cond_resched(); /* we're called from many long loops */
}
static void remove_trailing_rmap_items(struct mm_slot *mm_slot,
struct rmap_item **rmap_list)
{
while (*rmap_list) {
struct rmap_item *rmap_item = *rmap_list;
*rmap_list = rmap_item->rmap_list;
remove_rmap_item_from_tree(rmap_item);
free_rmap_item(rmap_item);
}
}
/*
* Though it's very tempting to unmerge in_stable_tree(rmap_item)s rather
* than check every pte of a given vma, the locking doesn't quite work for
* that - an rmap_item is assigned to the stable tree after inserting ksm
* page and upping mmap_sem. Nor does it fit with the way we skip dup'ing
* rmap_items from parent to child at fork time (so as not to waste time
* if exit comes before the next scan reaches it).
*
* Similarly, although we'd like to remove rmap_items (so updating counts
* and freeing memory) when unmerging an area, it's easier to leave that
* to the next pass of ksmd - consider, for example, how ksmd might be
* in cmp_and_merge_page on one of the rmap_items we would be removing.
*/
static int unmerge_ksm_pages(struct vm_area_struct *vma,
unsigned long start, unsigned long end)
{
unsigned long addr;
int err = 0;
for (addr = start; addr < end && !err; addr += PAGE_SIZE) {
if (ksm_test_exit(vma->vm_mm))
break;
if (signal_pending(current))
err = -ERESTARTSYS;
else
err = break_ksm(vma, addr);
}
return err;
}
#ifdef CONFIG_SYSFS
/*
* Only called through the sysfs control interface:
*/
static int unmerge_and_remove_all_rmap_items(void)
{
struct mm_slot *mm_slot;
struct mm_struct *mm;
struct vm_area_struct *vma;
int err = 0;
spin_lock(&ksm_mmlist_lock);
ksm_scan.mm_slot = list_entry(ksm_mm_head.mm_list.next,
struct mm_slot, mm_list);
spin_unlock(&ksm_mmlist_lock);
for (mm_slot = ksm_scan.mm_slot;
mm_slot != &ksm_mm_head; mm_slot = ksm_scan.mm_slot) {
mm = mm_slot->mm;
down_read(&mm->mmap_sem);
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (ksm_test_exit(mm))
break;
if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
continue;
err = unmerge_ksm_pages(vma,
vma->vm_start, vma->vm_end);
if (err)
goto error;
}
remove_trailing_rmap_items(mm_slot, &mm_slot->rmap_list);
spin_lock(&ksm_mmlist_lock);
ksm_scan.mm_slot = list_entry(mm_slot->mm_list.next,
struct mm_slot, mm_list);
if (ksm_test_exit(mm)) {
hlist_del(&mm_slot->link);
list_del(&mm_slot->mm_list);
spin_unlock(&ksm_mmlist_lock);
free_mm_slot(mm_slot);
clear_bit(MMF_VM_MERGEABLE, &mm->flags);
up_read(&mm->mmap_sem);
mmdrop(mm);
} else {
spin_unlock(&ksm_mmlist_lock);
up_read(&mm->mmap_sem);
}
}
ksm_scan.seqnr = 0;
return 0;
error:
up_read(&mm->mmap_sem);
spin_lock(&ksm_mmlist_lock);
ksm_scan.mm_slot = &ksm_mm_head;
spin_unlock(&ksm_mmlist_lock);
return err;
}
#endif /* CONFIG_SYSFS */
static u32 calc_checksum(struct page *page)
{
u32 checksum;
void *addr = kmap_atomic(page);
checksum = jhash2(addr, PAGE_SIZE / 4, 17);
kunmap_atomic(addr);
return checksum;
}
static int memcmp_pages(struct page *page1, struct page *page2)
{
char *addr1, *addr2;
int ret;
addr1 = kmap_atomic(page1);
addr2 = kmap_atomic(page2);
ret = memcmp(addr1, addr2, PAGE_SIZE);
kunmap_atomic(addr2);
kunmap_atomic(addr1);
return ret;
}
static inline int pages_identical(struct page *page1, struct page *page2)
{
return !memcmp_pages(page1, page2);
}
static int write_protect_page(struct vm_area_struct *vma, struct page *page,
pte_t *orig_pte)
{
struct mm_struct *mm = vma->vm_mm;
unsigned long addr;
pte_t *ptep;
spinlock_t *ptl;
int swapped;
int err = -EFAULT;
addr = page_address_in_vma(page, vma);
if (addr == -EFAULT)
goto out;
BUG_ON(PageTransCompound(page));
ptep = page_check_address(page, mm, addr, &ptl, 0);
if (!ptep)
goto out;
if (pte_write(*ptep) || pte_dirty(*ptep)) {
pte_t entry;
swapped = PageSwapCache(page);
flush_cache_page(vma, addr, page_to_pfn(page));
/*
* Ok this is tricky, when get_user_pages_fast() run it doesn't
* take any lock, therefore the check that we are going to make
* with the pagecount against the mapcount is racey and
* O_DIRECT can happen right after the check.
* So we clear the pte and flush the tlb before the check
* this assure us that no O_DIRECT can happen after the check
* or in the middle of the check.
*/
entry = ptep_clear_flush(vma, addr, ptep);
/*
* Check that no O_DIRECT or similar I/O is in progress on the
* page
*/
if (page_mapcount(page) + 1 + swapped != page_count(page)) {
set_pte_at(mm, addr, ptep, entry);
goto out_unlock;
}
if (pte_dirty(entry))
set_page_dirty(page);
entry = pte_mkclean(pte_wrprotect(entry));
set_pte_at_notify(mm, addr, ptep, entry);
}
*orig_pte = *ptep;
err = 0;
out_unlock:
pte_unmap_unlock(ptep, ptl);
out:
return err;
}
/**
* replace_page - replace page in vma by new ksm page
* @vma: vma that holds the pte pointing to page
* @page: the page we are replacing by kpage
* @kpage: the ksm page we replace page by
* @orig_pte: the original value of the pte
*
* Returns 0 on success, -EFAULT on failure.
*/
static int replace_page(struct vm_area_struct *vma, struct page *page,
struct page *kpage, pte_t orig_pte)
{
struct mm_struct *mm = vma->vm_mm;
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *ptep;
spinlock_t *ptl;
unsigned long addr;
int err = -EFAULT;
addr = page_address_in_vma(page, vma);
if (addr == -EFAULT)
goto out;
pgd = pgd_offset(mm, addr);
if (!pgd_present(*pgd))
goto out;
pud = pud_offset(pgd, addr);
if (!pud_present(*pud))
goto out;
pmd = pmd_offset(pud, addr);
BUG_ON(pmd_trans_huge(*pmd));
if (!pmd_present(*pmd))
goto out;
ptep = pte_offset_map_lock(mm, pmd, addr, &ptl);
if (!pte_same(*ptep, orig_pte)) {
pte_unmap_unlock(ptep, ptl);
goto out;
}
get_page(kpage);
page_add_anon_rmap(kpage, vma, addr);
flush_cache_page(vma, addr, pte_pfn(*ptep));
ptep_clear_flush(vma, addr, ptep);
set_pte_at_notify(mm, addr, ptep, mk_pte(kpage, vma->vm_page_prot));
page_remove_rmap(page);
if (!page_mapped(page))
try_to_free_swap(page);
put_page(page);
pte_unmap_unlock(ptep, ptl);
err = 0;
out:
return err;
}
static int page_trans_compound_anon_split(struct page *page)
{
int ret = 0;
struct page *transhuge_head = page_trans_compound_anon(page);
if (transhuge_head) {
/* Get the reference on the head to split it. */
if (get_page_unless_zero(transhuge_head)) {
/*
* Recheck we got the reference while the head
* was still anonymous.
*/
if (PageAnon(transhuge_head))
ret = split_huge_page(transhuge_head);
else
/*
* Retry later if split_huge_page run
* from under us.
*/
ret = 1;
put_page(transhuge_head);
} else
/* Retry later if split_huge_page run from under us. */
ret = 1;
}
return ret;
}
/*
* try_to_merge_one_page - take two pages and merge them into one
* @vma: the vma that holds the pte pointing to page
* @page: the PageAnon page that we want to replace with kpage
* @kpage: the PageKsm page that we want to map instead of page,
* or NULL the first time when we want to use page as kpage.
*
* This function returns 0 if the pages were merged, -EFAULT otherwise.
*/
static int try_to_merge_one_page(struct vm_area_struct *vma,
struct page *page, struct page *kpage)
{
pte_t orig_pte = __pte(0);
int err = -EFAULT;
if (page == kpage) /* ksm page forked */
return 0;
if (!(vma->vm_flags & VM_MERGEABLE))
goto out;
if (PageTransCompound(page) && page_trans_compound_anon_split(page))
goto out;
BUG_ON(PageTransCompound(page));
if (!PageAnon(page))
goto out;
/*
* We need the page lock to read a stable PageSwapCache in
* write_protect_page(). We use trylock_page() instead of
* lock_page() because we don't want to wait here - we
* prefer to continue scanning and merging different pages,
* then come back to this page when it is unlocked.
*/
if (!trylock_page(page))
goto out;
/*
* If this anonymous page is mapped only here, its pte may need
* to be write-protected. If it's mapped elsewhere, all of its
* ptes are necessarily already write-protected. But in either
* case, we need to lock and check page_count is not raised.
*/
if (write_protect_page(vma, page, &orig_pte) == 0) {
if (!kpage) {
/*
* While we hold page lock, upgrade page from
* PageAnon+anon_vma to PageKsm+NULL stable_node:
* stable_tree_insert() will update stable_node.
*/
set_page_stable_node(page, NULL);
mark_page_accessed(page);
err = 0;
} else if (pages_identical(page, kpage))
err = replace_page(vma, page, kpage, orig_pte);
}
if ((vma->vm_flags & VM_LOCKED) && kpage && !err) {
munlock_vma_page(page);
if (!PageMlocked(kpage)) {
unlock_page(page);
lock_page(kpage);
mlock_vma_page(kpage);
page = kpage; /* for final unlock */
}
}
unlock_page(page);
out:
return err;
}
/*
* try_to_merge_with_ksm_page - like try_to_merge_two_pages,
* but no new kernel page is allocated: kpage must already be a ksm page.
*
* This function returns 0 if the pages were merged, -EFAULT otherwise.
*/
static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
struct page *page, struct page *kpage)
{
struct mm_struct *mm = rmap_item->mm;
struct vm_area_struct *vma;
int err = -EFAULT;
down_read(&mm->mmap_sem);
if (ksm_test_exit(mm))
goto out;
vma = find_vma(mm, rmap_item->address);
if (!vma || vma->vm_start > rmap_item->address)
goto out;
err = try_to_merge_one_page(vma, page, kpage);
if (err)
goto out;
/* Must get reference to anon_vma while still holding mmap_sem */
rmap_item->anon_vma = vma->anon_vma;
get_anon_vma(vma->anon_vma);
out:
up_read(&mm->mmap_sem);
return err;
}
/*
* try_to_merge_two_pages - take two identical pages and prepare them
* to be merged into one page.
*
* This function returns the kpage if we successfully merged two identical
* pages into one ksm page, NULL otherwise.
*
* Note that this function upgrades page to ksm page: if one of the pages
* is already a ksm page, try_to_merge_with_ksm_page should be used.
*/
static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,
struct page *page,
struct rmap_item *tree_rmap_item,
struct page *tree_page)
{
int err;
err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
if (!err) {
err = try_to_merge_with_ksm_page(tree_rmap_item,
tree_page, page);
/*
* If that fails, we have a ksm page with only one pte
* pointing to it: so break it.
*/
if (err)
break_cow(rmap_item);
}
return err ? NULL : page;
}
/*
* stable_tree_search - search for page inside the stable tree
*
* This function checks if there is a page inside the stable tree
* with identical content to the page that we are scanning right now.
*
* This function returns the stable tree node of identical content if found,
* NULL otherwise.
*/
static struct page *stable_tree_search(struct page *page)
{
struct rb_node *node = root_stable_tree.rb_node;
struct stable_node *stable_node;
stable_node = page_stable_node(page);
if (stable_node) { /* ksm page forked */
get_page(page);
return page;
}
while (node) {
struct page *tree_page;
int ret;
cond_resched();
stable_node = rb_entry(node, struct stable_node, node);
tree_page = get_ksm_page(stable_node);
if (!tree_page)
return NULL;
ret = memcmp_pages(page, tree_page);
if (ret < 0) {
put_page(tree_page);
node = node->rb_left;
} else if (ret > 0) {
put_page(tree_page);
node = node->rb_right;
} else
return tree_page;
}
return NULL;
}
/*
* stable_tree_insert - insert rmap_item pointing to new ksm page
* into the stable tree.
*
* This function returns the stable tree node just allocated on success,
* NULL otherwise.
*/
static struct stable_node *stable_tree_insert(struct page *kpage)
{
struct rb_node **new = &root_stable_tree.rb_node;
struct rb_node *parent = NULL;
struct stable_node *stable_node;
while (*new) {
struct page *tree_page;
int ret;
cond_resched();
stable_node = rb_entry(*new, struct stable_node, node);
tree_page = get_ksm_page(stable_node);
if (!tree_page)
return NULL;
ret = memcmp_pages(kpage, tree_page);
put_page(tree_page);
parent = *new;
if (ret < 0)
new = &parent->rb_left;
else if (ret > 0)
new = &parent->rb_right;
else {
/*
* It is not a bug that stable_tree_search() didn't
* find this node: because at that time our page was
* not yet write-protected, so may have changed since.
*/
return NULL;
}
}
stable_node = alloc_stable_node();
if (!stable_node)
return NULL;
rb_link_node(&stable_node->node, parent, new);
rb_insert_color(&stable_node->node, &root_stable_tree);
INIT_HLIST_HEAD(&stable_node->hlist);
stable_node->kpfn = page_to_pfn(kpage);
set_page_stable_node(kpage, stable_node);
return stable_node;
}
/*
* unstable_tree_search_insert - search for identical page,
* else insert rmap_item into the unstable tree.
*
* This function searches for a page in the unstable tree identical to the
* page currently being scanned; and if no identical page is found in the
* tree, we insert rmap_item as a new object into the unstable tree.
*
* This function returns pointer to rmap_item found to be identical
* to the currently scanned page, NULL otherwise.
*
* This function does both searching and inserting, because they share
* the same walking algorithm in an rbtree.
*/
static
struct rmap_item *unstable_tree_search_insert(struct rmap_item *rmap_item,
struct page *page,
struct page **tree_pagep)
{
struct rb_node **new = &root_unstable_tree.rb_node;
struct rb_node *parent = NULL;
while (*new) {
struct rmap_item *tree_rmap_item;
struct page *tree_page;
int ret;
cond_resched();
tree_rmap_item = rb_entry(*new, struct rmap_item, node);
tree_page = get_mergeable_page(tree_rmap_item);
if (IS_ERR_OR_NULL(tree_page))
return NULL;
/*
* Don't substitute a ksm page for a forked page.
*/
if (page == tree_page) {
put_page(tree_page);
return NULL;
}
ret = memcmp_pages(page, tree_page);
parent = *new;
if (ret < 0) {
put_page(tree_page);
new = &parent->rb_left;
} else if (ret > 0) {
put_page(tree_page);
new = &parent->rb_right;
} else {
*tree_pagep = tree_page;
return tree_rmap_item;
}
}
rmap_item->address |= UNSTABLE_FLAG;
rmap_item->address |= (ksm_scan.seqnr & SEQNR_MASK);
rb_link_node(&rmap_item->node, parent, new);
rb_insert_color(&rmap_item->node, &root_unstable_tree);
ksm_pages_unshared++;
return NULL;
}
/*
* stable_tree_append - add another rmap_item to the linked list of
* rmap_items hanging off a given node of the stable tree, all sharing
* the same ksm page.
*/
static void stable_tree_append(struct rmap_item *rmap_item,
struct stable_node *stable_node)
{
rmap_item->head = stable_node;
rmap_item->address |= STABLE_FLAG;
hlist_add_head(&rmap_item->hlist, &stable_node->hlist);
if (rmap_item->hlist.next)
ksm_pages_sharing++;
else
ksm_pages_shared++;
}
/*
* cmp_and_merge_page - first see if page can be merged into the stable tree;
* if not, compare checksum to previous and if it's the same, see if page can
* be inserted into the unstable tree, or merged with a page already there and
* both transferred to the stable tree.
*
* @page: the page that we are searching identical page to.
* @rmap_item: the reverse mapping into the virtual address of this page
*/
static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
{
struct rmap_item *tree_rmap_item;
struct page *tree_page = NULL;
struct stable_node *stable_node;
struct page *kpage;
unsigned int checksum;
int err;
remove_rmap_item_from_tree(rmap_item);
/* We first start with searching the page inside the stable tree */
kpage = stable_tree_search(page);
if (kpage) {
err = try_to_merge_with_ksm_page(rmap_item, page, kpage);
if (!err) {
/*
* The page was successfully merged:
* add its rmap_item to the stable tree.
*/
lock_page(kpage);
stable_tree_append(rmap_item, page_stable_node(kpage));
unlock_page(kpage);
}
put_page(kpage);
return;
}
/*
* If the hash value of the page has changed from the last time
* we calculated it, this page is changing frequently: therefore we
* don't want to insert it in the unstable tree, and we don't want
* to waste our time searching for something identical to it there.
*/
checksum = calc_checksum(page);
if (rmap_item->oldchecksum != checksum) {
rmap_item->oldchecksum = checksum;
return;
}
tree_rmap_item =
unstable_tree_search_insert(rmap_item, page, &tree_page);
if (tree_rmap_item) {
kpage = try_to_merge_two_pages(rmap_item, page,
tree_rmap_item, tree_page);
put_page(tree_page);
/*
* As soon as we merge this page, we want to remove the
* rmap_item of the page we have merged with from the unstable
* tree, and insert it instead as new node in the stable tree.
*/
if (kpage) {
remove_rmap_item_from_tree(tree_rmap_item);
lock_page(kpage);
stable_node = stable_tree_insert(kpage);
if (stable_node) {
stable_tree_append(tree_rmap_item, stable_node);
stable_tree_append(rmap_item, stable_node);
}
unlock_page(kpage);
/*
* If we fail to insert the page into the stable tree,
* we will have 2 virtual addresses that are pointing
* to a ksm page left outside the stable tree,
* in which case we need to break_cow on both.
*/
if (!stable_node) {
break_cow(tree_rmap_item);
break_cow(rmap_item);
}
}
}
}
static struct rmap_item *get_next_rmap_item(struct mm_slot *mm_slot,
struct rmap_item **rmap_list,
unsigned long addr)
{
struct rmap_item *rmap_item;
while (*rmap_list) {
rmap_item = *rmap_list;
if ((rmap_item->address & PAGE_MASK) == addr)
return rmap_item;
if (rmap_item->address > addr)
break;
*rmap_list = rmap_item->rmap_list;
remove_rmap_item_from_tree(rmap_item);
free_rmap_item(rmap_item);
}
rmap_item = alloc_rmap_item();
if (rmap_item) {
/* It has already been zeroed */
rmap_item->mm = mm_slot->mm;
rmap_item->address = addr;
rmap_item->rmap_list = *rmap_list;
*rmap_list = rmap_item;
}
return rmap_item;
}
static struct rmap_item *scan_get_next_rmap_item(struct page **page)
{
struct mm_struct *mm;
struct mm_slot *slot;
struct vm_area_struct *vma;
struct rmap_item *rmap_item;
if (list_empty(&ksm_mm_head.mm_list))
return NULL;
slot = ksm_scan.mm_slot;
if (slot == &ksm_mm_head) {
/*
* A number of pages can hang around indefinitely on per-cpu
* pagevecs, raised page count preventing write_protect_page
* from merging them. Though it doesn't really matter much,
* it is puzzling to see some stuck in pages_volatile until
* other activity jostles them out, and they also prevented
* LTP's KSM test from succeeding deterministically; so drain
* them here (here rather than on entry to ksm_do_scan(),
* so we don't IPI too often when pages_to_scan is set low).
*/
lru_add_drain_all();
root_unstable_tree = RB_ROOT;
spin_lock(&ksm_mmlist_lock);
slot = list_entry(slot->mm_list.next, struct mm_slot, mm_list);
ksm_scan.mm_slot = slot;
spin_unlock(&ksm_mmlist_lock);
/*
* Although we tested list_empty() above, a racing __ksm_exit
* of the last mm on the list may have removed it since then.
*/
if (slot == &ksm_mm_head)
return NULL;
next_mm:
ksm_scan.address = 0;
ksm_scan.rmap_list = &slot->rmap_list;
}
mm = slot->mm;
down_read(&mm->mmap_sem);
if (ksm_test_exit(mm))
vma = NULL;
else
vma = find_vma(mm, ksm_scan.address);
for (; vma; vma = vma->vm_next) {
if (!(vma->vm_flags & VM_MERGEABLE))
continue;
if (ksm_scan.address < vma->vm_start)
ksm_scan.address = vma->vm_start;
if (!vma->anon_vma)
ksm_scan.address = vma->vm_end;
while (ksm_scan.address < vma->vm_end) {
if (ksm_test_exit(mm))
break;
*page = follow_page(vma, ksm_scan.address, FOLL_GET);
if (IS_ERR_OR_NULL(*page)) {
ksm_scan.address += PAGE_SIZE;
cond_resched();
continue;
}
if (PageAnon(*page) ||
page_trans_compound_anon(*page)) {
flush_anon_page(vma, *page, ksm_scan.address);
flush_dcache_page(*page);
rmap_item = get_next_rmap_item(slot,
ksm_scan.rmap_list, ksm_scan.address);
if (rmap_item) {
ksm_scan.rmap_list =
&rmap_item->rmap_list;
ksm_scan.address += PAGE_SIZE;
} else
put_page(*page);
up_read(&mm->mmap_sem);
return rmap_item;
}
put_page(*page);
ksm_scan.address += PAGE_SIZE;
cond_resched();
}
}
if (ksm_test_exit(mm)) {
ksm_scan.address = 0;
ksm_scan.rmap_list = &slot->rmap_list;
}
/*
* Nuke all the rmap_items that are above this current rmap:
* because there were no VM_MERGEABLE vmas with such addresses.
*/
remove_trailing_rmap_items(slot, ksm_scan.rmap_list);
spin_lock(&ksm_mmlist_lock);
ksm_scan.mm_slot = list_entry(slot->mm_list.next,
struct mm_slot, mm_list);
if (ksm_scan.address == 0) {
/*
* We've completed a full scan of all vmas, holding mmap_sem
* throughout, and found no VM_MERGEABLE: so do the same as
* __ksm_exit does to remove this mm from all our lists now.
* This applies either when cleaning up after __ksm_exit
* (but beware: we can reach here even before __ksm_exit),
* or when all VM_MERGEABLE areas have been unmapped (and
* mmap_sem then protects against race with MADV_MERGEABLE).
*/
hlist_del(&slot->link);
list_del(&slot->mm_list);
spin_unlock(&ksm_mmlist_lock);
free_mm_slot(slot);
clear_bit(MMF_VM_MERGEABLE, &mm->flags);
up_read(&mm->mmap_sem);
mmdrop(mm);
} else {
spin_unlock(&ksm_mmlist_lock);
up_read(&mm->mmap_sem);
}
/* Repeat until we've completed scanning the whole list */
slot = ksm_scan.mm_slot;
if (slot != &ksm_mm_head)
goto next_mm;
ksm_scan.seqnr++;
return NULL;
}
static inline int is_page_scanned(struct page *page)
{
#ifdef CONFIG_KSM_CHECK_PAGE
/* page is already marked as ksm, so this will be simple merge */
if (PageKsm(page))
return 0;
if (ksm_scan.seqnr & 0x1) {
/* odd cycle */
/* clear even cycle bit */
ClearPageKsmScan0(page);
/* get old value and mark it scanned */
return TestSetPageKsmScan1(page);
} else {
/* even cycle */
/* clear odd cycle bit */
ClearPageKsmScan1(page);
/* get old value and mark it scanned */
return TestSetPageKsmScan0(page);
}
#else
return 0;
#endif
}
/**
* ksm_do_scan - the ksm scanner main worker function.
* @scan_npages - number of pages we want to scan before we return.
*/
static void ksm_do_scan(unsigned int scan_npages)
{
struct rmap_item *rmap_item;
struct page *uninitialized_var(page);
while (scan_npages-- && likely(!freezing(current))) {
cond_resched();
rmap_item = scan_get_next_rmap_item(&page);
if (!rmap_item)
return;
if (!PageKsm(page) || !in_stable_tree(rmap_item)) {
if (!is_page_scanned(page))
cmp_and_merge_page(page, rmap_item);
}
put_page(page);
}
}
static void process_timeout(unsigned long __data)
{
wake_up_process((struct task_struct *)__data);
}
static signed long __sched deferred_schedule_timeout(signed long timeout)
{
struct timer_list timer;
unsigned long expire;
__set_current_state(TASK_INTERRUPTIBLE);
if (timeout < 0) {
pr_err("schedule_timeout: wrong timeout value %lx\n",
timeout);
__set_current_state(TASK_RUNNING);
goto out;
}
expire = timeout + jiffies;
setup_deferrable_timer_on_stack(&timer, process_timeout,
(unsigned long)current);
mod_timer(&timer, expire);
schedule();
del_singleshot_timer_sync(&timer);
/* Remove the timer from the object tracker */
destroy_timer_on_stack(&timer);
timeout = expire - jiffies;
out:
return timeout < 0 ? 0 : timeout;
}
static int ksmd_should_run(void)
{
return (ksm_run & KSM_RUN_MERGE) && !list_empty(&ksm_mm_head.mm_list);
}
static int ksm_scan_thread(void *nothing)
{
set_freezable();
set_user_nice(current, 5);
while (!kthread_should_stop()) {
mutex_lock(&ksm_thread_mutex);
if (ksmd_should_run())
ksm_do_scan(ksm_thread_pages_to_scan);
mutex_unlock(&ksm_thread_mutex);
try_to_freeze();
if (ksmd_should_run()) {
if (use_deferred_timer)
deferred_schedule_timeout(
msecs_to_jiffies(ksm_thread_sleep_millisecs));
else
schedule_timeout_interruptible(
msecs_to_jiffies(ksm_thread_sleep_millisecs));
} else {
wait_event_freezable(ksm_thread_wait,
ksmd_should_run() || kthread_should_stop());
}
}
return 0;
}
int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
unsigned long end, int advice, unsigned long *vm_flags)
{
struct mm_struct *mm = vma->vm_mm;
int err;
switch (advice) {
case MADV_MERGEABLE:
/*
* Be somewhat over-protective for now!
*/
if (*vm_flags & (VM_MERGEABLE | VM_SHARED | VM_MAYSHARE |
VM_PFNMAP | VM_IO | VM_DONTEXPAND |
VM_RESERVED | VM_HUGETLB | VM_INSERTPAGE |
VM_NONLINEAR | VM_MIXEDMAP | VM_SAO))
return 0; /* just ignore the advice */
if (!test_bit(MMF_VM_MERGEABLE, &mm->flags)) {
err = __ksm_enter(mm);
if (err)
return err;
}
*vm_flags |= VM_MERGEABLE;
break;
case MADV_UNMERGEABLE:
if (!(*vm_flags & VM_MERGEABLE))
return 0; /* just ignore the advice */
if (vma->anon_vma) {
err = unmerge_ksm_pages(vma, start, end);
if (err)
return err;
}
*vm_flags &= ~VM_MERGEABLE;
break;
}
return 0;
}
int __ksm_enter(struct mm_struct *mm)
{
struct mm_slot *mm_slot;
int needs_wakeup;
mm_slot = alloc_mm_slot();
if (!mm_slot)
return -ENOMEM;
/* Check ksm_run too? Would need tighter locking */
needs_wakeup = list_empty(&ksm_mm_head.mm_list);
spin_lock(&ksm_mmlist_lock);
insert_to_mm_slots_hash(mm, mm_slot);
/*
* Insert just behind the scanning cursor, to let the area settle
* down a little; when fork is followed by immediate exec, we don't
* want ksmd to waste time setting up and tearing down an rmap_list.
*/
list_add_tail(&mm_slot->mm_list, &ksm_scan.mm_slot->mm_list);
spin_unlock(&ksm_mmlist_lock);
set_bit(MMF_VM_MERGEABLE, &mm->flags);
atomic_inc(&mm->mm_count);
if (needs_wakeup)
wake_up_interruptible(&ksm_thread_wait);
return 0;
}
void __ksm_exit(struct mm_struct *mm)
{
struct mm_slot *mm_slot;
int easy_to_free = 0;
/*
* This process is exiting: if it's straightforward (as is the
* case when ksmd was never running), free mm_slot immediately.
* But if it's at the cursor or has rmap_items linked to it, use
* mmap_sem to synchronize with any break_cows before pagetables
* are freed, and leave the mm_slot on the list for ksmd to free.
* Beware: ksm may already have noticed it exiting and freed the slot.
*/
spin_lock(&ksm_mmlist_lock);
mm_slot = get_mm_slot(mm);
if (mm_slot && ksm_scan.mm_slot != mm_slot) {
if (!mm_slot->rmap_list) {
hlist_del(&mm_slot->link);
list_del(&mm_slot->mm_list);
easy_to_free = 1;
} else {
list_move(&mm_slot->mm_list,
&ksm_scan.mm_slot->mm_list);
}
}
spin_unlock(&ksm_mmlist_lock);
if (easy_to_free) {
free_mm_slot(mm_slot);
clear_bit(MMF_VM_MERGEABLE, &mm->flags);
mmdrop(mm);
} else if (mm_slot) {
down_write(&mm->mmap_sem);
up_write(&mm->mmap_sem);
}
}
struct page *ksm_does_need_to_copy(struct page *page,
struct vm_area_struct *vma, unsigned long address)
{
struct page *new_page;
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
if (new_page) {
copy_user_highpage(new_page, page, address, vma);
SetPageDirty(new_page);
__SetPageUptodate(new_page);
SetPageSwapBacked(new_page);
__set_page_locked(new_page);
if (page_evictable(new_page, vma))
lru_cache_add_lru(new_page, LRU_ACTIVE_ANON);
else
add_page_to_unevictable_list(new_page);
}
return new_page;
}
int page_referenced_ksm(struct page *page, struct mem_cgroup *memcg,
unsigned long *vm_flags)
{
struct stable_node *stable_node;
struct rmap_item *rmap_item;
struct hlist_node *hlist;
unsigned int mapcount = page_mapcount(page);
int referenced = 0;
int search_new_forks = 0;
VM_BUG_ON(!PageKsm(page));
VM_BUG_ON(!PageLocked(page));
stable_node = page_stable_node(page);
if (!stable_node)
return 0;
again:
hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
struct anon_vma *anon_vma = rmap_item->anon_vma;
struct anon_vma_chain *vmac;
struct vm_area_struct *vma;
anon_vma_lock(anon_vma);
list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
vma = vmac->vma;
if (rmap_item->address < vma->vm_start ||
rmap_item->address >= vma->vm_end)
continue;
/*
* Initially we examine only the vma which covers this
* rmap_item; but later, if there is still work to do,
* we examine covering vmas in other mms: in case they
* were forked from the original since ksmd passed.
*/
if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
continue;
if (memcg && !mm_match_cgroup(vma->vm_mm, memcg))
continue;
referenced += page_referenced_one(page, vma,
rmap_item->address, &mapcount, vm_flags);
if (!search_new_forks || !mapcount)
break;
}
anon_vma_unlock(anon_vma);
if (!mapcount)
goto out;
}
if (!search_new_forks++)
goto again;
out:
return referenced;
}
int try_to_unmap_ksm(struct page *page, enum ttu_flags flags)
{
struct stable_node *stable_node;
struct hlist_node *hlist;
struct rmap_item *rmap_item;
int ret = SWAP_AGAIN;
int search_new_forks = 0;
VM_BUG_ON(!PageKsm(page));
VM_BUG_ON(!PageLocked(page));
stable_node = page_stable_node(page);
if (!stable_node)
return SWAP_FAIL;
again:
hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
struct anon_vma *anon_vma = rmap_item->anon_vma;
struct anon_vma_chain *vmac;
struct vm_area_struct *vma;
anon_vma_lock(anon_vma);
list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
vma = vmac->vma;
if (rmap_item->address < vma->vm_start ||
rmap_item->address >= vma->vm_end)
continue;
/*
* Initially we examine only the vma which covers this
* rmap_item; but later, if there is still work to do,
* we examine covering vmas in other mms: in case they
* were forked from the original since ksmd passed.
*/
if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
continue;
ret = try_to_unmap_one(page, vma,
rmap_item->address, flags);
if (ret != SWAP_AGAIN || !page_mapped(page)) {
anon_vma_unlock(anon_vma);
goto out;
}
}
anon_vma_unlock(anon_vma);
}
if (!search_new_forks++)
goto again;
out:
return ret;
}
#ifdef CONFIG_MIGRATION
int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *,
struct vm_area_struct *, unsigned long, void *), void *arg)
{
struct stable_node *stable_node;
struct hlist_node *hlist;
struct rmap_item *rmap_item;
int ret = SWAP_AGAIN;
int search_new_forks = 0;
VM_BUG_ON(!PageKsm(page));
VM_BUG_ON(!PageLocked(page));
stable_node = page_stable_node(page);
if (!stable_node)
return ret;
again:
hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
struct anon_vma *anon_vma = rmap_item->anon_vma;
struct anon_vma_chain *vmac;
struct vm_area_struct *vma;
anon_vma_lock(anon_vma);
list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
vma = vmac->vma;
if (rmap_item->address < vma->vm_start ||
rmap_item->address >= vma->vm_end)
continue;
/*
* Initially we examine only the vma which covers this
* rmap_item; but later, if there is still work to do,
* we examine covering vmas in other mms: in case they
* were forked from the original since ksmd passed.
*/
if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
continue;
ret = rmap_one(page, vma, rmap_item->address, arg);
if (ret != SWAP_AGAIN) {
anon_vma_unlock(anon_vma);
goto out;
}
}
anon_vma_unlock(anon_vma);
}
if (!search_new_forks++)
goto again;
out:
return ret;
}
void ksm_migrate_page(struct page *newpage, struct page *oldpage)
{
struct stable_node *stable_node;
VM_BUG_ON(!PageLocked(oldpage));
VM_BUG_ON(!PageLocked(newpage));
VM_BUG_ON(newpage->mapping != oldpage->mapping);
stable_node = page_stable_node(newpage);
if (stable_node) {
VM_BUG_ON(stable_node->kpfn != page_to_pfn(oldpage));
stable_node->kpfn = page_to_pfn(newpage);
}
}
#endif /* CONFIG_MIGRATION */
#ifdef CONFIG_MEMORY_HOTREMOVE
static struct stable_node *ksm_check_stable_tree(unsigned long start_pfn,
unsigned long end_pfn)
{
struct rb_node *node;
for (node = rb_first(&root_stable_tree); node; node = rb_next(node)) {
struct stable_node *stable_node;
stable_node = rb_entry(node, struct stable_node, node);
if (stable_node->kpfn >= start_pfn &&
stable_node->kpfn < end_pfn)
return stable_node;
}
return NULL;
}
static int ksm_memory_callback(struct notifier_block *self,
unsigned long action, void *arg)
{
struct memory_notify *mn = arg;
struct stable_node *stable_node;
switch (action) {
case MEM_GOING_OFFLINE:
/*
* Keep it very simple for now: just lock out ksmd and
* MADV_UNMERGEABLE while any memory is going offline.
* mutex_lock_nested() is necessary because lockdep was alarmed
* that here we take ksm_thread_mutex inside notifier chain
* mutex, and later take notifier chain mutex inside
* ksm_thread_mutex to unlock it. But that's safe because both
* are inside mem_hotplug_mutex.
*/
mutex_lock_nested(&ksm_thread_mutex, SINGLE_DEPTH_NESTING);
break;
case MEM_OFFLINE:
/*
* Most of the work is done by page migration; but there might
* be a few stable_nodes left over, still pointing to struct
* pages which have been offlined: prune those from the tree.
*/
while ((stable_node = ksm_check_stable_tree(mn->start_pfn,
mn->start_pfn + mn->nr_pages)) != NULL)
remove_node_from_stable_tree(stable_node);
/* fallthrough */
case MEM_CANCEL_OFFLINE:
mutex_unlock(&ksm_thread_mutex);
break;
}
return NOTIFY_OK;
}
#endif /* CONFIG_MEMORY_HOTREMOVE */
#ifdef CONFIG_SYSFS
/*
* This all compiles without CONFIG_SYSFS, but is a waste of space.
*/
#define KSM_ATTR_RO(_name) \
static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
#define KSM_ATTR(_name) \
static struct kobj_attribute _name##_attr = \
__ATTR(_name, 0644, _name##_show, _name##_store)
static ssize_t sleep_millisecs_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%u\n", ksm_thread_sleep_millisecs);
}
static ssize_t sleep_millisecs_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
unsigned long msecs;
int err;
err = strict_strtoul(buf, 10, &msecs);
if (err || msecs > UINT_MAX)
return -EINVAL;
ksm_thread_sleep_millisecs = msecs;
return count;
}
KSM_ATTR(sleep_millisecs);
static ssize_t pages_to_scan_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%u\n", ksm_thread_pages_to_scan);
}
static ssize_t pages_to_scan_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
int err;
unsigned long nr_pages;
err = strict_strtoul(buf, 10, &nr_pages);
if (err || nr_pages > UINT_MAX)
return -EINVAL;
ksm_thread_pages_to_scan = nr_pages;
return count;
}
KSM_ATTR(pages_to_scan);
static ssize_t run_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
return sprintf(buf, "%u\n", ksm_run);
}
static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
int err;
unsigned long flags;
err = strict_strtoul(buf, 10, &flags);
if (err || flags > UINT_MAX)
return -EINVAL;
if (flags > KSM_RUN_UNMERGE)
return -EINVAL;
/*
* KSM_RUN_MERGE sets ksmd running, and 0 stops it running.
* KSM_RUN_UNMERGE stops it running and unmerges all rmap_items,
* breaking COW to free the pages_shared (but leaves mm_slots
* on the list for when ksmd may be set running again).
*/
mutex_lock(&ksm_thread_mutex);
if (ksm_run != flags) {
ksm_run = flags;
if (flags & KSM_RUN_UNMERGE) {
int oom_score_adj;
oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX);
err = unmerge_and_remove_all_rmap_items();
compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX,
oom_score_adj);
if (err) {
ksm_run = KSM_RUN_STOP;
count = err;
}
}
}
mutex_unlock(&ksm_thread_mutex);
if (flags & KSM_RUN_MERGE)
wake_up_interruptible(&ksm_thread_wait);
return count;
}
KSM_ATTR(run);
static ssize_t deferred_timer_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return snprintf(buf, 8, "%d\n", use_deferred_timer);
}
static ssize_t deferred_timer_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
unsigned long enable;
int err;
err = kstrtoul(buf, 10, &enable);
use_deferred_timer = enable;
return count;
}
KSM_ATTR(deferred_timer);
static ssize_t pages_shared_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", ksm_pages_shared);
}
KSM_ATTR_RO(pages_shared);
static ssize_t pages_sharing_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", ksm_pages_sharing);
}
KSM_ATTR_RO(pages_sharing);
static ssize_t pages_unshared_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", ksm_pages_unshared);
}
KSM_ATTR_RO(pages_unshared);
static ssize_t pages_volatile_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
long ksm_pages_volatile;
ksm_pages_volatile = ksm_rmap_items - ksm_pages_shared
- ksm_pages_sharing - ksm_pages_unshared;
/*
* It was not worth any locking to calculate that statistic,
* but it might therefore sometimes be negative: conceal that.
*/
if (ksm_pages_volatile < 0)
ksm_pages_volatile = 0;
return sprintf(buf, "%ld\n", ksm_pages_volatile);
}
KSM_ATTR_RO(pages_volatile);
static ssize_t full_scans_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", ksm_scan.seqnr);
}
KSM_ATTR_RO(full_scans);
static struct attribute *ksm_attrs[] = {
&sleep_millisecs_attr.attr,
&pages_to_scan_attr.attr,
&run_attr.attr,
&pages_shared_attr.attr,
&pages_sharing_attr.attr,
&pages_unshared_attr.attr,
&pages_volatile_attr.attr,
&full_scans_attr.attr,
&deferred_timer_attr.attr,
NULL,
};
static struct attribute_group ksm_attr_group = {
.attrs = ksm_attrs,
.name = "ksm",
};
#endif /* CONFIG_SYSFS */
static int __init ksm_init(void)
{
struct task_struct *ksm_thread;
int err;
err = ksm_slab_init();
if (err)
goto out;
ksm_thread = kthread_run(ksm_scan_thread, NULL, "ksmd");
if (IS_ERR(ksm_thread)) {
printk(KERN_ERR "ksm: creating kthread failed\n");
err = PTR_ERR(ksm_thread);
goto out_free;
}
#ifdef CONFIG_SYSFS
err = sysfs_create_group(mm_kobj, &ksm_attr_group);
if (err) {
printk(KERN_ERR "ksm: register sysfs failed\n");
kthread_stop(ksm_thread);
goto out_free;
}
#else
ksm_run = KSM_RUN_MERGE; /* no way for user to start it */
#endif /* CONFIG_SYSFS */
#ifdef CONFIG_MEMORY_HOTREMOVE
/*
* Choose a high priority since the callback takes ksm_thread_mutex:
* later callbacks could only be taking locks which nest within that.
*/
hotplug_memory_notifier(ksm_memory_callback, 100);
#endif
return 0;
out_free:
ksm_slab_free();
out:
return err;
}
module_init(ksm_init)
| abazad/SizotrixKernel | mm/ksm.c | C | gpl-2.0 | 58,113 |
<?php
require_once(dirname(__FILE__) . "/../Base/MixpanelBase.php");
/**
* Provides some base methods for use by a Consumer implementation
*/
abstract class ConsumerStrategies_AbstractConsumer extends Base_MixpanelBase {
/**
* Creates a new AbstractConsumer
* @param array $options
*/
function __construct($options = array()) {
parent::__construct($options);
if ($this->_debug()) {
$this->_log("Instantiated new Consumer");
}
}
/**
* Encode an array to be persisted
* @param array $params
* @return string
*/
protected function _encode($params) {
return base64_encode(json_encode($params));
}
/**
* Handles errors that occur in a consumer
* @param $code
* @param $msg
*/
protected function _handleError($code, $msg) {
if (isset($this->_options['error_callback'])) {
$handler = $this->_options['error_callback'];
call_user_func($handler, $code, $msg);
}
if ($this->_debug()) {
$arr = debug_backtrace();
$class = get_class($arr[0]['object']);
$line = $arr[0]['line'];
error_log ( "[ $class - line $line ] : " . print_r($msg, true) );
}
}
/**
* Persist a batch of messages in whatever way the implementer sees fit
* @param array $batch an array of messages to consume
* @return boolean success or fail
*/
abstract function persist($batch);
} | Pramodf/justaboutself | wp-content/plugins/sidekick/libs/mixpanel/ConsumerStrategies/AbstractConsumer.php | PHP | gpl-2.0 | 1,516 |
-----------------------------------
-- Area: Pashhow Marshlands
-- MOB: Copper Quadav
-----------------------------------
require("scripts/globals/fieldsofvalor");
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
checkRegime(player,mob,60,1);
end;
| UnknownX7/darkstar | scripts/zones/Pashhow_Marshlands/mobs/Copper_Quadav.lua | Lua | gpl-3.0 | 336 |
// PR c++/69509
// { dg-do compile { target c++14 } }
constexpr int
fn_bad (int n)
{
__extension__ int a [n] = { 0 };
int z = a [0] + (n ? fn_bad (n - 1) : 0);
return z;
}
constexpr int
fn_ok (int n)
{
__extension__ int a [n] = { 0 };
int z = a [0] + (n > 1 ? fn_ok (n - 1) : 0);
return z;
}
constexpr int i1 = fn_ok (3);
constexpr int i2 = fn_bad (3); // { dg-error "array subscript" }
| selmentdev/selment-toolchain | source/gcc-latest/gcc/testsuite/g++.dg/ext/constexpr-vla2.C | C++ | gpl-3.0 | 402 |
package command
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
const (
// DefaultInitName is the default name we use when
// initializing the example file
DefaultInitName = "example.nomad"
)
// InitCommand generates a new job template that you can customize to your
// liking, like vagrant init
type InitCommand struct {
Meta
}
func (c *InitCommand) Help() string {
helpText := `
Usage: nomad init
Creates an example job file that can be used as a starting
point to customize further.
`
return strings.TrimSpace(helpText)
}
func (c *InitCommand) Synopsis() string {
return "Create an example job file"
}
func (c *InitCommand) Run(args []string) int {
// Check if the file already exists
_, err := os.Stat(DefaultInitName)
if err == nil || !os.IsNotExist(err) {
c.Ui.Error(fmt.Sprintf("Job '%s' already exists", DefaultInitName))
return 1
} else if !os.IsNotExist(err) {
c.Ui.Error(fmt.Sprintf("Failed to stat '%s': %v", DefaultInitName, err))
return 1
}
// Write out the example
err = ioutil.WriteFile(DefaultInitName, []byte(defaultJob), 0660)
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to write '%s': %v", DefaultInitName, err))
return 1
}
// Success
c.Ui.Output(fmt.Sprintf("Example job file written to %s", DefaultInitName))
return 0
}
const defaultJob = `
# There can only be a single job definition per file.
# Create a job with ID and Name 'example'
job "example" {
# Run the job in the global region, which is the default.
# region = "global"
# Specify the datacenters within the region this job can run in.
datacenters = ["dc1"]
# Service type jobs optimize for long-lived services. This is
# the default but we can change to batch for short-lived tasks.
# type = "service"
# Priority controls our access to resources and scheduling priority.
# This can be 1 to 100, inclusively, and defaults to 50.
# priority = 50
# Restrict our job to only linux. We can specify multiple
# constraints as needed.
constraint {
attribute = "$attr.kernel.name"
value = "linux"
}
# Configure the job to do rolling updates
update {
# Stagger updates every 10 seconds
stagger = "10s"
# Update a single task at a time
max_parallel = 1
}
# Create a 'cache' group. Each task in the group will be
# scheduled onto the same machine.
group "cache" {
# Control the number of instances of this groups.
# Defaults to 1
# count = 1
# Define a task to run
task "redis" {
# Use Docker to run the task.
driver = "docker"
# Configure Docker driver with the image
config {
image = "redis:latest"
}
# We must specify the resources required for
# this task to ensure it runs on a machine with
# enough capacity.
resources {
cpu = 500 # 500 Mhz
memory = 256 # 256MB
network {
mbits = 10
dynamic_ports = ["redis"]
}
}
}
}
}
`
| apognu/nomad | command/init.go | GO | mpl-2.0 | 2,862 |
class CreateCommentLabelUser < ActiveRecord::Migration
def self.up
create_table :comment_classification_plugin_comment_label_user do |t|
t.references :profile
t.references :comment
t.references :label
t.timestamps
end
end
def self.down
drop_table :comment_classification_plugin_comment_label_user
end
end
| evandrojr/noosferogov | plugins/comment_classification/db/migrate/20130822075623_create_comment_label_user.rb | Ruby | agpl-3.0 | 355 |
/*
* Copyright (c) 2014. Marshal Chen.
*/
package com.marshalchen.common.usefulModule.standuptimer.model;
import java.util.List;
public class MeetingStats {
private float numParticipants = 0;
private float individualStatusLength = 0;
private float meetingLength = 0;
private float quickestStatus = 0;
private float longestStatus = 0;
public MeetingStats(float numParticipants, float individualStatusLength, float meetingLength, float quickestStatus, float longestStatus) {
this.numParticipants = numParticipants;
this.individualStatusLength = individualStatusLength;
this.meetingLength = meetingLength;
this.quickestStatus = quickestStatus;
this.longestStatus = longestStatus;
}
public static MeetingStats getAverageStats(List<MeetingStats> meetingStatsList) {
float totalNumParticipants = 0;
float totalIndividualStatusLength = 0;
float totalMeetingLength = 0;
float totalQuickestStatus = 0;
float totalLongestStatus = 0;
for (MeetingStats meetingStats : meetingStatsList) {
totalNumParticipants += meetingStats.getNumParticipants();
totalIndividualStatusLength += meetingStats.getIndividualStatusLength();
totalMeetingLength += meetingStats.getMeetingLength();
totalQuickestStatus += meetingStats.getQuickestStatus();
totalLongestStatus += meetingStats.getLongestStatus();
}
return new MeetingStats(totalNumParticipants / meetingStatsList.size(),
totalIndividualStatusLength / meetingStatsList.size(),
totalMeetingLength / meetingStatsList.size(),
totalQuickestStatus / meetingStatsList.size(),
totalLongestStatus / meetingStatsList.size());
}
public float getNumParticipants() {
return numParticipants;
}
public float getIndividualStatusLength() {
return individualStatusLength;
}
public float getMeetingLength() {
return meetingLength;
}
public float getQuickestStatus() {
return quickestStatus;
}
public float getLongestStatus() {
return longestStatus;
}
}
| cymcsg/UltimateAndroid | deprecated/UltimateAndroidNormal/UltimateAndroid/src/com/marshalchen/common/usefulModule/standuptimer/model/MeetingStats.java | Java | apache-2.0 | 2,220 |
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.cli.command;
import java.util.Collection;
import org.springframework.boot.cli.command.options.OptionHelp;
import org.springframework.boot.cli.command.status.ExitStatus;
/**
* A single command that can be run from the CLI.
*
* @author Phillip Webb
* @author Dave Syer
* @author Stephane Nicoll
* @since 1.0.0
* @see #run(String...)
*/
public interface Command {
/**
* Returns the name of the command.
* @return the command's name
*/
String getName();
/**
* Returns a description of the command.
* @return the command's description
*/
String getDescription();
/**
* Returns usage help for the command. This should be a simple one-line string
* describing basic usage. e.g. '[options] <file>'. Do not include the name of
* the command in this string.
* @return the command's usage help
*/
String getUsageHelp();
/**
* Gets full help text for the command, e.g. a longer description and one line per
* option.
* @return the command's help text
*/
String getHelp();
/**
* Returns help for each supported option.
* @return help for each of the command's options
*/
Collection<OptionHelp> getOptionsHelp();
/**
* Return some examples for the command.
* @return the command's examples
*/
Collection<HelpExample> getExamples();
/**
* Run the command.
* @param args command arguments (this will not include the command itself)
* @return the outcome of the command
* @throws Exception if the command fails
*/
ExitStatus run(String... args) throws Exception;
}
| spring-projects/spring-boot | spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/Command.java | Java | apache-2.0 | 2,195 |
/*
* #%L
* BroadleafCommerce Common Libraries
* %%
* Copyright (C) 2009 - 2013 Broadleaf Commerce
* %%
* 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.
* #L%
*/
package org.broadleafcommerce.common.extensibility.jpa;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used to mark collections for multi-tenancy when the commercial multi-tenant module is loaded. Please note, multi-tenant
* collections are NOT eligible for level 2 cache, which results in a query to the database every time the collection is lazy initialized.
* This can result in production performance degradation depending on how frequently the collection is utilized. It is
* for this reason that we recommend utilizing a custom service or service extension that explicitly creates a query
* for the collection entity members based on the parent entity. See the multi-tenant module documentation for more
* information.
*
* @author Jeff Fischer
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface SiteDiscriminatable {
SiteDiscriminatableType type();
}
| cloudbearings/BroadleafCommerce | common/src/main/java/org/broadleafcommerce/common/extensibility/jpa/SiteDiscriminatable.java | Java | apache-2.0 | 1,707 |
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
package org.tensorflow.op.core;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.tensorflow.Operand;
import org.tensorflow.Output;
import org.tensorflow.op.Op;
import org.tensorflow.op.Operands;
import org.tensorflow.op.Scope;
import org.tensorflow.op.annotation.Operator;
/**
* Adds operations to compute the partial derivatives of sum of {@code y}s w.r.t {@code x}s,
* i.e., {@code d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...}
* <p>
* If {@code Options.dx()} values are set, they are as the initial symbolic partial derivatives of some loss
* function {@code L} w.r.t. {@code y}. {@code Options.dx()} must have the size of {@code y}.
* <p>
* If {@code Options.dx()} is not set, the implementation will use dx of {@code OnesLike} for all
* shapes in {@code y}.
* <p>
* The partial derivatives are returned in output {@code dy}, with the size of {@code x}.
* <p>
* Example of usage:
* <pre>{@code
* Gradients gradients = Gradients.create(scope, Arrays.asList(loss), Arrays.asList(w, b));
*
* Constant<Float> alpha = ops.constant(1.0f, Float.class);
* ApplyGradientDescent.create(scope, w, alpha, gradients.<Float>dy(0));
* ApplyGradientDescent.create(scope, b, alpha, gradients.<Float>dy(1));
* }</pre>
*/
@Operator
public class Gradients implements Op, Iterable<Operand<?>> {
/**
* Optional attributes for {@link Gradients}
*/
public static class Options {
/**
* @param dx partial derivatives of some loss function {@code L} w.r.t. {@code y}
* @return this option builder
*/
public Options dx(Iterable<? extends Operand<?>> dx) {
this.dx = dx;
return this;
}
private Iterable<? extends Operand<?>> dx;
private Options() {
}
}
/**
* Adds gradients computation ops to the graph according to scope.
*
* @param scope current graph scope
* @param y outputs of the function to derive
* @param x inputs of the function for which partial derivatives are computed
* @param options carries optional attributes values
* @return a new instance of {@code Gradients}
*/
public static Gradients create(
Scope scope,
Iterable<? extends Operand<?>> y,
Iterable<? extends Operand<?>> x,
Options... options) {
Output<?>[] dx = null;
if (options != null) {
for (Options opts : options) {
if (opts.dx != null) {
dx = Operands.asOutputs(opts.dx);
}
}
}
Output<?>[] dy =
scope
.graph()
.addGradients(
scope.makeOpName("Gradients"), Operands.asOutputs(y), Operands.asOutputs(x), dx);
return new Gradients(Arrays.asList(dy));
}
/**
* Adds gradients computation ops to the graph according to scope.
*
* <p>This is a simplified version of {@link #create(Scope, Iterable, Iterable, Options...)} where
* {@code y} is a single output.
*
* @param scope current graph scope
* @param y output of the function to derive
* @param x inputs of the function for which partial derivatives are computed
* @param options carries optional attributes values
* @return a new instance of {@code Gradients}
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static Gradients create(
Scope scope, Operand<?> y, Iterable<? extends Operand<?>> x, Options... options) {
return create(scope, (Iterable) Arrays.asList(y), x, options);
}
/**
* @param dx partial derivatives of some loss function {@code L} w.r.t. {@code y}
* @return builder to add more options to this operation
*/
public static Options dx(Iterable<? extends Operand<?>> dx) {
return new Options().dx(dx);
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Iterator<Operand<?>> iterator() {
return (Iterator) dy.iterator();
}
/**
* Partial derivatives of {@code y}s w.r.t. {@code x}s, with the size of {@code x}
*/
public List<Output<?>> dy() {
return dy;
}
/**
* Returns a symbolic handle to one of the gradient operation output
*
* <p>Warning: Does not check that the type of the tensor matches T. It is recommended to call
* this method with an explicit type parameter rather than letting it be inferred, e.g. {@code
* gradients.<Float>dy(0)}
*
* @param <T> The expected element type of the tensors produced by this output.
* @param index The index of the output among the gradients added by this operation
*/
@SuppressWarnings("unchecked")
public <T> Output<T> dy(int index) {
return (Output<T>) dy.get(index);
}
private List<Output<?>> dy;
private Gradients(List<Output<?>> dy) {
this.dy = dy;
}
}
| jbedorf/tensorflow | tensorflow/java/src/main/java/org/tensorflow/op/core/Gradients.java | Java | apache-2.0 | 5,361 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.runtime.iterative.convergence;
import org.apache.flink.api.common.aggregators.ConvergenceCriterion;
import org.apache.flink.types.LongValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A workset iteration is by definition converged if no records have been updated in the solutionset.
*/
public class WorksetEmptyConvergenceCriterion implements ConvergenceCriterion<LongValue> {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(WorksetEmptyConvergenceCriterion.class);
public static final String AGGREGATOR_NAME = "pact.runtime.workset-empty-aggregator";
@Override
public boolean isConverged(int iteration, LongValue value) {
long updatedElements = value.getValue();
if (log.isInfoEnabled()) {
log.info("[" + updatedElements + "] elements updated in the solutionset in iteration [" + iteration + "]");
}
return updatedElements == 0;
}
}
| hequn8128/flink | flink-runtime/src/main/java/org/apache/flink/runtime/iterative/convergence/WorksetEmptyConvergenceCriterion.java | Java | apache-2.0 | 1,774 |
/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.keycloak.models.jpa.entities;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@Table(name="CLIENT_ATTRIBUTES")
@Entity
@IdClass(ClientAttributeEntity.Key.class)
public class ClientAttributeEntity {
@Id
@ManyToOne(fetch= FetchType.LAZY)
@JoinColumn(name = "CLIENT_ID")
protected ClientEntity client;
@Id
@Column(name="NAME")
protected String name;
@Column(name = "VALUE", length = 4000)
protected String value;
public ClientEntity getClient() {
return client;
}
public void setClient(ClientEntity client) {
this.client = client;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static class Key implements Serializable {
protected ClientEntity client;
protected String name;
public Key() {
}
public Key(ClientEntity client, String name) {
this.client = client;
this.name = name;
}
public ClientEntity getClient() {
return client;
}
public String getName() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ClientAttributeEntity.Key key = (ClientAttributeEntity.Key) o;
if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false;
if (name != null ? !name.equals(key.name != null ? key.name : null) : key.name != null) return false;
return true;
}
@Override
public int hashCode() {
int result = client != null ? client.getId().hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!(o instanceof ClientAttributeEntity)) return false;
ClientAttributeEntity key = (ClientAttributeEntity) o;
if (client != null ? !client.getId().equals(key.client != null ? key.client.getId() : null) : key.client != null) return false;
if (name != null ? !name.equals(key.name != null ? key.name : null) : key.name != null) return false;
return true;
}
@Override
public int hashCode() {
int result = client != null ? client.getId().hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}
| thomasdarimont/keycloak | model/jpa/src/main/java/org/keycloak/models/jpa/entities/ClientAttributeEntity.java | Java | apache-2.0 | 3,880 |
# Flot Reference #
Consider a call to the plot function:
```js
var plot = $.plot(placeholder, data, options)
```
The placeholder is a jQuery object or DOM element or jQuery expression
that the plot will be put into. This placeholder needs to have its
width and height set as explained in the README (go read that now if
you haven't, it's short). The plot will modify some properties of the
placeholder so it's recommended you simply pass in a div that you
don't use for anything else. Make sure you check any fancy styling
you apply to the div, e.g. background images have been reported to be a
problem on IE 7.
The plot function can also be used as a jQuery chainable property. This form
naturally can't return the plot object directly, but you can still access it
via the 'plot' data key, like this:
```js
var plot = $("#placeholder").plot(data, options).data("plot");
```
The format of the data is documented below, as is the available
options. The plot object returned from the call has some methods you
can call. These are documented separately below.
Note that in general Flot gives no guarantees if you change any of the
objects you pass in to the plot function or get out of it since
they're not necessarily deep-copied.
## Data Format ##
The data is an array of data series:
```js
[ series1, series2, ... ]
```
A series can either be raw data or an object with properties. The raw
data format is an array of points:
```js
[ [x1, y1], [x2, y2], ... ]
```
E.g.
```js
[ [1, 3], [2, 14.01], [3.5, 3.14] ]
```
Note that to simplify the internal logic in Flot both the x and y
values must be numbers (even if specifying time series, see below for
how to do this). This is a common problem because you might retrieve
data from the database and serialize them directly to JSON without
noticing the wrong type. If you're getting mysterious errors, double
check that you're inputting numbers and not strings.
If a null is specified as a point or if one of the coordinates is null
or couldn't be converted to a number, the point is ignored when
drawing. As a special case, a null value for lines is interpreted as a
line segment end, i.e. the points before and after the null value are
not connected.
Lines and points take two coordinates. For filled lines and bars, you
can specify a third coordinate which is the bottom of the filled
area/bar (defaults to 0).
The format of a single series object is as follows:
```js
{
color: color or number
data: rawdata
label: string
lines: specific lines options
bars: specific bars options
points: specific points options
xaxis: number
yaxis: number
clickable: boolean
hoverable: boolean
shadowSize: number
highlightColor: color or number
}
```
You don't have to specify any of them except the data, the rest are
options that will get default values. Typically you'd only specify
label and data, like this:
```js
{
label: "y = 3",
data: [[0, 3], [10, 3]]
}
```
The label is used for the legend, if you don't specify one, the series
will not show up in the legend.
If you don't specify color, the series will get a color from the
auto-generated colors. The color is either a CSS color specification
(like "rgb(255, 100, 123)") or an integer that specifies which of
auto-generated colors to select, e.g. 0 will get color no. 0, etc.
The latter is mostly useful if you let the user add and remove series,
in which case you can hard-code the color index to prevent the colors
from jumping around between the series.
The "xaxis" and "yaxis" options specify which axis to use. The axes
are numbered from 1 (default), so { yaxis: 2} means that the series
should be plotted against the second y axis.
"clickable" and "hoverable" can be set to false to disable
interactivity for specific series if interactivity is turned on in
the plot, see below.
The rest of the options are all documented below as they are the same
as the default options passed in via the options parameter in the plot
commmand. When you specify them for a specific data series, they will
override the default options for the plot for that data series.
Here's a complete example of a simple data specification:
```js
[ { label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] },
{ label: "Bar", data: [ [11, 13], [19, 11], [30, -7] ] }
]
```
## Plot Options ##
All options are completely optional. They are documented individually
below, to change them you just specify them in an object, e.g.
```js
var options = {
series: {
lines: { show: true },
points: { show: true }
}
};
$.plot(placeholder, data, options);
```
## Customizing the legend ##
```js
legend: {
show: boolean
labelFormatter: null or (fn: string, series object -> string)
labelBoxBorderColor: color
noColumns: number
position: "ne" or "nw" or "se" or "sw"
margin: number of pixels or [x margin, y margin]
backgroundColor: null or color
backgroundOpacity: number between 0 and 1
container: null or jQuery object/DOM element/jQuery expression
sorted: null/false, true, "ascending", "descending", "reverse", or a comparator
}
```
The legend is generated as a table with the data series labels and
small label boxes with the color of the series. If you want to format
the labels in some way, e.g. make them to links, you can pass in a
function for "labelFormatter". Here's an example that makes them
clickable:
```js
labelFormatter: function(label, series) {
// series is the series object for the label
return '<a href="#' + label + '">' + label + '</a>';
}
```
To prevent a series from showing up in the legend, simply have the function
return null.
"noColumns" is the number of columns to divide the legend table into.
"position" specifies the overall placement of the legend within the
plot (top-right, top-left, etc.) and margin the distance to the plot
edge (this can be either a number or an array of two numbers like [x,
y]). "backgroundColor" and "backgroundOpacity" specifies the
background. The default is a partly transparent auto-detected
background.
If you want the legend to appear somewhere else in the DOM, you can
specify "container" as a jQuery object/expression to put the legend
table into. The "position" and "margin" etc. options will then be
ignored. Note that Flot will overwrite the contents of the container.
Legend entries appear in the same order as their series by default. If "sorted"
is "reverse" then they appear in the opposite order from their series. To sort
them alphabetically, you can specify true, "ascending" or "descending", where
true and "ascending" are equivalent.
You can also provide your own comparator function that accepts two
objects with "label" and "color" properties, and returns zero if they
are equal, a positive value if the first is greater than the second,
and a negative value if the first is less than the second.
```js
sorted: function(a, b) {
// sort alphabetically in ascending order
return a.label == b.label ? 0 : (
a.label > b.label ? 1 : -1
)
}
```
## Customizing the axes ##
```js
xaxis, yaxis: {
show: null or true/false
position: "bottom" or "top" or "left" or "right"
mode: null or "time" ("time" requires jquery.flot.time.js plugin)
timezone: null, "browser" or timezone (only makes sense for mode: "time")
color: null or color spec
tickColor: null or color spec
font: null or font spec object
min: null or number
max: null or number
autoscaleMargin: null or number
transform: null or fn: number -> number
inverseTransform: null or fn: number -> number
ticks: null or number or ticks array or (fn: axis -> ticks array)
tickSize: number or array
minTickSize: number or array
tickFormatter: (fn: number, object -> string) or string
tickDecimals: null or number
labelWidth: null or number
labelHeight: null or number
reserveSpace: null or true
tickLength: null or number
alignTicksWithAxis: null or number
}
```
All axes have the same kind of options. The following describes how to
configure one axis, see below for what to do if you've got more than
one x axis or y axis.
If you don't set the "show" option (i.e. it is null), visibility is
auto-detected, i.e. the axis will show up if there's data associated
with it. You can override this by setting the "show" option to true or
false.
The "position" option specifies where the axis is placed, bottom or
top for x axes, left or right for y axes. The "mode" option determines
how the data is interpreted, the default of null means as decimal
numbers. Use "time" for time series data; see the time series data
section. The time plugin (jquery.flot.time.js) is required for time
series support.
The "color" option determines the color of the line and ticks for the axis, and
defaults to the grid color with transparency. For more fine-grained control you
can also set the color of the ticks separately with "tickColor".
You can customize the font and color used to draw the axis tick labels with CSS
or directly via the "font" option. When "font" is null - the default - each
tick label is given the 'flot-tick-label' class. For compatibility with Flot
0.7 and earlier the labels are also given the 'tickLabel' class, but this is
deprecated and scheduled to be removed with the release of version 1.0.0.
To enable more granular control over styles, labels are divided between a set
of text containers, with each holding the labels for one axis. These containers
are given the classes 'flot-[x|y]-axis', and 'flot-[x|y]#-axis', where '#' is
the number of the axis when there are multiple axes. For example, the x-axis
labels for a simple plot with only a single x-axis might look like this:
```html
<div class='flot-x-axis flot-x1-axis'>
<div class='flot-tick-label'>January 2013</div>
...
</div>
```
For direct control over label styles you can also provide "font" as an object
with this format:
```js
{
size: 11,
lineHeight: 13,
style: "italic",
weight: "bold",
family: "sans-serif",
variant: "small-caps",
color: "#545454"
}
```
The size and lineHeight must be expressed in pixels; CSS units such as 'em'
or 'smaller' are not allowed.
The options "min"/"max" are the precise minimum/maximum value on the
scale. If you don't specify either of them, a value will automatically
be chosen based on the minimum/maximum data values. Note that Flot
always examines all the data values you feed to it, even if a
restriction on another axis may make some of them invisible (this
makes interactive use more stable).
The "autoscaleMargin" is a bit esoteric: it's the fraction of margin
that the scaling algorithm will add to avoid that the outermost points
ends up on the grid border. Note that this margin is only applied when
a min or max value is not explicitly set. If a margin is specified,
the plot will furthermore extend the axis end-point to the nearest
whole tick. The default value is "null" for the x axes and 0.02 for y
axes which seems appropriate for most cases.
"transform" and "inverseTransform" are callbacks you can put in to
change the way the data is drawn. You can design a function to
compress or expand certain parts of the axis non-linearly, e.g.
suppress weekends or compress far away points with a logarithm or some
other means. When Flot draws the plot, each value is first put through
the transform function. Here's an example, the x axis can be turned
into a natural logarithm axis with the following code:
```js
xaxis: {
transform: function (v) { return Math.log(v); },
inverseTransform: function (v) { return Math.exp(v); }
}
```
Similarly, for reversing the y axis so the values appear in inverse
order:
```js
yaxis: {
transform: function (v) { return -v; },
inverseTransform: function (v) { return -v; }
}
```
Note that for finding extrema, Flot assumes that the transform
function does not reorder values (it should be monotone).
The inverseTransform is simply the inverse of the transform function
(so v == inverseTransform(transform(v)) for all relevant v). It is
required for converting from canvas coordinates to data coordinates,
e.g. for a mouse interaction where a certain pixel is clicked. If you
don't use any interactive features of Flot, you may not need it.
The rest of the options deal with the ticks.
If you don't specify any ticks, a tick generator algorithm will make
some for you. The algorithm has two passes. It first estimates how
many ticks would be reasonable and uses this number to compute a nice
round tick interval size. Then it generates the ticks.
You can specify how many ticks the algorithm aims for by setting
"ticks" to a number. The algorithm always tries to generate reasonably
round tick values so even if you ask for three ticks, you might get
five if that fits better with the rounding. If you don't want any
ticks at all, set "ticks" to 0 or an empty array.
Another option is to skip the rounding part and directly set the tick
interval size with "tickSize". If you set it to 2, you'll get ticks at
2, 4, 6, etc. Alternatively, you can specify that you just don't want
ticks at a size less than a specific tick size with "minTickSize".
Note that for time series, the format is an array like [2, "month"],
see the next section.
If you want to completely override the tick algorithm, you can specify
an array for "ticks", either like this:
```js
ticks: [0, 1.2, 2.4]
```
Or like this where the labels are also customized:
```js
ticks: [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
```
You can mix the two if you like.
For extra flexibility you can specify a function as the "ticks"
parameter. The function will be called with an object with the axis
min and max and should return a ticks array. Here's a simplistic tick
generator that spits out intervals of pi, suitable for use on the x
axis for trigonometric functions:
```js
function piTickGenerator(axis) {
var res = [], i = Math.floor(axis.min / Math.PI);
do {
var v = i * Math.PI;
res.push([v, i + "\u03c0"]);
++i;
} while (v < axis.max);
return res;
}
```
You can control how the ticks look like with "tickDecimals", the
number of decimals to display (default is auto-detected).
Alternatively, for ultimate control over how ticks are formatted you can
provide a function to "tickFormatter". The function is passed two
parameters, the tick value and an axis object with information, and
should return a string. The default formatter looks like this:
```js
function formatter(val, axis) {
return val.toFixed(axis.tickDecimals);
}
```
The axis object has "min" and "max" with the range of the axis,
"tickDecimals" with the number of decimals to round the value to and
"tickSize" with the size of the interval between ticks as calculated
by the automatic axis scaling algorithm (or specified by you). Here's
an example of a custom formatter:
```js
function suffixFormatter(val, axis) {
if (val > 1000000)
return (val / 1000000).toFixed(axis.tickDecimals) + " MB";
else if (val > 1000)
return (val / 1000).toFixed(axis.tickDecimals) + " kB";
else
return val.toFixed(axis.tickDecimals) + " B";
}
```
"labelWidth" and "labelHeight" specifies a fixed size of the tick
labels in pixels. They're useful in case you need to align several
plots. "reserveSpace" means that even if an axis isn't shown, Flot
should reserve space for it - it is useful in combination with
labelWidth and labelHeight for aligning multi-axis charts.
"tickLength" is the length of the tick lines in pixels. By default, the
innermost axes will have ticks that extend all across the plot, while
any extra axes use small ticks. A value of null means use the default,
while a number means small ticks of that length - set it to 0 to hide
the lines completely.
If you set "alignTicksWithAxis" to the number of another axis, e.g.
alignTicksWithAxis: 1, Flot will ensure that the autogenerated ticks
of this axis are aligned with the ticks of the other axis. This may
improve the looks, e.g. if you have one y axis to the left and one to
the right, because the grid lines will then match the ticks in both
ends. The trade-off is that the forced ticks won't necessarily be at
natural places.
## Multiple axes ##
If you need more than one x axis or y axis, you need to specify for
each data series which axis they are to use, as described under the
format of the data series, e.g. { data: [...], yaxis: 2 } specifies
that a series should be plotted against the second y axis.
To actually configure that axis, you can't use the xaxis/yaxis options
directly - instead there are two arrays in the options:
```js
xaxes: []
yaxes: []
```
Here's an example of configuring a single x axis and two y axes (we
can leave options of the first y axis empty as the defaults are fine):
```js
{
xaxes: [ { position: "top" } ],
yaxes: [ { }, { position: "right", min: 20 } ]
}
```
The arrays get their default values from the xaxis/yaxis settings, so
say you want to have all y axes start at zero, you can simply specify
yaxis: { min: 0 } instead of adding a min parameter to all the axes.
Generally, the various interfaces in Flot dealing with data points
either accept an xaxis/yaxis parameter to specify which axis number to
use (starting from 1), or lets you specify the coordinate directly as
x2/x3/... or x2axis/x3axis/... instead of "x" or "xaxis".
## Time series data ##
Please note that it is now required to include the time plugin,
jquery.flot.time.js, for time series support.
Time series are a bit more difficult than scalar data because
calendars don't follow a simple base 10 system. For many cases, Flot
abstracts most of this away, but it can still be a bit difficult to
get the data into Flot. So we'll first discuss the data format.
The time series support in Flot is based on Javascript timestamps,
i.e. everywhere a time value is expected or handed over, a Javascript
timestamp number is used. This is a number, not a Date object. A
Javascript timestamp is the number of milliseconds since January 1,
1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's
in milliseconds, so remember to multiply by 1000!
You can see a timestamp like this
```js
alert((new Date()).getTime())
```
There are different schools of thought when it comes to diplay of
timestamps. Many will want the timestamps to be displayed according to
a certain time zone, usually the time zone in which the data has been
produced. Some want the localized experience, where the timestamps are
displayed according to the local time of the visitor. Flot supports
both. Optionally you can include a third-party library to get
additional timezone support.
Default behavior is that Flot always displays timestamps according to
UTC. The reason being that the core Javascript Date object does not
support other fixed time zones. Often your data is at another time
zone, so it may take a little bit of tweaking to work around this
limitation.
The easiest way to think about it is to pretend that the data
production time zone is UTC, even if it isn't. So if you have a
datapoint at 2002-02-20 08:00, you can generate a timestamp for eight
o'clock UTC even if it really happened eight o'clock UTC+0200.
In PHP you can get an appropriate timestamp with:
```php
strtotime("2002-02-20 UTC") * 1000
```
In Python you can get it with something like:
```python
calendar.timegm(datetime_object.timetuple()) * 1000
```
In .NET you can get it with something like:
```aspx
public static int GetJavascriptTimestamp(System.DateTime input)
{
System.TimeSpan span = new System.TimeSpan(System.DateTime.Parse("1/1/1970").Ticks);
System.DateTime time = input.Subtract(span);
return (long)(time.Ticks / 10000);
}
```
Javascript also has some support for parsing date strings, so it is
possible to generate the timestamps manually client-side.
If you've already got the real UTC timestamp, it's too late to use the
pretend trick described above. But you can fix up the timestamps by
adding the time zone offset, e.g. for UTC+0200 you would add 2 hours
to the UTC timestamp you got. Then it'll look right on the plot. Most
programming environments have some means of getting the timezone
offset for a specific date (note that you need to get the offset for
each individual timestamp to account for daylight savings).
The alternative with core Javascript is to interpret the timestamps
according to the time zone that the visitor is in, which means that
the ticks will shift with the time zone and daylight savings of each
visitor. This behavior is enabled by setting the axis option
"timezone" to the value "browser".
If you need more time zone functionality than this, there is still
another option. If you include the "timezone-js" library
<https://github.com/mde/timezone-js> in the page and set axis.timezone
to a value recognized by said library, Flot will use timezone-js to
interpret the timestamps according to that time zone.
Once you've gotten the timestamps into the data and specified "time"
as the axis mode, Flot will automatically generate relevant ticks and
format them. As always, you can tweak the ticks via the "ticks" option
- just remember that the values should be timestamps (numbers), not
Date objects.
Tick generation and formatting can also be controlled separately
through the following axis options:
```js
minTickSize: array
timeformat: null or format string
monthNames: null or array of size 12 of strings
dayNames: null or array of size 7 of strings
twelveHourClock: boolean
```
Here "timeformat" is a format string to use. You might use it like
this:
```js
xaxis: {
mode: "time",
timeformat: "%Y/%m/%d"
}
```
This will result in tick labels like "2000/12/24". A subset of the
standard strftime specifiers are supported (plus the nonstandard %q):
```js
%a: weekday name (customizable)
%b: month name (customizable)
%d: day of month, zero-padded (01-31)
%e: day of month, space-padded ( 1-31)
%H: hours, 24-hour time, zero-padded (00-23)
%I: hours, 12-hour time, zero-padded (01-12)
%m: month, zero-padded (01-12)
%M: minutes, zero-padded (00-59)
%q: quarter (1-4)
%S: seconds, zero-padded (00-59)
%y: year (two digits)
%Y: year (four digits)
%p: am/pm
%P: AM/PM (uppercase version of %p)
%w: weekday as number (0-6, 0 being Sunday)
```
You can customize the month names with the "monthNames" option. For
instance, for Danish you might specify:
```js
monthNames: ["jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"]
```
Similarly you can customize the weekday names with the "dayNames"
option. An example in French:
```js
dayNames: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"]
```
If you set "twelveHourClock" to true, the autogenerated timestamps
will use 12 hour AM/PM timestamps instead of 24 hour. This only
applies if you have not set "timeformat". Use the "%I" and "%p" or
"%P" options if you want to build your own format string with 12-hour
times.
If the Date object has a strftime property (and it is a function), it
will be used instead of the built-in formatter. Thus you can include
a strftime library such as http://hacks.bluesmoon.info/strftime/ for
more powerful date/time formatting.
If everything else fails, you can control the formatting by specifying
a custom tick formatter function as usual. Here's a simple example
which will format December 24 as 24/12:
```js
tickFormatter: function (val, axis) {
var d = new Date(val);
return d.getUTCDate() + "/" + (d.getUTCMonth() + 1);
}
```
Note that for the time mode "tickSize" and "minTickSize" are a bit
special in that they are arrays on the form "[value, unit]" where unit
is one of "second", "minute", "hour", "day", "month" and "year". So
you can specify
```js
minTickSize: [1, "month"]
```
to get a tick interval size of at least 1 month and correspondingly,
if axis.tickSize is [2, "day"] in the tick formatter, the ticks have
been produced with two days in-between.
## Customizing the data series ##
```js
series: {
lines, points, bars: {
show: boolean
lineWidth: number
fill: boolean or number
fillColor: null or color/gradient
}
lines, bars: {
zero: boolean
}
points: {
radius: number
symbol: "circle" or function
}
bars: {
barWidth: number
align: "left", "right" or "center"
horizontal: boolean
}
lines: {
steps: boolean
}
shadowSize: number
highlightColor: color or number
}
colors: [ color1, color2, ... ]
```
The options inside "series: {}" are copied to each of the series. So
you can specify that all series should have bars by putting it in the
global options, or override it for individual series by specifying
bars in a particular the series object in the array of data.
The most important options are "lines", "points" and "bars" that
specify whether and how lines, points and bars should be shown for
each data series. In case you don't specify anything at all, Flot will
default to showing lines (you can turn this off with
lines: { show: false }). You can specify the various types
independently of each other, and Flot will happily draw each of them
in turn (this is probably only useful for lines and points), e.g.
```js
var options = {
series: {
lines: { show: true, fill: true, fillColor: "rgba(255, 255, 255, 0.8)" },
points: { show: true, fill: false }
}
};
```
"lineWidth" is the thickness of the line or outline in pixels. You can
set it to 0 to prevent a line or outline from being drawn; this will
also hide the shadow.
"fill" is whether the shape should be filled. For lines, this produces
area graphs. You can use "fillColor" to specify the color of the fill.
If "fillColor" evaluates to false (default for everything except
points which are filled with white), the fill color is auto-set to the
color of the data series. You can adjust the opacity of the fill by
setting fill to a number between 0 (fully transparent) and 1 (fully
opaque).
For bars, fillColor can be a gradient, see the gradient documentation
below. "barWidth" is the width of the bars in units of the x axis (or
the y axis if "horizontal" is true), contrary to most other measures
that are specified in pixels. For instance, for time series the unit
is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of
a day. "align" specifies whether a bar should be left-aligned
(default), right-aligned or centered on top of the value it represents.
When "horizontal" is on, the bars are drawn horizontally, i.e. from the
y axis instead of the x axis; note that the bar end points are still
defined in the same way so you'll probably want to swap the
coordinates if you've been plotting vertical bars first.
Area and bar charts normally start from zero, regardless of the data's range.
This is because they convey information through size, and starting from a
different value would distort their meaning. In cases where the fill is purely
for decorative purposes, however, "zero" allows you to override this behavior.
It defaults to true for filled lines and bars; setting it to false tells the
series to use the same automatic scaling as an un-filled line.
For lines, "steps" specifies whether two adjacent data points are
connected with a straight (possibly diagonal) line or with first a
horizontal and then a vertical line. Note that this transforms the
data by adding extra points.
For points, you can specify the radius and the symbol. The only
built-in symbol type is circles, for other types you can use a plugin
or define them yourself by specifying a callback:
```js
function cross(ctx, x, y, radius, shadow) {
var size = radius * Math.sqrt(Math.PI) / 2;
ctx.moveTo(x - size, y - size);
ctx.lineTo(x + size, y + size);
ctx.moveTo(x - size, y + size);
ctx.lineTo(x + size, y - size);
}
```
The parameters are the drawing context, x and y coordinates of the
center of the point, a radius which corresponds to what the circle
would have used and whether the call is to draw a shadow (due to
limited canvas support, shadows are currently faked through extra
draws). It's good practice to ensure that the area covered by the
symbol is the same as for the circle with the given radius, this
ensures that all symbols have approximately the same visual weight.
"shadowSize" is the default size of shadows in pixels. Set it to 0 to
remove shadows.
"highlightColor" is the default color of the translucent overlay used
to highlight the series when the mouse hovers over it.
The "colors" array specifies a default color theme to get colors for
the data series from. You can specify as many colors as you like, like
this:
```js
colors: ["#d18b2c", "#dba255", "#919733"]
```
If there are more data series than colors, Flot will try to generate
extra colors by lightening and darkening colors in the theme.
## Customizing the grid ##
```js
grid: {
show: boolean
aboveData: boolean
color: color
backgroundColor: color/gradient or null
margin: number or margin object
labelMargin: number
axisMargin: number
markings: array of markings or (fn: axes -> array of markings)
borderWidth: number or object with "top", "right", "bottom" and "left" properties with different widths
borderColor: color or null or object with "top", "right", "bottom" and "left" properties with different colors
minBorderMargin: number or null
clickable: boolean
hoverable: boolean
autoHighlight: boolean
mouseActiveRadius: number
}
interaction: {
redrawOverlayInterval: number or -1
}
```
The grid is the thing with the axes and a number of ticks. Many of the
things in the grid are configured under the individual axes, but not
all. "color" is the color of the grid itself whereas "backgroundColor"
specifies the background color inside the grid area, here null means
that the background is transparent. You can also set a gradient, see
the gradient documentation below.
You can turn off the whole grid including tick labels by setting
"show" to false. "aboveData" determines whether the grid is drawn
above the data or below (below is default).
"margin" is the space in pixels between the canvas edge and the grid,
which can be either a number or an object with individual margins for
each side, in the form:
```js
margin: {
top: top margin in pixels
left: left margin in pixels
bottom: bottom margin in pixels
right: right margin in pixels
}
```
"labelMargin" is the space in pixels between tick labels and axis
line, and "axisMargin" is the space in pixels between axes when there
are two next to each other.
"borderWidth" is the width of the border around the plot. Set it to 0
to disable the border. Set it to an object with "top", "right",
"bottom" and "left" properties to use different widths. You can
also set "borderColor" if you want the border to have a different color
than the grid lines. Set it to an object with "top", "right", "bottom"
and "left" properties to use different colors. "minBorderMargin" controls
the default minimum margin around the border - it's used to make sure
that points aren't accidentally clipped by the canvas edge so by default
the value is computed from the point radius.
"markings" is used to draw simple lines and rectangular areas in the
background of the plot. You can either specify an array of ranges on
the form { xaxis: { from, to }, yaxis: { from, to } } (with multiple
axes, you can specify coordinates for other axes instead, e.g. as
x2axis/x3axis/...) or with a function that returns such an array given
the axes for the plot in an object as the first parameter.
You can set the color of markings by specifying "color" in the ranges
object. Here's an example array:
```js
markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" }, ... ]
```
If you leave out one of the values, that value is assumed to go to the
border of the plot. So for example if you only specify { xaxis: {
from: 0, to: 2 } } it means an area that extends from the top to the
bottom of the plot in the x range 0-2.
A line is drawn if from and to are the same, e.g.
```js
markings: [ { yaxis: { from: 1, to: 1 } }, ... ]
```
would draw a line parallel to the x axis at y = 1. You can control the
line width with "lineWidth" in the range object.
An example function that makes vertical stripes might look like this:
```js
markings: function (axes) {
var markings = [];
for (var x = Math.floor(axes.xaxis.min); x < axes.xaxis.max; x += 2)
markings.push({ xaxis: { from: x, to: x + 1 } });
return markings;
}
```
If you set "clickable" to true, the plot will listen for click events
on the plot area and fire a "plotclick" event on the placeholder with
a position and a nearby data item object as parameters. The coordinates
are available both in the unit of the axes (not in pixels) and in
global screen coordinates.
Likewise, if you set "hoverable" to true, the plot will listen for
mouse move events on the plot area and fire a "plothover" event with
the same parameters as the "plotclick" event. If "autoHighlight" is
true (the default), nearby data items are highlighted automatically.
If needed, you can disable highlighting and control it yourself with
the highlight/unhighlight plot methods described elsewhere.
You can use "plotclick" and "plothover" events like this:
```js
$.plot($("#placeholder"), [ d ], { grid: { clickable: true } });
$("#placeholder").bind("plotclick", function (event, pos, item) {
alert("You clicked at " + pos.x + ", " + pos.y);
// axis coordinates for other axes, if present, are in pos.x2, pos.x3, ...
// if you need global screen coordinates, they are pos.pageX, pos.pageY
if (item) {
highlight(item.series, item.datapoint);
alert("You clicked a point!");
}
});
```
The item object in this example is either null or a nearby object on the form:
```js
item: {
datapoint: the point, e.g. [0, 2]
dataIndex: the index of the point in the data array
series: the series object
seriesIndex: the index of the series
pageX, pageY: the global screen coordinates of the point
}
```
For instance, if you have specified the data like this
```js
$.plot($("#placeholder"), [ { label: "Foo", data: [[0, 10], [7, 3]] } ], ...);
```
and the mouse is near the point (7, 3), "datapoint" is [7, 3],
"dataIndex" will be 1, "series" is a normalized series object with
among other things the "Foo" label in series.label and the color in
series.color, and "seriesIndex" is 0. Note that plugins and options
that transform the data can shift the indexes from what you specified
in the original data array.
If you use the above events to update some other information and want
to clear out that info in case the mouse goes away, you'll probably
also need to listen to "mouseout" events on the placeholder div.
"mouseActiveRadius" specifies how far the mouse can be from an item
and still activate it. If there are two or more points within this
radius, Flot chooses the closest item. For bars, the top-most bar
(from the latest specified data series) is chosen.
If you want to disable interactivity for a specific data series, you
can set "hoverable" and "clickable" to false in the options for that
series, like this:
```js
{ data: [...], label: "Foo", clickable: false }
```
"redrawOverlayInterval" specifies the maximum time to delay a redraw
of interactive things (this works as a rate limiting device). The
default is capped to 60 frames per second. You can set it to -1 to
disable the rate limiting.
## Specifying gradients ##
A gradient is specified like this:
```js
{ colors: [ color1, color2, ... ] }
```
For instance, you might specify a background on the grid going from
black to gray like this:
```js
grid: {
backgroundColor: { colors: ["#000", "#999"] }
}
```
For the series you can specify the gradient as an object that
specifies the scaling of the brightness and the opacity of the series
color, e.g.
```js
{ colors: [{ opacity: 0.8 }, { brightness: 0.6, opacity: 0.8 } ] }
```
where the first color simply has its alpha scaled, whereas the second
is also darkened. For instance, for bars the following makes the bars
gradually disappear, without outline:
```js
bars: {
show: true,
lineWidth: 0,
fill: true,
fillColor: { colors: [ { opacity: 0.8 }, { opacity: 0.1 } ] }
}
```
Flot currently only supports vertical gradients drawn from top to
bottom because that's what works with IE.
## Plot Methods ##
The Plot object returned from the plot function has some methods you
can call:
- highlight(series, datapoint)
Highlight a specific datapoint in the data series. You can either
specify the actual objects, e.g. if you got them from a
"plotclick" event, or you can specify the indices, e.g.
highlight(1, 3) to highlight the fourth point in the second series
(remember, zero-based indexing).
- unhighlight(series, datapoint) or unhighlight()
Remove the highlighting of the point, same parameters as
highlight.
If you call unhighlight with no parameters, e.g. as
plot.unhighlight(), all current highlights are removed.
- setData(data)
You can use this to reset the data used. Note that axis scaling,
ticks, legend etc. will not be recomputed (use setupGrid() to do
that). You'll probably want to call draw() afterwards.
You can use this function to speed up redrawing a small plot if
you know that the axes won't change. Put in the new data with
setData(newdata), call draw(), and you're good to go. Note that
for large datasets, almost all the time is consumed in draw()
plotting the data so in this case don't bother.
- setupGrid()
Recalculate and set axis scaling, ticks, legend etc.
Note that because of the drawing model of the canvas, this
function will immediately redraw (actually reinsert in the DOM)
the labels and the legend, but not the actual tick lines because
they're drawn on the canvas. You need to call draw() to get the
canvas redrawn.
- draw()
Redraws the plot canvas.
- triggerRedrawOverlay()
Schedules an update of an overlay canvas used for drawing
interactive things like a selection and point highlights. This
is mostly useful for writing plugins. The redraw doesn't happen
immediately, instead a timer is set to catch multiple successive
redraws (e.g. from a mousemove). You can get to the overlay by
setting up a drawOverlay hook.
- width()/height()
Gets the width and height of the plotting area inside the grid.
This is smaller than the canvas or placeholder dimensions as some
extra space is needed (e.g. for labels).
- offset()
Returns the offset of the plotting area inside the grid relative
to the document, useful for instance for calculating mouse
positions (event.pageX/Y minus this offset is the pixel position
inside the plot).
- pointOffset({ x: xpos, y: ypos })
Returns the calculated offset of the data point at (x, y) in data
space within the placeholder div. If you are working with multiple
axes, you can specify the x and y axis references, e.g.
```js
o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 })
// o.left and o.top now contains the offset within the div
````
- resize()
Tells Flot to resize the drawing canvas to the size of the
placeholder. You need to run setupGrid() and draw() afterwards as
canvas resizing is a destructive operation. This is used
internally by the resize plugin.
- shutdown()
Cleans up any event handlers Flot has currently registered. This
is used internally.
There are also some members that let you peek inside the internal
workings of Flot which is useful in some cases. Note that if you change
something in the objects returned, you're changing the objects used by
Flot to keep track of its state, so be careful.
- getData()
Returns an array of the data series currently used in normalized
form with missing settings filled in according to the global
options. So for instance to find out what color Flot has assigned
to the data series, you could do this:
```js
var series = plot.getData();
for (var i = 0; i < series.length; ++i)
alert(series[i].color);
```
A notable other interesting field besides color is datapoints
which has a field "points" with the normalized data points in a
flat array (the field "pointsize" is the increment in the flat
array to get to the next point so for a dataset consisting only of
(x,y) pairs it would be 2).
- getAxes()
Gets an object with the axes. The axes are returned as the
attributes of the object, so for instance getAxes().xaxis is the
x axis.
Various things are stuffed inside an axis object, e.g. you could
use getAxes().xaxis.ticks to find out what the ticks are for the
xaxis. Two other useful attributes are p2c and c2p, functions for
transforming from data point space to the canvas plot space and
back. Both returns values that are offset with the plot offset.
Check the Flot source code for the complete set of attributes (or
output an axis with console.log() and inspect it).
With multiple axes, the extra axes are returned as x2axis, x3axis,
etc., e.g. getAxes().y2axis is the second y axis. You can check
y2axis.used to see whether the axis is associated with any data
points and y2axis.show to see if it is currently shown.
- getPlaceholder()
Returns placeholder that the plot was put into. This can be useful
for plugins for adding DOM elements or firing events.
- getCanvas()
Returns the canvas used for drawing in case you need to hack on it
yourself. You'll probably need to get the plot offset too.
- getPlotOffset()
Gets the offset that the grid has within the canvas as an object
with distances from the canvas edges as "left", "right", "top",
"bottom". I.e., if you draw a circle on the canvas with the center
placed at (left, top), its center will be at the top-most, left
corner of the grid.
- getOptions()
Gets the options for the plot, normalized, with default values
filled in. You get a reference to actual values used by Flot, so
if you modify the values in here, Flot will use the new values.
If you change something, you probably have to call draw() or
setupGrid() or triggerRedrawOverlay() to see the change.
## Hooks ##
In addition to the public methods, the Plot object also has some hooks
that can be used to modify the plotting process. You can install a
callback function at various points in the process, the function then
gets access to the internal data structures in Flot.
Here's an overview of the phases Flot goes through:
1. Plugin initialization, parsing options
2. Constructing the canvases used for drawing
3. Set data: parsing data specification, calculating colors,
copying raw data points into internal format,
normalizing them, finding max/min for axis auto-scaling
4. Grid setup: calculating axis spacing, ticks, inserting tick
labels, the legend
5. Draw: drawing the grid, drawing each of the series in turn
6. Setting up event handling for interactive features
7. Responding to events, if any
8. Shutdown: this mostly happens in case a plot is overwritten
Each hook is simply a function which is put in the appropriate array.
You can add them through the "hooks" option, and they are also available
after the plot is constructed as the "hooks" attribute on the returned
plot object, e.g.
```js
// define a simple draw hook
function hellohook(plot, canvascontext) { alert("hello!"); };
// pass it in, in an array since we might want to specify several
var plot = $.plot(placeholder, data, { hooks: { draw: [hellohook] } });
// we can now find it again in plot.hooks.draw[0] unless a plugin
// has added other hooks
```
The available hooks are described below. All hook callbacks get the
plot object as first parameter. You can find some examples of defined
hooks in the plugins bundled with Flot.
- processOptions [phase 1]
```function(plot, options)```
Called after Flot has parsed and merged options. Useful in the
instance where customizations beyond simple merging of default
values is needed. A plugin might use it to detect that it has been
enabled and then turn on or off other options.
- processRawData [phase 3]
```function(plot, series, data, datapoints)```
Called before Flot copies and normalizes the raw data for the given
series. If the function fills in datapoints.points with normalized
points and sets datapoints.pointsize to the size of the points,
Flot will skip the copying/normalization step for this series.
In any case, you might be interested in setting datapoints.format,
an array of objects for specifying how a point is normalized and
how it interferes with axis scaling. It accepts the following options:
```js
{
x, y: boolean,
number: boolean,
required: boolean,
defaultValue: value,
autoscale: boolean
}
```
"x" and "y" specify whether the value is plotted against the x or y axis,
and is currently used only to calculate axis min-max ranges. The default
format array, for example, looks like this:
```js
[
{ x: true, number: true, required: true },
{ y: true, number: true, required: true }
]
```
This indicates that a point, i.e. [0, 25], consists of two values, with the
first being plotted on the x axis and the second on the y axis.
If "number" is true, then the value must be numeric, and is set to null if
it cannot be converted to a number.
"defaultValue" provides a fallback in case the original value is null. This
is for instance handy for bars, where one can omit the third coordinate
(the bottom of the bar), which then defaults to zero.
If "required" is true, then the value must exist (be non-null) for the
point as a whole to be valid. If no value is provided, then the entire
point is cleared out with nulls, turning it into a gap in the series.
"autoscale" determines whether the value is considered when calculating an
automatic min-max range for the axes that the value is plotted against.
- processDatapoints [phase 3]
```function(plot, series, datapoints)```
Called after normalization of the given series but before finding
min/max of the data points. This hook is useful for implementing data
transformations. "datapoints" contains the normalized data points in
a flat array as datapoints.points with the size of a single point
given in datapoints.pointsize. Here's a simple transform that
multiplies all y coordinates by 2:
```js
function multiply(plot, series, datapoints) {
var points = datapoints.points, ps = datapoints.pointsize;
for (var i = 0; i < points.length; i += ps)
points[i + 1] *= 2;
}
```
Note that you must leave datapoints in a good condition as Flot
doesn't check it or do any normalization on it afterwards.
- processOffset [phase 4]
```function(plot, offset)```
Called after Flot has initialized the plot's offset, but before it
draws any axes or plot elements. This hook is useful for customizing
the margins between the grid and the edge of the canvas. "offset" is
an object with attributes "top", "bottom", "left" and "right",
corresponding to the margins on the four sides of the plot.
- drawBackground [phase 5]
```function(plot, canvascontext)```
Called before all other drawing operations. Used to draw backgrounds
or other custom elements before the plot or axes have been drawn.
- drawSeries [phase 5]
```function(plot, canvascontext, series)```
Hook for custom drawing of a single series. Called just before the
standard drawing routine has been called in the loop that draws
each series.
- draw [phase 5]
```function(plot, canvascontext)```
Hook for drawing on the canvas. Called after the grid is drawn
(unless it's disabled or grid.aboveData is set) and the series have
been plotted (in case any points, lines or bars have been turned
on). For examples of how to draw things, look at the source code.
- bindEvents [phase 6]
```function(plot, eventHolder)```
Called after Flot has setup its event handlers. Should set any
necessary event handlers on eventHolder, a jQuery object with the
canvas, e.g.
```js
function (plot, eventHolder) {
eventHolder.mousedown(function (e) {
alert("You pressed the mouse at " + e.pageX + " " + e.pageY);
});
}
```
Interesting events include click, mousemove, mouseup/down. You can
use all jQuery events. Usually, the event handlers will update the
state by drawing something (add a drawOverlay hook and call
triggerRedrawOverlay) or firing an externally visible event for
user code. See the crosshair plugin for an example.
Currently, eventHolder actually contains both the static canvas
used for the plot itself and the overlay canvas used for
interactive features because some versions of IE get the stacking
order wrong. The hook only gets one event, though (either for the
overlay or for the static canvas).
Note that custom plot events generated by Flot are not generated on
eventHolder, but on the div placeholder supplied as the first
argument to the plot call. You can get that with
plot.getPlaceholder() - that's probably also the one you should use
if you need to fire a custom event.
- drawOverlay [phase 7]
```function (plot, canvascontext)```
The drawOverlay hook is used for interactive things that need a
canvas to draw on. The model currently used by Flot works the way
that an extra overlay canvas is positioned on top of the static
canvas. This overlay is cleared and then completely redrawn
whenever something interesting happens. This hook is called when
the overlay canvas is to be redrawn.
"canvascontext" is the 2D context of the overlay canvas. You can
use this to draw things. You'll most likely need some of the
metrics computed by Flot, e.g. plot.width()/plot.height(). See the
crosshair plugin for an example.
- shutdown [phase 8]
```function (plot, eventHolder)```
Run when plot.shutdown() is called, which usually only happens in
case a plot is overwritten by a new plot. If you're writing a
plugin that adds extra DOM elements or event handlers, you should
add a callback to clean up after you. Take a look at the section in
PLUGINS.txt for more info.
## Plugins ##
Plugins extend the functionality of Flot. To use a plugin, simply
include its Javascript file after Flot in the HTML page.
If you're worried about download size/latency, you can concatenate all
the plugins you use, and Flot itself for that matter, into one big file
(make sure you get the order right), then optionally run it through a
Javascript minifier such as YUI Compressor.
Here's a brief explanation of how the plugin plumbings work:
Each plugin registers itself in the global array $.plot.plugins. When
you make a new plot object with $.plot, Flot goes through this array
calling the "init" function of each plugin and merging default options
from the "option" attribute of the plugin. The init function gets a
reference to the plot object created and uses this to register hooks
and add new public methods if needed.
See the PLUGINS.txt file for details on how to write a plugin. As the
above description hints, it's actually pretty easy.
## Version number ##
The version number of Flot is available in ```$.plot.version```.
| ysawa/ysawacom | vendor/assets/javascripts/flot/API.md | Markdown | apache-2.0 | 53,649 |
# This hook overrides config.sub and config.guess.
hook() {
local _cfgdir="${XBPS_COMMONDIR}/environment/configure/automake"
if [ -z "$build_style" -o "$build_style" = "gnu-configure" ]; then
for f in $(find "${wrksrc}" -type f -name "*config*.sub"); do
cp -f ${_cfgdir}/config.sub ${f}
done
for f in $(find "${wrksrc}" -type f -name "*config*.guess"); do
cp -f ${_cfgdir}/config.guess ${f}
done
fi
}
| oliver-cfc/void-packages | common/hooks/pre-configure/01-override-config.sh | Shell | bsd-2-clause | 420 |
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Pdf
*/
namespace ZendPdf\Resource\Font\CidFont;
use ZendPdf as Pdf;
use ZendPdf\Exception;
use ZendPdf\InternalType;
use ZendPdf\Resource\Font as FontResource;
/**
* Adobe PDF CIDFont font object implementation
*
* A CIDFont program contains glyph descriptions that are accessed using a CID as
* the character selector. There are two types of CIDFont. A Type 0 CIDFont contains
* glyph descriptions based on Adobe’s Type 1 font format, whereas those in a
* Type 2 CIDFont are based on the TrueType font format.
*
* A CIDFont dictionary is a PDF object that contains information about a CIDFont program.
* Although its Type value is Font, a CIDFont is not actually a font. It does not have an Encoding
* entry, it cannot be listed in the Font subdictionary of a resource dictionary, and it cannot be
* used as the operand of the Tf operator. It is used only as a descendant of a Type 0 font.
* The CMap in the Type 0 font is what defines the encoding that maps character codes to CIDs
* in the CIDFont.
*
* Font objects should be normally be obtained from the factory methods
* {@link \ZendPdf\Font::fontWithName} and {@link \ZendPdf\Font::fontWithPath}.
*
* @package Zend_PDF
* @subpackage Zend_PDF_Fonts
*/
abstract class AbstractCidFont extends FontResource\AbstractFont
{
/**
* Object representing the font's cmap (character to glyph map).
* @var \ZendPdf\Cmap\AbstractCmap
*/
protected $_cmap = null;
/**
* Array containing the widths of each character that have entries in used character map.
*
* @var array
*/
protected $_charWidths = null;
/**
* Width for characters missed in the font
*
* @var integer
*/
protected $_missingCharWidth = 0;
/**
* Object constructor
*
* @param \ZendPdf\BinaryParser\Font\OpenType\AbstractOpenType $fontParser Font parser object
* containing OpenType file.
* @param integer $embeddingOptions Options for font embedding.
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function __construct(Pdf\BinaryParser\Font\OpenType\AbstractOpenType $fontParser)
{
parent::__construct();
$fontParser->parse();
/* Object properties */
$this->_fontNames = $fontParser->names;
$this->_isBold = $fontParser->isBold;
$this->_isItalic = $fontParser->isItalic;
$this->_isMonospaced = $fontParser->isMonospaced;
$this->_underlinePosition = $fontParser->underlinePosition;
$this->_underlineThickness = $fontParser->underlineThickness;
$this->_strikePosition = $fontParser->strikePosition;
$this->_strikeThickness = $fontParser->strikeThickness;
$this->_unitsPerEm = $fontParser->unitsPerEm;
$this->_ascent = $fontParser->ascent;
$this->_descent = $fontParser->descent;
$this->_lineGap = $fontParser->lineGap;
$this->_cmap = $fontParser->cmap;
/* Resource dictionary */
$baseFont = $this->getFontName(Pdf\Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
$this->_resource->BaseFont = new InternalType\NameObject($baseFont);
/**
* Prepare widths array.
*/
/* Constract characters widths array using font CMap and glyphs widths array */
$glyphWidths = $fontParser->glyphWidths;
$charGlyphs = $this->_cmap->getCoveredCharactersGlyphs();
$charWidths = array();
foreach ($charGlyphs as $charCode => $glyph) {
$charWidths[$charCode] = $glyphWidths[$glyph];
}
$this->_charWidths = $charWidths;
$this->_missingCharWidth = $glyphWidths[0];
/* Width array optimization. Step1: extract default value */
$widthFrequencies = array_count_values($charWidths);
$defaultWidth = null;
$defaultWidthFrequency = -1;
foreach ($widthFrequencies as $width => $frequency) {
if ($frequency > $defaultWidthFrequency) {
$defaultWidth = $width;
$defaultWidthFrequency = $frequency;
}
}
// Store default value in the font dictionary
$this->_resource->DW = new InternalType\NumericObject($this->toEmSpace($defaultWidth));
// Remove characters which corresponds to default width from the widths array
$defWidthChars = array_keys($charWidths, $defaultWidth);
foreach ($defWidthChars as $charCode) {
unset($charWidths[$charCode]);
}
// Order cheracter widths aray by character codes
ksort($charWidths, SORT_NUMERIC);
/* Width array optimization. Step2: Compact character codes sequences */
$lastCharCode = -1;
$widthsSequences = array();
foreach ($charWidths as $charCode => $width) {
if ($lastCharCode == -1) {
$charCodesSequense = array();
$sequenceStartCode = $charCode;
} elseif ($charCode != $lastCharCode + 1) {
// New chracters sequence detected
$widthsSequences[$sequenceStartCode] = $charCodesSequense;
$charCodesSequense = array();
$sequenceStartCode = $charCode;
}
$charCodesSequense[] = $width;
$lastCharCode = $charCode;
}
// Save last sequence, if widths array is not empty (it may happens for monospaced fonts)
if (count($charWidths) != 0) {
$widthsSequences[$sequenceStartCode] = $charCodesSequense;
}
$pdfCharsWidths = array();
foreach ($widthsSequences as $startCode => $widthsSequence) {
/* Width array optimization. Step3: Compact widths sequences */
$pdfWidths = array();
$lastWidth = -1;
$widthsInSequence = 0;
foreach ($widthsSequence as $width) {
if ($lastWidth != $width) {
// New width is detected
if ($widthsInSequence != 0) {
// Previous width value was a part of the widths sequence. Save it as 'c_1st c_last w'.
$pdfCharsWidths[] = new InternalType\NumericObject($startCode); // First character code
$pdfCharsWidths[] = new InternalType\NumericObject($startCode + $widthsInSequence - 1); // Last character code
$pdfCharsWidths[] = new InternalType\NumericObject($this->toEmSpace($lastWidth)); // Width
// Reset widths sequence
$startCode = $startCode + $widthsInSequence;
$widthsInSequence = 0;
}
// Collect new width
$pdfWidths[] = new InternalType\NumericObject($this->toEmSpace($width));
$lastWidth = $width;
} else {
// Width is equal to previous
if (count($pdfWidths) != 0) {
// We already have some widths collected
// So, we've just detected new widths sequence
// Remove last element from widths list, since it's a part of widths sequence
array_pop($pdfWidths);
// and write the rest if it's not empty
if (count($pdfWidths) != 0) {
// Save it as 'c_1st [w1 w2 ... wn]'.
$pdfCharsWidths[] = new InternalType\NumericObject($startCode); // First character code
$pdfCharsWidths[] = new InternalType\ArrayObject($pdfWidths); // Widths array
// Reset widths collection
$startCode += count($pdfWidths);
$pdfWidths = array();
}
$widthsInSequence = 2;
} else {
// Continue widths sequence
$widthsInSequence++;
}
}
}
// Check if we have widths collection or widths sequence to wite it down
if (count($pdfWidths) != 0) {
// We have some widths collected
// Save it as 'c_1st [w1 w2 ... wn]'.
$pdfCharsWidths[] = new InternalType\NumericObject($startCode); // First character code
$pdfCharsWidths[] = new InternalType\ArrayObject($pdfWidths); // Widths array
} elseif ($widthsInSequence != 0){
// We have widths sequence
// Save it as 'c_1st c_last w'.
$pdfCharsWidths[] = new InternalType\NumericObject($startCode); // First character code
$pdfCharsWidths[] = new InternalType\NumericObject($startCode + $widthsInSequence - 1); // Last character code
$pdfCharsWidths[] = new InternalType\NumericObject($this->toEmSpace($lastWidth)); // Width
}
}
/* Create the \ZendPdf\InternalType\ArrayObject object and add it to the font's
* object factory and resource dictionary.
*/
$widthsArrayElement = new InternalType\ArrayObject($pdfCharsWidths);
$widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
$this->_resource->W = $widthsObject;
/* CIDSystemInfo dictionary */
$cidSystemInfo = new InternalType\DictionaryObject();
$cidSystemInfo->Registry = new InternalType\StringObject('Adobe');
$cidSystemInfo->Ordering = new InternalType\StringObject('UCS');
$cidSystemInfo->Supplement = new InternalType\NumericObject(0);
$cidSystemInfoObject = $this->_objectFactory->newObject($cidSystemInfo);
$this->_resource->CIDSystemInfo = $cidSystemInfoObject;
}
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function glyphNumbersForCharacters($characterCodes)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function glyphNumberForCharacter($characterCode)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
/* Convert the string to UTF-16BE encoding so we can match the string's
* character codes to those found in the cmap.
*/
if ($charEncoding != 'UTF-16BE') {
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
$charCount = iconv_strlen($string, 'UTF-16BE');
if ($charCount == 0) {
return 0;
}
/* Calculate the score by doing a lookup for each character.
*/
$score = 0;
$maxIndex = strlen($string);
for ($i = 0; $i < $maxIndex; $i++) {
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$charCode = (ord($string[$i]) << 8) | ord($string[++$i]);
/* This could probably be optimized a bit with a binary search...
*/
if (isset($this->_charWidths[$charCode])) {
$score++;
}
}
return $score / $charCount;
}
/**
* Returns the widths of the Chars.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForChar()}.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
*/
public function widthsForChars($charCodes)
{
$widths = array();
foreach ($charCodes as $key => $charCode) {
if (!isset($this->_charWidths[$charCode])) {
$widths[$key] = $this->_missingCharWidth;
} else {
$widths[$key] = $this->_charWidths[$charCode];
}
}
return $widths;
}
/**
* Returns the width of the character.
*
* Like {@link widthsForChars()} but used for one char at a time.
*
* @param integer $charCode
* @return integer
*/
public function widthForChar($charCode)
{
if (!isset($this->_charWidths[$charCode])) {
return $this->_missingCharWidth;
}
return $this->_charWidths[$charCode];
}
/**
* Returns the widths of the glyphs.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function widthsForGlyphs($glyphNumbers)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function widthForGlyph($glyphNumber)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string to the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function encodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string from the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
* @throws \ZendPdf\Exception\ExceptionInterface
*/
public function decodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Exception\RuntimeException('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
}
| Samuel18/qrcodeGene | vendor/zendframework/zendpdf/library/ZendPdf/Resource/Font/CidFont/AbstractCidFont.php | PHP | bsd-3-clause | 18,407 |
// Copyright 2009 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.
// HTTP Response reading and parsing.
package http
import (
"bufio"
"errors"
"io"
"net/textproto"
"net/url"
"strconv"
"strings"
)
var respExcludeHeader = map[string]bool{
"Content-Length": true,
"Transfer-Encoding": true,
"Trailer": true,
}
// Response represents the response from an HTTP request.
//
type Response struct {
Status string // e.g. "200 OK"
StatusCode int // e.g. 200
Proto string // e.g. "HTTP/1.0"
ProtoMajor int // e.g. 1
ProtoMinor int // e.g. 0
// Header maps header keys to values. If the response had multiple
// headers with the same key, they will be concatenated, with comma
// delimiters. (Section 4.2 of RFC 2616 requires that multiple headers
// be semantically equivalent to a comma-delimited sequence.) Values
// duplicated by other fields in this struct (e.g., ContentLength) are
// omitted from Header.
//
// Keys in the map are canonicalized (see CanonicalHeaderKey).
Header Header
// Body represents the response body.
//
// The http Client and Transport guarantee that Body is always
// non-nil, even on responses without a body or responses with
// a zero-lengthed body.
//
// The Body is automatically dechunked if the server replied
// with a "chunked" Transfer-Encoding.
Body io.ReadCloser
// ContentLength records the length of the associated content. The
// value -1 indicates that the length is unknown. Unless Request.Method
// is "HEAD", values >= 0 indicate that the given number of bytes may
// be read from Body.
ContentLength int64
// Contains transfer encodings from outer-most to inner-most. Value is
// nil, means that "identity" encoding is used.
TransferEncoding []string
// Close records whether the header directed that the connection be
// closed after reading Body. The value is advice for clients: neither
// ReadResponse nor Response.Write ever closes a connection.
Close bool
// Trailer maps trailer keys to values, in the same
// format as the header.
Trailer Header
// The Request that was sent to obtain this Response.
// Request's Body is nil (having already been consumed).
// This is only populated for Client requests.
Request *Request
}
// Cookies parses and returns the cookies set in the Set-Cookie headers.
func (r *Response) Cookies() []*Cookie {
return readSetCookies(r.Header)
}
var ErrNoLocation = errors.New("http: no Location header in response")
// Location returns the URL of the response's "Location" header,
// if present. Relative redirects are resolved relative to
// the Response's Request. ErrNoLocation is returned if no
// Location header is present.
func (r *Response) Location() (*url.URL, error) {
lv := r.Header.Get("Location")
if lv == "" {
return nil, ErrNoLocation
}
if r.Request != nil && r.Request.URL != nil {
return r.Request.URL.Parse(lv)
}
return url.Parse(lv)
}
// ReadResponse reads and returns an HTTP response from r. The
// req parameter specifies the Request that corresponds to
// this Response. Clients must call resp.Body.Close when finished
// reading resp.Body. After that call, clients can inspect
// resp.Trailer to find key/value pairs included in the response
// trailer.
func ReadResponse(r *bufio.Reader, req *Request) (resp *Response, err error) {
tp := textproto.NewReader(r)
resp = new(Response)
resp.Request = req
// Parse the first line of the response.
line, err := tp.ReadLine()
if err != nil {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return nil, err
}
f := strings.SplitN(line, " ", 3)
if len(f) < 2 {
return nil, &badStringError{"malformed HTTP response", line}
}
reasonPhrase := ""
if len(f) > 2 {
reasonPhrase = f[2]
}
resp.Status = f[1] + " " + reasonPhrase
resp.StatusCode, err = strconv.Atoi(f[1])
if err != nil {
return nil, &badStringError{"malformed HTTP status code", f[1]}
}
resp.Proto = f[0]
var ok bool
if resp.ProtoMajor, resp.ProtoMinor, ok = ParseHTTPVersion(resp.Proto); !ok {
return nil, &badStringError{"malformed HTTP version", resp.Proto}
}
// Parse the response headers.
mimeHeader, err := tp.ReadMIMEHeader()
if err != nil {
return nil, err
}
resp.Header = Header(mimeHeader)
fixPragmaCacheControl(resp.Header)
err = readTransfer(resp, r)
if err != nil {
return nil, err
}
return resp, nil
}
// RFC2616: Should treat
// Pragma: no-cache
// like
// Cache-Control: no-cache
func fixPragmaCacheControl(header Header) {
if hp, ok := header["Pragma"]; ok && len(hp) > 0 && hp[0] == "no-cache" {
if _, presentcc := header["Cache-Control"]; !presentcc {
header["Cache-Control"] = []string{"no-cache"}
}
}
}
// ProtoAtLeast returns whether the HTTP protocol used
// in the response is at least major.minor.
func (r *Response) ProtoAtLeast(major, minor int) bool {
return r.ProtoMajor > major ||
r.ProtoMajor == major && r.ProtoMinor >= minor
}
// Writes the response (header, body and trailer) in wire format. This method
// consults the following fields of the response:
//
// StatusCode
// ProtoMajor
// ProtoMinor
// Request.Method
// TransferEncoding
// Trailer
// Body
// ContentLength
// Header, values for non-canonical keys will have unpredictable behavior
//
func (r *Response) Write(w io.Writer) error {
// Status line
text := r.Status
if text == "" {
var ok bool
text, ok = statusText[r.StatusCode]
if !ok {
text = "status code " + strconv.Itoa(r.StatusCode)
}
}
protoMajor, protoMinor := strconv.Itoa(r.ProtoMajor), strconv.Itoa(r.ProtoMinor)
statusCode := strconv.Itoa(r.StatusCode) + " "
text = strings.TrimPrefix(text, statusCode)
io.WriteString(w, "HTTP/"+protoMajor+"."+protoMinor+" "+statusCode+text+"\r\n")
// Process Body,ContentLength,Close,Trailer
tw, err := newTransferWriter(r)
if err != nil {
return err
}
err = tw.WriteHeader(w)
if err != nil {
return err
}
// Rest of header
err = r.Header.WriteSubset(w, respExcludeHeader)
if err != nil {
return err
}
// End-of-header
io.WriteString(w, "\r\n")
// Write body and trailer
err = tw.WriteBody(w)
if err != nil {
return err
}
// Success
return nil
}
| xiocode/go | src/pkg/net/http/response.go | GO | bsd-3-clause | 6,286 |
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
#define CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "cc/base/cc_export.h"
#include "cc/resources/resource_update_queue.h"
namespace base { class SingleThreadTaskRunner; }
namespace cc {
class ResourceProvider;
class ResourceUpdateControllerClient {
public:
virtual void ReadyToFinalizeTextureUpdates() = 0;
protected:
virtual ~ResourceUpdateControllerClient() {}
};
class CC_EXPORT ResourceUpdateController {
public:
static scoped_ptr<ResourceUpdateController> Create(
ResourceUpdateControllerClient* client,
base::SingleThreadTaskRunner* task_runner,
scoped_ptr<ResourceUpdateQueue> queue,
ResourceProvider* resource_provider) {
return make_scoped_ptr(new ResourceUpdateController(
client, task_runner, queue.Pass(), resource_provider));
}
static size_t MaxPartialTextureUpdates();
virtual ~ResourceUpdateController();
// Discard uploads to textures that were evicted on the impl thread.
void DiscardUploadsToEvictedResources();
void PerformMoreUpdates(base::TimeTicks time_limit);
void Finalize();
// Virtual for testing.
virtual size_t UpdateMoreTexturesSize() const;
virtual base::TimeTicks UpdateMoreTexturesCompletionTime();
protected:
ResourceUpdateController(ResourceUpdateControllerClient* client,
base::SingleThreadTaskRunner* task_runner,
scoped_ptr<ResourceUpdateQueue> queue,
ResourceProvider* resource_provider);
private:
static size_t MaxFullUpdatesPerTick(ResourceProvider* resource_provider);
size_t MaxBlockingUpdates() const;
void UpdateTexture(ResourceUpdate update);
// This returns true when there were textures left to update.
bool UpdateMoreTexturesIfEnoughTimeRemaining();
void UpdateMoreTexturesNow();
void OnTimerFired();
ResourceUpdateControllerClient* client_;
scoped_ptr<ResourceUpdateQueue> queue_;
bool contents_textures_purged_;
ResourceProvider* resource_provider_;
base::TimeTicks time_limit_;
size_t texture_updates_per_tick_;
bool first_update_attempt_;
base::SingleThreadTaskRunner* task_runner_;
bool task_posted_;
base::WeakPtrFactory<ResourceUpdateController> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController);
};
} // namespace cc
#endif // CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_
| mkaluza/external_chromium_org | cc/resources/resource_update_controller.h | C | bsd-3-clause | 2,703 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h"
#include <algorithm>
#include <string>
#include <vector>
#include "ash/launcher/launcher_model.h"
#include "ash/launcher/launcher_model_observer.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/models/menu_model.h"
using extensions::Extension;
using extensions::Manifest;
namespace {
const char* offline_gmail_url = "https://mail.google.com/mail/mu/u";
const char* gmail_url = "https://mail.google.com/mail/u";
}
namespace {
// LauncherModelObserver implementation that tracks what messages are invoked.
class TestLauncherModelObserver : public ash::LauncherModelObserver {
public:
TestLauncherModelObserver()
: added_(0),
removed_(0),
changed_(0) {
}
virtual ~TestLauncherModelObserver() {
}
// LauncherModelObserver
virtual void LauncherItemAdded(int index) OVERRIDE {
++added_;
last_index_ = index;
}
virtual void LauncherItemRemoved(int index, ash::LauncherID id) OVERRIDE {
++removed_;
last_index_ = index;
}
virtual void LauncherItemChanged(int index,
const ash::LauncherItem& old_item) OVERRIDE {
++changed_;
last_index_ = index;
}
virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE {
last_index_ = target_index;
}
virtual void LauncherStatusChanged() OVERRIDE {
}
void clear_counts() {
added_ = 0;
removed_ = 0;
changed_ = 0;
last_index_ = 0;
}
int added() const { return added_; }
int removed() const { return removed_; }
int changed() const { return changed_; }
int last_index() const { return last_index_; }
private:
int added_;
int removed_;
int changed_;
int last_index_;
DISALLOW_COPY_AND_ASSIGN(TestLauncherModelObserver);
};
// Test implementation of AppIconLoader.
class TestAppIconLoaderImpl : public extensions::AppIconLoader {
public:
TestAppIconLoaderImpl() : fetch_count_(0) {
}
virtual ~TestAppIconLoaderImpl() {
}
// AppIconLoader implementation:
virtual void FetchImage(const std::string& id) OVERRIDE {
++fetch_count_;
}
virtual void ClearImage(const std::string& id) OVERRIDE {
}
virtual void UpdateImage(const std::string& id) OVERRIDE {
}
int fetch_count() const { return fetch_count_; }
private:
int fetch_count_;
DISALLOW_COPY_AND_ASSIGN(TestAppIconLoaderImpl);
};
} // namespace
class ChromeLauncherControllerPerAppTest : public BrowserWithTestWindowTest {
protected:
ChromeLauncherControllerPerAppTest()
: extension_service_(NULL) {
SetHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH);
}
virtual ~ChromeLauncherControllerPerAppTest() {
}
virtual void SetUp() OVERRIDE {
BrowserWithTestWindowTest::SetUp();
model_.reset(new ash::LauncherModel);
model_observer_.reset(new TestLauncherModelObserver);
model_->AddObserver(model_observer_.get());
DictionaryValue manifest;
manifest.SetString(extension_manifest_keys::kName,
"launcher controller test extension");
manifest.SetString(extension_manifest_keys::kVersion, "1");
manifest.SetString(extension_manifest_keys::kDescription,
"for testing pinned apps");
extensions::TestExtensionSystem* extension_system(
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(profile())));
extension_service_ = extension_system->CreateExtensionService(
CommandLine::ForCurrentProcess(), base::FilePath(), false);
std::string error;
extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
manifest,
Extension::NO_FLAGS,
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
&error);
extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
manifest,
Extension::NO_FLAGS,
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
&error);
// Fake gmail extension.
DictionaryValue manifest_gmail;
manifest_gmail.SetString(extension_manifest_keys::kName,
"Gmail launcher controller test extension");
manifest_gmail.SetString(extension_manifest_keys::kVersion, "1");
manifest_gmail.SetString(extension_manifest_keys::kDescription,
"for testing pinned Gmail");
manifest_gmail.SetString(extension_manifest_keys::kLaunchWebURL,
"https://mail.google.com/mail/ca");
ListValue* list = new ListValue();
list->Append(Value::CreateStringValue("*://mail.google.com/mail/ca"));
manifest_gmail.Set(extension_manifest_keys::kWebURLs, list);
extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
manifest_gmail,
Extension::NO_FLAGS,
extension_misc::kGmailAppId,
&error);
// Fake search extension.
extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
manifest,
Extension::NO_FLAGS,
extension_misc::kGoogleSearchAppId,
&error);
}
virtual void TearDown() OVERRIDE {
model_->RemoveObserver(model_observer_.get());
model_observer_.reset();
launcher_controller_.reset();
model_.reset();
BrowserWithTestWindowTest::TearDown();
}
void InitLauncherController() {
launcher_controller_.reset(
new ChromeLauncherControllerPerApp(profile(), model_.get()));
launcher_controller_->Init();
}
void InitLauncherControllerWithBrowser() {
chrome::NewTab(browser());
BrowserList::SetLastActive(browser());
InitLauncherController();
}
void SetAppIconLoader(extensions::AppIconLoader* loader) {
launcher_controller_->SetAppIconLoaderForTest(loader);
}
void InsertPrefValue(base::ListValue* pref_value,
int index,
const std::string& extension_id) {
base::DictionaryValue* entry = new DictionaryValue();
entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id);
pref_value->Insert(index, entry);
}
// Gets the currently configured app launchers from the controller.
void GetAppLaunchers(ChromeLauncherControllerPerApp* controller,
std::vector<std::string>* launchers) {
launchers->clear();
for (ash::LauncherItems::const_iterator iter(model_->items().begin());
iter != model_->items().end(); ++iter) {
ChromeLauncherControllerPerApp::IDToItemControllerMap::const_iterator
entry(controller->id_to_item_controller_map_.find(iter->id));
if (iter->type == ash::TYPE_APP_SHORTCUT &&
entry != controller->id_to_item_controller_map_.end()) {
launchers->push_back(entry->second->app_id());
}
}
}
std::string GetPinnedAppStatus() {
std::string result;
for (int i = 0; i < model_->item_count(); i++) {
switch (model_->items()[i].type) {
case ash::TYPE_APP_SHORTCUT: {
const std::string& app =
launcher_controller_->GetAppIDForLauncherID(
model_->items()[i].id);
if (app == extension1_->id()) {
result += "App1, ";
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
} else if (app == extension2_->id()) {
result += "App2, ";
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
} else if (app == extension3_->id()) {
result += "App3, ";
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
} else {
result += "unknown";
}
break;
}
case ash::TYPE_BROWSER_SHORTCUT:
result += "Chrome, ";
break;
case ash::TYPE_APP_LIST:
result += "AppList";
break;
default:
result += "Unknown";
break;
}
}
return result;
}
// Needed for extension service & friends to work.
scoped_refptr<Extension> extension1_;
scoped_refptr<Extension> extension2_;
scoped_refptr<Extension> extension3_;
scoped_refptr<Extension> extension4_;
scoped_ptr<ChromeLauncherControllerPerApp> launcher_controller_;
scoped_ptr<TestLauncherModelObserver> model_observer_;
scoped_ptr<ash::LauncherModel> model_;
ExtensionService* extension_service_;
DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerAppTest);
};
TEST_F(ChromeLauncherControllerPerAppTest, DefaultApps) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
// Installing |extension3_| should add it to the launcher - behind the
// chrome icon.
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ("Chrome, App3, AppList", GetPinnedAppStatus());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
}
// Check that the restauration of launcher items is happening in the same order
// as the user has pinned them (on another system) when they are synced reverse
// order.
TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsReverseOrder) {
InitLauncherController();
base::ListValue policy_value;
InsertPrefValue(&policy_value, 0, extension1_->id());
InsertPrefValue(&policy_value, 1, extension2_->id());
InsertPrefValue(&policy_value, 2, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex));
// Model should only contain the browser shortcut and app list items.
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus());
// Installing |extension3_| should add it to the launcher - behind the
// chrome icon.
ash::LauncherItem item;
extension_service_->AddExtension(extension3_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_EQ("Chrome, App3, AppList", GetPinnedAppStatus());
// Installing |extension2_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension2_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_EQ("Chrome, App2, App3, AppList", GetPinnedAppStatus());
// Installing |extension1_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension1_.get());
EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus());
}
// Check that the restauration of launcher items is happening in the same order
// as the user has pinned them (on another system) when they are synced random
// order.
TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsRandomOrder) {
InitLauncherController();
base::ListValue policy_value;
InsertPrefValue(&policy_value, 0, extension1_->id());
InsertPrefValue(&policy_value, 1, extension2_->id());
InsertPrefValue(&policy_value, 2, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex));
// Model should only contain the browser shortcut and app list items.
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus());
// Installing |extension2_| should add it to the launcher - behind the
// chrome icon.
extension_service_->AddExtension(extension2_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, App2, AppList", GetPinnedAppStatus());
// Installing |extension1_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension1_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, App1, App2, AppList", GetPinnedAppStatus());
// Installing |extension3_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus());
}
// Check that the restauration of launcher items is happening in the same order
// as the user has pinned / moved them (on another system) when they are synced
// random order - including the chrome icon.
TEST_F(ChromeLauncherControllerPerAppTest,
RestoreDefaultAppsRandomOrderChromeMoved) {
InitLauncherController();
base::ListValue policy_value;
InsertPrefValue(&policy_value, 0, extension1_->id());
InsertPrefValue(&policy_value, 1, extension2_->id());
InsertPrefValue(&policy_value, 2, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex,
1);
// Model should only contain the browser shortcut and app list items.
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, AppList", GetPinnedAppStatus());
// Installing |extension2_| should add it to the launcher - behind the
// chrome icon.
ash::LauncherItem item;
extension_service_->AddExtension(extension2_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("Chrome, App2, AppList", GetPinnedAppStatus());
// Installing |extension1_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension1_.get());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_EQ("App1, Chrome, App2, AppList", GetPinnedAppStatus());
// Installing |extension3_| should add it to the launcher - behind the
// chrome icon, but in first location.
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ("App1, Chrome, App2, App3, AppList", GetPinnedAppStatus());
}
// Check that syncing to a different state does the correct thing.
TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsResyncOrder) {
InitLauncherController();
base::ListValue policy_value;
InsertPrefValue(&policy_value, 0, extension1_->id());
InsertPrefValue(&policy_value, 1, extension2_->id());
InsertPrefValue(&policy_value, 2, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex));
extension_service_->AddExtension(extension2_.get());
extension_service_->AddExtension(extension1_.get());
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ("Chrome, App1, App2, App3, AppList", GetPinnedAppStatus());
// Change the order with increasing chrome position and decreasing position.
base::ListValue policy_value1;
InsertPrefValue(&policy_value1, 0, extension3_->id());
InsertPrefValue(&policy_value1, 1, extension1_->id());
InsertPrefValue(&policy_value1, 2, extension2_->id());
profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex,
2);
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value1.DeepCopy());
EXPECT_EQ("App3, App1, Chrome, App2, AppList", GetPinnedAppStatus());
base::ListValue policy_value2;
InsertPrefValue(&policy_value2, 0, extension2_->id());
InsertPrefValue(&policy_value2, 1, extension3_->id());
InsertPrefValue(&policy_value2, 2, extension1_->id());
profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex,
1);
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
policy_value2.DeepCopy());
EXPECT_EQ("App2, Chrome, App3, App1, AppList", GetPinnedAppStatus());
}
// Check that simple locking of an application will 'create' a launcher item.
TEST_F(ChromeLauncherControllerPerAppTest, CheckLockApps) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
}
// Check that multiple locks of an application will be properly handled.
TEST_F(ChromeLauncherControllerPerAppTest, CheckMukltiLockApps) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
for (int i = 0; i < 2; i++) {
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(
extension1_->id()));
}
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
}
// Check that already pinned items are not effected by locks.
TEST_F(ChromeLauncherControllerPerAppTest, CheckAlreadyPinnedLockApps) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnpinAppsWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
}
// Check that already pinned items which get locked stay after unpinning.
TEST_F(ChromeLauncherControllerPerAppTest, CheckPinnedAppsStayAfterUnlock) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnpinAppsWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
}
// Check that lock -> pin -> unlock -> unpin does properly transition.
TEST_F(ChromeLauncherControllerPerAppTest, CheckLockPinUnlockUnpin) {
InitLauncherController();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->LockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->PinAppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnlockV1AppWithID(extension1_->id());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(
launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
launcher_controller_->UnpinAppsWithID(extension1_->id());
EXPECT_EQ(2, model_->item_count());
}
TEST_F(ChromeLauncherControllerPerAppTest, Policy) {
extension_service_->AddExtension(extension1_.get());
extension_service_->AddExtension(extension3_.get());
base::ListValue policy_value;
InsertPrefValue(&policy_value, 0, extension1_->id());
InsertPrefValue(&policy_value, 1, extension2_->id());
profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
// Only |extension1_| should get pinned. |extension2_| is specified but not
// installed, and |extension3_| is part of the default set, but that shouldn't
// take effect when the policy override is in place.
InitLauncherController();
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
// Installing |extension2_| should add it to the launcher.
extension_service_->AddExtension(extension2_.get());
EXPECT_EQ(4, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
// Removing |extension1_| from the policy should be reflected in the launcher.
policy_value.Remove(0, NULL);
profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps,
policy_value.DeepCopy());
EXPECT_EQ(3, model_->item_count());
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
}
TEST_F(ChromeLauncherControllerPerAppTest, UnpinWithUninstall) {
extension_service_->AddExtension(extension3_.get());
extension_service_->AddExtension(extension4_.get());
InitLauncherController();
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
extension_service_->UnloadExtension(extension3_->id(),
extension_misc::UNLOAD_REASON_UNINSTALL);
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
}
TEST_F(ChromeLauncherControllerPerAppTest, PrefUpdates) {
extension_service_->AddExtension(extension2_.get());
extension_service_->AddExtension(extension3_.get());
extension_service_->AddExtension(extension4_.get());
InitLauncherController();
std::vector<std::string> expected_launchers;
std::vector<std::string> actual_launchers;
base::ListValue pref_value;
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
// Unavailable extensions don't create launcher items.
InsertPrefValue(&pref_value, 0, extension1_->id());
InsertPrefValue(&pref_value, 1, extension2_->id());
InsertPrefValue(&pref_value, 2, extension4_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
expected_launchers.push_back(extension2_->id());
expected_launchers.push_back(extension4_->id());
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
// Redundant pref entries show up only once.
InsertPrefValue(&pref_value, 2, extension3_->id());
InsertPrefValue(&pref_value, 2, extension3_->id());
InsertPrefValue(&pref_value, 5, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
expected_launchers.insert(expected_launchers.begin() + 1, extension3_->id());
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
// Order changes are reflected correctly.
pref_value.Clear();
InsertPrefValue(&pref_value, 0, extension4_->id());
InsertPrefValue(&pref_value, 1, extension3_->id());
InsertPrefValue(&pref_value, 2, extension2_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
std::reverse(expected_launchers.begin(), expected_launchers.end());
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
// Clearing works.
pref_value.Clear();
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
expected_launchers.clear();
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
}
TEST_F(ChromeLauncherControllerPerAppTest, PendingInsertionOrder) {
extension_service_->AddExtension(extension1_.get());
extension_service_->AddExtension(extension3_.get());
InitLauncherController();
base::ListValue pref_value;
InsertPrefValue(&pref_value, 0, extension1_->id());
InsertPrefValue(&pref_value, 1, extension2_->id());
InsertPrefValue(&pref_value, 2, extension3_->id());
profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
pref_value.DeepCopy());
std::vector<std::string> expected_launchers;
expected_launchers.push_back(extension1_->id());
expected_launchers.push_back(extension3_->id());
std::vector<std::string> actual_launchers;
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
// Install |extension2| and verify it shows up between the other two.
extension_service_->AddExtension(extension2_.get());
expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id());
GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
EXPECT_EQ(expected_launchers, actual_launchers);
}
// Checks the created menus and menu lists for correctness. It uses the given
// |controller| to create the objects for the given |item| and checks the
// found item count against the |expected_items|. The |title| list contains the
// menu titles in the order of their appearance in the menu (not including the
// application name).
bool CheckMenuCreation(ChromeLauncherControllerPerApp* controller,
const ash::LauncherItem& item,
size_t expected_items,
string16 title[],
bool is_browser) {
ChromeLauncherAppMenuItems items = controller->GetApplicationList(item, 0);
// A new behavior has been added: Only show menus if there is at least one
// item available.
if (expected_items < 1 && is_browser) {
EXPECT_EQ(0u, items.size());
return items.size() == 0;
}
// There should be one item in there: The title.
EXPECT_EQ(expected_items + 1, items.size());
EXPECT_FALSE(items[0]->IsEnabled());
for (size_t i = 0; i < expected_items; i++) {
EXPECT_EQ(title[i], items[1 + i]->title());
// Check that the first real item has a leading separator.
if (i == 1)
EXPECT_TRUE(items[i]->HasLeadingSeparator());
else
EXPECT_FALSE(items[i]->HasLeadingSeparator());
}
scoped_ptr<ash::LauncherMenuModel> menu(
controller->CreateApplicationMenu(item, 0));
// The first element in the menu is a spacing separator. On some systems
// (e.g. Windows) such things do not exist. As such we check the existence
// and adjust dynamically.
int first_item = menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR ? 1 : 0;
int expected_menu_items = first_item +
(expected_items ? (expected_items + 3) : 2);
EXPECT_EQ(expected_menu_items, menu->GetItemCount());
EXPECT_FALSE(menu->IsEnabledAt(first_item));
if (expected_items) {
EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR,
menu->GetTypeAt(first_item + 1));
}
return items.size() == expected_items + 1;
}
// Check that browsers get reflected correctly in the launcher menu.
TEST_F(ChromeLauncherControllerPerAppTest, BrowserMenuGeneration) {
EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
chrome::NewTab(browser());
InitLauncherController();
// Check that the browser list is empty at this time.
ash::LauncherItem item_browser;
item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
item_browser.id =
launcher_controller_->GetLauncherIDForAppID(extension_misc::kChromeAppId);
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_browser, 0, NULL, true));
// Now make the created browser() visible by adding it to the active browser
// list.
BrowserList::SetLastActive(browser());
string16 title1 = ASCIIToUTF16("Test1");
NavigateAndCommitActiveTabWithTitle(browser(), GURL("http://test1"), title1);
string16 one_menu_item[] = {title1};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_browser, 1, one_menu_item, true));
// Create one more browser/window and check that one more was added.
Browser::CreateParams ash_params(profile(), chrome::HOST_DESKTOP_TYPE_ASH);
scoped_ptr<Browser> browser2(
chrome::CreateBrowserWithTestWindowForParams(&ash_params));
chrome::NewTab(browser2.get());
BrowserList::SetLastActive(browser2.get());
string16 title2 = ASCIIToUTF16("Test2");
NavigateAndCommitActiveTabWithTitle(browser2.get(), GURL("http://test2"),
title2);
// Check that the list contains now two entries - make furthermore sure that
// the active item is the first entry.
string16 two_menu_items[] = {title1, title2};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_browser, 2, two_menu_items, true));
// Apparently we have to close all tabs we have.
chrome::CloseTab(browser2.get());
}
// Check that V1 apps are correctly reflected in the launcher menu using the
// refocus logic.
// Note that the extension matching logic is tested by the extension system
// and does not need a separate test here.
TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuGeneration) {
EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
EXPECT_EQ(0, browser()->tab_strip_model()->count());
InitLauncherControllerWithBrowser();
// Model should only contain the browser shortcut and app list items.
EXPECT_EQ(2, model_->item_count());
EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
// Installing |extension3_| adds it to the launcher.
ash::LauncherID gmail_id = model_->next_id();
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ(3, model_->item_count());
int gmail_index = model_->ItemIndexByID(gmail_id);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
// Check the menu content.
ash::LauncherItem item_browser;
item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
item_browser.id =
launcher_controller_->GetLauncherIDForAppID(extension_misc::kChromeAppId);
ash::LauncherItem item_gmail;
item_gmail.type = ash::TYPE_APP_SHORTCUT;
item_gmail.id = gmail_id;
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 0, NULL, false));
// Set the gmail URL to a new tab.
string16 title1 = ASCIIToUTF16("Test1");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
string16 one_menu_item[] = {title1};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 1, one_menu_item, false));
// Create one empty tab.
chrome::NewTab(browser());
string16 title2 = ASCIIToUTF16("Test2");
NavigateAndCommitActiveTabWithTitle(
browser(),
GURL("https://bla"),
title2);
// and another one with another gmail instance.
chrome::NewTab(browser());
string16 title3 = ASCIIToUTF16("Test3");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title3);
string16 two_menu_items[] = {title1, title3};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 2, two_menu_items, false));
// Even though the item is in the V1 app list, it should also be in the
// browser list.
string16 browser_menu_item[] = {title3};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_browser, 1, browser_menu_item, false));
// Test that closing of (all) the item(s) does work (and all menus get
// updated properly).
launcher_controller_->Close(item_gmail.id);
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 0, NULL, false));
string16 browser_menu_item2[] = {title2};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_browser, 1, browser_menu_item2, false));
}
// Checks that the generated menu list properly activates items.
TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuExecution) {
InitLauncherControllerWithBrowser();
// Add |extension3_| to the launcher and add two items.
GURL gmail = GURL("https://mail.google.com/mail/u");
ash::LauncherID gmail_id = model_->next_id();
extension_service_->AddExtension(extension3_.get());
launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
string16 title1 = ASCIIToUTF16("Test1");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
chrome::NewTab(browser());
string16 title2 = ASCIIToUTF16("Test2");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
// Check that the menu is properly set.
ash::LauncherItem item_gmail;
item_gmail.type = ash::TYPE_APP_SHORTCUT;
item_gmail.id = gmail_id;
string16 two_menu_items[] = {title1, title2};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 2, two_menu_items, false));
EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
// Execute the second item in the list (which shouldn't do anything since that
// item is per definition already the active tab).
{
scoped_ptr<ash::LauncherMenuModel> menu(
launcher_controller_->CreateApplicationMenu(item_gmail, 0));
// The first element in the menu is a spacing separator. On some systems
// (e.g. Windows) such things do not exist. As such we check the existence
// and adjust dynamically.
int first_item =
(menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0;
menu->ActivatedAt(first_item + 3);
}
EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
// Execute the first item.
{
scoped_ptr<ash::LauncherMenuModel> menu(
launcher_controller_->CreateApplicationMenu(item_gmail, 0));
int first_item =
(menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0;
menu->ActivatedAt(first_item + 2);
}
// Now the active tab should be the second item.
EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
}
// Checks that the generated menu list properly deletes items.
TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuDeletionExecution) {
InitLauncherControllerWithBrowser();
// Add |extension3_| to the launcher and add two items.
GURL gmail = GURL("https://mail.google.com/mail/u");
ash::LauncherID gmail_id = model_->next_id();
extension_service_->AddExtension(extension3_.get());
launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
string16 title1 = ASCIIToUTF16("Test1");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
chrome::NewTab(browser());
string16 title2 = ASCIIToUTF16("Test2");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title2);
// Check that the menu is properly set.
ash::LauncherItem item_gmail;
item_gmail.type = ash::TYPE_APP_SHORTCUT;
item_gmail.id = gmail_id;
string16 two_menu_items[] = {title1, title2};
EXPECT_TRUE(CheckMenuCreation(
launcher_controller_.get(), item_gmail, 2, two_menu_items, false));
int tabs = browser()->tab_strip_model()->count();
// Activate the proper tab through the menu item.
{
ChromeLauncherAppMenuItems items =
launcher_controller_->GetApplicationList(item_gmail, 0);
items[1]->Execute(0);
EXPECT_EQ(tabs, browser()->tab_strip_model()->count());
}
// Delete one tab through the menu item.
{
ChromeLauncherAppMenuItems items =
launcher_controller_->GetApplicationList(item_gmail, 0);
items[1]->Execute(ui::EF_SHIFT_DOWN);
EXPECT_EQ(--tabs, browser()->tab_strip_model()->count());
}
}
// Tests that panels create launcher items correctly
TEST_F(ChromeLauncherControllerPerAppTest, AppPanels) {
InitLauncherControllerWithBrowser();
EXPECT_EQ(1, model_observer_->added());
TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
SetAppIconLoader(app_icon_loader);
// Test adding an app panel
std::string app_id = extension1_->id();
ShellWindowLauncherItemController app_panel_controller(
LauncherItemController::TYPE_APP_PANEL, "id", app_id,
launcher_controller_.get());
ash::LauncherID launcher_id1 = launcher_controller_->CreateAppLauncherItem(
&app_panel_controller, app_id, ash::STATUS_RUNNING);
int panel_index = model_observer_->last_index();
EXPECT_EQ(2, model_observer_->added());
EXPECT_EQ(0, model_observer_->changed());
EXPECT_EQ(1, app_icon_loader->fetch_count());
model_observer_->clear_counts();
// App panels should have a separate identifier than the app id
EXPECT_EQ(0, launcher_controller_->GetLauncherIDForAppID(app_id));
// Setting the app image image should not change the panel if it set its icon
app_panel_controller.set_image_set_by_controller(true);
gfx::ImageSkia image;
launcher_controller_->SetAppImage(app_id, image);
EXPECT_EQ(0, model_observer_->changed());
model_observer_->clear_counts();
// Add a second app panel and verify that it get the same index as the first
// one had, being added to the left of the existing panel.
ash::LauncherID launcher_id2 = launcher_controller_->CreateAppLauncherItem(
&app_panel_controller, app_id, ash::STATUS_RUNNING);
EXPECT_EQ(panel_index, model_observer_->last_index());
EXPECT_EQ(1, model_observer_->added());
model_observer_->clear_counts();
launcher_controller_->CloseLauncherItem(launcher_id2);
launcher_controller_->CloseLauncherItem(launcher_id1);
EXPECT_EQ(2, model_observer_->removed());
}
// Tests that the Gmail extension matches more then the app itself claims with
// the manifest file.
TEST_F(ChromeLauncherControllerPerAppTest, GmailMatching) {
InitLauncherControllerWithBrowser();
// Create a Gmail browser tab.
chrome::NewTab(browser());
string16 title = ASCIIToUTF16("Test");
NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title);
content::WebContents* content =
browser()->tab_strip_model()->GetActiveWebContents();
// Check that the launcher controller does not recognize the running app.
EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
// Installing |extension3_| adds it to the launcher.
ash::LauncherID gmail_id = model_->next_id();
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ(3, model_->item_count());
int gmail_index = model_->ItemIndexByID(gmail_id);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
// Check that it is now handled.
EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
// Check also that the app has detected that properly.
ash::LauncherItem item_gmail;
item_gmail.type = ash::TYPE_APP_SHORTCUT;
item_gmail.id = gmail_id;
EXPECT_EQ(2U, launcher_controller_->GetApplicationList(item_gmail, 0).size());
}
// Tests that the Gmail extension does not match the offline verison.
TEST_F(ChromeLauncherControllerPerAppTest, GmailOfflineMatching) {
InitLauncherControllerWithBrowser();
// Create a Gmail browser tab.
chrome::NewTab(browser());
string16 title = ASCIIToUTF16("Test");
NavigateAndCommitActiveTabWithTitle(browser(),
GURL(offline_gmail_url),
title);
content::WebContents* content =
browser()->tab_strip_model()->GetActiveWebContents();
// Installing |extension3_| adds it to the launcher.
ash::LauncherID gmail_id = model_->next_id();
extension_service_->AddExtension(extension3_.get());
EXPECT_EQ(3, model_->item_count());
int gmail_index = model_->ItemIndexByID(gmail_id);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type);
EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
// The content should not be able to be handled by the app.
EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
}
| gfreed/android_external_chromium-org | chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc | C++ | bsd-3-clause | 48,320 |
/*!
* # Semantic UI 1.11.1 - Progress Bar
* http://github.com/semantic-org/semantic-ui/
*
*
* Copyright 2014 Contributorss
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
/*******************************
Progress
*******************************/
.ui.progress {
position: relative;
display: block;
max-width: 100%;
border: 1px solid rgba(39, 41, 43, 0.15);
margin: 1em 0em 2.5em;
box-shadow: none;
background: rgba(0, 0, 0, 0.03);
padding: 0.2857em;
border-radius: 0.2857rem;
}
.ui.progress:first-child {
margin: 0em 0em 2.5em;
}
.ui.progress:last-child {
margin: 0em 0em 1.5em;
}
/* Indicating */
.ui.indicating.progress .bar[style*="width: 1"],
.ui.indicating.progress .bar[style*="width: 2"] {
background-color: #d95c5c;
}
.ui.indicating.progress .bar[style*="width: 3"] {
background-color: #d9a65c;
}
.ui.indicating.progress .bar[style*="width: 4"],
.ui.indicating.progress .bar[style*="width: 5"] {
background-color: #e6bb48;
}
.ui.indicating.progress .bar[style*="width: 6"] {
background-color: #ddc928;
}
.ui.indicating.progress .bar[style*="width: 7"],
.ui.indicating.progress .bar[style*="width: 8"] {
background-color: #b4d95c;
}
.ui.indicating.progress .bar[style*="width: 9"],
.ui.indicating.progress .bar[style*="width: 100"] {
background-color: #66da81;
}
/* Indicating Label */
.ui.indicating.progress[data-percent^="1"] .label,
.ui.indicating.progress[data-percent^="2"] .label {
color: #d95c5c;
}
.ui.indicating.progress[data-percent^="3"] .label {
color: #d9a65c;
}
.ui.indicating.progress[data-percent^="4"] .label,
.ui.indicating.progress[data-percent^="5"] .label {
color: #e6bb48;
}
.ui.indicating.progress[data-percent^="6"] .label {
color: #ddc928;
}
.ui.indicating.progress[data-percent^="7"] .label,
.ui.indicating.progress[data-percent^="8"] .label {
color: #b4d95c;
}
.ui.indicating.progress[data-percent^="9"] .label,
.ui.indicating.progress[data-percent^="100"] .label {
color: #66da81;
}
/* Single Digits */
.ui.indicating.progress .bar[style^="width: 1%"],
.ui.indicating.progress .bar[style^="width: 2%"],
.ui.indicating.progress .bar[style^="width: 3%"],
.ui.indicating.progress .bar[style^="width: 4%"],
.ui.indicating.progress .bar[style^="width: 5%"],
.ui.indicating.progress .bar[style^="width: 6%"],
.ui.indicating.progress .bar[style^="width: 7%"],
.ui.indicating.progress .bar[style^="width: 8%"],
.ui.indicating.progress .bar[style^="width: 9%"] {
background-color: #d95c5c;
}
.ui.indicating.progress[data-percent="1"] .label,
.ui.indicating.progress[data-percent="2"] .label,
.ui.indicating.progress[data-percent="3"] .label,
.ui.indicating.progress[data-percent="4"] .label,
.ui.indicating.progress[data-percent="5"] .label,
.ui.indicating.progress[data-percent="6"] .label,
.ui.indicating.progress[data-percent="7"] .label,
.ui.indicating.progress[data-percent="8"] .label,
.ui.indicating.progress[data-percent="9"] .label {
color: #d95c5c;
}
/* Indicating Success */
.ui.indicating.progress.success .label {
color: #356e36;
}
/*******************************
Content
*******************************/
/* Activity Bar */
.ui.progress .bar {
display: block;
line-height: 1;
position: relative;
width: 0%;
min-width: 2em;
background: #888888;
border-radius: 0.2857rem;
-webkit-transition: width 0.3s ease, background-color 0.3s ease;
transition: width 0.3s ease, background-color 0.3s ease;
}
/* Percent Complete */
.ui.progress .bar > .progress {
white-space: nowrap;
position: absolute;
width: auto;
font-size: 0.9em;
top: 50%;
right: 0.5em;
left: auto;
bottom: auto;
color: rgba(255, 255, 255, 0.8);
text-shadow: none;
margin-top: -0.5em;
font-weight: bold;
text-align: left;
}
/* Label */
.ui.progress > .label {
position: absolute;
width: 100%;
font-size: 1em;
top: 100%;
right: auto;
left: 0%;
bottom: auto;
color: rgba(0, 0, 0, 0.8);
font-weight: bold;
text-shadow: none;
margin-top: 0.2em;
text-align: center;
-webkit-transition: color 0.4s ease;
transition: color 0.4s ease;
}
/*******************************
States
*******************************/
/*--------------
Success
---------------*/
.ui.progress.success .bar {
background-color: #5bbd72 !important;
}
.ui.progress.success .bar,
.ui.progress.success .bar::after {
-webkit-animation: none !important;
animation: none !important;
}
.ui.progress.success > .label {
color: #356e36;
}
/*--------------
Warning
---------------*/
.ui.progress.warning .bar {
background-color: #f2c037 !important;
}
.ui.progress.warning .bar,
.ui.progress.warning .bar::after {
-webkit-animation: none !important;
animation: none !important;
}
.ui.progress.warning > .label {
color: #825c01;
}
/*--------------
Error
---------------*/
.ui.progress.error .bar {
background-color: #d95c5c !important;
}
.ui.progress.error .bar,
.ui.progress.error .bar::after {
-webkit-animation: none !important;
animation: none !important;
}
.ui.progress.error > .label {
color: #912d2b;
}
/*--------------
Active
---------------*/
.ui.active.progress .bar {
position: relative;
min-width: 2em;
}
.ui.active.progress .bar::after {
content: '';
opacity: 0;
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
background: #ffffff;
border-radius: 0.2857rem;
-webkit-animation: progress-active 2s ease infinite;
animation: progress-active 2s ease infinite;
}
@-webkit-keyframes progress-active {
0% {
opacity: 0.3;
width: 0;
}
100% {
opacity: 0;
width: 100%;
}
}
@keyframes progress-active {
0% {
opacity: 0.3;
width: 0;
}
100% {
opacity: 0;
width: 100%;
}
}
/*--------------
Disabled
---------------*/
.ui.disabled.progress {
opacity: 0.35;
}
.ui.disabled.progress .bar,
.ui.disabled.progress .bar::after {
-webkit-animation: none !important;
animation: none !important;
}
/*******************************
Variations
*******************************/
/*--------------
Inverted
---------------*/
.ui.inverted.progress {
background: rgba(255, 255, 255, 0.05);
border: none;
}
.ui.inverted.progress .bar {
background: #888888;
}
.ui.inverted.progress .bar > .progress {
color: #fafafa;
}
.ui.inverted.progress > .label {
color: #ffffff;
}
.ui.inverted.progress.success > .label {
color: #5bbd72;
}
.ui.inverted.progress.warning > .label {
color: #f2c037;
}
.ui.inverted.progress.error > .label {
color: #d95c5c;
}
/*--------------
Attached
---------------*/
/* bottom attached */
.ui.progress.attached {
background: transparent;
position: relative;
border: none;
margin: 0em;
}
.ui.progress.attached,
.ui.progress.attached .bar {
display: block;
height: 0.2rem;
padding: 0px;
overflow: hidden;
border-radius: 0em 0em 0.2857rem 0.2857rem;
}
.ui.progress.attached .bar {
border-radius: 0em;
}
/* top attached */
.ui.progress.top.attached,
.ui.progress.top.attached .bar {
top: 0px;
border-radius: 0.2857rem 0.2857rem 0em 0em;
}
.ui.progress.top.attached .bar {
border-radius: 0em;
}
/* Coupling */
.ui.segment > .ui.attached.progress,
.ui.card > .ui.attached.progress {
position: absolute;
top: auto;
left: 0;
bottom: 100%;
width: 100%;
}
.ui.segment > .ui.bottom.attached.progress,
.ui.card > .ui.bottom.attached.progress {
top: 100%;
bottom: auto;
}
/*--------------
Colors
---------------*/
.ui.black.progress .bar {
background-color: #1b1c1d;
}
.ui.blue.progress .bar {
background-color: #3b83c0;
}
.ui.green.progress .bar {
background-color: #5bbd72;
}
.ui.orange.progress .bar {
background-color: #e07b53;
}
.ui.pink.progress .bar {
background-color: #d9499a;
}
.ui.purple.progress .bar {
background-color: #564f8a;
}
.ui.red.progress .bar {
background-color: #d95c5c;
}
.ui.teal.progress .bar {
background-color: #00b5ad;
}
.ui.yellow.progress .bar {
background-color: #f2c61f;
}
.ui.black.inverted.progress .bar {
background-color: #333333;
}
.ui.blue.inverted.progress .bar {
background-color: #54c8ff;
}
.ui.green.inverted.progress .bar {
background-color: #2ecc40;
}
.ui.orange.inverted.progress .bar {
background-color: #ff851b;
}
.ui.pink.inverted.progress .bar {
background-color: #ff8edf;
}
.ui.purple.inverted.progress .bar {
background-color: #cdc6ff;
}
.ui.red.inverted.progress .bar {
background-color: #ff695e;
}
.ui.teal.inverted.progress .bar {
background-color: #6dffff;
}
.ui.yellow.inverted.progress .bar {
background-color: #ffe21f;
}
/*--------------
Sizes
---------------*/
.ui.tiny.progress {
font-size: 0.85714286rem;
}
.ui.tiny.progress .bar {
height: 0.5em;
}
.ui.small.progress {
font-size: 0.92857143rem;
}
.ui.small.progress .bar {
height: 1em;
}
.ui.progress {
font-size: 1rem;
}
.ui.progress .bar {
height: 1.75em;
}
.ui.large.progress {
font-size: 1.14285714rem;
}
.ui.large.progress .bar {
height: 2.5em;
}
.ui.big.progress {
font-size: 1.28571429rem;
}
.ui.big.progress .bar {
height: 3.5em;
}
/*******************************
Progress
*******************************/
/*******************************
Site Overrides
*******************************/
| wackyapples/cdnjs | ajax/libs/semantic-ui/1.11.1/components/progress.css | CSS | mit | 9,351 |
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _CUSTOM_HELPER_H_
#define _CUSTOM_HELPER_H_
#include "common/common.h"
#include "nrf_ble.h"
#include "ble/UUID.h"
#include "ble/GattCharacteristic.h"
#ifdef __cplusplus
extern "C" {
#endif
#define UUID_TABLE_MAX_ENTRIES (4) /* This is the maximum number of 128-bit UUIDs with distinct bases that
* we expect to be in use; increase this limit if needed. */
/**
* Reset the table of 128bits uuids.
* This table is used to keep track of vendors uuids added to the softdevice.
* It is important to reset it before disabling the softdevice otherwise the
* next time the softdevice will be enabled, this table will not be synchronmized
* with the softdevice table.
*/
void custom_reset_128bits_uuid_table();
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base);
error_t custom_decode_uuid(uint8_t const *const p_uuid_base,
ble_uuid_t *p_uuid);
ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid);
error_t custom_add_in_characteristic(uint16_t service_handle,
ble_uuid_t *p_uuid,
uint8_t properties,
SecurityManager::SecurityMode_t requiredSecurity,
uint8_t *p_data,
uint16_t length,
uint16_t max_length,
bool has_variable_len,
const uint8_t *userDescriptionDescriptorValuePtr,
uint16_t userDescriptionDescriptorValueLen,
bool readAuthorization,
bool writeAuthorization,
ble_gatts_char_handles_t *p_char_handle);
error_t custom_add_in_descriptor(uint16_t char_handle,
ble_uuid_t *p_uuid,
uint8_t *p_data,
uint16_t length,
uint16_t max_length,
bool has_variable_len,
uint16_t *p_desc_handle);
#ifdef __cplusplus
}
#endif
#endif // ifndef _CUSTOM_HELPER_H_
| Neuromancer2701/mbedROS2_STF7 | mbed-os/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/custom/custom_helper.h | C | mit | 3,289 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pig.builtin;
import java.io.IOException;
import java.util.Map;
import org.apache.pig.EvalFunc;
import org.apache.pig.PigException;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataType;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.schema.Schema;
/**
* This method should never be used directly, use {@link SIZE}.
*/
public class MapSize extends EvalFunc<Long> {
@SuppressWarnings("unchecked")
@Override
public Long exec(Tuple input) throws IOException {
try {
Map<String, Object> m = (Map<String, Object>)(input.get(0));
return m == null ? null : Long.valueOf(m.keySet().size());
} catch (ExecException exp) {
throw exp;
} catch (Exception e) {
int errCode = 2106;
String msg = "Error while computing size in " + this.getClass().getSimpleName();
throw new ExecException(msg, errCode, PigException.BUG, e);
}
}
@Override
public Schema outputSchema(Schema input) {
return new Schema(new Schema.FieldSchema(null, DataType.LONG));
}
}
| kaituo/sedge | trunk/src/org/apache/pig/builtin/MapSize.java | Java | mit | 1,978 |
/**************************************************************************
*
* Copyright (C) 2006 Steve Karg <skarg@users.sourceforge.net>
*
* 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.
*
*********************************************************************/
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "config.h"
#include "txbuf.h"
#include "bacdef.h"
#include "bacdcode.h"
#include "bactext.h"
#include "ihave.h"
#include "handlers.h"
/** @file h_ihave.c Handles incoming I-Have messages. */
/** Simple Handler for I-Have responses (just validates response).
* @ingroup DMDOB
* @param service_request [in] The received message to be handled.
* @param service_len [in] Length of the service_request message.
* @param src [in] The BACNET_ADDRESS of the message's source.
*/
void handler_i_have(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
BACNET_I_HAVE_DATA data;
(void) service_len;
(void) src;
len = ihave_decode_service_request(service_request, service_len, &data);
if (len != -1) {
#if PRINT_ENABLED
fprintf(stderr, "I-Have: %s %lu from %s %lu!\r\n",
bactext_object_type_name(data.object_id.type),
(unsigned long) data.object_id.instance,
bactext_object_type_name(data.device_id.type),
(unsigned long) data.device_id.instance);
#endif
} else {
#if PRINT_ENABLED
fprintf(stderr, "I-Have: received, but unable to decode!\n");
#endif
}
return;
}
| temcocontrols/T3000_Building_Automation_System | BacNetDllforVc/Handler/h_ihave.c | C | mit | 2,548 |
#include <ctype.h>
#include <assert.h>
#include "bam.h"
#include "khash.h"
#include "ksort.h"
#include "bam_endian.h"
#ifdef _USE_KNETFILE
#include "knetfile.h"
#endif
/*!
@header
Alignment indexing. Before indexing, BAM must be sorted based on the
leftmost coordinate of alignments. In indexing, BAM uses two indices:
a UCSC binning index and a simple linear index. The binning index is
efficient for alignments spanning long distance, while the auxiliary
linear index helps to reduce unnecessary seek calls especially for
short alignments.
The UCSC binning scheme was suggested by Richard Durbin and Lincoln
Stein and is explained by Kent et al. (2002). In this scheme, each bin
represents a contiguous genomic region which can be fully contained in
another bin; each alignment is associated with a bin which represents
the smallest region containing the entire alignment. The binning
scheme is essentially another representation of R-tree. A distinct bin
uniquely corresponds to a distinct internal node in a R-tree. Bin A is
a child of Bin B if region A is contained in B.
In BAM, each bin may span 2^29, 2^26, 2^23, 2^20, 2^17 or 2^14 bp. Bin
0 spans a 512Mbp region, bins 1-8 span 64Mbp, 9-72 8Mbp, 73-584 1Mbp,
585-4680 128Kbp and bins 4681-37449 span 16Kbp regions. If we want to
find the alignments overlapped with a region [rbeg,rend), we need to
calculate the list of bins that may be overlapped the region and test
the alignments in the bins to confirm the overlaps. If the specified
region is short, typically only a few alignments in six bins need to
be retrieved. The overlapping alignments can be quickly fetched.
*/
#define BAM_MIN_CHUNK_GAP 32768
// 1<<14 is the size of minimum bin.
#define BAM_LIDX_SHIFT 14
#define BAM_MAX_BIN 37450 // =(8^6-1)/7+1
typedef struct {
uint64_t u, v;
} pair64_t;
#define pair64_lt(a,b) ((a).u < (b).u)
KSORT_INIT(off, pair64_t, pair64_lt)
typedef struct {
uint32_t m, n;
pair64_t *list;
} bam_binlist_t;
typedef struct {
int32_t n, m;
uint64_t *offset;
} bam_lidx_t;
KHASH_MAP_INIT_INT(i, bam_binlist_t)
struct __bam_index_t {
int32_t n;
uint64_t n_no_coor; // unmapped reads without coordinate
khash_t(i) **index;
bam_lidx_t *index2;
};
// requirement: len <= LEN_MASK
static inline void insert_offset(khash_t(i) *h, int bin, uint64_t beg, uint64_t end)
{
khint_t k;
bam_binlist_t *l;
int ret;
k = kh_put(i, h, bin, &ret);
l = &kh_value(h, k);
if (ret) { // not present
l->m = 1; l->n = 0;
l->list = (pair64_t*)calloc(l->m, 16);
}
if (l->n == l->m) {
l->m <<= 1;
l->list = (pair64_t*)realloc(l->list, l->m * 16);
}
l->list[l->n].u = beg; l->list[l->n++].v = end;
}
static inline void insert_offset2(bam_lidx_t *index2, bam1_t *b, uint64_t offset)
{
int i, beg, end;
beg = b->core.pos >> BAM_LIDX_SHIFT;
end = (bam_calend(&b->core, bam1_cigar(b)) - 1) >> BAM_LIDX_SHIFT;
if (index2->m < end + 1) {
int old_m = index2->m;
index2->m = end + 1;
kroundup32(index2->m);
index2->offset = (uint64_t*)realloc(index2->offset, index2->m * 8);
memset(index2->offset + old_m, 0, 8 * (index2->m - old_m));
}
if (beg == end) {
if (index2->offset[beg] == 0) index2->offset[beg] = offset;
} else {
for (i = beg; i <= end; ++i)
if (index2->offset[i] == 0) index2->offset[i] = offset;
}
index2->n = end + 1;
}
static void merge_chunks(bam_index_t *idx)
{
#if defined(BAM_TRUE_OFFSET) || defined(BAM_VIRTUAL_OFFSET16)
khash_t(i) *index;
int i, l, m;
khint_t k;
for (i = 0; i < idx->n; ++i) {
index = idx->index[i];
for (k = kh_begin(index); k != kh_end(index); ++k) {
bam_binlist_t *p;
if (!kh_exist(index, k) || kh_key(index, k) == BAM_MAX_BIN) continue;
p = &kh_value(index, k);
m = 0;
for (l = 1; l < p->n; ++l) {
#ifdef BAM_TRUE_OFFSET
if (p->list[m].v + BAM_MIN_CHUNK_GAP > p->list[l].u) p->list[m].v = p->list[l].v;
#else
if (p->list[m].v>>16 == p->list[l].u>>16) p->list[m].v = p->list[l].v;
#endif
else p->list[++m] = p->list[l];
} // ~for(l)
p->n = m + 1;
} // ~for(k)
} // ~for(i)
#endif // defined(BAM_TRUE_OFFSET) || defined(BAM_BGZF)
}
static void fill_missing(bam_index_t *idx)
{
int i, j;
for (i = 0; i < idx->n; ++i) {
bam_lidx_t *idx2 = &idx->index2[i];
for (j = 1; j < idx2->n; ++j)
if (idx2->offset[j] == 0)
idx2->offset[j] = idx2->offset[j-1];
}
}
bam_index_t *bam_index_core(bamFile fp)
{
bam1_t *b;
bam_header_t *h;
int i, ret;
bam_index_t *idx;
uint32_t last_bin, save_bin;
int32_t last_coor, last_tid, save_tid;
bam1_core_t *c;
uint64_t save_off, last_off, n_mapped, n_unmapped, off_beg, off_end, n_no_coor;
h = bam_header_read(fp);
if(h == 0) {
fprintf(stderr, "[bam_index_core] Invalid BAM header.");
return NULL;
}
idx = (bam_index_t*)calloc(1, sizeof(bam_index_t));
b = (bam1_t*)calloc(1, sizeof(bam1_t));
c = &b->core;
idx->n = h->n_targets;
bam_header_destroy(h);
idx->index = (khash_t(i)**)calloc(idx->n, sizeof(void*));
for (i = 0; i < idx->n; ++i) idx->index[i] = kh_init(i);
idx->index2 = (bam_lidx_t*)calloc(idx->n, sizeof(bam_lidx_t));
save_bin = save_tid = last_tid = last_bin = 0xffffffffu;
save_off = last_off = bam_tell(fp); last_coor = 0xffffffffu;
n_mapped = n_unmapped = n_no_coor = off_end = 0;
off_beg = off_end = bam_tell(fp);
while ((ret = bam_read1(fp, b)) >= 0) {
if (c->tid < 0) ++n_no_coor;
if (last_tid < c->tid || (last_tid >= 0 && c->tid < 0)) { // change of chromosomes
last_tid = c->tid;
last_bin = 0xffffffffu;
} else if ((uint32_t)last_tid > (uint32_t)c->tid) {
fprintf(stderr, "[bam_index_core] the alignment is not sorted (%s): %d-th chr > %d-th chr\n",
bam1_qname(b), last_tid+1, c->tid+1);
return NULL;
} else if ((int32_t)c->tid >= 0 && last_coor > c->pos) {
fprintf(stderr, "[bam_index_core] the alignment is not sorted (%s): %u > %u in %d-th chr\n",
bam1_qname(b), last_coor, c->pos, c->tid+1);
return NULL;
}
if (c->tid >= 0 && !(c->flag & BAM_FUNMAP)) insert_offset2(&idx->index2[b->core.tid], b, last_off);
if (c->bin != last_bin) { // then possibly write the binning index
if (save_bin != 0xffffffffu) // save_bin==0xffffffffu only happens to the first record
insert_offset(idx->index[save_tid], save_bin, save_off, last_off);
if (last_bin == 0xffffffffu && save_tid != 0xffffffffu) { // write the meta element
off_end = last_off;
insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, off_end);
insert_offset(idx->index[save_tid], BAM_MAX_BIN, n_mapped, n_unmapped);
n_mapped = n_unmapped = 0;
off_beg = off_end;
}
save_off = last_off;
save_bin = last_bin = c->bin;
save_tid = c->tid;
if (save_tid < 0) break;
}
if (bam_tell(fp) <= last_off) {
fprintf(stderr, "[bam_index_core] bug in BGZF/RAZF: %llx < %llx\n",
(unsigned long long)bam_tell(fp), (unsigned long long)last_off);
return NULL;
}
if (c->flag & BAM_FUNMAP) ++n_unmapped;
else ++n_mapped;
last_off = bam_tell(fp);
last_coor = b->core.pos;
}
if (save_tid >= 0) {
insert_offset(idx->index[save_tid], save_bin, save_off, bam_tell(fp));
insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, bam_tell(fp));
insert_offset(idx->index[save_tid], BAM_MAX_BIN, n_mapped, n_unmapped);
}
merge_chunks(idx);
fill_missing(idx);
if (ret >= 0) {
while ((ret = bam_read1(fp, b)) >= 0) {
++n_no_coor;
if (c->tid >= 0 && n_no_coor) {
fprintf(stderr, "[bam_index_core] the alignment is not sorted: reads without coordinates prior to reads with coordinates.\n");
return NULL;
}
}
}
if (ret < -1) fprintf(stderr, "[bam_index_core] truncated file? Continue anyway. (%d)\n", ret);
free(b->data); free(b);
idx->n_no_coor = n_no_coor;
return idx;
}
void bam_index_destroy(bam_index_t *idx)
{
khint_t k;
int i;
if (idx == 0) return;
for (i = 0; i < idx->n; ++i) {
khash_t(i) *index = idx->index[i];
bam_lidx_t *index2 = idx->index2 + i;
for (k = kh_begin(index); k != kh_end(index); ++k) {
if (kh_exist(index, k))
free(kh_value(index, k).list);
}
kh_destroy(i, index);
free(index2->offset);
}
free(idx->index); free(idx->index2);
free(idx);
}
void bam_index_save(const bam_index_t *idx, FILE *fp)
{
int32_t i, size;
khint_t k;
fwrite("BAI\1", 1, 4, fp);
if (bam_is_be) {
uint32_t x = idx->n;
fwrite(bam_swap_endian_4p(&x), 4, 1, fp);
} else fwrite(&idx->n, 4, 1, fp);
for (i = 0; i < idx->n; ++i) {
khash_t(i) *index = idx->index[i];
bam_lidx_t *index2 = idx->index2 + i;
// write binning index
size = kh_size(index);
if (bam_is_be) { // big endian
uint32_t x = size;
fwrite(bam_swap_endian_4p(&x), 4, 1, fp);
} else fwrite(&size, 4, 1, fp);
for (k = kh_begin(index); k != kh_end(index); ++k) {
if (kh_exist(index, k)) {
bam_binlist_t *p = &kh_value(index, k);
if (bam_is_be) { // big endian
uint32_t x;
x = kh_key(index, k); fwrite(bam_swap_endian_4p(&x), 4, 1, fp);
x = p->n; fwrite(bam_swap_endian_4p(&x), 4, 1, fp);
for (x = 0; (int)x < p->n; ++x) {
bam_swap_endian_8p(&p->list[x].u);
bam_swap_endian_8p(&p->list[x].v);
}
fwrite(p->list, 16, p->n, fp);
for (x = 0; (int)x < p->n; ++x) {
bam_swap_endian_8p(&p->list[x].u);
bam_swap_endian_8p(&p->list[x].v);
}
} else {
fwrite(&kh_key(index, k), 4, 1, fp);
fwrite(&p->n, 4, 1, fp);
fwrite(p->list, 16, p->n, fp);
}
}
}
// write linear index (index2)
if (bam_is_be) {
int x = index2->n;
fwrite(bam_swap_endian_4p(&x), 4, 1, fp);
} else fwrite(&index2->n, 4, 1, fp);
if (bam_is_be) { // big endian
int x;
for (x = 0; (int)x < index2->n; ++x)
bam_swap_endian_8p(&index2->offset[x]);
fwrite(index2->offset, 8, index2->n, fp);
for (x = 0; (int)x < index2->n; ++x)
bam_swap_endian_8p(&index2->offset[x]);
} else fwrite(index2->offset, 8, index2->n, fp);
}
{ // write the number of reads coor-less records.
uint64_t x = idx->n_no_coor;
if (bam_is_be) bam_swap_endian_8p(&x);
fwrite(&x, 8, 1, fp);
}
fflush(fp);
}
static bam_index_t *bam_index_load_core(FILE *fp)
{
int i;
char magic[4];
bam_index_t *idx;
if (fp == 0) {
fprintf(stderr, "[bam_index_load_core] fail to load index.\n");
return 0;
}
fread(magic, 1, 4, fp);
if (strncmp(magic, "BAI\1", 4)) {
fprintf(stderr, "[bam_index_load] wrong magic number.\n");
fclose(fp);
return 0;
}
idx = (bam_index_t*)calloc(1, sizeof(bam_index_t));
fread(&idx->n, 4, 1, fp);
if (bam_is_be) bam_swap_endian_4p(&idx->n);
idx->index = (khash_t(i)**)calloc(idx->n, sizeof(void*));
idx->index2 = (bam_lidx_t*)calloc(idx->n, sizeof(bam_lidx_t));
for (i = 0; i < idx->n; ++i) {
khash_t(i) *index;
bam_lidx_t *index2 = idx->index2 + i;
uint32_t key, size;
khint_t k;
int j, ret;
bam_binlist_t *p;
index = idx->index[i] = kh_init(i);
// load binning index
fread(&size, 4, 1, fp);
if (bam_is_be) bam_swap_endian_4p(&size);
for (j = 0; j < (int)size; ++j) {
fread(&key, 4, 1, fp);
if (bam_is_be) bam_swap_endian_4p(&key);
k = kh_put(i, index, key, &ret);
p = &kh_value(index, k);
fread(&p->n, 4, 1, fp);
if (bam_is_be) bam_swap_endian_4p(&p->n);
p->m = p->n;
p->list = (pair64_t*)malloc(p->m * 16);
fread(p->list, 16, p->n, fp);
if (bam_is_be) {
int x;
for (x = 0; x < p->n; ++x) {
bam_swap_endian_8p(&p->list[x].u);
bam_swap_endian_8p(&p->list[x].v);
}
}
}
// load linear index
fread(&index2->n, 4, 1, fp);
if (bam_is_be) bam_swap_endian_4p(&index2->n);
index2->m = index2->n;
index2->offset = (uint64_t*)calloc(index2->m, 8);
fread(index2->offset, index2->n, 8, fp);
if (bam_is_be)
for (j = 0; j < index2->n; ++j) bam_swap_endian_8p(&index2->offset[j]);
}
if (fread(&idx->n_no_coor, 8, 1, fp) == 0) idx->n_no_coor = 0;
if (bam_is_be) bam_swap_endian_8p(&idx->n_no_coor);
return idx;
}
bam_index_t *bam_index_load_local(const char *_fn)
{
FILE *fp;
char *fnidx, *fn;
if (strstr(_fn, "ftp://") == _fn || strstr(_fn, "http://") == _fn) {
const char *p;
int l = strlen(_fn);
for (p = _fn + l - 1; p >= _fn; --p)
if (*p == '/') break;
fn = strdup(p + 1);
} else fn = strdup(_fn);
fnidx = (char*)calloc(strlen(fn) + 5, 1);
strcpy(fnidx, fn); strcat(fnidx, ".bai");
fp = fopen(fnidx, "rb");
if (fp == 0) { // try "{base}.bai"
char *s = strstr(fn, "bam");
if (s == fn + strlen(fn) - 3) {
strcpy(fnidx, fn);
fnidx[strlen(fn)-1] = 'i';
fp = fopen(fnidx, "rb");
}
}
free(fnidx); free(fn);
if (fp) {
bam_index_t *idx = bam_index_load_core(fp);
fclose(fp);
return idx;
} else return 0;
}
#ifdef _USE_KNETFILE
static void download_from_remote(const char *url)
{
const int buf_size = 1 * 1024 * 1024;
char *fn;
FILE *fp;
uint8_t *buf;
knetFile *fp_remote;
int l;
if (strstr(url, "ftp://") != url && strstr(url, "http://") != url) return;
l = strlen(url);
for (fn = (char*)url + l - 1; fn >= url; --fn)
if (*fn == '/') break;
++fn; // fn now points to the file name
fp_remote = knet_open(url, "r");
if (fp_remote == 0) {
fprintf(stderr, "[download_from_remote] fail to open remote file.\n");
return;
}
if ((fp = fopen(fn, "wb")) == 0) {
fprintf(stderr, "[download_from_remote] fail to create file in the working directory.\n");
knet_close(fp_remote);
return;
}
buf = (uint8_t*)calloc(buf_size, 1);
while ((l = knet_read(fp_remote, buf, buf_size)) != 0)
fwrite(buf, 1, l, fp);
free(buf);
fclose(fp);
knet_close(fp_remote);
}
#else
static void download_from_remote(const char *url)
{
return;
}
#endif
bam_index_t *bam_index_load(const char *fn)
{
bam_index_t *idx;
idx = bam_index_load_local(fn);
if (idx == 0 && (strstr(fn, "ftp://") == fn || strstr(fn, "http://") == fn)) {
char *fnidx = calloc(strlen(fn) + 5, 1);
strcat(strcpy(fnidx, fn), ".bai");
fprintf(stderr, "[bam_index_load] attempting to download the remote index file.\n");
download_from_remote(fnidx);
free(fnidx);
idx = bam_index_load_local(fn);
}
if (idx == 0) fprintf(stderr, "[bam_index_load] fail to load BAM index.\n");
return idx;
}
int bam_index_build2(const char *fn, const char *_fnidx)
{
char *fnidx;
FILE *fpidx;
bamFile fp;
bam_index_t *idx;
if ((fp = bam_open(fn, "r")) == 0) {
fprintf(stderr, "[bam_index_build2] fail to open the BAM file.\n");
return -1;
}
idx = bam_index_core(fp);
bam_close(fp);
if(idx == 0) {
fprintf(stderr, "[bam_index_build2] fail to index the BAM file.\n");
return -1;
}
if (_fnidx == 0) {
fnidx = (char*)calloc(strlen(fn) + 5, 1);
strcpy(fnidx, fn); strcat(fnidx, ".bai");
} else fnidx = strdup(_fnidx);
fpidx = fopen(fnidx, "wb");
if (fpidx == 0) {
fprintf(stderr, "[bam_index_build2] fail to create the index file.\n");
free(fnidx);
bam_index_destroy(idx);
return -1;
}
bam_index_save(idx, fpidx);
bam_index_destroy(idx);
fclose(fpidx);
free(fnidx);
return 0;
}
int bam_index_build(const char *fn)
{
return bam_index_build2(fn, 0);
}
int bam_index(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage: samtools index <in.bam> [out.index]\n");
return 1;
}
if (argc >= 3) bam_index_build2(argv[1], argv[2]);
else bam_index_build(argv[1]);
return 0;
}
int bam_idxstats(int argc, char *argv[])
{
bam_index_t *idx;
bam_header_t *header;
bamFile fp;
int i;
if (argc < 2) {
fprintf(stderr, "Usage: samtools idxstats <in.bam>\n");
return 1;
}
fp = bam_open(argv[1], "r");
if (fp == 0) { fprintf(stderr, "[%s] fail to open BAM.\n", __func__); return 1; }
header = bam_header_read(fp);
bam_close(fp);
idx = bam_index_load(argv[1]);
if (idx == 0) { fprintf(stderr, "[%s] fail to load the index.\n", __func__); return 1; }
for (i = 0; i < idx->n; ++i) {
khint_t k;
khash_t(i) *h = idx->index[i];
printf("%s\t%d", header->target_name[i], header->target_len[i]);
k = kh_get(i, h, BAM_MAX_BIN);
if (k != kh_end(h))
printf("\t%llu\t%llu", (long long)kh_val(h, k).list[1].u, (long long)kh_val(h, k).list[1].v);
else printf("\t0\t0");
putchar('\n');
}
printf("*\t0\t0\t%llu\n", (long long)idx->n_no_coor);
bam_header_destroy(header);
bam_index_destroy(idx);
return 0;
}
static inline int reg2bins(uint32_t beg, uint32_t end, uint16_t list[BAM_MAX_BIN])
{
int i = 0, k;
if (beg >= end) return 0;
if (end >= 1u<<29) end = 1u<<29;
--end;
list[i++] = 0;
for (k = 1 + (beg>>26); k <= 1 + (end>>26); ++k) list[i++] = k;
for (k = 9 + (beg>>23); k <= 9 + (end>>23); ++k) list[i++] = k;
for (k = 73 + (beg>>20); k <= 73 + (end>>20); ++k) list[i++] = k;
for (k = 585 + (beg>>17); k <= 585 + (end>>17); ++k) list[i++] = k;
for (k = 4681 + (beg>>14); k <= 4681 + (end>>14); ++k) list[i++] = k;
return i;
}
static inline int is_overlap(uint32_t beg, uint32_t end, const bam1_t *b)
{
uint32_t rbeg = b->core.pos;
uint32_t rend = b->core.n_cigar? bam_calend(&b->core, bam1_cigar(b)) : b->core.pos + 1;
return (rend > beg && rbeg < end);
}
struct __bam_iter_t {
int from_first; // read from the first record; no random access
int tid, beg, end, n_off, i, finished;
uint64_t curr_off;
pair64_t *off;
};
// bam_fetch helper function retrieves
bam_iter_t bam_iter_query(const bam_index_t *idx, int tid, int beg, int end)
{
uint16_t *bins;
int i, n_bins, n_off;
pair64_t *off;
khint_t k;
khash_t(i) *index;
uint64_t min_off;
bam_iter_t iter = 0;
if (beg < 0) beg = 0;
if (end < beg) return 0;
// initialize iter
iter = calloc(1, sizeof(struct __bam_iter_t));
iter->tid = tid, iter->beg = beg, iter->end = end; iter->i = -1;
//
bins = (uint16_t*)calloc(BAM_MAX_BIN, 2);
n_bins = reg2bins(beg, end, bins);
index = idx->index[tid];
if (idx->index2[tid].n > 0) {
min_off = (beg>>BAM_LIDX_SHIFT >= idx->index2[tid].n)? idx->index2[tid].offset[idx->index2[tid].n-1]
: idx->index2[tid].offset[beg>>BAM_LIDX_SHIFT];
if (min_off == 0) { // improvement for index files built by tabix prior to 0.1.4
int n = beg>>BAM_LIDX_SHIFT;
if (n > idx->index2[tid].n) n = idx->index2[tid].n;
for (i = n - 1; i >= 0; --i)
if (idx->index2[tid].offset[i] != 0) break;
if (i >= 0) min_off = idx->index2[tid].offset[i];
}
} else min_off = 0; // tabix 0.1.2 may produce such index files
for (i = n_off = 0; i < n_bins; ++i) {
if ((k = kh_get(i, index, bins[i])) != kh_end(index))
n_off += kh_value(index, k).n;
}
if (n_off == 0) {
free(bins); return iter;
}
off = (pair64_t*)calloc(n_off, 16);
for (i = n_off = 0; i < n_bins; ++i) {
if ((k = kh_get(i, index, bins[i])) != kh_end(index)) {
int j;
bam_binlist_t *p = &kh_value(index, k);
for (j = 0; j < p->n; ++j)
if (p->list[j].v > min_off) off[n_off++] = p->list[j];
}
}
free(bins);
if (n_off == 0) {
free(off); return iter;
}
{
bam1_t *b = (bam1_t*)calloc(1, sizeof(bam1_t));
int l;
ks_introsort(off, n_off, off);
// resolve completely contained adjacent blocks
for (i = 1, l = 0; i < n_off; ++i)
if (off[l].v < off[i].v)
off[++l] = off[i];
n_off = l + 1;
// resolve overlaps between adjacent blocks; this may happen due to the merge in indexing
for (i = 1; i < n_off; ++i)
if (off[i-1].v >= off[i].u) off[i-1].v = off[i].u;
{ // merge adjacent blocks
#if defined(BAM_TRUE_OFFSET) || defined(BAM_VIRTUAL_OFFSET16)
for (i = 1, l = 0; i < n_off; ++i) {
#ifdef BAM_TRUE_OFFSET
if (off[l].v + BAM_MIN_CHUNK_GAP > off[i].u) off[l].v = off[i].v;
#else
if (off[l].v>>16 == off[i].u>>16) off[l].v = off[i].v;
#endif
else off[++l] = off[i];
}
n_off = l + 1;
#endif
}
bam_destroy1(b);
}
iter->n_off = n_off; iter->off = off;
return iter;
}
pair64_t *get_chunk_coordinates(const bam_index_t *idx, int tid, int beg, int end, int *cnt_off)
{ // for pysam compatibility
bam_iter_t iter;
pair64_t *off;
iter = bam_iter_query(idx, tid, beg, end);
off = iter->off; *cnt_off = iter->n_off;
free(iter);
return off;
}
void bam_iter_destroy(bam_iter_t iter)
{
if (iter) { free(iter->off); free(iter); }
}
int bam_iter_read(bamFile fp, bam_iter_t iter, bam1_t *b)
{
int ret;
if (iter && iter->finished) return -1;
if (iter == 0 || iter->from_first) {
ret = bam_read1(fp, b);
if (ret < 0 && iter) iter->finished = 1;
return ret;
}
if (iter->off == 0) return -1;
for (;;) {
if (iter->curr_off == 0 || iter->curr_off >= iter->off[iter->i].v) { // then jump to the next chunk
if (iter->i == iter->n_off - 1) { ret = -1; break; } // no more chunks
if (iter->i >= 0) assert(iter->curr_off == iter->off[iter->i].v); // otherwise bug
if (iter->i < 0 || iter->off[iter->i].v != iter->off[iter->i+1].u) { // not adjacent chunks; then seek
bam_seek(fp, iter->off[iter->i+1].u, SEEK_SET);
iter->curr_off = bam_tell(fp);
}
++iter->i;
}
if ((ret = bam_read1(fp, b)) >= 0) {
iter->curr_off = bam_tell(fp);
if (b->core.tid != iter->tid || b->core.pos >= iter->end) { // no need to proceed
ret = bam_validate1(NULL, b)? -1 : -5; // determine whether end of region or error
break;
}
else if (is_overlap(iter->beg, iter->end, b)) return ret;
} else break; // end of file or error
}
iter->finished = 1;
return ret;
}
int bam_fetch(bamFile fp, const bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func)
{
int ret;
bam_iter_t iter;
bam1_t *b;
b = bam_init1();
iter = bam_iter_query(idx, tid, beg, end);
while ((ret = bam_iter_read(fp, iter, b)) >= 0) func(b, data);
bam_iter_destroy(iter);
bam_destroy1(b);
return (ret == -1)? 0 : ret;
}
| ding-lab/msisensor | vendor/samtools-0.1.19/bam_index.c | C | mit | 21,491 |
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2008-2011, International Business Machines
* Corporation, Google and others. All Rights Reserved.
*
*******************************************************************************
*/
/*
* Author : eldawy@google.com (Mohamed Eldawy)
* ucnvsel.h
*
* Purpose: To generate a list of encodings capable of handling
* a given Unicode text
*
* Started 09-April-2008
*/
#ifndef __ICU_UCNV_SEL_H__
#define __ICU_UCNV_SEL_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_CONVERSION
#include "unicode/uset.h"
#include "unicode/utf16.h"
#include "unicode/uenum.h"
#include "unicode/ucnv.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
/**
* \file
*
* A converter selector is built with a set of encoding/charset names
* and given an input string returns the set of names of the
* corresponding converters which can convert the string.
*
* A converter selector can be serialized into a buffer and reopened
* from the serialized form.
*/
struct UConverterSelector;
/**
* @{
* Typedef for selector data structure.
*/
typedef struct UConverterSelector UConverterSelector;
/** @} */
/**
* Open a selector.
* If converterListSize is 0, build for all available converters.
* If excludedCodePoints is NULL, don't exclude any code points.
*
* @param converterList a pointer to encoding names needed to be involved.
* Can be NULL if converterListSize==0.
* The list and the names will be cloned, and the caller
* retains ownership of the original.
* @param converterListSize number of encodings in above list.
* If 0, builds a selector for all available converters.
* @param excludedCodePoints a set of code points to be excluded from consideration.
* That is, excluded code points in a string do not change
* the selection result. (They might be handled by a callback.)
* Use NULL to exclude nothing.
* @param whichSet what converter set to use? Use this to determine whether
* to consider only roundtrip mappings or also fallbacks.
* @param status an in/out ICU UErrorCode
* @return the new selector
*
* @stable ICU 4.2
*/
U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_open(const char* const* converterList, int32_t converterListSize,
const USet* excludedCodePoints,
const UConverterUnicodeSet whichSet, UErrorCode* status);
/**
* Closes a selector.
* If any Enumerations were returned by ucnv_select*, they become invalid.
* They can be closed before or after calling ucnv_closeSelector,
* but should never be used after the selector is closed.
*
* @see ucnv_selectForString
* @see ucnv_selectForUTF8
*
* @param sel selector to close
*
* @stable ICU 4.2
*/
U_CAPI void U_EXPORT2
ucnvsel_close(UConverterSelector *sel);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* \class LocalUConverterSelectorPointer
* "Smart pointer" class, closes a UConverterSelector via ucnvsel_close().
* For most methods see the LocalPointerBase base class.
*
* @see LocalPointerBase
* @see LocalPointer
* @stable ICU 4.4
*/
U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterSelectorPointer, UConverterSelector, ucnvsel_close);
U_NAMESPACE_END
#endif
/**
* Open a selector from its serialized form.
* The buffer must remain valid and unchanged for the lifetime of the selector.
* This is much faster than creating a selector from scratch.
* Using a serialized form from a different machine (endianness/charset) is supported.
*
* @param buffer pointer to the serialized form of a converter selector;
* must be 32-bit-aligned
* @param length the capacity of this buffer (can be equal to or larger than
* the actual data length)
* @param status an in/out ICU UErrorCode
* @return the new selector
*
* @stable ICU 4.2
*/
U_CAPI UConverterSelector* U_EXPORT2
ucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status);
/**
* Serialize a selector into a linear buffer.
* The serialized form is portable to different machines.
*
* @param sel selector to consider
* @param buffer pointer to 32-bit-aligned memory to be filled with the
* serialized form of this converter selector
* @param bufferCapacity the capacity of this buffer
* @param status an in/out ICU UErrorCode
* @return the required buffer capacity to hold serialize data (even if the call fails
* with a U_BUFFER_OVERFLOW_ERROR, it will return the required capacity)
*
* @stable ICU 4.2
*/
U_CAPI int32_t U_EXPORT2
ucnvsel_serialize(const UConverterSelector* sel,
void* buffer, int32_t bufferCapacity, UErrorCode* status);
/**
* Select converters that can map all characters in a UTF-16 string,
* ignoring the excluded code points.
*
* @param sel a selector
* @param s UTF-16 string
* @param length length of the string, or -1 if NUL-terminated
* @param status an in/out ICU UErrorCode
* @return an enumeration containing encoding names.
* The returned encoding names and their order will be the same as
* supplied when building the selector.
*
* @stable ICU 4.2
*/
U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForString(const UConverterSelector* sel,
const UChar *s, int32_t length, UErrorCode *status);
/**
* Select converters that can map all characters in a UTF-8 string,
* ignoring the excluded code points.
*
* @param sel a selector
* @param s UTF-8 string
* @param length length of the string, or -1 if NUL-terminated
* @param status an in/out ICU UErrorCode
* @return an enumeration containing encoding names.
* The returned encoding names and their order will be the same as
* supplied when building the selector.
*
* @stable ICU 4.2
*/
U_CAPI UEnumeration * U_EXPORT2
ucnvsel_selectForUTF8(const UConverterSelector* sel,
const char *s, int32_t length, UErrorCode *status);
#endif /* !UCONFIG_NO_CONVERSION */
#endif /* __ICU_UCNV_SEL_H__ */
| honix/godot | thirdparty/icu4c/common/unicode/ucnvsel.h | C | mit | 6,339 |
var test = require('tape');
var watchify = require('../');
var browserify = require('browserify');
var vm = require('vm');
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var os = require('os');
var tmpdir = path.join((os.tmpdir || os.tmpDir)(), 'watchify-' + Math.random());
var files = {
main: path.join(tmpdir, 'main.js'),
beep: path.join(tmpdir, 'beep.js'),
boop: path.join(tmpdir, 'boop.js'),
abc: path.join(tmpdir, 'lib', 'abc.js'),
xyz: path.join(tmpdir, 'lib', 'xyz.js')
};
mkdirp.sync(tmpdir);
mkdirp.sync(path.join(tmpdir, 'lib'));
fs.writeFileSync(files.main, [
'var abc = require("abc");',
'var xyz = require("xyz");',
'var beep = require("./beep");',
'console.log(abc + " " + xyz + " " + beep);'
].join('\n'));
fs.writeFileSync(files.beep, 'module.exports = require("./boop");');
fs.writeFileSync(files.boop, 'module.exports = require("xyz");');
fs.writeFileSync(files.abc, 'module.exports = "abc";');
fs.writeFileSync(files.xyz, 'module.exports = "xyz";');
test('properly caches exposed files', function (t) {
t.plan(4);
var cache = {};
var w = watchify(browserify({
entries: [files.main],
basedir: tmpdir,
cache: cache,
packageCache: {}
}));
w.require('./lib/abc', {expose: 'abc'});
w.require('./lib/xyz', {expose: 'xyz'});
w.on('update', function () {
w.bundle(function (err, src) {
t.ifError(err);
t.equal(run(src), 'ABC XYZ XYZ\n');
w.close();
});
});
w.bundle(function (err, src) {
t.ifError(err);
t.equal(run(src), 'abc xyz xyz\n');
setTimeout(function () {
// If we're incorrectly caching exposed files,
// then "files.abc" would be re-read from disk.
cache[files.abc].source = 'module.exports = "ABC";';
fs.writeFileSync(files.xyz, 'module.exports = "XYZ";');
}, 1000);
});
});
function run (src) {
var output = '';
function log (msg) { output += msg + '\n' }
vm.runInNewContext(src, { console: { log: log } });
return output;
}
| sagiavinash/onlineImageEditor | tasks/node_modules/grunt-browserify/node_modules/watchify/test/expose.js | JavaScript | mit | 2,151 |
package cucumber.runtime.java.spring.commonglue;
import org.springframework.beans.factory.annotation.Autowired;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
public class OneStepDef {
int cucumbers;
@Autowired
private ThirdStepDef thirdStepDef;
public ThirdStepDef getThirdStepDef() {
return thirdStepDef;
}
@Given("^the StepDef injection works$")
public void the_StepDef_injection_works() throws Throwable {
// blank
}
@When("^I assign the \"cucumbers\" attribute to (\\d+) in one step def class$")
public void i_assign_the_cucumbers_attribute_to_in_one_step_def_class(int arg1) throws Throwable {
cucumbers = arg1;
thirdStepDef.cucumbers = arg1;
}
}
| paoloambrosio/cucumber-jvm | spring/src/test/java/cucumber/runtime/java/spring/commonglue/OneStepDef.java | Java | mit | 759 |
<?php
namespace Illuminate\Pagination;
use Closure;
use ArrayIterator;
use Illuminate\Support\Str;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Support\Htmlable;
/**
* @mixin \Illuminate\Support\Collection
*/
abstract class AbstractPaginator implements Htmlable
{
/**
* All of the items being paginated.
*
* @var \Illuminate\Support\Collection
*/
protected $items;
/**
* The number of items to be shown per page.
*
* @var int
*/
protected $perPage;
/**
* The current page being "viewed".
*
* @var int
*/
protected $currentPage;
/**
* The base path to assign to all URLs.
*
* @var string
*/
protected $path = '/';
/**
* The query parameters to add to all URLs.
*
* @var array
*/
protected $query = [];
/**
* The URL fragment to add to all URLs.
*
* @var string|null
*/
protected $fragment;
/**
* The query string variable used to store the page.
*
* @var string
*/
protected $pageName = 'page';
/**
* The current path resolver callback.
*
* @var \Closure
*/
protected static $currentPathResolver;
/**
* The current page resolver callback.
*
* @var \Closure
*/
protected static $currentPageResolver;
/**
* The view factory resolver callback.
*
* @var \Closure
*/
protected static $viewFactoryResolver;
/**
* The default pagination view.
*
* @var string
*/
public static $defaultView = 'pagination::default';
/**
* The default "simple" pagination view.
*
* @var string
*/
public static $defaultSimpleView = 'pagination::simple-default';
/**
* Determine if the given value is a valid page number.
*
* @param int $page
* @return bool
*/
protected function isValidPageNumber($page)
{
return $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false;
}
/**
* Get the URL for the previous page.
*
* @return string|null
*/
public function previousPageUrl()
{
if ($this->currentPage() > 1) {
return $this->url($this->currentPage() - 1);
}
}
/**
* Create a range of pagination URLs.
*
* @param int $start
* @param int $end
* @return array
*/
public function getUrlRange($start, $end)
{
return collect(range($start, $end))->mapWithKeys(function ($page) {
return [$page => $this->url($page)];
})->all();
}
/**
* Get the URL for a given page number.
*
* @param int $page
* @return string
*/
public function url($page)
{
if ($page <= 0) {
$page = 1;
}
// If we have any extra query string key / value pairs that need to be added
// onto the URL, we will put them in query string form and then attach it
// to the URL. This allows for extra information like sortings storage.
$parameters = [$this->pageName => $page];
if (count($this->query) > 0) {
$parameters = array_merge($this->query, $parameters);
}
return $this->path
.(Str::contains($this->path, '?') ? '&' : '?')
.http_build_query($parameters, '', '&')
.$this->buildFragment();
}
/**
* Get / set the URL fragment to be appended to URLs.
*
* @param string|null $fragment
* @return $this|string|null
*/
public function fragment($fragment = null)
{
if (is_null($fragment)) {
return $this->fragment;
}
$this->fragment = $fragment;
return $this;
}
/**
* Add a set of query string values to the paginator.
*
* @param array|string $key
* @param string|null $value
* @return $this
*/
public function appends($key, $value = null)
{
if (is_array($key)) {
return $this->appendArray($key);
}
return $this->addQuery($key, $value);
}
/**
* Add an array of query string values.
*
* @param array $keys
* @return $this
*/
protected function appendArray(array $keys)
{
foreach ($keys as $key => $value) {
$this->addQuery($key, $value);
}
return $this;
}
/**
* Add a query string value to the paginator.
*
* @param string $key
* @param string $value
* @return $this
*/
protected function addQuery($key, $value)
{
if ($key !== $this->pageName) {
$this->query[$key] = $value;
}
return $this;
}
/**
* Build the full fragment portion of a URL.
*
* @return string
*/
protected function buildFragment()
{
return $this->fragment ? '#'.$this->fragment : '';
}
/**
* Get the slice of items being paginated.
*
* @return array
*/
public function items()
{
return $this->items->all();
}
/**
* Get the number of the first item in the slice.
*
* @return int
*/
public function firstItem()
{
return count($this->items) > 0 ? ($this->currentPage - 1) * $this->perPage + 1 : null;
}
/**
* Get the number of the last item in the slice.
*
* @return int
*/
public function lastItem()
{
return count($this->items) > 0 ? $this->firstItem() + $this->count() - 1 : null;
}
/**
* Get the number of items shown per page.
*
* @return int
*/
public function perPage()
{
return $this->perPage;
}
/**
* Determine if there are enough items to split into multiple pages.
*
* @return bool
*/
public function hasPages()
{
return $this->currentPage() != 1 || $this->hasMorePages();
}
/**
* Determine if the paginator is on the first page.
*
* @return bool
*/
public function onFirstPage()
{
return $this->currentPage() <= 1;
}
/**
* Get the current page.
*
* @return int
*/
public function currentPage()
{
return $this->currentPage;
}
/**
* Get the query string variable used to store the page.
*
* @return string
*/
public function getPageName()
{
return $this->pageName;
}
/**
* Set the query string variable used to store the page.
*
* @param string $name
* @return $this
*/
public function setPageName($name)
{
$this->pageName = $name;
return $this;
}
/**
* Set the base path to assign to all URLs.
*
* @param string $path
* @return $this
*/
public function withPath($path)
{
return $this->setPath($path);
}
/**
* Set the base path to assign to all URLs.
*
* @param string $path
* @return $this
*/
public function setPath($path)
{
$this->path = $path;
return $this;
}
/**
* Resolve the current request path or return the default value.
*
* @param string $default
* @return string
*/
public static function resolveCurrentPath($default = '/')
{
if (isset(static::$currentPathResolver)) {
return call_user_func(static::$currentPathResolver);
}
return $default;
}
/**
* Set the current request path resolver callback.
*
* @param \Closure $resolver
* @return void
*/
public static function currentPathResolver(Closure $resolver)
{
static::$currentPathResolver = $resolver;
}
/**
* Resolve the current page or return the default value.
*
* @param string $pageName
* @param int $default
* @return int
*/
public static function resolveCurrentPage($pageName = 'page', $default = 1)
{
if (isset(static::$currentPageResolver)) {
return call_user_func(static::$currentPageResolver, $pageName);
}
return $default;
}
/**
* Set the current page resolver callback.
*
* @param \Closure $resolver
* @return void
*/
public static function currentPageResolver(Closure $resolver)
{
static::$currentPageResolver = $resolver;
}
/**
* Get an instance of the view factory from the resolver.
*
* @return \Illuminate\Contracts\View\Factory
*/
public static function viewFactory()
{
return call_user_func(static::$viewFactoryResolver);
}
/**
* Set the view factory resolver callback.
*
* @param \Closure $resolver
* @return void
*/
public static function viewFactoryResolver(Closure $resolver)
{
static::$viewFactoryResolver = $resolver;
}
/**
* Set the default pagination view.
*
* @param string $view
* @return void
*/
public static function defaultView($view)
{
static::$defaultView = $view;
}
/**
* Set the default "simple" pagination view.
*
* @param string $view
* @return void
*/
public static function defaultSimpleView($view)
{
static::$defaultSimpleView = $view;
}
/**
* Get an iterator for the items.
*
* @return \ArrayIterator
*/
public function getIterator()
{
return new ArrayIterator($this->items->all());
}
/**
* Determine if the list of items is empty or not.
*
* @return bool
*/
public function isEmpty()
{
return $this->items->isEmpty();
}
/**
* Get the number of items for the current page.
*
* @return int
*/
public function count()
{
return $this->items->count();
}
/**
* Get the paginator's underlying collection.
*
* @return \Illuminate\Support\Collection
*/
public function getCollection()
{
return $this->items;
}
/**
* Set the paginator's underlying collection.
*
* @param \Illuminate\Support\Collection $collection
* @return $this
*/
public function setCollection(Collection $collection)
{
$this->items = $collection;
return $this;
}
/**
* Determine if the given item exists.
*
* @param mixed $key
* @return bool
*/
public function offsetExists($key)
{
return $this->items->has($key);
}
/**
* Get the item at the given offset.
*
* @param mixed $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->items->get($key);
}
/**
* Set the item at the given offset.
*
* @param mixed $key
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)
{
$this->items->put($key, $value);
}
/**
* Unset the item at the given key.
*
* @param mixed $key
* @return void
*/
public function offsetUnset($key)
{
$this->items->forget($key);
}
/**
* Render the contents of the paginator to HTML.
*
* @return string
*/
public function toHtml()
{
return (string) $this->render();
}
/**
* Make dynamic calls into the collection.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return $this->getCollection()->$method(...$parameters);
}
/**
* Render the contents of the paginator when casting to string.
*
* @return string
*/
public function __toString()
{
return (string) $this->render();
}
}
| magyury/yanapa-volunteer-match | webapp/vendor/laravel/framework/src/Illuminate/Pagination/AbstractPaginator.php | PHP | mit | 12,056 |
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
module.exports = webpackMerge(commonConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: helpers.root('dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
devServer: {
historyApiFallback: true,
stats: 'minimal'
}
}); | jacksongomesbr/livro-web-codigo-fonte | front-end/sistema-eventos/passo-9/config/webpack.dev.js | JavaScript | cc0-1.0 | 573 |
/*
* Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed 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, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef MLX5_IB_H
#define MLX5_IB_H
#include <linux/kernel.h>
#include <linux/sched.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_smi.h>
#include <linux/mlx5/driver.h>
#include <linux/mlx5/cq.h>
#include <linux/mlx5/fs.h>
#include <linux/mlx5/qp.h>
#include <linux/types.h>
#include <linux/mlx5/transobj.h>
#include <rdma/ib_user_verbs.h>
#include <rdma/mlx5-abi.h>
#include <rdma/uverbs_ioctl.h>
#include <rdma/mlx5_user_ioctl_cmds.h>
#include "srq.h"
#define mlx5_ib_dbg(_dev, format, arg...) \
dev_dbg(&(_dev)->ib_dev.dev, "%s:%d:(pid %d): " format, __func__, \
__LINE__, current->pid, ##arg)
#define mlx5_ib_err(_dev, format, arg...) \
dev_err(&(_dev)->ib_dev.dev, "%s:%d:(pid %d): " format, __func__, \
__LINE__, current->pid, ##arg)
#define mlx5_ib_warn(_dev, format, arg...) \
dev_warn(&(_dev)->ib_dev.dev, "%s:%d:(pid %d): " format, __func__, \
__LINE__, current->pid, ##arg)
#define field_avail(type, fld, sz) (offsetof(type, fld) + \
sizeof(((type *)0)->fld) <= (sz))
#define MLX5_IB_DEFAULT_UIDX 0xffffff
#define MLX5_USER_ASSIGNED_UIDX_MASK __mlx5_mask(qpc, user_index)
#define MLX5_MKEY_PAGE_SHIFT_MASK __mlx5_mask(mkc, log_page_size)
enum {
MLX5_IB_MMAP_CMD_SHIFT = 8,
MLX5_IB_MMAP_CMD_MASK = 0xff,
};
enum {
MLX5_RES_SCAT_DATA32_CQE = 0x1,
MLX5_RES_SCAT_DATA64_CQE = 0x2,
MLX5_REQ_SCAT_DATA32_CQE = 0x11,
MLX5_REQ_SCAT_DATA64_CQE = 0x22,
};
enum mlx5_ib_mad_ifc_flags {
MLX5_MAD_IFC_IGNORE_MKEY = 1,
MLX5_MAD_IFC_IGNORE_BKEY = 2,
MLX5_MAD_IFC_NET_VIEW = 4,
};
enum {
MLX5_CROSS_CHANNEL_BFREG = 0,
};
enum {
MLX5_CQE_VERSION_V0,
MLX5_CQE_VERSION_V1,
};
enum {
MLX5_TM_MAX_RNDV_MSG_SIZE = 64,
MLX5_TM_MAX_SGE = 1,
};
enum {
MLX5_IB_INVALID_UAR_INDEX = BIT(31),
MLX5_IB_INVALID_BFREG = BIT(31),
};
enum {
MLX5_MAX_MEMIC_PAGES = 0x100,
MLX5_MEMIC_ALLOC_SIZE_MASK = 0x3f,
};
enum {
MLX5_MEMIC_BASE_ALIGN = 6,
MLX5_MEMIC_BASE_SIZE = 1 << MLX5_MEMIC_BASE_ALIGN,
};
struct mlx5_ib_ucontext {
struct ib_ucontext ibucontext;
struct list_head db_page_list;
/* protect doorbell record alloc/free
*/
struct mutex db_page_mutex;
struct mlx5_bfreg_info bfregi;
u8 cqe_version;
/* Transport Domain number */
u32 tdn;
u64 lib_caps;
DECLARE_BITMAP(dm_pages, MLX5_MAX_MEMIC_PAGES);
u16 devx_uid;
/* For RoCE LAG TX affinity */
atomic_t tx_port_affinity;
};
static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
{
return container_of(ibucontext, struct mlx5_ib_ucontext, ibucontext);
}
struct mlx5_ib_pd {
struct ib_pd ibpd;
u32 pdn;
u16 uid;
};
enum {
MLX5_IB_FLOW_ACTION_MODIFY_HEADER,
MLX5_IB_FLOW_ACTION_PACKET_REFORMAT,
MLX5_IB_FLOW_ACTION_DECAP,
};
#define MLX5_IB_FLOW_MCAST_PRIO (MLX5_BY_PASS_NUM_PRIOS - 1)
#define MLX5_IB_FLOW_LAST_PRIO (MLX5_BY_PASS_NUM_REGULAR_PRIOS - 1)
#if (MLX5_IB_FLOW_LAST_PRIO <= 0)
#error "Invalid number of bypass priorities"
#endif
#define MLX5_IB_FLOW_LEFTOVERS_PRIO (MLX5_IB_FLOW_MCAST_PRIO + 1)
#define MLX5_IB_NUM_FLOW_FT (MLX5_IB_FLOW_LEFTOVERS_PRIO + 1)
#define MLX5_IB_NUM_SNIFFER_FTS 2
#define MLX5_IB_NUM_EGRESS_FTS 1
struct mlx5_ib_flow_prio {
struct mlx5_flow_table *flow_table;
unsigned int refcount;
};
struct mlx5_ib_flow_handler {
struct list_head list;
struct ib_flow ibflow;
struct mlx5_ib_flow_prio *prio;
struct mlx5_flow_handle *rule;
struct ib_counters *ibcounters;
struct mlx5_ib_dev *dev;
struct mlx5_ib_flow_matcher *flow_matcher;
};
struct mlx5_ib_flow_matcher {
struct mlx5_ib_match_params matcher_mask;
int mask_len;
enum mlx5_ib_flow_type flow_type;
enum mlx5_flow_namespace_type ns_type;
u16 priority;
struct mlx5_core_dev *mdev;
atomic_t usecnt;
u8 match_criteria_enable;
};
struct mlx5_ib_flow_db {
struct mlx5_ib_flow_prio prios[MLX5_IB_NUM_FLOW_FT];
struct mlx5_ib_flow_prio egress_prios[MLX5_IB_NUM_FLOW_FT];
struct mlx5_ib_flow_prio sniffer[MLX5_IB_NUM_SNIFFER_FTS];
struct mlx5_ib_flow_prio egress[MLX5_IB_NUM_EGRESS_FTS];
struct mlx5_flow_table *lag_demux_ft;
/* Protect flow steering bypass flow tables
* when add/del flow rules.
* only single add/removal of flow steering rule could be done
* simultaneously.
*/
struct mutex lock;
};
/* Use macros here so that don't have to duplicate
* enum ib_send_flags and enum ib_qp_type for low-level driver
*/
#define MLX5_IB_SEND_UMR_ENABLE_MR (IB_SEND_RESERVED_START << 0)
#define MLX5_IB_SEND_UMR_DISABLE_MR (IB_SEND_RESERVED_START << 1)
#define MLX5_IB_SEND_UMR_FAIL_IF_FREE (IB_SEND_RESERVED_START << 2)
#define MLX5_IB_SEND_UMR_UPDATE_XLT (IB_SEND_RESERVED_START << 3)
#define MLX5_IB_SEND_UMR_UPDATE_TRANSLATION (IB_SEND_RESERVED_START << 4)
#define MLX5_IB_SEND_UMR_UPDATE_PD_ACCESS IB_SEND_RESERVED_END
#define MLX5_IB_QPT_REG_UMR IB_QPT_RESERVED1
/*
* IB_QPT_GSI creates the software wrapper around GSI, and MLX5_IB_QPT_HW_GSI
* creates the actual hardware QP.
*/
#define MLX5_IB_QPT_HW_GSI IB_QPT_RESERVED2
#define MLX5_IB_QPT_DCI IB_QPT_RESERVED3
#define MLX5_IB_QPT_DCT IB_QPT_RESERVED4
#define MLX5_IB_WR_UMR IB_WR_RESERVED1
#define MLX5_IB_UMR_OCTOWORD 16
#define MLX5_IB_UMR_XLT_ALIGNMENT 64
#define MLX5_IB_UPD_XLT_ZAP BIT(0)
#define MLX5_IB_UPD_XLT_ENABLE BIT(1)
#define MLX5_IB_UPD_XLT_ATOMIC BIT(2)
#define MLX5_IB_UPD_XLT_ADDR BIT(3)
#define MLX5_IB_UPD_XLT_PD BIT(4)
#define MLX5_IB_UPD_XLT_ACCESS BIT(5)
#define MLX5_IB_UPD_XLT_INDIRECT BIT(6)
/* Private QP creation flags to be passed in ib_qp_init_attr.create_flags.
*
* These flags are intended for internal use by the mlx5_ib driver, and they
* rely on the range reserved for that use in the ib_qp_create_flags enum.
*/
/* Create a UD QP whose source QP number is 1 */
static inline enum ib_qp_create_flags mlx5_ib_create_qp_sqpn_qp1(void)
{
return IB_QP_CREATE_RESERVED_START;
}
struct wr_list {
u16 opcode;
u16 next;
};
enum mlx5_ib_rq_flags {
MLX5_IB_RQ_CVLAN_STRIPPING = 1 << 0,
MLX5_IB_RQ_PCI_WRITE_END_PADDING = 1 << 1,
};
struct mlx5_ib_wq {
struct mlx5_frag_buf_ctrl fbc;
u64 *wrid;
u32 *wr_data;
struct wr_list *w_list;
unsigned *wqe_head;
u16 unsig_count;
/* serialize post to the work queue
*/
spinlock_t lock;
int wqe_cnt;
int max_post;
int max_gs;
int offset;
int wqe_shift;
unsigned head;
unsigned tail;
u16 cur_post;
void *cur_edge;
};
enum mlx5_ib_wq_flags {
MLX5_IB_WQ_FLAGS_DELAY_DROP = 0x1,
MLX5_IB_WQ_FLAGS_STRIDING_RQ = 0x2,
};
#define MLX5_MIN_SINGLE_WQE_LOG_NUM_STRIDES 9
#define MLX5_MAX_SINGLE_WQE_LOG_NUM_STRIDES 16
#define MLX5_MIN_SINGLE_STRIDE_LOG_NUM_BYTES 6
#define MLX5_MAX_SINGLE_STRIDE_LOG_NUM_BYTES 13
struct mlx5_ib_rwq {
struct ib_wq ibwq;
struct mlx5_core_qp core_qp;
u32 rq_num_pas;
u32 log_rq_stride;
u32 log_rq_size;
u32 rq_page_offset;
u32 log_page_size;
u32 log_num_strides;
u32 two_byte_shift_en;
u32 single_stride_log_num_of_bytes;
struct ib_umem *umem;
size_t buf_size;
unsigned int page_shift;
int create_type;
struct mlx5_db db;
u32 user_index;
u32 wqe_count;
u32 wqe_shift;
int wq_sig;
u32 create_flags; /* Use enum mlx5_ib_wq_flags */
};
enum {
MLX5_QP_USER,
MLX5_QP_KERNEL,
MLX5_QP_EMPTY
};
enum {
MLX5_WQ_USER,
MLX5_WQ_KERNEL
};
struct mlx5_ib_rwq_ind_table {
struct ib_rwq_ind_table ib_rwq_ind_tbl;
u32 rqtn;
u16 uid;
};
struct mlx5_ib_ubuffer {
struct ib_umem *umem;
int buf_size;
u64 buf_addr;
};
struct mlx5_ib_qp_base {
struct mlx5_ib_qp *container_mibqp;
struct mlx5_core_qp mqp;
struct mlx5_ib_ubuffer ubuffer;
};
struct mlx5_ib_qp_trans {
struct mlx5_ib_qp_base base;
u16 xrcdn;
u8 alt_port;
u8 atomic_rd_en;
u8 resp_depth;
};
struct mlx5_ib_rss_qp {
u32 tirn;
};
struct mlx5_ib_rq {
struct mlx5_ib_qp_base base;
struct mlx5_ib_wq *rq;
struct mlx5_ib_ubuffer ubuffer;
struct mlx5_db *doorbell;
u32 tirn;
u8 state;
u32 flags;
};
struct mlx5_ib_sq {
struct mlx5_ib_qp_base base;
struct mlx5_ib_wq *sq;
struct mlx5_ib_ubuffer ubuffer;
struct mlx5_db *doorbell;
struct mlx5_flow_handle *flow_rule;
u32 tisn;
u8 state;
};
struct mlx5_ib_raw_packet_qp {
struct mlx5_ib_sq sq;
struct mlx5_ib_rq rq;
};
struct mlx5_bf {
int buf_size;
unsigned long offset;
struct mlx5_sq_bfreg *bfreg;
};
struct mlx5_ib_dct {
struct mlx5_core_dct mdct;
u32 *in;
};
struct mlx5_ib_qp {
struct ib_qp ibqp;
union {
struct mlx5_ib_qp_trans trans_qp;
struct mlx5_ib_raw_packet_qp raw_packet_qp;
struct mlx5_ib_rss_qp rss_qp;
struct mlx5_ib_dct dct;
};
struct mlx5_frag_buf buf;
struct mlx5_db db;
struct mlx5_ib_wq rq;
u8 sq_signal_bits;
u8 next_fence;
struct mlx5_ib_wq sq;
/* serialize qp state modifications
*/
struct mutex mutex;
u32 flags;
u8 port;
u8 state;
int wq_sig;
int scat_cqe;
int max_inline_data;
struct mlx5_bf bf;
int has_rq;
/* only for user space QPs. For kernel
* we have it from the bf object
*/
int bfregn;
int create_type;
/* Store signature errors */
bool signature_en;
struct list_head qps_list;
struct list_head cq_recv_list;
struct list_head cq_send_list;
struct mlx5_rate_limit rl;
u32 underlay_qpn;
u32 flags_en;
/* storage for qp sub type when core qp type is IB_QPT_DRIVER */
enum ib_qp_type qp_sub_type;
};
struct mlx5_ib_cq_buf {
struct mlx5_frag_buf_ctrl fbc;
struct mlx5_frag_buf frag_buf;
struct ib_umem *umem;
int cqe_size;
int nent;
};
enum mlx5_ib_qp_flags {
MLX5_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO,
MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK,
MLX5_IB_QP_CROSS_CHANNEL = IB_QP_CREATE_CROSS_CHANNEL,
MLX5_IB_QP_MANAGED_SEND = IB_QP_CREATE_MANAGED_SEND,
MLX5_IB_QP_MANAGED_RECV = IB_QP_CREATE_MANAGED_RECV,
MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 5,
/* QP uses 1 as its source QP number */
MLX5_IB_QP_SQPN_QP1 = 1 << 6,
MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7,
MLX5_IB_QP_RSS = 1 << 8,
MLX5_IB_QP_CVLAN_STRIPPING = 1 << 9,
MLX5_IB_QP_UNDERLAY = 1 << 10,
MLX5_IB_QP_PCI_WRITE_END_PADDING = 1 << 11,
MLX5_IB_QP_TUNNEL_OFFLOAD = 1 << 12,
MLX5_IB_QP_PACKET_BASED_CREDIT = 1 << 13,
};
struct mlx5_umr_wr {
struct ib_send_wr wr;
u64 virt_addr;
u64 offset;
struct ib_pd *pd;
unsigned int page_shift;
unsigned int xlt_size;
u64 length;
int access_flags;
u32 mkey;
};
static inline const struct mlx5_umr_wr *umr_wr(const struct ib_send_wr *wr)
{
return container_of(wr, struct mlx5_umr_wr, wr);
}
struct mlx5_shared_mr_info {
int mr_id;
struct ib_umem *umem;
};
enum mlx5_ib_cq_pr_flags {
MLX5_IB_CQ_PR_FLAGS_CQE_128_PAD = 1 << 0,
};
struct mlx5_ib_cq {
struct ib_cq ibcq;
struct mlx5_core_cq mcq;
struct mlx5_ib_cq_buf buf;
struct mlx5_db db;
/* serialize access to the CQ
*/
spinlock_t lock;
/* protect resize cq
*/
struct mutex resize_mutex;
struct mlx5_ib_cq_buf *resize_buf;
struct ib_umem *resize_umem;
int cqe_size;
struct list_head list_send_qp;
struct list_head list_recv_qp;
u32 create_flags;
struct list_head wc_list;
enum ib_cq_notify_flags notify_flags;
struct work_struct notify_work;
u16 private_flags; /* Use mlx5_ib_cq_pr_flags */
};
struct mlx5_ib_wc {
struct ib_wc wc;
struct list_head list;
};
struct mlx5_ib_srq {
struct ib_srq ibsrq;
struct mlx5_core_srq msrq;
struct mlx5_frag_buf buf;
struct mlx5_db db;
struct mlx5_frag_buf_ctrl fbc;
u64 *wrid;
/* protect SRQ hanlding
*/
spinlock_t lock;
int head;
int tail;
u16 wqe_ctr;
struct ib_umem *umem;
/* serialize arming a SRQ
*/
struct mutex mutex;
int wq_sig;
};
struct mlx5_ib_xrcd {
struct ib_xrcd ibxrcd;
u32 xrcdn;
};
enum mlx5_ib_mtt_access_flags {
MLX5_IB_MTT_READ = (1 << 0),
MLX5_IB_MTT_WRITE = (1 << 1),
};
struct mlx5_ib_dm {
struct ib_dm ibdm;
phys_addr_t dev_addr;
};
#define MLX5_IB_MTT_PRESENT (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE)
#define MLX5_IB_DM_ALLOWED_ACCESS (IB_ACCESS_LOCAL_WRITE |\
IB_ACCESS_REMOTE_WRITE |\
IB_ACCESS_REMOTE_READ |\
IB_ACCESS_REMOTE_ATOMIC |\
IB_ZERO_BASED)
struct mlx5_ib_mr {
struct ib_mr ibmr;
void *descs;
dma_addr_t desc_map;
int ndescs;
int max_descs;
int desc_size;
int access_mode;
struct mlx5_core_mkey mmkey;
struct ib_umem *umem;
struct mlx5_shared_mr_info *smr_info;
struct list_head list;
int order;
bool allocated_from_cache;
int npages;
struct mlx5_ib_dev *dev;
u32 out[MLX5_ST_SZ_DW(create_mkey_out)];
struct mlx5_core_sig_ctx *sig;
int live;
void *descs_alloc;
int access_flags; /* Needed for rereg MR */
struct mlx5_ib_mr *parent;
atomic_t num_leaf_free;
wait_queue_head_t q_leaf_free;
};
struct mlx5_ib_mw {
struct ib_mw ibmw;
struct mlx5_core_mkey mmkey;
int ndescs;
};
struct mlx5_ib_umr_context {
struct ib_cqe cqe;
enum ib_wc_status status;
struct completion done;
};
struct umr_common {
struct ib_pd *pd;
struct ib_cq *cq;
struct ib_qp *qp;
/* control access to UMR QP
*/
struct semaphore sem;
};
enum {
MLX5_FMR_INVALID,
MLX5_FMR_VALID,
MLX5_FMR_BUSY,
};
struct mlx5_cache_ent {
struct list_head head;
/* sync access to the cahce entry
*/
spinlock_t lock;
struct dentry *dir;
char name[4];
u32 order;
u32 xlt;
u32 access_mode;
u32 page;
u32 size;
u32 cur;
u32 miss;
u32 limit;
struct dentry *fsize;
struct dentry *fcur;
struct dentry *fmiss;
struct dentry *flimit;
struct mlx5_ib_dev *dev;
struct work_struct work;
struct delayed_work dwork;
int pending;
struct completion compl;
};
struct mlx5_mr_cache {
struct workqueue_struct *wq;
struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES];
int stopped;
struct dentry *root;
unsigned long last_add;
};
struct mlx5_ib_gsi_qp;
struct mlx5_ib_port_resources {
struct mlx5_ib_resources *devr;
struct mlx5_ib_gsi_qp *gsi;
struct work_struct pkey_change_work;
};
struct mlx5_ib_resources {
struct ib_cq *c0;
struct ib_xrcd *x0;
struct ib_xrcd *x1;
struct ib_pd *p0;
struct ib_srq *s0;
struct ib_srq *s1;
struct mlx5_ib_port_resources ports[2];
/* Protects changes to the port resources */
struct mutex mutex;
};
struct mlx5_ib_counters {
const char **names;
size_t *offsets;
u32 num_q_counters;
u32 num_cong_counters;
u32 num_ext_ppcnt_counters;
u16 set_id;
bool set_id_valid;
};
struct mlx5_ib_multiport_info;
struct mlx5_ib_multiport {
struct mlx5_ib_multiport_info *mpi;
/* To be held when accessing the multiport info */
spinlock_t mpi_lock;
};
struct mlx5_ib_port {
struct mlx5_ib_counters cnts;
struct mlx5_ib_multiport mp;
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
};
struct mlx5_roce {
/* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL
* netdev pointer
*/
rwlock_t netdev_lock;
struct net_device *netdev;
struct notifier_block nb;
atomic_t tx_port_affinity;
enum ib_port_state last_port_state;
struct mlx5_ib_dev *dev;
u8 native_port_num;
};
struct mlx5_ib_dbg_param {
int offset;
struct mlx5_ib_dev *dev;
struct dentry *dentry;
u8 port_num;
};
enum mlx5_ib_dbg_cc_types {
MLX5_IB_DBG_CC_RP_CLAMP_TGT_RATE,
MLX5_IB_DBG_CC_RP_CLAMP_TGT_RATE_ATI,
MLX5_IB_DBG_CC_RP_TIME_RESET,
MLX5_IB_DBG_CC_RP_BYTE_RESET,
MLX5_IB_DBG_CC_RP_THRESHOLD,
MLX5_IB_DBG_CC_RP_AI_RATE,
MLX5_IB_DBG_CC_RP_HAI_RATE,
MLX5_IB_DBG_CC_RP_MIN_DEC_FAC,
MLX5_IB_DBG_CC_RP_MIN_RATE,
MLX5_IB_DBG_CC_RP_RATE_TO_SET_ON_FIRST_CNP,
MLX5_IB_DBG_CC_RP_DCE_TCP_G,
MLX5_IB_DBG_CC_RP_DCE_TCP_RTT,
MLX5_IB_DBG_CC_RP_RATE_REDUCE_MONITOR_PERIOD,
MLX5_IB_DBG_CC_RP_INITIAL_ALPHA_VALUE,
MLX5_IB_DBG_CC_RP_GD,
MLX5_IB_DBG_CC_NP_CNP_DSCP,
MLX5_IB_DBG_CC_NP_CNP_PRIO_MODE,
MLX5_IB_DBG_CC_NP_CNP_PRIO,
MLX5_IB_DBG_CC_MAX,
};
struct mlx5_ib_dbg_cc_params {
struct dentry *root;
struct mlx5_ib_dbg_param params[MLX5_IB_DBG_CC_MAX];
};
enum {
MLX5_MAX_DELAY_DROP_TIMEOUT_MS = 100,
};
struct mlx5_ib_dbg_delay_drop {
struct dentry *dir_debugfs;
struct dentry *rqs_cnt_debugfs;
struct dentry *events_cnt_debugfs;
struct dentry *timeout_debugfs;
};
struct mlx5_ib_delay_drop {
struct mlx5_ib_dev *dev;
struct work_struct delay_drop_work;
/* serialize setting of delay drop */
struct mutex lock;
u32 timeout;
bool activate;
atomic_t events_cnt;
atomic_t rqs_cnt;
struct mlx5_ib_dbg_delay_drop *dbg;
};
enum mlx5_ib_stages {
MLX5_IB_STAGE_INIT,
MLX5_IB_STAGE_FLOW_DB,
MLX5_IB_STAGE_CAPS,
MLX5_IB_STAGE_NON_DEFAULT_CB,
MLX5_IB_STAGE_ROCE,
MLX5_IB_STAGE_SRQ,
MLX5_IB_STAGE_DEVICE_RESOURCES,
MLX5_IB_STAGE_DEVICE_NOTIFIER,
MLX5_IB_STAGE_ODP,
MLX5_IB_STAGE_COUNTERS,
MLX5_IB_STAGE_CONG_DEBUGFS,
MLX5_IB_STAGE_UAR,
MLX5_IB_STAGE_BFREG,
MLX5_IB_STAGE_PRE_IB_REG_UMR,
MLX5_IB_STAGE_WHITELIST_UID,
MLX5_IB_STAGE_IB_REG,
MLX5_IB_STAGE_POST_IB_REG_UMR,
MLX5_IB_STAGE_DELAY_DROP,
MLX5_IB_STAGE_CLASS_ATTR,
MLX5_IB_STAGE_MAX,
};
struct mlx5_ib_stage {
int (*init)(struct mlx5_ib_dev *dev);
void (*cleanup)(struct mlx5_ib_dev *dev);
};
#define STAGE_CREATE(_stage, _init, _cleanup) \
.stage[_stage] = {.init = _init, .cleanup = _cleanup}
struct mlx5_ib_profile {
struct mlx5_ib_stage stage[MLX5_IB_STAGE_MAX];
};
struct mlx5_ib_multiport_info {
struct list_head list;
struct mlx5_ib_dev *ibdev;
struct mlx5_core_dev *mdev;
struct notifier_block mdev_events;
struct completion unref_comp;
u64 sys_image_guid;
u32 mdev_refcnt;
bool is_master;
bool unaffiliate;
};
struct mlx5_ib_flow_action {
struct ib_flow_action ib_action;
union {
struct {
u64 ib_flags;
struct mlx5_accel_esp_xfrm *ctx;
} esp_aes_gcm;
struct {
struct mlx5_ib_dev *dev;
u32 sub_type;
u32 action_id;
} flow_action_raw;
};
};
struct mlx5_memic {
struct mlx5_core_dev *dev;
spinlock_t memic_lock;
DECLARE_BITMAP(memic_alloc_pages, MLX5_MAX_MEMIC_PAGES);
};
struct mlx5_read_counters_attr {
struct mlx5_fc *hw_cntrs_hndl;
u64 *out;
u32 flags;
};
enum mlx5_ib_counters_type {
MLX5_IB_COUNTERS_FLOW,
};
struct mlx5_ib_mcounters {
struct ib_counters ibcntrs;
enum mlx5_ib_counters_type type;
/* number of counters supported for this counters type */
u32 counters_num;
struct mlx5_fc *hw_cntrs_hndl;
/* read function for this counters type */
int (*read_counters)(struct ib_device *ibdev,
struct mlx5_read_counters_attr *read_attr);
/* max index set as part of create_flow */
u32 cntrs_max_index;
/* number of counters data entries (<description,index> pair) */
u32 ncounters;
/* counters data array for descriptions and indexes */
struct mlx5_ib_flow_counters_desc *counters_data;
/* protects access to mcounters internal data */
struct mutex mcntrs_mutex;
};
static inline struct mlx5_ib_mcounters *
to_mcounters(struct ib_counters *ibcntrs)
{
return container_of(ibcntrs, struct mlx5_ib_mcounters, ibcntrs);
}
int parse_flow_flow_action(struct mlx5_ib_flow_action *maction,
bool is_egress,
struct mlx5_flow_act *action);
struct mlx5_ib_lb_state {
/* protect the user_td */
struct mutex mutex;
u32 user_td;
int qps;
bool enabled;
};
struct mlx5_ib_pf_eq {
struct mlx5_ib_dev *dev;
struct mlx5_eq *core;
struct work_struct work;
spinlock_t lock; /* Pagefaults spinlock */
struct workqueue_struct *wq;
mempool_t *pool;
};
struct mlx5_ib_dev {
struct ib_device ib_dev;
struct mlx5_core_dev *mdev;
struct notifier_block mdev_events;
struct mlx5_roce roce[MLX5_MAX_PORTS];
int num_ports;
/* serialize update of capability mask
*/
struct mutex cap_mask_mutex;
bool ib_active;
struct umr_common umrc;
/* sync used page count stats
*/
struct mlx5_ib_resources devr;
struct mlx5_mr_cache cache;
struct timer_list delay_timer;
/* Prevents soft lock on massive reg MRs */
struct mutex slow_path_mutex;
int fill_delay;
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
struct ib_odp_caps odp_caps;
u64 odp_max_size;
struct mlx5_ib_pf_eq odp_pf_eq;
/*
* Sleepable RCU that prevents destruction of MRs while they are still
* being used by a page fault handler.
*/
struct srcu_struct mr_srcu;
u32 null_mkey;
struct workqueue_struct *advise_mr_wq;
#endif
struct mlx5_ib_flow_db *flow_db;
/* protect resources needed as part of reset flow */
spinlock_t reset_flow_resource_lock;
struct list_head qp_list;
/* Array with num_ports elements */
struct mlx5_ib_port *port;
struct mlx5_sq_bfreg bfreg;
struct mlx5_sq_bfreg fp_bfreg;
struct mlx5_ib_delay_drop delay_drop;
const struct mlx5_ib_profile *profile;
struct mlx5_eswitch_rep *rep;
int lag_active;
struct mlx5_ib_lb_state lb;
u8 umr_fence;
struct list_head ib_dev_list;
u64 sys_image_guid;
struct mlx5_memic memic;
u16 devx_whitelist_uid;
struct mlx5_srq_table srq_table;
};
static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
{
return container_of(mcq, struct mlx5_ib_cq, mcq);
}
static inline struct mlx5_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd)
{
return container_of(ibxrcd, struct mlx5_ib_xrcd, ibxrcd);
}
static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
{
return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
}
static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
{
return container_of(ibcq, struct mlx5_ib_cq, ibcq);
}
static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp)
{
return container_of(mqp, struct mlx5_ib_qp_base, mqp)->container_mibqp;
}
static inline struct mlx5_ib_rwq *to_mibrwq(struct mlx5_core_qp *core_qp)
{
return container_of(core_qp, struct mlx5_ib_rwq, core_qp);
}
static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mkey *mmkey)
{
return container_of(mmkey, struct mlx5_ib_mr, mmkey);
}
static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd)
{
return container_of(ibpd, struct mlx5_ib_pd, ibpd);
}
static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq)
{
return container_of(ibsrq, struct mlx5_ib_srq, ibsrq);
}
static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp)
{
return container_of(ibqp, struct mlx5_ib_qp, ibqp);
}
static inline struct mlx5_ib_rwq *to_mrwq(struct ib_wq *ibwq)
{
return container_of(ibwq, struct mlx5_ib_rwq, ibwq);
}
static inline struct mlx5_ib_rwq_ind_table *to_mrwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
{
return container_of(ib_rwq_ind_tbl, struct mlx5_ib_rwq_ind_table, ib_rwq_ind_tbl);
}
static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq)
{
return container_of(msrq, struct mlx5_ib_srq, msrq);
}
static inline struct mlx5_ib_dm *to_mdm(struct ib_dm *ibdm)
{
return container_of(ibdm, struct mlx5_ib_dm, ibdm);
}
static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr)
{
return container_of(ibmr, struct mlx5_ib_mr, ibmr);
}
static inline struct mlx5_ib_mw *to_mmw(struct ib_mw *ibmw)
{
return container_of(ibmw, struct mlx5_ib_mw, ibmw);
}
static inline struct mlx5_ib_flow_action *
to_mflow_act(struct ib_flow_action *ibact)
{
return container_of(ibact, struct mlx5_ib_flow_action, ib_action);
}
int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt,
struct mlx5_db *db);
void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db);
void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
const void *in_mad, void *response_mad);
struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
u32 flags, struct ib_udata *udata);
int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
int mlx5_ib_destroy_ah(struct ib_ah *ah, u32 flags);
struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
struct ib_srq_init_attr *init_attr,
struct ib_udata *udata);
int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
int mlx5_ib_destroy_srq(struct ib_srq *srq);
int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr);
int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp);
void mlx5_ib_disable_lb(struct mlx5_ib_dev *dev, bool td, bool qp);
struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata);
int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata);
int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
struct ib_qp_init_attr *qp_init_attr);
int mlx5_ib_destroy_qp(struct ib_qp *qp);
void mlx5_ib_drain_sq(struct ib_qp *qp);
void mlx5_ib_drain_rq(struct ib_qp *qp);
int mlx5_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
const struct ib_send_wr **bad_wr);
int mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr);
int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index,
void *buffer, u32 length,
struct mlx5_ib_qp_base *base);
struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata);
int mlx5_ib_destroy_cq(struct ib_cq *cq);
int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc);
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
struct ib_udata *udata);
int mlx5_ib_advise_mr(struct ib_pd *pd,
enum ib_uverbs_advise_mr_advice advice,
u32 flags,
struct ib_sge *sg_list,
u32 num_sge,
struct uverbs_attr_bundle *attrs);
struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
struct ib_udata *udata);
int mlx5_ib_dealloc_mw(struct ib_mw *mw);
int mlx5_ib_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
int page_shift, int flags);
struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
int access_flags);
void mlx5_ib_free_implicit_mr(struct mlx5_ib_mr *mr);
int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
u64 length, u64 virt_addr, int access_flags,
struct ib_pd *pd, struct ib_udata *udata);
int mlx5_ib_dereg_mr(struct ib_mr *ibmr);
struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
enum ib_mr_type mr_type,
u32 max_num_sg);
int mlx5_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
unsigned int *sg_offset);
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
const struct ib_wc *in_wc, const struct ib_grh *in_grh,
const struct ib_mad_hdr *in, size_t in_mad_size,
struct ib_mad_hdr *out, size_t *out_mad_size,
u16 *out_mad_pkey_index);
struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
struct ib_ucontext *context,
struct ib_udata *udata);
int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd);
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset);
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
struct ib_smp *out_mad);
int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
__be64 *sys_image_guid);
int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,
u16 *max_pkeys);
int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev,
u32 *vendor_id);
int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc);
int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid);
int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u8 port, u16 index,
u16 *pkey);
int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid);
int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props);
int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props);
int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev);
void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev);
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr,
unsigned long max_page_shift,
int *count, int *shift,
int *ncont, int *order);
void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
int page_shift, size_t offset, size_t num_pages,
__be64 *pas, int access_flags);
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
int page_shift, __be64 *pas, int access_flags);
void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num);
int mlx5_ib_get_cqe_size(struct ib_cq *ibcq);
int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
struct mlx5_ib_mr *mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, int entry);
void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr);
int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
struct ib_mr_status *mr_status);
struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
struct ib_wq_init_attr *init_attr,
struct ib_udata *udata);
int mlx5_ib_destroy_wq(struct ib_wq *wq);
int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
u32 wq_attr_mask, struct ib_udata *udata);
struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
struct ib_rwq_ind_table_init_attr *init_attr,
struct ib_udata *udata);
int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
bool mlx5_ib_dc_atomic_is_supported(struct mlx5_ib_dev *dev);
struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev,
struct ib_ucontext *context,
struct ib_dm_alloc_attr *attr,
struct uverbs_attr_bundle *attrs);
int mlx5_ib_dealloc_dm(struct ib_dm *ibdm);
struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm,
struct ib_dm_mr_attr *attr,
struct uverbs_attr_bundle *attrs);
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev);
int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev);
void mlx5_ib_odp_cleanup_one(struct mlx5_ib_dev *ibdev);
int __init mlx5_ib_odp_init(void);
void mlx5_ib_odp_cleanup(void);
void mlx5_ib_invalidate_range(struct ib_umem_odp *umem_odp, unsigned long start,
unsigned long end);
void mlx5_odp_init_mr_cache_entry(struct mlx5_cache_ent *ent);
void mlx5_odp_populate_klm(struct mlx5_klm *pklm, size_t offset,
size_t nentries, struct mlx5_ib_mr *mr, int flags);
int mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
enum ib_uverbs_advise_mr_advice advice,
u32 flags, struct ib_sge *sg_list, u32 num_sge);
#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
static inline void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
{
return;
}
static inline int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev) { return 0; }
static inline void mlx5_ib_odp_cleanup_one(struct mlx5_ib_dev *ibdev) {}
static inline int mlx5_ib_odp_init(void) { return 0; }
static inline void mlx5_ib_odp_cleanup(void) {}
static inline void mlx5_odp_init_mr_cache_entry(struct mlx5_cache_ent *ent) {}
static inline void mlx5_odp_populate_klm(struct mlx5_klm *pklm, size_t offset,
size_t nentries, struct mlx5_ib_mr *mr,
int flags) {}
static inline int
mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
enum ib_uverbs_advise_mr_advice advice, u32 flags,
struct ib_sge *sg_list, u32 num_sge)
{
return -EOPNOTSUPP;
}
#endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
/* Needed for rep profile */
int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_rep_flow_db_init(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_rep_non_default_cb(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_rep_roce_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_rep_roce_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_dev_res_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_dev_res_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_counters_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_counters_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_bfrag_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_bfrag_cleanup(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_pre_ib_reg_umr_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev);
void mlx5_ib_stage_ib_reg_cleanup(struct mlx5_ib_dev *dev);
int mlx5_ib_stage_post_ib_reg_umr_init(struct mlx5_ib_dev *dev);
void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
const struct mlx5_ib_profile *profile,
int stage);
void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
const struct mlx5_ib_profile *profile);
int mlx5_ib_get_vf_config(struct ib_device *device, int vf,
u8 port, struct ifla_vf_info *info);
int mlx5_ib_set_vf_link_state(struct ib_device *device, int vf,
u8 port, int state);
int mlx5_ib_get_vf_stats(struct ib_device *device, int vf,
u8 port, struct ifla_vf_stats *stats);
int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port,
u64 guid, int type);
__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev,
const struct ib_gid_attr *attr);
void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
/* GSI QP helper functions */
struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
struct ib_qp_init_attr *init_attr);
int mlx5_ib_gsi_destroy_qp(struct ib_qp *qp);
int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
int attr_mask);
int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
int qp_attr_mask,
struct ib_qp_init_attr *qp_init_attr);
int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr,
const struct ib_send_wr **bad_wr);
int mlx5_ib_gsi_post_recv(struct ib_qp *qp, const struct ib_recv_wr *wr,
const struct ib_recv_wr **bad_wr);
void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi);
int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc);
void mlx5_ib_free_bfreg(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi,
int bfregn);
struct mlx5_ib_dev *mlx5_ib_get_ibdev_from_mpi(struct mlx5_ib_multiport_info *mpi);
struct mlx5_core_dev *mlx5_ib_get_native_port_mdev(struct mlx5_ib_dev *dev,
u8 ib_port_num,
u8 *native_port_num);
void mlx5_ib_put_native_port_mdev(struct mlx5_ib_dev *dev,
u8 port_num);
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user);
void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid);
const struct uverbs_object_tree_def *mlx5_ib_get_devx_tree(void);
extern const struct uapi_definition mlx5_ib_devx_defs[];
extern const struct uapi_definition mlx5_ib_flow_defs[];
struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
struct mlx5_flow_act *flow_act, u32 counter_id,
void *cmd_in, int inlen, int dest_id, int dest_type);
bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
bool mlx5_ib_devx_is_flow_counter(void *obj, u32 *counter_id);
int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root);
void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction);
#else
static inline int
mlx5_ib_devx_create(struct mlx5_ib_dev *dev,
bool is_user) { return -EOPNOTSUPP; }
static inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid) {}
static inline bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id,
int *dest_type)
{
return false;
}
static inline void
mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction)
{
return;
};
#endif
static inline void init_query_mad(struct ib_smp *mad)
{
mad->base_version = 1;
mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
mad->class_version = 1;
mad->method = IB_MGMT_METHOD_GET;
}
static inline u8 convert_access(int acc)
{
return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) |
(acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) |
(acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) |
(acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) |
MLX5_PERM_LOCAL_READ;
}
static inline int is_qp1(enum ib_qp_type qp_type)
{
return qp_type == MLX5_IB_QPT_HW_GSI;
}
#define MLX5_MAX_UMR_SHIFT 16
#define MLX5_MAX_UMR_PAGES (1 << MLX5_MAX_UMR_SHIFT)
static inline u32 check_cq_create_flags(u32 flags)
{
/*
* It returns non-zero value for unsupported CQ
* create flags, otherwise it returns zero.
*/
return (flags & ~(IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN |
IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION));
}
static inline int verify_assign_uidx(u8 cqe_version, u32 cmd_uidx,
u32 *user_index)
{
if (cqe_version) {
if ((cmd_uidx == MLX5_IB_DEFAULT_UIDX) ||
(cmd_uidx & ~MLX5_USER_ASSIGNED_UIDX_MASK))
return -EINVAL;
*user_index = cmd_uidx;
} else {
*user_index = MLX5_IB_DEFAULT_UIDX;
}
return 0;
}
static inline int get_qp_user_index(struct mlx5_ib_ucontext *ucontext,
struct mlx5_ib_create_qp *ucmd,
int inlen,
u32 *user_index)
{
u8 cqe_version = ucontext->cqe_version;
if (field_avail(struct mlx5_ib_create_qp, uidx, inlen) &&
!cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
return 0;
if (!!(field_avail(struct mlx5_ib_create_qp, uidx, inlen) !=
!!cqe_version))
return -EINVAL;
return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
}
static inline int get_srq_user_index(struct mlx5_ib_ucontext *ucontext,
struct mlx5_ib_create_srq *ucmd,
int inlen,
u32 *user_index)
{
u8 cqe_version = ucontext->cqe_version;
if (field_avail(struct mlx5_ib_create_srq, uidx, inlen) &&
!cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
return 0;
if (!!(field_avail(struct mlx5_ib_create_srq, uidx, inlen) !=
!!cqe_version))
return -EINVAL;
return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
}
static inline int get_uars_per_sys_page(struct mlx5_ib_dev *dev, bool lib_support)
{
return lib_support && MLX5_CAP_GEN(dev->mdev, uar_4k) ?
MLX5_UARS_IN_PAGE : 1;
}
static inline int get_num_static_uars(struct mlx5_ib_dev *dev,
struct mlx5_bfreg_info *bfregi)
{
return get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * bfregi->num_static_sys_pages;
}
unsigned long mlx5_ib_get_xlt_emergency_page(void);
void mlx5_ib_put_xlt_emergency_page(void);
int bfregn_to_uar_index(struct mlx5_ib_dev *dev,
struct mlx5_bfreg_info *bfregi, u32 bfregn,
bool dyn_bfreg);
#endif /* MLX5_IB_H */
| uniphier/linux-unph | drivers/infiniband/hw/mlx5/mlx5_ib.h | C | gpl-2.0 | 41,224 |
/*
* Copyright (c) 2006, 2014, 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.
*/
/*
test
@bug 4955110
@summary tests that a drag ends on button2 release
@author Alexander.Gerasimov area=dnd
@library ../../regtesthelpers
@build Util
@run applet/othervm Button2DragTest.html
*/
/**
* Button2DragTest.java
*
* summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec
* (does not depend on the user drop action)
*
*/
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import test.java.awt.regtesthelpers.Util;
public class Button2DragTest extends Applet {
private volatile boolean dropSuccess;
private Frame frame;
public void init() {
// Set up the environment -- set the layout manager, add
// buttons, etc.
setLayout(new BorderLayout());
frame = new Frame();
final DragSourceListener dragSourceListener = new DragSourceAdapter() {
public void dragDropEnd(DragSourceDropEvent e) {
dropSuccess = e.getDropSuccess();
System.err.println("Drop was successful: " + dropSuccess);
}
};
DragGestureListener dragGestureListener = new DragGestureListener() {
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(null, new StringSelection("OK"), dragSourceListener);
}
};
new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_MOVE,
dragGestureListener);
DropTargetAdapter dropTargetListener = new DropTargetAdapter() {
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
dtde.dropComplete(true);
System.err.println("Drop");
}
};
new DropTarget(frame, dropTargetListener);
}
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200,200);
setVisible(true);
validate();
//What would normally go into main() will probably go here.
//Use System.out.println for diagnostic messages that you want
//to read after the test is done.
frame.setBounds(100, 100, 200, 200);
frame.setVisible(true);
Robot robot = Util.createRobot();
Util.waitForIdle(robot);
Point startPoint = frame.getLocationOnScreen();
Point endPoint = new Point(startPoint);
startPoint.translate(50, 50);
endPoint.translate(150, 150);
Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK);
Util.waitForIdle(robot);
robot.delay(500);
if (dropSuccess) {
System.err.println("test passed");
} else {
throw new RuntimeException("test failed: drop was not successful");
}
}
}
| frohoff/jdk8u-jdk | test/java/awt/dnd/Button2DragTest/Button2DragTest.java | Java | gpl-2.0 | 4,012 |
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2007 AMD
* Written by Yinghai Lu <yinghailu@amd.com> for AMD.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
static void setup_mb_resource_map(void)
{
static const unsigned int register_values[] = {
/* Careful set limit registers before base registers which contain the enables */
/* DRAM Limit i Registers
* F1:0x44 i = 0
* F1:0x4C i = 1
* F1:0x54 i = 2
* F1:0x5C i = 3
* F1:0x64 i = 4
* F1:0x6C i = 5
* F1:0x74 i = 6
* F1:0x7C i = 7
* [ 2: 0] Destination Node ID
* 000 = Node 0
* 001 = Node 1
* 010 = Node 2
* 011 = Node 3
* 100 = Node 4
* 101 = Node 5
* 110 = Node 6
* 111 = Node 7
* [ 7: 3] Reserved
* [10: 8] Interleave select
* specifies the values of A[14:12] to use with interleave enable.
* [15:11] Reserved
* [31:16] DRAM Limit Address i Bits 39-24
* This field defines the upper address bits of a 40 bit address
* that define the end of the DRAM region.
*/
PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
PCI_ADDR(0, 0x18, 1, 0x54), 0x0000f8f8, 0x00000002,
PCI_ADDR(0, 0x18, 1, 0x5C), 0x0000f8f8, 0x00000003,
PCI_ADDR(0, 0x18, 1, 0x64), 0x0000f8f8, 0x00000004,
PCI_ADDR(0, 0x18, 1, 0x6C), 0x0000f8f8, 0x00000005,
PCI_ADDR(0, 0x18, 1, 0x74), 0x0000f8f8, 0x00000006,
PCI_ADDR(0, 0x18, 1, 0x7C), 0x0000f8f8, 0x00000007,
/* DRAM Base i Registers
* F1:0x40 i = 0
* F1:0x48 i = 1
* F1:0x50 i = 2
* F1:0x58 i = 3
* F1:0x60 i = 4
* F1:0x68 i = 5
* F1:0x70 i = 6
* F1:0x78 i = 7
* [ 0: 0] Read Enable
* 0 = Reads Disabled
* 1 = Reads Enabled
* [ 1: 1] Write Enable
* 0 = Writes Disabled
* 1 = Writes Enabled
* [ 7: 2] Reserved
* [10: 8] Interleave Enable
* 000 = No interleave
* 001 = Interleave on A[12] (2 nodes)
* 010 = reserved
* 011 = Interleave on A[12] and A[14] (4 nodes)
* 100 = reserved
* 101 = reserved
* 110 = reserved
* 111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
* [15:11] Reserved
* [13:16] DRAM Base Address i Bits 39-24
* This field defines the upper address bits of a 40-bit address
* that define the start of the DRAM region.
*/
PCI_ADDR(0, 0x18, 1, 0x40), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00000000,
/* Memory-Mapped I/O Limit i Registers
* F1:0x84 i = 0
* F1:0x8C i = 1
* F1:0x94 i = 2
* F1:0x9C i = 3
* F1:0xA4 i = 4
* F1:0xAC i = 5
* F1:0xB4 i = 6
* F1:0xBC i = 7
* [ 2: 0] Destination Node ID
* 000 = Node 0
* 001 = Node 1
* 010 = Node 2
* 011 = Node 3
* 100 = Node 4
* 101 = Node 5
* 110 = Node 6
* 111 = Node 7
* [ 3: 3] Reserved
* [ 5: 4] Destination Link ID
* 00 = Link 0
* 01 = Link 1
* 10 = Link 2
* 11 = Reserved
* [ 6: 6] Reserved
* [ 7: 7] Non-Posted
* 0 = CPU writes may be posted
* 1 = CPU writes must be non-posted
* [31: 8] Memory-Mapped I/O Limit Address i (39-16)
* This field defines the upp adddress bits of a 40-bit address that
* defines the end of a memory-mapped I/O region n
*/
PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000000,
// PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00ffff00,
/* Memory-Mapped I/O Base i Registers
* F1:0x80 i = 0
* F1:0x88 i = 1
* F1:0x90 i = 2
* F1:0x98 i = 3
* F1:0xA0 i = 4
* F1:0xA8 i = 5
* F1:0xB0 i = 6
* F1:0xB8 i = 7
* [ 0: 0] Read Enable
* 0 = Reads disabled
* 1 = Reads Enabled
* [ 1: 1] Write Enable
* 0 = Writes disabled
* 1 = Writes Enabled
* [ 2: 2] Cpu Disable
* 0 = Cpu can use this I/O range
* 1 = Cpu requests do not use this I/O range
* [ 3: 3] Lock
* 0 = base/limit registers i are read/write
* 1 = base/limit registers i are read-only
* [ 7: 4] Reserved
* [31: 8] Memory-Mapped I/O Base Address i (39-16)
* This field defines the upper address bits of a 40bit address
* that defines the start of memory-mapped I/O region i
*/
PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000000,
// PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00fc0003,
/* PCI I/O Limit i Registers
* F1:0xC4 i = 0
* F1:0xCC i = 1
* F1:0xD4 i = 2
* F1:0xDC i = 3
* [ 2: 0] Destination Node ID
* 000 = Node 0
* 001 = Node 1
* 010 = Node 2
* 011 = Node 3
* 100 = Node 4
* 101 = Node 5
* 110 = Node 6
* 111 = Node 7
* [ 3: 3] Reserved
* [ 5: 4] Destination Link ID
* 00 = Link 0
* 01 = Link 1
* 10 = Link 2
* 11 = reserved
* [11: 6] Reserved
* [24:12] PCI I/O Limit Address i
* This field defines the end of PCI I/O region n
* [31:25] Reserved
*/
PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x01fff020,
PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x00000000, // need to talk to ANALOG of second CK804 to release PCI E reset
PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
/* PCI I/O Base i Registers
* F1:0xC0 i = 0
* F1:0xC8 i = 1
* F1:0xD0 i = 2
* F1:0xD8 i = 3
* [ 0: 0] Read Enable
* 0 = Reads Disabled
* 1 = Reads Enabled
* [ 1: 1] Write Enable
* 0 = Writes Disabled
* 1 = Writes Enabled
* [ 3: 2] Reserved
* [ 4: 4] VGA Enable
* 0 = VGA matches Disabled
* 1 = matches all address < 64K and where A[9:0] is in the
* range 3B0-3BB or 3C0-3DF independen of the base & limit registers
* [ 5: 5] ISA Enable
* 0 = ISA matches Disabled
* 1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
* from matching agains this base/limit pair
* [11: 6] Reserved
* [24:12] PCI I/O Base i
* This field defines the start of PCI I/O region n
* [31:25] Reserved
*/
PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x00000033,
PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
/* Config Base and Limit i Registers
* F1:0xE0 i = 0
* F1:0xE4 i = 1
* F1:0xE8 i = 2
* F1:0xEC i = 3
* [ 0: 0] Read Enable
* 0 = Reads Disabled
* 1 = Reads Enabled
* [ 1: 1] Write Enable
* 0 = Writes Disabled
* 1 = Writes Enabled
* [ 2: 2] Device Number Compare Enable
* 0 = The ranges are based on bus number
* 1 = The ranges are ranges of devices on bus 0
* [ 3: 3] Reserved
* [ 6: 4] Destination Node
* 000 = Node 0
* 001 = Node 1
* 010 = Node 2
* 011 = Node 3
* 100 = Node 4
* 101 = Node 5
* 110 = Node 6
* 111 = Node 7
* [ 7: 7] Reserved
* [ 9: 8] Destination Link
* 00 = Link 0
* 01 = Link 1
* 10 = Link 2
* 11 - Reserved
* [15:10] Reserved
* [23:16] Bus Number Base i
* This field defines the lowest bus number in configuration region i
* [31:24] Bus Number Limit i
* This field defines the highest bus number in configuration region i
*/
PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0x3f000203, /* link 2 of cpu 0 --> Nvidia MCP55 Pro */
PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
};
int max;
max = ARRAY_SIZE(register_values);
setup_resource_map(register_values, max);
}
| hustcalm/coreboot-hacking | src/mainboard/supermicro/h8dmr/resourcemap.c | C | gpl-2.0 | 9,232 |
/***************************************************************************
qgsgeometryfollowboundariescheck.h
---------------------
begin : September 2017
copyright : (C) 2017 by Sandro Mani / Sourcepole AG
email : smani at sourcepole dot ch
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#define SIP_NO_FILE
#ifndef QGSGEOMETRYFOLLOWBOUNDARIESCHECK_H
#define QGSGEOMETRYFOLLOWBOUNDARIESCHECK_H
#include "qgsgeometrycheck.h"
class QgsSpatialIndex;
/**
* \ingroup analysis
* \brief A follow boundaries check.
*/
class ANALYSIS_EXPORT QgsGeometryFollowBoundariesCheck : public QgsGeometryCheck
{
Q_DECLARE_TR_FUNCTIONS( QgsGeometryFollowBoundariesCheck )
public:
QgsGeometryFollowBoundariesCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration, QgsVectorLayer *checkLayer );
~QgsGeometryFollowBoundariesCheck() override;
static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
static QString factoryDescription() { return tr( "Polygon does not follow boundaries" ); }
QString description() const override { return factoryDescription(); }
static QString factoryId() { return QStringLiteral( "QgsGeometryFollowBoundariesCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
private:
enum ResolutionMethod { NoChange };
QgsVectorLayer *mCheckLayer;
QgsSpatialIndex *mIndex = nullptr;
QgsGeometryFollowBoundariesCheck( const QgsGeometryFollowBoundariesCheck & ) = delete;
QgsGeometryFollowBoundariesCheck &operator=( const QgsGeometryFollowBoundariesCheck & ) = delete;
};
#endif // QGSGEOMETRYFOLLOWBOUNDARIESCHECK_H
| pblottiere/QGIS | src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h | C | gpl-2.0 | 3,227 |
/*
* Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com>
*
* 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.
*
* 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 <drm/drm_crtc.h>
#include <drm/drm_probe_helper.h>
#include "mdp4_kms.h"
struct mdp4_dtv_encoder {
struct drm_encoder base;
struct clk *hdmi_clk;
struct clk *mdp_clk;
unsigned long int pixclock;
bool enabled;
uint32_t bsc;
};
#define to_mdp4_dtv_encoder(x) container_of(x, struct mdp4_dtv_encoder, base)
static struct mdp4_kms *get_kms(struct drm_encoder *encoder)
{
struct msm_drm_private *priv = encoder->dev->dev_private;
return to_mdp4_kms(to_mdp_kms(priv->kms));
}
#ifdef DOWNSTREAM_CONFIG_MSM_BUS_SCALING
#include <mach/board.h>
/* not ironically named at all.. no, really.. */
static void bs_init(struct mdp4_dtv_encoder *mdp4_dtv_encoder)
{
struct drm_device *dev = mdp4_dtv_encoder->base.dev;
struct lcdc_platform_data *dtv_pdata = mdp4_find_pdata("dtv.0");
if (!dtv_pdata) {
DRM_DEV_ERROR(dev->dev, "could not find dtv pdata\n");
return;
}
if (dtv_pdata->bus_scale_table) {
mdp4_dtv_encoder->bsc = msm_bus_scale_register_client(
dtv_pdata->bus_scale_table);
DBG("bus scale client: %08x", mdp4_dtv_encoder->bsc);
DBG("lcdc_power_save: %p", dtv_pdata->lcdc_power_save);
if (dtv_pdata->lcdc_power_save)
dtv_pdata->lcdc_power_save(1);
}
}
static void bs_fini(struct mdp4_dtv_encoder *mdp4_dtv_encoder)
{
if (mdp4_dtv_encoder->bsc) {
msm_bus_scale_unregister_client(mdp4_dtv_encoder->bsc);
mdp4_dtv_encoder->bsc = 0;
}
}
static void bs_set(struct mdp4_dtv_encoder *mdp4_dtv_encoder, int idx)
{
if (mdp4_dtv_encoder->bsc) {
DBG("set bus scaling: %d", idx);
msm_bus_scale_client_update_request(mdp4_dtv_encoder->bsc, idx);
}
}
#else
static void bs_init(struct mdp4_dtv_encoder *mdp4_dtv_encoder) {}
static void bs_fini(struct mdp4_dtv_encoder *mdp4_dtv_encoder) {}
static void bs_set(struct mdp4_dtv_encoder *mdp4_dtv_encoder, int idx) {}
#endif
static void mdp4_dtv_encoder_destroy(struct drm_encoder *encoder)
{
struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
bs_fini(mdp4_dtv_encoder);
drm_encoder_cleanup(encoder);
kfree(mdp4_dtv_encoder);
}
static const struct drm_encoder_funcs mdp4_dtv_encoder_funcs = {
.destroy = mdp4_dtv_encoder_destroy,
};
static void mdp4_dtv_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
struct mdp4_kms *mdp4_kms = get_kms(encoder);
uint32_t dtv_hsync_skew, vsync_period, vsync_len, ctrl_pol;
uint32_t display_v_start, display_v_end;
uint32_t hsync_start_x, hsync_end_x;
mode = adjusted_mode;
DBG("set mode: " DRM_MODE_FMT, DRM_MODE_ARG(mode));
mdp4_dtv_encoder->pixclock = mode->clock * 1000;
DBG("pixclock=%lu", mdp4_dtv_encoder->pixclock);
ctrl_pol = 0;
if (mode->flags & DRM_MODE_FLAG_NHSYNC)
ctrl_pol |= MDP4_DTV_CTRL_POLARITY_HSYNC_LOW;
if (mode->flags & DRM_MODE_FLAG_NVSYNC)
ctrl_pol |= MDP4_DTV_CTRL_POLARITY_VSYNC_LOW;
/* probably need to get DATA_EN polarity from panel.. */
dtv_hsync_skew = 0; /* get this from panel? */
hsync_start_x = (mode->htotal - mode->hsync_start);
hsync_end_x = mode->htotal - (mode->hsync_start - mode->hdisplay) - 1;
vsync_period = mode->vtotal * mode->htotal;
vsync_len = (mode->vsync_end - mode->vsync_start) * mode->htotal;
display_v_start = (mode->vtotal - mode->vsync_start) * mode->htotal + dtv_hsync_skew;
display_v_end = vsync_period - ((mode->vsync_start - mode->vdisplay) * mode->htotal) + dtv_hsync_skew - 1;
mdp4_write(mdp4_kms, REG_MDP4_DTV_HSYNC_CTRL,
MDP4_DTV_HSYNC_CTRL_PULSEW(mode->hsync_end - mode->hsync_start) |
MDP4_DTV_HSYNC_CTRL_PERIOD(mode->htotal));
mdp4_write(mdp4_kms, REG_MDP4_DTV_VSYNC_PERIOD, vsync_period);
mdp4_write(mdp4_kms, REG_MDP4_DTV_VSYNC_LEN, vsync_len);
mdp4_write(mdp4_kms, REG_MDP4_DTV_DISPLAY_HCTRL,
MDP4_DTV_DISPLAY_HCTRL_START(hsync_start_x) |
MDP4_DTV_DISPLAY_HCTRL_END(hsync_end_x));
mdp4_write(mdp4_kms, REG_MDP4_DTV_DISPLAY_VSTART, display_v_start);
mdp4_write(mdp4_kms, REG_MDP4_DTV_DISPLAY_VEND, display_v_end);
mdp4_write(mdp4_kms, REG_MDP4_DTV_BORDER_CLR, 0);
mdp4_write(mdp4_kms, REG_MDP4_DTV_UNDERFLOW_CLR,
MDP4_DTV_UNDERFLOW_CLR_ENABLE_RECOVERY |
MDP4_DTV_UNDERFLOW_CLR_COLOR(0xff));
mdp4_write(mdp4_kms, REG_MDP4_DTV_HSYNC_SKEW, dtv_hsync_skew);
mdp4_write(mdp4_kms, REG_MDP4_DTV_CTRL_POLARITY, ctrl_pol);
mdp4_write(mdp4_kms, REG_MDP4_DTV_ACTIVE_HCTL,
MDP4_DTV_ACTIVE_HCTL_START(0) |
MDP4_DTV_ACTIVE_HCTL_END(0));
mdp4_write(mdp4_kms, REG_MDP4_DTV_ACTIVE_VSTART, 0);
mdp4_write(mdp4_kms, REG_MDP4_DTV_ACTIVE_VEND, 0);
}
static void mdp4_dtv_encoder_disable(struct drm_encoder *encoder)
{
struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
struct mdp4_kms *mdp4_kms = get_kms(encoder);
if (WARN_ON(!mdp4_dtv_encoder->enabled))
return;
mdp4_write(mdp4_kms, REG_MDP4_DTV_ENABLE, 0);
/*
* Wait for a vsync so we know the ENABLE=0 latched before
* the (connector) source of the vsync's gets disabled,
* otherwise we end up in a funny state if we re-enable
* before the disable latches, which results that some of
* the settings changes for the new modeset (like new
* scanout buffer) don't latch properly..
*/
mdp_irq_wait(&mdp4_kms->base, MDP4_IRQ_EXTERNAL_VSYNC);
clk_disable_unprepare(mdp4_dtv_encoder->hdmi_clk);
clk_disable_unprepare(mdp4_dtv_encoder->mdp_clk);
bs_set(mdp4_dtv_encoder, 0);
mdp4_dtv_encoder->enabled = false;
}
static void mdp4_dtv_encoder_enable(struct drm_encoder *encoder)
{
struct drm_device *dev = encoder->dev;
struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
struct mdp4_kms *mdp4_kms = get_kms(encoder);
unsigned long pc = mdp4_dtv_encoder->pixclock;
int ret;
if (WARN_ON(mdp4_dtv_encoder->enabled))
return;
mdp4_crtc_set_config(encoder->crtc,
MDP4_DMA_CONFIG_R_BPC(BPC8) |
MDP4_DMA_CONFIG_G_BPC(BPC8) |
MDP4_DMA_CONFIG_B_BPC(BPC8) |
MDP4_DMA_CONFIG_PACK(0x21));
mdp4_crtc_set_intf(encoder->crtc, INTF_LCDC_DTV, 1);
bs_set(mdp4_dtv_encoder, 1);
DBG("setting mdp_clk=%lu", pc);
ret = clk_set_rate(mdp4_dtv_encoder->mdp_clk, pc);
if (ret)
DRM_DEV_ERROR(dev->dev, "failed to set mdp_clk to %lu: %d\n",
pc, ret);
ret = clk_prepare_enable(mdp4_dtv_encoder->mdp_clk);
if (ret)
DRM_DEV_ERROR(dev->dev, "failed to enabled mdp_clk: %d\n", ret);
ret = clk_prepare_enable(mdp4_dtv_encoder->hdmi_clk);
if (ret)
DRM_DEV_ERROR(dev->dev, "failed to enable hdmi_clk: %d\n", ret);
mdp4_write(mdp4_kms, REG_MDP4_DTV_ENABLE, 1);
mdp4_dtv_encoder->enabled = true;
}
static const struct drm_encoder_helper_funcs mdp4_dtv_encoder_helper_funcs = {
.mode_set = mdp4_dtv_encoder_mode_set,
.enable = mdp4_dtv_encoder_enable,
.disable = mdp4_dtv_encoder_disable,
};
long mdp4_dtv_round_pixclk(struct drm_encoder *encoder, unsigned long rate)
{
struct mdp4_dtv_encoder *mdp4_dtv_encoder = to_mdp4_dtv_encoder(encoder);
return clk_round_rate(mdp4_dtv_encoder->mdp_clk, rate);
}
/* initialize encoder */
struct drm_encoder *mdp4_dtv_encoder_init(struct drm_device *dev)
{
struct drm_encoder *encoder = NULL;
struct mdp4_dtv_encoder *mdp4_dtv_encoder;
int ret;
mdp4_dtv_encoder = kzalloc(sizeof(*mdp4_dtv_encoder), GFP_KERNEL);
if (!mdp4_dtv_encoder) {
ret = -ENOMEM;
goto fail;
}
encoder = &mdp4_dtv_encoder->base;
drm_encoder_init(dev, encoder, &mdp4_dtv_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
drm_encoder_helper_add(encoder, &mdp4_dtv_encoder_helper_funcs);
mdp4_dtv_encoder->hdmi_clk = devm_clk_get(dev->dev, "hdmi_clk");
if (IS_ERR(mdp4_dtv_encoder->hdmi_clk)) {
DRM_DEV_ERROR(dev->dev, "failed to get hdmi_clk\n");
ret = PTR_ERR(mdp4_dtv_encoder->hdmi_clk);
goto fail;
}
mdp4_dtv_encoder->mdp_clk = devm_clk_get(dev->dev, "tv_clk");
if (IS_ERR(mdp4_dtv_encoder->mdp_clk)) {
DRM_DEV_ERROR(dev->dev, "failed to get tv_clk\n");
ret = PTR_ERR(mdp4_dtv_encoder->mdp_clk);
goto fail;
}
bs_init(mdp4_dtv_encoder);
return encoder;
fail:
if (encoder)
mdp4_dtv_encoder_destroy(encoder);
return ERR_PTR(ret);
}
| Taeung/tip | drivers/gpu/drm/msm/disp/mdp4/mdp4_dtv_encoder.c | C | gpl-2.0 | 8,711 |
---------------------------------------------------
-- Mighty Strikes
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:getMobMod(MOBMOD_SCRIPTED_2HOUR) == 1) then
return 0;
elseif (mob:getHPP() <= mob:getMobMod(MOBMOD_2HOUR_PROC)) then
return 0;
end
return 1;
end;
function onMobWeaponSkill(target, mob, skill)
local typeEffect = EFFECT_MIGHTY_STRIKES;
local duration = 45;
if (skill:getParam() ~= 0 and mob:getMobMod(MOBMOD_SCRIPTED_2HOUR) == 1) then
duration = skill:getParam();
end
MobBuffMove(mob, typeEffect, 1, 0, duration);
skill:setMsg(MSG_USES);
return typeEffect;
end;
| bmscoordinators/FFXI-Server | scripts/globals/mobskills/mighty_strikes.lua | Lua | gpl-3.0 | 874 |
package com.hitherejoe.module_test_only.injection.component;
import com.hitherejoe.androidboilerplate.injection.component.ApplicationComponent;
import com.hitherejoe.module_test_only.injection.module.ApplicationTestModule;
import javax.inject.Singleton;
import dagger.Component;
@Singleton
@Component(modules = ApplicationTestModule.class)
public interface TestComponent extends ApplicationComponent {
} | tsdl2013/Android-Boilerplate | module-test-only/src/main/java/com/hitherejoe/module_test_only/injection/component/TestComponent.java | Java | gpl-3.0 | 408 |
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 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/>.
Class
Foam::cyclicAMIFvPatchField
Group
grpCoupledBoundaryConditions
Description
This boundary condition enforces a cyclic condition between a pair of
boundaries, whereby communication between the patches is performed using
an arbitrary mesh interface (AMI) interpolation.
\heading Patch usage
Example of the boundary condition specification:
\verbatim
myPatch
{
type cyclicAMI;
}
\endverbatim
Note
The outer boundary of the patch pairs must be similar, i.e. if the owner
patch is transformed to the neighbour patch, the outer perimiter of each
patch should be identical (or very similar).
SeeAlso
Foam::AMIInterpolation
SourceFiles
cyclicAMIFvPatchField.C
\*---------------------------------------------------------------------------*/
#ifndef cyclicAMIFvPatchField_H
#define cyclicAMIFvPatchField_H
#include "coupledFvPatchField.H"
#include "cyclicAMILduInterfaceField.H"
#include "cyclicAMIFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cyclicAMIFvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class cyclicAMIFvPatchField
:
virtual public cyclicAMILduInterfaceField,
public coupledFvPatchField<Type>
{
// Private data
//- Local reference cast into the cyclic patch
const cyclicAMIFvPatch& cyclicAMIPatch_;
// Private Member Functions
//- Return neighbour side field given internal fields
template<class Type2>
tmp<Field<Type2> > neighbourSideField
(
const Field<Type2>&
) const;
public:
//- Runtime type information
TypeName(cyclicAMIFvPatch::typeName_());
// Constructors
//- Construct from patch and internal field
cyclicAMIFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&
);
//- Construct from patch, internal field and dictionary
cyclicAMIFvPatchField
(
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const dictionary&
);
//- Construct by mapping given cyclicAMIFvPatchField onto a new patch
cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>&,
const fvPatch&,
const DimensionedField<Type, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
cyclicAMIFvPatchField(const cyclicAMIFvPatchField<Type>&);
//- Construct and return a clone
virtual tmp<fvPatchField<Type> > clone() const
{
return tmp<fvPatchField<Type> >
(
new cyclicAMIFvPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
cyclicAMIFvPatchField
(
const cyclicAMIFvPatchField<Type>&,
const DimensionedField<Type, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchField<Type> > clone
(
const DimensionedField<Type, volMesh>& iF
) const
{
return tmp<fvPatchField<Type> >
(
new cyclicAMIFvPatchField<Type>(*this, iF)
);
}
// Member functions
// Access
//- Return local reference cast into the cyclic AMI patch
const cyclicAMIFvPatch& cyclicAMIPatch() const
{
return cyclicAMIPatch_;
}
// Evaluation functions
//- Return true if coupled. Note that the underlying patch
// is not coupled() - the points don't align.
virtual bool coupled() const;
//- Return neighbour coupled internal cell data
virtual tmp<Field<Type> > patchNeighbourField() const;
//- Return reference to neighbour patchField
const cyclicAMIFvPatchField<Type>& neighbourPatchField() const;
//- Update result field based on interface functionality
virtual void updateInterfaceMatrix
(
scalarField& result,
const scalarField& psiInternal,
const scalarField& coeffs,
const direction cmpt,
const Pstream::commsTypes commsType
) const;
//- Update result field based on interface functionality
virtual void updateInterfaceMatrix
(
Field<Type>&,
const Field<Type>&,
const scalarField&,
const Pstream::commsTypes commsType
) const;
// Cyclic AMI coupled interface functions
//- Does the patch field perform the transformation
virtual bool doTransform() const
{
return
!(cyclicAMIPatch_.parallel() || pTraits<Type>::rank == 0);
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return cyclicAMIPatch_.forwardT();
}
//- Return neighbour-cell transformation tensor
virtual const tensorField& reverseT() const
{
return cyclicAMIPatch_.reverseT();
}
//- Return rank of component for transform
virtual int rank() const
{
return pTraits<Type>::rank;
}
// I-O
//- Write
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "cyclicAMIFvPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| adrcad/OpenFOAM-2.3.x | src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H | C++ | gpl-3.0 | 7,365 |
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Loader;
/**
* @copyright Copyright (c) 2010, Union of RAD http://union-of-rad.org (http://lithify.me/)
* @copyright Copyright (c) 2012, Clemens Tolboom
*/
class PoFileLoader extends FileLoader
{
/**
* Parses portable object (PO) format.
*
* From http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files
* we should be able to parse files having:
*
* white-space
* # translator-comments
* #. extracted-comments
* #: reference...
* #, flag...
* #| msgid previous-untranslated-string
* msgid untranslated-string
* msgstr translated-string
*
* extra or different lines are:
*
* #| msgctxt previous-context
* #| msgid previous-untranslated-string
* msgctxt context
*
* #| msgid previous-untranslated-string-singular
* #| msgid_plural previous-untranslated-string-plural
* msgid untranslated-string-singular
* msgid_plural untranslated-string-plural
* msgstr[0] translated-string-case-0
* ...
* msgstr[N] translated-string-case-n
*
* The definition states:
* - white-space and comments are optional.
* - msgid "" that an empty singleline defines a header.
*
* This parser sacrifices some features of the reference implementation the
* differences to that implementation are as follows.
* - No support for comments spanning multiple lines.
* - Translator and extracted comments are treated as being the same type.
* - Message IDs are allowed to have other encodings as just US-ASCII.
*
* Items with an empty id are ignored.
*
* {@inheritdoc}
*/
protected function loadResource($resource)
{
$stream = fopen($resource, 'r');
$defaults = array(
'ids' => array(),
'translated' => null,
);
$messages = array();
$item = $defaults;
$flags = array();
while ($line = fgets($stream)) {
$line = trim($line);
if ('' === $line) {
// Whitespace indicated current item is done
if (!in_array('fuzzy', $flags)) {
$this->addMessage($messages, $item);
}
$item = $defaults;
$flags = array();
} elseif ('#,' === substr($line, 0, 2)) {
$flags = array_map('trim', explode(',', substr($line, 2)));
} elseif ('msgid "' === substr($line, 0, 7)) {
// We start a new msg so save previous
// TODO: this fails when comments or contexts are added
$this->addMessage($messages, $item);
$item = $defaults;
$item['ids']['singular'] = substr($line, 7, -1);
} elseif ('msgstr "' === substr($line, 0, 8)) {
$item['translated'] = substr($line, 8, -1);
} elseif ('"' === $line[0]) {
$continues = isset($item['translated']) ? 'translated' : 'ids';
if (is_array($item[$continues])) {
end($item[$continues]);
$item[$continues][key($item[$continues])] .= substr($line, 1, -1);
} else {
$item[$continues] .= substr($line, 1, -1);
}
} elseif ('msgid_plural "' === substr($line, 0, 14)) {
$item['ids']['plural'] = substr($line, 14, -1);
} elseif ('msgstr[' === substr($line, 0, 7)) {
$size = strpos($line, ']');
$item['translated'][(int) substr($line, 7, 1)] = substr($line, $size + 3, -1);
}
}
// save last item
if (!in_array('fuzzy', $flags)) {
$this->addMessage($messages, $item);
}
fclose($stream);
return $messages;
}
/**
* Save a translation item to the messages.
*
* A .po file could contain by error missing plural indexes. We need to
* fix these before saving them.
*
* @param array $messages
* @param array $item
*/
private function addMessage(array &$messages, array $item)
{
if (is_array($item['translated'])) {
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated'][0]);
if (isset($item['ids']['plural'])) {
$plurals = $item['translated'];
// PO are by definition indexed so sort by index.
ksort($plurals);
// Make sure every index is filled.
end($plurals);
$count = key($plurals);
// Fill missing spots with '-'.
$empties = array_fill(0, $count + 1, '-');
$plurals += $empties;
ksort($plurals);
$messages[stripcslashes($item['ids']['plural'])] = stripcslashes(implode('|', $plurals));
}
} elseif (!empty($item['ids']['singular'])) {
$messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']);
}
}
}
| kethxenn/C.B.U.L.M.S. | vendor/symfony/translation/Loader/PoFileLoader.php | PHP | gpl-3.0 | 5,380 |
#!/usr/bin/env bash
set -e
############################################################################
#
# find-dead-code.sh
#
# This script analyzes the edx-platform for dead code instances using
# vulture, a static analysis tool that ranks potential unused code using
# the following confidence scores:
# - 100% = completely unreachable code: code that follows return, continue
# or raise statements, or code that cannot logically be run, i.e.
# a condition that can never be True
# - 90% = unused imports within a file
# - 60% = unused code: code that has no reference in the code base, aside
# from definition
#
# This script will output a list of dead-code instances with their
# confidence scores, in descending order of the size of the instance
# (in lines). This in turn can be used to clean up the edx-platform.
# However, you shouldn't automatically delete code reported back from
# vulture. It can report false positives. Often it's not the case that
# code is truly dead, but has been referenced incorrectly (spelling)
# elsewhere in the code base, most likely in a refactor. Another example
# of code that will be interpreted as dead by vulture is anything that
# is used in a template (which is not considered in the analysis).
#
# Therefore, the results of this script should be used as a jumping off
# point for investigating potential dead code removal
#
############################################################################
OUTPUT_DIR="reports/vulture"
mkdir -p ${OUTPUT_DIR}
OUTPUT_FILE=${OUTPUT_DIR}/vulture-report.txt
echo '' > $OUTPUT_FILE
# exclude test code from analysis, as it isn't explicitly called by other
# code. Additionally, application code that is only called by tests
# should be considered dead
EXCLUSIONS='/test,/acceptance,cms/envs,lms/envs,/terrain,migrations/,signals.py'
MIN_CONFIDENCE=90
# paths to the code on which to run the analysis
CODE_PATHS='cms common lms openedx'
WHITELIST_PATH="$(dirname "${BASH_SOURCE[0]}")/whitelist.py"
echo "Checking for dead code in the following paths: $CODE_PATHS"
echo "Results can be found in $OUTPUT_FILE"
vulture $CODE_PATHS $WHITELIST_PATH --exclude $EXCLUSIONS \
--min-confidence $MIN_CONFIDENCE \
--sort-by-size |tac > $OUTPUT_FILE
| kmoocdev2/edx-platform | scripts/vulture/find-dead-code.sh | Shell | agpl-3.0 | 2,257 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.