text
stringlengths 2
100k
| meta
dict |
---|---|
fileFormatVersion: 2
guid: 2e1ddfe69a7e04f4a8c3588b38c44cfe
folderAsset: yes
timeCreated: 1428753050
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
# Processes - Elixir's Unit of Concurrency
Elixir processes are fast and lightweight units of concurrency. Not to be confused with OS processes, millions of them can be spawned on a single machine, and each are managed entirely by the Erlang VM. Processes live at the core of Elixir application architectures and can send and receive messages to other processes located locally, or remotely on another connected Node.
### spawn
Spawn creates a new process and returns the Pid, or Process ID of the new process. Messages are sent to the processes using the `send/2` function.
### Mailboxes
Processes all contain a *mailbox* where messages are passively kept until consumed via a `receive` block. `receive` processes message in the order received and allows messages to be pattern matched. A common pattern is to send a message to a process with a tuple containing `self` as the first element. This allows the receiving process to have a reference to message's "sender" and respond back to the sender Pid with its own response messages.
```elixir
pid = spawn fn ->
receive do
{sender, :ping} ->
IO.puts "Got ping"
send sender, :pong
end
end
send pid, {self, :ping}
# Got ping
receive do
message -> IO.puts "Got #{message} back"
end
# Got pong back
```
`receive` blocks the current process until a message is received that matches a message clause. An `after` clause can optionally be provided to exit the receive loop if no messages are receive after a set amount of time.
```elixir
receive do
message -> IO.inspect message
after 5000 ->
IO.puts "Timeout, giving up"
end
```
Results in...
```elixir
# Timeout, giving up
```
## spawn_link
Similar to `spawn`, `spawn_link` creates a new process, but links the current and new process so that if one crashes, both processes terminate. Linking processes is essential to the Elixir and Erlang philosophy of letting programs crash instead of trying to rescue from errors. Since Elixir programs exist as a hierarchy of many processes, linking allows a predictable process dependency tree where failures in one process cascade down to all other dependent processes.
```elixir
pid = spawn_link fn ->
receive do
:boom -> raise "boom!"
end
end
send pid, :boom
```
Results in...
```elixir
=ERROR REPORT==== 27-Dec-2013::16:49:14 ===
Error in process <0.64.0> with exit value: {{'Elixir.RuntimeError','__exception__',<<5 bytes>>},[{erlang,apply,2,[]}]}
** (EXIT from #PID<0.64.0>) {RuntimeError[message: "boom!"], [{:erlang, :apply, 2, []}]}
```
```elixir
pid = spawn fn ->
receive do
:boom -> raise "boom!"
end
end
send pid, :boom
```
Results in...
```elixir
=ERROR REPORT==== 27-Dec-2013::16:49:50 ===
Error in process <0.71.0> with exit value: {{'Elixir.RuntimeError','__exception__',<<5 bytes>>},[{erlang,apply,2,[]}]}
iex(5)>
```
The first example above using `spawn_link`, we see the process termination cascade to our own iex session from the `** (EXIT from #PID<0.64.0>)` error. Our iex session stays alive because it is internally restarted by a process Supervisor. Supervisors are covered in the next section on OTP.
## Holding State
Since Elixir is immutable, you may be wondering how state is held. Holding and mutating state can be performed by spawning a process that exposes its state via messages and infinitely recurses on itself with its current state. For example:
```elixir
defmodule Counter do
def start(initial_count) do
spawn fn -> listen(initial_count) end
end
def listen(count) do
receive do
:inc -> listen(count + 1)
{sender, :val} ->
send sender, count
listen(count)
end
end
end
{:module, Counter,...
iex(8)> counter_pid = Counter.start(10)
#PID<0.140.0>
iex(9)> send counter_pid, :inc
:inc
iex(10)> send counter_pid, :inc
:inc
iex(11)> send counter_pid, :inc
:inc
iex(12)> send counter_pid, {self, :val}
{#PID<0.40.0>, :val}
iex(13)> receive do
...(13)> value -> value
...(13)> end
13
```
## Registered Processes
Pids can be registered under a name for easy lookup by other processes
```elixir
iex(26)> pid = Counter.start 10
iex(27)> Process.register pid, :count
true
iex(28)> Process.whereis(:count) == pid
true
iex(29)> send :count, :inc
:inc
iex(30)> receive do
...(30)> value -> value
...(30)> end
11
```
| {
"pile_set_name": "Github"
} |
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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.
//
// Author: [email protected] (Keir Mierle)
// [email protected] (Sameer Agarwal)
//
// Templated functions for manipulating rotations. The templated
// functions are useful when implementing functors for automatic
// differentiation.
//
// In the following, the Quaternions are laid out as 4-vectors, thus:
//
// q[0] scalar part.
// q[1] coefficient of i.
// q[2] coefficient of j.
// q[3] coefficient of k.
//
// where: i*i = j*j = k*k = -1 and i*j = k, j*k = i, k*i = j.
#ifndef CERES_PUBLIC_ROTATION_H_
#define CERES_PUBLIC_ROTATION_H_
#include <algorithm>
#include <cmath>
#include <limits>
namespace ceres {
// Trivial wrapper to index linear arrays as matrices, given a fixed
// column and row stride. When an array "T* array" is wrapped by a
//
// (const) MatrixAdapter<T, row_stride, col_stride> M"
//
// the expression M(i, j) is equivalent to
//
// arrary[i * row_stride + j * col_stride]
//
// Conversion functions to and from rotation matrices accept
// MatrixAdapters to permit using row-major and column-major layouts,
// and rotation matrices embedded in larger matrices (such as a 3x4
// projection matrix).
template <typename T, int row_stride, int col_stride>
struct MatrixAdapter;
// Convenience functions to create a MatrixAdapter that treats the
// array pointed to by "pointer" as a 3x3 (contiguous) column-major or
// row-major matrix.
template <typename T>
MatrixAdapter<T, 1, 3> ColumnMajorAdapter3x3(T* pointer);
template <typename T>
MatrixAdapter<T, 3, 1> RowMajorAdapter3x3(T* pointer);
// Convert a value in combined axis-angle representation to a quaternion.
// The value angle_axis is a triple whose norm is an angle in radians,
// and whose direction is aligned with the axis of rotation,
// and quaternion is a 4-tuple that will contain the resulting quaternion.
// The implementation may be used with auto-differentiation up to the first
// derivative, higher derivatives may have unexpected results near the origin.
template<typename T>
void AngleAxisToQuaternion(const T* angle_axis, T* quaternion);
// Convert a quaternion to the equivalent combined axis-angle representation.
// The value quaternion must be a unit quaternion - it is not normalized first,
// and angle_axis will be filled with a value whose norm is the angle of
// rotation in radians, and whose direction is the axis of rotation.
// The implementation may be used with auto-differentiation up to the first
// derivative, higher derivatives may have unexpected results near the origin.
template<typename T>
void QuaternionToAngleAxis(const T* quaternion, T* angle_axis);
// Conversions between 3x3 rotation matrix (in column major order) and
// quaternion rotation representations. Templated for use with
// autodifferentiation.
template <typename T>
void RotationMatrixToQuaternion(const T* R, T* quaternion);
template <typename T, int row_stride, int col_stride>
void RotationMatrixToQuaternion(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* quaternion);
// Conversions between 3x3 rotation matrix (in column major order) and
// axis-angle rotation representations. Templated for use with
// autodifferentiation.
template <typename T>
void RotationMatrixToAngleAxis(const T* R, T* angle_axis);
template <typename T, int row_stride, int col_stride>
void RotationMatrixToAngleAxis(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* angle_axis);
template <typename T>
void AngleAxisToRotationMatrix(const T* angle_axis, T* R);
template <typename T, int row_stride, int col_stride>
void AngleAxisToRotationMatrix(
const T* angle_axis,
const MatrixAdapter<T, row_stride, col_stride>& R);
// Conversions between 3x3 rotation matrix (in row major order) and
// Euler angle (in degrees) rotation representations.
//
// The {pitch,roll,yaw} Euler angles are rotations around the {x,y,z}
// axes, respectively. They are applied in that same order, so the
// total rotation R is Rz * Ry * Rx.
template <typename T>
void EulerAnglesToRotationMatrix(const T* euler, int row_stride, T* R);
template <typename T, int row_stride, int col_stride>
void EulerAnglesToRotationMatrix(
const T* euler,
const MatrixAdapter<T, row_stride, col_stride>& R);
// Convert a 4-vector to a 3x3 scaled rotation matrix.
//
// The choice of rotation is such that the quaternion [1 0 0 0] goes to an
// identity matrix and for small a, b, c the quaternion [1 a b c] goes to
// the matrix
//
// [ 0 -c b ]
// I + 2 [ c 0 -a ] + higher order terms
// [ -b a 0 ]
//
// which corresponds to a Rodrigues approximation, the last matrix being
// the cross-product matrix of [a b c]. Together with the property that
// R(q1 * q2) = R(q1) * R(q2) this uniquely defines the mapping from q to R.
//
// No normalization of the quaternion is performed, i.e.
// R = ||q||^2 * Q, where Q is an orthonormal matrix
// such that det(Q) = 1 and Q*Q' = I
//
// WARNING: The rotation matrix is ROW MAJOR
template <typename T> inline
void QuaternionToScaledRotation(const T q[4], T R[3 * 3]);
template <typename T, int row_stride, int col_stride> inline
void QuaternionToScaledRotation(
const T q[4],
const MatrixAdapter<T, row_stride, col_stride>& R);
// Same as above except that the rotation matrix is normalized by the
// Frobenius norm, so that R * R' = I (and det(R) = 1).
//
// WARNING: The rotation matrix is ROW MAJOR
template <typename T> inline
void QuaternionToRotation(const T q[4], T R[3 * 3]);
template <typename T, int row_stride, int col_stride> inline
void QuaternionToRotation(
const T q[4],
const MatrixAdapter<T, row_stride, col_stride>& R);
// Rotates a point pt by a quaternion q:
//
// result = R(q) * pt
//
// Assumes the quaternion is unit norm. This assumption allows us to
// write the transform as (something)*pt + pt, as is clear from the
// formula below. If you pass in a quaternion with |q|^2 = 2 then you
// WILL NOT get back 2 times the result you get for a unit quaternion.
template <typename T> inline
void UnitQuaternionRotatePoint(const T q[4], const T pt[3], T result[3]);
// With this function you do not need to assume that q has unit norm.
// It does assume that the norm is non-zero.
template <typename T> inline
void QuaternionRotatePoint(const T q[4], const T pt[3], T result[3]);
// zw = z * w, where * is the Quaternion product between 4 vectors.
template<typename T> inline
void QuaternionProduct(const T z[4], const T w[4], T zw[4]);
// xy = x cross y;
template<typename T> inline
void CrossProduct(const T x[3], const T y[3], T x_cross_y[3]);
template<typename T> inline
T DotProduct(const T x[3], const T y[3]);
// y = R(angle_axis) * x;
template<typename T> inline
void AngleAxisRotatePoint(const T angle_axis[3], const T pt[3], T result[3]);
// --- IMPLEMENTATION
template<typename T, int row_stride, int col_stride>
struct MatrixAdapter {
T* pointer_;
explicit MatrixAdapter(T* pointer)
: pointer_(pointer)
{}
T& operator()(int r, int c) const {
return pointer_[r * row_stride + c * col_stride];
}
};
template <typename T>
MatrixAdapter<T, 1, 3> ColumnMajorAdapter3x3(T* pointer) {
return MatrixAdapter<T, 1, 3>(pointer);
}
template <typename T>
MatrixAdapter<T, 3, 1> RowMajorAdapter3x3(T* pointer) {
return MatrixAdapter<T, 3, 1>(pointer);
}
template<typename T>
inline void AngleAxisToQuaternion(const T* angle_axis, T* quaternion) {
const T& a0 = angle_axis[0];
const T& a1 = angle_axis[1];
const T& a2 = angle_axis[2];
const T theta_squared = a0 * a0 + a1 * a1 + a2 * a2;
// For points not at the origin, the full conversion is numerically stable.
if (theta_squared > T(0.0)) {
const T theta = sqrt(theta_squared);
const T half_theta = theta * T(0.5);
const T k = sin(half_theta) / theta;
quaternion[0] = cos(half_theta);
quaternion[1] = a0 * k;
quaternion[2] = a1 * k;
quaternion[3] = a2 * k;
} else {
// At the origin, sqrt() will produce NaN in the derivative since
// the argument is zero. By approximating with a Taylor series,
// and truncating at one term, the value and first derivatives will be
// computed correctly when Jets are used.
const T k(0.5);
quaternion[0] = T(1.0);
quaternion[1] = a0 * k;
quaternion[2] = a1 * k;
quaternion[3] = a2 * k;
}
}
template<typename T>
inline void QuaternionToAngleAxis(const T* quaternion, T* angle_axis) {
const T& q1 = quaternion[1];
const T& q2 = quaternion[2];
const T& q3 = quaternion[3];
const T sin_squared_theta = q1 * q1 + q2 * q2 + q3 * q3;
// For quaternions representing non-zero rotation, the conversion
// is numerically stable.
if (sin_squared_theta > T(0.0)) {
const T sin_theta = sqrt(sin_squared_theta);
const T& cos_theta = quaternion[0];
// If cos_theta is negative, theta is greater than pi/2, which
// means that angle for the angle_axis vector which is 2 * theta
// would be greater than pi.
//
// While this will result in the correct rotation, it does not
// result in a normalized angle-axis vector.
//
// In that case we observe that 2 * theta ~ 2 * theta - 2 * pi,
// which is equivalent saying
//
// theta - pi = atan(sin(theta - pi), cos(theta - pi))
// = atan(-sin(theta), -cos(theta))
//
const T two_theta =
T(2.0) * ((cos_theta < 0.0)
? atan2(-sin_theta, -cos_theta)
: atan2(sin_theta, cos_theta));
const T k = two_theta / sin_theta;
angle_axis[0] = q1 * k;
angle_axis[1] = q2 * k;
angle_axis[2] = q3 * k;
} else {
// For zero rotation, sqrt() will produce NaN in the derivative since
// the argument is zero. By approximating with a Taylor series,
// and truncating at one term, the value and first derivatives will be
// computed correctly when Jets are used.
const T k(2.0);
angle_axis[0] = q1 * k;
angle_axis[1] = q2 * k;
angle_axis[2] = q3 * k;
}
}
template <typename T>
void RotationMatrixToQuaternion(const T* R, T* angle_axis) {
RotationMatrixToQuaternion(ColumnMajorAdapter3x3(R), angle_axis);
}
// This algorithm comes from "Quaternion Calculus and Fast Animation",
// Ken Shoemake, 1987 SIGGRAPH course notes
template <typename T, int row_stride, int col_stride>
void RotationMatrixToQuaternion(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* quaternion) {
const T trace = R(0, 0) + R(1, 1) + R(2, 2);
if (trace >= 0.0) {
T t = sqrt(trace + T(1.0));
quaternion[0] = T(0.5) * t;
t = T(0.5) / t;
quaternion[1] = (R(2, 1) - R(1, 2)) * t;
quaternion[2] = (R(0, 2) - R(2, 0)) * t;
quaternion[3] = (R(1, 0) - R(0, 1)) * t;
} else {
int i = 0;
if (R(1, 1) > R(0, 0)) {
i = 1;
}
if (R(2, 2) > R(i, i)) {
i = 2;
}
const int j = (i + 1) % 3;
const int k = (j + 1) % 3;
T t = sqrt(R(i, i) - R(j, j) - R(k, k) + T(1.0));
quaternion[i + 1] = T(0.5) * t;
t = T(0.5) / t;
quaternion[0] = (R(k, j) - R(j, k)) * t;
quaternion[j + 1] = (R(j, i) + R(i, j)) * t;
quaternion[k + 1] = (R(k, i) + R(i, k)) * t;
}
}
// The conversion of a rotation matrix to the angle-axis form is
// numerically problematic when then rotation angle is close to zero
// or to Pi. The following implementation detects when these two cases
// occurs and deals with them by taking code paths that are guaranteed
// to not perform division by a small number.
template <typename T>
inline void RotationMatrixToAngleAxis(const T* R, T* angle_axis) {
RotationMatrixToAngleAxis(ColumnMajorAdapter3x3(R), angle_axis);
}
template <typename T, int row_stride, int col_stride>
void RotationMatrixToAngleAxis(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* angle_axis) {
T quaternion[4];
RotationMatrixToQuaternion(R, quaternion);
QuaternionToAngleAxis(quaternion, angle_axis);
return;
}
template <typename T>
inline void AngleAxisToRotationMatrix(const T* angle_axis, T* R) {
AngleAxisToRotationMatrix(angle_axis, ColumnMajorAdapter3x3(R));
}
template <typename T, int row_stride, int col_stride>
void AngleAxisToRotationMatrix(
const T* angle_axis,
const MatrixAdapter<T, row_stride, col_stride>& R) {
static const T kOne = T(1.0);
const T theta2 = DotProduct(angle_axis, angle_axis);
if (theta2 > T(std::numeric_limits<double>::epsilon())) {
// We want to be careful to only evaluate the square root if the
// norm of the angle_axis vector is greater than zero. Otherwise
// we get a division by zero.
const T theta = sqrt(theta2);
const T wx = angle_axis[0] / theta;
const T wy = angle_axis[1] / theta;
const T wz = angle_axis[2] / theta;
const T costheta = cos(theta);
const T sintheta = sin(theta);
R(0, 0) = costheta + wx*wx*(kOne - costheta);
R(1, 0) = wz*sintheta + wx*wy*(kOne - costheta);
R(2, 0) = -wy*sintheta + wx*wz*(kOne - costheta);
R(0, 1) = wx*wy*(kOne - costheta) - wz*sintheta;
R(1, 1) = costheta + wy*wy*(kOne - costheta);
R(2, 1) = wx*sintheta + wy*wz*(kOne - costheta);
R(0, 2) = wy*sintheta + wx*wz*(kOne - costheta);
R(1, 2) = -wx*sintheta + wy*wz*(kOne - costheta);
R(2, 2) = costheta + wz*wz*(kOne - costheta);
} else {
// Near zero, we switch to using the first order Taylor expansion.
R(0, 0) = kOne;
R(1, 0) = angle_axis[2];
R(2, 0) = -angle_axis[1];
R(0, 1) = -angle_axis[2];
R(1, 1) = kOne;
R(2, 1) = angle_axis[0];
R(0, 2) = angle_axis[1];
R(1, 2) = -angle_axis[0];
R(2, 2) = kOne;
}
}
template <typename T>
inline void EulerAnglesToRotationMatrix(const T* euler,
const int row_stride_parameter,
T* R) {
EulerAnglesToRotationMatrix(euler, RowMajorAdapter3x3(R));
}
template <typename T, int row_stride, int col_stride>
void EulerAnglesToRotationMatrix(
const T* euler,
const MatrixAdapter<T, row_stride, col_stride>& R) {
const double kPi = 3.14159265358979323846;
const T degrees_to_radians(kPi / 180.0);
const T pitch(euler[0] * degrees_to_radians);
const T roll(euler[1] * degrees_to_radians);
const T yaw(euler[2] * degrees_to_radians);
const T c1 = cos(yaw);
const T s1 = sin(yaw);
const T c2 = cos(roll);
const T s2 = sin(roll);
const T c3 = cos(pitch);
const T s3 = sin(pitch);
R(0, 0) = c1*c2;
R(0, 1) = -s1*c3 + c1*s2*s3;
R(0, 2) = s1*s3 + c1*s2*c3;
R(1, 0) = s1*c2;
R(1, 1) = c1*c3 + s1*s2*s3;
R(1, 2) = -c1*s3 + s1*s2*c3;
R(2, 0) = -s2;
R(2, 1) = c2*s3;
R(2, 2) = c2*c3;
}
template <typename T> inline
void QuaternionToScaledRotation(const T q[4], T R[3 * 3]) {
QuaternionToScaledRotation(q, RowMajorAdapter3x3(R));
}
template <typename T, int row_stride, int col_stride> inline
void QuaternionToScaledRotation(
const T q[4],
const MatrixAdapter<T, row_stride, col_stride>& R) {
// Make convenient names for elements of q.
T a = q[0];
T b = q[1];
T c = q[2];
T d = q[3];
// This is not to eliminate common sub-expression, but to
// make the lines shorter so that they fit in 80 columns!
T aa = a * a;
T ab = a * b;
T ac = a * c;
T ad = a * d;
T bb = b * b;
T bc = b * c;
T bd = b * d;
T cc = c * c;
T cd = c * d;
T dd = d * d;
R(0, 0) = aa + bb - cc - dd; R(0, 1) = T(2) * (bc - ad); R(0, 2) = T(2) * (ac + bd); // NOLINT
R(1, 0) = T(2) * (ad + bc); R(1, 1) = aa - bb + cc - dd; R(1, 2) = T(2) * (cd - ab); // NOLINT
R(2, 0) = T(2) * (bd - ac); R(2, 1) = T(2) * (ab + cd); R(2, 2) = aa - bb - cc + dd; // NOLINT
}
template <typename T> inline
void QuaternionToRotation(const T q[4], T R[3 * 3]) {
QuaternionToRotation(q, RowMajorAdapter3x3(R));
}
template <typename T, int row_stride, int col_stride> inline
void QuaternionToRotation(const T q[4],
const MatrixAdapter<T, row_stride, col_stride>& R) {
QuaternionToScaledRotation(q, R);
T normalizer = q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3];
normalizer = T(1) / normalizer;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
R(i, j) *= normalizer;
}
}
}
template <typename T> inline
void UnitQuaternionRotatePoint(const T q[4], const T pt[3], T result[3]) {
const T t2 = q[0] * q[1];
const T t3 = q[0] * q[2];
const T t4 = q[0] * q[3];
const T t5 = -q[1] * q[1];
const T t6 = q[1] * q[2];
const T t7 = q[1] * q[3];
const T t8 = -q[2] * q[2];
const T t9 = q[2] * q[3];
const T t1 = -q[3] * q[3];
result[0] = T(2) * ((t8 + t1) * pt[0] + (t6 - t4) * pt[1] + (t3 + t7) * pt[2]) + pt[0]; // NOLINT
result[1] = T(2) * ((t4 + t6) * pt[0] + (t5 + t1) * pt[1] + (t9 - t2) * pt[2]) + pt[1]; // NOLINT
result[2] = T(2) * ((t7 - t3) * pt[0] + (t2 + t9) * pt[1] + (t5 + t8) * pt[2]) + pt[2]; // NOLINT
}
template <typename T> inline
void QuaternionRotatePoint(const T q[4], const T pt[3], T result[3]) {
// 'scale' is 1 / norm(q).
const T scale = T(1) / sqrt(q[0] * q[0] +
q[1] * q[1] +
q[2] * q[2] +
q[3] * q[3]);
// Make unit-norm version of q.
const T unit[4] = {
scale * q[0],
scale * q[1],
scale * q[2],
scale * q[3],
};
UnitQuaternionRotatePoint(unit, pt, result);
}
template<typename T> inline
void QuaternionProduct(const T z[4], const T w[4], T zw[4]) {
zw[0] = z[0] * w[0] - z[1] * w[1] - z[2] * w[2] - z[3] * w[3];
zw[1] = z[0] * w[1] + z[1] * w[0] + z[2] * w[3] - z[3] * w[2];
zw[2] = z[0] * w[2] - z[1] * w[3] + z[2] * w[0] + z[3] * w[1];
zw[3] = z[0] * w[3] + z[1] * w[2] - z[2] * w[1] + z[3] * w[0];
}
// xy = x cross y;
template<typename T> inline
void CrossProduct(const T x[3], const T y[3], T x_cross_y[3]) {
x_cross_y[0] = x[1] * y[2] - x[2] * y[1];
x_cross_y[1] = x[2] * y[0] - x[0] * y[2];
x_cross_y[2] = x[0] * y[1] - x[1] * y[0];
}
template<typename T> inline
T DotProduct(const T x[3], const T y[3]) {
return (x[0] * y[0] + x[1] * y[1] + x[2] * y[2]);
}
template<typename T> inline
void AngleAxisRotatePoint(const T angle_axis[3], const T pt[3], T result[3]) {
const T theta2 = DotProduct(angle_axis, angle_axis);
if (theta2 > T(std::numeric_limits<double>::epsilon())) {
// Away from zero, use the rodriguez formula
//
// result = pt costheta +
// (w x pt) * sintheta +
// w (w . pt) (1 - costheta)
//
// We want to be careful to only evaluate the square root if the
// norm of the angle_axis vector is greater than zero. Otherwise
// we get a division by zero.
//
const T theta = sqrt(theta2);
const T costheta = cos(theta);
const T sintheta = sin(theta);
const T theta_inverse = T(1.0) / theta;
const T w[3] = { angle_axis[0] * theta_inverse,
angle_axis[1] * theta_inverse,
angle_axis[2] * theta_inverse };
// Explicitly inlined evaluation of the cross product for
// performance reasons.
const T w_cross_pt[3] = { w[1] * pt[2] - w[2] * pt[1],
w[2] * pt[0] - w[0] * pt[2],
w[0] * pt[1] - w[1] * pt[0] };
const T tmp =
(w[0] * pt[0] + w[1] * pt[1] + w[2] * pt[2]) * (T(1.0) - costheta);
result[0] = pt[0] * costheta + w_cross_pt[0] * sintheta + w[0] * tmp;
result[1] = pt[1] * costheta + w_cross_pt[1] * sintheta + w[1] * tmp;
result[2] = pt[2] * costheta + w_cross_pt[2] * sintheta + w[2] * tmp;
} else {
// Near zero, the first order Taylor approximation of the rotation
// matrix R corresponding to a vector w and angle w is
//
// R = I + hat(w) * sin(theta)
//
// But sintheta ~ theta and theta * w = angle_axis, which gives us
//
// R = I + hat(w)
//
// and actually performing multiplication with the point pt, gives us
// R * pt = pt + w x pt.
//
// Switching to the Taylor expansion near zero provides meaningful
// derivatives when evaluated using Jets.
//
// Explicitly inlined evaluation of the cross product for
// performance reasons.
const T w_cross_pt[3] = { angle_axis[1] * pt[2] - angle_axis[2] * pt[1],
angle_axis[2] * pt[0] - angle_axis[0] * pt[2],
angle_axis[0] * pt[1] - angle_axis[1] * pt[0] };
result[0] = pt[0] + w_cross_pt[0];
result[1] = pt[1] + w_cross_pt[1];
result[2] = pt[2] + w_cross_pt[2];
}
}
} // namespace ceres
#endif // CERES_PUBLIC_ROTATION_H_
| {
"pile_set_name": "Github"
} |
門井瑛子最新番号
【CADV-303】四十路マダム 8時間100連発!!
【CADV-151】熟女初撮り 8時間100連発!!
【CADV-142】Around 40
【CADV-123】S級美熟女4時間DX
【MMV-179】美熟女 悩殺Body 3
【MMV-173】四十路マダム 18</a>2008-09-12クリスタル映像$$$MADAM MANI119分钟 | {
"pile_set_name": "Github"
} |
body {
margin: 0;
padding: 0;
background-color: #fff;
color: #000;
font-size: 62.5%; /* Explain @ www.clagnut.com/blog/348/ */
}
/* common definitions */
h1 {
color: #444444;
font-size: 2em;
font-family: Arial, Helvetica, sans-serif;
margin-left: 1em;
}
h2 {
color: #444444;
font-size: 1.6em;
font-family: Arial, Helvetica, sans-serif;
margin-left: 1em;
border-bottom: 1px solid #000;
}
h3 {
color: #444444;
font-size: 1.6em;
font-family: Arial, Helvetica, sans-serif;
margin-left: 1em;
}
p {
color: #444444;
font-size: 1.2em;
font-family: serif;
margin-left: 2em;
}
a {
color: #16009A;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #0E0062;
text-decoration: underline;
}
code {
font-size: 1.2em;
}
.command {
background: #efefff;
padding-left: 0.5em;
padding-right: 0.5em;
}
.programlisting {
background: #efefff;
font-size: 1.2em;
margin-left: 3em;
margin-right: 3em;
padding-left: 0.5em;
padding-right: 0.5em;
}
.strikethrough {
text-decoration: line-through;
}
hr {
display: none;
}
/*
Navigation
*/
div.navheader, div.navfooter {
background: #f5f5f5;
border-bottom: 1px solid #000;
margin: 0;
padding: 0;
letter-spacing: 0.1em;
font-size: 1.2em;
}
div.navheader th, div.navfooter th{
color: #444444;
font-size: 2em;
font-family: Arial, Helvetica, sans-serif;
}
/* title */
h1.title {
background: #f5f5f5;
border-bottom: 1px solid #000;
margin: 0;
padding: 0.5em;
letter-spacing: 0.1em;
}
/* toc */
div.toc {
margin: 1em;
background: #efefef;
border: 1px solid #000;
font-size: 1.4em;
font-family: Arial, Helvetica, sans-serif;
}
div.toc a {
font-weight: normal;
font-family: Arial, Helvetica, sans-serif;
}
div.toc p {
font-family: Arial, Helvetica, sans-serif;
font-size: 1.4em;
margin: 0.5em;
}
div.toc dd, div.toc dt{
margin-left: 2em;
}
div.toc dt{
margin-top: 0.2em;
}
/* footer */
div.footer {
background: #f5f5f5;
border-top: 1px solid #000;
margin: 0;
margin-top: 5em;
padding: 0.1em;
text-align: center;
font-size: 0.8em;
letter-spacing: 0.1em;
} | {
"pile_set_name": "Github"
} |
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
html {
background: #833;
}
body {
margin: 0;
padding: 0 1em;
color: -moz-FieldText;
font: message-box;
}
h1 {
margin: 0 0 .6em 0;
border-bottom: 1px solid ThreeDLightShadow;
font-size: 160%;
}
h2 {
font-size: 130%;
}
#errorPageContainer {
position: relative;
min-width: 13em;
max-width: 52em;
margin: 4em auto;
border: 2px solid #DD0D09;
border-radius: 10px;
box-shadow: 0px 0px 8px red;
padding: 3em;
padding-inline-start: 30px;
background: url("chrome://global/skin/icons/sslWarning.png") left 0 no-repeat -moz-Field;
background-origin: content-box;
}
#errorPageContainer:-moz-dir(rtl) {
background-position: right 0;
}
#errorTitle {
margin-inline-start: 80px;
}
#errorLongContent {
margin-inline-start: 80px;
}
.expander > button {
padding-inline-start: 20px;
margin-inline-start: -20px;
background: url("chrome://browser/skin/aboutCertError_sectionExpanded.png") left center no-repeat;
border: none;
font: inherit;
color: inherit;
cursor: pointer;
}
.expander > button:-moz-dir(rtl) {
background-position: right center;
}
.expander[collapsed] > button {
background-image: url("chrome://browser/skin/aboutCertError_sectionCollapsed.png");
}
.expander[collapsed] > button:-moz-dir(rtl) {
background-image: url("chrome://browser/skin/aboutCertError_sectionCollapsed-rtl.png");
}
| {
"pile_set_name": "Github"
} |
SUBDIRS=src
.PHONY: all build test history clean info
all build clean:
@for d in $(SUBDIRS); do \
if [ -f $$d/Makefile ] ; then \
$(MAKE) -C $$d $@ || exit $?; \
fi; \
done
test:
cd test && $(MAKE) build test
history:
cd test && $(MAKE) history
info:
@echo "SUBDIRS=$(SUBDIRS)"
| {
"pile_set_name": "Github"
} |
//##########################################################################
//# #
//# CLOUDCOMPARE #
//# #
//# 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; version 2 or later of the License. #
//# #
//# 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. #
//# #
//# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
//# #
//##########################################################################
#ifndef CC_POINT_PICKING_GENERIC_INTERFACE_HEADER
#define CC_POINT_PICKING_GENERIC_INTERFACE_HEADER
//Local
#include "ccOverlayDialog.h"
#include "ccCommon.h"
#include "ccPickingListener.h"
//CCCoreLib
#include <CCGeom.h>
//system
#include <vector>
class ccGLWindow;
class ccPointCloud;
class ccHObject;
class ccPickingHub;
/** Generic interface for any dialog/graphical interactor that relies on point picking.
**/
class ccPointPickingGenericInterface : public ccOverlayDialog, public ccPickingListener
{
Q_OBJECT
public:
//! Default constructor
explicit ccPointPickingGenericInterface(ccPickingHub* pickingHub, QWidget* parent = nullptr);
//! Destructor
~ccPointPickingGenericInterface() override = default;
//inherited from ccOverlayDialog
bool linkWith(ccGLWindow* win) override;
bool start() override;
void stop(bool state) override;
//! Inherited from ccPickingListener
void onItemPicked(const PickedItem& pi) override;
protected:
//! Generic method to process picked points
virtual void processPickedPoint(const PickedItem& picked) = 0;
//! Picking hub
ccPickingHub* m_pickingHub;
};
#endif
| {
"pile_set_name": "Github"
} |
[Script Info]
; Script generated by Aegisub 2.1.8
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 640
PlayResY: 480
ScaledBorderAndShadow: yes
Video Aspect Ratio: 0
Video Zoom: 6
Video Position: 0
Audio File: ?video
Last Style Storage: Default
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial Unicode MS,34,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:01:31.27,0:01:34.26,Default,,0000,0000,0000,, ママーッ!ママッ!私、選ばれたの!
Dialogue: 0,0:01:34.67,0:01:39.22,Default,,0000,0000,0000,, 人類を守る、エリートパイロットなのよ!世界一なのよ!
Dialogue: 0,0:01:40.19,0:01:43.78,Default,,0000,0000,0000,, 誰にも秘密なの!\Nでも、ママにだけ教えるわね!
Dialogue: 0,0:01:44.67,0:01:48.78,Default,,0000,0000,0000,, いろんな人が親切にしてくれるわ。だから、寂しくなんかないの!
Dialogue: 0,0:01:49.83,0:01:53.50,Default,,0000,0000,0000,, だから、パパがいなくっても大丈夫!さみしくなんかないわ!
Dialogue: 0,0:01:54.31,0:01:56.61,Default,,0000,0000,0000,, だから見て!私を見て!
Dialogue: 0,0:01:57.23,0:01:58.37,Default,,0000,0000,0000,, ねぇ、ママッ!
Dialogue: 0,0:02:07.31,0:02:11.50,Default,,0000,0000,0000,, シンクロ率ゼロ。セカンドチルドレンたる資格無し。
Dialogue: 0,0:02:11.91,0:02:14.21,Default,,0000,0000,0000,, もう私がいる理由もないわ。
Dialogue: 0,0:02:14.87,0:02:19.34,Default,,0000,0000,0000,, 誰も私を見てくれないもの。\Nパパもママも誰も。
Dialogue: 0,0:02:19.75,0:02:22.21,Default,,0000,0000,0000,, 私が生きてく理由もないわ…
Dialogue: 0,0:02:30.31,0:02:32.30,Default,,0000,0000,0000,, 惣流・アスカ・ラングレーだな?
Dialogue: 0,0:02:34.43,0:02:37.90,Default,,0000,0000,0000,, 諜報二課から、セカンドチルドレンを無事保護したそうです。
Dialogue: 0,0:02:38.31,0:02:43.14,Default,,0000,0000,0000,, そう。ロストした挙げ句七日後に発見とは、\N二課らしくないわね。
Dialogue: 0,0:02:43.55,0:02:47.66,Default,,0000,0000,0000,, わざと、でしょ。\N嫌がらせじゃないんですか?作戦課への。
Dialogue: 0,0:02:48.07,0:02:55.42,Default,,0000,0000,0000,, そうかもね…で今日、アスカの代わりの\Nフィフス到着。出来過ぎてるわね、シナリオ)
Dialogue: 0,0:03:03.23,0:03:07.54,Default,,0000,0000,0000,, 綾波レイ。やっぱりそうなのか?あの感じ。
Dialogue: 0,0:03:08.23,0:03:13.42,Default,,0000,0000,0000,, 母さんの。綾波レイを、母さんを、
Dialogue: 0,0:03:13.83,0:03:16.34,Default,,0000,0000,0000,, 何をしているんだ、父さん!
Dialogue: 0,0:03:18.19,0:03:19.10,Default,,0000,0000,0000,, 碇司令…
Dialogue: 0,0:03:20.59,0:03:24.54,Default,,0000,0000,0000,, 猫が死んだんです。おばあちゃんのところに預けていた。
Dialogue: 0,0:03:25.23,0:03:31.22,Default,,0000,0000,0000,, ずっと構っていなかったのに。\N突然、もう二度と会えなくなるのね。
Dialogue: 0,0:03:31.63,0:03:34.54,Default,,0000,0000,0000,, なぜ、ダミーシステムを破壊した?
Dialogue: 0,0:03:34.95,0:03:39.26,Default,,0000,0000,0000,, ダミーではありません。\N破壊したのはレイですわ。
Dialogue: 0,0:03:39.67,0:03:42.10,Default,,0000,0000,0000,, …今一度問う。\Nなぜだ?
Dialogue: 0,0:03:42.51,0:03:45.26,Default,,0000,0000,0000,, あなたに抱かれても嬉しくなくなったから。
Dialogue: 0,0:03:45.67,0:03:48.74,Default,,0000,0000,0000,, 私の体を好きにしたらどうです!?あの時みたいに!
Dialogue: 0,0:03:49.15,0:03:52.02,Default,,0000,0000,0000,, 君には失望した…\N失望!?
Dialogue: 0,0:03:52.43,0:03:58.90,Default,,0000,0000,0000,, 最初っから期待も望みも持たなかったくせに!\N私には何も!何も!何も…
Dialogue: 0,0:04:02.55,0:04:04.82,Default,,0000,0000,0000,, どうしたらいいの…母さん…
Dialogue: 0,0:04:06.95,0:04:09.66,Default,,0000,0000,0000,, (どこに行ったんだろう…アスカ…)
Dialogue: 0,0:04:10.91,0:04:15.06,Default,,0000,0000,0000,, (でも会ってどうするんだ…\N綾波の話でもするのか?)
Dialogue: 0,0:04:23.78,0:04:28.74,Default,,0000,0000,0000,, (トウジもケンスケもみんな家を失って他のところへ行ってしまった。
Dialogue: 0,0:04:29.59,0:04:35.38,Default,,0000,0000,0000,, 友達は…友達と呼べる人はいなくなってしまった…誰も…)
Dialogue: 0,0:04:36.99,0:04:40.50,Default,,0000,0000,0000,, (綾波には会えない…その勇気がない。
Dialogue: 0,0:04:40.91,0:04:43.82,Default,,0000,0000,0000,, どんな顔をすればいいのか、分からない。
Dialogue: 0,0:04:44.23,0:04:51.46,Default,,0000,0000,0000,, アスカ、ミサトさん、母さん!\N僕はどうすれば…どうしたらいい?)
Dialogue: 0,0:05:12.31,0:05:16.34,Default,,0000,0000,0000,, 歌はいいねぇ。\N歌は心を潤してくれる。
Dialogue: 0,0:05:16.75,0:05:19.42,Default,,0000,0000,0000,, リリンが生み出した文化の極みだよ。
Dialogue: 0,0:05:19.95,0:05:23.90,Default,,0000,0000,0000,, そう感じないか?碇シンジ君。
Dialogue: 0,0:05:24.55,0:05:27.11,Default,,0000,0000,0000,, 僕の名を?\N知らないものはないさ。
Dialogue: 0,0:05:27.51,0:05:31.34,Default,,0000,0000,0000,, 失礼だが、君は自分の立場を\Nもう少しは知ったほうがいいと思うよ。
Dialogue: 0,0:05:31.75,0:05:34.86,Default,,0000,0000,0000,, そうかなぁ…?あの、君は?
Dialogue: 0,0:05:35.27,0:05:41.14,Default,,0000,0000,0000,, 僕はカヲル。渚カヲル。\N君と同じ、仕組まれた子供。フィフスチルドレンさ。
Dialogue: 0,0:05:41.55,0:05:45.14,Default,,0000,0000,0000,, フィフスチルドレン?\N君が、あの、渚君?
Dialogue: 0,0:05:45.75,0:05:50.87,Default,,0000,0000,0000,, カヲルでいいよ、碇君。\N僕も、シンジでいいよ。
Dialogue: 0,0:05:54.63,0:05:57.30,Default,,0000,0000,0000,, フィフスチルドレンが、\N今到着したそうです。
Dialogue: 0,0:05:57.87,0:06:00.62,Default,,0000,0000,0000,, 渚カヲル。過去の経歴は抹消済み。
Dialogue: 0,0:06:01.19,0:06:06.18,Default,,0000,0000,0000,, レイと同じくね。\nただ生年月日は、セカンドインパクトと同一日です。
Dialogue: 0,0:06:06.59,0:06:10.62,Default,,0000,0000,0000,, 委員会が直で送ってきた\N子供よ。必ず何かあるわ。
Dialogue: 0,0:06:11.03,0:06:14.34,Default,,0000,0000,0000,, マルドゥックの報告書も、\Nフィフスの件は非公開となっています。
Dialogue: 0,0:06:14.75,0:06:18.22,Default,,0000,0000,0000,, それもあって、ちょいと諜報部の\Nデータに割り込みました。
Dialogue: 0,0:06:18.63,0:06:25.70,Default,,0000,0000,0000,, 危ない事するわねぇ!\Nその甲斐はありましたよ。リツコさんの居場所です!
Dialogue: 0,0:06:26.11,0:06:33.06,Default,,0000,0000,0000,, フィフスのシンクロテスト、どうします?\N今日のところは小細工をやめて、素直に彼の実力、見せてもらいましょ。
Dialogue: 0,0:06:35.31,0:06:38.98,Default,,0000,0000,0000,, 後、0コンマ3下げてみろ。
Dialogue: 0,0:06:39.67,0:06:44.66,Default,,0000,0000,0000,, このデータに間違いはないな?\N全ての計測システムは、正常に作動しています。
Dialogue: 0,0:06:45.07,0:06:47.37,Default,,0000,0000,0000,, MAGIによるデータ誤差、認められません。
Dialogue: 0,0:06:47.79,0:06:51.14,Default,,0000,0000,0000,, よもや、コアの変換も無しに弐号機と\Nシンクロするとはな。
Dialogue: 0,0:06:51.55,0:06:54.34,Default,,0000,0000,0000,, この少年が。\Nしかし、信じられません!
Dialogue: 0,0:06:54.75,0:06:58.66,Default,,0000,0000,0000,, いえ、システム上、ありえないです…\nでも事実なのよ。
Dialogue: 0,0:06:59.11,0:07:02.62,Default,,0000,0000,0000,, 事実をまず受け止めてから、\N原因を探ってみて。
Dialogue: 0,0:07:08.27,0:07:10.26,Default,,0000,0000,0000,, 君がファーストチルドレンだね。
Dialogue: 0,0:07:11.99,0:07:13.18,Default,,0000,0000,0000,, 綾波レイ。
Dialogue: 0,0:07:14.59,0:07:17.74,Default,,0000,0000,0000,, 君は僕と同じだね。\N…あなた誰?
Dialogue: 0,0:07:19.15,0:07:22.77,Default,,0000,0000,0000,, フィフスの少年がレイと接触したそうだ。\Nそうか…
Dialogue: 0,0:07:23.35,0:07:26.78,Default,,0000,0000,0000,, 今、フィフスのデータをMAGIが\N全力を挙げて当たっている。
Dialogue: 0,0:07:27.19,0:07:31.70,Default,,0000,0000,0000,, にもかかわらず、未だ正体不明。\N何者なの?あの少年。
Dialogue: 0,0:07:40.07,0:07:45.06,Default,,0000,0000,0000,, シンジ君も未だ戻らず。\N保護者失格ね、私。
Dialogue: 0,0:07:47.35,0:07:51.13,Default,,0000,0000,0000,, 現在、セントラルドグマは開放中。\N移動ルートは3番を使用してください。
Dialogue: 0,0:07:51.95,0:07:54.90,Default,,0000,0000,0000,, やぁ、僕を待っててくれたのかい?
Dialogue: 0,0:07:55.31,0:07:57.69,Default,,0000,0000,0000,, いや、別に、あ、\Nそんなつもりじゃ…
Dialogue: 0,0:07:58.11,0:08:03.82,Default,,0000,0000,0000,, 今日は?\Nあの、定時試験も終わったし、後はシャワーを浴びて帰るだけだけど…
Dialogue: 0,0:08:05.71,0:08:09.02,Default,,0000,0000,0000,, でも、本当は\Nあまり帰りたくないんだ。このごろ。
Dialogue: 0,0:08:09.43,0:08:14.26,Default,,0000,0000,0000,, 帰る家、ホームがあるという事実は、\N幸せにつながる。良いことだよ。
Dialogue: 0,0:08:14.87,0:08:19.66,Default,,0000,0000,0000,, そうかなぁ。\N僕は君ともっと話がしたいな。いっしょに行っていいかい?
Dialogue: 0,0:08:21.03,0:08:24.34,Default,,0000,0000,0000,, シャワーだよ。これからなんだろ?\N…うん。
Dialogue: 0,0:08:24.95,0:08:28.90,Default,,0000,0000,0000,, だめなのかい?\Nいや、別に、そういうわけじゃないけど…
Dialogue: 0,0:08:35.67,0:08:41.90,Default,,0000,0000,0000,, 一時的接触を極端に避けるね、君は。\N恐いのかい?人と触れ合うのが。
Dialogue: 0,0:08:42.31,0:08:47.70,Default,,0000,0000,0000,, 他人を知らなければ\N裏切られることも互いに傷つくこともない。
Dialogue: 0,0:08:48.00,0:08:50.82,Default,,0000,0000,0000,, でも、さびしさを忘れることもないよ。
Dialogue: 0,0:08:51.00,0:08:55.80,Default,,0000,0000,0000,, 人間はさびしさを永久に\Nなくすことはできない。人は一人だからね。
Dialogue: 0,0:08:55.80,0:08:59.38,Default,,0000,0000,0000,, ただ忘れることができるから、\N人は生きていけるのさ。
Dialogue: 0,0:09:07.31,0:09:09.98,Default,,0000,0000,0000,, 時間だ…\Nもう、終わりなのかい?
Dialogue: 0,0:09:10.39,0:09:13.66,Default,,0000,0000,0000,, うん、もう寝なきゃ。\N君と?
Dialogue: 0,0:09:14.07,0:09:20.17,Default,,0000,0000,0000,, あっ、いや、カヲル君には\N部屋が用意されていると思うよ。別の…
Dialogue: 0,0:09:21.35,0:09:24.06,Default,,0000,0000,0000,, 常に人間は心に痛みを感じている。
Dialogue: 0,0:09:25.83,0:09:28.90,Default,,0000,0000,0000,, 心が痛がりだから、生きるのも辛いと感じる。
Dialogue: 0,0:09:30.55,0:09:34.78,Default,,0000,0000,0000,, ガラスのように繊細だね。特に君の心は。\N僕が?
Dialogue: 0,0:09:35.19,0:09:38.62,Default,,0000,0000,0000,, そう。コウイに値するよ。\Nコウイ…?
Dialogue: 0,0:09:39.19,0:09:40.30,Default,,0000,0000,0000,, 好きって事さ。
Dialogue: 0,0:09:47.80,0:09:51.95,Default,,0000,0000,0000,, ネルフ。われらゼーレの\N実行機関として結成されし組織。
Dialogue: 0,0:09:52.36,0:09:55.75,Default,,0000,0000,0000,, われらのシナリオを\N実践するために用意されたモノ。
Dialogue: 0,0:09:56.16,0:09:59.43,Default,,0000,0000,0000,, だが、今は一個人の\N占有機関と成り果てている。
Dialogue: 0,0:09:59.88,0:10:04.47,Default,,0000,0000,0000,, さよう。われらの手に取り戻さねばならん。\N約束の日の前に。
Dialogue: 0,0:10:04.88,0:10:08.15,Default,,0000,0000,0000,, ネルフとエヴァシリーズを\N本来の姿にしておかねばならん。
Dialogue: 0,0:10:08.56,0:10:12.51,Default,,0000,0000,0000,, 碇、ゼーレへの背任、\Nその責任は取ってもらうぞ。
Dialogue: 0,0:10:13.48,0:10:16.35,Default,,0000,0000,0000,, われわれに与えられた時間はもう残り少ない。
Dialogue: 0,0:10:17.16,0:10:21.51,Default,,0000,0000,0000,, だがわれらの願いを妨げる\Nロンギヌスの槍はすでにないのだ。
Dialogue: 0,0:10:22.24,0:10:25.94,Default,,0000,0000,0000,, まもなく最後の使徒が現れる。それを消せば願いがかなう。
Dialogue: 0,0:10:26.76,0:10:28.43,Default,,0000,0000,0000,, もうすぐだよ、ユイ。
Dialogue: 0,0:10:30.64,0:10:32.35,Default,,0000,0000,0000,, 私、なぜここにいるの?
Dialogue: 0,0:10:33.80,0:10:35.95,Default,,0000,0000,0000,, 私、なぜまた生きてるの?
Dialogue: 0,0:10:37.20,0:10:38.26,Default,,0000,0000,0000,, 何のために?
Dialogue: 0,0:10:39.36,0:10:40.47,Default,,0000,0000,0000,, 誰のために?
Dialogue: 0,0:10:41.68,0:10:43.51,Default,,0000,0000,0000,, フィフスチルドレン。
Dialogue: 0,0:10:44.44,0:10:48.11,Default,,0000,0000,0000,, あの人、私と同じ感じがする。\Nどうして?
Dialogue: 0,0:10:54.24,0:10:59.26,Default,,0000,0000,0000,, ここが街外れで良かったわ。\Nあなたが巻き込まれなくて良かったもの。
Dialogue: 0,0:10:59.72,0:11:01.75,Default,,0000,0000,0000,, でも、この次の保証はないの。
Dialogue: 0,0:11:02.52,0:11:05.67,Default,,0000,0000,0000,, だから、明日からは洞木さんちのお世話になるのよ。
Dialogue: 0,0:11:06.12,0:11:08.50,Default,,0000,0000,0000,, しばらくお別れね、ペンペン。
Dialogue: 0,0:11:16.08,0:11:18.19,Default,,0000,0000,0000,, やはり、僕が下で寝るよ。
Dialogue: 0,0:11:18.60,0:11:24.59,Default,,0000,0000,0000,, いいよ、僕が無理言って泊めてもらってるんだ、\Nここでいいよ。
Dialogue: 0,0:11:27.08,0:11:30.03,Default,,0000,0000,0000,, 君は何を話たいんだい?
Dialogue: 0,0:11:30.44,0:11:34.14,Default,,0000,0000,0000,, 僕に聞いてほしいことがあるんだろう?
Dialogue: 0,0:11:34.56,0:11:37.95,Default,,0000,0000,0000,, いろいろあったんだ、ここに来て。
Dialogue: 0,0:11:38.36,0:11:44.27,Default,,0000,0000,0000,, 来る前は、先生のところにいたんだ。\N穏やかで何にもない日々だった。
Dialogue: 0,0:11:44.68,0:11:46.83,Default,,0000,0000,0000,, ただそこにいるだけの。
Dialogue: 0,0:11:47.24,0:11:52.03,Default,,0000,0000,0000,, でもそれでも良かったんだ。\N僕には何もすることがなかったから。
Dialogue: 0,0:11:52.44,0:11:56.79,Default,,0000,0000,0000,, 人間が嫌いなのかい?\N別に、どうでも良かったんだと思う。
Dialogue: 0,0:11:57.64,0:12:01.23,Default,,0000,0000,0000,, ただ、父さんは嫌いだった。
Dialogue: 0,0:12:01.64,0:12:04.99,Default,,0000,0000,0000,, (どうしてカヲル君にこんな事話すんだろう…)
Dialogue: 0,0:12:07.48,0:12:10.43,Default,,0000,0000,0000,, 僕は君に逢うために\N生まれてきたのかもしれない。
Dialogue: 0,0:12:11.92,0:12:14.43,Default,,0000,0000,0000,, どう?彼のデータ、入手できた?
Dialogue: 0,0:12:15.00,0:12:17.95,Default,,0000,0000,0000,, これです。伊吹二尉から\N無断で借用したものです。
Dialogue: 0,0:12:18.36,0:12:22.27,Default,,0000,0000,0000,, すまないわね、泥棒みたいなことばかりやらせて…
Dialogue: 0,0:12:22.68,0:12:27.27,Default,,0000,0000,0000,, 何これ!- マヤちゃんが公表できないわけですよ。\N理論上は、ありえないことですから。
Dialogue: 0,0:12:27.68,0:12:30.83,Default,,0000,0000,0000,, そうね、謎は深まるばかりだわ。
Dialogue: 0,0:12:31.24,0:12:35.87,Default,,0000,0000,0000,, エヴァとのシンクロ率を自由に\N設定できるとはね。それも自分の意志で。
Dialogue: 0,0:12:36.72,0:12:38.75,Default,,0000,0000,0000,, またも、なり振り構ってらんないか…
Dialogue: 0,0:12:40.52,0:12:43.59,Default,,0000,0000,0000,, 良く来られたわね。\N聞きたいことがあるの。
Dialogue: 0,0:12:44.00,0:12:47.23,Default,,0000,0000,0000,, ここでの会話、録音されるわよ。\N構わないわ。
Dialogue: 0,0:12:47.64,0:12:53.71,Default,,0000,0000,0000,, あの少年の、フィフスの正体は何?\Nおそらく、最後のシ者ね。
Dialogue: 0,0:12:56.12,0:13:01.59,Default,,0000,0000,0000,, さあ行くよ、おいで、\Nアダムの分身。そしてリリンのしもべ。
Dialogue: 0,0:13:07.56,0:13:10.55,Default,,0000,0000,0000,, エヴァ弐号機、起動!\Nそんなバカな!アスカは!?
Dialogue: 0,0:13:11.16,0:13:13.27,Default,,0000,0000,0000,, 303(サンマルサン)病室です。確認済みです。
Dialogue: 0,0:13:13.84,0:13:18.43,Default,,0000,0000,0000,, じゃあいったい誰が…?\N無人です、弐号機にエントリープラグは挿入されていません!
Dialogue: 0,0:13:18.92,0:13:21.71,Default,,0000,0000,0000,, 誰もいない?フィフスの少年ではないの?
Dialogue: 0,0:13:23.20,0:13:25.39,Default,,0000,0000,0000,, セントラルドグマに、\NA.T.フィールドの発生を確認!
Dialogue: 0,0:13:25.80,0:13:29.31,Default,,0000,0000,0000,, 弐号機?\Nいえ、パターン青!間違いありません!使徒です!
Dialogue: 0,0:13:29.72,0:13:31.71,Default,,0000,0000,0000,, 何ですって?
Dialogue: 0,0:13:32.12,0:13:33.87,Default,,0000,0000,0000,, 使徒…あの少年が?
Dialogue: 0,0:13:36.28,0:13:38.79,Default,,0000,0000,0000,, 目標は第4層を通過、\Nなおも降下中!
Dialogue: 0,0:13:39.20,0:13:40.91,Default,,0000,0000,0000,, だめです、リニアの電源は切れません!
Dialogue: 0,0:13:41.32,0:13:42.38,Default,,0000,0000,0000,, 目標は第5層を通過!
Dialogue: 0,0:13:43.08,0:13:47.91,Default,,0000,0000,0000,, セントラルドグマの全隔壁を緊急閉鎖!\N少しでもいい、時間を稼げ!
Dialogue: 0,0:13:48.88,0:13:53.74,Default,,0000,0000,0000,, マルボルジェ全層緊急閉鎖、総員待避、総員待避!
Dialogue: 0,0:13:54.64,0:13:57.10,Default,,0000,0000,0000,, まさか、ゼーレが直接送り込んでくるとはな…
Dialogue: 0,0:13:57.52,0:14:01.55,Default,,0000,0000,0000,, 老人は予定を\N一つ繰り上げるつもりだ。我々の手で。
Dialogue: 0,0:14:02.28,0:14:06.27,Default,,0000,0000,0000,, 最後の使徒がセントラルドグマに\N侵入した。現在降下中だ。
Dialogue: 0,0:14:06.68,0:14:12.43,Default,,0000,0000,0000,, 予定通りだな。\N碇。君はよき友人であり、志を共にする仲間であり、
Dialogue: 0,0:14:12.84,0:14:16.23,Default,,0000,0000,0000,, 理解ある協力者だった。これが\N最後の仕事だ。
Dialogue: 0,0:14:16.88,0:14:19.99,Default,,0000,0000,0000,, 初号機による遂行を願うぞ。
Dialogue: 0,0:14:21.48,0:14:26.19,Default,,0000,0000,0000,, 装甲隔壁は、エヴァ弐号機に\Nより突破されています!\N目標は、第2コキュートスを通過!
Dialogue: 0,0:14:26.60,0:14:29.06,Default,,0000,0000,0000,, エヴァ初号機に追撃させろ。\Nはい。
Dialogue: 0,0:14:29.64,0:14:33.99,Default,,0000,0000,0000,, いかなる方法をもってしても、\N目標のターミナルドグマ侵入を阻止しろ。
Dialogue: 0,0:14:37.08,0:14:39.03,Default,,0000,0000,0000,, しかし、使徒はなぜ弐号機を?
Dialogue: 0,0:14:39.96,0:14:45.08,Default,,0000,0000,0000,, もしや、弐号機との融合を果たすつもりなのか?\Nあるいは破滅を導くためか、だ。
Dialogue: 0,0:14:45.48,0:14:51.23,Default,,0000,0000,0000,, 嘘だ嘘だ嘘だ!カヲル君が、\N彼が使徒だったなんて、そんなの嘘だ!
Dialogue: 0,0:14:51.64,0:14:56.91,Default,,0000,0000,0000,, 事実よ。受け止めなさい。\N出撃、いいわね。
Dialogue: 0,0:14:59.48,0:15:00.95,Default,,0000,0000,0000,, 遅いな、シンジ君。
Dialogue: 0,0:15:01.68,0:15:05.07,Default,,0000,0000,0000,, エヴァ初号機、\Nルート2を降下!目標を追撃中!
Dialogue: 0,0:15:05.48,0:15:10.50,Default,,0000,0000,0000,, 裏切ったな…僕の気持ちを裏切ったな…\N父さんと同じに裏切ったんだ!
Dialogue: 0,0:15:11.20,0:15:14.11,Default,,0000,0000,0000,, 初号機、第4層に到達、\N目標と接触します。
Dialogue: 0,0:15:14.52,0:15:16.35,Default,,0000,0000,0000,, いた!
Dialogue: 0,0:15:16.88,0:15:19.39,Default,,0000,0000,0000,, 待っていたよ、シンジ君。\Nカヲル君!
Dialogue: 0,0:15:24.72,0:15:27.28,Default,,0000,0000,0000,, アスカ、ごめんよ!
Dialogue: 0,0:15:29.28,0:15:33.75,Default,,0000,0000,0000,, エヴァシリーズ。アダムより\N生まれし人間にとって忌むべき存在。
Dialogue: 0,0:15:34.16,0:15:38.47,Default,,0000,0000,0000,, それを利用してまで生き延びようとするリリン。\N僕にはわからないよ。
Dialogue: 0,0:15:41.44,0:15:43.79,Default,,0000,0000,0000,, カヲル君!やめてよ、どうしてだよ!
Dialogue: 0,0:15:44.56,0:15:47.12,Default,,0000,0000,0000,, エヴァは僕と同じ体でできている。
Dialogue: 0,0:15:47.52,0:15:51.71,Default,,0000,0000,0000,, 僕もアダムより生まれしものだからね。魂さえなければ同化できるさ。
Dialogue: 0,0:15:52.76,0:15:56.63,Default,,0000,0000,0000,, この弐号機の魂は、今自ら閉じこもっているから。
Dialogue: 0,0:15:58.68,0:16:02.63,Default,,0000,0000,0000,, ハッ…A.T.フィールド…!?\Nそう、君たちリリンはそう呼んでるね。
Dialogue: 0,0:16:03.12,0:16:07.03,Default,,0000,0000,0000,, なんぴとにも侵されざる聖なる領域、心の光。
Dialogue: 0,0:16:08.00,0:16:13.27,Default,,0000,0000,0000,, リリンもわかっているんだろ?\NA.T.フィールドは誰もが持っている心の壁だということを。
Dialogue: 0,0:16:13.68,0:16:16.03,Default,,0000,0000,0000,, そんなの分からないよ、\Nカヲル君!クッ!
Dialogue: 0,0:16:18.72,0:16:22.67,Default,,0000,0000,0000,, エヴァ両機、最下層に到達。\N目標、ターミナルドグマまで、後20。
Dialogue: 0,0:16:24.24,0:16:27.23,Default,,0000,0000,0000,, 初号機の信号が消えて、\Nもう一度変化があったときは…
Dialogue: 0,0:16:27.84,0:16:30.79,Default,,0000,0000,0000,, 分かってます。その時は\Nここを自爆させるんですね。
Dialogue: 0,0:16:31.52,0:16:35.30,Default,,0000,0000,0000,, サードインパクトが起こされるよりはマシですから。\Nすまないわね。
Dialogue: 0,0:16:35.84,0:16:39.46,Default,,0000,0000,0000,, いいですよ、あなたといっしょなら。\Nありがとう。
Dialogue: 0,0:16:44.36,0:16:49.59,Default,,0000,0000,0000,, 人の宿命(さだめ)か…\N人の希望は悲しみに綴られているね…
Dialogue: 0,0:16:52.04,0:16:55.43,Default,,0000,0000,0000,, どういうこと!?\Nこれまでにない強力なA.T.フィールドです!
Dialogue: 0,0:16:56.60,0:16:59.75,Default,,0000,0000,0000,, 光波、電磁波、粒子も遮断しています!\N何もモニターできません!
Dialogue: 0,0:17:00.16,0:17:01.43,Default,,0000,0000,0000,, まさに結界か…
Dialogue: 0,0:17:01.96,0:17:06.63,Default,,0000,0000,0000,, 目標およびエヴァ弐号機、初号機共にロスト、\Nパイロットとの連絡も取れません!
Dialogue: 0,0:17:19.00,0:17:20.99,Default,,0000,0000,0000,, う…くっ…カヲル君!
Dialogue: 0,0:17:23.60,0:17:25.79,Default,,0000,0000,0000,, 待って!うっ!
Dialogue: 0,0:17:36.40,0:17:41.31,Default,,0000,0000,0000,, 最終安全装置、解除!\Nヘヴンズドアが、開いて行きます…
Dialogue: 0,0:17:41.72,0:17:46.47,Default,,0000,0000,0000,, 遂にたどり着いたのね、使徒が…\N日向君…
Dialogue: 0,0:17:51.60,0:17:52.35,Default,,0000,0000,0000,, なんだ!?
Dialogue: 0,0:17:52.92,0:17:54.55,Default,,0000,0000,0000,, 状況は?\NA.T.フィールドです!
Dialogue: 0,0:17:55.20,0:17:59.19,Default,,0000,0000,0000,, ターミナルドグマの結界周辺に\N先と同等のA.T.フィールドが発生。
Dialogue: 0,0:17:59.88,0:18:01.35,Default,,0000,0000,0000,, 結界の中へ侵入していきます!
Dialogue: 0,0:18:02.00,0:18:04.95,Default,,0000,0000,0000,, まさか、新たな使徒?\Nだめです、確認できません!
Dialogue: 0,0:18:06.04,0:18:09.79,Default,,0000,0000,0000,, あ、いえ、消失しました!\N消えた!?使徒が?
Dialogue: 0,0:18:12.16,0:18:14.99,Default,,0000,0000,0000,, アダム…われらの母たる存在…
Dialogue: 0,0:18:15.40,0:18:18.43,Default,,0000,0000,0000,, アダムより生まれしものはアダムに\N還らねばならないのか?
Dialogue: 0,0:18:19.20,0:18:25.19,Default,,0000,0000,0000,, 人を滅ぼしてまで…\N違う…これは…リリス!
Dialogue: 0,0:18:26.00,0:18:28.23,Default,,0000,0000,0000,, そうか、そういうことかリリン!
Dialogue: 0,0:18:42.12,0:18:46.43,Default,,0000,0000,0000,, ありがとう、シンジ君。弐号機は君に止めておいてもらいたかったんだ。
Dialogue: 0,0:18:47.08,0:18:50.11,Default,,0000,0000,0000,, そうしなければ彼女と生き続けたかもしれないからね。
Dialogue: 0,0:18:50.52,0:18:52.07,Default,,0000,0000,0000,, カヲル君…どうして…
Dialogue: 0,0:18:52.68,0:18:57.83,Default,,0000,0000,0000,, 僕が生き続けることが僕の運命だからだよ。結果、人が滅びてもね。
Dialogue: 0,0:18:59.12,0:19:03.79,Default,,0000,0000,0000,, だが、このまま死ぬこともできる。\N生と死は等価値なんだ、僕にとってはね。
Dialogue: 0,0:19:04.20,0:19:07.31,Default,,0000,0000,0000,, 自らの死、それが唯一の絶対的自由なんだよ。
Dialogue: 0,0:19:07.80,0:19:13.79,Default,,0000,0000,0000,, 何を…カヲル君…\N君が何を言っているのか分かんないよ!カヲル君!
Dialogue: 0,0:19:14.20,0:19:15.23,Default,,0000,0000,0000,, 遺言だよ。
Dialogue: 0,0:19:16.60,0:19:22.27,Default,,0000,0000,0000,, さあ、僕を消してくれ。そうしなければ君らが消えることになる。
Dialogue: 0,0:19:22.68,0:19:26.79,Default,,0000,0000,0000,, そして、君は死すべき存在ではない。
Dialogue: 0,0:19:27.84,0:19:31.67,Default,,0000,0000,0000,, 滅びの時を免れ、未来を与えられる\N生命体は一つしか選ばれないんだ。
Dialogue: 0,0:19:36.60,0:19:38.75,Default,,0000,0000,0000,, 君たちには未来が必要だ。
Dialogue: 0,0:19:40.88,0:19:44.31,Default,,0000,0000,0000,, ありがとう。\N君に逢えて、嬉しかったよ。
Dialogue: 0,0:21:08.84,0:21:14.31,Default,,0000,0000,0000,, カヲル君が好きだって言ってくれたんだ…
Dialogue: 0,0:21:16.56,0:21:22.51,Default,,0000,0000,0000,, 僕のこと…初めて…\N初めて人から好きだっていわれたんだ…
Dialogue: 0,0:21:22.92,0:21:25.99,Default,,0000,0000,0000,, 僕に似てたんだ…綾波にも…
Dialogue: 0,0:21:28.32,0:21:30.70,Default,,0000,0000,0000,, 好きだったんだ。
Dialogue: 0,0:21:31.12,0:21:34.63,Default,,0000,0000,0000,, 生き残るならカヲル君のほうだったんだ…
Dialogue: 0,0:21:35.04,0:21:39.79,Default,,0000,0000,0000,, 僕なんかより、彼のほうがずっといい人だったのに…
Dialogue: 0,0:21:40.20,0:21:42.55,Default,,0000,0000,0000,, カヲル君が生き残るべきだったんだ。
Dialogue: 0,0:21:42.96,0:21:46.58,Default,,0000,0000,0000,, 違うわ。生き残るのは生きる意志を持った者だけよ。
Dialogue: 0,0:21:48.12,0:21:53.27,Default,,0000,0000,0000,, 彼は死を望んだ。生きる意志を放棄して\N見せ掛けだけの希望にすがったのよ。
Dialogue: 0,0:21:53.68,0:21:56.99,Default,,0000,0000,0000,, シンジ君は悪くないわ。
Dialogue: 0,0:21:57.40,0:21:59.55,Default,,0000,0000,0000,, 冷たいね…ミサトさん…
Dialogue: 0,0:23:07.44,0:23:10.54,Default,,0000,0000,0000,, 最後の使徒は消えた。だが、シンジは苦悩する。
Dialogue: 0,0:23:10.75,0:23:15.39,Default,,0000,0000,0000,, そして、ミサト、アスカも心を暴露する。
Dialogue: 0,0:23:15.68,0:23:18.80,Default,,0000,0000,0000,, 人々に救いを求めながら、これも、\N終局のひとつの形であることを認めながら。
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0000,0000,0000,, | {
"pile_set_name": "Github"
} |
{
"sideEffects": [
"./init.js"
]
}
| {
"pile_set_name": "Github"
} |
//-*****************************************************************************
//
// Copyright (c) 2009-2011,
// Sony Pictures Imageworks Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic, nor the names of their 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.
//
//-*****************************************************************************
#include <boost/python/detail/wrap_python.hpp>
#include <Alembic/Abc/All.h>
#include <Alembic/AbcCoreHDF5/All.h>
#include <string>
#include <boost/python.hpp>
using namespace boost::python;
namespace Abc = Alembic::Abc;
//-*****************************************************************************
static boost::shared_ptr<Abc::IArchive> mkIArchive(const std::string &iName)
{
return boost::shared_ptr<Abc::IArchive>(
new Abc::IArchive(::Alembic::AbcCoreHDF5::ReadArchive(), iName));
}
//-*****************************************************************************
void register_iarchive()
{
class_<Abc::IArchive, boost::shared_ptr<Abc::IArchive> >("IArchive")
.def("__init__", make_constructor(mkIArchive),
"IArchive ctor\nFirst argument is the pathname to the .abc file to "
"open.")
.def("getName", &Abc::IArchive::getName)
.def("getTop", &Abc::IArchive::getTop,
with_custodian_and_ward_postcall<0, 1>())
.def("valid", &Abc::IArchive::valid)
.def("__nonzero__", &Abc::IArchive::valid)
.def("__str__", &Abc::IArchive::getName);
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
* Copyright 2009 Jerome Glisse.
*
* 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: Dave Airlie
* Alex Deucher
* Jerome Glisse
*/
#include <linux/console.h>
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
#include <drm/radeon_drm.h>
#include <linux/vgaarb.h>
#include "radeon_reg.h"
#include "radeon.h"
#include "radeon_asic.h"
#include "atom.h"
/*
* Registers accessors functions.
*/
/**
* radeon_invalid_rreg - dummy reg read function
*
* @rdev: radeon device pointer
* @reg: offset of register
*
* Dummy register read function. Used for register blocks
* that certain asics don't have (all asics).
* Returns the value in the register.
*/
static uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg)
{
DRM_ERROR("Invalid callback to read register 0x%04X\n", reg);
BUG_ON(1);
return 0;
}
/**
* radeon_invalid_wreg - dummy reg write function
*
* @rdev: radeon device pointer
* @reg: offset of register
* @v: value to write to the register
*
* Dummy register read function. Used for register blocks
* that certain asics don't have (all asics).
*/
static void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
{
DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n",
reg, v);
BUG_ON(1);
}
/**
* radeon_register_accessor_init - sets up the register accessor callbacks
*
* @rdev: radeon device pointer
*
* Sets up the register accessor callbacks for various register
* apertures. Not all asics have all apertures (all asics).
*/
static void radeon_register_accessor_init(struct radeon_device *rdev)
{
rdev->mc_rreg = &radeon_invalid_rreg;
rdev->mc_wreg = &radeon_invalid_wreg;
rdev->pll_rreg = &radeon_invalid_rreg;
rdev->pll_wreg = &radeon_invalid_wreg;
rdev->pciep_rreg = &radeon_invalid_rreg;
rdev->pciep_wreg = &radeon_invalid_wreg;
/* Don't change order as we are overridding accessor. */
if (rdev->family < CHIP_RV515) {
rdev->pcie_reg_mask = 0xff;
} else {
rdev->pcie_reg_mask = 0x7ff;
}
/* FIXME: not sure here */
if (rdev->family <= CHIP_R580) {
rdev->pll_rreg = &r100_pll_rreg;
rdev->pll_wreg = &r100_pll_wreg;
}
if (rdev->family >= CHIP_R420) {
rdev->mc_rreg = &r420_mc_rreg;
rdev->mc_wreg = &r420_mc_wreg;
}
if (rdev->family >= CHIP_RV515) {
rdev->mc_rreg = &rv515_mc_rreg;
rdev->mc_wreg = &rv515_mc_wreg;
}
if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
rdev->mc_rreg = &rs400_mc_rreg;
rdev->mc_wreg = &rs400_mc_wreg;
}
if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
rdev->mc_rreg = &rs690_mc_rreg;
rdev->mc_wreg = &rs690_mc_wreg;
}
if (rdev->family == CHIP_RS600) {
rdev->mc_rreg = &rs600_mc_rreg;
rdev->mc_wreg = &rs600_mc_wreg;
}
if (rdev->family == CHIP_RS780 || rdev->family == CHIP_RS880) {
rdev->mc_rreg = &rs780_mc_rreg;
rdev->mc_wreg = &rs780_mc_wreg;
}
if (rdev->family >= CHIP_BONAIRE) {
rdev->pciep_rreg = &cik_pciep_rreg;
rdev->pciep_wreg = &cik_pciep_wreg;
} else if (rdev->family >= CHIP_R600) {
rdev->pciep_rreg = &r600_pciep_rreg;
rdev->pciep_wreg = &r600_pciep_wreg;
}
}
static int radeon_invalid_get_allowed_info_register(struct radeon_device *rdev,
u32 reg, u32 *val)
{
return -EINVAL;
}
/* helper to disable agp */
/**
* radeon_agp_disable - AGP disable helper function
*
* @rdev: radeon device pointer
*
* Removes AGP flags and changes the gart callbacks on AGP
* cards when using the internal gart rather than AGP (all asics).
*/
void radeon_agp_disable(struct radeon_device *rdev)
{
rdev->flags &= ~RADEON_IS_AGP;
if (rdev->family >= CHIP_R600) {
DRM_INFO("Forcing AGP to PCIE mode\n");
rdev->flags |= RADEON_IS_PCIE;
} else if (rdev->family >= CHIP_RV515 ||
rdev->family == CHIP_RV380 ||
rdev->family == CHIP_RV410 ||
rdev->family == CHIP_R423) {
DRM_INFO("Forcing AGP to PCIE mode\n");
rdev->flags |= RADEON_IS_PCIE;
rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush;
rdev->asic->gart.get_page_entry = &rv370_pcie_gart_get_page_entry;
rdev->asic->gart.set_page = &rv370_pcie_gart_set_page;
} else {
DRM_INFO("Forcing AGP to PCI mode\n");
rdev->flags |= RADEON_IS_PCI;
rdev->asic->gart.tlb_flush = &r100_pci_gart_tlb_flush;
rdev->asic->gart.get_page_entry = &r100_pci_gart_get_page_entry;
rdev->asic->gart.set_page = &r100_pci_gart_set_page;
}
rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
}
/*
* ASIC
*/
static const struct radeon_asic_ring r100_gfx_ring = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r100_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
.cs_parse = &r100_cs_parse,
.ring_start = &r100_ring_start,
.ring_test = &r100_ring_test,
.ib_test = &r100_ib_test,
.is_lockup = &r100_gpu_is_lockup,
.get_rptr = &r100_gfx_get_rptr,
.get_wptr = &r100_gfx_get_wptr,
.set_wptr = &r100_gfx_set_wptr,
};
static struct radeon_asic r100_asic = {
.init = &r100_init,
.fini = &r100_fini,
.suspend = &r100_suspend,
.resume = &r100_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r100_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &r100_pci_gart_tlb_flush,
.get_page_entry = &r100_pci_gart_get_page_entry,
.set_page = &r100_pci_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r100_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &radeon_legacy_set_backlight_level,
.get_backlight_level = &radeon_legacy_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = NULL,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r100_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_legacy_get_engine_clock,
.set_engine_clock = &radeon_legacy_set_engine_clock,
.get_memory_clock = &radeon_legacy_get_memory_clock,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = &radeon_legacy_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static struct radeon_asic r200_asic = {
.init = &r100_init,
.fini = &r100_fini,
.suspend = &r100_suspend,
.resume = &r100_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r100_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &r100_pci_gart_tlb_flush,
.get_page_entry = &r100_pci_gart_get_page_entry,
.set_page = &r100_pci_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r100_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &radeon_legacy_set_backlight_level,
.get_backlight_level = &radeon_legacy_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r100_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_legacy_get_engine_clock,
.set_engine_clock = &radeon_legacy_set_engine_clock,
.get_memory_clock = &radeon_legacy_get_memory_clock,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = &radeon_legacy_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static const struct radeon_asic_ring r300_gfx_ring = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
.cs_parse = &r300_cs_parse,
.ring_start = &r300_ring_start,
.ring_test = &r100_ring_test,
.ib_test = &r100_ib_test,
.is_lockup = &r100_gpu_is_lockup,
.get_rptr = &r100_gfx_get_rptr,
.get_wptr = &r100_gfx_get_wptr,
.set_wptr = &r100_gfx_set_wptr,
};
static const struct radeon_asic_ring rv515_gfx_ring = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
.cs_parse = &r300_cs_parse,
.ring_start = &rv515_ring_start,
.ring_test = &r100_ring_test,
.ib_test = &r100_ib_test,
.is_lockup = &r100_gpu_is_lockup,
.get_rptr = &r100_gfx_get_rptr,
.get_wptr = &r100_gfx_get_wptr,
.set_wptr = &r100_gfx_set_wptr,
};
static struct radeon_asic r300_asic = {
.init = &r300_init,
.fini = &r300_fini,
.suspend = &r300_suspend,
.resume = &r300_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r300_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r300_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &r100_pci_gart_tlb_flush,
.get_page_entry = &r100_pci_gart_get_page_entry,
.set_page = &r100_pci_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &radeon_legacy_set_backlight_level,
.get_backlight_level = &radeon_legacy_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r100_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_legacy_get_engine_clock,
.set_engine_clock = &radeon_legacy_set_engine_clock,
.get_memory_clock = &radeon_legacy_get_memory_clock,
.set_memory_clock = NULL,
.get_pcie_lanes = &rv370_get_pcie_lanes,
.set_pcie_lanes = &rv370_set_pcie_lanes,
.set_clock_gating = &radeon_legacy_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static struct radeon_asic r300_asic_pcie = {
.init = &r300_init,
.fini = &r300_fini,
.suspend = &r300_suspend,
.resume = &r300_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r300_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r300_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rv370_pcie_gart_tlb_flush,
.get_page_entry = &rv370_pcie_gart_get_page_entry,
.set_page = &rv370_pcie_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &radeon_legacy_set_backlight_level,
.get_backlight_level = &radeon_legacy_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r100_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_legacy_get_engine_clock,
.set_engine_clock = &radeon_legacy_set_engine_clock,
.get_memory_clock = &radeon_legacy_get_memory_clock,
.set_memory_clock = NULL,
.get_pcie_lanes = &rv370_get_pcie_lanes,
.set_pcie_lanes = &rv370_set_pcie_lanes,
.set_clock_gating = &radeon_legacy_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static struct radeon_asic r420_asic = {
.init = &r420_init,
.fini = &r420_fini,
.suspend = &r420_suspend,
.resume = &r420_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r300_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r300_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rv370_pcie_gart_tlb_flush,
.get_page_entry = &rv370_pcie_gart_get_page_entry,
.set_page = &rv370_pcie_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r420_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &rv370_get_pcie_lanes,
.set_pcie_lanes = &rv370_set_pcie_lanes,
.set_clock_gating = &radeon_atom_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static struct radeon_asic rs400_asic = {
.init = &rs400_init,
.fini = &rs400_fini,
.suspend = &rs400_suspend,
.resume = &rs400_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &r300_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &rs400_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rs400_gart_tlb_flush,
.get_page_entry = &rs400_gart_get_page_entry,
.set_page = &rs400_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
.display = {
.bandwidth_update = &r100_bandwidth_update,
.get_vblank_counter = &r100_get_vblank_counter,
.wait_for_vblank = &r100_wait_for_vblank,
.set_backlight_level = &radeon_legacy_set_backlight_level,
.get_backlight_level = &radeon_legacy_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
.sense = &r100_hpd_sense,
.set_polarity = &r100_hpd_set_polarity,
},
.pm = {
.misc = &r100_pm_misc,
.prepare = &r100_pm_prepare,
.finish = &r100_pm_finish,
.init_profile = &r100_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_legacy_get_engine_clock,
.set_engine_clock = &radeon_legacy_set_engine_clock,
.get_memory_clock = &radeon_legacy_get_memory_clock,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = &radeon_legacy_set_clock_gating,
},
.pflip = {
.page_flip = &r100_page_flip,
.page_flip_pending = &r100_page_flip_pending,
},
};
static struct radeon_asic rs600_asic = {
.init = &rs600_init,
.fini = &rs600_fini,
.suspend = &rs600_suspend,
.resume = &rs600_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &rs600_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &rs600_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rs600_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &rs600_irq_set,
.process = &rs600_irq_process,
},
.display = {
.bandwidth_update = &rs600_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &rs600_hpd_init,
.fini = &rs600_hpd_fini,
.sense = &rs600_hpd_sense,
.set_polarity = &rs600_hpd_set_polarity,
},
.pm = {
.misc = &rs600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r420_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = &radeon_atom_set_clock_gating,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static struct radeon_asic rs690_asic = {
.init = &rs690_init,
.fini = &rs690_fini,
.suspend = &rs690_suspend,
.resume = &rs690_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &rs600_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &rs690_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rs400_gart_tlb_flush,
.get_page_entry = &rs400_gart_get_page_entry,
.set_page = &rs400_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r300_gfx_ring
},
.irq = {
.set = &rs600_irq_set,
.process = &rs600_irq_process,
},
.display = {
.get_vblank_counter = &rs600_get_vblank_counter,
.bandwidth_update = &rs690_bandwidth_update,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r200_copy_dma,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &rs600_hpd_init,
.fini = &rs600_hpd_fini,
.sense = &rs600_hpd_sense,
.set_polarity = &rs600_hpd_set_polarity,
},
.pm = {
.misc = &rs600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r420_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = &radeon_atom_set_clock_gating,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static struct radeon_asic rv515_asic = {
.init = &rv515_init,
.fini = &rv515_fini,
.suspend = &rv515_suspend,
.resume = &rv515_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &rs600_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &rv515_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rv370_pcie_gart_tlb_flush,
.get_page_entry = &rv370_pcie_gart_get_page_entry,
.set_page = &rv370_pcie_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &rv515_gfx_ring
},
.irq = {
.set = &rs600_irq_set,
.process = &rs600_irq_process,
},
.display = {
.get_vblank_counter = &rs600_get_vblank_counter,
.bandwidth_update = &rv515_bandwidth_update,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &rs600_hpd_init,
.fini = &rs600_hpd_fini,
.sense = &rs600_hpd_sense,
.set_polarity = &rs600_hpd_set_polarity,
},
.pm = {
.misc = &rs600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r420_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &rv370_get_pcie_lanes,
.set_pcie_lanes = &rv370_set_pcie_lanes,
.set_clock_gating = &radeon_atom_set_clock_gating,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static struct radeon_asic r520_asic = {
.init = &r520_init,
.fini = &rv515_fini,
.suspend = &rv515_suspend,
.resume = &r520_resume,
.vga_set_state = &r100_vga_set_state,
.asic_reset = &rs600_asic_reset,
.mmio_hdp_flush = NULL,
.gui_idle = &r100_gui_idle,
.mc_wait_for_idle = &r520_mc_wait_for_idle,
.get_allowed_info_register = radeon_invalid_get_allowed_info_register,
.gart = {
.tlb_flush = &rv370_pcie_gart_tlb_flush,
.get_page_entry = &rv370_pcie_gart_get_page_entry,
.set_page = &rv370_pcie_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &rv515_gfx_ring
},
.irq = {
.set = &rs600_irq_set,
.process = &rs600_irq_process,
},
.display = {
.bandwidth_update = &rv515_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r200_copy_dma,
.dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r100_set_surface_reg,
.clear_reg = r100_clear_surface_reg,
},
.hpd = {
.init = &rs600_hpd_init,
.fini = &rs600_hpd_fini,
.sense = &rs600_hpd_sense,
.set_polarity = &rs600_hpd_set_polarity,
},
.pm = {
.misc = &rs600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r420_pm_init_profile,
.get_dynpm_state = &r100_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &rv370_get_pcie_lanes,
.set_pcie_lanes = &rv370_set_pcie_lanes,
.set_clock_gating = &radeon_atom_set_clock_gating,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static const struct radeon_asic_ring r600_gfx_ring = {
.ib_execute = &r600_ring_ib_execute,
.emit_fence = &r600_fence_ring_emit,
.emit_semaphore = &r600_semaphore_ring_emit,
.cs_parse = &r600_cs_parse,
.ring_test = &r600_ring_test,
.ib_test = &r600_ib_test,
.is_lockup = &r600_gfx_is_lockup,
.get_rptr = &r600_gfx_get_rptr,
.get_wptr = &r600_gfx_get_wptr,
.set_wptr = &r600_gfx_set_wptr,
};
static const struct radeon_asic_ring r600_dma_ring = {
.ib_execute = &r600_dma_ring_ib_execute,
.emit_fence = &r600_dma_fence_ring_emit,
.emit_semaphore = &r600_dma_semaphore_ring_emit,
.cs_parse = &r600_dma_cs_parse,
.ring_test = &r600_dma_ring_test,
.ib_test = &r600_dma_ib_test,
.is_lockup = &r600_dma_is_lockup,
.get_rptr = &r600_dma_get_rptr,
.get_wptr = &r600_dma_get_wptr,
.set_wptr = &r600_dma_set_wptr,
};
static struct radeon_asic r600_asic = {
.init = &r600_init,
.fini = &r600_fini,
.suspend = &r600_suspend,
.resume = &r600_resume,
.vga_set_state = &r600_vga_set_state,
.asic_reset = &r600_asic_reset,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = r600_get_allowed_info_register,
.gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r600_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &r600_dma_ring,
},
.irq = {
.set = &r600_irq_set,
.process = &r600_irq_process,
},
.display = {
.bandwidth_update = &rv515_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r600_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &r600_copy_cpdma,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &r600_hpd_init,
.fini = &r600_hpd_fini,
.sense = &r600_hpd_sense,
.set_polarity = &r600_hpd_set_polarity,
},
.pm = {
.misc = &r600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r600_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.get_temperature = &rv6xx_get_temp,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static const struct radeon_asic_ring rv6xx_uvd_ring = {
.ib_execute = &uvd_v1_0_ib_execute,
.emit_fence = &uvd_v1_0_fence_emit,
.emit_semaphore = &uvd_v1_0_semaphore_emit,
.cs_parse = &radeon_uvd_cs_parse,
.ring_test = &uvd_v1_0_ring_test,
.ib_test = &uvd_v1_0_ib_test,
.is_lockup = &radeon_ring_test_lockup,
.get_rptr = &uvd_v1_0_get_rptr,
.get_wptr = &uvd_v1_0_get_wptr,
.set_wptr = &uvd_v1_0_set_wptr,
};
static struct radeon_asic rv6xx_asic = {
.init = &r600_init,
.fini = &r600_fini,
.suspend = &r600_suspend,
.resume = &r600_resume,
.vga_set_state = &r600_vga_set_state,
.asic_reset = &r600_asic_reset,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = r600_get_allowed_info_register,
.gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r600_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &r600_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv6xx_uvd_ring,
},
.irq = {
.set = &r600_irq_set,
.process = &r600_irq_process,
},
.display = {
.bandwidth_update = &rv515_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r600_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &r600_copy_cpdma,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &r600_hpd_init,
.fini = &r600_hpd_fini,
.sense = &r600_hpd_sense,
.set_polarity = &r600_hpd_set_polarity,
},
.pm = {
.misc = &r600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r600_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.get_temperature = &rv6xx_get_temp,
.set_uvd_clocks = &r600_set_uvd_clocks,
},
.dpm = {
.init = &rv6xx_dpm_init,
.setup_asic = &rv6xx_setup_asic,
.enable = &rv6xx_dpm_enable,
.late_enable = &r600_dpm_late_enable,
.disable = &rv6xx_dpm_disable,
.pre_set_power_state = &r600_dpm_pre_set_power_state,
.set_power_state = &rv6xx_dpm_set_power_state,
.post_set_power_state = &r600_dpm_post_set_power_state,
.display_configuration_changed = &rv6xx_dpm_display_configuration_changed,
.fini = &rv6xx_dpm_fini,
.get_sclk = &rv6xx_dpm_get_sclk,
.get_mclk = &rv6xx_dpm_get_mclk,
.print_power_state = &rv6xx_dpm_print_power_state,
.debugfs_print_current_performance_level = &rv6xx_dpm_debugfs_print_current_performance_level,
.force_performance_level = &rv6xx_dpm_force_performance_level,
.get_current_sclk = &rv6xx_dpm_get_current_sclk,
.get_current_mclk = &rv6xx_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static struct radeon_asic rs780_asic = {
.init = &r600_init,
.fini = &r600_fini,
.suspend = &r600_suspend,
.resume = &r600_resume,
.vga_set_state = &r600_vga_set_state,
.asic_reset = &r600_asic_reset,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = r600_get_allowed_info_register,
.gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r600_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &r600_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv6xx_uvd_ring,
},
.irq = {
.set = &r600_irq_set,
.process = &r600_irq_process,
},
.display = {
.bandwidth_update = &rs690_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &r600_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &r600_copy_cpdma,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &r600_hpd_init,
.fini = &r600_hpd_fini,
.sense = &r600_hpd_sense,
.set_polarity = &r600_hpd_set_polarity,
},
.pm = {
.misc = &r600_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &rs780_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = NULL,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = NULL,
.get_temperature = &rv6xx_get_temp,
.set_uvd_clocks = &r600_set_uvd_clocks,
},
.dpm = {
.init = &rs780_dpm_init,
.setup_asic = &rs780_dpm_setup_asic,
.enable = &rs780_dpm_enable,
.late_enable = &r600_dpm_late_enable,
.disable = &rs780_dpm_disable,
.pre_set_power_state = &r600_dpm_pre_set_power_state,
.set_power_state = &rs780_dpm_set_power_state,
.post_set_power_state = &r600_dpm_post_set_power_state,
.display_configuration_changed = &rs780_dpm_display_configuration_changed,
.fini = &rs780_dpm_fini,
.get_sclk = &rs780_dpm_get_sclk,
.get_mclk = &rs780_dpm_get_mclk,
.print_power_state = &rs780_dpm_print_power_state,
.debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level,
.force_performance_level = &rs780_dpm_force_performance_level,
.get_current_sclk = &rs780_dpm_get_current_sclk,
.get_current_mclk = &rs780_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &rs600_page_flip,
.page_flip_pending = &rs600_page_flip_pending,
},
};
static const struct radeon_asic_ring rv770_uvd_ring = {
.ib_execute = &uvd_v1_0_ib_execute,
.emit_fence = &uvd_v2_2_fence_emit,
.emit_semaphore = &uvd_v2_2_semaphore_emit,
.cs_parse = &radeon_uvd_cs_parse,
.ring_test = &uvd_v1_0_ring_test,
.ib_test = &uvd_v1_0_ib_test,
.is_lockup = &radeon_ring_test_lockup,
.get_rptr = &uvd_v1_0_get_rptr,
.get_wptr = &uvd_v1_0_get_wptr,
.set_wptr = &uvd_v1_0_set_wptr,
};
static struct radeon_asic rv770_asic = {
.init = &rv770_init,
.fini = &rv770_fini,
.suspend = &rv770_suspend,
.resume = &rv770_resume,
.asic_reset = &r600_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = r600_get_allowed_info_register,
.gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &r600_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &r600_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv770_uvd_ring,
},
.irq = {
.set = &r600_irq_set,
.process = &r600_irq_process,
},
.display = {
.bandwidth_update = &rv515_bandwidth_update,
.get_vblank_counter = &rs600_get_vblank_counter,
.wait_for_vblank = &avivo_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &rv770_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &rv770_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &r600_hpd_init,
.fini = &r600_hpd_fini,
.sense = &r600_hpd_sense,
.set_polarity = &r600_hpd_set_polarity,
},
.pm = {
.misc = &rv770_pm_misc,
.prepare = &rs600_pm_prepare,
.finish = &rs600_pm_finish,
.init_profile = &r600_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = &radeon_atom_set_clock_gating,
.set_uvd_clocks = &rv770_set_uvd_clocks,
.get_temperature = &rv770_get_temp,
},
.dpm = {
.init = &rv770_dpm_init,
.setup_asic = &rv770_dpm_setup_asic,
.enable = &rv770_dpm_enable,
.late_enable = &rv770_dpm_late_enable,
.disable = &rv770_dpm_disable,
.pre_set_power_state = &r600_dpm_pre_set_power_state,
.set_power_state = &rv770_dpm_set_power_state,
.post_set_power_state = &r600_dpm_post_set_power_state,
.display_configuration_changed = &rv770_dpm_display_configuration_changed,
.fini = &rv770_dpm_fini,
.get_sclk = &rv770_dpm_get_sclk,
.get_mclk = &rv770_dpm_get_mclk,
.print_power_state = &rv770_dpm_print_power_state,
.debugfs_print_current_performance_level = &rv770_dpm_debugfs_print_current_performance_level,
.force_performance_level = &rv770_dpm_force_performance_level,
.vblank_too_short = &rv770_dpm_vblank_too_short,
.get_current_sclk = &rv770_dpm_get_current_sclk,
.get_current_mclk = &rv770_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &rv770_page_flip,
.page_flip_pending = &rv770_page_flip_pending,
},
};
static const struct radeon_asic_ring evergreen_gfx_ring = {
.ib_execute = &evergreen_ring_ib_execute,
.emit_fence = &r600_fence_ring_emit,
.emit_semaphore = &r600_semaphore_ring_emit,
.cs_parse = &evergreen_cs_parse,
.ring_test = &r600_ring_test,
.ib_test = &r600_ib_test,
.is_lockup = &evergreen_gfx_is_lockup,
.get_rptr = &r600_gfx_get_rptr,
.get_wptr = &r600_gfx_get_wptr,
.set_wptr = &r600_gfx_set_wptr,
};
static const struct radeon_asic_ring evergreen_dma_ring = {
.ib_execute = &evergreen_dma_ring_ib_execute,
.emit_fence = &evergreen_dma_fence_ring_emit,
.emit_semaphore = &r600_dma_semaphore_ring_emit,
.cs_parse = &evergreen_dma_cs_parse,
.ring_test = &r600_dma_ring_test,
.ib_test = &r600_dma_ib_test,
.is_lockup = &evergreen_dma_is_lockup,
.get_rptr = &r600_dma_get_rptr,
.get_wptr = &r600_dma_get_wptr,
.set_wptr = &r600_dma_set_wptr,
};
static struct radeon_asic evergreen_asic = {
.init = &evergreen_init,
.fini = &evergreen_fini,
.suspend = &evergreen_suspend,
.resume = &evergreen_resume,
.asic_reset = &evergreen_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = evergreen_get_allowed_info_register,
.gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &evergreen_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &evergreen_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv770_uvd_ring,
},
.irq = {
.set = &evergreen_irq_set,
.process = &evergreen_irq_process,
},
.display = {
.bandwidth_update = &evergreen_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &evergreen_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &evergreen_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &r600_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.set_uvd_clocks = &evergreen_set_uvd_clocks,
.get_temperature = &evergreen_get_temp,
},
.dpm = {
.init = &cypress_dpm_init,
.setup_asic = &cypress_dpm_setup_asic,
.enable = &cypress_dpm_enable,
.late_enable = &rv770_dpm_late_enable,
.disable = &cypress_dpm_disable,
.pre_set_power_state = &r600_dpm_pre_set_power_state,
.set_power_state = &cypress_dpm_set_power_state,
.post_set_power_state = &r600_dpm_post_set_power_state,
.display_configuration_changed = &cypress_dpm_display_configuration_changed,
.fini = &cypress_dpm_fini,
.get_sclk = &rv770_dpm_get_sclk,
.get_mclk = &rv770_dpm_get_mclk,
.print_power_state = &rv770_dpm_print_power_state,
.debugfs_print_current_performance_level = &rv770_dpm_debugfs_print_current_performance_level,
.force_performance_level = &rv770_dpm_force_performance_level,
.vblank_too_short = &cypress_dpm_vblank_too_short,
.get_current_sclk = &rv770_dpm_get_current_sclk,
.get_current_mclk = &rv770_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static struct radeon_asic sumo_asic = {
.init = &evergreen_init,
.fini = &evergreen_fini,
.suspend = &evergreen_suspend,
.resume = &evergreen_resume,
.asic_reset = &evergreen_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = evergreen_get_allowed_info_register,
.gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &evergreen_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &evergreen_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv770_uvd_ring,
},
.irq = {
.set = &evergreen_irq_set,
.process = &evergreen_irq_process,
},
.display = {
.bandwidth_update = &evergreen_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &evergreen_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &evergreen_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &sumo_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = NULL,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = NULL,
.set_uvd_clocks = &sumo_set_uvd_clocks,
.get_temperature = &sumo_get_temp,
},
.dpm = {
.init = &sumo_dpm_init,
.setup_asic = &sumo_dpm_setup_asic,
.enable = &sumo_dpm_enable,
.late_enable = &sumo_dpm_late_enable,
.disable = &sumo_dpm_disable,
.pre_set_power_state = &sumo_dpm_pre_set_power_state,
.set_power_state = &sumo_dpm_set_power_state,
.post_set_power_state = &sumo_dpm_post_set_power_state,
.display_configuration_changed = &sumo_dpm_display_configuration_changed,
.fini = &sumo_dpm_fini,
.get_sclk = &sumo_dpm_get_sclk,
.get_mclk = &sumo_dpm_get_mclk,
.print_power_state = &sumo_dpm_print_power_state,
.debugfs_print_current_performance_level = &sumo_dpm_debugfs_print_current_performance_level,
.force_performance_level = &sumo_dpm_force_performance_level,
.get_current_sclk = &sumo_dpm_get_current_sclk,
.get_current_mclk = &sumo_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static struct radeon_asic btc_asic = {
.init = &evergreen_init,
.fini = &evergreen_fini,
.suspend = &evergreen_suspend,
.resume = &evergreen_resume,
.asic_reset = &evergreen_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = evergreen_get_allowed_info_register,
.gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &evergreen_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &evergreen_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &rv770_uvd_ring,
},
.irq = {
.set = &evergreen_irq_set,
.process = &evergreen_irq_process,
},
.display = {
.bandwidth_update = &evergreen_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &evergreen_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &evergreen_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &btc_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.set_uvd_clocks = &evergreen_set_uvd_clocks,
.get_temperature = &evergreen_get_temp,
},
.dpm = {
.init = &btc_dpm_init,
.setup_asic = &btc_dpm_setup_asic,
.enable = &btc_dpm_enable,
.late_enable = &rv770_dpm_late_enable,
.disable = &btc_dpm_disable,
.pre_set_power_state = &btc_dpm_pre_set_power_state,
.set_power_state = &btc_dpm_set_power_state,
.post_set_power_state = &btc_dpm_post_set_power_state,
.display_configuration_changed = &cypress_dpm_display_configuration_changed,
.fini = &btc_dpm_fini,
.get_sclk = &btc_dpm_get_sclk,
.get_mclk = &btc_dpm_get_mclk,
.print_power_state = &rv770_dpm_print_power_state,
.debugfs_print_current_performance_level = &btc_dpm_debugfs_print_current_performance_level,
.force_performance_level = &rv770_dpm_force_performance_level,
.vblank_too_short = &btc_dpm_vblank_too_short,
.get_current_sclk = &btc_dpm_get_current_sclk,
.get_current_mclk = &btc_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static const struct radeon_asic_ring cayman_gfx_ring = {
.ib_execute = &cayman_ring_ib_execute,
.ib_parse = &evergreen_ib_parse,
.emit_fence = &cayman_fence_ring_emit,
.emit_semaphore = &r600_semaphore_ring_emit,
.cs_parse = &evergreen_cs_parse,
.ring_test = &r600_ring_test,
.ib_test = &r600_ib_test,
.is_lockup = &cayman_gfx_is_lockup,
.vm_flush = &cayman_vm_flush,
.get_rptr = &cayman_gfx_get_rptr,
.get_wptr = &cayman_gfx_get_wptr,
.set_wptr = &cayman_gfx_set_wptr,
};
static const struct radeon_asic_ring cayman_dma_ring = {
.ib_execute = &cayman_dma_ring_ib_execute,
.ib_parse = &evergreen_dma_ib_parse,
.emit_fence = &evergreen_dma_fence_ring_emit,
.emit_semaphore = &r600_dma_semaphore_ring_emit,
.cs_parse = &evergreen_dma_cs_parse,
.ring_test = &r600_dma_ring_test,
.ib_test = &r600_dma_ib_test,
.is_lockup = &cayman_dma_is_lockup,
.vm_flush = &cayman_dma_vm_flush,
.get_rptr = &cayman_dma_get_rptr,
.get_wptr = &cayman_dma_get_wptr,
.set_wptr = &cayman_dma_set_wptr
};
static const struct radeon_asic_ring cayman_uvd_ring = {
.ib_execute = &uvd_v1_0_ib_execute,
.emit_fence = &uvd_v2_2_fence_emit,
.emit_semaphore = &uvd_v3_1_semaphore_emit,
.cs_parse = &radeon_uvd_cs_parse,
.ring_test = &uvd_v1_0_ring_test,
.ib_test = &uvd_v1_0_ib_test,
.is_lockup = &radeon_ring_test_lockup,
.get_rptr = &uvd_v1_0_get_rptr,
.get_wptr = &uvd_v1_0_get_wptr,
.set_wptr = &uvd_v1_0_set_wptr,
};
static struct radeon_asic cayman_asic = {
.init = &cayman_init,
.fini = &cayman_fini,
.suspend = &cayman_suspend,
.resume = &cayman_resume,
.asic_reset = &cayman_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = cayman_get_allowed_info_register,
.gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.vm = {
.init = &cayman_vm_init,
.fini = &cayman_vm_fini,
.copy_pages = &cayman_dma_vm_copy_pages,
.write_pages = &cayman_dma_vm_write_pages,
.set_pages = &cayman_dma_vm_set_pages,
.pad_ib = &cayman_dma_vm_pad_ib,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &cayman_gfx_ring,
[CAYMAN_RING_TYPE_CP1_INDEX] = &cayman_gfx_ring,
[CAYMAN_RING_TYPE_CP2_INDEX] = &cayman_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &cayman_dma_ring,
[CAYMAN_RING_TYPE_DMA1_INDEX] = &cayman_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &cayman_uvd_ring,
},
.irq = {
.set = &evergreen_irq_set,
.process = &evergreen_irq_process,
},
.display = {
.bandwidth_update = &evergreen_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &evergreen_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &evergreen_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &btc_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.set_uvd_clocks = &evergreen_set_uvd_clocks,
.get_temperature = &evergreen_get_temp,
},
.dpm = {
.init = &ni_dpm_init,
.setup_asic = &ni_dpm_setup_asic,
.enable = &ni_dpm_enable,
.late_enable = &rv770_dpm_late_enable,
.disable = &ni_dpm_disable,
.pre_set_power_state = &ni_dpm_pre_set_power_state,
.set_power_state = &ni_dpm_set_power_state,
.post_set_power_state = &ni_dpm_post_set_power_state,
.display_configuration_changed = &cypress_dpm_display_configuration_changed,
.fini = &ni_dpm_fini,
.get_sclk = &ni_dpm_get_sclk,
.get_mclk = &ni_dpm_get_mclk,
.print_power_state = &ni_dpm_print_power_state,
.debugfs_print_current_performance_level = &ni_dpm_debugfs_print_current_performance_level,
.force_performance_level = &ni_dpm_force_performance_level,
.vblank_too_short = &ni_dpm_vblank_too_short,
.get_current_sclk = &ni_dpm_get_current_sclk,
.get_current_mclk = &ni_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static const struct radeon_asic_ring trinity_vce_ring = {
.ib_execute = &radeon_vce_ib_execute,
.emit_fence = &radeon_vce_fence_emit,
.emit_semaphore = &radeon_vce_semaphore_emit,
.cs_parse = &radeon_vce_cs_parse,
.ring_test = &radeon_vce_ring_test,
.ib_test = &radeon_vce_ib_test,
.is_lockup = &radeon_ring_test_lockup,
.get_rptr = &vce_v1_0_get_rptr,
.get_wptr = &vce_v1_0_get_wptr,
.set_wptr = &vce_v1_0_set_wptr,
};
static struct radeon_asic trinity_asic = {
.init = &cayman_init,
.fini = &cayman_fini,
.suspend = &cayman_suspend,
.resume = &cayman_resume,
.asic_reset = &cayman_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.get_allowed_info_register = cayman_get_allowed_info_register,
.gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.vm = {
.init = &cayman_vm_init,
.fini = &cayman_vm_fini,
.copy_pages = &cayman_dma_vm_copy_pages,
.write_pages = &cayman_dma_vm_write_pages,
.set_pages = &cayman_dma_vm_set_pages,
.pad_ib = &cayman_dma_vm_pad_ib,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &cayman_gfx_ring,
[CAYMAN_RING_TYPE_CP1_INDEX] = &cayman_gfx_ring,
[CAYMAN_RING_TYPE_CP2_INDEX] = &cayman_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &cayman_dma_ring,
[CAYMAN_RING_TYPE_DMA1_INDEX] = &cayman_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &cayman_uvd_ring,
[TN_RING_TYPE_VCE1_INDEX] = &trinity_vce_ring,
[TN_RING_TYPE_VCE2_INDEX] = &trinity_vce_ring,
},
.irq = {
.set = &evergreen_irq_set,
.process = &evergreen_irq_process,
},
.display = {
.bandwidth_update = &dce6_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &evergreen_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &evergreen_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &sumo_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = NULL,
.set_memory_clock = NULL,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = NULL,
.set_uvd_clocks = &sumo_set_uvd_clocks,
.set_vce_clocks = &tn_set_vce_clocks,
.get_temperature = &tn_get_temp,
},
.dpm = {
.init = &trinity_dpm_init,
.setup_asic = &trinity_dpm_setup_asic,
.enable = &trinity_dpm_enable,
.late_enable = &trinity_dpm_late_enable,
.disable = &trinity_dpm_disable,
.pre_set_power_state = &trinity_dpm_pre_set_power_state,
.set_power_state = &trinity_dpm_set_power_state,
.post_set_power_state = &trinity_dpm_post_set_power_state,
.display_configuration_changed = &trinity_dpm_display_configuration_changed,
.fini = &trinity_dpm_fini,
.get_sclk = &trinity_dpm_get_sclk,
.get_mclk = &trinity_dpm_get_mclk,
.print_power_state = &trinity_dpm_print_power_state,
.debugfs_print_current_performance_level = &trinity_dpm_debugfs_print_current_performance_level,
.force_performance_level = &trinity_dpm_force_performance_level,
.enable_bapm = &trinity_dpm_enable_bapm,
.get_current_sclk = &trinity_dpm_get_current_sclk,
.get_current_mclk = &trinity_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static const struct radeon_asic_ring si_gfx_ring = {
.ib_execute = &si_ring_ib_execute,
.ib_parse = &si_ib_parse,
.emit_fence = &si_fence_ring_emit,
.emit_semaphore = &r600_semaphore_ring_emit,
.cs_parse = NULL,
.ring_test = &r600_ring_test,
.ib_test = &r600_ib_test,
.is_lockup = &si_gfx_is_lockup,
.vm_flush = &si_vm_flush,
.get_rptr = &cayman_gfx_get_rptr,
.get_wptr = &cayman_gfx_get_wptr,
.set_wptr = &cayman_gfx_set_wptr,
};
static const struct radeon_asic_ring si_dma_ring = {
.ib_execute = &cayman_dma_ring_ib_execute,
.ib_parse = &evergreen_dma_ib_parse,
.emit_fence = &evergreen_dma_fence_ring_emit,
.emit_semaphore = &r600_dma_semaphore_ring_emit,
.cs_parse = NULL,
.ring_test = &r600_dma_ring_test,
.ib_test = &r600_dma_ib_test,
.is_lockup = &si_dma_is_lockup,
.vm_flush = &si_dma_vm_flush,
.get_rptr = &cayman_dma_get_rptr,
.get_wptr = &cayman_dma_get_wptr,
.set_wptr = &cayman_dma_set_wptr,
};
static struct radeon_asic si_asic = {
.init = &si_init,
.fini = &si_fini,
.suspend = &si_suspend,
.resume = &si_resume,
.asic_reset = &si_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &si_get_xclk,
.get_gpu_clock_counter = &si_get_gpu_clock_counter,
.get_allowed_info_register = si_get_allowed_info_register,
.gart = {
.tlb_flush = &si_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.vm = {
.init = &si_vm_init,
.fini = &si_vm_fini,
.copy_pages = &si_dma_vm_copy_pages,
.write_pages = &si_dma_vm_write_pages,
.set_pages = &si_dma_vm_set_pages,
.pad_ib = &cayman_dma_vm_pad_ib,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &si_gfx_ring,
[CAYMAN_RING_TYPE_CP1_INDEX] = &si_gfx_ring,
[CAYMAN_RING_TYPE_CP2_INDEX] = &si_gfx_ring,
[R600_RING_TYPE_DMA_INDEX] = &si_dma_ring,
[CAYMAN_RING_TYPE_DMA1_INDEX] = &si_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &cayman_uvd_ring,
[TN_RING_TYPE_VCE1_INDEX] = &trinity_vce_ring,
[TN_RING_TYPE_VCE2_INDEX] = &trinity_vce_ring,
},
.irq = {
.set = &si_irq_set,
.process = &si_irq_process,
},
.display = {
.bandwidth_update = &dce6_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &r600_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &si_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &si_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &sumo_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = &r600_get_pcie_lanes,
.set_pcie_lanes = &r600_set_pcie_lanes,
.set_clock_gating = NULL,
.set_uvd_clocks = &si_set_uvd_clocks,
.set_vce_clocks = &si_set_vce_clocks,
.get_temperature = &si_get_temp,
},
.dpm = {
.init = &si_dpm_init,
.setup_asic = &si_dpm_setup_asic,
.enable = &si_dpm_enable,
.late_enable = &si_dpm_late_enable,
.disable = &si_dpm_disable,
.pre_set_power_state = &si_dpm_pre_set_power_state,
.set_power_state = &si_dpm_set_power_state,
.post_set_power_state = &si_dpm_post_set_power_state,
.display_configuration_changed = &si_dpm_display_configuration_changed,
.fini = &si_dpm_fini,
.get_sclk = &ni_dpm_get_sclk,
.get_mclk = &ni_dpm_get_mclk,
.print_power_state = &ni_dpm_print_power_state,
.debugfs_print_current_performance_level = &si_dpm_debugfs_print_current_performance_level,
.force_performance_level = &si_dpm_force_performance_level,
.vblank_too_short = &ni_dpm_vblank_too_short,
.fan_ctrl_set_mode = &si_fan_ctrl_set_mode,
.fan_ctrl_get_mode = &si_fan_ctrl_get_mode,
.get_fan_speed_percent = &si_fan_ctrl_get_fan_speed_percent,
.set_fan_speed_percent = &si_fan_ctrl_set_fan_speed_percent,
.get_current_sclk = &si_dpm_get_current_sclk,
.get_current_mclk = &si_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static const struct radeon_asic_ring ci_gfx_ring = {
.ib_execute = &cik_ring_ib_execute,
.ib_parse = &cik_ib_parse,
.emit_fence = &cik_fence_gfx_ring_emit,
.emit_semaphore = &cik_semaphore_ring_emit,
.cs_parse = NULL,
.ring_test = &cik_ring_test,
.ib_test = &cik_ib_test,
.is_lockup = &cik_gfx_is_lockup,
.vm_flush = &cik_vm_flush,
.get_rptr = &cik_gfx_get_rptr,
.get_wptr = &cik_gfx_get_wptr,
.set_wptr = &cik_gfx_set_wptr,
};
static const struct radeon_asic_ring ci_cp_ring = {
.ib_execute = &cik_ring_ib_execute,
.ib_parse = &cik_ib_parse,
.emit_fence = &cik_fence_compute_ring_emit,
.emit_semaphore = &cik_semaphore_ring_emit,
.cs_parse = NULL,
.ring_test = &cik_ring_test,
.ib_test = &cik_ib_test,
.is_lockup = &cik_gfx_is_lockup,
.vm_flush = &cik_vm_flush,
.get_rptr = &cik_compute_get_rptr,
.get_wptr = &cik_compute_get_wptr,
.set_wptr = &cik_compute_set_wptr,
};
static const struct radeon_asic_ring ci_dma_ring = {
.ib_execute = &cik_sdma_ring_ib_execute,
.ib_parse = &cik_ib_parse,
.emit_fence = &cik_sdma_fence_ring_emit,
.emit_semaphore = &cik_sdma_semaphore_ring_emit,
.cs_parse = NULL,
.ring_test = &cik_sdma_ring_test,
.ib_test = &cik_sdma_ib_test,
.is_lockup = &cik_sdma_is_lockup,
.vm_flush = &cik_dma_vm_flush,
.get_rptr = &cik_sdma_get_rptr,
.get_wptr = &cik_sdma_get_wptr,
.set_wptr = &cik_sdma_set_wptr,
};
static const struct radeon_asic_ring ci_vce_ring = {
.ib_execute = &radeon_vce_ib_execute,
.emit_fence = &radeon_vce_fence_emit,
.emit_semaphore = &radeon_vce_semaphore_emit,
.cs_parse = &radeon_vce_cs_parse,
.ring_test = &radeon_vce_ring_test,
.ib_test = &radeon_vce_ib_test,
.is_lockup = &radeon_ring_test_lockup,
.get_rptr = &vce_v1_0_get_rptr,
.get_wptr = &vce_v1_0_get_wptr,
.set_wptr = &vce_v1_0_set_wptr,
};
static struct radeon_asic ci_asic = {
.init = &cik_init,
.fini = &cik_fini,
.suspend = &cik_suspend,
.resume = &cik_resume,
.asic_reset = &cik_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = &r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &cik_get_xclk,
.get_gpu_clock_counter = &cik_get_gpu_clock_counter,
.get_allowed_info_register = cik_get_allowed_info_register,
.gart = {
.tlb_flush = &cik_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.vm = {
.init = &cik_vm_init,
.fini = &cik_vm_fini,
.copy_pages = &cik_sdma_vm_copy_pages,
.write_pages = &cik_sdma_vm_write_pages,
.set_pages = &cik_sdma_vm_set_pages,
.pad_ib = &cik_sdma_vm_pad_ib,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &ci_gfx_ring,
[CAYMAN_RING_TYPE_CP1_INDEX] = &ci_cp_ring,
[CAYMAN_RING_TYPE_CP2_INDEX] = &ci_cp_ring,
[R600_RING_TYPE_DMA_INDEX] = &ci_dma_ring,
[CAYMAN_RING_TYPE_DMA1_INDEX] = &ci_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &cayman_uvd_ring,
[TN_RING_TYPE_VCE1_INDEX] = &ci_vce_ring,
[TN_RING_TYPE_VCE2_INDEX] = &ci_vce_ring,
},
.irq = {
.set = &cik_irq_set,
.process = &cik_irq_process,
},
.display = {
.bandwidth_update = &dce8_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &cik_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &cik_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &cik_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &sumo_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = NULL,
.set_uvd_clocks = &cik_set_uvd_clocks,
.set_vce_clocks = &cik_set_vce_clocks,
.get_temperature = &ci_get_temp,
},
.dpm = {
.init = &ci_dpm_init,
.setup_asic = &ci_dpm_setup_asic,
.enable = &ci_dpm_enable,
.late_enable = &ci_dpm_late_enable,
.disable = &ci_dpm_disable,
.pre_set_power_state = &ci_dpm_pre_set_power_state,
.set_power_state = &ci_dpm_set_power_state,
.post_set_power_state = &ci_dpm_post_set_power_state,
.display_configuration_changed = &ci_dpm_display_configuration_changed,
.fini = &ci_dpm_fini,
.get_sclk = &ci_dpm_get_sclk,
.get_mclk = &ci_dpm_get_mclk,
.print_power_state = &ci_dpm_print_power_state,
.debugfs_print_current_performance_level = &ci_dpm_debugfs_print_current_performance_level,
.force_performance_level = &ci_dpm_force_performance_level,
.vblank_too_short = &ci_dpm_vblank_too_short,
.powergate_uvd = &ci_dpm_powergate_uvd,
.fan_ctrl_set_mode = &ci_fan_ctrl_set_mode,
.fan_ctrl_get_mode = &ci_fan_ctrl_get_mode,
.get_fan_speed_percent = &ci_fan_ctrl_get_fan_speed_percent,
.set_fan_speed_percent = &ci_fan_ctrl_set_fan_speed_percent,
.get_current_sclk = &ci_dpm_get_current_sclk,
.get_current_mclk = &ci_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
static struct radeon_asic kv_asic = {
.init = &cik_init,
.fini = &cik_fini,
.suspend = &cik_suspend,
.resume = &cik_resume,
.asic_reset = &cik_asic_reset,
.vga_set_state = &r600_vga_set_state,
.mmio_hdp_flush = &r600_mmio_hdp_flush,
.gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &cik_get_xclk,
.get_gpu_clock_counter = &cik_get_gpu_clock_counter,
.get_allowed_info_register = cik_get_allowed_info_register,
.gart = {
.tlb_flush = &cik_pcie_gart_tlb_flush,
.get_page_entry = &rs600_gart_get_page_entry,
.set_page = &rs600_gart_set_page,
},
.vm = {
.init = &cik_vm_init,
.fini = &cik_vm_fini,
.copy_pages = &cik_sdma_vm_copy_pages,
.write_pages = &cik_sdma_vm_write_pages,
.set_pages = &cik_sdma_vm_set_pages,
.pad_ib = &cik_sdma_vm_pad_ib,
},
.ring = {
[RADEON_RING_TYPE_GFX_INDEX] = &ci_gfx_ring,
[CAYMAN_RING_TYPE_CP1_INDEX] = &ci_cp_ring,
[CAYMAN_RING_TYPE_CP2_INDEX] = &ci_cp_ring,
[R600_RING_TYPE_DMA_INDEX] = &ci_dma_ring,
[CAYMAN_RING_TYPE_DMA1_INDEX] = &ci_dma_ring,
[R600_RING_TYPE_UVD_INDEX] = &cayman_uvd_ring,
[TN_RING_TYPE_VCE1_INDEX] = &ci_vce_ring,
[TN_RING_TYPE_VCE2_INDEX] = &ci_vce_ring,
},
.irq = {
.set = &cik_irq_set,
.process = &cik_irq_process,
},
.display = {
.bandwidth_update = &dce8_bandwidth_update,
.get_vblank_counter = &evergreen_get_vblank_counter,
.wait_for_vblank = &dce4_wait_for_vblank,
.set_backlight_level = &atombios_set_backlight_level,
.get_backlight_level = &atombios_get_backlight_level,
},
.copy = {
.blit = &cik_copy_cpdma,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
.dma = &cik_copy_dma,
.dma_ring_index = R600_RING_TYPE_DMA_INDEX,
.copy = &cik_copy_dma,
.copy_ring_index = R600_RING_TYPE_DMA_INDEX,
},
.surface = {
.set_reg = r600_set_surface_reg,
.clear_reg = r600_clear_surface_reg,
},
.hpd = {
.init = &evergreen_hpd_init,
.fini = &evergreen_hpd_fini,
.sense = &evergreen_hpd_sense,
.set_polarity = &evergreen_hpd_set_polarity,
},
.pm = {
.misc = &evergreen_pm_misc,
.prepare = &evergreen_pm_prepare,
.finish = &evergreen_pm_finish,
.init_profile = &sumo_pm_init_profile,
.get_dynpm_state = &r600_pm_get_dynpm_state,
.get_engine_clock = &radeon_atom_get_engine_clock,
.set_engine_clock = &radeon_atom_set_engine_clock,
.get_memory_clock = &radeon_atom_get_memory_clock,
.set_memory_clock = &radeon_atom_set_memory_clock,
.get_pcie_lanes = NULL,
.set_pcie_lanes = NULL,
.set_clock_gating = NULL,
.set_uvd_clocks = &cik_set_uvd_clocks,
.set_vce_clocks = &cik_set_vce_clocks,
.get_temperature = &kv_get_temp,
},
.dpm = {
.init = &kv_dpm_init,
.setup_asic = &kv_dpm_setup_asic,
.enable = &kv_dpm_enable,
.late_enable = &kv_dpm_late_enable,
.disable = &kv_dpm_disable,
.pre_set_power_state = &kv_dpm_pre_set_power_state,
.set_power_state = &kv_dpm_set_power_state,
.post_set_power_state = &kv_dpm_post_set_power_state,
.display_configuration_changed = &kv_dpm_display_configuration_changed,
.fini = &kv_dpm_fini,
.get_sclk = &kv_dpm_get_sclk,
.get_mclk = &kv_dpm_get_mclk,
.print_power_state = &kv_dpm_print_power_state,
.debugfs_print_current_performance_level = &kv_dpm_debugfs_print_current_performance_level,
.force_performance_level = &kv_dpm_force_performance_level,
.powergate_uvd = &kv_dpm_powergate_uvd,
.enable_bapm = &kv_dpm_enable_bapm,
.get_current_sclk = &kv_dpm_get_current_sclk,
.get_current_mclk = &kv_dpm_get_current_mclk,
},
.pflip = {
.page_flip = &evergreen_page_flip,
.page_flip_pending = &evergreen_page_flip_pending,
},
};
/**
* radeon_asic_init - register asic specific callbacks
*
* @rdev: radeon device pointer
*
* Registers the appropriate asic specific callbacks for each
* chip family. Also sets other asics specific info like the number
* of crtcs and the register aperture accessors (all asics).
* Returns 0 for success.
*/
int radeon_asic_init(struct radeon_device *rdev)
{
radeon_register_accessor_init(rdev);
/* set the number of crtcs */
if (rdev->flags & RADEON_SINGLE_CRTC)
rdev->num_crtc = 1;
else
rdev->num_crtc = 2;
rdev->has_uvd = false;
rdev->has_vce = false;
switch (rdev->family) {
case CHIP_R100:
case CHIP_RV100:
case CHIP_RS100:
case CHIP_RV200:
case CHIP_RS200:
rdev->asic = &r100_asic;
break;
case CHIP_R200:
case CHIP_RV250:
case CHIP_RS300:
case CHIP_RV280:
rdev->asic = &r200_asic;
break;
case CHIP_R300:
case CHIP_R350:
case CHIP_RV350:
case CHIP_RV380:
if (rdev->flags & RADEON_IS_PCIE)
rdev->asic = &r300_asic_pcie;
else
rdev->asic = &r300_asic;
break;
case CHIP_R420:
case CHIP_R423:
case CHIP_RV410:
rdev->asic = &r420_asic;
/* handle macs */
if (rdev->bios == NULL) {
rdev->asic->pm.get_engine_clock = &radeon_legacy_get_engine_clock;
rdev->asic->pm.set_engine_clock = &radeon_legacy_set_engine_clock;
rdev->asic->pm.get_memory_clock = &radeon_legacy_get_memory_clock;
rdev->asic->pm.set_memory_clock = NULL;
rdev->asic->display.set_backlight_level = &radeon_legacy_set_backlight_level;
}
break;
case CHIP_RS400:
case CHIP_RS480:
rdev->asic = &rs400_asic;
break;
case CHIP_RS600:
rdev->asic = &rs600_asic;
break;
case CHIP_RS690:
case CHIP_RS740:
rdev->asic = &rs690_asic;
break;
case CHIP_RV515:
rdev->asic = &rv515_asic;
break;
case CHIP_R520:
case CHIP_RV530:
case CHIP_RV560:
case CHIP_RV570:
case CHIP_R580:
rdev->asic = &r520_asic;
break;
case CHIP_R600:
rdev->asic = &r600_asic;
break;
case CHIP_RV610:
case CHIP_RV630:
case CHIP_RV620:
case CHIP_RV635:
case CHIP_RV670:
rdev->asic = &rv6xx_asic;
rdev->has_uvd = true;
break;
case CHIP_RS780:
case CHIP_RS880:
rdev->asic = &rs780_asic;
/* 760G/780V/880V don't have UVD */
if ((rdev->pdev->device == 0x9616)||
(rdev->pdev->device == 0x9611)||
(rdev->pdev->device == 0x9613)||
(rdev->pdev->device == 0x9711)||
(rdev->pdev->device == 0x9713))
rdev->has_uvd = false;
else
rdev->has_uvd = true;
break;
case CHIP_RV770:
case CHIP_RV730:
case CHIP_RV710:
case CHIP_RV740:
rdev->asic = &rv770_asic;
rdev->has_uvd = true;
break;
case CHIP_CEDAR:
case CHIP_REDWOOD:
case CHIP_JUNIPER:
case CHIP_CYPRESS:
case CHIP_HEMLOCK:
/* set num crtcs */
if (rdev->family == CHIP_CEDAR)
rdev->num_crtc = 4;
else
rdev->num_crtc = 6;
rdev->asic = &evergreen_asic;
rdev->has_uvd = true;
break;
case CHIP_PALM:
case CHIP_SUMO:
case CHIP_SUMO2:
rdev->asic = &sumo_asic;
rdev->has_uvd = true;
break;
case CHIP_BARTS:
case CHIP_TURKS:
case CHIP_CAICOS:
/* set num crtcs */
if (rdev->family == CHIP_CAICOS)
rdev->num_crtc = 4;
else
rdev->num_crtc = 6;
rdev->asic = &btc_asic;
rdev->has_uvd = true;
break;
case CHIP_CAYMAN:
rdev->asic = &cayman_asic;
/* set num crtcs */
rdev->num_crtc = 6;
rdev->has_uvd = true;
break;
case CHIP_ARUBA:
rdev->asic = &trinity_asic;
/* set num crtcs */
rdev->num_crtc = 4;
rdev->has_uvd = true;
rdev->has_vce = true;
rdev->cg_flags =
RADEON_CG_SUPPORT_VCE_MGCG;
break;
case CHIP_TAHITI:
case CHIP_PITCAIRN:
case CHIP_VERDE:
case CHIP_OLAND:
case CHIP_HAINAN:
rdev->asic = &si_asic;
/* set num crtcs */
if (rdev->family == CHIP_HAINAN)
rdev->num_crtc = 0;
else if (rdev->family == CHIP_OLAND)
rdev->num_crtc = 2;
else
rdev->num_crtc = 6;
if (rdev->family == CHIP_HAINAN) {
rdev->has_uvd = false;
rdev->has_vce = false;
} else {
rdev->has_uvd = true;
rdev->has_vce = true;
}
switch (rdev->family) {
case CHIP_TAHITI:
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
break;
case CHIP_PITCAIRN:
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_GFX_RLC_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
break;
case CHIP_VERDE:
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_GFX_RLC_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0 |
/*RADEON_PG_SUPPORT_GFX_PG | */
RADEON_PG_SUPPORT_SDMA;
break;
case CHIP_OLAND:
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_GFX_RLC_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
break;
case CHIP_HAINAN:
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_GFX_RLC_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
break;
default:
rdev->cg_flags = 0;
rdev->pg_flags = 0;
break;
}
break;
case CHIP_BONAIRE:
case CHIP_HAWAII:
rdev->asic = &ci_asic;
rdev->num_crtc = 6;
rdev->has_uvd = true;
rdev->has_vce = true;
if (rdev->family == CHIP_BONAIRE) {
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CGTS_LS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_SDMA_LS |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
} else {
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_MC_LS |
RADEON_CG_SUPPORT_MC_MGCG |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_SDMA_LS |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
}
break;
case CHIP_KAVERI:
case CHIP_KABINI:
case CHIP_MULLINS:
rdev->asic = &kv_asic;
/* set num crtcs */
if (rdev->family == CHIP_KAVERI) {
rdev->num_crtc = 4;
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CGTS_LS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_SDMA_LS |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
/*RADEON_PG_SUPPORT_GFX_PG |
RADEON_PG_SUPPORT_GFX_SMG |
RADEON_PG_SUPPORT_GFX_DMG |
RADEON_PG_SUPPORT_UVD |
RADEON_PG_SUPPORT_VCE |
RADEON_PG_SUPPORT_CP |
RADEON_PG_SUPPORT_GDS |
RADEON_PG_SUPPORT_RLC_SMU_HS |
RADEON_PG_SUPPORT_ACP |
RADEON_PG_SUPPORT_SAMU;*/
} else {
rdev->num_crtc = 2;
rdev->cg_flags =
RADEON_CG_SUPPORT_GFX_MGCG |
RADEON_CG_SUPPORT_GFX_MGLS |
/*RADEON_CG_SUPPORT_GFX_CGCG |*/
RADEON_CG_SUPPORT_GFX_CGLS |
RADEON_CG_SUPPORT_GFX_CGTS |
RADEON_CG_SUPPORT_GFX_CGTS_LS |
RADEON_CG_SUPPORT_GFX_CP_LS |
RADEON_CG_SUPPORT_SDMA_MGCG |
RADEON_CG_SUPPORT_SDMA_LS |
RADEON_CG_SUPPORT_BIF_LS |
RADEON_CG_SUPPORT_VCE_MGCG |
RADEON_CG_SUPPORT_UVD_MGCG |
RADEON_CG_SUPPORT_HDP_LS |
RADEON_CG_SUPPORT_HDP_MGCG;
rdev->pg_flags = 0;
/*RADEON_PG_SUPPORT_GFX_PG |
RADEON_PG_SUPPORT_GFX_SMG |
RADEON_PG_SUPPORT_UVD |
RADEON_PG_SUPPORT_VCE |
RADEON_PG_SUPPORT_CP |
RADEON_PG_SUPPORT_GDS |
RADEON_PG_SUPPORT_RLC_SMU_HS |
RADEON_PG_SUPPORT_SAMU;*/
}
rdev->has_uvd = true;
rdev->has_vce = true;
break;
default:
/* FIXME: not supported yet */
return -EINVAL;
}
if (rdev->flags & RADEON_IS_IGP) {
rdev->asic->pm.get_memory_clock = NULL;
rdev->asic->pm.set_memory_clock = NULL;
}
if (!radeon_uvd)
rdev->has_uvd = false;
if (!radeon_vce)
rdev->has_vce = false;
return 0;
}
| {
"pile_set_name": "Github"
} |
<?php
/**
* Pi Engine (http://piengine.org)
*
* @link http://code.piengine.org for the Pi Engine source repository
* @copyright Copyright (c) Pi Engine http://piengine.org
* @license http://piengine.org/license.txt BSD 3-Clause License
*/
namespace Module\Demo\Form;
use Pi\Form\Form as BaseForm;
class DemoForm extends BaseForm
{
public function init()
{
$this->add([
'name' => 'date',
'type' => 'datepicker',
'options' => [
'label' => __('Date'),
'datepicker' => [
'format' => 'yyyy/mm/dd',
'start_Date' => '1984/09/04',
'End-date' => '1984/12/03',
],
],
'attributes' => [
'id' => 'demo-date',
'value' => '1984/10/26',
],
]);
$this->add([
'name' => 'content_text',
'type' => 'text',
'options' => [
'label' => __('Input'),
],
]);
$this->add([
'name' => 'content_textarea',
'type' => 'textarea',
'options' => [
'label' => __('Text'),
],
]);
$this->add([
'name' => 'description',
'type' => 'editor',
'options' => [
'label' => __('Description'),
'editor' => 'html',
],
'attributes' => [
'placeholder' => __('Type your content'),
'class' => 'span6',
'rows' => 5,
],
]);
$this->add([
'name' => 'content_html',
'type' => 'editor',
'options' => [
'label' => __('HTML'),
'editor' => 'html',
],
'attributes' => [
'placeholder' => __('Type your content'),
'class' => 'span6',
'rows' => 5,
],
]);
$this->add([
'name' => 'content_html_second',
'type' => 'editor',
'options' => [
'label' => __('HTML2'),
'editor' => 'html',
],
'attributes' => [
'placeholder' => __('Type your content'),
'class' => 'span6',
'rows' => 5,
],
]);
$this->add([
'name' => 'content_markdown',
'type' => 'editor',
'options' => [
'label' => __('Markdown'),
'editor' => 'makeitup',
],
'attributes' => [
'placeholder' => __('Type your content'),
'class' => 'span6',
'rows' => 5,
],
]);
$this->add([
'name' => 'upload_file',
'type' => 'file',
'options' => [
'label' => __('File'),
],
]);
$this->add([
'name' => 'rename',
'type' => 'radio',
'options' => [
'label' => __('File naming'),
'value_options' => [
'overwrite' => __('Keep name and overwrite when duplicated'),
'random' => __('Rename to random'),
],
],
'attributes' => [
'value' => 'random',
],
]);
$this->add([
'name' => 'submit',
'type' => 'submit',
'attributes' => [
'value' => __('Ready to go!'),
],
]);
}
}
| {
"pile_set_name": "Github"
} |
import memberin_extend_c
t = memberin_extend_c.Person()
t.name = "Fred Bloggs"
if t.name != "FRED BLOGGS":
raise RuntimeError("name wrong")
| {
"pile_set_name": "Github"
} |
{
"context_is_admin": "role:admin",
"admin_or_owner": "is_admin:True or project_id:%(project_id)s",
"default": "rule:admin_or_owner",
"compute:create": "",
"compute:create:attach_network": "",
"compute:create:attach_volume": "",
"compute:create:forced_host": "is_admin:True",
"compute:get_all": "",
"compute:get_all_tenants": "",
"admin_api": "is_admin:True",
"compute_extension:accounts": "rule:admin_api",
"compute_extension:admin_actions": "rule:admin_api",
"compute_extension:admin_actions:pause": "rule:admin_or_owner",
"compute_extension:admin_actions:unpause": "rule:admin_or_owner",
"compute_extension:admin_actions:suspend": "rule:admin_or_owner",
"compute_extension:admin_actions:resume": "rule:admin_or_owner",
"compute_extension:admin_actions:lock": "rule:admin_api",
"compute_extension:admin_actions:unlock": "rule:admin_api",
"compute_extension:admin_actions:resetNetwork": "rule:admin_api",
"compute_extension:admin_actions:injectNetworkInfo": "rule:admin_api",
"compute_extension:admin_actions:createBackup": "rule:admin_or_owner",
"compute_extension:admin_actions:migrateLive": "rule:admin_api",
"compute_extension:admin_actions:resetState": "rule:admin_api",
"compute_extension:admin_actions:migrate": "rule:admin_api",
"compute_extension:aggregates": "rule:admin_api",
"compute_extension:agents": "rule:admin_api",
"compute_extension:attach_interfaces": "",
"compute_extension:baremetal_nodes": "rule:admin_api",
"compute_extension:cells": "rule:admin_api",
"compute_extension:certificates": "",
"compute_extension:cloudpipe": "rule:admin_api",
"compute_extension:cloudpipe_update": "rule:admin_api",
"compute_extension:console_output": "",
"compute_extension:consoles": "",
"compute_extension:coverage_ext": "rule:admin_api",
"compute_extension:createserverext": "",
"compute_extension:deferred_delete": "",
"compute_extension:disk_config": "",
"compute_extension:evacuate": "rule:admin_api",
"compute_extension:extended_server_attributes": "rule:admin_api",
"compute_extension:extended_status": "",
"compute_extension:extended_availability_zone": "",
"compute_extension:extended_ips": "",
"compute_extension:fixed_ips": "rule:admin_api",
"compute_extension:flavor_access": "",
"compute_extension:flavor_disabled": "",
"compute_extension:flavor_rxtx": "",
"compute_extension:flavor_swap": "",
"compute_extension:flavorextradata": "",
"compute_extension:flavorextraspecs:index": "",
"compute_extension:flavorextraspecs:show": "",
"compute_extension:flavorextraspecs:create": "rule:admin_api",
"compute_extension:flavorextraspecs:update": "rule:admin_api",
"compute_extension:flavorextraspecs:delete": "rule:admin_api",
"compute_extension:flavormanage": "rule:admin_api",
"compute_extension:floating_ip_dns": "",
"compute_extension:floating_ip_pools": "",
"compute_extension:floating_ips": "",
"compute_extension:floating_ips_bulk": "rule:admin_api",
"compute_extension:fping": "",
"compute_extension:fping:all_tenants": "rule:admin_api",
"compute_extension:hide_server_addresses": "is_admin:False",
"compute_extension:hosts": "rule:admin_api",
"compute_extension:hypervisors": "rule:admin_api",
"compute_extension:image_size": "",
"compute_extension:instance_actions": "",
"compute_extension:instance_actions:events": "rule:admin_api",
"compute_extension:instance_usage_audit_log": "rule:admin_api",
"compute_extension:keypairs": "",
"compute_extension:multinic": "",
"compute_extension:networks": "rule:admin_api",
"compute_extension:networks:view": "",
"compute_extension:networks_associate": "rule:admin_api",
"compute_extension:quotas:show": "",
"compute_extension:quotas:update": "rule:admin_api",
"compute_extension:quota_classes": "",
"compute_extension:rescue": "",
"compute_extension:security_group_default_rules": "rule:admin_api",
"compute_extension:security_groups": "",
"compute_extension:server_diagnostics": "rule:admin_api",
"compute_extension:server_password": "",
"compute_extension:services": "rule:admin_api",
"compute_extension:simple_tenant_usage:show": "rule:admin_or_owner",
"compute_extension:simple_tenant_usage:list": "rule:admin_api",
"compute_extension:users": "rule:admin_api",
"compute_extension:virtual_interfaces": "",
"compute_extension:virtual_storage_arrays": "",
"compute_extension:volumes": "",
"compute_extension:volume_attachments:index": "",
"compute_extension:volume_attachments:show": "",
"compute_extension:volume_attachments:create": "",
"compute_extension:volume_attachments:delete": "",
"compute_extension:volumetypes": "",
"compute_extension:availability_zone:list": "",
"compute_extension:availability_zone:detail": "rule:admin_api",
"volume:create": "",
"volume:get_all": "",
"volume:get_volume_metadata": "",
"volume:get_snapshot": "",
"volume:get_all_snapshots": "",
"volume_extension:types_manage": "rule:admin_api",
"volume_extension:types_extra_specs": "rule:admin_api",
"volume_extension:volume_admin_actions:reset_status": "rule:admin_api",
"volume_extension:snapshot_admin_actions:reset_status": "rule:admin_api",
"volume_extension:volume_admin_actions:force_delete": "rule:admin_api",
"network:get_all": "",
"network:get": "",
"network:create": "",
"network:delete": "",
"network:associate": "",
"network:disassociate": "",
"network:get_vifs_by_instance": "",
"network:allocate_for_instance": "",
"network:deallocate_for_instance": "",
"network:validate_networks": "",
"network:get_instance_uuids_by_ip_filter": "",
"network:get_instance_id_by_floating_address": "",
"network:setup_networks_on_host": "",
"network:get_backdoor_port": "",
"network:get_floating_ip": "",
"network:get_floating_ip_pools": "",
"network:get_floating_ip_by_address": "",
"network:get_floating_ips_by_project": "",
"network:get_floating_ips_by_fixed_address": "",
"network:allocate_floating_ip": "",
"network:deallocate_floating_ip": "",
"network:associate_floating_ip": "",
"network:disassociate_floating_ip": "",
"network:release_floating_ip": "",
"network:migrate_instance_start": "",
"network:migrate_instance_finish": "",
"network:get_fixed_ip": "",
"network:get_fixed_ip_by_address": "",
"network:add_fixed_ip_to_instance": "",
"network:remove_fixed_ip_from_instance": "",
"network:add_network_to_project": "",
"network:get_instance_nw_info": "",
"network:get_dns_domains": "",
"network:add_dns_entry": "",
"network:modify_dns_entry": "",
"network:delete_dns_entry": "",
"network:get_dns_entries_by_address": "",
"network:get_dns_entries_by_name": "",
"network:create_private_dns_domain": "",
"network:create_public_dns_domain": "",
"network:delete_dns_domain": ""
}
| {
"pile_set_name": "Github"
} |
<http://example/s> <http://example/p> "abc' .
| {
"pile_set_name": "Github"
} |
/*
* 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.pdfbox.contentstream.operator.graphics;
import java.util.List;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.contentstream.operator.Operator;
import org.apache.pdfbox.contentstream.operator.OperatorName;
import java.io.IOException;
/**
* s: close and stroke the path.
*
* @author Ben Litchfield
*/
public class CloseAndStrokePath extends GraphicsOperatorProcessor
{
@Override
public void process(Operator operator, List<COSBase> arguments) throws IOException
{
context.processOperator(OperatorName.CLOSE_PATH, arguments);
context.processOperator(OperatorName.STROKE_PATH, arguments);
}
@Override
public String getName()
{
return OperatorName.CLOSE_AND_STROKE;
}
}
| {
"pile_set_name": "Github"
} |
===============================
C-SKY Performance Monitor Units
===============================
C-SKY Performance Monitor is designed for ck807/ck810/ck860 SMP soc and
it could count cpu's events for helping analysis performance issues.
============================
PMU node bindings definition
============================
Description: Describes PMU
PROPERTIES
- compatible
Usage: required
Value type: <string>
Definition: must be "csky,csky-pmu"
- interrupts
Usage: required
Value type: <u32 IRQ_TYPE_XXX>
Definition: must be pmu irq num defined by soc
- count-width
Usage: optional
Value type: <u32>
Definition: the width of pmu counter
Examples:
---------
#include <dt-bindings/interrupt-controller/irq.h>
pmu: performace-monitor {
compatible = "csky,csky-pmu";
interrupts = <23 IRQ_TYPE_EDGE_RISING>;
interrupt-parent = <&intc>;
count-width = <48>;
};
| {
"pile_set_name": "Github"
} |
a live chat room built with python(flask / gevent / apscheduler) + redis
Basic Architecture
==================

Screenshot
==========

Install
=======
- cd /path/to/source
- python bootstrap.py
- bin/buildout
- make sure redis-server is started
- bin/supervisord
- [optional] bin/supervisorctl
- goto localhost:9527
Tips
====
- open multi browser to test live communication
- execute `bin/python scripts/clear_key.py` to clear all data
Changes
=======
0.2
---
* adjust comet strategy
* add admin role
* fix duplicate name
0.1.1
-----
* adjust create room UI / UE
* add rm room func
* improve add chat message's response speed
* bugfixes
0.1
---
* add home page (all rooms in one page, and live content)
* custom nickname
* create room
* coffee-script
* bugfixes


| {
"pile_set_name": "Github"
} |
/**************************************************************************//**
* @file core_cm0.h
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
* @version V3.01
* @date 13. March 2012
*
* @note
* Copyright (C) 2009-2012 ARM Limited. All rights reserved.
*
* @par
* ARM Limited (ARM) is supplying this software for use with Cortex-M
* processor based microcontrollers. This file can be freely distributed
* within development tools that are supporting such ARM based processors.
*
* @par
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __CORE_CM0_H_GENERIC
#define __CORE_CM0_H_GENERIC
/** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
CMSIS violates the following MISRA-C:2004 rules:
\li Required Rule 8.5, object/function definition in header file.<br>
Function definitions in header files are used to allow 'inlining'.
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
Unions are used for effective representation of core registers.
\li Advisory Rule 19.7, Function-like macro defined.<br>
Function-like macros are used to allow more efficient code.
*/
/*******************************************************************************
* CMSIS definitions
******************************************************************************/
/** \ingroup Cortex_M0
@{
*/
/* CMSIS CM0 definitions */
#define __CM0_CMSIS_VERSION_MAIN (0x03) /*!< [31:16] CMSIS HAL main version */
#define __CM0_CMSIS_VERSION_SUB (0x01) /*!< [15:0] CMSIS HAL sub version */
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16) | \
__CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
#define __CORTEX_M (0x00) /*!< Cortex-M Core */
#if defined ( __CC_ARM )
#define __ASM __asm /*!< asm keyword for ARM Compiler */
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
#define __STATIC_INLINE static __inline
#elif defined ( __ICCARM__ )
#define __ASM __asm /*!< asm keyword for IAR Compiler */
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
#define __STATIC_INLINE static inline
#elif defined ( __GNUC__ )
#define __ASM __asm /*!< asm keyword for GNU Compiler */
#define __INLINE inline /*!< inline keyword for GNU Compiler */
#define __STATIC_INLINE static inline
#elif defined ( __TASKING__ )
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
#define __STATIC_INLINE static inline
#endif
/** __FPU_USED indicates whether an FPU is used or not. This core does not support an FPU at all
*/
#define __FPU_USED 0
#if defined ( __CC_ARM )
#if defined __TARGET_FPU_VFP
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __ICCARM__ )
#if defined __ARMVFP__
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __TASKING__ )
#if defined __FPU_VFP__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#endif
#include <stdint.h> /* standard types definitions */
#include <core_cmInstr.h> /* Core Instruction Access */
#include <core_cmFunc.h> /* Core Function Access */
#endif /* __CORE_CM0_H_GENERIC */
#ifndef __CMSIS_GENERIC
#ifndef __CORE_CM0_H_DEPENDANT
#define __CORE_CM0_H_DEPENDANT
/* check device defines and use defaults */
#if defined __CHECK_DEVICE_DEFINES
#ifndef __CM0_REV
#define __CM0_REV 0x0000
#warning "__CM0_REV not defined in device header file; using default!"
#endif
#ifndef __NVIC_PRIO_BITS
#define __NVIC_PRIO_BITS 2
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
#endif
#ifndef __Vendor_SysTickConfig
#define __Vendor_SysTickConfig 0
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
#endif
#endif
/* IO definitions (access restrictions to peripheral registers) */
/**
\defgroup CMSIS_glob_defs CMSIS Global Defines
<strong>IO Type Qualifiers</strong> are used
\li to specify the access to peripheral variables.
\li for automatic generation of peripheral register debug information.
*/
#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions */
#else
#define __I volatile const /*!< Defines 'read only' permissions */
#endif
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */
/*@} end of group Cortex_M0 */
/*******************************************************************************
* Register Abstraction
Core Register contain:
- Core Register
- Core NVIC Register
- Core SCB Register
- Core SysTick Register
******************************************************************************/
/** \defgroup CMSIS_core_register Defines and Type Definitions
\brief Type definitions and defines for Cortex-M processor based devices.
*/
/** \ingroup CMSIS_core_register
\defgroup CMSIS_CORE Status and Control Registers
\brief Core Register type definitions.
@{
*/
/** \brief Union type to access the Application Program Status Register (APSR).
*/
typedef union
{
struct
{
#if (__CORTEX_M != 0x04)
uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */
#else
uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
#endif
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} APSR_Type;
/** \brief Union type to access the Interrupt Program Status Register (IPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} IPSR_Type;
/** \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
#if (__CORTEX_M != 0x04)
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
#else
uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */
uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
#endif
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */
uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} xPSR_Type;
/** \brief Union type to access the Control Registers (CONTROL).
*/
typedef union
{
struct
{
uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} CONTROL_Type;
/*@} end of group CMSIS_CORE */
/** \ingroup CMSIS_core_register
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
\brief Type definitions for the NVIC Registers
@{
*/
/** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
*/
typedef struct
{
__IO uint32_t ISER[1]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
uint32_t RESERVED0[31];
__IO uint32_t ICER[1]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
uint32_t RSERVED1[31];
__IO uint32_t ISPR[1]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
uint32_t RESERVED2[31];
__IO uint32_t ICPR[1]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
uint32_t RESERVED3[31];
uint32_t RESERVED4[64];
__IO uint32_t IP[8]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
} NVIC_Type;
/*@} end of group CMSIS_NVIC */
/** \ingroup CMSIS_core_register
\defgroup CMSIS_SCB System Control Block (SCB)
\brief Type definitions for the System Control Block Registers
@{
*/
/** \brief Structure type to access the System Control Block (SCB).
*/
typedef struct
{
__I uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
__IO uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
uint32_t RESERVED0;
__IO uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
__IO uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
__IO uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
uint32_t RESERVED1;
__IO uint32_t SHP[2]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
__IO uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
} SCB_Type;
/* SCB CPUID Register Definitions */
#define SCB_CPUID_IMPLEMENTER_Pos 24 /*!< SCB CPUID: IMPLEMENTER Position */
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
#define SCB_CPUID_VARIANT_Pos 20 /*!< SCB CPUID: VARIANT Position */
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
#define SCB_CPUID_ARCHITECTURE_Pos 16 /*!< SCB CPUID: ARCHITECTURE Position */
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
#define SCB_CPUID_PARTNO_Pos 4 /*!< SCB CPUID: PARTNO Position */
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
#define SCB_CPUID_REVISION_Pos 0 /*!< SCB CPUID: REVISION Position */
#define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) /*!< SCB CPUID: REVISION Mask */
/* SCB Interrupt Control State Register Definitions */
#define SCB_ICSR_NMIPENDSET_Pos 31 /*!< SCB ICSR: NMIPENDSET Position */
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
#define SCB_ICSR_PENDSVSET_Pos 28 /*!< SCB ICSR: PENDSVSET Position */
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
#define SCB_ICSR_PENDSVCLR_Pos 27 /*!< SCB ICSR: PENDSVCLR Position */
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
#define SCB_ICSR_PENDSTSET_Pos 26 /*!< SCB ICSR: PENDSTSET Position */
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
#define SCB_ICSR_PENDSTCLR_Pos 25 /*!< SCB ICSR: PENDSTCLR Position */
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
#define SCB_ICSR_ISRPREEMPT_Pos 23 /*!< SCB ICSR: ISRPREEMPT Position */
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
#define SCB_ICSR_ISRPENDING_Pos 22 /*!< SCB ICSR: ISRPENDING Position */
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
#define SCB_ICSR_VECTPENDING_Pos 12 /*!< SCB ICSR: VECTPENDING Position */
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
#define SCB_ICSR_VECTACTIVE_Pos 0 /*!< SCB ICSR: VECTACTIVE Position */
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) /*!< SCB ICSR: VECTACTIVE Mask */
/* SCB Application Interrupt and Reset Control Register Definitions */
#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
#define SCB_AIRCR_VECTKEYSTAT_Pos 16 /*!< SCB AIRCR: VECTKEYSTAT Position */
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
#define SCB_AIRCR_ENDIANESS_Pos 15 /*!< SCB AIRCR: ENDIANESS Position */
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1 /*!< SCB AIRCR: VECTCLRACTIVE Position */
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
/* SCB System Control Register Definitions */
#define SCB_SCR_SEVONPEND_Pos 4 /*!< SCB SCR: SEVONPEND Position */
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
#define SCB_SCR_SLEEPDEEP_Pos 2 /*!< SCB SCR: SLEEPDEEP Position */
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
#define SCB_SCR_SLEEPONEXIT_Pos 1 /*!< SCB SCR: SLEEPONEXIT Position */
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
/* SCB Configuration Control Register Definitions */
#define SCB_CCR_STKALIGN_Pos 9 /*!< SCB CCR: STKALIGN Position */
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
#define SCB_CCR_UNALIGN_TRP_Pos 3 /*!< SCB CCR: UNALIGN_TRP Position */
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
/* SCB System Handler Control and State Register Definitions */
#define SCB_SHCSR_SVCALLPENDED_Pos 15 /*!< SCB SHCSR: SVCALLPENDED Position */
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
/*@} end of group CMSIS_SCB */
/** \ingroup CMSIS_core_register
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
\brief Type definitions for the System Timer Registers.
@{
*/
/** \brief Structure type to access the System Timer (SysTick).
*/
typedef struct
{
__IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
__IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
__IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
__I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
} SysTick_Type;
/* SysTick Control / Status Register Definitions */
#define SysTick_CTRL_COUNTFLAG_Pos 16 /*!< SysTick CTRL: COUNTFLAG Position */
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
#define SysTick_CTRL_CLKSOURCE_Pos 2 /*!< SysTick CTRL: CLKSOURCE Position */
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
#define SysTick_CTRL_TICKINT_Pos 1 /*!< SysTick CTRL: TICKINT Position */
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
#define SysTick_CTRL_ENABLE_Pos 0 /*!< SysTick CTRL: ENABLE Position */
#define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) /*!< SysTick CTRL: ENABLE Mask */
/* SysTick Reload Register Definitions */
#define SysTick_LOAD_RELOAD_Pos 0 /*!< SysTick LOAD: RELOAD Position */
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) /*!< SysTick LOAD: RELOAD Mask */
/* SysTick Current Register Definitions */
#define SysTick_VAL_CURRENT_Pos 0 /*!< SysTick VAL: CURRENT Position */
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick VAL: CURRENT Mask */
/* SysTick Calibration Register Definitions */
#define SysTick_CALIB_NOREF_Pos 31 /*!< SysTick CALIB: NOREF Position */
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
#define SysTick_CALIB_SKEW_Pos 30 /*!< SysTick CALIB: SKEW Position */
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
#define SysTick_CALIB_TENMS_Pos 0 /*!< SysTick CALIB: TENMS Position */
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) /*!< SysTick CALIB: TENMS Mask */
/*@} end of group CMSIS_SysTick */
/** \ingroup CMSIS_core_register
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
\brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR)
are only accessible over DAP and not via processor. Therefore
they are not covered by the Cortex-M0 header file.
@{
*/
/*@} end of group CMSIS_CoreDebug */
/** \ingroup CMSIS_core_register
\defgroup CMSIS_core_base Core Definitions
\brief Definitions for base addresses, unions, and structures.
@{
*/
/* Memory mapping of Cortex-M0 Hardware */
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
/*@} */
/*******************************************************************************
* Hardware Abstraction Layer
Core Function Interface contains:
- Core NVIC Functions
- Core SysTick Functions
- Core Register Access Functions
******************************************************************************/
/** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
*/
/* ########################## NVIC functions #################################### */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
\brief Functions that manage interrupts and exceptions via the NVIC.
@{
*/
/* Interrupt Priorities are WORD accessible only under ARMv6M */
/* The following MACROS handle generation of the register offset and byte masks */
#define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
#define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
#define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
/** \brief Enable External Interrupt
The function enables a device-specific interrupt in the NVIC interrupt controller.
\param [in] IRQn External interrupt number. Value cannot be negative.
*/
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
{
NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}
/** \brief Disable External Interrupt
The function disables a device-specific interrupt in the NVIC interrupt controller.
\param [in] IRQn External interrupt number. Value cannot be negative.
*/
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
{
NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}
/** \brief Get Pending Interrupt
The function reads the pending register in the NVIC and returns the pending bit
for the specified interrupt.
\param [in] IRQn Interrupt number.
\return 0 Interrupt status is not pending.
\return 1 Interrupt status is pending.
*/
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
{
return((uint32_t) ((NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
}
/** \brief Set Pending Interrupt
The function sets the pending bit of an external interrupt.
\param [in] IRQn Interrupt number. Value cannot be negative.
*/
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
{
NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}
/** \brief Clear Pending Interrupt
The function clears the pending bit of an external interrupt.
\param [in] IRQn External interrupt number. Value cannot be negative.
*/
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
}
/** \brief Set Interrupt Priority
The function sets the priority of an interrupt.
\note The priority cannot be set for every core interrupt.
\param [in] IRQn Interrupt number.
\param [in] priority Priority to set.
*/
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if(IRQn < 0) {
SCB->SHP[_SHP_IDX(IRQn)] = (SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
else {
NVIC->IP[_IP_IDX(IRQn)] = (NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
(((priority << (8 - __NVIC_PRIO_BITS)) & 0xFF) << _BIT_SHIFT(IRQn)); }
}
/** \brief Get Interrupt Priority
The function reads the priority of an interrupt. The interrupt
number can be positive to specify an external (device specific)
interrupt, or negative to specify an internal (core) interrupt.
\param [in] IRQn Interrupt number.
\return Interrupt Priority. Value is aligned automatically to the implemented
priority bits of the microcontroller.
*/
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
{
if(IRQn < 0) {
return((uint32_t)((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M0 system interrupts */
else {
return((uint32_t)((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
}
/** \brief System Reset
The function initiates a system reset request to reset the MCU.
*/
__STATIC_INLINE void NVIC_SystemReset(void)
{
__DSB(); /* Ensure all outstanding memory accesses included
buffered write are completed before reset */
SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
SCB_AIRCR_SYSRESETREQ_Msk);
__DSB(); /* Ensure completion of memory access */
while(1); /* wait until reset */
}
/*@} end of CMSIS_Core_NVICFunctions */
/* ################################## SysTick function ############################################ */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
\brief Functions that configure the System.
@{
*/
#if (__Vendor_SysTickConfig == 0)
/** \brief System Tick Configuration
The function initializes the System Timer and its interrupt, and starts the System Tick Timer.
Counter is in free running mode to generate periodic interrupts.
\param [in] ticks Number of ticks between two interrupts.
\return 0 Function succeeded.
\return 1 Function failed.
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
must contain a vendor-specific implementation of this function.
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
SysTick->VAL = 0; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0); /* Function successful */
}
#endif
/*@} end of CMSIS_Core_SysTickFunctions */
#endif /* __CORE_CM0_H_DEPENDANT */
#endif /* __CMSIS_GENERIC */
#ifdef __cplusplus
}
#endif
| {
"pile_set_name": "Github"
} |
{
"info" : {
"version" : 1,
"author" : "xcode"
}
} | {
"pile_set_name": "Github"
} |
package PAUSE::Web::Exception;
use Mojo::Base -base;
use overload
'""' => sub {$_[0]->{ERROR} ? $_[0]->{ERROR} : $_[0]->{HTTP_STATUS} ? $_[0]->{HTTP_STATUS} : ""},
;
1;
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<!--
VS SDK Notes: This resx file contains the resources that will be consumed from your package by Visual Studio.
For example, Visual Studio will attempt to load resource '400' from this resource stream when it needs to
load your package's icon. Because Visual Studio will always look in the VSPackage.resources stream first for
resources it needs, you should put additional resources that Visual Studio will load directly into this resx
file.
Resources that you would like to access directly from your package in a strong-typed fashion should be stored
in Resources.resx or another resx file.
-->
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="110" xml:space="preserve">
<value>VSSDKSupportForSettingsCategories</value>
</data>
<data name="112" xml:space="preserve">
<value>Information about my package</value>
</data>
<data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> | {
"pile_set_name": "Github"
} |
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.auth.client.oauth2;
/**
* This is an exception class for OAUTH specific errors. i.e. The error responses described in the
* RFC6749. Do NOT confuse this with Java errors.
*
* <p>
* To keep it simple, this exception class serves for both Authorization Request and Authorization Grant
* error response
*
* <p>
* The field names are kept exactly the same as the specification.
* This allows the error responses to be directly deserialized from JSON.
*
* @author Gary Tse - Initial contribution
*
* @see <a href="https://tools.ietf.org/html/rfc6749#section-4.1.2.1">rfc6749 section-4.1.2.1</a>
* @see <a href="https://tools.ietf.org/html/rfc6749#section-5.2">rfc6749 section-5.2</a>
*/
public class OAuthResponseException extends Exception {
private static final long serialVersionUID = -3268280125111194474L;
/**
* error is compulsary in OAUth error response.
* Must be one of { invalid_request, invalid_client, invalid_grant, unauthorized_client, unsupported_grant_type,
* invalid_scope, access_denied, unsupported_response_type, server_error, temporarily_unavailable }
*/
private String error;
private String errorDescription;
private String errorUri;
private String state;
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getErrorDescription() {
return errorDescription;
}
public void setErrorDescription(String errorDescription) {
this.errorDescription = errorDescription;
}
public String getErrorUri() {
return errorUri;
}
public void setErrorUri(String errorUri) {
this.errorUri = errorUri;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
@Override
public String toString() {
return "OAuthResponseException [error=" + error + ", errorDescription=" + errorDescription + ", errorUri="
+ errorUri + ", state=" + state + "]";
}
}
| {
"pile_set_name": "Github"
} |
/dts-v1/;
#include "rt3050_allnet_all0256n.dtsi"
/ {
compatible = "allnet,all0256n-8m", "allnet,all0256n", "ralink,rt3050-soc";
model = "Allnet ALL0256N (8M)";
};
&spi0 {
status = "okay";
m25p80@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};
factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};
partition@50000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x50000 0x7b0000>;
};
};
};
};
| {
"pile_set_name": "Github"
} |
module Test
module Unit
AutoRunner.register_runner(:console) do |auto_runner|
require 'test/unit/ui/console/testrunner'
Test::Unit::UI::Console::TestRunner
end
AutoRunner.setup_option do |auto_runner, opts|
require 'test/unit/ui/console/outputlevel'
output_levels = [
["silent", UI::Console::OutputLevel::SILENT],
["progress", UI::Console::OutputLevel::PROGRESS_ONLY],
["important-only", UI::Console::OutputLevel::IMPORTANT_FAULTS_ONLY],
["normal", UI::Console::OutputLevel::NORMAL],
["verbose", UI::Console::OutputLevel::VERBOSE],
]
opts.on('-v', '--verbose=[LEVEL]', output_levels,
"Set the output level (default is verbose).",
"(#{auto_runner.keyword_display(output_levels)})") do |level|
level ||= output_levels.assoc("verbose")[1]
auto_runner.runner_options[:output_level] = level
end
use_color_options = [
[:auto, :auto],
["-", false],
["no", false],
["false", false],
["+", true],
["yes", true],
["true", true],
]
opts.on("--[no-]use-color=[auto]", use_color_options,
"Uses color output",
"(default is auto)") do |use_color|
case use_color
when nil
use_color = true
when :auto
use_color = nil
end
auto_runner.runner_options[:use_color] = use_color
end
opts.on("--progress-row-max=MAX", Integer,
"Uses MAX as max terminal width for progress mark",
"(default is auto)") do |max|
auto_runner.runner_options[:progress_row_max] = max
end
opts.on("--no-show-detail-immediately",
"Shows not passed test details immediately.",
"(default is yes)") do |boolean|
auto_runner.runner_options[:show_detail_immediately] = boolean
end
end
end
end
| {
"pile_set_name": "Github"
} |
/*******************************************************************************
* Copyright 2013 EMBL-EBI
*
* 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 uk.ac.sanger.artemis.cramtools.ref;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import htsjdk.samtools.SAMSequenceRecord;
import htsjdk.samtools.cram.io.InputStreamUtils;
import htsjdk.samtools.cram.ref.CRAMReferenceSource;
import htsjdk.samtools.reference.FastaSequenceIndex;
import htsjdk.samtools.reference.ReferenceSequence;
import htsjdk.samtools.reference.ReferenceSequenceFile;
import htsjdk.samtools.reference.ReferenceSequenceFileFactory;
import htsjdk.samtools.util.IOUtil;
import htsjdk.samtools.util.Log;
/**
* A central class for automated discovery of reference sequences. The algorithm
* is expected similar to that of samtools:
* <ul>
* <li>Search in memory cache by sequence name.</li>
* <li>Use local fasta file is supplied as a reference file and cache the found
* sequence in memory.</li>
* <li>Try REF_CACHE env variable.</li>
* <li>Try all entries in REF_PATH. The default value is the EBI reference
* service.</li>
* <li>Try @SQ:UR as a URL for a fasta file with the fasta index next to
* it.</li>
* </ul>
*
* @author vadim
*/
public class ReferenceSource implements CRAMReferenceSource {
private static final int REF_BASES_TO_CHECK_FOR_SANITY = 1000;
private static final Pattern chrPattern = Pattern.compile("chr.*", Pattern.CASE_INSENSITIVE);
private static String REF_CACHE = System.getenv("REF_CACHE");
private static String REF_PATH = System.getenv("REF_PATH");
private static List<PathPattern> refPatterns = new ArrayList<PathPattern>();
static {
// Next line changed by kp11
if (REF_PATH == null || REF_PATH.trim().length() == 0)
REF_PATH = "https://www.ebi.ac.uk/ena/cram/md5/%s";
// Next line changed by kp11
if (REF_CACHE != null && REF_CACHE.trim().length() > 0)
refPatterns.add(new PathPattern(REF_CACHE));
for (String s : REF_PATH.split("(?i)(?<!(https|ftp)):")) {
refPatterns.add(new PathPattern(s));
}
}
private static Log log = Log.getInstance(ReferenceSource.class);
private ReferenceSequenceFile rsFile;
private FastaSequenceIndex fastaSequenceIndex;
private int downloadTriesBeforeFailing = 2;
/*
* In-memory cache of ref bases by sequence name. Garbage collector will
* automatically clean it if memory is low.
*/
private Map<String, WeakReference<byte[]>> cacheW = new HashMap<String, WeakReference<byte[]>>();
public ReferenceSource() {
}
public ReferenceSource(File file) {
if (file != null) {
rsFile = ReferenceSequenceFileFactory.getReferenceSequenceFile(file);
File indexFile = new File(file.getAbsoluteFile() + ".fai");
if (indexFile.exists())
fastaSequenceIndex = new FastaSequenceIndex(indexFile);
}
}
public ReferenceSource(ReferenceSequenceFile rsFile) {
this.rsFile = rsFile;
}
public void clearCache() {
cacheW.clear();
}
private byte[] findInCache(String name) {
WeakReference<byte[]> r = cacheW.get(name);
if (r != null) {
byte[] bytes = r.get();
if (bytes != null)
return bytes;
}
return null;
}
@Override
public synchronized byte[] getReferenceBases(SAMSequenceRecord record, boolean tryNameVariants) {
byte[] bases = findBases(record, tryNameVariants);
if (bases == null)
return null;
cacheW.put(record.getSequenceName(), new WeakReference<byte[]>(bases));
String md5 = record.getAttribute(SAMSequenceRecord.MD5_TAG);
if (md5 == null) {
md5 = Utils.calculateMD5String(bases);
record.setAttribute(SAMSequenceRecord.MD5_TAG, md5);
}
if (REF_CACHE != null)
addToRefCache(md5, bases);
return bases;
}
private static byte[] readBytesFromFile(File file, int offset, int len) throws IOException {
long size = file.length();
if (size < offset || len < 0) {
log.warn(String.format("Ref request is out of range: %s, size=%d, offset=%d, len=%d",
file.getAbsolutePath(), size, offset, len));
return new byte[] {};
}
byte[] data = new byte[(int) Math.min(size - offset, len)];
FileInputStream fis = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fis);
dis.skip(offset);
dis.readFully(data);
dis.close();
return data;
}
public synchronized ReferenceRegion getRegion(SAMSequenceRecord record, int start_1based, int endInclusive_1based)
throws IOException {
{ // check cache by sequence name:
String name = record.getSequenceName();
byte[] bases = findInCache(name);
if (bases != null) {
log.debug("Reference found in memory cache by name: " + name);
return ReferenceRegion.copyRegion(bases, record.getSequenceIndex(), record.getSequenceName(),
start_1based, endInclusive_1based);
}
}
String md5 = record.getAttribute(SAMSequenceRecord.MD5_TAG);
{ // check cache by md5:
if (md5 != null) {
byte[] bases = findInCache(md5);
if (bases != null) {
log.debug("Reference found in memory cache by md5: " + md5);
return ReferenceRegion.copyRegion(bases, record.getSequenceIndex(), record.getSequenceName(),
start_1based, endInclusive_1based);
}
}
}
byte[] bases = null;
if (REF_CACHE != null) {
PathPattern pathPattern = new PathPattern(REF_CACHE);
File file = new File(pathPattern.format(md5));
if (file.exists()) {
bases = readBytesFromFile(file, start_1based - 1, endInclusive_1based - start_1based + 1);
return new ReferenceRegion(bases, record.getSequenceIndex(), record.getSequenceName(), start_1based);
}
}
{ // try to fetch sequence by md5:
if (md5 != null)
try {
bases = findBasesByMD5(md5);
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new RuntimeException(e);
}
if (bases != null) {
cacheW.put(record.getSequenceName(), new WeakReference<byte[]>(bases));
if (REF_CACHE != null)
addToRefCache(md5, bases);
return ReferenceRegion.copyRegion(bases, record.getSequenceIndex(), record.getSequenceName(),
start_1based, endInclusive_1based);
}
}
return null;
}
protected byte[] findBases(SAMSequenceRecord record, boolean tryNameVariants) {
{ // check cache by sequence name:
String name = record.getSequenceName();
byte[] bases = findInCache(name);
if (bases != null) {
log.debug("Reference found in memory cache by name: " + name);
return bases;
}
}
String md5 = record.getAttribute(SAMSequenceRecord.MD5_TAG);
{ // check cache by md5:
if (md5 != null) {
byte[] bases = findInCache(md5);
if (bases != null) {
log.debug("Reference found in memory cache by md5: " + md5);
return bases;
}
}
}
byte[] bases;
{ // try to fetch sequence by name:
bases = findBasesByName(record.getSequenceName(), tryNameVariants);
if (bases != null) {
Utils.upperCase(bases);
return bases;
}
}
{ // try to fetch sequence by md5:
if (md5 != null)
try {
bases = findBasesByMD5(md5);
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new RuntimeException(e);
}
if (bases != null) {
return bases;
}
}
{ // try @SQ:UR file location
if (record.getAttribute(SAMSequenceRecord.URI_TAG) != null) {
ReferenceSequenceFromSeekable s = ReferenceSequenceFromSeekable
.fromString(record.getAttribute(SAMSequenceRecord.URI_TAG));
bases = s.getSubsequenceAt(record.getSequenceName(), 1, record.getSequenceLength());
Utils.upperCase(bases);
return bases;
}
}
return null;
}
protected byte[] findBasesByName(String name, boolean tryVariants) {
if (rsFile == null || !rsFile.isIndexed())
return null;
ReferenceSequence sequence = null;
if (fastaSequenceIndex != null)
if (fastaSequenceIndex.hasIndexEntry(name))
sequence = rsFile.getSequence(name);
else
sequence = null;
if (sequence != null)
return sequence.getBases();
if (tryVariants) {
for (String variant : getVariants(name)) {
try {
sequence = rsFile.getSequence(variant);
} catch (Exception e) {
log.info("Sequence not found: " + variant);
}
if (sequence != null) {
log.debug("Reference found in memory cache for name %s by variant %s", name, variant);
return sequence.getBases();
}
}
}
return null;
}
/**
* @param path
* @return true if the path is a valid URL, false otherwise.
*/
private static boolean isURL(String path) {
try {
URL url = new URL(path);
return true;
} catch (MalformedURLException e) {
return false;
}
}
private byte[] loadFromPath(String path, String md5) throws IOException {
if (isURL(path)) {
URL url = new URL(path);
for (int i = 0; i < downloadTriesBeforeFailing; i++) {
InputStream is = url.openStream();
if (is == null)
return null;
if (REF_CACHE != null) {
String localPath = addToRefCache(md5, is);
File file = new File(localPath);
if (file.length() > Integer.MAX_VALUE)
throw new RuntimeException("The reference sequence is too long: " + md5);
return readBytesFromFile(file, 0, (int) file.length());
}
byte[] data = InputStreamUtils.readFully(is);
is.close();
if (confirmMD5(md5, data)) {
// sanitize, Internet is a wild place:
if (Utils.isValidSequence(data, REF_BASES_TO_CHECK_FOR_SANITY))
return data;
else {
// reject, it looks like garbage
log.error("Downloaded sequence looks suspicous, rejected: " + url.toExternalForm());
break;
}
}
}
} else {
File file = new File(path);
if (file.exists()) {
if (file.length() > Integer.MAX_VALUE)
throw new RuntimeException("The reference sequence is too long: " + md5);
byte[] data = readBytesFromFile(file, 0, (int) file.length());
if (confirmMD5(md5, data))
return data;
else
throw new RuntimeException("MD5 mismatch for cached file: " + file.getAbsolutePath());
}
}
return null;
}
protected byte[] findBasesByMD5(String md5) throws MalformedURLException, IOException {
for (PathPattern p : refPatterns) {
String path = p.format(md5);
byte[] data = loadFromPath(path, md5);
if (data == null)
continue;
log.debug("Reference found at the location ", path);
return data;
}
return null;
}
private static void addToRefCache(String md5, byte[] data) {
File cachedFile = new File(new PathPattern(REF_CACHE).format(md5));
if (!cachedFile.exists()) {
log.debug(String.format("Adding to REF_CACHE: md5=%s, length=%d", md5, data.length));
cachedFile.getParentFile().mkdirs();
File tmpFile;
try {
tmpFile = File.createTempFile(md5, ".tmp", cachedFile.getParentFile());
FileOutputStream fos = new FileOutputStream(tmpFile);
fos.write(data);
fos.close();
if (!cachedFile.exists())
tmpFile.renameTo(cachedFile);
else
tmpFile.delete();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
private static String addToRefCache(String md5, InputStream stream) {
String localPath = new PathPattern(REF_CACHE).format(md5);
File cachedFile = new File(localPath);
if (!cachedFile.exists()) {
log.info(String.format("Adding to REF_CACHE sequence md5=%s", md5));
cachedFile.getParentFile().mkdirs();
File tmpFile;
try {
tmpFile = File.createTempFile(md5, ".tmp", cachedFile.getParentFile());
FileOutputStream fos = new FileOutputStream(tmpFile);
IOUtil.copyStream(stream, fos);
fos.close();
if (!cachedFile.exists())
tmpFile.renameTo(cachedFile);
else
tmpFile.delete();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return localPath;
}
private boolean confirmMD5(String md5, byte[] data) {
String downloadedMD5 = null;
downloadedMD5 = Utils.calculateMD5String(data);
if (md5.equals(downloadedMD5)) {
return true;
} else {
String message = String.format("Downloaded sequence is corrupt: requested md5=%s, received md5=%s", md5,
downloadedMD5);
log.error(message);
return false;
}
}
protected List<String> getVariants(String name) {
List<String> variants = new ArrayList<String>();
if (name.equals("M"))
variants.add("MT");
if (name.equals("MT"))
variants.add("M");
boolean chrPatternMatch = chrPattern.matcher(name).matches();
if (chrPatternMatch)
variants.add(name.substring(3));
else
variants.add("chr" + name);
if ("chrM".equals(name)) {
// chrM case:
variants.add("MT");
}
return variants;
}
public int getDownloadTriesBeforeFailing() {
return downloadTriesBeforeFailing;
}
public void setDownloadTriesBeforeFailing(int downloadTriesBeforeFailing) {
this.downloadTriesBeforeFailing = downloadTriesBeforeFailing;
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="29dp"
android:paddingLeft="52dp"
android:paddingRight="52dp"
android:paddingTop="29dp" >
<!-- row 1 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
</LinearLayout>
<!-- row 2 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal" >
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_male"
app:riv_height_to_width_ratio="1" />
</LinearLayout>
<!-- row 3 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal" >
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_other"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/socially_portrait_other"
app:riv_height_to_width_ratio="1" />
<FrameLayout
android:layout_width="@dimen/socially_register_portrait_padding"
android:layout_height="1dp" />
<cn.forward.androids.views.RatioImageView
android:id="@+id/socially_register_portrait_item9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/socially_portrait_other"
app:riv_height_to_width_ratio="1" />
</LinearLayout>
</LinearLayout> | {
"pile_set_name": "Github"
} |
#include <thrift/c_glib/protocol/thrift_binary_protocol.h>
#include <thrift/c_glib/protocol/thrift_protocol.h>
#include <thrift/c_glib/transport/thrift_memory_buffer.h>
#include <thrift/c_glib/transport/thrift_transport.h>
#include "gen-c_glib/t_test_debug_proto_test_types.h"
#include "gen-c_glib/t_test_enum_test_types.h"
static void enum_constants_read_write() {
GError* error = NULL;
ThriftTransport* transport
= THRIFT_TRANSPORT(g_object_new(THRIFT_TYPE_MEMORY_BUFFER, "buf_size", 1024, NULL));
ThriftProtocol* protocol
= THRIFT_PROTOCOL(g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, NULL));
TTestEnumTestStruct* src = T_TEST_ENUM_TEST;
TTestEnumTestStruct* dst = g_object_new(T_TEST_TYPE_ENUM_TEST_STRUCT, NULL);
TTestEnumTestStructClass* cls = T_TEST_ENUM_TEST_STRUCT_GET_CLASS(src);
int write_len;
int read_len;
write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
g_assert(!error);
g_assert(write_len > 0);
read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
g_assert(!error);
g_assert_cmpint(write_len, ==, read_len);
g_object_unref(dst);
g_object_unref(protocol);
g_object_unref(transport);
}
static void struct_constants_read_write() {
GError* error = NULL;
ThriftTransport* transport
= THRIFT_TRANSPORT(g_object_new(THRIFT_TYPE_MEMORY_BUFFER, "buf_size", 4096, NULL));
ThriftProtocol* protocol
= THRIFT_PROTOCOL(g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, NULL));
TTestCompactProtoTestStruct* src = T_TEST_COMPACT_TEST;
TTestCompactProtoTestStruct* dst = g_object_new(T_TEST_TYPE_COMPACT_PROTO_TEST_STRUCT, NULL);
TTestCompactProtoTestStructClass* cls = T_TEST_COMPACT_PROTO_TEST_STRUCT_GET_CLASS(src);
int write_len;
int read_len;
write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
g_assert(!error);
g_assert(write_len > 0);
read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
g_assert(!error);
g_assert_cmpint(write_len, ==, read_len);
g_object_unref(dst);
g_object_unref(protocol);
g_object_unref(transport);
}
static void struct_read_write_length_should_equal() {
GError* error = NULL;
ThriftTransport* transport
= THRIFT_TRANSPORT(g_object_new(THRIFT_TYPE_MEMORY_BUFFER, "buf_size", 2048, NULL));
ThriftProtocol* protocol
= THRIFT_PROTOCOL(g_object_new(THRIFT_TYPE_BINARY_PROTOCOL, "transport", transport, NULL));
TTestBonk* src = g_object_new(T_TEST_TYPE_BONK, NULL);
TTestBonk* dst = g_object_new(T_TEST_TYPE_BONK, NULL);
TTestBonkClass* cls = T_TEST_BONK_GET_CLASS(src);
int write_len;
int read_len;
write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
g_assert(!error);
g_assert(write_len > 0);
read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
g_assert(!error);
g_assert_cmpint(write_len, ==, read_len);
g_object_unref(dst);
g_object_unref(src);
g_object_unref(protocol);
g_object_unref(transport);
}
int main(int argc, char* argv[]) {
#if (!GLIB_CHECK_VERSION(2, 36, 0))
g_type_init();
#endif
g_test_init(&argc, &argv, NULL);
g_test_add_func("/testserialization/StructReadWriteLengthShouldEqual",
struct_read_write_length_should_equal);
g_test_add_func("/testserialization/StructConstants", struct_constants_read_write);
g_test_add_func("/testserialization/EnumConstants", enum_constants_read_write);
return g_test_run();
}
| {
"pile_set_name": "Github"
} |
#include <fs-core-modules>
| {
"pile_set_name": "Github"
} |
<div id="pluginsPage" data-role="page" class="page type-interior pluginConfigurationPage withTabs fullWidthContent" data-require="scripts/pluginspage">
<div>
<div class="content-primary">
<div class="installedPlugins"></div>
</div>
</div>
</div> | {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="zh">
<head>
<!-- Generated by javadoc (1.8.0_181) on Tue Oct 29 14:27:37 CST 2019 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Transform</title>
<meta name="date" content="2019-10-29">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Transform";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10};
var tabs = {65535:["t0","所有方法"],2:["t2","实例方法"],8:["t4","具体方法"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>您的浏览器已禁用 JavaScript。</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../../overview-summary.html">概览</a></li>
<li><a href="package-summary.html">程序包</a></li>
<li class="navBarCell1Rev">类</li>
<li><a href="package-tree.html">树</a></li>
<li><a href="../../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../../index-files/index-1.html">索引</a></li>
<li><a href="../../../../../../help-doc.html">帮助</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../com/ppdai/das/console/common/utils/StringUtil.html" title="com.ppdai.das.console.common.utils中的类"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../com/ppdai/das/console/common/utils/XmlUtil.html" title="com.ppdai.das.console.common.utils中的类"><span class="typeNameLink">下一个类</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?com/ppdai/das/console/common/utils/Transform.html" target="_top">框架</a></li>
<li><a href="Transform.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">所有类</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>概要: </li>
<li>嵌套 | </li>
<li>字段 | </li>
<li><a href="#constructor.summary">构造器</a> | </li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料: </li>
<li>字段 | </li>
<li><a href="#constructor.detail">构造器</a> | </li>
<li><a href="#method.detail">方法</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.ppdai.das.console.common.utils</div>
<h2 title="类 Transform" class="title">类 Transform</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>com.ppdai.das.console.common.utils.Transform</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Component
public class <span class="typeNameLabel">Transform</span>
extends java.lang.Object</pre>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>构造器概要</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="构造器概要表, 列表构造器和解释">
<caption><span>构造器</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">构造器和说明</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#Transform--">Transform</a></span>()</code> </td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>方法概要</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="方法概要表, 列表方法和解释">
<caption><span id="t0" class="activeTableTab"><span>所有方法</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">实例方法</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">具体方法</a></span><span class="tabEnd"> </span></span></caption>
<tr>
<th class="colFirst" scope="col">限定符和类型</th>
<th class="colLast" scope="col">方法和说明</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetEntryVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetEntryVO</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toDatabaseSetEntryVO-com.ppdai.das.console.dto.entry.das.DatabaseSetEntry-">toDatabaseSetEntryVO</a></span>(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSetEntry.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSetEntry</a> dbset)</code> </td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>java.util.List<<a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetEntryVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetEntryVO</a>></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toDatabaseSetEntryVOList-java.util.List-">toDatabaseSetEntryVOList</a></span>(java.util.List<<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSetEntry.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSetEntry</a>> list)</code> </td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetVO</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toDatabaseSetVO-com.ppdai.das.console.dto.entry.das.DatabaseSet-">toDatabaseSetVO</a></span>(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSet.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSet</a> dbset)</code> </td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/openapi/vo/DataBaseVO.html" title="com.ppdai.das.console.openapi.vo中的类">DataBaseVO</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toDataBaseVO-com.ppdai.das.console.dto.entry.das.DataBaseInfo-">toDataBaseVO</a></span>(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DataBaseInfo.html" title="com.ppdai.das.console.dto.entry.das中的类">DataBaseInfo</a> dataBaseInfo)</code> </td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>java.util.List<<a href="../../../../../../com/ppdai/das/console/openapi/vo/DataBaseVO.html" title="com.ppdai.das.console.openapi.vo中的类">DataBaseVO</a>></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toDataBaseVOList-java.util.List-">toDataBaseVOList</a></span>(java.util.List<<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DataBaseInfo.html" title="com.ppdai.das.console.dto.entry.das中的类">DataBaseInfo</a>> list)</code> </td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/dto/entry/das/LoginUser.html" title="com.ppdai.das.console.dto.entry.das中的类">LoginUser</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toLoginUser-com.ppdai.das.console.api.model.UserIdentity-">toLoginUser</a></span>(<a href="../../../../../../com/ppdai/das/console/api/model/UserIdentity.html" title="com.ppdai.das.console.api.model中的接口">UserIdentity</a> userIdentity)</code> </td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/openapi/vo/ProjectVO.html" title="com.ppdai.das.console.openapi.vo中的类">ProjectVO</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toProjectVO-com.ppdai.das.console.dto.entry.das.Project-">toProjectVO</a></span>(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/Project.html" title="com.ppdai.das.console.dto.entry.das中的类">Project</a> project)</code> </td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="../../../../../../com/ppdai/das/console/openapi/vo/ProjectVO.html" title="com.ppdai.das.console.openapi.vo中的类">ProjectVO</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../com/ppdai/das/console/common/utils/Transform.html#toProjectVO-com.ppdai.das.console.dto.view.ProjectView-">toProjectVO</a></span>(<a href="../../../../../../com/ppdai/das/console/dto/view/ProjectView.html" title="com.ppdai.das.console.dto.view中的类">ProjectView</a> projectView)</code> </td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>从类继承的方法 java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>构造器详细资料</h3>
<a name="Transform--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>Transform</h4>
<pre>public Transform()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>方法详细资料</h3>
<a name="toLoginUser-com.ppdai.das.console.api.model.UserIdentity-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toLoginUser</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/dto/entry/das/LoginUser.html" title="com.ppdai.das.console.dto.entry.das中的类">LoginUser</a> toLoginUser(<a href="../../../../../../com/ppdai/das/console/api/model/UserIdentity.html" title="com.ppdai.das.console.api.model中的接口">UserIdentity</a> userIdentity)</pre>
</li>
</ul>
<a name="toDataBaseVOList-java.util.List-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDataBaseVOList</h4>
<pre>public java.util.List<<a href="../../../../../../com/ppdai/das/console/openapi/vo/DataBaseVO.html" title="com.ppdai.das.console.openapi.vo中的类">DataBaseVO</a>> toDataBaseVOList(java.util.List<<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DataBaseInfo.html" title="com.ppdai.das.console.dto.entry.das中的类">DataBaseInfo</a>> list)</pre>
</li>
</ul>
<a name="toDataBaseVO-com.ppdai.das.console.dto.entry.das.DataBaseInfo-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDataBaseVO</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/openapi/vo/DataBaseVO.html" title="com.ppdai.das.console.openapi.vo中的类">DataBaseVO</a> toDataBaseVO(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DataBaseInfo.html" title="com.ppdai.das.console.dto.entry.das中的类">DataBaseInfo</a> dataBaseInfo)</pre>
</li>
</ul>
<a name="toDatabaseSetVO-com.ppdai.das.console.dto.entry.das.DatabaseSet-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDatabaseSetVO</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetVO</a> toDatabaseSetVO(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSet.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSet</a> dbset)</pre>
</li>
</ul>
<a name="toDatabaseSetEntryVOList-java.util.List-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDatabaseSetEntryVOList</h4>
<pre>public java.util.List<<a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetEntryVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetEntryVO</a>> toDatabaseSetEntryVOList(java.util.List<<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSetEntry.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSetEntry</a>> list)
throws java.sql.SQLException</pre>
<dl>
<dt><span class="throwsLabel">抛出:</span></dt>
<dd><code>java.sql.SQLException</code></dd>
</dl>
</li>
</ul>
<a name="toDatabaseSetEntryVO-com.ppdai.das.console.dto.entry.das.DatabaseSetEntry-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDatabaseSetEntryVO</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/openapi/vo/DatabaseSetEntryVO.html" title="com.ppdai.das.console.openapi.vo中的类">DatabaseSetEntryVO</a> toDatabaseSetEntryVO(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/DatabaseSetEntry.html" title="com.ppdai.das.console.dto.entry.das中的类">DatabaseSetEntry</a> dbset)
throws java.sql.SQLException</pre>
<dl>
<dt><span class="throwsLabel">抛出:</span></dt>
<dd><code>java.sql.SQLException</code></dd>
</dl>
</li>
</ul>
<a name="toProjectVO-com.ppdai.das.console.dto.entry.das.Project-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toProjectVO</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/openapi/vo/ProjectVO.html" title="com.ppdai.das.console.openapi.vo中的类">ProjectVO</a> toProjectVO(<a href="../../../../../../com/ppdai/das/console/dto/entry/das/Project.html" title="com.ppdai.das.console.dto.entry.das中的类">Project</a> project)</pre>
</li>
</ul>
<a name="toProjectVO-com.ppdai.das.console.dto.view.ProjectView-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>toProjectVO</h4>
<pre>public <a href="../../../../../../com/ppdai/das/console/openapi/vo/ProjectVO.html" title="com.ppdai.das.console.openapi.vo中的类">ProjectVO</a> toProjectVO(<a href="../../../../../../com/ppdai/das/console/dto/view/ProjectView.html" title="com.ppdai.das.console.dto.view中的类">ProjectView</a> projectView)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../../overview-summary.html">概览</a></li>
<li><a href="package-summary.html">程序包</a></li>
<li class="navBarCell1Rev">类</li>
<li><a href="package-tree.html">树</a></li>
<li><a href="../../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../../index-files/index-1.html">索引</a></li>
<li><a href="../../../../../../help-doc.html">帮助</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../com/ppdai/das/console/common/utils/StringUtil.html" title="com.ppdai.das.console.common.utils中的类"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../com/ppdai/das/console/common/utils/XmlUtil.html" title="com.ppdai.das.console.common.utils中的类"><span class="typeNameLink">下一个类</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?com/ppdai/das/console/common/utils/Transform.html" target="_top">框架</a></li>
<li><a href="Transform.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">所有类</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>概要: </li>
<li>嵌套 | </li>
<li>字段 | </li>
<li><a href="#constructor.summary">构造器</a> | </li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料: </li>
<li>字段 | </li>
<li><a href="#constructor.detail">构造器</a> | </li>
<li><a href="#method.detail">方法</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| {
"pile_set_name": "Github"
} |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_SPDY_HPACK_ENTRY_H_
#define NET_SPDY_HPACK_ENTRY_H_
#include <stddef.h>
#include <string>
#include "base/macros.h"
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
// All section references below are to
// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
namespace net {
// A structure for an entry in the static table (3.3.1)
// and the header table (3.3.2).
class NET_EXPORT_PRIVATE HpackEntry {
public:
// The constant amount added to name().size() and value().size() to
// get the size of an HpackEntry as defined in 5.1.
static const size_t kSizeOverhead;
// Creates an entry. Preconditions:
// - |is_static| captures whether this entry is a member of the static
// or dynamic header table.
// - |insertion_index| is this entry's index in the total set of entries ever
// inserted into the header table (including static entries).
//
// The combination of |is_static| and |insertion_index| allows an
// HpackEntryTable to determine the index of an HpackEntry in O(1) time.
// Copies |name| and |value|.
HpackEntry(base::StringPiece name,
base::StringPiece value,
bool is_static,
size_t insertion_index);
// Create a 'lookup' entry (only) suitable for querying a HpackEntrySet. The
// instance InsertionIndex() always returns 0 and IsLookup() returns true.
// The memory backing |name| and |value| must outlive this object.
HpackEntry(base::StringPiece name, base::StringPiece value);
HpackEntry(const HpackEntry& other);
HpackEntry& operator=(const HpackEntry& other);
// Creates an entry with empty name and value. Only defined so that
// entries can be stored in STL containers.
HpackEntry();
~HpackEntry();
base::StringPiece name() const { return name_ref_; }
base::StringPiece value() const { return value_ref_; }
// Returns whether this entry is a member of the static (as opposed to
// dynamic) table.
bool IsStatic() const { return type_ == STATIC; }
// Returns whether this entry is a lookup-only entry.
bool IsLookup() const { return type_ == LOOKUP; }
// Used to compute the entry's index in the header table.
size_t InsertionIndex() const { return insertion_index_; }
// Returns the size of an entry as defined in 5.1.
static size_t Size(base::StringPiece name, base::StringPiece value);
size_t Size() const;
std::string GetDebugString() const;
int64_t time_added() const { return time_added_; }
void set_time_added(int64_t now) { time_added_ = now; }
private:
enum EntryType {
LOOKUP,
DYNAMIC,
STATIC,
};
// These members are not used for LOOKUP entries.
std::string name_;
std::string value_;
// These members are always valid. For DYNAMIC and STATIC entries, they
// always point to |name_| and |value_|.
base::StringPiece name_ref_;
base::StringPiece value_ref_;
// The entry's index in the total set of entries ever inserted into the header
// table.
size_t insertion_index_;
EntryType type_;
// For HpackHeaderTable::DebugVisitorInterface
int64_t time_added_;
};
} // namespace net
#endif // NET_SPDY_HPACK_ENTRY_H_
| {
"pile_set_name": "Github"
} |
# SPDX-License-Identifier: GPL-2.0-only
config JFS_FS
tristate "JFS filesystem support"
select NLS
select CRC32
help
This is a port of IBM's Journaled Filesystem . More information is
available in the file <file:Documentation/admin-guide/jfs.rst>.
If you do not intend to use the JFS filesystem, say N.
config JFS_POSIX_ACL
bool "JFS POSIX Access Control Lists"
depends on JFS_FS
select FS_POSIX_ACL
help
Posix Access Control Lists (ACLs) support permissions for users and
groups beyond the owner/group/world scheme.
If you don't know what Access Control Lists are, say N
config JFS_SECURITY
bool "JFS Security Labels"
depends on JFS_FS
help
Security labels support alternative access control models
implemented by security modules like SELinux. This option
enables an extended attribute handler for file security
labels in the jfs filesystem.
If you are not using a security module that requires using
extended attributes for file security labels, say N.
config JFS_DEBUG
bool "JFS debugging"
depends on JFS_FS
help
If you are experiencing any problems with the JFS filesystem, say
Y here. This will result in additional debugging messages to be
written to the system log. Under normal circumstances, this
results in very little overhead.
config JFS_STATISTICS
bool "JFS statistics"
depends on JFS_FS
help
Enabling this option will cause statistics from the JFS file system
to be made available to the user in the /proc/fs/jfs/ directory.
| {
"pile_set_name": "Github"
} |
model :model file
3 :#interfaces in model
plotcolors :model colors file
m :first plot descriptor (mwq) ...SEE
dummywell :well coordinates FILE
s :shooting mode (sd) NOTES...
modelgeometry :receiver geometry ..........
sg :second plot descriptor (sgq) ...THIS
r :job descriptor (rlt) DIRECTORY
demo1 :output filename(s)
-80. 80. :range of takeoff angles
.5 :increment in takeoff angle
2000.0 3000.0 4000.0 3000.0 : velocities
y :direct wave? (y or n)
:headwave interface numbers (1, 2, ...)
n :primaries? (y or n)
| {
"pile_set_name": "Github"
} |
import { _ } from "canvax"
import Projection from './projection'
let rate = 0.75
/**
*
* @param {Object} geoData
* @param {Object} graphBBox 绘制在什么位置{x,y,width,height}
*/
export default function( geoData , graphBBox, specialArea={} )
{
//先过一遍解码,么有编码的数据会直接返回
geoData.json = decode( geoData.json );
let data = _getProjectionData( geoData, graphBBox, specialArea );
return data;
}
let _getProjectionData = ( geoData, graphBBox, specialArea ) => {
var province = [];
var bbox = geoData.bbox || Projection.getBbox( geoData.json , specialArea );
var transform = _getTransform(
bbox,graphBBox,
rate
);
var lastTransform = geoData.lastTransform || {
scale: {}
};
var pathArray;
if (transform.left != lastTransform.left || transform.top != lastTransform.top || transform.scale.x != lastTransform.scale.x || transform.scale.y != lastTransform.scale.y) {
//发生过变化,需要重新生成pathArray
pathArray = Projection.geoJson2Path( geoData.json, transform, specialArea );
lastTransform = _.clone(transform);
} else {
transform = geoData.transform;
pathArray = geoData.pathArray;
}
geoData.bbox = bbox;
geoData.transform = transform;
geoData.lastTransform = lastTransform;
geoData.pathArray = pathArray;
var position = [transform.left, transform.top];
for (var i = 0, l = pathArray.length; i < l; i++) {
province.push( _getSingleProvince(
geoData, pathArray[i], position, bbox
));
};
return province;
}
let _getTransform = (bbox, graphBBox, rate) => {
let {width,height} = graphBBox;
var mapWidth = bbox.width;
var mapHeight = bbox.height;
//var minScale;
var xScale = (width / rate) / mapWidth;
var yScale = height / mapHeight;
if (xScale > yScale) {
//minScale = yScale;
xScale = yScale * rate;
width = mapWidth * xScale;
} else {
yScale = xScale;
xScale = yScale * rate;
height = mapHeight * yScale;
}
return {
left: 0,
top: 0,
width: width,
height: height,
baseScale: 1,
scale: {
x: xScale,
y: yScale
}
};
}
let _getSingleProvince = (geoData, path, position, bbox) => {
var textPosition;
var name = path.properties.name;
var textFixed = [0, 0];
if (path.cp) {
textPosition = [
path.cp[0] + textFixed[0],
path.cp[1] + textFixed[1]
];
} else {
textPosition = geo2pos(
geoData, [bbox.left + bbox.width / 2, bbox.top + bbox.height / 2]
);
textPosition[0] += textFixed[0];
textPosition[1] += textFixed[1];
}
path.name = name;
path.position = position;
path.textX = textPosition[0];
path.textY = textPosition[1];
return path;
}
/**
* 经纬度转平面坐标
* @param {Object} p
*/
let geo2pos = (geoData, p) => {
if (!geoData.transform) {
return null;
};
return Projection.geo2pos(
geoData.transform, p
);
}
//geoJson有的加过密,比如百度图表库的geoJson
let decode = (geoData) => {
if (!geoData.UTF8Encoding) {
return geoData;
}
var features = geoData.features;
for (var f = 0; f < features.length; f++) {
var feature = features[f];
var coordinates = feature.geometry.coordinates;
var encodeOffsets = feature.geometry.encodeOffsets;
for (var c = 0; c < coordinates.length; c++) {
var coordinate = coordinates[c];
if (feature.geometry.type === 'Polygon') {
coordinates[c] = decodePolygon(
coordinate,
encodeOffsets[c]
);
} else if (feature.geometry.type === 'MultiPolygon') {
for (var c2 = 0; c2 < coordinate.length; c2++) {
var polygon = coordinate[c2];
coordinate[c2] = decodePolygon(
polygon,
encodeOffsets[c][c2]
);
}
}
}
}
// Has been decoded
geoData.UTF8Encoding = false;
return geoData;
}
let decodePolygon = (coordinate, encodeOffsets) => {
var result = [];
var prevX = encodeOffsets[0];
var prevY = encodeOffsets[1];
for (var i = 0; i < coordinate.length; i+=2) {
var x = coordinate.charCodeAt(i) - 64;
var y = coordinate.charCodeAt(i+1) - 64;
// ZigZag decoding
x = (x >> 1) ^ (-(x & 1));
y = (y >> 1) ^ (-(y & 1));
// Delta deocding
x += prevX;
y += prevY;
prevX = x;
prevY = y;
// Dequantize
result.push([x / 1024, y / 1024]);
}
return result;
} | {
"pile_set_name": "Github"
} |
Module(body=[ClassDef(name='Stuff',
bases=[],
body=[FunctionDef(name='__init__',
args=arguments(args=[Name(id='self',
ctx=Param())],
vararg=None,
kwarg=None,
defaults=[]),
body=[Assign(targets=[Attribute(value=Name(id='self',
ctx=Load()),
attr='a',
ctx=Store())],
value=Num(n=0)),
Assign(targets=[Attribute(value=Name(id='self',
ctx=Load()),
attr='b',
ctx=Store())],
value=Str(s='b')),
Assign(targets=[Attribute(value=Name(id='self',
ctx=Load()),
attr='c',
ctx=Store())],
value=List(elts=[Num(n=1),
Num(n=2),
Num(n=3)],
ctx=Load())),
Assign(targets=[Attribute(value=Name(id='self',
ctx=Load()),
attr='d',
ctx=Store())],
value=Num(n=100000000000000))],
decorator_list=[]),
FunctionDef(name='doit',
args=arguments(args=[Name(id='self',
ctx=Param())],
vararg=None,
kwarg=None,
defaults=[]),
body=[AugAssign(target=Attribute(value=Name(id='self',
ctx=Load()),
attr='a',
ctx=Store()),
op=Add(),
value=Num(n=10)),
AugAssign(target=Attribute(value=Name(id='self',
ctx=Load()),
attr='b',
ctx=Store()),
op=Add(),
value=Str(s='dog')),
AugAssign(target=Attribute(value=Name(id='self',
ctx=Load()),
attr='c',
ctx=Store()),
op=Add(),
value=List(elts=[Num(n=9),
Num(n=10)],
ctx=Load())),
AugAssign(target=Attribute(value=Name(id='self',
ctx=Load()),
attr='d',
ctx=Store()),
op=Add(),
value=Num(n=10000))],
decorator_list=[])],
decorator_list=[]),
Assign(targets=[Name(id='s',
ctx=Store())],
value=Call(func=Name(id='Stuff',
ctx=Load()),
args=[],
keywords=[],
starargs=None,
kwargs=None)),
Expr(value=Call(func=Attribute(value=Name(id='s',
ctx=Load()),
attr='doit',
ctx=Load()),
args=[],
keywords=[],
starargs=None,
kwargs=None)),
Print(dest=None,
values=[Attribute(value=Name(id='s',
ctx=Load()),
attr='a',
ctx=Load())],
nl=True),
Print(dest=None,
values=[Attribute(value=Name(id='s',
ctx=Load()),
attr='b',
ctx=Load())],
nl=True),
Print(dest=None,
values=[Attribute(value=Name(id='s',
ctx=Load()),
attr='c',
ctx=Load())],
nl=True),
Print(dest=None,
values=[Attribute(value=Name(id='s',
ctx=Load()),
attr='d',
ctx=Load())],
nl=True)])
| {
"pile_set_name": "Github"
} |
<input type="checkbox"
class="mblCheckBox mblCheckBoxChecked" value="${value}" tabindex="0"
style="-webkit-user-select: none;" aria-checked="true">
| {
"pile_set_name": "Github"
} |
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2015-2019 Baldur Karlsson
*
* 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.
******************************************************************************/
#pragma once
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Documentation for the API is available at https://renderdoc.org/docs/in_application_api.html
//
#if !defined(RENDERDOC_NO_STDINT)
#include <stdint.h>
#endif
#if defined(WIN32)
#define RENDERDOC_CC __cdecl
#elif defined(__linux__)
#define RENDERDOC_CC
#elif defined(__APPLE__)
#define RENDERDOC_CC
#else
#error "Unknown platform"
#endif
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////
// Constants not used directly in below API
// This is a GUID/magic value used for when applications pass a path where shader debug
// information can be found to match up with a stripped shader.
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue =
// RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct \
{ \
0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// as an alternative when you want a byte array (assuming x86 endianness):
#define RENDERDOC_ShaderDebugMagicValue_bytearray \
{ \
0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff \
}
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc capture options
//
typedef enum RENDERDOC_CaptureOption {
// Allow the application to enable vsync
//
// Default - enabled
//
// 1 - The application can enable or disable vsync at will
// 0 - vsync is force disabled
eRENDERDOC_Option_AllowVSync = 0,
// Allow the application to enable fullscreen
//
// Default - enabled
//
// 1 - The application can enable or disable fullscreen at will
// 0 - fullscreen is force disabled
eRENDERDOC_Option_AllowFullscreen = 1,
// Record API debugging events and messages
//
// Default - disabled
//
// 1 - Enable built-in API debugging features and records the results into
// the capture, which is matched up with events on replay
// 0 - no API debugging is forcibly enabled
eRENDERDOC_Option_APIValidation = 2,
eRENDERDOC_Option_DebugDeviceMode = 2, // deprecated name of this enum
// Capture CPU callstacks for API events
//
// Default - disabled
//
// 1 - Enables capturing of callstacks
// 0 - no callstacks are captured
eRENDERDOC_Option_CaptureCallstacks = 3,
// When capturing CPU callstacks, only capture them from drawcalls.
// This option does nothing without the above option being enabled
//
// Default - disabled
//
// 1 - Only captures callstacks for drawcall type API events.
// Ignored if CaptureCallstacks is disabled
// 0 - Callstacks, if enabled, are captured for every event.
eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
// Specify a delay in seconds to wait for a debugger to attach, after
// creating or injecting into a process, before continuing to allow it to run.
//
// 0 indicates no delay, and the process will run immediately after injection
//
// Default - 0 seconds
//
eRENDERDOC_Option_DelayForDebugger = 5,
// Verify buffer access. This includes checking the memory returned by a Map() call to
// detect any out-of-bounds modification, as well as initialising buffers with undefined contents
// to a marker value to catch use of uninitialised memory.
//
// NOTE: This option is only valid for OpenGL and D3D11. Explicit APIs such as D3D12 and Vulkan do
// not do the same kind of interception & checking and undefined contents are really undefined.
//
// Default - disabled
//
// 1 - Verify buffer access
// 0 - No verification is performed, and overwriting bounds may cause crashes or corruption in
// RenderDoc.
eRENDERDOC_Option_VerifyBufferAccess = 6,
// The old name for eRENDERDOC_Option_VerifyBufferAccess was eRENDERDOC_Option_VerifyMapWrites.
// This option now controls the filling of uninitialised buffers with 0xdddddddd which was
// previously always enabled
eRENDERDOC_Option_VerifyMapWrites = eRENDERDOC_Option_VerifyBufferAccess,
// Hooks any system API calls that create child processes, and injects
// RenderDoc into them recursively with the same options.
//
// Default - disabled
//
// 1 - Hooks into spawned child processes
// 0 - Child processes are not hooked by RenderDoc
eRENDERDOC_Option_HookIntoChildren = 7,
// By default RenderDoc only includes resources in the final capture necessary
// for that frame, this allows you to override that behaviour.
//
// Default - disabled
//
// 1 - all live resources at the time of capture are included in the capture
// and available for inspection
// 0 - only the resources referenced by the captured frame are included
eRENDERDOC_Option_RefAllResources = 8,
// **NOTE**: As of RenderDoc v1.1 this option has been deprecated. Setting or
// getting it will be ignored, to allow compatibility with older versions.
// In v1.1 the option acts as if it's always enabled.
//
// By default RenderDoc skips saving initial states for resources where the
// previous contents don't appear to be used, assuming that writes before
// reads indicate previous contents aren't used.
//
// Default - disabled
//
// 1 - initial contents at the start of each captured frame are saved, even if
// they are later overwritten or cleared before being used.
// 0 - unless a read is detected, initial contents will not be saved and will
// appear as black or empty data.
eRENDERDOC_Option_SaveAllInitials = 9,
// In APIs that allow for the recording of command lists to be replayed later,
// RenderDoc may choose to not capture command lists before a frame capture is
// triggered, to reduce overheads. This means any command lists recorded once
// and replayed many times will not be available and may cause a failure to
// capture.
//
// NOTE: This is only true for APIs where multithreading is difficult or
// discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
// and always capture all command lists since the API is heavily oriented
// around it and the overheads have been reduced by API design.
//
// 1 - All command lists are captured from the start of the application
// 0 - Command lists are only captured if their recording begins during
// the period when a frame capture is in progress.
eRENDERDOC_Option_CaptureAllCmdLists = 10,
// Mute API debugging output when the API validation mode option is enabled
//
// Default - enabled
//
// 1 - Mute any API debug messages from being displayed or passed through
// 0 - API debugging is displayed as normal
eRENDERDOC_Option_DebugOutputMute = 11,
// Option to allow vendor extensions to be used even when they may be
// incompatible with RenderDoc and cause corrupted replays or crashes.
//
// Default - inactive
//
// No values are documented, this option should only be used when absolutely
// necessary as directed by a RenderDoc developer.
eRENDERDOC_Option_AllowUnsupportedVendorExtensions = 12,
} RENDERDOC_CaptureOption;
// Sets an option that controls how RenderDoc behaves on capture.
//
// Returns 1 if the option and value are valid
// Returns 0 if either is invalid and the option is unchanged
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
typedef int(RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
// Gets the current value of an option as a uint32_t
//
// If the option is invalid, 0xffffffff is returned
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
// Gets the current value of an option as a float
//
// If the option is invalid, -FLT_MAX is returned
typedef float(RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
typedef enum RENDERDOC_InputButton {
// '0' - '9' matches ASCII values
eRENDERDOC_Key_0 = 0x30,
eRENDERDOC_Key_1 = 0x31,
eRENDERDOC_Key_2 = 0x32,
eRENDERDOC_Key_3 = 0x33,
eRENDERDOC_Key_4 = 0x34,
eRENDERDOC_Key_5 = 0x35,
eRENDERDOC_Key_6 = 0x36,
eRENDERDOC_Key_7 = 0x37,
eRENDERDOC_Key_8 = 0x38,
eRENDERDOC_Key_9 = 0x39,
// 'A' - 'Z' matches ASCII values
eRENDERDOC_Key_A = 0x41,
eRENDERDOC_Key_B = 0x42,
eRENDERDOC_Key_C = 0x43,
eRENDERDOC_Key_D = 0x44,
eRENDERDOC_Key_E = 0x45,
eRENDERDOC_Key_F = 0x46,
eRENDERDOC_Key_G = 0x47,
eRENDERDOC_Key_H = 0x48,
eRENDERDOC_Key_I = 0x49,
eRENDERDOC_Key_J = 0x4A,
eRENDERDOC_Key_K = 0x4B,
eRENDERDOC_Key_L = 0x4C,
eRENDERDOC_Key_M = 0x4D,
eRENDERDOC_Key_N = 0x4E,
eRENDERDOC_Key_O = 0x4F,
eRENDERDOC_Key_P = 0x50,
eRENDERDOC_Key_Q = 0x51,
eRENDERDOC_Key_R = 0x52,
eRENDERDOC_Key_S = 0x53,
eRENDERDOC_Key_T = 0x54,
eRENDERDOC_Key_U = 0x55,
eRENDERDOC_Key_V = 0x56,
eRENDERDOC_Key_W = 0x57,
eRENDERDOC_Key_X = 0x58,
eRENDERDOC_Key_Y = 0x59,
eRENDERDOC_Key_Z = 0x5A,
// leave the rest of the ASCII range free
// in case we want to use it later
eRENDERDOC_Key_NonPrintable = 0x100,
eRENDERDOC_Key_Divide,
eRENDERDOC_Key_Multiply,
eRENDERDOC_Key_Subtract,
eRENDERDOC_Key_Plus,
eRENDERDOC_Key_F1,
eRENDERDOC_Key_F2,
eRENDERDOC_Key_F3,
eRENDERDOC_Key_F4,
eRENDERDOC_Key_F5,
eRENDERDOC_Key_F6,
eRENDERDOC_Key_F7,
eRENDERDOC_Key_F8,
eRENDERDOC_Key_F9,
eRENDERDOC_Key_F10,
eRENDERDOC_Key_F11,
eRENDERDOC_Key_F12,
eRENDERDOC_Key_Home,
eRENDERDOC_Key_End,
eRENDERDOC_Key_Insert,
eRENDERDOC_Key_Delete,
eRENDERDOC_Key_PageUp,
eRENDERDOC_Key_PageDn,
eRENDERDOC_Key_Backspace,
eRENDERDOC_Key_Tab,
eRENDERDOC_Key_PrtScrn,
eRENDERDOC_Key_Pause,
eRENDERDOC_Key_Max,
} RENDERDOC_InputButton;
// Sets which key or keys can be used to toggle focus between multiple windows
//
// If keys is NULL or num is 0, toggle keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
// Sets which key or keys can be used to capture the next frame
//
// If keys is NULL or num is 0, captures keys will be disabled
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
typedef enum RENDERDOC_OverlayBits {
// This single bit controls whether the overlay is enabled or disabled globally
eRENDERDOC_Overlay_Enabled = 0x1,
// Show the average framerate over several seconds as well as min/max
eRENDERDOC_Overlay_FrameRate = 0x2,
// Show the current frame number
eRENDERDOC_Overlay_FrameNumber = 0x4,
// Show a list of recent captures, and how many captures have been made
eRENDERDOC_Overlay_CaptureList = 0x8,
// Default values for the overlay mask
eRENDERDOC_Overlay_Default = (eRENDERDOC_Overlay_Enabled | eRENDERDOC_Overlay_FrameRate |
eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList),
// Enable all bits
eRENDERDOC_Overlay_All = ~0U,
// Disable all bits
eRENDERDOC_Overlay_None = 0,
} RENDERDOC_OverlayBits;
// returns the overlay bits that have been set
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
// sets the overlay bits with an and & or mask
typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
// this function will attempt to shut down RenderDoc.
//
// Note: that this will only work correctly if done immediately after
// the dll is loaded, before any API work happens. RenderDoc will remove its
// injected hooks and shut down. Behaviour is undefined if this is called
// after any API functions have been called.
typedef void(RENDERDOC_CC *pRENDERDOC_Shutdown)();
// This function will unload RenderDoc's crash handler.
//
// If you use your own crash handler and don't want RenderDoc's handler to
// intercede, you can call this function to unload it and any unhandled
// exceptions will pass to the next handler.
typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
// Sets the capture file path template
//
// pathtemplate is a UTF-8 string that gives a template for how captures will be named
// and where they will be saved.
//
// Any extension is stripped off the path, and captures are saved in the directory
// specified, and named with the filename and the frame number appended. If the
// directory does not exist it will be created, including any parent directories.
//
// If pathtemplate is NULL, the template will remain unchanged
//
// Example:
//
// SetCaptureFilePathTemplate("my_captures/example");
//
// Capture #1 -> my_captures/example_frame123.rdc
// Capture #2 -> my_captures/example_frame456.rdc
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate);
// returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string
typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)();
// DEPRECATED: compatibility for code compiled against pre-1.1.2 headers.
typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate;
typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate;
// returns the number of captures that have been made
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
// This function returns the details of a capture, by index. New captures are added
// to the end of the list.
//
// filename will be filled with the absolute path to the capture file, as a UTF-8 string
// pathlength will be written with the length in bytes of the filename string
// timestamp will be written with the time of the capture, in seconds since the Unix epoch
//
// Any of the parameters can be NULL and they'll be skipped.
//
// The function will return 1 if the capture index is valid, or 0 if the index is invalid
// If the index is invalid, the values will be unchanged
//
// Note: when captures are deleted in the UI they will remain in this list, so the
// capture path may not exist anymore.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *filename,
uint32_t *pathlength, uint64_t *timestamp);
// Sets the comments associated with a capture file. These comments are displayed in the
// UI program when opening.
//
// filePath should be a path to the capture file to add comments to. If set to NULL or ""
// the most recent capture file created made will be used instead.
// comments should be a NULL-terminated UTF-8 string to add as comments.
//
// Any existing comments will be overwritten.
typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePath,
const char *comments);
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)();
// DEPRECATED: compatibility for code compiled against pre-1.1.1 headers.
// This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for
// backwards compatibility with old code, it is castable either way since it's ABI compatible
// as the same function pointer type.
typedef pRENDERDOC_IsTargetControlConnected pRENDERDOC_IsRemoteAccessConnected;
// This function will launch the Replay UI associated with the RenderDoc library injected
// into the running application.
//
// if connectTargetControl is 1, the Replay UI will be launched with a command line parameter
// to connect to this application
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
// if cmdline is NULL, the command line will be empty.
//
// returns the PID of the replay UI if successful, 0 if not successful.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectTargetControl,
const char *cmdline);
// RenderDoc can return a higher version than requested if it's backwards compatible,
// this function returns the actual version returned. If a parameter is NULL, it will be
// ignored and the others will be filled out.
typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
//////////////////////////////////////////////////////////////////////////
// Capturing functions
//
// A device pointer is a pointer to the API's root handle.
//
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
typedef void *RENDERDOC_DevicePointer;
// A window handle is the OS's native window handle
//
// This would be an HWND, GLXDrawable, etc
typedef void *RENDERDOC_WindowHandle;
// A helper macro for Vulkan, where the device handle cannot be used directly.
//
// Passing the VkInstance to this macro will return the RENDERDOC_DevicePointer to use.
//
// Specifically, the value needed is the dispatch table pointer, which sits as the first
// pointer-sized object in the memory pointed to by the VkInstance. Thus we cast to a void** and
// indirect once.
#define RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst) (*((void **)(inst)))
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
// respond to keypresses. Neither parameter can be NULL
typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// capture the next frame on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
// capture the next N frames on whichever window and API is currently considered active
typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames);
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
// any API rendering to a specific window, or a specific API instance rendering to any window,
// or in the simplest case of one window and one API, you can just pass NULL for both.
//
// In either case, if there are two or more possible matching (device,window) pairs it
// is undefined which one will be captured.
//
// Note: for headless rendering you can pass NULL for the window handle and either specify
// a device pointer or leave it NULL as above.
// Immediately starts capturing API calls on the specified device pointer and window handle.
//
// If there is no matching thing to capture (e.g. no supported API has been initialised),
// this will do nothing.
//
// The results are undefined (including crashes) if two captures are started overlapping,
// even on separate devices and/oror windows.
typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Returns whether or not a frame capture is currently ongoing anywhere.
//
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
// Ends capturing immediately.
//
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
// Ends capturing immediately and discard any data stored without saving to disk.
//
// This will return 1 if the capture was discarded, and 0 if there was an error or no capture
// was in progress
typedef uint32_t(RENDERDOC_CC *pRENDERDOC_DiscardFrameCapture)(RENDERDOC_DevicePointer device,
RENDERDOC_WindowHandle wndHandle);
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API versions
//
// RenderDoc uses semantic versioning (http://semver.org/).
//
// MAJOR version is incremented when incompatible API changes happen.
// MINOR version is incremented when functionality is added in a backwards-compatible manner.
// PATCH version is incremented when backwards-compatible bug fixes happen.
//
// Note that this means the API returned can be higher than the one you might have requested.
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
typedef enum RENDERDOC_Version {
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 00 00
eRENDERDOC_API_Version_1_0_1 = 10001, // RENDERDOC_API_1_0_1 = 1 00 01
eRENDERDOC_API_Version_1_0_2 = 10002, // RENDERDOC_API_1_0_2 = 1 00 02
eRENDERDOC_API_Version_1_1_0 = 10100, // RENDERDOC_API_1_1_0 = 1 01 00
eRENDERDOC_API_Version_1_1_1 = 10101, // RENDERDOC_API_1_1_1 = 1 01 01
eRENDERDOC_API_Version_1_1_2 = 10102, // RENDERDOC_API_1_1_2 = 1 01 02
eRENDERDOC_API_Version_1_2_0 = 10200, // RENDERDOC_API_1_2_0 = 1 02 00
eRENDERDOC_API_Version_1_3_0 = 10300, // RENDERDOC_API_1_3_0 = 1 03 00
eRENDERDOC_API_Version_1_4_0 = 10400, // RENDERDOC_API_1_4_0 = 1 04 00
} RENDERDOC_Version;
// API version changelog:
//
// 1.0.0 - initial release
// 1.0.1 - Bugfix: IsFrameCapturing() was returning false for captures that were triggered
// by keypress or TriggerCapture, instead of Start/EndFrameCapture.
// 1.0.2 - Refactor: Renamed eRENDERDOC_Option_DebugDeviceMode to eRENDERDOC_Option_APIValidation
// 1.1.0 - Add feature: TriggerMultiFrameCapture(). Backwards compatible with 1.0.x since the new
// function pointer is added to the end of the struct, the original layout is identical
// 1.1.1 - Refactor: Renamed remote access to target control (to better disambiguate from remote
// replay/remote server concept in replay UI)
// 1.1.2 - Refactor: Renamed "log file" in function names to just capture, to clarify that these
// are captures and not debug logging files. This is the first API version in the v1.0
// branch.
// 1.2.0 - Added feature: SetCaptureFileComments() to add comments to a capture file that will be
// displayed in the UI program on load.
// 1.3.0 - Added feature: New capture option eRENDERDOC_Option_AllowUnsupportedVendorExtensions
// which allows users to opt-in to allowing unsupported vendor extensions to function.
// Should be used at the user's own risk.
// Refactor: Renamed eRENDERDOC_Option_VerifyMapWrites to
// eRENDERDOC_Option_VerifyBufferAccess, which now also controls initialisation to
// 0xdddddddd of uninitialised buffer contents.
// 1.4.0 - Added feature: DiscardFrameCapture() to discard a frame capture in progress and stop
// capturing without saving anything to disk.
typedef struct RENDERDOC_API_1_4_0
{
pRENDERDOC_GetAPIVersion GetAPIVersion;
pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
pRENDERDOC_SetCaptureKeys SetCaptureKeys;
pRENDERDOC_GetOverlayBits GetOverlayBits;
pRENDERDOC_MaskOverlayBits MaskOverlayBits;
pRENDERDOC_Shutdown Shutdown;
pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
// Get/SetLogFilePathTemplate was renamed to Get/SetCaptureFilePathTemplate in 1.1.2.
// These unions allow old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
// current name
pRENDERDOC_SetCaptureFilePathTemplate SetCaptureFilePathTemplate;
};
union
{
// deprecated name
pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
// current name
pRENDERDOC_GetCaptureFilePathTemplate GetCaptureFilePathTemplate;
};
pRENDERDOC_GetNumCaptures GetNumCaptures;
pRENDERDOC_GetCapture GetCapture;
pRENDERDOC_TriggerCapture TriggerCapture;
// IsRemoteAccessConnected was renamed to IsTargetControlConnected in 1.1.1.
// This union allows old code to continue compiling without changes
union
{
// deprecated name
pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
// current name
pRENDERDOC_IsTargetControlConnected IsTargetControlConnected;
};
pRENDERDOC_LaunchReplayUI LaunchReplayUI;
pRENDERDOC_SetActiveWindow SetActiveWindow;
pRENDERDOC_StartFrameCapture StartFrameCapture;
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
pRENDERDOC_EndFrameCapture EndFrameCapture;
// new function in 1.1.0
pRENDERDOC_TriggerMultiFrameCapture TriggerMultiFrameCapture;
// new function in 1.2.0
pRENDERDOC_SetCaptureFileComments SetCaptureFileComments;
// new function in 1.4.0
pRENDERDOC_DiscardFrameCapture DiscardFrameCapture;
} RENDERDOC_API_1_4_0;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_0_0;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_0_1;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_0_2;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_1_0;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_1_1;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_1_2;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_2_0;
typedef RENDERDOC_API_1_4_0 RENDERDOC_API_1_3_0;
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc API entry point
//
// This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
//
// The name is the same as the typedef - "RENDERDOC_GetAPI"
//
// This function is not thread safe, and should not be called on multiple threads at once.
// Ideally, call this once as early as possible in your application's startup, before doing
// any API work, since some configuration functionality etc has to be done also before
// initialising any APIs.
//
// Parameters:
// version is a single value from the RENDERDOC_Version above.
//
// outAPIPointers will be filled out with a pointer to the corresponding struct of function
// pointers.
//
// Returns:
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
// 0 - if the requested version is not supported or the arguments are invalid.
//
typedef int(RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
#ifdef __cplusplus
} // extern "C"
#endif
| {
"pile_set_name": "Github"
} |
#include <vector>
#include "caffe/layers/accuracy_layer.hpp"
#include "caffe/util/math_functions.hpp"
namespace caffe {
template <typename Dtype>
__global__ void AccuracyForwardGPU(const int nthreads,
const Dtype* bottom_data, const Dtype* label, Dtype* acc,
const int num, const int dim, const int spatial_dim,
const int num_labels, const int top_k,
const bool has_ignore_label_, const int ignore_label_,
Dtype* counts) {
CUDA_KERNEL_LOOP(index, nthreads) {
const int n = index / spatial_dim;
const int s = index % spatial_dim;
const int label_value = static_cast<int>(label[n * spatial_dim + s]);
const Dtype prob_of_true_class = bottom_data[n * dim
+ label_value * spatial_dim
+ s];
int num_better_predictions = -1; // true_class also counts as "better"
if (has_ignore_label_ && label_value == ignore_label_) {
acc[index] = 0;
counts[index] = 0;
} else {
for (int k = 0; k < num_labels & num_better_predictions < top_k; k++) {
num_better_predictions +=
(bottom_data[n * dim + k * spatial_dim + s] >= prob_of_true_class);
}
acc[index] = (num_better_predictions < top_k);
counts[index] = 1;
}
}
}
template <typename Dtype>
__global__ void AccuracyForwardWithPerClassGPU(const int nthreads,
const Dtype* bottom_data, const Dtype* label,
Dtype* acc, Dtype* counts,
const int num, const int dim, const int spatial_dim,
const int num_labels, const int top_k,
const bool has_ignore_label_, const int ignore_label_) {
CUDA_KERNEL_LOOP(index, nthreads) {
const int n = index / spatial_dim;
const int s = index % spatial_dim;
const int label_value = static_cast<int>(label[n * spatial_dim + s]);
const Dtype prob_of_true_class = bottom_data[n * dim
+ label_value * spatial_dim
+ s];
if (has_ignore_label_ && label_value == ignore_label_) {
// nothing to be done.
} else {
int num_better_predictions = -1; // true_class also counts as "better"
for (int k = 0; k < num_labels & num_better_predictions < top_k; k++) {
num_better_predictions +=
(bottom_data[n * dim + k * spatial_dim + s] >= prob_of_true_class);
}
acc[label_value*nthreads + index] += (num_better_predictions < top_k);
counts[label_value*nthreads + index] = 1;
}
}
}
template <typename Dtype>
void AccuracyLayer<Dtype>::Forward_gpu(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
const Dtype* bottom_data = bottom[0]->gpu_data();
const Dtype* bottom_label = bottom[1]->gpu_data();
const int dim = bottom[0]->count() / outer_num_;
const int num_labels = bottom[0]->shape(label_axis_);
const int nthreads = outer_num_ * inner_num_;
// Since this memory is not used for anything, we use it here to avoid having
// to allocate new GPU memory to accumulate intermediate results.
Dtype* acc_data = bottom[0]->mutable_gpu_diff();
if (top.size() == 1) {
// simple case - report only global accuracy.
// Similarly, this memory is never used elsewhere, and thus we can use it
// to avoid having to allocate additional GPU memory.
Dtype* counts = bottom[1]->mutable_gpu_diff();
// NOLINT_NEXT_LINE(whitespace/operators)
AccuracyForwardGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads, bottom_data, bottom_label,
acc_data, outer_num_, dim, inner_num_, num_labels, top_k_,
has_ignore_label_, ignore_label_, counts);
Dtype acc;
caffe_gpu_asum(nthreads, acc_data, &acc);
Dtype valid_count;
caffe_gpu_asum(nthreads, counts, &valid_count);
if (valid_count > 0) {
top[0]->mutable_cpu_data()[0] = acc / valid_count;
} else {
top[0]->mutable_cpu_data()[0] = 0;
}
} else {
// need to report per-class accuracy as well
// allocate space for more detailed "counts"
nums_buffer_.ReshapeLike(*bottom[0]);
Dtype* counts = nums_buffer_.mutable_gpu_data();
caffe_gpu_set(bottom[0]->count(), Dtype(0), acc_data);
caffe_gpu_set(nums_buffer_.count(), Dtype(0), counts);
// NOLINT_NEXT_LINE(whitespace/operators)
AccuracyForwardWithPerClassGPU<Dtype><<<CAFFE_GET_BLOCKS(nthreads),
CAFFE_CUDA_NUM_THREADS>>>(nthreads, bottom_data, bottom_label,
acc_data, counts, outer_num_, dim, inner_num_, num_labels, top_k_,
has_ignore_label_, ignore_label_);
// get the overall accuracy
Dtype acc;
caffe_gpu_asum(bottom[0]->count(), acc_data, &acc);
Dtype valid_count;
caffe_gpu_asum(nums_buffer_.count(), counts, &valid_count);
if (valid_count > 0) {
top[0]->mutable_cpu_data()[0] = acc / valid_count;
} else {
top[0]->mutable_cpu_data()[0] = 0;
}
// get per-class accuracy
Dtype* per_class_acc = top[1]->mutable_cpu_data();
for (int l = 0; l < num_labels; l++) {
caffe_gpu_asum(nthreads, acc_data + l*nthreads, per_class_acc+l);
caffe_gpu_asum(nthreads, counts + l*nthreads, &valid_count);
if (valid_count > 0) {
per_class_acc[l] /= valid_count;
} else {
per_class_acc[l] = 0;
}
}
}
// Clear scratch memory to prevent interfering with backward (see #6202).
caffe_gpu_set(bottom[0]->count(), Dtype(0), bottom[0]->mutable_gpu_diff());
}
template <typename Dtype>
void AccuracyLayer<Dtype>::Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
if (propagate_down[1]) { NOT_IMPLEMENTED; }
}
INSTANTIATE_LAYER_GPU_FUNCS(AccuracyLayer);
} // namespace caffe
| {
"pile_set_name": "Github"
} |
/** @file $Id: vboxvideo_crtc.c $
*
* VirtualBox Additions Linux kernel video driver, KMS support
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on
* glint_crtc.c
* with the following copyright and permission notice:
*
* Copyright 2010 Matt Turner.
*
* 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: Matt Turner
*/
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
#include <VBox/VBoxVideoGuest.h>
#include "vboxvideo_drv.h"
#include "drm/drm_crtc_helper.h"
static void vboxvideo_crtc_dpms(struct drm_crtc *crtc, int mode)
{
struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct vboxvideo_device *gdev = dev->dev_private;
if (mode == vboxvideo_crtc->last_dpms) /* Don't do unnecesary mode changes. */
return;
vboxvideo_crtc->last_dpms = mode;
switch (mode) {
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
vboxvideo_crtc->enabled = false;
break;
case DRM_MODE_DPMS_ON:
vboxvideo_crtc->enabled = true;
break;
}
}
static bool vboxvideo_crtc_mode_fixup(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
return true;
}
static int vboxvideo_crtc_mode_set(struct drm_crtc *crtc,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode,
int x, int y, struct drm_framebuffer *old_fb)
{
/*
struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
vboxvideo_crtc_set_base(crtc, x, y, old_fb);
vboxvideo_set_crtc_timing(crtc, adjusted_mode);
vboxvideo_set_pll(crtc, adjusted_mode);
*/
return 0;
}
static void vboxvideo_crtc_prepare(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct drm_crtc *crtci;
/*
list_for_each_entry(crtci, &dev->mode_config.crtc_list, head)
vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_OFF);
*/
}
static void vboxvideo_crtc_commit(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct drm_crtc *crtci;
/*
list_for_each_entry(crtci, &dev->mode_config.crtc_list, head) {
if (crtci->enabled)
vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_ON);
}
*/
}
static void vboxvideo_crtc_load_lut(struct drm_crtc *crtc)
{
/* Dummy */
}
static void vboxvideo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
u16 *green, u16 *blue, uint32_t size)
{
/* Dummy */
}
static void vboxvideo_crtc_destroy(struct drm_crtc *crtc)
{
struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
drm_crtc_cleanup(crtc);
kfree(vboxvideo_crtc);
}
static const struct drm_crtc_funcs vboxvideo_crtc_funcs = {
/*
.cursor_set = vboxvideo_crtc_cursor_set,
.cursor_move = vboxvideo_crtc_cursor_move,
*/
.cursor_set = NULL,
.cursor_move = NULL,
.gamma_set = vboxvideo_crtc_gamma_set,
.set_config = drm_crtc_helper_set_config,
.destroy = vboxvideo_crtc_destroy,
};
static const struct drm_crtc_helper_funcs vboxvideo_helper_funcs = {
.dpms = vboxvideo_crtc_dpms,
.mode_fixup = vboxvideo_crtc_mode_fixup,
.mode_set = vboxvideo_crtc_mode_set,
/*
.mode_set_base = vboxvideo_crtc_set_base,
*/
.prepare = vboxvideo_crtc_prepare,
.commit = vboxvideo_crtc_commit,
.load_lut = vboxvideo_crtc_load_lut,
};
void vboxvideo_crtc_init(struct drm_device *dev, int index)
{
struct vboxvideo_device *gdev = dev->dev_private;
struct vboxvideo_crtc *vboxvideo_crtc;
int i;
vboxvideo_crtc = kzalloc( sizeof(struct vboxvideo_crtc)
+ (VBOXVIDEOFB_CONN_LIMIT
* sizeof(struct drm_connector *)),
GFP_KERNEL);
if (vboxvideo_crtc == NULL)
return;
drm_crtc_init(dev, &vboxvideo_crtc->base, &vboxvideo_crtc_funcs);
vboxvideo_crtc->crtc_id = index;
vboxvideo_crtc->last_dpms = VBOXVIDEO_DPMS_CLEARED;
gdev->mode_info.crtcs[index] = vboxvideo_crtc;
drm_crtc_helper_add(&vboxvideo_crtc->base, &vboxvideo_helper_funcs);
}
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
| {
"pile_set_name": "Github"
} |
/*
* $Xorg: ifparser.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
*
* Copyright 1992 Network Computing Devices, Inc.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Network Computing Devices may not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. Network Computing Devices makes
* no representations about the suitability of this software for any purpose.
* It is provided ``as is'' without express or implied warranty.
*
* NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Author: Jim Fulton
* Network Computing Devices, Inc.
*
* Simple if statement processor
*
* This module can be used to evaluate string representations of C language
* if constructs. It accepts the following grammar:
*
* EXPRESSION := VALUE
* | VALUE BINOP EXPRESSION
* | VALUE '?' EXPRESSION ':' EXPRESSION
*
* VALUE := '(' EXPRESSION ')'
* | '!' VALUE
* | '-' VALUE
* | '+' VALUE
* | '~' VALUE
* | 'defined' '(' variable ')'
* | 'defined' variable
* | # variable '(' variable-list ')'
* | variable
* | number
*
* BINOP := '*' | '/' | '%'
* | '+' | '-'
* | '<<' | '>>'
* | '<' | '>' | '<=' | '>='
* | '==' | '!='
* | '&' | '^' | '|'
* | '&&' | '||'
*
* The normal C order of precedence is supported.
*
*
* External Entry Points:
*
* ParseIfExpression parse a string for #if
*/
/* $XFree86: xc/config/makedepend/ifparser.c,v 3.11 2002/09/23 01:48:08 tsi Exp $ */
#include "ifparser.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/****************************************************************************
Internal Macros and Utilities for Parser
****************************************************************************/
#define DO(val) if (!(val)) return NULL
#define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))
#define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
static const char *
parse_variable (IfParser *g, const char *cp, const char **varp)
{
SKIPSPACE (cp);
if (!isvarfirstletter (*cp))
return CALLFUNC(g, handle_error) (g, cp, "variable name");
*varp = cp;
/* EMPTY */
for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
return cp;
}
static const char *
parse_number (IfParser *g, const char *cp, long *valp)
{
long base = 10;
SKIPSPACE (cp);
if (!isdigit(*cp))
return CALLFUNC(g, handle_error) (g, cp, "number");
*valp = 0;
if (*cp == '0') {
cp++;
if ((*cp == 'x') || (*cp == 'X')) {
base = 16;
cp++;
} else {
base = 8;
}
}
/* Ignore overflows and assume ASCII, what source is usually written in */
while (1) {
int increment = -1;
if (base == 8) {
if ((*cp >= '0') && (*cp <= '7'))
increment = *cp++ - '0';
} else if (base == 16) {
if ((*cp >= '0') && (*cp <= '9'))
increment = *cp++ - '0';
else if ((*cp >= 'A') && (*cp <= 'F'))
increment = *cp++ - ('A' - 10);
else if ((*cp >= 'a') && (*cp <= 'f'))
increment = *cp++ - ('a' - 10);
} else { /* Decimal */
if ((*cp >= '0') && (*cp <= '9'))
increment = *cp++ - '0';
}
if (increment < 0)
break;
*valp = (*valp * base) + increment;
}
/* Skip trailing qualifiers */
while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
return cp;
}
static const char *
parse_character (IfParser *g, const char *cp, long *valp)
{
char val;
SKIPSPACE (cp);
if (*cp == '\\')
switch (cp[1]) {
case 'n': val = '\n'; break;
case 't': val = '\t'; break;
case 'v': val = '\v'; break;
case 'b': val = '\b'; break;
case 'r': val = '\r'; break;
case 'f': val = '\f'; break;
case 'a': val = '\a'; break;
case '\\': val = '\\'; break;
case '?': val = '\?'; break;
case '\'': val = '\''; break;
case '\"': val = '\"'; break;
case 'x': val = (char) strtol (cp + 2, NULL, 16); break;
default: val = (char) strtol (cp + 1, NULL, 8); break;
}
else
val = *cp;
while (*cp != '\'') cp++;
*valp = (long) val;
return cp;
}
static const char *
parse_value (IfParser *g, const char *cp, long *valp)
{
const char *var, *varend;
*valp = 0;
SKIPSPACE (cp);
if (!*cp)
return cp;
switch (*cp) {
case '(':
DO (cp = ParseIfExpression (g, cp + 1, valp));
SKIPSPACE (cp);
if (*cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
return cp + 1; /* skip the right paren */
case '!':
DO (cp = parse_value (g, cp + 1, valp));
*valp = !(*valp);
return cp;
case '-':
DO (cp = parse_value (g, cp + 1, valp));
*valp = -(*valp);
return cp;
case '+':
DO (cp = parse_value (g, cp + 1, valp));
return cp;
case '~':
DO (cp = parse_value (g, cp + 1, valp));
*valp = ~(*valp);
return cp;
case '#':
DO (cp = parse_variable (g, cp + 1, &var));
SKIPSPACE (cp);
if (*cp != '(')
return CALLFUNC(g, handle_error) (g, cp, "(");
do {
DO (cp = parse_variable (g, cp + 1, &var));
SKIPSPACE (cp);
} while (*cp && *cp != ')');
if (*cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
*valp = 1; /* XXX */
return cp + 1;
case '\'':
DO (cp = parse_character (g, cp + 1, valp));
if (*cp != '\'')
return CALLFUNC(g, handle_error) (g, cp, "'");
return cp + 1;
case 'd':
if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
int paren = 0;
int len;
cp += 7;
SKIPSPACE (cp);
if (*cp == '(') {
paren = 1;
cp++;
}
DO (cp = parse_variable (g, cp, &var));
len = cp - var;
SKIPSPACE (cp);
if (paren && *cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
*valp = (*(g->funcs.eval_defined)) (g, var, len);
return cp + paren; /* skip the right paren */
}
/* fall out */
}
if (isdigit(*cp)) {
DO (cp = parse_number (g, cp, valp));
} else if (!isvarfirstletter(*cp))
return CALLFUNC(g, handle_error) (g, cp, "variable or number");
else {
DO (cp = parse_variable (g, cp, &var));
varend = cp;
SKIPSPACE(cp);
if (*cp != '(') {
*valp = (*(g->funcs.eval_variable)) (g, var, varend - var);
} else {
do {
long dummy;
DO (cp = ParseIfExpression (g, cp + 1, &dummy));
SKIPSPACE(cp);
if (*cp == ')')
break;
if (*cp != ',')
return CALLFUNC(g, handle_error) (g, cp, ",");
} while (1);
*valp = 1; /* XXX */
cp++;
}
}
return cp;
}
static const char *
parse_product (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_value (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '*':
DO (cp = parse_product (g, cp + 1, &rightval));
*valp = (*valp * rightval);
break;
case '/':
DO (cp = parse_product (g, cp + 1, &rightval));
if (rightval == 0)
return CALLFUNC(g, handle_error) (g, cp, "0");
*valp = (*valp / rightval);
break;
case '%':
DO (cp = parse_product (g, cp + 1, &rightval));
*valp = (*valp % rightval);
break;
}
return cp;
}
static const char *
parse_sum (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_product (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '+':
DO (cp = parse_sum (g, cp + 1, &rightval));
*valp = (*valp + rightval);
break;
case '-':
DO (cp = parse_sum (g, cp + 1, &rightval));
*valp = (*valp - rightval);
break;
}
return cp;
}
static const char *
parse_shift (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_sum (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '<':
if (cp[1] == '<') {
DO (cp = parse_shift (g, cp + 2, &rightval));
*valp = (*valp << rightval);
}
break;
case '>':
if (cp[1] == '>') {
DO (cp = parse_shift (g, cp + 2, &rightval));
*valp = (*valp >> rightval);
}
break;
}
return cp;
}
static const char *
parse_inequality (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_shift (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '<':
if (cp[1] == '=') {
DO (cp = parse_inequality (g, cp + 2, &rightval));
*valp = (*valp <= rightval);
} else {
DO (cp = parse_inequality (g, cp + 1, &rightval));
*valp = (*valp < rightval);
}
break;
case '>':
if (cp[1] == '=') {
DO (cp = parse_inequality (g, cp + 2, &rightval));
*valp = (*valp >= rightval);
} else {
DO (cp = parse_inequality (g, cp + 1, &rightval));
*valp = (*valp > rightval);
}
break;
}
return cp;
}
static const char *
parse_equality (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_inequality (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '=':
if (cp[1] == '=')
cp++;
DO (cp = parse_equality (g, cp + 1, &rightval));
*valp = (*valp == rightval);
break;
case '!':
if (cp[1] != '=')
break;
DO (cp = parse_equality (g, cp + 2, &rightval));
*valp = (*valp != rightval);
break;
}
return cp;
}
static const char *
parse_band (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_equality (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '&':
if (cp[1] != '&') {
DO (cp = parse_band (g, cp + 1, &rightval));
*valp = (*valp & rightval);
}
break;
}
return cp;
}
static const char *
parse_bxor (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_band (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '^':
DO (cp = parse_bxor (g, cp + 1, &rightval));
*valp = (*valp ^ rightval);
break;
}
return cp;
}
static const char *
parse_bor (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_bxor (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '|':
if (cp[1] != '|') {
DO (cp = parse_bor (g, cp + 1, &rightval));
*valp = (*valp | rightval);
}
break;
}
return cp;
}
static const char *
parse_land (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_bor (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '&':
if (cp[1] != '&')
return CALLFUNC(g, handle_error) (g, cp, "&&");
DO (cp = parse_land (g, cp + 2, &rightval));
*valp = (*valp && rightval);
break;
}
return cp;
}
static const char *
parse_lor (IfParser *g, const char *cp, long *valp)
{
long rightval;
DO (cp = parse_land (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '|':
if (cp[1] != '|')
return CALLFUNC(g, handle_error) (g, cp, "||");
DO (cp = parse_lor (g, cp + 2, &rightval));
*valp = (*valp || rightval);
break;
}
return cp;
}
static const char *
parse_cond(IfParser *g, const char *cp, long *valp)
{
long trueval, falseval;
DO (cp = parse_lor (g, cp, valp));
SKIPSPACE (cp);
switch (*cp) {
case '?':
DO (cp = parse_cond (g, cp + 1, &trueval));
SKIPSPACE (cp);
if (*cp != ':')
return CALLFUNC(g, handle_error) (g, cp, ":");
DO (cp = parse_cond (g, cp + 1, &falseval));
*valp = (*valp ? trueval : falseval);
break;
}
return cp;
}
/****************************************************************************
External Entry Points
****************************************************************************/
const char *
ParseIfExpression (IfParser *g, const char *cp, long *valp)
{
return parse_cond (g, cp, valp);
}
| {
"pile_set_name": "Github"
} |
ASK {}
| {
"pile_set_name": "Github"
} |
# Versioning Library for Go
[](https://travis-ci.org/hashicorp/go-version)
go-version is a library for parsing versions and version constraints,
and verifying versions against a set of constraints. go-version
can sort a collection of versions properly, handles prerelease/beta
versions, can increment versions, etc.
Versions used with go-version must follow [SemVer](http://semver.org/).
## Installation and Usage
Package documentation can be found on
[GoDoc](http://godoc.org/github.com/hashicorp/go-version).
Installation can be done with a normal `go get`:
```
$ go get github.com/hashicorp/go-version
```
#### Version Parsing and Comparison
```go
v1, err := version.NewVersion("1.2")
v2, err := version.NewVersion("1.5+metadata")
// Comparison example. There is also GreaterThan, Equal, and just
// a simple Compare that returns an int allowing easy >=, <=, etc.
if v1.LessThan(v2) {
fmt.Printf("%s is less than %s", v1, v2)
}
```
#### Version Constraints
```go
v1, err := version.NewVersion("1.2")
// Constraints example.
constraints, err := version.NewConstraint(">= 1.0, < 1.4")
if constraints.Check(v1) {
fmt.Printf("%s satisfies constraints %s", v1, constraints)
}
```
#### Version Sorting
```go
versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"}
versions := make([]*version.Version, len(versionsRaw))
for i, raw := range versionsRaw {
v, _ := version.NewVersion(raw)
versions[i] = v
}
// After this, the versions are properly sorted
sort.Sort(version.Collection(versions))
```
## Issues and Contributing
If you find an issue with this library, please report an issue. If you'd
like, we welcome any contributions. Fork this library and submit a pull
request.
| {
"pile_set_name": "Github"
} |
################################################################################
#
# jsoncpp
#
################################################################################
JSONCPP_VERSION = 1.9.2
JSONCPP_SITE = $(call github,open-source-parsers,jsoncpp,$(JSONCPP_VERSION))
JSONCPP_LICENSE = Public Domain or MIT
JSONCPP_LICENSE_FILES = LICENSE
JSONCPP_INSTALL_STAGING = YES
JSONCPP_CONF_OPTS = -Dtests=false
$(eval $(meson-package))
| {
"pile_set_name": "Github"
} |
# Test app
Tests installing a module that depends on two modules that use node-pre-gyp at build time.
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout android:id="@+id/encyclopedia_location_hub_item"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:background="@drawable/list_item_bg_selector"
android:clickable="true"
android:padding="3sp">
<TextView android:id="@+id/encyclopedia_location_hub_name"
style="@style/PlayNameStyle"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10sp"
android:layout_gravity="center"/>
</LinearLayout>
<View android:id="@+id/list_divider"
android:layout_height="1sp"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:background="#e0e0e0" />
</LinearLayout> | {
"pile_set_name": "Github"
} |
//*@@@+++@@@@******************************************************************
//
// Microsoft Windows Media Foundation
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//*@@@---@@@@******************************************************************
//
#include "stdafx.h"
#include "multipinmft.h"
#ifdef MF_WPP
#include "multipinmft.tmh" //--REF_ANALYZER_DONT_REMOVE--
#endif
//
// Note since MFT_UNIQUE_METHOD_NAMES is defined all the functions of IMFTransform have the Mft suffix..
//
extern const CLSID CLSID_HwMFTActivate;
CMultipinMft::CMultipinMft()
: m_nRefCount( 0 ),
m_InputPinCount( 0 ),
m_OutputPinCount( 0 ),
m_dwWorkQueueId ( MFASYNC_CALLBACK_QUEUE_MULTITHREADED ),
m_lWorkQueuePriority ( 0 ),
m_spAttributes( nullptr ),
m_spSourceTransform( nullptr ),
m_SymbolicLink(nullptr)
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
, m_spPhotoConfirmationCallback(nullptr)
, m_firePhotoConfirmation(FALSE)
#endif
#if defined (MF_DEVICEMFT_WARMSTART_HANDLING)
, m_dwWarmStartMask(0)
#endif
{
HRESULT hr = S_OK;
ComPtr<IMFAttributes> pAttributes = nullptr;
MFCreateAttributes( &pAttributes, 0 );
DMFTCHECKHR_GOTO(pAttributes->SetUINT32( MF_TRANSFORM_ASYNC, TRUE ),done);
DMFTCHECKHR_GOTO(pAttributes->SetUINT32( MFT_SUPPORT_DYNAMIC_FORMAT_CHANGE, TRUE ),done);
DMFTCHECKHR_GOTO(pAttributes->SetUINT32( MF_SA_D3D_AWARE, TRUE ), done);
DMFTCHECKHR_GOTO(pAttributes->SetString( MFT_ENUM_HARDWARE_URL_Attribute, L"SampleMultiPinMft" ),done);
m_spAttributes = pAttributes;
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
m_guidPhotoConfirmationSubtype = MFVideoFormat_NV12;
#endif
done:
if (FAILED(hr))
{
}
}
CMultipinMft::~CMultipinMft( )
{
for ( ULONG ulIndex = 0, ulSize = (ULONG) m_InPins.size(); ulIndex < ulSize; ulIndex++ )
{
SAFERELEASE(m_InPins[ ulIndex ]);
}
m_InPins.clear();
for (ULONG ulIndex = 0, ulSize = (ULONG) m_OutPins.size(); ulIndex < ulSize; ulIndex++)
{
SAFERELEASE(m_OutPins[ ulIndex ]);
}
m_OutPins.clear();
SAFE_ARRAYDELETE(m_SymbolicLink);
m_spSourceTransform = nullptr;
}
STDMETHODIMP_(ULONG) CMultipinMft::AddRef(
void
)
{
return InterlockedIncrement(&m_nRefCount);
}
STDMETHODIMP_(ULONG) CMultipinMft::Release(
void
)
{
ULONG uCount = InterlockedDecrement(&m_nRefCount);
if ( uCount == 0 )
{
delete this;
}
return uCount;
}
STDMETHODIMP CMultipinMft::QueryInterface(
_In_ REFIID iid,
_COM_Outptr_ void** ppv
)
{
HRESULT hr = S_OK;
*ppv = NULL;
if ((iid == __uuidof(IMFDeviceTransform)) || (iid == __uuidof(IUnknown)))
{
*ppv = static_cast< IMFDeviceTransform* >(this);
}
else if ( iid == __uuidof( IMFMediaEventGenerator ) )
{
*ppv = static_cast< IMFMediaEventGenerator* >(this);
}
else if ( iid == __uuidof( IMFShutdown ) )
{
*ppv = static_cast< IMFShutdown* >( this );
}
#if defined (MF_DEVICEMFT_ALLOW_MFT0_LOAD) && defined (MFT_UNIQUE_METHOD_NAMES)
else if (iid == __uuidof(IMFTransform))
{
*ppv = static_cast< IMFTransform* >(this);
}
#endif
else if ( iid == __uuidof( IKsControl ) )
{
*ppv = static_cast< IKsControl* >( this );
}
else if ( iid == __uuidof( IMFRealTimeClientEx ) )
{
*ppv = static_cast< IMFRealTimeClientEx* >( this );
}
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
else if (iid == __uuidof(IMFCapturePhotoConfirmation))
{
*ppv = static_cast< IMFCapturePhotoConfirmation* >(this);
}
else if (iid == __uuidof(IMFGetService))
{
*ppv = static_cast< IMFGetService* >(this);
}
#endif
else
{
hr = E_NOINTERFACE;
goto done;
}
AddRef();
done:
return hr;
}
/*++
Description:
This function is the entry point of the transform
The following things may be initialized here
1) Query for MF_DEVICEMFT_CONNECTED_FILTER_KSCONTROL on the attributes supplied
2) From the IUnknown acquired get the IMFTransform interface.
3) Get the stream count.. The output streams are of consequence to the tranform.
The input streams should correspond to the output streams exposed by the source transform
acquired from the Attributes supplied.
4) Get the IKSControl which is used to send KSPROPERTIES, KSEVENTS and KSMETHODS to the driver for the filer level. Store it in your filter class
5) Get the OutPutStreamAttributes for the output pins of the source transform. This can further be used to QI and acquire
the IKSControl related to the specific pin. This can be used to send PIN level KSPROPERTIES, EVENTS and METHODS to the pins
6) Create the output pins
--*/
// This sample will create a grayscale for known media types. Please remove MF_DEVICEMFT_ADD_GRAYSCALER_ to remove the grayscaler
// This sample also has photo confirmation enabled remove DMF_DEVICEMFT_PHTOTOCONFIRMATION to remove photo confirmation
// Please search for the @@@@ README tag for critical sections in code and it's documentation
//
STDMETHODIMP CMultipinMft::InitializeTransform (
_In_ IMFAttributes *pAttributes
)
{
HRESULT hr = S_OK;
ComPtr<IUnknown> spFilterUnk = nullptr;
DWORD *pcInputStreams = NULL, *pcOutputStreams = NULL;
DWORD inputStreams = 0;
DWORD outputStreams = 0;
GUID* outGuids = NULL;
GUID streamCategory = GUID_NULL;
ULONG ulOutPinIndex = 0;
UINT32 uiSymLinkLen = 0;
CPinCreationFactory* pPinFactory = new (std::nothrow) CPinCreationFactory(this);
DMFTCHECKNULL_GOTO( pAttributes, done, E_INVALIDARG );
//
// The attribute passed with MF_DEVICEMFT_CONNECTED_FILTER_KSCONTROL is the source transform. This generally represents a filter
// This needs to be stored so that we know the device properties. We cache it. We query for the IKSControl which is used to send
// controls to the driver.
//
DMFTCHECKHR_GOTO( pAttributes->GetUnknown( MF_DEVICEMFT_CONNECTED_FILTER_KSCONTROL,IID_PPV_ARGS( &spFilterUnk ) ),done );
if (SUCCEEDED(pAttributes->GetStringLength(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &uiSymLinkLen))) // Not available prior to RS5
{
m_SymbolicLink = new (std::nothrow) WCHAR[++uiSymLinkLen];
DMFTCHECKNULL_GOTO(m_SymbolicLink, done, E_OUTOFMEMORY);
DMFTCHECKHR_GOTO(pAttributes->GetString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, m_SymbolicLink, uiSymLinkLen, &uiSymLinkLen), done);
}
DMFTCHECKHR_GOTO( spFilterUnk.As( &m_spSourceTransform ), done );
DMFTCHECKHR_GOTO( m_spSourceTransform.As( &m_spIkscontrol ), done );
DMFTCHECKHR_GOTO( m_spSourceTransform->MFTGetStreamCount( &inputStreams, &outputStreams ), done );
spFilterUnk = nullptr;
//
//The number of input pins created by the device transform should match the pins exposed by
//the source transform i.e. outputStreams from SourceTransform or DevProxy = Input pins of the Device MFT
//
if ( inputStreams > 0 || outputStreams > 0 )
{
pcInputStreams = new (std::nothrow) DWORD[ inputStreams ];
DMFTCHECKNULL_GOTO( pcInputStreams, done, E_OUTOFMEMORY);
pcOutputStreams = new (std::nothrow) DWORD[ outputStreams ];
DMFTCHECKNULL_GOTO( pcOutputStreams, done, E_OUTOFMEMORY );
DMFTCHECKHR_GOTO( m_spSourceTransform->MFTGetStreamIDs( inputStreams, pcInputStreams,
outputStreams,
pcOutputStreams ),done );
//
// Output pins from DevProxy = Input pins of device MFT.. We are the first transform in the pipeline before MFT0
//
for ( ULONG ulIndex = 0; ulIndex < outputStreams; ulIndex++ )
{
ComPtr<IMFAttributes> pInAttributes = nullptr;
BOOL bCustom = FALSE;
ComPtr<CInPin> spInPin;
DMFTCHECKHR_GOTO(pPinFactory->CreatePin(
pcOutputStreams[ulIndex], /*Input Pin ID as advertised by the pipeline*/
0, /*This is not needed for Input Pin*/
CPinCreationFactory::DMFT_PIN_INPUT, /*Input Pin*/
(CBasePin**)spInPin.GetAddressOf(),
bCustom), done);
if (bCustom)
{
m_CustomPinCount++;
}
hr = ExceptionBoundary([&]()
{
m_InPins.push_back(spInPin.Get());
});
DMFTCHECKHR_GOTO(hr, done);
DMFTCHECKHR_GOTO( spInPin->Init(m_spSourceTransform.Get() ), done);
spInPin.Detach();
}
//
// Create one on one mapping
//
for (ULONG ulIndex = 0; ulIndex < m_InPins.size(); ulIndex++)
{
ComPtr<COutPin> spoPin;
BOOL bCustom = FALSE;
ComPtr<CInPin> spiPin = ( CInPin * )m_InPins[ ulIndex ];
if (spiPin.Get())
{
BOOL isCustom = false;
if (SUCCEEDED(CheckCustomPin(spiPin.Get(), &isCustom)) && (isCustom))
{
//
// In this sample we are not connecting the custom pin to the output
// This is because we really have no way of testing the custom pin with the
// pipeline.
// This however can be changed if the custom media type is converted here in
// the device MFT and later exposed to the pipeline..
//
continue;
}
DMFTCHECKHR_GOTO(pPinFactory->CreatePin(spiPin->streamId(), /*Input Pin connected to the Output Pin*/
ulOutPinIndex, /*Output pin Id*/
CPinCreationFactory::DMFT_PIN_OUTPUT, /*Output pin */
(CBasePin**)spoPin.ReleaseAndGetAddressOf(),
bCustom), done);
hr = BridgeInputPinOutputPin(spiPin.Get(), spoPin.Get());
if (SUCCEEDED(hr))
{
DMFTCHECKHR_GOTO(ExceptionBoundary([&]()
{
m_OutPins.push_back(spoPin.Get());
}), done);
spoPin.Detach();
ulOutPinIndex++;
hr = S_OK;
}
if (hr == MF_E_INVALID_STREAM_DATA)
{
// Skip the pin which doesn't have any mediatypes exposed
hr = S_OK;
}
DMFTCHECKHR_GOTO(hr, done);
}
}
}
m_InputPinCount = ULONG ( m_InPins.size() );
m_OutputPinCount = ULONG ( m_OutPins.size() );
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!",hr,hr);
if ( pcInputStreams )
{
delete[ ] ( pcInputStreams );
}
if ( pcOutputStreams )
{
delete[ ] ( pcOutputStreams );
}
if ( outGuids )
{
delete [] ( outGuids );
}
SAFE_DELETE(pPinFactory);
if ( FAILED( hr ) )
{
//Release the pins and the resources acquired
for (ULONG ulIndex = 0, ulSize = (ULONG)m_InPins.size(); ulIndex < ulSize; ulIndex++)
{
SAFERELEASE(m_InPins[ulIndex]);
}
m_InPins.clear();
for (ULONG ulIndex = 0, ulSize = (ULONG)m_OutPins.size(); ulIndex < ulSize; ulIndex++)
{
SAFERELEASE(m_OutPins[ulIndex]);
}
m_OutPins.clear();
//
// Simply clear the custom pins since the input pins must have deleted the pin
//
m_spSourceTransform = nullptr;
m_spIkscontrol = nullptr;
}
return hr;
}
STDMETHODIMP CMultipinMft::SetWorkQueueEx(
_In_ DWORD dwWorkQueueId,
_In_ LONG lWorkItemBasePriority
)
/*++
Description:
Implements IMFRealTimeClientEx::SetWorkQueueEx function
--*/
{
CAutoLock lock( m_critSec );
//
// Cache the WorkQueuId and WorkItemBasePriority. This is called once soon after the device MFT is initialized
//
m_dwWorkQueueId = dwWorkQueueId;
m_lWorkQueuePriority = lWorkItemBasePriority;
// Set it on the pins
for (DWORD dwIndex = 0; dwIndex < (DWORD)m_InPins.size(); dwIndex++)
{
m_InPins[dwIndex]->SetWorkQueue(dwWorkQueueId);
}
for (DWORD dwIndex = 0; dwIndex < (DWORD)m_OutPins.size(); dwIndex++)
{
m_OutPins[dwIndex]->SetWorkQueue(dwWorkQueueId);
}
return S_OK;
}
//
// IMFDeviceTransform functions
//
STDMETHODIMP CMultipinMft::GetStreamCount(
_Inout_ DWORD *pdwInputStreams,
_Inout_ DWORD *pdwOutputStreams
)
/*++
Description: Implements IMFTransform::GetStreamCount function
--*/
{
HRESULT hr = S_OK;
CAutoLock lock(m_critSec);
DMFTCHECKNULL_GOTO(pdwInputStreams, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO(pdwOutputStreams, done, E_INVALIDARG);
*pdwInputStreams = m_InputPinCount;
*pdwOutputStreams = m_OutputPinCount;
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
done:
return hr;
}
//
//Doesn't strictly conform to the GetStreamIDs on IMFTransform Interface!
//
STDMETHODIMP CMultipinMft::GetStreamIDs(
_In_ DWORD dwInputIDArraySize,
_When_(dwInputIDArraySize >= m_InputPinCount, _Out_writes_(dwInputIDArraySize)) DWORD* pdwInputIDs,
_In_ DWORD dwOutputIDArraySize,
_When_(dwOutputIDArraySize >= m_OutputPinCount && (pdwInputIDs && (dwInputIDArraySize > 0)),
_Out_writes_(dwOutputIDArraySize)) _On_failure_(_Valid_) DWORD* pdwOutputIDs
)
/*++
Description:
Implements IMFTransform::GetStreamIDs function
--*/
{
HRESULT hr = S_OK;
CAutoLock lock(m_critSec);
if ( ( dwInputIDArraySize < m_InputPinCount ) && ( dwOutputIDArraySize < m_OutputPinCount ) )
{
hr = MF_E_BUFFERTOOSMALL;
goto done;
}
if ( dwInputIDArraySize )
{
DMFTCHECKNULL_GOTO( pdwInputIDs, done, E_POINTER );
for ( DWORD dwIndex = 0; dwIndex < ((dwInputIDArraySize > m_InputPinCount) ? m_InputPinCount:
dwInputIDArraySize); dwIndex++ )
{
pdwInputIDs[ dwIndex ] = ( m_InPins[dwIndex] )->streamId();
}
}
if ( dwOutputIDArraySize )
{
DMFTCHECKNULL_GOTO( pdwOutputIDs, done, E_POINTER );
for ( DWORD dwIndex = 0; dwIndex < ((dwOutputIDArraySize > m_OutputPinCount)? m_OutputPinCount:
dwOutputIDArraySize); dwIndex++ )
{
pdwOutputIDs[ dwIndex ] = (m_OutPins[ dwIndex ])->streamId();
}
}
done:
return hr;
}
/*++
Name: CMultipinMft::GetInputAvailableType
Description:
Implements IMFTransform::GetInputAvailableType function. This function
gets the media type supported by the specified stream based on the
index dwTypeIndex.
--*/
STDMETHODIMP CMultipinMft::GetInputAvailableType(
_In_ DWORD dwInputStreamID,
_In_ DWORD dwTypeIndex,
_Out_ IMFMediaType** ppMediaType
)
{
HRESULT hr = S_OK;
ComPtr<CInPin> spiPin = GetInPin( dwInputStreamID );
DMFTCHECKNULL_GOTO(ppMediaType, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO( spiPin, done, MF_E_INVALIDSTREAMNUMBER );
*ppMediaType = nullptr;
hr = spiPin->GetOutputAvailableType( dwTypeIndex,ppMediaType );
if (FAILED(hr))
{
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Pin: %d Index: %d exiting %!HRESULT!",
dwInputStreamID,
dwTypeIndex,
hr);
}
done:
return hr;
}
STDMETHODIMP CMultipinMft::GetOutputAvailableType(
_In_ DWORD dwOutputStreamID,
_In_ DWORD dwTypeIndex,
_Out_ IMFMediaType** ppMediaType
)
/*++
Description:
Implements IMFTransform::GetOutputAvailableType function. This function
gets the media type supported by the specified stream based on the
index dwTypeIndex.
--*/
{
HRESULT hr = S_OK;
CAutoLock Lock(m_critSec);
ComPtr<COutPin> spoPin = GetOutPin( dwOutputStreamID );
DMFTCHECKNULL_GOTO( spoPin.Get(), done, MF_E_INVALIDSTREAMNUMBER );
DMFTCHECKNULL_GOTO(ppMediaType, done, E_INVALIDARG);
*ppMediaType = nullptr;
hr = spoPin->GetOutputAvailableType( dwTypeIndex, ppMediaType );
if ( FAILED( hr ) )
{
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Pin: %d Index: %d exiting %!HRESULT!",
dwOutputStreamID,
dwTypeIndex,
hr );
}
done:
return hr;
}
STDMETHODIMP CMultipinMft::GetInputCurrentType(
_In_ DWORD dwInputStreamID,
_COM_Outptr_result_maybenull_ IMFMediaType** ppMediaType
)
/*++
Description:
Implements IMFTransform::GetInputCurrentType function. This function
returns the current media type set on the specified stream.
--*/
{
//
// The input current types will not come to this transform.
// The outputs of this transform matter. The DTM manages the
// output of this transform and the inptuts of the source transform
//
UNREFERENCED_PARAMETER(dwInputStreamID);
UNREFERENCED_PARAMETER(ppMediaType);
return S_OK;
}
STDMETHODIMP CMultipinMft::GetOutputCurrentType(
_In_ DWORD dwOutputStreamID,
_Out_ IMFMediaType** ppMediaType
)
/*++
Description:
Implements IMFTransform::GetOutputCurrentType function. This function
returns the current media type set on the specified stream.
--*/
{
HRESULT hr = S_OK;
ComPtr<COutPin> spoPin;
CAutoLock lock( m_critSec );
DMFTCHECKNULL_GOTO( ppMediaType, done, E_INVALIDARG );
*ppMediaType = nullptr;
spoPin = GetOutPin( dwOutputStreamID );
DMFTCHECKNULL_GOTO(spoPin, done, MF_E_INVALIDSTREAMNUMBER );
DMFTCHECKHR_GOTO(spoPin->getMediaType( ppMediaType ),done );
DMFTCHECKNULL_GOTO( *ppMediaType, done, MF_E_TRANSFORM_TYPE_NOT_SET );
done:
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
return hr;
}
STDMETHODIMP CMultipinMft::ProcessEvent(
_In_ DWORD dwInputStreamID,
_In_ IMFMediaEvent* pEvent
)
/*++
Description:
Implements IMFTransform::ProcessEvent function. This function
processes events that come to the MFT.
--*/
{
UNREFERENCED_PARAMETER(dwInputStreamID);
UNREFERENCED_PARAMETER(pEvent);
return S_OK;
}
STDMETHODIMP CMultipinMft::ProcessMessage(
_In_ MFT_MESSAGE_TYPE eMessage,
_In_ ULONG_PTR ulParam
)
/*++
Description:
Implements IMFTransform::ProcessMessage function. This function
processes messages coming to the MFT.
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER(ulParam);
CAutoLock _lock( m_critSec );
printMessageEvent( eMessage );
switch ( eMessage )
{
case MFT_MESSAGE_COMMAND_FLUSH:
//
// This is MFT wide flush.. Flush all output pins
//
(VOID)FlushAllStreams();
break;
case MFT_MESSAGE_COMMAND_DRAIN:
//
// There is no draining for Device MFT. Just kept here for reference
//
break;
case MFT_MESSAGE_NOTIFY_START_OF_STREAM:
//
// No op for device MFTs
//
break;
case MFT_MESSAGE_SET_D3D_MANAGER:
{
if ( ulParam )
{
ComPtr< IDirect3DDeviceManager9 > spD3D9Manager;
ComPtr< IMFDXGIDeviceManager > spDXGIManager;
hr = ( ( IUnknown* ) ulParam )->QueryInterface( IID_PPV_ARGS( &spD3D9Manager ) );
if ( SUCCEEDED( hr ) )
{
m_spDeviceManagerUnk = ( IUnknown* )ulParam;
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! IDirect3DDeviceManager9 %p, is passed", spD3D9Manager.Get() );
}
else
{
hr = ( ( IUnknown* ) ulParam )->QueryInterface( IID_PPV_ARGS( &spDXGIManager ) );
if ( SUCCEEDED(hr) )
{
m_spDeviceManagerUnk = (IUnknown*)ulParam;
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! IMFDXGIDeviceManager %p, is passed", spDXGIManager.Get());
}
}
}
else
{
m_spDeviceManagerUnk = nullptr;
hr = S_OK;
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC!IDirect3DDeviceManager9 was not passed in");
}
//
// set it on the pins. Can happen anytime
//
for (DWORD dwIndex = 0; dwIndex < (DWORD)m_InPins.size(); dwIndex++)
{
m_InPins[dwIndex]->SetD3DManager(m_spDeviceManagerUnk.Get());
}
for (DWORD dwIndex = 0; dwIndex < (DWORD)m_OutPins.size(); dwIndex++)
{
m_OutPins[dwIndex]->SetD3DManager(m_spDeviceManagerUnk.Get());
}
}
break;
case MFT_MESSAGE_NOTIFY_BEGIN_STREAMING:
{
SetStreamingState( DeviceStreamState_Run );
//
// Start Streaming custom pins if the device transfrom has any
//
SetStreamingStateCustomPins( DeviceStreamState_Run );
}
break;
case MFT_MESSAGE_NOTIFY_END_STREAMING:
{
SetStreamingState(DeviceStreamState_Stop);
//
// Stop streaming custom pins if the device transform has any
//
SetStreamingStateCustomPins( DeviceStreamState_Stop );
}
break;
case MFT_MESSAGE_NOTIFY_END_OF_STREAM:
{
SetStreamingState(DeviceStreamState_Stop);
}
break;
default:
;
}
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
return hr;
}
STDMETHODIMP CMultipinMft::ProcessInput(
_In_ DWORD dwInputStreamID,
_In_ IMFSample* pSample,
_In_ DWORD dwFlags
)
/*++
Description:
Implements IMFTransform::ProcessInput function.This function is called
when the sourcetransform has input to feed. the pins will try to deliver the
samples to the active output pins conencted. if none are connected then just
returns the sample back to the source transform
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER( dwFlags );
ComPtr<CInPin> spInPin = GetInPin( dwInputStreamID );
DMFTCHECKNULL_GOTO(spInPin, done, MF_E_INVALIDSTREAMNUMBER);
if ( !IsStreaming() )
{
goto done;
}
DMFTCHECKHR_GOTO(spInPin->SendSample( pSample ), done );
done:
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
//
//@@@@ README : There is a bug in the sample that the device transform manager which manages the
// device MFT does not release the sample after passing it to Device MFT in processInput like it should. The
// Device MFT therefore unfortunately has to make sure that the sample that leaves processoutput has a reference count of 1
//
SAFE_RELEASE(pSample);
return hr;
}
STDMETHODIMP CMultipinMft::ProcessOutput(
_In_ DWORD dwFlags,
_In_ DWORD cOutputBufferCount,
_Inout_updates_(cOutputBufferCount) MFT_OUTPUT_DATA_BUFFER *pOutputSamples,
_Out_ DWORD *pdwStatus
)
/*++
Description:
Implements IMFTransform::ProcessOutput function. This is called by the DTM when
the DT indicates it has samples to give. The DTM will send enough MFT_OUTPUT_DATA_BUFFER
pointers to be filled up as is the number of output pins available. The DT should traverse its
output pins and populate the corresponding MFT_OUTPUT_DATA_BUFFER with the samples available
--*/
{
HRESULT hr = S_OK;
BOOL gotOne = false;
ComPtr<COutPin> spOpin;
UNREFERENCED_PARAMETER( dwFlags );
if (cOutputBufferCount > m_OutputPinCount )
{
DMFTCHECKHR_GOTO( E_INVALIDARG, done );
}
*pdwStatus = 0;
for ( DWORD i = 0; i < cOutputBufferCount; i++ )
{
DWORD dwStreamID = pOutputSamples[i].dwStreamID;
{
CAutoLock _lock(m_critSec);
spOpin = nullptr;
spOpin = GetOutPin(dwStreamID);
GUID pinGuid = GUID_NULL;
DMFTCHECKNULL_GOTO(spOpin.Get(), done, E_INVALIDARG);
}
if ( SUCCEEDED(spOpin->ProcessOutput( dwFlags, &pOutputSamples[i],
pdwStatus ) ) )
{
gotOne = true;
// Do photo confirmation if enabled from the preview stream only
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
BOOL pIsPreviewPin = FALSE;
if (pOutputSamples[i].pSample &&
IsPhotoConfirmationEnabled() &&
((SUCCEEDED(CheckPreviewPin(static_cast<IMFAttributes*>(spOpin.Get()), &pIsPreviewPin)) && pIsPreviewPin) &&
InterlockedCompareExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation), FALSE, TRUE)))
{
// Please note photo confirmation should always be fired from the preview stream.
ComPtr<IMFMediaType> spMediaType;
if (SUCCEEDED(spOpin->getMediaType(spMediaType.GetAddressOf())))
{
// Do Photo confirmation
ProcessCapturePhotoConfirmationCallBack(spMediaType.Get(), pOutputSamples[i].pSample);
m_firePhotoConfirmation = FALSE;
}
}
#endif
}
}
if (gotOne)
{
hr = S_OK;
}
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::GetInputStreamAttributes(
_In_ DWORD dwInputStreamID,
_COM_Outptr_result_maybenull_ IMFAttributes** ppAttributes
)
/*++
Description:
Implements IMFTransform::GetInputStreamAttributes function. This function
gets the specified input stream's attributes.
--*/
{
HRESULT hr = S_OK;
ComPtr<CInPin> spIPin;
DMFTCHECKNULL_GOTO( ppAttributes, done, E_INVALIDARG );
*ppAttributes = nullptr;
spIPin = GetInPin( dwInputStreamID );
DMFTCHECKNULL_GOTO(spIPin, done, E_INVALIDARG );
hr = spIPin->getPinAttributes(ppAttributes);
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::GetOutputStreamAttributes(
_In_ DWORD dwOutputStreamID,
_Out_ IMFAttributes** ppAttributes
)
/*++
Description:
Implements IMFTransform::GetOutputStreamAttributes function. This function
gets the specified output stream's attributes.
--*/
{
HRESULT hr = S_OK;
ComPtr<COutPin> spoPin;
DMFTCHECKNULL_GOTO(ppAttributes, done, E_INVALIDARG);
*ppAttributes = nullptr;
spoPin = GetOutPin(dwOutputStreamID);
DMFTCHECKNULL_GOTO(spoPin, done, E_INVALIDARG );
DMFTCHECKHR_GOTO(spoPin->getPinAttributes(ppAttributes), done );
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
_Requires_no_locks_held_
STDMETHODIMP CMultipinMft::SetInputStreamState(
_In_ DWORD dwStreamID,
_In_ IMFMediaType *pMediaType,
_In_ DeviceStreamState value,
_In_ DWORD dwFlags
)
/*++
Description:
Implements IMFdeviceTransform::SetInputStreamState function.
Sets the input stream state.
The control lock is not taken here. The lock is taken for operations on
output pins. This operation is a result of the DT notifying the DTM that
output pin change has resulted in the need for the input to be changed. In
this case the DTM sends a getpreferredinputstate and then this call
--*/
{
HRESULT hr = S_OK;
ComPtr<CInPin> spiPin = GetInPin(dwStreamID);
DMFTCHECKNULL_GOTO(spiPin, done, MF_E_INVALIDSTREAMNUMBER);
DMFTCHECKHR_GOTO(spiPin->SetInputStreamState(pMediaType, value, dwFlags),done);
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::GetInputStreamState(
_In_ DWORD dwStreamID,
_Out_ DeviceStreamState *value
)
{
HRESULT hr = S_OK;
ComPtr<CInPin> piPin = GetInPin(dwStreamID);
DMFTCHECKNULL_GOTO(piPin, done, MF_E_INVALIDSTREAMNUMBER);
*value = piPin->GetState();
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::SetOutputStreamState(
_In_ DWORD dwStreamID,
_In_ IMFMediaType *pMediaType,
_In_ DeviceStreamState state,
_In_ DWORD dwFlags
)
/*++
Description:
Implements IMFdeviceTransform::SetOutputStreamState function.
Sets the output stream state. This is called whenever the stream
is selected or deslected i.e. started or stopped.
The control lock taken here and this operation should be atomic.
This function should check the input pins connected to the output pin
switch off the state of the input pin. Check if any other Pin connected
to the input pin is in a conflicting state with the state requested on this
output pin. Accordinly it calculates the media type to be set on the input pin
and the state to transition into. It then might recreate the other output pins
connected to it
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER(dwFlags);
CAutoLock Lock(m_critSec);
DMFTCHECKHR_GOTO(ChangeMediaTypeEx(dwStreamID, pMediaType, state),done);
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::GetOutputStreamState(
_In_ DWORD dwStreamID,
_Out_ DeviceStreamState *pState
)
/*++
Description:
Implements IMFdeviceTransform::GetOutputStreamState function.
Gets the output stream state.
Called by the DTM to checks states. Atomic operation. needs a lock
--*/
{
HRESULT hr = S_OK;
CAutoLock lock(m_critSec);
ComPtr<COutPin> spoPin = GetOutPin(dwStreamID);
DMFTCHECKNULL_GOTO(pState, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO(spoPin, done, MF_E_INVALIDSTREAMNUMBER);
*pState = spoPin->GetState();
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::GetInputStreamPreferredState(
_In_ DWORD dwStreamID,
_Inout_ DeviceStreamState *value,
_Outptr_opt_result_maybenull_ IMFMediaType **ppMediaType
)
/*++
Description:
Implements IMFdeviceTransform::GetInputStreamPreferredState function.
Gets the preferred state and the media type to be set on the input pin.
The lock is not held as this will always be called only when we notify
DTM to call us. We notify DTM only from the context on operations
happening on the output pin
--*/
{
HRESULT hr = S_OK;
ComPtr<CInPin> spiPin = GetInPin(dwStreamID);
DMFTCHECKNULL_GOTO(ppMediaType, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO(spiPin, done, MF_E_INVALIDSTREAMNUMBER);
hr = spiPin->GetInputStreamPreferredState(value, ppMediaType);
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::FlushInputStream(
_In_ DWORD dwStreamIndex,
_In_ DWORD dwFlags
)
/*++
Description:
Implements IMFdeviceTransform::FlushInputStream function.
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER(dwStreamIndex);
UNREFERENCED_PARAMETER(dwFlags);
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
STDMETHODIMP CMultipinMft::FlushOutputStream(
_In_ DWORD dwStreamIndex,
_In_ DWORD dwFlags
)
/*++
Description:
Implements IMFdeviceTransform::FlushOutputStream function.
Called by the DTM to flush streams
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER(dwFlags);
CAutoLock Lock(m_critSec);
ComPtr<COutPin> spoPin = GetOutPin(dwStreamIndex);
DMFTCHECKNULL_GOTO(spoPin, done, E_INVALIDARG);
DeviceStreamState oldState = spoPin->SetState(DeviceStreamState_Disabled);
DMFTCHECKHR_GOTO(spoPin->FlushQueues(),done);
spoPin->SetState(oldState);
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
/*++
Description:
Called when the Device Transform gets a MFT_MESSAGE_COMMAND_FLUSH. We drain all the queues.
This is called in device source when the source gets end of streaming.
--*/
STDMETHODIMP_(VOID) CMultipinMft::FlushAllStreams(
VOID
)
{
DeviceStreamState oldState;
CAutoLock Lock(m_critSec);
for ( DWORD dwIndex = 0, dwSize = (DWORD)m_OutPins.size(); dwIndex < dwSize; dwIndex++ )
{
ComPtr<COutPin> spoPin = (COutPin *)m_OutPins[dwIndex];
oldState = spoPin->SetState(DeviceStreamState_Disabled);
spoPin->FlushQueues();
//
//Restore state
//
spoPin->SetState(oldState);
}
}
//
// IKsControl interface functions
//
STDMETHODIMP CMultipinMft::KsProperty(
_In_reads_bytes_(ulPropertyLength) PKSPROPERTY pProperty,
_In_ ULONG ulPropertyLength,
_Inout_updates_bytes_(ulDataLength) LPVOID pvPropertyData,
_In_ ULONG ulDataLength,
_Inout_ ULONG* pulBytesReturned
)
/*++
Description:
Implements IKSProperty::KsProperty function.
used to pass control commands to the driver (generally)
This can be used to intercepted the control to figure out
if it needs to be propogated to the driver or not
--*/
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER(pulBytesReturned);
DMFTCHECKNULL_GOTO(pProperty, done, E_INVALIDARG);
DMFTCHECKNULL_GOTO(pulBytesReturned, done, E_INVALIDARG);
//
// Enable Warm Start on All filters for the sample. Please comment out this
// section if this is not needed
//
if (IsEqualCLSID(pProperty->Set, KSPROPERTYSETID_ExtendedCameraControl)
&& (pProperty->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_WARMSTART))
{
#if MF_DEVICEMFT_WARMSTART_HANDLING
DMFTCHECKHR_GOTO(WarmStartHandler(pProperty,
ulPropertyLength, pvPropertyData, ulDataLength, pulBytesReturned),done);
goto done;
#endif
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Warm Start Control %d Passed ", pProperty->Id);
}
if (IsEqualCLSID(pProperty->Set, KSPROPERTYSETID_ExtendedCameraControl))
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Extended Control %d Passed ",pProperty->Id);
}
else if ((IsEqualCLSID(pProperty->Set, PROPSETID_VIDCAP_VIDEOCONTROL)) && (pProperty->Id == KSPROPERTY_VIDEOCONTROL_MODE))
{
// A function illustrating how we can capture and service photos from the device MFT. This block shows how we can
// intercept Photo triggers going down to the pipeline
if (sizeof(KSPROPERTY_VIDEOCONTROL_MODE_S) == ulDataLength)
{
PKSPROPERTY_VIDEOCONTROL_MODE_S VideoControl = (PKSPROPERTY_VIDEOCONTROL_MODE_S)pvPropertyData;
m_PhotoModeIsPhotoSequence = false;
if (VideoControl->Mode == KS_VideoControlFlag_StartPhotoSequenceCapture)
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Starting PhotoSequence Trigger");
m_PhotoModeIsPhotoSequence = true;
}
else if (VideoControl->Mode == KS_VideoControlFlag_StopPhotoSequenceCapture)
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Stopping PhotoSequence Trigger");
m_PhotoModeIsPhotoSequence = false;
}
else
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Take Single Photo Trigger");
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
InterlockedExchange(reinterpret_cast<PLONG>(&m_firePhotoConfirmation),TRUE);
#endif
}
}
}
DMFTCHECKHR_GOTO(m_spIkscontrol->KsProperty(pProperty,
ulPropertyLength,
pvPropertyData,
ulDataLength,
pulBytesReturned),done);
done:
LPSTR guidStr = DumpGUIDA(pProperty->Set);
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! g:%s p:%d exiting %x = %!HRESULT!", guidStr, pProperty->Id, hr, hr);
delete(guidStr);
return hr;
}
STDMETHODIMP CMultipinMft::KsMethod(
_In_reads_bytes_(ulPropertyLength) PKSMETHOD pMethod,
_In_ ULONG ulPropertyLength,
_Inout_updates_bytes_(ulDataLength) LPVOID pvPropertyData,
_In_ ULONG ulDataLength,
_Inout_ ULONG* pulBytesReturned
)
/*++
Description:
Implements IKSProperty::KsMethod function. We can trap ksmethod calls here.
--*/
{
return m_spIkscontrol->KsMethod(
pMethod,
ulPropertyLength,
pvPropertyData,
ulDataLength,
pulBytesReturned
);
}
STDMETHODIMP CMultipinMft::KsEvent(
_In_reads_bytes_(ulEventLength) PKSEVENT pEvent,
_In_ ULONG ulEventLength,
_Inout_updates_bytes_opt_(ulDataLength) LPVOID pEventData,
_In_ ULONG ulDataLength,
_Inout_ ULONG* pBytesReturned
)
/*++
Description:
Implements IKSProperty::KsEvent function.
--*/
{
HRESULT hr = S_OK;
#if MF_DEVICEMFT_WARMSTART_HANDLING
if (pEvent && (pEvent->Set == KSEVENTSETID_ExtendedCameraControl) &&
(pEvent->Id == KSPROPERTY_CAMERACONTROL_EXTENDED_WARMSTART))
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Acquiring Event for Async Extended Control");
//
// For the Sample the warmstate handlers are supported by Device MFT and not passed to driver
//
hr = m_eventHandler.KSEvent(pEvent,
ulEventLength,
pEventData,
ulDataLength,
pBytesReturned
);
}
else
#endif
{
//
// All the Events we don't handle should be sent to the driver!
//
hr = m_spIkscontrol->KsEvent(pEvent,
ulEventLength,
pEventData,
ulDataLength,
pBytesReturned);
}
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
//
//IMFGetService functions
//
STDMETHODIMP CMultipinMft::GetService(
__in REFGUID guidService,
__in REFIID riid,
__deref_out LPVOID* ppvObject
)
{
//
//This doesn't necessarily need to be a GetService function, but this is just so that the
//pipeline implementation and the Device transform implementation is consistent.
//In this sample the photoconfirmation interface is implementated by the same class
//we can delegate it later to any of the pins if needed
//
UNREFERENCED_PARAMETER(guidService);
if (riid == __uuidof(IMFCapturePhotoConfirmation))
{
return QueryInterface(riid, ppvObject);
}
else
return MF_E_UNSUPPORTED_SERVICE;
}
//
//IMFCapturePhotoConfirmation functions implemented
//
STDMETHODIMP CMultipinMft::SetPhotoConfirmationCallback(
_In_ IMFAsyncCallback* pNotificationCallback
)
{
CAutoLock Lock(m_critSec);
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Setting PhotoConfirmation %p, is passed", pNotificationCallback);
m_spPhotoConfirmationCallback = pNotificationCallback;
return S_OK;
}
STDMETHODIMP CMultipinMft::SetPixelFormat(
_In_ GUID subtype
)
{
CAutoLock Lock(m_critSec);
m_guidPhotoConfirmationSubtype = subtype;
return S_OK;
}
STDMETHODIMP CMultipinMft::GetPixelFormat(
_Out_ GUID* subtype
)
{
CAutoLock Lock(m_critSec);
*subtype = m_guidPhotoConfirmationSubtype;
return S_OK;
}
#endif
#if defined (MF_DEVICEMFT_ALLOW_MFT0_LOAD) && defined (MFT_UNIQUE_METHOD_NAMES)
//
// IMFTransform function(s).
//
//
// Note: This is the only IMFTransform function which is not a redirector to the
// DeviceTransform functions. The rest of IMFTransform functions are in the file common.h
// This function returns the IMFAttribute created for Device MFT. If DMFT is
// not loaded (usually )MFT0's call to GetAttributes will get the Attribute store of DevProxy.
// A device MFT loaded will not pass through the devproxy attribute store, but it will pass
// the device MFT attributes. This should be similar to the singular DevProxy attribute
// which the MFT0 providers can use to synchronize across various MFT0's
//
STDMETHODIMP CMultipinMft::GetAttributes(
_COM_Outptr_opt_result_maybenull_ IMFAttributes** ppAttributes
)
{
HRESULT hr = S_OK;
CAutoLock Lock(m_critSec);
DMFTCHECKNULL_GOTO(ppAttributes, done, E_INVALIDARG);
*ppAttributes = nullptr;
if (m_spAttributes != nullptr)
{
m_spAttributes.CopyTo(ppAttributes);
}
else
{
hr = E_OUTOFMEMORY;
}
done:
return hr;
}
#endif
#if ((defined NTDDI_WIN10_VB) && (NTDDI_VERSION >= NTDDI_WIN10_VB))
//
// IMFSampleAllocatorControl Inferface function declarations
//
STDMETHODIMP CMultipinMft::SetDefaultAllocator(
_In_ DWORD dwOutputStreamID,
_In_ IUnknown *pAllocator
)
{
CAutoLock Lock(m_critSec);
// SetAllocator will be called on the streamId that returns MFSampleAllocatorMode_Default
wil::com_ptr_nothrow<COutPin> outPin = GetOutPin(dwOutputStreamID);
RETURN_HR_IF_NULL(E_INVALIDARG, outPin);
RETURN_HR_IF_NULL(E_INVALIDARG, pAllocator);
wil::com_ptr_nothrow<IMFVideoSampleAllocator> defaultAllocator;
RETURN_IF_FAILED(pAllocator->QueryInterface(&defaultAllocator));
outPin->SetAllocator(defaultAllocator.get());
return S_OK;
}
STDMETHODIMP CMultipinMft::GetAllocatorUsage(
_In_ DWORD dwOutputStreamID,
_Out_ DWORD* pdwInputStreamID,
_Out_ MFSampleAllocatorUsage* peUsage
)
{
CAutoLock Lock(m_critSec);
RETURN_HR_IF_NULL(E_INVALIDARG, peUsage);
wil::com_ptr_nothrow<COutPin> outPin = GetOutPin(dwOutputStreamID);
RETURN_HR_IF_NULL(MF_E_INVALIDSTREAMNUMBER, outPin);
*peUsage = outPin->GetSampleAllocatorUsage();
if (*peUsage == MFSampleAllocatorUsage_DoesNotAllocate)
{
RETURN_HR_IF_NULL(E_INVALIDARG, pdwInputStreamID);
RETURN_IF_FAILED(GetConnectedInpin((ULONG)dwOutputStreamID, *(ULONG*)pdwInputStreamID));
}
return S_OK;
}
#endif // ((defined NTDDI_WIN10_VB) && (NTDDI_VERSION >= NTDDI_WIN10_VB))
//
// HELPER FUNCTIONS
//
//
// A lock here could mean a deadlock because this will be called when the lock is already held
// in another thread.
//
CInPin* CMultipinMft::GetInPin(
_In_ DWORD dwStreamId
)
{
CInPin *inPin = NULL;
for (DWORD dwIndex = 0, dwSize = (DWORD)m_InPins.size(); dwIndex < dwSize; dwIndex++)
{
inPin = (CInPin *)m_InPins[dwIndex];
if (dwStreamId == inPin->streamId())
{
break;
}
inPin = NULL;
}
return inPin;
}
COutPin* CMultipinMft::GetOutPin(
_In_ DWORD dwStreamId
)
{
COutPin *outPin = NULL;
for ( DWORD dwIndex = 0, dwSize = (DWORD) m_OutPins.size(); dwIndex < dwSize; dwIndex++ )
{
outPin = ( COutPin * )m_OutPins[ dwIndex ];
if ( dwStreamId == outPin->streamId() )
{
break;
}
outPin = NULL;
}
return outPin;
}
_Requires_lock_held_(m_Critsec)
HRESULT CMultipinMft::GetConnectedInpin(_In_ ULONG ulOutpin, _Out_ ULONG &ulInPin)
{
HRESULT hr = S_OK;
map<int, int>::iterator it = m_outputPinMap.find(ulOutpin);
if (it != m_outputPinMap.end())
{
ulInPin = it->second;
}
else
{
hr = MF_E_INVALIDSTREAMNUMBER;
}
return hr;
}
//
// The Below function changes media type on the pins exposed by device MFT
//
__requires_lock_held(m_critSec)
HRESULT CMultipinMft::ChangeMediaTypeEx(
_In_ ULONG pinId,
_In_opt_ IMFMediaType *pMediaType,
_In_ DeviceStreamState reqState
)
{
HRESULT hr = S_OK;
ComPtr<COutPin> spoPin = GetOutPin(pinId);
ComPtr<CInPin> spinPin;
DeviceStreamState oldOutPinState, oldInputStreamState, newOutStreamState, newRequestedInPinState;
ComPtr<IMFMediaType> pFullType, pInputMediaType;
ULONG ulInPinId = 0;
DWORD dwFlags = 0;
DMFTCHECKNULL_GOTO(spoPin, done, E_INVALIDARG);
{
//
// dump the media types to the logs
//
ComPtr<IMFMediaType> spOldMediaType;
(VOID)spoPin->getMediaType(spOldMediaType.GetAddressOf());
CMediaTypePrinter newType(pMediaType);
CMediaTypePrinter oldType(spOldMediaType.Get());
if (WPP_LEVEL_ENABLED(DMFT_GENERAL))
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, " Pin:%d old MT:[%s] St:%d", pinId, oldType.ToString(), reqState);
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, " Pin:%d new MT:[%s] St:%d", pinId, newType.ToString(), reqState);
}
}
if (pMediaType)
{
if (!spoPin->IsMediaTypeSupported(pMediaType, &pFullType))
{
DMFTCHECKHR_GOTO(MF_E_INVALIDMEDIATYPE, done);
}
}
DMFTCHECKHR_GOTO(GetConnectedInpin(pinId, ulInPinId), done);
spinPin = GetInPin(ulInPinId); // Get the input pin
(VOID)spinPin->getMediaType(&pInputMediaType);
oldInputStreamState = spinPin->SetState(DeviceStreamState_Disabled); // Disable input pin
oldOutPinState = spoPin->SetState(DeviceStreamState_Disabled); // Disable output pin
(void)spoPin->FlushQueues(); // Flush the output queues
(void)spinPin->FlushQueues(); // Flush the input queues
newOutStreamState = pinStateTransition[oldOutPinState][reqState]; // New state needed
// The Old input and the output pin states should be the same
newRequestedInPinState = newOutStreamState;
if ((newOutStreamState != oldOutPinState) /*State change*/
||((pFullType.Get() != nullptr) && (pInputMediaType.Get()!=nullptr) && (S_OK != (pFullType->IsEqual(pInputMediaType.Get(), &dwFlags)))) /*Media Types dont match*/
||((pFullType == nullptr)||(pInputMediaType == nullptr))/*Either one of the mediatypes is null*/
)
{
//
// State has change or media type has changed so we need to change the media type on the
// underlying kernel pin
//
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "Changing Mediatype on the input ");
spinPin->setPreferredMediaType(pFullType.Get());
spinPin->setPreferredStreamState(newRequestedInPinState);
// Let the pipline know that the input needs to be changed.
SendEventToManager(METransformInputStreamStateChanged, GUID_NULL, spinPin->streamId());
//
// The media type will be set on the input pin by the time we return from the wait
//
DMFTCHECKHR_GOTO(spinPin->WaitForSetInputPinMediaChange(), done);
// Change the media type on the output..
DMFTCHECKHR_GOTO(spoPin->ChangeMediaTypeFromInpin(pFullType.Get(), pMediaType , reqState), done);
//
// Notify the pipeline that the output stream media type has changed
//
DMFTCHECKHR_GOTO(SendEventToManager(MEUnknown, MEDeviceStreamCreated, spoPin->streamId()), done);
spoPin->SetFirstSample(TRUE);
}
else
{
// Restore back old states as we have nothing to do
spinPin->SetState(oldInputStreamState);
spoPin->SetState(oldOutPinState);
}
done:
return hr;
}
//
// The below function sends events to the pipeline.
//
HRESULT CMultipinMft::SendEventToManager(
_In_ MediaEventType eventType,
_In_ REFGUID pGuid,
_In_ UINT32 context
)
/*++
Description:
Used to send the event to DTM.
--*/
{
HRESULT hr = S_OK;
ComPtr<IMFMediaEvent> pEvent = nullptr;
DMFTCHECKHR_GOTO(MFCreateMediaEvent(eventType, pGuid, S_OK, NULL, &pEvent ),done);
DMFTCHECKHR_GOTO(pEvent->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID, (ULONG)context),done);
DMFTCHECKHR_GOTO(QueueEvent(pEvent.Get()),done);
done:
return hr;
}
/*++
Description:
This function connects the input and output pins.
Any media type filtering can happen here
--*/
HRESULT CMultipinMft::BridgeInputPinOutputPin(
_In_ CInPin* piPin,
_In_ COutPin* poPin
)
{
HRESULT hr = S_OK;
ULONG ulIndex = 0;
ULONG ulAddedMediaTypeCount = 0;
ComPtr<IMFMediaType> spMediaType;
DMFTCHECKNULL_GOTO( piPin, done, E_INVALIDARG );
DMFTCHECKNULL_GOTO( poPin, done, E_INVALIDARG );
//
// Copy over the media types from input pin to output pin. Since there is no
// decoder support, only the uncompressed media types are inserted. Please make
// sure any pin advertised supports at least one media type. The pipeline doesn't
// like pins with no media types
//
while ( SUCCEEDED( hr = piPin->GetMediaTypeAt( ulIndex++, spMediaType.ReleaseAndGetAddressOf() )))
{
GUID subType = GUID_NULL;
DMFTCHECKHR_GOTO( spMediaType->GetGUID(MF_MT_SUBTYPE,&subType), done );
{
DMFTCHECKHR_GOTO(hr = poPin->AddMediaType(NULL, spMediaType.Get() ), done );
if (hr == S_OK)
{
ulAddedMediaTypeCount++;
}
}
}
if (ulAddedMediaTypeCount == 0)
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Make Sure Pin %d has one media type exposed ", piPin->streamId());
DMFTCHECKHR_GOTO( MF_E_INVALID_STREAM_DATA, done );
}
//
//Add the Input Pin to the output Pin
//
DMFTCHECKHR_GOTO(poPin->AddPin(piPin->streamId()), done);
hr = ExceptionBoundary([&](){
//
// Add the output pin to the input pin.
// Create the pin map. So that we know which pin input pin is connected to which output pin
//
piPin->ConnectPin(poPin);
m_outputPinMap.insert(std::pair< int, int >(poPin->streamId(), piPin->streamId()));
});
done:
//
//Failed adding media types
//
if (FAILED(hr))
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_ERROR, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
}
return hr;
}
//
// Look at the below code only if we need to handle an extended property in Device MFT
//
#if defined (MF_DEVICEMFT_WARMSTART_HANDLING)
HRESULT CMultipinMft::WarmStartHandler(
_In_ PKSPROPERTY Property,
_In_ ULONG ulPropertyLength,
_In_ LPVOID pData,
_In_ ULONG ulOutputBufferLength,
_Inout_ PULONG pulBytesReturned
)
{
HRESULT hr = S_OK;
UNREFERENCED_PARAMETER( ulPropertyLength );
*pulBytesReturned = 0;
if ( Property->Flags & KSPROPERTY_TYPE_SET )
{
if ( ulOutputBufferLength == 0 )
{
*pulBytesReturned = sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE );
DMFTCHECKHR_GOTO( HRESULT_FROM_WIN32( ERROR_MORE_DATA ), done);
}
else if (ulOutputBufferLength < sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE ))
{
DMFTCHECKHR_GOTO( HRESULT_FROM_WIN32( ERROR_MORE_DATA ), done);
}
else if ( pData && ulOutputBufferLength >= sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE ))
{
PBYTE pPayload = ( PBYTE )pData;
PKSCAMERA_EXTENDEDPROP_HEADER pExtendedHeader = ( PKSCAMERA_EXTENDEDPROP_HEADER )pPayload;
//
//Use the extended value to make changes to the property.. refer documentation
//PKSCAMERA_EXTENDEDPROP_VALUE pExtendedValue = (PKSCAMERA_EXTENDEDPROP_VALUE)(pPayload + sizeof(KSCAMERA_EXTENDEDPROP_HEADER));
//
SetWarmStart(pExtendedHeader->PinId, (pExtendedHeader->Flags & KSCAMERA_EXTENDEDPROP_WARMSTART_MODE_ENABLED));
*pulBytesReturned = sizeof( PKSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE );
m_eventHandler.SetOneShot(KSPROPERTY_CAMERACONTROL_EXTENDED_WARMSTART);
}
else
{
hr = S_OK;
}
}
else if (Property->Flags & KSPROPERTY_TYPE_GET)
{
if (ulOutputBufferLength == 0)
{
*pulBytesReturned = sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE );
DMFTCHECKHR_GOTO(HRESULT_FROM_WIN32(ERROR_MORE_DATA), done);
}
else if (ulOutputBufferLength < sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE ))
{
DMFTCHECKHR_GOTO( HRESULT_FROM_WIN32( ERROR_MORE_DATA ), done );
}
else if (pData && ulOutputBufferLength >= sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE ))
{
PBYTE pPayload = ( PBYTE )pData;
PKSCAMERA_EXTENDEDPROP_HEADER pExtendedHeader = ( PKSCAMERA_EXTENDEDPROP_HEADER )( pPayload );
//
//Use the extended value to make changes to the property.. refer documentation
//PKSCAMERA_EXTENDEDPROP_VALUE pExtendedValue = (PKSCAMERA_EXTENDEDPROP_VALUE)(pPayload +sizeof(KSCAMERA_EXTENDEDPROP_HEADER));
//
pExtendedHeader->Capability = KSCAMERA_EXTENDEDPROP_CAPS_ASYNCCONTROL | KSCAMERA_EXTENDEDPROP_WARMSTART_MODE_ENABLED;
pExtendedHeader->Flags = 0;
if (GetWarmStart(pExtendedHeader->PinId))
y
{
pExtendedHeader->Flags |= KSCAMERA_EXTENDEDPROP_WARMSTART_MODE_ENABLED;
}
pExtendedHeader->Result = 0;
pExtendedHeader->Size = sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE );
pExtendedHeader->Version = 1;
*pulBytesReturned = sizeof( KSCAMERA_EXTENDEDPROP_HEADER )+sizeof( KSCAMERA_EXTENDEDPROP_VALUE );
hr = S_OK;
}
else
{
hr = S_OK;
}
}
done:
DMFTRACE( DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr );
return hr;
}
#endif
//
// IMFShutdown interface functions
//
/*++
Description:
Implements the Shutdown from IMFShutdown
--*/
STDMETHODIMP CMultipinMft::Shutdown(
void
)
{
CAutoLock Lock(m_critSec);
(VOID) m_eventHandler.Clear();
for (ULONG ulIndex = 0, ulSize = (ULONG)m_InPins.size(); ulIndex < ulSize; ulIndex++ )
{
CInPin *pInPin = static_cast<CInPin *>(m_InPins[ulIndex]);
// Deref on the connected outpins to break reference loop
(VOID)pInPin->ShutdownPin();
}
#if defined (MF_DEVICEMFT_ALLOW_MFT0_LOAD) && defined (MFT_UNIQUE_METHOD_NAMES)
for (ULONG ulIndex = 0, ulSize = (ULONG)m_OutPins.size(); ulIndex < ulSize; ulIndex++)
{
(VOID) m_OutPins[ulIndex]->DeleteItem(MF_DEVICESTREAM_EXTENSION_PLUGIN_CONNECTION_POINT);
}
#endif
return ShutdownEventGenerator();
}
//
// Static method to create an instance of the MFT.
//
HRESULT CMultipinMft::CreateInstance(REFIID iid, void **ppMFT)
{
HRESULT hr = S_OK;
CMultipinMft *pMFT = NULL;
DMFTCHECKNULL_GOTO(ppMFT, done, E_POINTER);
pMFT = new (std::nothrow) CMultipinMft();
DMFTCHECKNULL_GOTO(pMFT, done, E_OUTOFMEMORY);
DMFTCHECKHR_GOTO(pMFT->QueryInterface(iid, ppMFT), done);
done:
if (FAILED(hr))
{
SAFERELEASE(pMFT);
}
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
#if defined (MF_DEVICEMFT_PHTOTOCONFIRMATION)
/*
Desciption:
This function will be called by the preview pin to execute the photo confirmation stored with the
MFT.
*/
STDMETHODIMP CMultipinMft::ProcessCapturePhotoConfirmationCallBack(
_In_ IMFMediaType* pMediaType,
_In_ IMFSample* pSample
)
{
//
//PhotoConfirmation Implementation
//Note this function doesn't scan the metadata as the pipeline does to find out which buffer is the photoconfirmation buffer
//The pipeline treats the preview buffer as the photo confirmation buffer and the driver marks the metadata on the buffer as being so.
//This example treats every buffer coming on the pin as the confirmation buffer.
//
HRESULT hr = S_OK;
ComPtr<IMFMediaType> spMediaType = nullptr;
LONGLONG timeStamp = 0;
DMFTCHECKHR_GOTO(MFCreateMediaType(&spMediaType), done);
DMFTCHECKHR_GOTO(pMediaType->CopyAllItems(spMediaType.Get()), done);
DMFTCHECKHR_GOTO(pSample->SetUnknown(MFSourceReader_SampleAttribute_MediaType_priv, spMediaType.Get()), done);
DMFTCHECKHR_GOTO(pSample->GetSampleTime(&timeStamp), done);
DMFTCHECKHR_GOTO(pSample->SetUINT64(MFSampleExtension_DeviceReferenceSystemTime, timeStamp), done);
if (m_spPhotoConfirmationCallback)
{
//
//We are directly sending the photo sample over to the consumers of the photoconfirmation interface.
//
ComPtr<IMFAsyncResult> spResult;
DMFTCHECKHR_GOTO(MFCreateAsyncResult(pSample, m_spPhotoConfirmationCallback.Get(), NULL, &spResult), done);
DMFTCHECKHR_GOTO(MFInvokeCallback(spResult.Get()), done);
}
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
#endif
//
// Only worry about this if you have customs pins defined in the driver
//
HRESULT CMultipinMft::SetStreamingStateCustomPins(
DeviceStreamState State
)
{
HRESULT hr = S_OK;
if ( m_CustomPinCount > 0 )
{
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! Custom Pin State changing to %d", State);
for (ULONG ulIndex = 0; ulIndex < m_InPins.size(); ulIndex++)
{
BOOL isCustom = false;
CInPin* pInPin = static_cast<CInPin*>(m_InPins[ulIndex]);
if ( SUCCEEDED( CheckCustomPin(pInPin, &isCustom) )
&& ( isCustom ) )
{
// Start the custom stream here. This will involve sending an event to the pipeline about the stream needing a state change
ComPtr<IMFMediaType> spMediaType;
if ( State == DeviceStreamState_Run )
{
// Only get the media type if we are going into run state
DMFTCHECKHR_GOTO(pInPin->GetMediaTypeAt(0, spMediaType.GetAddressOf()), done);
}
pInPin->SetState(DeviceStreamState_Disabled);
pInPin->setPreferredMediaType(spMediaType.Get());
pInPin->setPreferredStreamState(State);
//
// Let the pipline know that the input needs to be changed on the custom pin
//
SendEventToManager(METransformInputStreamStateChanged, GUID_NULL, pInPin->streamId());
//
// The media type will be set on the input pin by the time we return from the wait.
// For a custom pin, which is often the stats pin we can skip the wait as this will
// simply make the pipeline wait
//
DMFTCHECKHR_GOTO(pInPin->WaitForSetInputPinMediaChange(), done);
}
}
}
done:
DMFTRACE(DMFT_GENERAL, TRACE_LEVEL_INFORMATION, "%!FUNC! exiting %x = %!HRESULT!", hr, hr);
return hr;
}
| {
"pile_set_name": "Github"
} |
.ContentBackground:
backgroundColor: $ContentBackgroundColor
.ScrollableContentBackground:
_superclass: .ContentBackground
scrollIndicatorStyle: $ScrollIndicatorStyle
.ContentDisplayText:
_superclass: .DisplayText
color: $HeadingTextColor
.ContentHeadlineText:
_superclass: .HeadlineText
color: $HeadingTextColor
.ContentTitleText:
_superclass: .TitleText
color: $HeadingTextColor
.ContentSubheadText:
_superclass: .SubheadText
color: $HeadingTextColor
.ContentBodyText:
_superclass: .BodyText
color: $BodyTextColor
.ContentCaptionText:
_superclass: .CaptionText
color: $CaptionTextColor
| {
"pile_set_name": "Github"
} |
<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<template>
<link rel="import" href="external.html">
</template>
| {
"pile_set_name": "Github"
} |
<shapes name="mxgraph.bpmn">
<shape h="10.39" name="Ad Hoc" strokewidth="inherit" w="15">
<connections/>
<background>
<path>
<move x="0" y="1.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="1" x="7.5" x-axis-rotation="0" y="1.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="0" x="15" x-axis-rotation="0" y="1.69"/>
<line x="15" y="8.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="1" x="7.5" x-axis-rotation="0" y="8.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="0" x="0" x-axis-rotation="0" y="8.69"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape h="65" name="Business Rule Task" strokewidth="inherit" w="100">
<connections/>
<background>
<rect h="65" w="100" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<path>
<move x="0" y="15"/>
<line x="100" y="15"/>
<move x="1" y="40"/>
<line x="99.4" y="40"/>
<move x="25" y="15"/>
<line x="25" y="65"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Cancel End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<path>
<move x="23.5" y="23.5"/>
<line x="73.5" y="73.5"/>
<move x="73.5" y="23.5"/>
<line x="23.5" y="73.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Cancel Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<fillstroke/>
<strokewidth width="3"/>
<path>
<move x="24.5" y="24.5"/>
<line x="74.5" y="74.5"/>
<move x="74.5" y="24.5"/>
<line x="24.5" y="74.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape h="10" name="Compensation" strokewidth="inherit" w="15">
<connections/>
<background>
<path>
<move x="0" y="5"/>
<line x="7.5" y="0"/>
<line x="7.5" y="10"/>
<close/>
<move x="7.5" y="5"/>
<line x="15" y="0"/>
<line x="15" y="10"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Compensation End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<save/>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<restore/>
<rect/>
<stroke/>
<path>
<move x="26.5" y="48.5"/>
<line x="48.5" y="33.5"/>
<line x="48.5" y="63.5"/>
<close/>
<move x="48.5" y="48.5"/>
<line x="70.5" y="33.5"/>
<line x="70.5" y="63.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Compensation Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<fillstroke/>
<path>
<move x="27.5" y="49.5"/>
<line x="49.5" y="34.5"/>
<line x="49.5" y="64.5"/>
<close/>
<move x="49.5" y="49.5"/>
<line x="71.5" y="34.5"/>
<line x="71.5" y="64.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Error End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<save/>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<restore/>
<rect/>
<stroke/>
<path>
<move x="26.5" y="79.5"/>
<line x="39.5" y="24.5"/>
<line x="58.5" y="61.5"/>
<line x="69.5" y="18.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Error Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<path>
<move x="27.5" y="80.5"/>
<line x="40.5" y="25.5"/>
<line x="59.5" y="62.5"/>
<line x="70.5" y="19.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway AND" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<path>
<move x="49.5" y="19.5"/>
<line x="49.5" y="79.5"/>
<move x="79.5" y="49.5"/>
<line x="19.5" y="49.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway COMPLEX" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<strokewidth width="3"/>
<path>
<move x="79.5" y="49.5"/>
<line x="19.5" y="49.5"/>
<move x="49.5" y="19.5"/>
<line x="49.5" y="79.5"/>
<move x="28.5" y="28.5"/>
<line x="70.5" y="70.5"/>
<move x="70.5" y="28.5"/>
<line x="28.5" y="70.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway OR" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<strokewidth width="3"/>
<ellipse h="50" w="50" x="24.5" y="24.5"/>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway XOR (data)" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
<move x="37.5" y="23.5"/>
<line x="61.5" y="75.5"/>
<move x="61.5" y="23.5"/>
<line x="37.5" y="75.5"/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Gateway XOR (event)" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
</connections>
<background>
<path>
<move x="49.5" y="0"/>
<line x="99" y="49.5"/>
<line x="49.5" y="99"/>
<line x="0" y="49.5"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<ellipse h="49.8" w="49.8" x="24.6" y="24.6"/>
<stroke/>
<ellipse h="46.2" w="46.2" x="26.4" y="26.4"/>
<stroke/>
<path>
<move x="49.5" y="37.1"/>
<line x="60.2" y="55.7"/>
<line x="38.8" y="55.7"/>
<close/>
<move x="49.5" y="61.9"/>
<line x="59.5" y="43.3"/>
<line x="38.5" y="43.3"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="General End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="General Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="General Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Link End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<save/>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<restore/>
<rect/>
<stroke/>
<path>
<move x="25.5" y="57.5"/>
<line x="25.5" y="39.5"/>
<line x="54.5" y="39.5"/>
<line x="54.5" y="31.5"/>
<line x="71.5" y="48.5"/>
<line x="54.5" y="65.5"/>
<line x="54.5" y="57.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Link Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<path>
<move x="26.5" y="58.5"/>
<line x="26.5" y="40.5"/>
<line x="55.5" y="40.5"/>
<line x="55.5" y="32.5"/>
<line x="72.5" y="49.5"/>
<line x="55.5" y="66.5"/>
<line x="55.5" y="58.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Link Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<path>
<move x="26.5" y="58.5"/>
<line x="26.5" y="40.5"/>
<line x="55.5" y="40.5"/>
<line x="55.5" y="32.5"/>
<line x="72.5" y="49.5"/>
<line x="55.5" y="66.5"/>
<line x="55.5" y="58.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape h="21.62" name="Loop" strokewidth="inherit" w="22.49">
<connections/>
<background>
<path>
<move x="5.5" y="19.08"/>
<arc large-arc-flag="1" rx="10" ry="10" sweep-flag="1" x="10.5" x-axis-rotation="0" y="21.08"/>
<move x="5.5" y="14.08"/>
<line x="5.5" y="19.08"/>
<line x="0" y="17.58"/>
</path>
</background>
<foreground>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="10.39" name="Loop Marker" strokewidth="inherit" w="15">
<connections/>
<background>
<path>
<move x="0" y="1.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="1" x="7.5" x-axis-rotation="0" y="1.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="0" x="15" x-axis-rotation="0" y="1.69"/>
<line x="15" y="8.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="1" x="7.5" x-axis-rotation="0" y="8.69"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="0" x="0" x-axis-rotation="0" y="8.69"/>
<close/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape h="59.28" name="Manual Task" strokewidth="inherit" w="91.4">
<connections/>
<background>
<path>
<move x="0" y="14"/>
<arc large-arc-flag="0" rx="20" ry="20" sweep-flag="1" x="14" x-axis-rotation="0" y="0"/>
<line x="50" y="0"/>
<arc large-arc-flag="0" rx="6" ry="6" sweep-flag="1" x="50" x-axis-rotation="0" y="11"/>
<line x="26" y="11"/>
<line x="87" y="11"/>
<arc large-arc-flag="0" rx="7" ry="7" sweep-flag="1" x="87" x-axis-rotation="0" y="24"/>
<line x="45" y="24"/>
<line x="87" y="24"/>
<arc large-arc-flag="0" rx="7" ry="7" sweep-flag="1" x="87" x-axis-rotation="0" y="37"/>
<line x="49" y="37"/>
<line x="82" y="37"/>
<arc large-arc-flag="0" rx="6" ry="6" sweep-flag="1" x="82" x-axis-rotation="0" y="49"/>
<line x="48" y="49"/>
<line x="75" y="49"/>
<arc large-arc-flag="0" rx="5" ry="5" sweep-flag="1" x="75" x-axis-rotation="0" y="59"/>
<line x="9" y="59"/>
<arc large-arc-flag="0" rx="8" ry="8" sweep-flag="1" x="0" x-axis-rotation="0" y="52"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Message End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<save/>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<restore/>
<rect/>
<stroke/>
<rect h="40" w="70" x="13.5" y="28.5"/>
<stroke/>
<path>
<move x="13.5" y="28.5"/>
<line x="48.5" y="48.5"/>
<line x="83.5" y="28.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Message Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<rect h="40" w="70" x="14.5" y="29.5"/>
<stroke/>
<path>
<move x="14.5" y="29.5"/>
<line x="49.5" y="49.5"/>
<line x="84.5" y="29.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Message Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<rect h="40" w="70" x="14.5" y="29.5"/>
<stroke/>
<path>
<move x="14.5" y="29.5"/>
<line x="49.5" y="49.5"/>
<line x="84.5" y="29.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Multiple End" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<save/>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<restore/>
<rect/>
<stroke/>
<path>
<move x="48.5" y="23.5"/>
<line x="70.5" y="60.5"/>
<line x="26.5" y="60.5"/>
<close/>
<move x="48.5" y="73.5"/>
<line x="70.5" y="36.5"/>
<line x="26.5" y="36.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="14" name="Multiple Instances" strokewidth="inherit" w="9">
<connections/>
<background>
<path>
<move x="0" y="0"/>
<line x="3" y="0"/>
<line x="3" y="14"/>
<line x="0" y="14"/>
<close/>
<move x="6" y="0"/>
<line x="9" y="0"/>
<line x="9" y="14"/>
<line x="6" y="14"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Multiple Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<path>
<move x="49.5" y="24.5"/>
<line x="71.5" y="61.5"/>
<line x="27.5" y="61.5"/>
<close/>
<move x="49.5" y="74.5"/>
<line x="71.5" y="37.5"/>
<line x="27.5" y="37.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Multiple Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<path>
<move x="49.5" y="24.5"/>
<line x="71.5" y="61.5"/>
<line x="27.5" y="61.5"/>
<close/>
<move x="49.5" y="74.5"/>
<line x="71.5" y="37.5"/>
<line x="27.5" y="37.5"/>
<close/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Rule Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<rect h="68" w="40" x="29.5" y="15.5"/>
<stroke/>
<path>
<move x="29.5" y="22.5"/>
<line x="61.5" y="22.5"/>
<move x="29.5" y="40.5"/>
<line x="61.5" y="40.5"/>
<move x="29.5" y="58.5"/>
<line x="61.5" y="58.5"/>
<move x="29.5" y="76.5"/>
<line x="61.5" y="76.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Rule Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<rect h="68" w="40" x="29.5" y="15.5"/>
<stroke/>
<path>
<move x="29.5" y="22.5"/>
<line x="61.5" y="22.5"/>
<move x="29.5" y="40.5"/>
<line x="61.5" y="40.5"/>
<move x="29.5" y="58.5"/>
<line x="61.5" y="58.5"/>
<move x="29.5" y="76.5"/>
<line x="61.5" y="76.5"/>
</path>
<stroke/>
</foreground>
</shape>
<shape h="100" name="Script Task" strokewidth="inherit" w="73.4">
<connections/>
<background>
<path>
<move x="61.7" y="0"/>
<arc large-arc-flag="0" rx="40" ry="40" sweep-flag="0" x="61.7" x-axis-rotation="0" y="50"/>
<arc large-arc-flag="0" rx="40" ry="40" sweep-flag="1" x="61.7" x-axis-rotation="0" y="100"/>
<line x="11.7" y="100"/>
<arc large-arc-flag="0" rx="40" ry="40" sweep-flag="0" x="11.7" x-axis-rotation="0" y="50"/>
<arc large-arc-flag="0" rx="40" ry="40" sweep-flag="1" x="11.7" x-axis-rotation="0" y="0"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<path>
<move x="21.7" y="50"/>
<line x="51.7" y="50"/>
<move x="13.7" y="30"/>
<line x="43.7" y="30"/>
<move x="15.7" y="10"/>
<line x="45.7" y="10"/>
<move x="29.7" y="70"/>
<line x="59.7" y="70"/>
<move x="27.7" y="90"/>
<line x="57.7" y="90"/>
</path>
<stroke/>
</foreground>
</shape>
<shape h="93.3" name="Service Task" strokewidth="inherit" w="90.9">
<connections/>
<background>
<path>
<move x="2.06" y="24.62"/>
<line x="10.17" y="30.95"/>
<line x="9.29" y="37.73"/>
<line x="0" y="41.42"/>
<line x="2.95" y="54.24"/>
<line x="13.41" y="52.92"/>
<line x="17.39" y="58.52"/>
<line x="13.56" y="67.66"/>
<line x="24.47" y="74.44"/>
<line x="30.81" y="66.33"/>
<line x="37.88" y="67.21"/>
<line x="41.57" y="76.5"/>
<line x="54.24" y="73.55"/>
<line x="53.06" y="62.94"/>
<line x="58.52" y="58.52"/>
<line x="67.21" y="63.09"/>
<line x="74.58" y="51.88"/>
<line x="66.03" y="45.25"/>
<line x="66.92" y="38.62"/>
<line x="76.5" y="34.93"/>
<line x="73.7" y="22.26"/>
<line x="62.64" y="23.44"/>
<line x="58.81" y="18.42"/>
<line x="62.79" y="8.7"/>
<line x="51.74" y="2.21"/>
<line x="44.81" y="10.47"/>
<line x="38.03" y="9.43"/>
<line x="33.75" y="0"/>
<line x="21.52" y="3.24"/>
<line x="22.7" y="13.56"/>
<line x="18.13" y="17.54"/>
<line x="8.7" y="13.56"/>
<close/>
<move x="24.8" y="39"/>
<arc large-arc-flag="1" rx="12" ry="12" sweep-flag="1" x="51.8" x-axis-rotation="0" y="39"/>
<arc large-arc-flag="0" rx="12" ry="12" sweep-flag="1" x="24.8" x-axis-rotation="0" y="39"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<path>
<move x="16.46" y="41.42"/>
<line x="24.57" y="47.75"/>
<line x="23.69" y="54.53"/>
<line x="14.4" y="58.22"/>
<line x="17.35" y="71.04"/>
<line x="27.81" y="69.72"/>
<line x="31.79" y="75.32"/>
<line x="27.96" y="84.46"/>
<line x="38.87" y="91.24"/>
<line x="45.21" y="83.13"/>
<line x="52.28" y="84.01"/>
<line x="55.97" y="93.3"/>
<line x="68.64" y="90.35"/>
<line x="67.46" y="79.74"/>
<line x="72.92" y="75.32"/>
<line x="81.61" y="79.89"/>
<line x="88.98" y="68.68"/>
<line x="80.43" y="62.05"/>
<line x="81.32" y="55.42"/>
<line x="90.9" y="51.73"/>
<line x="88.1" y="39.06"/>
<line x="77.04" y="40.24"/>
<line x="73.21" y="35.22"/>
<line x="77.19" y="25.5"/>
<line x="66.14" y="19.01"/>
<line x="59.21" y="27.27"/>
<line x="52.43" y="26.23"/>
<line x="48.15" y="16.8"/>
<line x="35.92" y="20.04"/>
<line x="37.1" y="30.36"/>
<line x="32.53" y="34.34"/>
<line x="23.1" y="30.36"/>
<close/>
<move x="39.2" y="55.8"/>
<arc large-arc-flag="1" rx="12" ry="12" sweep-flag="1" x="66.2" x-axis-rotation="0" y="55.8"/>
<arc large-arc-flag="0" rx="12" ry="12" sweep-flag="1" x="39.2" x-axis-rotation="0" y="55.8"/>
<close/>
</path>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="97" name="Terminate" strokewidth="inherit" w="97">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="97" w="97" x="0" y="0"/>
</background>
<foreground>
<strokewidth width="3"/>
<fillstroke/>
<strokewidth width="42"/>
<ellipse h="42" w="42" x="27.5" y="27.5"/>
<fillstroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Timer Intermediate" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="92" w="92" x="3.5" y="3.5"/>
<stroke/>
<ellipse h="78" w="78" x="10.5" y="10.5"/>
<stroke/>
<path>
<move x="49.5" y="49.5"/>
<line x="51.5" y="16"/>
<move x="49.5" y="49.5"/>
<line x="71.5" y="49.5"/>
<move x="49.5" y="10.5"/>
<line x="49.5" y="15.5"/>
<move x="69" y="15.6"/>
<line x="66.2" y="20.5"/>
<move x="83.2" y="29.8"/>
<line x="78.3" y="32.8"/>
<move x="88.5" y="49.5"/>
<line x="83.5" y="49.5"/>
<move x="83.2" y="69.2"/>
<line x="78.3" y="66.2"/>
<move x="30" y="15.6"/>
<line x="32.8" y="20.5"/>
<move x="69" y="83.4"/>
<line x="66.2" y="78.5"/>
<move x="49.5" y="83.5"/>
<line x="49.5" y="88.5"/>
<move x="30" y="83.4"/>
<line x="32.8" y="78.5"/>
<move x="15.8" y="69.2"/>
<line x="20.7" y="66.2"/>
<move x="10.5" y="49.5"/>
<line x="15.5" y="49.5"/>
<move x="15.8" y="29.8"/>
<line x="20.7" y="32.8"/>
</path>
<stroke/>
</foreground>
</shape>
<shape aspect="fixed" h="99" name="Timer Start" strokewidth="inherit" w="99">
<connections>
<constraint name="N" perimeter="0" x="0.5" y="0"/>
<constraint name="S" perimeter="0" x="0.5" y="1"/>
<constraint name="W" perimeter="0" x="0" y="0.5"/>
<constraint name="E" perimeter="0" x="1" y="0.5"/>
<constraint name="NW" perimeter="0" x="0.145" y="0.145"/>
<constraint name="SW" perimeter="0" x="0.145" y="0.855"/>
<constraint name="NE" perimeter="0" x="0.855" y="0.145"/>
<constraint name="SE" perimeter="0" x="0.855" y="0.855"/>
</connections>
<background>
<ellipse h="99" w="99" x="0" y="0"/>
</background>
<foreground>
<fillstroke/>
<ellipse h="78" w="78" x="10.5" y="10.5"/>
<stroke/>
<path>
<move x="49.5" y="49.5"/>
<line x="51.5" y="16"/>
<move x="49.5" y="49.5"/>
<line x="71.5" y="49.5"/>
<move x="49.5" y="10.5"/>
<line x="49.5" y="15.5"/>
<move x="69" y="15.6"/>
<line x="66.2" y="20.5"/>
<move x="83.2" y="29.8"/>
<line x="78.3" y="32.8"/>
<move x="88.5" y="49.5"/>
<line x="83.5" y="49.5"/>
<move x="83.2" y="69.2"/>
<line x="78.3" y="66.2"/>
<move x="30" y="15.6"/>
<line x="32.8" y="20.5"/>
<move x="69" y="83.4"/>
<line x="66.2" y="78.5"/>
<move x="49.5" y="83.5"/>
<line x="49.5" y="88.5"/>
<move x="30" y="83.4"/>
<line x="32.8" y="78.5"/>
<move x="15.8" y="69.2"/>
<line x="20.7" y="66.2"/>
<move x="10.5" y="49.5"/>
<line x="15.5" y="49.5"/>
<move x="15.8" y="29.8"/>
<line x="20.7" y="32.8"/>
</path>
<stroke/>
</foreground>
</shape>
<shape h="91.81" name="User Task" strokewidth="inherit" w="94">
<connections/>
<background>
<path>
<move x="0" y="91.81"/>
<line x="0" y="63.81"/>
<arc large-arc-flag="0" rx="50" ry="50" sweep-flag="1" x="24" x-axis-rotation="0" y="42.81"/>
<arc large-arc-flag="0" rx="25" ry="25" sweep-flag="1" x="33" x-axis-rotation="0" y="41.81"/>
<arc large-arc-flag="0" rx="17" ry="17" sweep-flag="0" x="48" x-axis-rotation="0" y="58.81"/>
<arc large-arc-flag="0" rx="17" ry="17" sweep-flag="0" x="66" x-axis-rotation="0" y="41.81"/>
<arc large-arc-flag="0" rx="25" ry="25" sweep-flag="1" x="76.8" x-axis-rotation="0" y="42.81"/>
<arc large-arc-flag="0" rx="35" ry="35" sweep-flag="1" x="94" x-axis-rotation="0" y="63.81"/>
<line x="94" y="91.81"/>
<close/>
<move x="66" y="41.81"/>
<arc large-arc-flag="0" rx="17" ry="17" sweep-flag="1" x="48" x-axis-rotation="0" y="58.81"/>
<arc large-arc-flag="0" rx="17" ry="17" sweep-flag="1" x="33" x-axis-rotation="0" y="41.81"/>
<arc large-arc-flag="0" rx="25" ry="25" sweep-flag="0" x="38" x-axis-rotation="0" y="40.81"/>
<line x="39" y="36.81"/>
<arc large-arc-flag="0" rx="10" ry="10" sweep-flag="1" x="32" x-axis-rotation="0" y="30.81"/>
<arc large-arc-flag="1" rx="18" ry="12" sweep-flag="1" x="66" x-axis-rotation="0" y="30.81"/>
<arc large-arc-flag="0" rx="12" ry="12" sweep-flag="1" x="58" x-axis-rotation="0" y="36.81"/>
<line x="59" y="40.81"/>
<close/>
</path>
</background>
<foreground>
<fillstroke/>
<path>
<move x="16" y="75.81"/>
<line x="16" y="90.81"/>
<move x="75" y="75.81"/>
<line x="75" y="90.81"/>
</path>
<stroke/>
<fillcolor color="#000000"/>
<path>
<move x="32" y="30.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="1" x="29" x-axis-rotation="0" y="13.81"/>
<arc large-arc-flag="0" rx="22" ry="22" sweep-flag="1" x="48" x-axis-rotation="0" y="0.81"/>
<arc large-arc-flag="0" rx="22" ry="22" sweep-flag="1" x="70" x-axis-rotation="0" y="13.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="1" x="66" x-axis-rotation="0" y="30.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="0" x="64" x-axis-rotation="0" y="21.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="0" x="50" x-axis-rotation="0" y="20.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="0" x="35" x-axis-rotation="0" y="21.81"/>
<arc large-arc-flag="0" rx="15" ry="15" sweep-flag="0" x="32" x-axis-rotation="0" y="30.81"/>
<close/>
</path>
<fillstroke/>
</foreground>
</shape>
</shapes> | {
"pile_set_name": "Github"
} |
## Progress
Progress represents a follower’s progress in the view of the leader. Leader maintains progresses of all followers, and sends `replication message` to the follower based on its progress.
`replication message` is a `msgApp` with log entries.
A progress has two attribute: `match` and `next`. `match` is the index of the highest known matched entry. If leader knows nothing about follower’s replication status, `match` is set to zero. `next` is the index of the first entry that will be replicated to the follower. Leader puts entries from `next` to its latest one in next `replication message`.
A progress is in one of the three state: `probe`, `replicate`, `snapshot`.
```
+--------------------------------------------------------+
| send snapshot |
| |
+---------+----------+ +----------v---------+
+---> probe | | snapshot |
| | max inflight = 1 <----------------------------------+ max inflight = 0 |
| +---------+----------+ +--------------------+
| | 1. snapshot success
| | (next=snapshot.index + 1)
| | 2. snapshot failure
| | (no change)
| | 3. receives msgAppResp(rej=false&&index>lastsnap.index)
| | (match=m.index,next=match+1)
receives msgAppResp(rej=true)
(next=match+1)| |
| |
| |
| | receives msgAppResp(rej=false&&index>match)
| | (match=m.index,next=match+1)
| |
| |
| |
| +---------v----------+
| | replicate |
+---+ max inflight = n |
+--------------------+
```
When the progress of a follower is in `probe` state, leader sends at most one `replication message` per heartbeat interval. The leader sends `replication message` slowly and probing the actual progress of the follower. A `msgHeartbeatResp` or a `msgAppResp` with reject might trigger the sending of the next `replication message`.
When the progress of a follower is in `replicate` state, leader sends `replication message`, then optimistically increases `next` to the latest entry sent. This is an optimized state for fast replicating log entries to the follower.
When the progress of a follower is in `snapshot` state, leader stops sending any `replication message`.
A newly elected leader sets the progresses of all the followers to `probe` state with `match` = 0 and `next` = last index. The leader slowly (at most once per heartbeat) sends `replication message` to the follower and probes its progress.
A progress changes to `replicate` when the follower replies with a non-rejection `msgAppResp`, which implies that it has matched the index sent. At this point, leader starts to stream log entries to the follower fast. The progress will fall back to `probe` when the follower replies a rejection `msgAppResp` or the link layer reports the follower is unreachable. We aggressively reset `next` to `match`+1 since if we receive any `msgAppResp` soon, both `match` and `next` will increase directly to the `index` in `msgAppResp`. (We might end up with sending some duplicate entries when aggressively reset `next` too low. see open question)
A progress changes from `probe` to `snapshot` when the follower falls very far behind and requires a snapshot. After sending `msgSnap`, the leader waits until the success, failure or abortion of the previous snapshot sent. The progress will go back to `probe` after the sending result is applied.
### Flow Control
1. limit the max size of message sent per message. Max should be configurable.
Lower the cost at probing state as we limit the size per message; lower the penalty when aggressively decreased to a too low `next`
2. limit the # of in flight messages < N when in `replicate` state. N should be configurable. Most implementation will have a sending buffer on top of its actual network transport layer (not blocking raft node). We want to make sure raft does not overflow that buffer, which can cause message dropping and triggering a bunch of unnecessary resending repeatedly.
| {
"pile_set_name": "Github"
} |
# Multi-Stage Code Generation within `ygot`
**Authors**: robjs<sup>†</sup>, wenbli<sup>†</sup> <small>(<sup>†</sup>@google.com)</small>
**July 2020**
## Overview
Originally, the `ygen` package was developed to solely generate a single format of Go code from a YANG schema. Following this initial implementation, it has subsequently been extended to generate additional code artifacts, including a library for generating path-based helpers (`ypathgen`) and generating protobuf IDL files from a YANG schema. As each of these languages were added, some incremental changes were made (e.g., generating a set of leaf types and directory definitions for `ypathgen`, and refactoring of common state generation for protobuf-generation), but as new options for generation of code have been added to the `ygen` package, its complexity has increased. In order to reduce the maintenance effort for ygen, as well as allow simpler extension of the ygot-suite into generating new code from YANG modules (e.g., C++, or Python), some refactoring is required.
Particularly, we intend to restructure ygen to enforce a strict multi-stage code generation process. The target end-to-end pipeline is targeted to be:
1. An input set of YANG schemas is to be parsed by `goyang` and resolved through `yang.Node` representations into a set of `yang.Entry` structs. The set of `yang.Entry` structures that exist for a schema will be implemented to be lossless, such that there is no information that is available in the input YANG schema that cannot be extracted from them, and the original format of the structure is maintained.
1. A refactored `ygen` library will take the input set of `yang.Entry` structures for a schema, and create an intermediate representation (IR) that:
* Has undergone transformation of the schema that is required by the code generation process. The current schema transformations are described by `genutil.CompressBehaviour` and are implemented solely for OpenConfig modules. Their purpose is to simplify the generated code for particular users.
* Has resolved the types and names of entities that are to be output in the generated code. This should include the identification of directories, their fields and types, and any derived types that are needed by the generated code (typically enumerated types).
The IR produced by ygen will be lossy compared to the input YANG schema, and should expose the minimum required fields to the subsequent code generation stages. The IR should not include `yang.Entry` fields, such that there is an explicitly defined API that is available to code generation - and transformations that require full schema knowledge are applied within the `ygen` library itself.
Further to this, the IR itself must be language-agnostic to the greatest extent possible -- with any language-specific requirements being through well-known interfaces that are implemented by downstream code generation.
1. A set of language-specific, and potentially use-case specific, code generation libraries that convert the IR into a specific set of output code. These language libraries may consume only the `ygen` IR, and convert this from the pre-transformed schema into generated code artifacts. Different binaries may be utilised to call these libraries which provide the user interface.
This structure will have the following benefits:
* Knowledge of schema transformations will be clearly encapsulated into the `ygen` library -- today, numerous methods that are outputting code must be aware of the different transformations that are being applied to the schema - resulting in complex state tracking being required through the entire generation process. This causes significant additional effort to understand all the hooks required in the code generation libraries to add new output formats.
* Generation of names for output code entities is moved from being a on-the-fly process, which requires careful consideration of order, or can potentially have non-deterministic output - to being an up-front process. Previous changes have shown the benefits of moving enumeration naming to an up-front process where there can be clear understanding of how names are to be resolved, ensuring that there is a strictly defined IR ensures that this pattern can be applied across the code base.
* The requirement for expert knowledge of YANG for adding code generation can be reduced - for example, rather than requiring a developer adding to `ygen` to understand the structure of a `yang.Entry` and all the possible fields that can be used in these cases, `ygen` itself can clearly document the IR, and keep this to being a subset of the available information - for example, this allows abstraction of properties that depend on a characteristic of the YANG schema that can only be described in a `yang.Node` (e.g., how a element is defined in the actual YANG structure) away from code generation libraries.
* In the future, the IR may form a more compact means to express the YANG schema that is being used by `ytypes` for validation and unmarshalling -- since there is a reasonable binary size, and memory overhead for storing the existing `yang.Entry` structure. This aim is not part of the initial goal of implementing this design.
## Refactored `ygen` Design
### Language-specific Implementation Characteristics
In order to fully resolve the schema into an IR that includes all directories, and types, `ygen` must understand how to name these types. There are two approaches that could be taken to allow this.
* Produce an abstract naming that is language agnostic that can be mapped by the language-specific libraries at output time. Adopting this approach keeps the `ygen` logic itself as simple as possible, but comes at the cost of needing to make assumptions as to the uniqueness required of names -- for example, for languages that use a single namespace for all generated directories (that is `struct` or `message` entities) then there would need to be a globally-unique identifier, for languages that have scoped naming (e.g., use different packages, or scopes for the output code) this global uniqueness may need to be undone.
* Provide an `interface` via which a 'naming' entity can be provided to the generated code. This interface allows for a language-generating library to pick a specific means by which to name entities, and use this as the means by which they are referenced in the output code. Using this design, each generating library can provide individual "safe naming" methods, e.g., choosing `CamelCase` over `names_with_underscores`, without needing each of these naming behaviours to be translated from an abstract format, or implemented within `ygen` itself.
Based on prototyping, the language specific naming interface is to be adopted. Particularly, we define a `LangMapper` interface with the following characteristics:
```golang
type LangMapper interface {
// FieldName maps an input yang.Entry to the name that should be used
// in the intermediate representation. It is called for each field of
// a defined directory.
FieldName(e *yang.Entry) (string, error)
// DirectoryName maps an input yang.Entry to the name that should be used in the
// intermediate representation (IR). It is called for any directory entity that
// is to be output in the generated code.
DirectoryName(*yang.Entry, genutil.CompressBehaviour) (string, error)
// KeyLeafType maps an input yang.Entry which must represent a leaf to the
// type that should be used when the leaf is used in the context of a
// list key within the output IR.
KeyLeafType(*yang.Entry, genutil.CompressBehaviour) (*MappedType, error)
// LeafType maps an input yang.Entry which must represent a leaf to the
// type that should be used when the leaf is used in the context of a
// field within a directory within the output IR.
LeafType(*yang.Entry, genutil.CompressBehaviour) (*MappedType, error)
// EnumeratedValueName maps an input string representing an enumerated
// value to a language-safe name for the enumerated value. This function
// should ensure that the returned string is sanitised to ensure that
// it can be directly output in the generated code.
EnumeratedValueName(string) (string, error)
// SetEnumSet is used to supply a set of enumerated values to the
// mapper such that leaves that have enumerated types can be looked up.
// An enumSet provides lookup methods that allow:
// - simple enumerated types
// - identityrefs
// - enumerations within typedefs
// - identityrefs within typedefs
// to be resolved to the corresponding type that is to be used in
// the IR.
SetEnumSet(*enumSet)
// SetSchemaTree is used to supply a copy of the YANG schema tree to
// the mapped such that leaves of type leafref can be resolved to
// their target leaves.
SetSchemaTree(*schemaTree)
}
```
Within this interface:
* There is some leakage of the schema transformations, and `yang.Entry` outside of the `ygen` library itself (since the package defining the interface must be aware of these). However, these are limited - and encapsulated cleanly within methods that return simple types to the `ygen` generator process.
* Separate methods for naming leaves and directories are provided - it is expected that the `LeafName` can be used to name any field within the generated code, and requires only the input `yang.Entry`, where `DirectoryName` can be used to determine the name of a directory.
* Since we do not want the generating package to need to be aware of the logic behing generating an enumerated type, or the entire schema tree, `ygen` supplies the `LangMapper` with a copy of the fully-resolved set of enumerated types, and the schema tree via which references can be looked up.
* Two methods for generating leaf types are included - `LeafType` is used when the leaf being mapped to a type is a field of a `directory`, and `KeyLeafType` is used when a leaf is being mapped as part of a list key. The two methods are defined separately to ensure that where there are different types that are used for optional vs. mandatory contexts the mapping language can return different types. Most notably, this is the case in the `protobuf` output, where a wrapper type is used for standard leaves, whereas the simple built-in type is used when the field is mandatory as a list key.
* A language-specific method to map enumerated value names - this function should handle the means by which a enumeration or identity name (as specified by the RFC7950 grammar) can be safely translated to a value which can be used in the target language.
An implementation of a `LangMapper` keeps its own internal state that is not made accessible to the `ygen` library. Since a `LangMapper` implementation has access to the `yang.Entry`, it is able to use the entire context of a particular YANG entry to be able to choose how to map it to its name in the generated language.
Other than the `LangMapper` interface, no other language-specific mapping code is implemented in the production of the IR.
### Defining the ygen IR
Currently, the `ypathgen` library defines a `GetDirectoriesAndLeafTypes` method that can be called to return:
* A map of the directories that are used in the generated code, keyed by the YANG path (represented as a string).
* A map of maps, keyed by directory name, with the inner map keyed by field name, returning the language-type to be used for a particular leaf.
These types are sufficient for `ypathgen` to generate the code that it currently generates, but insufficient for all languages to be produced (or other formats of Go). Equally, there is some duplication between these types that requires cross-referencing between them which could be simplified.
We propose to modify this return format - and define the IR to be broken down into two subsets - encapsulated by a common type:
```
type Definitions struct {
// ParsedTree is the set of parsed directory entries, keyed by the YANG path
// to the directory.
ParsedTree map[string]*ParsedDirectory
// Enums is the set of enumerated entries that are extracted from the generated
// code. The key of the map is the global name of the enumeration.
Enums map[string]*EnumeratedYANGType
// ModelData stores the metadata extracted from the input YANG modules.
ModelData []*gpb.ModelData
}
```
#### Definitions for Directory / Leaf Nodes
The proposed IR for the directory types in the returned code is as follows. The base philosophy of whether fields are included within this representation is to keep to the set of fields made available to the code output library to their minimum, to ensure that there is clear encapsulation of the complexities of the YANG hierarchy within `ygen`.
```golang
// ParsedDirectory describes an internal node within the generated
// code. Such a 'directory' may represent a struct, or a message,
// in the generated code. It represents a YANG 'container' or 'list'.
type ParsedDirectory struct {
// Name is the language-specific name of the directory to be
// output.
Name string
// Type describes the type of directory that is being produced -
// such that YANG 'list' entries can have special handling.
Type DirType
// Fields is the set of direct children of the node that are
// to be output. It is keyed by the name of the child field
// using a language-specific format.
Fields map[string]*NodeDetails
// ListAttr describes the attributes of a YANG list that
// are required in the output code (e.g., the characteristics
// of the list's keys).
ListAttr *YangListAttr
// IsFakeRoot indicates whether the directory being described
// is the root entity and has been synthetically generated by
// ygen.
IsFakeRoot bool
}
// NodeDetails describes an individual field of the generated
// code tree. The Node may correspond to another Directory
// entry in the output code, or a individual leaf node.
type NodeDetails struct {
// Name is the language-specific name that should be used for
// the node.
Name string
// YANGDetails stores details of the node from the original
// YANG schema, such that some characteristics can be accessed
// by the code generation process. Only details that are
// directly required are provided.
YANGDetails YANGNodeDetails
// Type describes the type of node that the leaf represents,
// allowing for container, list, leaf and leaf-list entries
// to be distinguished.
// In the future it can be used to store other node types that
// form a direct child of a subtree node.
Type NodeType
// LangType describes the type that the node should be given in
// the output code, using the output of the language-specific
// type mapping provided by calling the LangMapper interface.
LangType *MappedType
// MapPaths describes the paths that the output node should
// be mapped to in the output code - these annotations can be
// used to annotation the output code with the field(s) that it
// corresponds to in the YANG schema.
MapPaths [][]string
}
// YANGNodeDetails stores the YANG-specific details of a node
// within the schema.
type YANGNodeDetails struct {
// Name is the name of the node from the YANG schema.
Name string
// Default represents the 'default' value directly
// specified in the YANG schema.
Default string
// Module stores the name of the module that instantiates
// the node.
Module string
// Path specifies the complete YANG schema node path.
Path []string
}
```
#### Definitions for Enumerated Types
YANG has a number of different types of enumerated values - particularly, `identity` and `enumeration` statements. Generated code may choose to treat these differently. For example, for an `enumeration` leaf - some languages may choose to use an embedded enumeration (e.g., protobuf can use a scoped `Enum` within a message). For this reason, some of the provenance of a particular value needs to be exposed to the downstream code generation libraries.
Despite this, a significant amount of pre-parsing can be done by the `ygen` library to pre-process enumerated values prior to being output to code. Particularly:
* Handling of an enumerated value's integer ID to an language-specific name can be created (using the relevant features of the `LangMapper` interface).
* A reverse mapping between the integer ID and defining module and corresponding YANG identifier can be created.
By performing this pre-processing, the functionality of the code generation library is constrained to determine how each type of enumeration should be output, and creating the language-specific constructs required for mapping (e.g., the enumeration map created in `ygen`'s current Go output).
The IR format for enumerations is defined to be as follows:
```golang
type EnumeratedValueType int64
const (
_ EnumeratedValueType = iota
// SimpleEnumerationType represents 'enumeration' leaves within
// the YANG schema.
SimpleEnumerationType
// DerivedEnumerationType represents enumerations that are within
// a YANG 'typedef'
DerivedEnumerationType
// UnionEnumerationType represents a 'type enumeration' within
// a union.
UnionEnumerationType
// DerivedUnionEnumeration type represents a 'enumeration' within
// a union that is itself within a typedef.
DerivedUnionEnumerationType
// IdentityType represents an enumeration that is an 'identity'
// within the YANG schema.
IdentityType
)
// EnumeratedYANGType is an abstract representation of an enumerated
// type to be produced in the output code.
type EnumeratedYANGType struct {
// Name is the name of the generated enumeration to be
// used in the generated code.
Name string
// Kind indicates the type of enumerated value that the
// EnumeratedYANGType represents - allowing for a code
// generation mechanism to select how different enumerated
// value types are output.
Kind EnumeratedValueType
// ValuePrefix stores any prefix that has been annotated by the IR generation
// that specifies what prefix should be appended to value names within the type.
ValuePrefix []string
// TypeName stores the original YANG type name for the enumeration.
TypeName string
// ValToCodeName stores the mapping between the int64
// value for the enumeration, and its language-specific
// name.
ValToCodeName map[int64]string
// ValToYANGDetails stores the mapping between the
// int64 identifier for the enumeration value and its
// YANG-specific details (as defined by the ygot.EnumDefinition).
ValToYANGDetails map[int64]*ygot.EnumDefinition
}
```
Some additional information - such as the `ValuePrefix` can be optionally generated when processing the enumerated types by the `LangMapper`, and is stored within the relevant `yang.Entry` as an `Annotation` field.
## Proposed Next Steps
This design has been arrived at through significant prototyping work in the `ygen` code-base. Following agreement of this design, we will begin to refactor the existing ygen code to meet this pattern. This work will be considered a pre-requisite for a 1.0.0 release of ygot as a package. | {
"pile_set_name": "Github"
} |
@php
/*
$layout_page = shop_profile
$user
*/
@endphp
@extends($sc_templatePath.'.layout')
@section('main')
<section >
<div class="container">
<div class="row">
<h2 class="title text-center">{{ trans('account.my_profile') }}</h2>
<ul class="list-group list-group-flush">
<li class="list-group-item"><i class="fa fa-angle-double-right" aria-hidden="true"></i> <a href="{{ sc_route('member.change_password') }}">{{ trans('account.change_password') }}</a></li>
<li class="list-group-item"><i class="fa fa-angle-double-right" aria-hidden="true"></i> <a href="{{ sc_route('member.change_infomation') }}">{{ trans('account.change_infomation') }}</a></li>
<li class="list-group-item"><i class="fa fa-angle-double-right" aria-hidden="true"></i> <a href="{{ sc_route('member.order_list') }}">{{ trans('account.order_list') }}</a></li>
</ul>
</div>
</div>
</section>
@endsection
@section('breadcrumb')
<div class="breadcrumbs">
<ol class="breadcrumb">
<li><a href="{{ sc_route('home') }}">{{ trans('front.home') }}</a></li>
<li class="active">{{ $title }}</li>
</ol>
</div>
@endsection
@push('styles')
{{-- style css --}}
@endpush
@push('scripts')
{{-- script --}}
@endpush
| {
"pile_set_name": "Github"
} |
> * 原文地址:[A Guide For Time Series Prediction Using Recurrent Neural Networks (LSTMs)](https://blog.statsbot.co/time-series-prediction-using-recurrent-neural-networks-lstms-807fa6ca7f)
> * 原文作者:[Neelabh Pant](https://blog.statsbot.co/@neelabhpant?source=post_header_lockup)
> * 译文出自:[掘金翻译计划](https://github.com/xitu/gold-miner)
> * 本文永久链接:[https://github.com/xitu/gold-miner/blob/master/TODO1/time-series-prediction-using-recurrent-neural-networks-lstms.md](https://github.com/xitu/gold-miner/blob/master/TODO1/time-series-prediction-using-recurrent-neural-networks-lstms.md)
> * 译者:[haiyang-tju](https://github.com/haiyang-tju)
> * 校对者:[TrWestdoor](https://github.com/TrWestdoor), [yzrds](https://github.com/yzrds)
# 使用递归神经网络(LSTMs)对时序数据进行预测
## 使用长短时记忆网络(LSTMs)来预测未来货币汇率变化

**[Statsbot](http://statsbot.co?utm_source=blog&utm_medium=article&utm_campaign=timeseries_lstm) 团队已经发表了一篇关于[使用时间序列分析进行异常检测](https://blog.statsbot.co/time-series-anomaly-detection-algorithms-1cef5519aef2)的文章。今天,我们将讨论使用长短时记忆模型(LSTMs)进行时间序列的预测。我们请数据科学家 Neelabh Pant 向大家来讲述他使用循环神经网络预测汇率变化的经验。**

作为一个生活在美国的印度人,我和我的家人之间会有源源不断的资金流相互流转。如果美元在市场上走强,那么印度卢比(INR)就会下跌,因此,一个印度人将要用更多的卢比来购买一美元。如果美元走弱,你就会花更少的卢比去购买同样的一美元。
如果你能预测出明天的一美元是什么价格,那么它就能指导你的决策,这对于最小化风险和最大化回报是非常重要的。通过观察神经网络的优势,特别是循环神经网络,我想到了预测美元和印度卢比的汇率。
预测汇率的方法有很多,例如:
* **购买力平价(PPP)**,它将通货膨胀考虑在内并计算通胀的差异。
* **相对经济实力方法**,它考虑了各国经济增长,以此对汇率的走势进行预测。
* **计量经济模式** 是另一种常用的汇率预测技术,可以根据预测者认为重要的因素或属性进行定制。这样的因素或属性可能是不同国家之间存在的利率差异、GDP 的增长率和收入增长率等特征。
* **时间序列模型** 则是纯粹取决于过去的变化行为和价格模式来预测未来的汇率对应价格。
在本文中,我们将告诉你如何使用机器学习进行时间序列分析来预测未来的汇率变化。
### 序列问题
让我们从顺序问题开始。涉及序列的最简单的机器学习问题是一对一问题。

一对一
在这种情况下,模型的输入数据或输入张量只有一个,同时模型根据给定的输入生成一个对应的预测。线性回归、分类和使用卷积网络进行的图像分类都属于这一范畴。将其进行拓展,可以允许模型使用输入和输出的旧值。
这就是一对多问题了。一对多问题开始时就和一对一问题一样,模型有一个输入,同时生成一个输出。然而,模型的输出现在作为新的输入反馈给模型。模型现在可以生成一个新的输出,我们可以这样无限地继续循环下去。现在你可以看到为什么这些被称为循环神经网络了。

一对多
使用递归神经网络处理序列问题,因为它们都可以连接形成一个有向的循环。换句话说,通过使用它们自己的输出作为下一个步骤的输入,它们可以保持从一个迭代到下一个迭代的状态。使用编程的术语来说,这就像是在运行一个固定的程序,其中带有特定输入和一些内部变量。如果我们在时间轴上将其**展开**,最简单的递归神经网络可以看作是一个完全连接的神经网络。

在时间轴上展开的 RNN

在这种单变量情况下,只涉及到两个权重。权重 _u_ 乘以当前的输入 _xt_,而另一个权重 _w_ 乘以前一次的输出 _yt-1_ 。这个公式类似于指数加权移动平均方法(EWMA),它将过去的输出值与当前的输入值结合起来。
可以通过简单堆叠神经网络单元来建立一个深层的循环神经网络。一个简单的循环神经网络只对短期记忆有效。如果我们有长期记忆的需求,就会发现它对此有根本上的不足。
### 长短时神经网络
正如我们已经讨论过的,一个简单的循环网络存在一个根本问题,即不能捕获序列中的长时依赖关系。我们构建的 RNNs 在分析文本和回答问题时,涉及到跟踪长序列的单词,所以这将会是一个问题。
在 90 年代后期,[LSTM 是由 Sepp Hochreiter 和 Jurgen Schmidhuber 提出的](http://www.mitpressjournals.org/doi/abs/10.1162/neco.1997.9.8.1735),用来替代 RNNs、隐马尔科夫模型以及其它众多应用中的序列学习方法,相比于它们 LSTM 对时间间隔长度不敏感。

LSTM 网络结构
该模型是一个操作单元,其中包括几个基本操作。LSTM 有一个内部状态变量,它从一个单元传递到另外一个单元,并由 **操作门** 来修改。
1. **遗忘门**

使用一个 sigmoid 层来接收前一个时间节点 _t-1_ 的输出和当前时间节点 _t_ 的输入,将其合并成为一个张量(tensor),然后在其后应用一个线性变换。经过 sigmoid 激活函数后,遗忘门的输出为 0 到 1 之间的数值。这个数值将会与内部状态相乘,这也就是为什么它会被称为遗忘门的原因。如果 _ft=0_,则完全忘记之前的内部状态,如果 _ft=1_ ,则会没有任何改变地通过。
2. **输入门**

输入门接受先前的输出和新输入,并将其传递到另一个 sigmoid 层。输入门返回的也是 0 到 1 之间的值。然后输入门返回的值与候选层的输出相乘。

这一层对输入和先前层的输出进行混合,然后应用双曲切线激活,返回一个候选向量添加到内部状态上。
内部状态更新规则如下:

之前的状态乘以遗忘门输出,然后添加到输出门允许的新的候选项中。
3. **输出门**


输出门控制着有多少内部状态被传递给输出,它的工作方式类似于其它的门结构。
上面描述的这三个门结构具有独立的权值和偏差,因此网络需要学习有多少过去的输出需要保留,有多少当前的输入需要保留,以及有多少的内部状态需要被传送到输出。
在递归神经网络中,需要输入的不仅仅是当前网络的输入数据,还有该网络的前一个时刻的状态数据。例如,如果我说“嘿!我在开车的时候发生了一件疯狂的事情”,然后你的大脑某个部分就开始转动开关,说“哦,这是 Neelabh 告诉我的一个故事,故事的主角是 Neelabh,路上发生了一些事情。”现在,你就会保留一部分我刚才告诉你的句子的信息。当你听我讲其它句子的时候,为了理解整个故事,你必须保留一些之前句子信息中的记忆。
另外一个例子是使用循环神经网络进行**视频处理**。在当前帧中发生的事情很大程度上取决于上一帧的内容。在一段时间内,一个循环神经网络应该学习到保留什么、从过去的数据中保留多少、以及对当前状态保留多少的策略,这使得它比简单的前馈神经网络更加强大。
### 时间序列预测
我对循环神经网络的优势印象是很深刻的,决定使用它来预测美元和印度卢比的汇率。本项目使用的数据集是 1980 年 1 月 2 日至 2017 年 8 月 10 日的汇率数据。稍后,我会提供一个链接来下载这个数据集并进行实验。

表 1 数据集示例
数据集显示了 1 美元的卢比价值。从 1980 年 1 月 2 日到 2017 年 8 月 10 日,我们总共有 13730 项记录。

USD 对 INR
从整个阶段看,1 美元的卢比价格一直是在上涨的。我们可以看到,美国经济在 2007 到 2008 年间大幅下滑,这在很大程度上是由那段时期的大衰退造成的。2000 年代末至 2010 年代初,全球市场普遍经历了经济衰退。
这段时期对世界上的发达经济体来说并不是很好,特别是北美和欧洲(包括俄罗斯),它们已经陷入了严重的经济衰退。许多较新的发达经济体受到的影响要小得多,特别是中国和印度,这两个国家的经济在这段时期大幅增长。
### 训练-测试数据划分
现在,要训练模型,我们就需要将数据划分为测试集和训练集。处理时间序列时,以一个特定的日期将其划分为训练集和测试集是非常重要的。所以,我们不希望看到的是测试数据出现在训练数据之前。
在我们的实验中,我们将定义一个日期,比如 2010 年 1 月 1 日,作为我们分开的日期。训练数据是 1980 年 1 月 2 日至 2009 年 12 月 31 日之间的数据,大约有 11000 个训练数据点。
测试数据集在 2010 年 1 月 1 日到 2017 年 8 月 10 日之间,大约 2700 个数据点。

测试-训练数据划分
接下来要做的是对数据集进行规范化。只需要调整和变换训练数据,然后变换测试数据即可。这样做的原因是,假定我们是不知道测试数据的规模的。
对数据进行规范化或变换是指应用一个新的介于 0 和 1 之间的缩放变量。
### 神经网络模型
**全连接模型**是一个简单的神经网络模型,它被构建为一个单输入单输出的回归模型。基本上是取前一天的价格来预测第二天的价格。
我们使用均方差作为损失函数,使用随机梯度下降作为优化器,在训练足够多的时期(epochs)后,将会找到一个较好的局部最优值。下面是全连接层的概要。

全连接层概要
在将该模型训练到 200 个时期后或者无论出现哪个 _early_callbacks_(即满足条件的提前终止回调)之后,该模型通过训练学习到数据的模式和行为。由于我们将数据分为训练集和测试集,我们现在可以预测测试数据对应的数值了,并将其与真实值进行比较。

真实值(蓝色)对 预测值(橙色)
正如你所看到的,这个模型的表现并不好。它本质上就是重复前面的数据,只有一个轻微的变化。全连接模型不能从单个先前值来预测未来的数据。现在让我们来尝试使用一个循环神经网络,看看它做得如何。
### **长短时记忆**
我们使用的循环网络模型是一个单层的顺序模型。在我们输入维度形状为 (1,1) 的层中使用了 6 个 LSTM 节点,即该网络的输入只有一个。

LSTM 模型概要
最后一层是密集层(即全连接层),损失函数采用的是均方差,优化器使用随机梯度下降算法。我们使用 _early_stopping_ 回调对这个模型进行了200次的训练。模型的概要如上图所示。

LSTM 预测
这个模型已经学到了重现数据在年度内的整体形状,而且不像前面使用简单的前馈神经网络那样有延迟。但是它仍然低估了一些观察值,所以该模型肯定还有改进的空间。
### 模型修改
该模型可以做很多的改变来使它变得更好。一般可以直接通过修改优化器来更改模型训练配置。另外一个重要的修改是使用了[滑动时间窗口](https://en.wikipedia.org/wiki/Data_stream_management_system#Windows)的方法,它是来自于流数据管理系统领域的方法。
这种方法来自于这样一种观点,即只有最近的数据才是重要的。你可以使用一年的模型数据,并试着对下一年的第一天做出预测。滑动时间窗口方法在获取数据集中的重要模式方面非常有用,这些模式高度依赖于过去的大量观察。
你可以尝试根据个人喜好对该模型进行修改,并查看模型对这些修改的反应。
### 数据集
我在 github 账户的仓库中 [deep learning in python](https://github.com/neelabhpant/Deep-Learning-in-Python) 提供了该数据集。请随意下载并使用它。
### 有用的资源
我个人关注了一些喜欢的数据科学家,比如 [Kirill Eremenko](https://www.superdatascience.com)、[Jose Portilla](https://www.udemy.com/user/joseporitlla/) 和 [Dan Van Boxel](https://www.youtube.com/user/dvbuntu)(即著名的 Dan Does Data)等等。他们中的大多数人都可以在不同的博客站点上找到,他们的博客中有很多不同的主题,比如 RNN、卷积神经网络和 LSTM,甚至最新的[神经图灵机](https://en.wikipedia.org/wiki/Neural_Turing_machine)技术。
保持更新各种[人工智能会议](http://www.aaai.org)的新闻。顺便说一下,如果你感兴趣的话,Kirill Eremenko 将会[在今年的 11 月份](https://www.datasciencego.com/?utm_source=Email&utm_medium=AllLess_ID1&utm_content=EM2_EarlyBirds_ImageLogo&utm_campaign=event)来到圣地亚哥和他的团队一起做关于机器学习、神经网络和数据科学的演讲。
### 结论
LSTM 模型足够强大,可以学习到最重要的过去行为,并理解这些过去的行为是否是进行未来预测的重要特征。在许多应用程序中,LSTM 的使用率都很高。一些应用比如语音识别、音乐合成和手写识别,甚至是在我目前的人口流动和旅游预测等的研究中。
在我看来,LSTM 就像是一个拥有自己记忆的模型,在做决定时可以表现得像一个聪明的人。
再次感谢,并祝在机器学习的学习过程中得到快乐!
> 如果发现译文存在错误或其他需要改进的地方,欢迎到 [掘金翻译计划](https://github.com/xitu/gold-miner) 对译文进行修改并 PR,也可获得相应奖励积分。文章开头的 **本文永久链接** 即为本文在 GitHub 上的 MarkDown 链接。
---
> [掘金翻译计划](https://github.com/xitu/gold-miner) 是一个翻译优质互联网技术文章的社区,文章来源为 [掘金](https://juejin.im) 上的英文分享文章。内容覆盖 [Android](https://github.com/xitu/gold-miner#android)、[iOS](https://github.com/xitu/gold-miner#ios)、[前端](https://github.com/xitu/gold-miner#前端)、[后端](https://github.com/xitu/gold-miner#后端)、[区块链](https://github.com/xitu/gold-miner#区块链)、[产品](https://github.com/xitu/gold-miner#产品)、[设计](https://github.com/xitu/gold-miner#设计)、[人工智能](https://github.com/xitu/gold-miner#人工智能)等领域,想要查看更多优质译文请持续关注 [掘金翻译计划](https://github.com/xitu/gold-miner)、[官方微博](http://weibo.com/juejinfanyi)、[知乎专栏](https://zhuanlan.zhihu.com/juejinfanyi)。
| {
"pile_set_name": "Github"
} |
/*!
* QUnit 1.18.0
* http://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-04-03T10:23Z
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699A4;
background-color: #0D3349;
font-size: 1.5em;
line-height: 1em;
font-weight: 400;
border-radius: 5px 5px 0 0;
}
#qunit-header a {
text-decoration: none;
color: #C2CCD1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #FFF;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 0.5em 0 0.1em;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
background-color: #2B81AF;
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
padding: 0.2em;
}
.qunit-url-config {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
float: right;
margin-left: 1em;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
visibility: hidden;
position: absolute;
width: 0px;
height: 0px;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #FFF;
border-radius: 5px;
}
.qunit-collapsed {
display: none;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: 0.2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 0.5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #E0F2BE;
color: #374E0C;
text-decoration: none;
}
#qunit-tests ins {
background-color: #FFCACA;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: #000; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #FFF;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #FFF;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
}
#qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
/** Result */
#qunit-testresult {
padding: 0.5em 1em 0.5em 1em;
color: #2B81AF;
background-color: #D2E0E6;
border-bottom: 1px solid #FFF;
}
#qunit-testresult .module-name {
font-weight: 700;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}
| {
"pile_set_name": "Github"
} |
SUBROUTINE ccsdtq_t4_1_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_off
&set)
C $Id$
C This is a Fortran77 program generated by Tensor Contraction Engine v.1.0
C Copyright (c) Battelle & Pacific Northwest National Laboratory (2002)
C i1 ( h14 p5 h1 h2 )_vt + = -1 * P( 2 ) * Sum ( p11 ) * t ( p11 h1 )_t * i2 ( h14 p5 h2 p11 )_v
IMPLICIT NONE
#include "global.fh"
#include "mafdecls.fh"
#include "sym.fh"
#include "errquit.fh"
#include "tce.fh"
INTEGER d_a
INTEGER k_a_offset
INTEGER d_b
INTEGER k_b_offset
INTEGER d_c
INTEGER k_c_offset
INTEGER nxtask
INTEGER next
INTEGER nprocs
INTEGER count
INTEGER p5b
INTEGER h14b
INTEGER h1b
INTEGER h2b
INTEGER dimc
INTEGER l_c_sort
INTEGER k_c_sort
INTEGER p11b
INTEGER p11b_1
INTEGER h1b_1
INTEGER p5b_2
INTEGER h14b_2
INTEGER h2b_2
INTEGER p11b_2
INTEGER dim_common
INTEGER dima_sort
INTEGER dima
INTEGER dimb_sort
INTEGER dimb
INTEGER l_a_sort
INTEGER k_a_sort
INTEGER l_a
INTEGER k_a
INTEGER l_b_sort
INTEGER k_b_sort
INTEGER l_b
INTEGER k_b
INTEGER l_c
INTEGER k_c
EXTERNAL nxtask
nprocs = GA_NNODES()
count = 0
next = nxtask(nprocs,1)
DO p5b = noab+1,noab+nvab
DO h14b = 1,noab
DO h1b = 1,noab
DO h2b = 1,noab
IF (next.eq.count) THEN
IF ((.not.restricted).or.(int_mb(k_spin+p5b-1)+int_mb(k_spin+h14b-
&1)+int_mb(k_spin+h1b-1)+int_mb(k_spin+h2b-1).ne.8)) THEN
IF (int_mb(k_spin+p5b-1)+int_mb(k_spin+h14b-1) .eq. int_mb(k_spin+
&h1b-1)+int_mb(k_spin+h2b-1)) THEN
IF (ieor(int_mb(k_sym+p5b-1),ieor(int_mb(k_sym+h14b-1),ieor(int_mb
&(k_sym+h1b-1),int_mb(k_sym+h2b-1)))) .eq. ieor(irrep_v,irrep_t)) T
&HEN
dimc = int_mb(k_range+p5b-1) * int_mb(k_range+h14b-1) * int_mb(k_r
&ange+h1b-1) * int_mb(k_range+h2b-1)
IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL
& ERRQUIT('ccsdtq_t4_1_3',0,MA_ERR)
CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1)
DO p11b = noab+1,noab+nvab
IF (int_mb(k_spin+p11b-1) .eq. int_mb(k_spin+h1b-1)) THEN
IF (ieor(int_mb(k_sym+p11b-1),int_mb(k_sym+h1b-1)) .eq. irrep_t) T
&HEN
CALL TCE_RESTRICTED_2(p11b,h1b,p11b_1,h1b_1)
CALL TCE_RESTRICTED_4(p5b,h14b,h2b,p11b,p5b_2,h14b_2,h2b_2,p11b_2)
dim_common = int_mb(k_range+p11b-1)
dima_sort = int_mb(k_range+h1b-1)
dima = dim_common * dima_sort
dimb_sort = int_mb(k_range+p5b-1) * int_mb(k_range+h14b-1) * int_m
&b(k_range+h2b-1)
dimb = dim_common * dimb_sort
IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN
IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL
& ERRQUIT('ccsdtq_t4_1_3',1,MA_ERR)
IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT('
&ccsdtq_t4_1_3',2,MA_ERR)
CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h1b_1
& - 1 + noab * (p11b_1 - noab - 1)))
CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p11b-1
&),int_mb(k_range+h1b-1),2,1,1.0d0)
IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('ccsdtq_t4_1_3',3,MA_ERR)
IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL
& ERRQUIT('ccsdtq_t4_1_3',4,MA_ERR)
IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT('
&ccsdtq_t4_1_3',5,MA_ERR)
CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p11b_
&2 - noab - 1 + nvab * (h2b_2 - 1 + noab * (h14b_2 - 1 + noab * (p5
&b_2 - noab - 1)))))
CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+p5b-1)
&,int_mb(k_range+h14b-1),int_mb(k_range+h2b-1),int_mb(k_range+p11b-
&1),3,2,1,4,1.0d0)
IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('ccsdtq_t4_1_3',6,MA_ERR)
CALL DGEMM('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a
&_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor
&t),dima_sort)
IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('ccsdtq_t4_1_3',7,MA
&_ERR)
IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('ccsdtq_t4_1_3',8,MA
&_ERR)
END IF
END IF
END IF
END DO
IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT('
&ccsdtq_t4_1_3',9,MA_ERR)
IF ((h1b .le. h2b)) THEN
CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h2b-1)
&,int_mb(k_range+h14b-1),int_mb(k_range+p5b-1),int_mb(k_range+h1b-1
&),3,2,4,1,-1.0d0)
CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h2b -
& 1 + noab * (h1b - 1 + noab * (h14b - 1 + noab * (p5b - noab - 1))
&)))
END IF
IF ((h2b .le. h1b)) THEN
CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h2b-1)
&,int_mb(k_range+h14b-1),int_mb(k_range+p5b-1),int_mb(k_range+h1b-1
&),3,2,1,4,1.0d0)
CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h1b -
& 1 + noab * (h2b - 1 + noab * (h14b - 1 + noab * (p5b - noab - 1))
&)))
END IF
IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('ccsdtq_t4_1_3',10,MA_ERR
&)
IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('ccsdtq_t4_1_3',11,M
&A_ERR)
END IF
END IF
END IF
next = nxtask(nprocs,1)
END IF
count = count + 1
END DO
END DO
END DO
END DO
next = nxtask(-nprocs,1)
call GA_SYNC()
RETURN
END
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 2014 BlueKitchen GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* 4. Any redistribution, use, or modification is done solely for
* personal benefit and not for any commercial purpose or for
* monetary gain.
*
* THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH 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 MATTHIAS
* RINGWALD 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.
*
* Please inquire about commercial licensing options at
* [email protected]
*
*/
#define BTSTACK_FILE__ "le_device_db_memory.c"
#include "ble/le_device_db.h"
#include "ble/core.h"
#include <string.h>
#include "btstack_debug.h"
// ignore if NVM_LE_DEVICE_DB_ENTRIES is defined
#ifndef NVM_NUM_DEVICE_DB_ENTRIES
// LE Device db implemenation using static memory
typedef struct le_device_memory_db {
// Identification
int addr_type;
bd_addr_t addr;
sm_key_t irk;
// Stored pairing information allows to re-establish an enncrypted connection
// with a peripheral that doesn't have any persistent memory
sm_key_t ltk;
uint16_t ediv;
uint8_t rand[8];
uint8_t key_size;
uint8_t authenticated;
uint8_t authorized;
uint8_t secure_connection;
#ifdef ENABLE_LE_SIGNED_WRITE
// Signed Writes by remote
sm_key_t remote_csrk;
uint32_t remote_counter;
// Signed Writes by us
sm_key_t local_csrk;
uint32_t local_counter;
#endif
} le_device_memory_db_t;
#ifndef MAX_NR_LE_DEVICE_DB_ENTRIES
#error "MAX_NR_LE_DEVICE_DB_ENTRIES not defined, please define in btstack_config.h"
#endif
static le_device_memory_db_t le_devices[MAX_NR_LE_DEVICE_DB_ENTRIES];
void le_device_db_init(void){
int i;
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
le_device_db_remove(i);
}
}
void le_device_db_set_local_bd_addr(bd_addr_t bd_addr){
(void)bd_addr;
}
// @returns number of device in db
int le_device_db_count(void){
int i;
int counter = 0;
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
if (le_devices[i].addr_type != BD_ADDR_TYPE_UNKNOWN) counter++;
}
return counter;
}
int le_device_db_max_count(void){
return MAX_NR_LE_DEVICE_DB_ENTRIES;
}
// free device
void le_device_db_remove(int index){
le_devices[index].addr_type = BD_ADDR_TYPE_UNKNOWN;
}
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk){
int i;
int index = -1;
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
if (le_devices[i].addr_type == BD_ADDR_TYPE_UNKNOWN){
index = i;
break;
}
}
if (index < 0) return -1;
log_info("LE Device DB adding type %u - %s", addr_type, bd_addr_to_str(addr));
log_info_key("irk", irk);
le_devices[index].addr_type = addr_type;
(void)memcpy(le_devices[index].addr, addr, 6);
(void)memcpy(le_devices[index].irk, irk, 16);
#ifdef ENABLE_LE_SIGNED_WRITE
le_devices[index].remote_counter = 0;
#endif
return index;
}
// get device information: addr type and address
void le_device_db_info(int index, int * addr_type, bd_addr_t addr, sm_key_t irk){
if (addr_type) *addr_type = le_devices[index].addr_type;
if (addr) (void)memcpy(addr, le_devices[index].addr, 6);
if (irk) (void)memcpy(irk, le_devices[index].irk, 16);
}
void le_device_db_encryption_set(int index, uint16_t ediv, uint8_t rand[8], sm_key_t ltk, int key_size, int authenticated, int authorized, int secure_connection){
log_info("LE Device DB set encryption for %u, ediv x%04x, key size %u, authenticated %u, authorized %u, secure connection %u",
index, ediv, key_size, authenticated, authorized, secure_connection);
le_device_memory_db_t * device = &le_devices[index];
device->ediv = ediv;
if (rand) (void)memcpy(device->rand, rand, 8);
if (ltk) (void)memcpy(device->ltk, ltk, 16);
device->key_size = key_size;
device->authenticated = authenticated;
device->authorized = authorized;
device->secure_connection = secure_connection;
}
void le_device_db_encryption_get(int index, uint16_t * ediv, uint8_t rand[8], sm_key_t ltk, int * key_size, int * authenticated, int * authorized, int * secure_connection){
le_device_memory_db_t * device = &le_devices[index];
log_info("LE Device DB encryption for %u, ediv x%04x, keysize %u, authenticated %u, authorized %u, secure connection %u",
index, device->ediv, device->key_size, device->authenticated, device->authorized, device->secure_connection);
if (ediv) *ediv = device->ediv;
if (rand) (void)memcpy(rand, device->rand, 8);
if (ltk) (void)memcpy(ltk, device->ltk, 16);
if (key_size) *key_size = device->key_size;
if (authenticated) *authenticated = device->authenticated;
if (authorized) *authorized = device->authorized;
if (secure_connection) *secure_connection = device->secure_connection;
}
#ifdef ENABLE_LE_SIGNED_WRITE
// get signature key
void le_device_db_remote_csrk_get(int index, sm_key_t csrk){
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
log_error("le_device_db_remote_csrk_get called with invalid index %d", index);
return;
}
if (csrk) (void)memcpy(csrk, le_devices[index].remote_csrk, 16);
}
void le_device_db_remote_csrk_set(int index, sm_key_t csrk){
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
log_error("le_device_db_remote_csrk_set called with invalid index %d", index);
return;
}
if (csrk) (void)memcpy(le_devices[index].remote_csrk, csrk, 16);
}
void le_device_db_local_csrk_get(int index, sm_key_t csrk){
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
log_error("le_device_db_local_csrk_get called with invalid index %d", index);
return;
}
if (csrk) (void)memcpy(csrk, le_devices[index].local_csrk, 16);
}
void le_device_db_local_csrk_set(int index, sm_key_t csrk){
if (index < 0 || index >= MAX_NR_LE_DEVICE_DB_ENTRIES){
log_error("le_device_db_local_csrk_set called with invalid index %d", index);
return;
}
if (csrk) (void)memcpy(le_devices[index].local_csrk, csrk, 16);
}
// query last used/seen signing counter
uint32_t le_device_db_remote_counter_get(int index){
return le_devices[index].remote_counter;
}
// update signing counter
void le_device_db_remote_counter_set(int index, uint32_t counter){
le_devices[index].remote_counter = counter;
}
// query last used/seen signing counter
uint32_t le_device_db_local_counter_get(int index){
return le_devices[index].local_counter;
}
// update signing counter
void le_device_db_local_counter_set(int index, uint32_t counter){
le_devices[index].local_counter = counter;
}
#endif
void le_device_db_dump(void){
log_info("LE Device DB dump, devices: %d", le_device_db_count());
int i;
for (i=0;i<MAX_NR_LE_DEVICE_DB_ENTRIES;i++){
if (le_devices[i].addr_type == BD_ADDR_TYPE_UNKNOWN) continue;
log_info("%u: %u %s", i, le_devices[i].addr_type, bd_addr_to_str(le_devices[i].addr));
log_info_key("irk", le_devices[i].irk);
#ifdef ENABLE_LE_SIGNED_WRITE
log_info_key("local csrk", le_devices[i].local_csrk);
log_info_key("remote csrk", le_devices[i].remote_csrk);
#endif
}
}
#endif
| {
"pile_set_name": "Github"
} |
var baseEach = require('./baseEach');
/**
* Gets the extremum value of `collection` invoking `iteratee` for each value
* in `collection` to generate the criterion by which the value is ranked.
* The `iteratee` is invoked with three arguments: (value, index|key, collection).
*
* @private
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} comparator The function used to compare values.
* @param {*} exValue The initial extremum value.
* @returns {*} Returns the extremum value.
*/
function baseExtremum(collection, iteratee, comparator, exValue) {
var computed = exValue,
result = computed;
baseEach(collection, function(value, index, collection) {
var current = +iteratee(value, index, collection);
if (comparator(current, computed) || (current === exValue && current === result)) {
computed = current;
result = value;
}
});
return result;
}
module.exports = baseExtremum;
| {
"pile_set_name": "Github"
} |
local L = pace.LanguageString
pace.Fonts = {}
for i = 1, 5 do
surface.CreateFont("pac_font_"..i,
{
font = "Arial",
size = 11 + i,
weight = 50,
antialias = true,
})
table.insert(pace.Fonts, "pac_font_"..i)
end
for i = 1, 5 do
surface.CreateFont("pac_font_bold"..i,
{
font = "Arial",
size = 11 + i,
weight = 800,
antialias = true,
})
table.insert(pace.Fonts, "pac_font_bold"..i)
end
table.insert(pace.Fonts, "DermaDefault")
table.insert(pace.Fonts, "DermaDefaultBold")
local font_cvar = CreateClientConVar("pac_editor_font", pace.Fonts[1])
function pace.SetFont(fnt)
pace.CurrentFont = fnt or font_cvar:GetString()
if not table.HasValue(pace.Fonts, pace.CurrentFont) then
pace.CurrentFont = "DermaDefault"
end
RunConsoleCommand("pac_editor_font", pace.CurrentFont)
if pace.Editor and pace.Editor:IsValid() then
pace.CloseEditor()
timer.Simple(0.1, function()
pace.OpenEditor()
end)
end
end
function pace.AddFontsToMenu(menu)
local menu,pnl = menu:AddSubMenu(L"font")
pnl:SetImage("icon16/text_bold.png")
menu.GetDeleteSelf = function() return false end
for key, val in pairs(pace.Fonts) do
local pnl = menu:AddOption(L"The quick brown fox jumps over the lazy dog. (" ..val ..")", function()
pace.SetFont(val)
end)
pnl:SetFont(val)
end
end
pace.SetFont() | {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2000-2001 Christoph Hellwig.
* Copyright (c) 2016 Krzysztof Blaszkowski
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL").
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Veritas filesystem driver - fileset header routines.
*/
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
#include "vxfs.h"
#include "vxfs_inode.h"
#include "vxfs_extern.h"
#include "vxfs_fshead.h"
#ifdef DIAGNOSTIC
static void
vxfs_dumpfsh(struct vxfs_fsh *fhp)
{
printk("\n\ndumping fileset header:\n");
printk("----------------------------\n");
printk("version: %u\n", fhp->fsh_version);
printk("fsindex: %u\n", fhp->fsh_fsindex);
printk("iauino: %u\tninodes:%u\n",
fhp->fsh_iauino, fhp->fsh_ninodes);
printk("maxinode: %u\tlctino: %u\n",
fhp->fsh_maxinode, fhp->fsh_lctino);
printk("nau: %u\n", fhp->fsh_nau);
printk("ilistino[0]: %u\tilistino[1]: %u\n",
fhp->fsh_ilistino[0], fhp->fsh_ilistino[1]);
}
#endif
/**
* vxfs_getfsh - read fileset header into memory
* @ip: the (fake) fileset header inode
* @which: 0 for the structural, 1 for the primary fsh.
*
* Description:
* vxfs_getfsh reads either the structural or primary fileset header
* described by @ip into memory.
*
* Returns:
* The fileset header structure on success, else Zero.
*/
static struct vxfs_fsh *
vxfs_getfsh(struct inode *ip, int which)
{
struct buffer_head *bp;
bp = vxfs_bread(ip, which);
if (bp) {
struct vxfs_fsh *fhp;
if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL)))
goto out;
memcpy(fhp, bp->b_data, sizeof(*fhp));
put_bh(bp);
return (fhp);
}
out:
brelse(bp);
return NULL;
}
/**
* vxfs_read_fshead - read the fileset headers
* @sbp: superblock to which the fileset belongs
*
* Description:
* vxfs_read_fshead will fill the inode and structural inode list in @sb.
*
* Returns:
* Zero on success, else a negative error code (-EINVAL).
*/
int
vxfs_read_fshead(struct super_block *sbp)
{
struct vxfs_sb_info *infp = VXFS_SBI(sbp);
struct vxfs_fsh *pfp, *sfp;
struct vxfs_inode_info *vip;
infp->vsi_fship = vxfs_blkiget(sbp, infp->vsi_iext, infp->vsi_fshino);
if (!infp->vsi_fship) {
printk(KERN_ERR "vxfs: unable to read fsh inode\n");
return -EINVAL;
}
vip = VXFS_INO(infp->vsi_fship);
if (!VXFS_ISFSH(vip)) {
printk(KERN_ERR "vxfs: fsh list inode is of wrong type (%x)\n",
vip->vii_mode & VXFS_TYPE_MASK);
goto out_iput_fship;
}
#ifdef DIAGNOSTIC
printk("vxfs: fsh inode dump:\n");
vxfs_dumpi(vip, infp->vsi_fshino);
#endif
sfp = vxfs_getfsh(infp->vsi_fship, 0);
if (!sfp) {
printk(KERN_ERR "vxfs: unable to get structural fsh\n");
goto out_iput_fship;
}
#ifdef DIAGNOSTIC
vxfs_dumpfsh(sfp);
#endif
pfp = vxfs_getfsh(infp->vsi_fship, 1);
if (!pfp) {
printk(KERN_ERR "vxfs: unable to get primary fsh\n");
goto out_free_sfp;
}
#ifdef DIAGNOSTIC
vxfs_dumpfsh(pfp);
#endif
infp->vsi_stilist = vxfs_blkiget(sbp, infp->vsi_iext,
fs32_to_cpu(infp, sfp->fsh_ilistino[0]));
if (!infp->vsi_stilist) {
printk(KERN_ERR "vxfs: unable to get structural list inode\n");
goto out_free_pfp;
}
if (!VXFS_ISILT(VXFS_INO(infp->vsi_stilist))) {
printk(KERN_ERR "vxfs: structural list inode is of wrong type (%x)\n",
VXFS_INO(infp->vsi_stilist)->vii_mode & VXFS_TYPE_MASK);
goto out_iput_stilist;
}
infp->vsi_ilist = vxfs_stiget(sbp, fs32_to_cpu(infp, pfp->fsh_ilistino[0]));
if (!infp->vsi_ilist) {
printk(KERN_ERR "vxfs: unable to get inode list inode\n");
goto out_iput_stilist;
}
if (!VXFS_ISILT(VXFS_INO(infp->vsi_ilist))) {
printk(KERN_ERR "vxfs: inode list inode is of wrong type (%x)\n",
VXFS_INO(infp->vsi_ilist)->vii_mode & VXFS_TYPE_MASK);
goto out_iput_ilist;
}
kfree(pfp);
kfree(sfp);
return 0;
out_iput_ilist:
iput(infp->vsi_ilist);
out_iput_stilist:
iput(infp->vsi_stilist);
out_free_pfp:
kfree(pfp);
out_free_sfp:
kfree(sfp);
out_iput_fship:
iput(infp->vsi_fship);
return -EINVAL;
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8" ?>
<ldml>
<identity>
<version number="$Revision: 1.51 $"/>
<generation date="$Date: 2009/05/05 23:06:36 $"/>
<language type="gl"/>
<territory type="ES"/>
</identity>
</ldml>
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.coordinatorlayout.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
public class CustomBar extends View {
public CustomBar(Context context) {
super(context);
}
public CustomBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomBar(Context context, AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Hello World.xcodeproj">
</FileRef>
</Workspace>
| {
"pile_set_name": "Github"
} |
import React from 'react'
import { BrowserRouter, Route } from 'react-router-dom'
import { CssBaseline } from '@material-ui/core'
import AuthProvider from 'contexts/auth'
import App from './app'
function Root () {
return (
<AuthProvider>
<CssBaseline />
<BrowserRouter>
<Route component={App} />
</BrowserRouter>
</AuthProvider>
)
}
export default Root
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. 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.
*
*/
#ifndef CPU_AARCH64_MACROASSEMBLER_AARCH64_INLINE_HPP
#define CPU_AARCH64_MACROASSEMBLER_AARCH64_INLINE_HPP
#include "asm/assembler.hpp"
#ifndef PRODUCT
#endif // ndef PRODUCT
#endif // CPU_AARCH64_MACROASSEMBLER_AARCH64_INLINE_HPP
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2008-2014, David Karnok
* The file is part of the Open Imperium Galactica project.
*
* The code should be distributed under the LGPL license.
* See http://www.gnu.org/licenses/lgpl.html for details.
*/
package hu.openig.tools.ani;
/**
* Callback interface for notifying clients in
* the progress of the transcoding.
* @author karnokd
*/
public interface ProgressCallback {
/**
* Signals the current and the maximum frame count.
* @param value the current frame
* @param max the maximum frame
*/
void progress(int value, int max);
/**
* Should the operation be terminated?
* @return true if the operation should terminate
*/
boolean cancel();
}
| {
"pile_set_name": "Github"
} |
#pragma once
#include <array>
#include <vector>
#include "Runtime/RetroTypes.hpp"
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp>
namespace urde {
class CElementGen;
class CParticleGlobals {
CParticleGlobals() = default;
static std::unique_ptr<CParticleGlobals> g_ParticleGlobals;
public:
int m_EmitterTime = 0;
float m_EmitterTimeReal = 0.f;
void SetEmitterTime(int frame) {
m_EmitterTime = frame;
m_EmitterTimeReal = float(frame);
}
int m_ParticleLifetime = 0;
float m_ParticleLifetimeReal = 0.f;
void SetParticleLifetime(int frame) {
m_ParticleLifetime = frame;
m_ParticleLifetimeReal = float(frame);
}
int m_ParticleLifetimePercentage = 0;
float m_ParticleLifetimePercentageReal = 0.f;
float m_ParticleLifetimePercentageRemainder = 0.f;
void UpdateParticleLifetimeTweenValues(int frame) {
const float lt = m_ParticleLifetime != 0 ? float(m_ParticleLifetime) : 1.0f;
m_ParticleLifetimePercentageReal = 100.0f * float(frame) / lt;
m_ParticleLifetimePercentage = int(m_ParticleLifetimePercentageReal);
m_ParticleLifetimePercentageRemainder = m_ParticleLifetimePercentageReal - float(m_ParticleLifetimePercentage);
m_ParticleLifetimePercentage = zeus::clamp(0, m_ParticleLifetimePercentage, 100);
}
const std::array<float, 8>* m_particleAccessParameters = nullptr;
struct SParticleSystem {
FourCC x0_type;
CElementGen* x4_system;
};
SParticleSystem* m_currentParticleSystem = nullptr;
static CParticleGlobals* instance() {
if (!g_ParticleGlobals)
g_ParticleGlobals.reset(new CParticleGlobals());
return g_ParticleGlobals.get();
}
};
struct SParticleInstanceTex {
std::array<zeus::CVector4f, 4> pos;
zeus::CColor color;
std::array<zeus::CVector2f, 4> uvs;
};
extern std::vector<SParticleInstanceTex> g_instTexData;
struct SParticleInstanceIndTex {
std::array<zeus::CVector4f, 4> pos;
zeus::CColor color;
std::array<zeus::CVector4f, 4> texrTindUVs;
zeus::CVector4f sceneUVs;
};
extern std::vector<SParticleInstanceIndTex> g_instIndTexData;
struct SParticleInstanceNoTex {
std::array<zeus::CVector4f, 4> pos;
zeus::CColor color;
};
extern std::vector<SParticleInstanceNoTex> g_instNoTexData;
struct SParticleUniforms {
zeus::CMatrix4f mvp;
zeus::CColor moduColor;
};
} // namespace urde
| {
"pile_set_name": "Github"
} |
ticket1555
ticket1769
# walking to a bus stop
ticket1780
# consecutive walks should not crash
ticket1781
ticket2060
ticket2220
# collision
ticket2840
ticket2841
# (also affects other pedestrian models)
ticket3260
ticket3347
# pedestrian on looped route should not block itself
ticket3888
# pedestrian with internal edge id in route runs in a loop
ticket4314
# walking speed via internal (road) lanes
ticket4362
# width 0 sidewalk
ticket5257
# dealing with short internal lanes
ticket5661
| {
"pile_set_name": "Github"
} |
// go run mkasm_darwin.go arm64
// Code generated by the command above; DO NOT EDIT.
// +build go1.12
#include "textflag.h"
TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
JMP libc_getgroups(SB)
TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
JMP libc_setgroups(SB)
TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
JMP libc_wait4(SB)
TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
JMP libc_accept(SB)
TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
JMP libc_bind(SB)
TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
JMP libc_connect(SB)
TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
JMP libc_socket(SB)
TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
JMP libc_getsockopt(SB)
TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
JMP libc_setsockopt(SB)
TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
JMP libc_getpeername(SB)
TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
JMP libc_getsockname(SB)
TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
JMP libc_shutdown(SB)
TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
JMP libc_socketpair(SB)
TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
JMP libc_recvfrom(SB)
TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
JMP libc_sendto(SB)
TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
JMP libc_recvmsg(SB)
TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
JMP libc_sendmsg(SB)
TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
JMP libc_kevent(SB)
TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimes(SB)
TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
JMP libc_futimes(SB)
TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
JMP libc_fcntl(SB)
TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
JMP libc_poll(SB)
TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
JMP libc_madvise(SB)
TEXT ·libc_mlock_trampoline(SB),NOSPLIT,$0-0
JMP libc_mlock(SB)
TEXT ·libc_mlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_mlockall(SB)
TEXT ·libc_mprotect_trampoline(SB),NOSPLIT,$0-0
JMP libc_mprotect(SB)
TEXT ·libc_msync_trampoline(SB),NOSPLIT,$0-0
JMP libc_msync(SB)
TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlock(SB)
TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlockall(SB)
TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
JMP libc_getattrlist(SB)
TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
JMP libc_pipe(SB)
TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_getxattr(SB)
TEXT ·libc_fgetxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_fgetxattr(SB)
TEXT ·libc_setxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_setxattr(SB)
TEXT ·libc_fsetxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_fsetxattr(SB)
TEXT ·libc_removexattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_removexattr(SB)
TEXT ·libc_fremovexattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_fremovexattr(SB)
TEXT ·libc_listxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_listxattr(SB)
TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
JMP libc_flistxattr(SB)
TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
JMP libc_setattrlist(SB)
TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
JMP libc_kill(SB)
TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
JMP libc_ioctl(SB)
TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0
JMP libc_sendfile(SB)
TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
JMP libc_access(SB)
TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
JMP libc_adjtime(SB)
TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
JMP libc_chdir(SB)
TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
JMP libc_chflags(SB)
TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
JMP libc_chmod(SB)
TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
JMP libc_chown(SB)
TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
JMP libc_chroot(SB)
TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
JMP libc_clock_gettime(SB)
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
JMP libc_close(SB)
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
JMP libc_dup(SB)
TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
JMP libc_dup2(SB)
TEXT ·libc_exchangedata_trampoline(SB),NOSPLIT,$0-0
JMP libc_exchangedata(SB)
TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
JMP libc_exit(SB)
TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
JMP libc_faccessat(SB)
TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchdir(SB)
TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchflags(SB)
TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchmod(SB)
TEXT ·libc_fchmodat_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchmodat(SB)
TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchown(SB)
TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
JMP libc_fchownat(SB)
TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
JMP libc_flock(SB)
TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
JMP libc_fpathconf(SB)
TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
JMP libc_fsync(SB)
TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_ftruncate(SB)
TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
JMP libc_getdtablesize(SB)
TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getegid(SB)
TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
JMP libc_geteuid(SB)
TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getgid(SB)
TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getpgid(SB)
TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
JMP libc_getpgrp(SB)
TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getpid(SB)
TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getppid(SB)
TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
JMP libc_getpriority(SB)
TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
JMP libc_getrlimit(SB)
TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
JMP libc_getrusage(SB)
TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getsid(SB)
TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
JMP libc_getuid(SB)
TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
JMP libc_issetugid(SB)
TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
JMP libc_kqueue(SB)
TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
JMP libc_lchown(SB)
TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
JMP libc_link(SB)
TEXT ·libc_linkat_trampoline(SB),NOSPLIT,$0-0
JMP libc_linkat(SB)
TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
JMP libc_listen(SB)
TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
JMP libc_mkdir(SB)
TEXT ·libc_mkdirat_trampoline(SB),NOSPLIT,$0-0
JMP libc_mkdirat(SB)
TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
JMP libc_mkfifo(SB)
TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
JMP libc_mknod(SB)
TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
JMP libc_open(SB)
TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
JMP libc_openat(SB)
TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
JMP libc_pathconf(SB)
TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
JMP libc_pread(SB)
TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
JMP libc_pwrite(SB)
TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
JMP libc_read(SB)
TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
JMP libc_readlink(SB)
TEXT ·libc_readlinkat_trampoline(SB),NOSPLIT,$0-0
JMP libc_readlinkat(SB)
TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
JMP libc_rename(SB)
TEXT ·libc_renameat_trampoline(SB),NOSPLIT,$0-0
JMP libc_renameat(SB)
TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
JMP libc_revoke(SB)
TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
JMP libc_rmdir(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
JMP libc_select(SB)
TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setegid(SB)
TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
JMP libc_seteuid(SB)
TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setgid(SB)
TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
JMP libc_setlogin(SB)
TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setpgid(SB)
TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
JMP libc_setpriority(SB)
TEXT ·libc_setprivexec_trampoline(SB),NOSPLIT,$0-0
JMP libc_setprivexec(SB)
TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setregid(SB)
TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setreuid(SB)
TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
JMP libc_setrlimit(SB)
TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setsid(SB)
TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
JMP libc_settimeofday(SB)
TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
JMP libc_setuid(SB)
TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
JMP libc_symlink(SB)
TEXT ·libc_symlinkat_trampoline(SB),NOSPLIT,$0-0
JMP libc_symlinkat(SB)
TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
JMP libc_sync(SB)
TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_truncate(SB)
TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
JMP libc_umask(SB)
TEXT ·libc_undelete_trampoline(SB),NOSPLIT,$0-0
JMP libc_undelete(SB)
TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
JMP libc_unlink(SB)
TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
JMP libc_unlinkat(SB)
TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
JMP libc_unmount(SB)
TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
JMP libc_write(SB)
TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
JMP libc_gettimeofday(SB)
TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_fstat(SB)
TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
JMP libc_fstatat(SB)
TEXT ·libc_fstatfs_trampoline(SB),NOSPLIT,$0-0
JMP libc_fstatfs(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_lstat(SB)
TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
JMP libc_stat(SB)
TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
JMP libc_statfs(SB)
| {
"pile_set_name": "Github"
} |
<?php
final class FileAllocateConduitAPIMethod
extends FileConduitAPIMethod {
public function getAPIMethodName() {
return 'file.allocate';
}
public function getMethodDescription() {
return pht('Prepare to upload a file.');
}
protected function defineParamTypes() {
return array(
'name' => 'string',
'contentLength' => 'int',
'contentHash' => 'optional string',
'viewPolicy' => 'optional string',
'deleteAfterEpoch' => 'optional int',
);
}
protected function defineReturnType() {
return 'map<string, wild>';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$hash = $request->getValue('contentHash');
$name = $request->getValue('name');
$view_policy = $request->getValue('viewPolicy');
$length = $request->getValue('contentLength');
$properties = array(
'name' => $name,
'authorPHID' => $viewer->getPHID(),
'isExplicitUpload' => true,
);
if ($view_policy !== null) {
$properties['viewPolicy'] = $view_policy;
}
$ttl = $request->getValue('deleteAfterEpoch');
if ($ttl) {
$properties['ttl.absolute'] = $ttl;
}
$file = null;
if ($hash !== null) {
$file = PhabricatorFile::newFileFromContentHash(
$hash,
$properties);
}
if ($hash !== null && !$file) {
$chunked_hash = PhabricatorChunkedFileStorageEngine::getChunkedHash(
$viewer,
$hash);
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withContentHashes(array($chunked_hash))
->executeOne();
}
if (strlen($name) && !$hash && !$file) {
if ($length > PhabricatorFileStorageEngine::getChunkThreshold()) {
// If we don't have a hash, but this file is large enough to store in
// chunks and thus may be resumable, try to find a partially uploaded
// file by the same author with the same name and same length. This
// allows us to resume uploads in Javascript where we can't efficiently
// compute file hashes.
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withAuthorPHIDs(array($viewer->getPHID()))
->withNames(array($name))
->withLengthBetween($length, $length)
->withIsPartial(true)
->setLimit(1)
->executeOne();
}
}
if ($file) {
return array(
'upload' => (bool)$file->getIsPartial(),
'filePHID' => $file->getPHID(),
);
}
// If there are any non-chunk engines which this file can fit into,
// just tell the client to upload the file.
$engines = PhabricatorFileStorageEngine::loadStorageEngines($length);
if ($engines) {
return array(
'upload' => true,
'filePHID' => null,
);
}
// Otherwise, this is a large file and we want to perform a chunked
// upload if we have a chunk engine available.
$chunk_engines = PhabricatorFileStorageEngine::loadWritableChunkEngines();
if ($chunk_engines) {
$chunk_properties = $properties;
if ($hash !== null) {
$chunk_properties += array(
'chunkedHash' => $chunked_hash,
);
}
$chunk_engine = head($chunk_engines);
$file = $chunk_engine->allocateChunks($length, $chunk_properties);
return array(
'upload' => true,
'filePHID' => $file->getPHID(),
);
}
// None of the storage engines can accept this file.
if (PhabricatorFileStorageEngine::loadWritableEngines()) {
$error = pht(
'Unable to upload file: this file is too large for any '.
'configured storage engine.');
} else {
$error = pht(
'Unable to upload file: the server is not configured with any '.
'writable storage engines.');
}
return array(
'upload' => false,
'filePHID' => null,
'error' => $error,
);
}
}
| {
"pile_set_name": "Github"
} |
# This file is part of the MapProxy project.
# Copyright (C) 2017 Omniscale <http://omniscale.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
import hashlib
from mapproxy.image import ImageSource
from mapproxy.cache.base import (
TileCacheBase,
tile_buffer,
)
from mapproxy.compat import BytesIO
try:
import redis
except ImportError:
redis = None
import logging
log = logging.getLogger(__name__)
class RedisCache(TileCacheBase):
def __init__(self, host, port, prefix, ttl=0, db=0):
if redis is None:
raise ImportError("Redis backend requires 'redis' package.")
self.prefix = prefix
self.lock_cache_id = 'redis-' + hashlib.md5((host + str(port) + prefix + str(db)).encode('utf-8')).hexdigest()
self.ttl = ttl
self.r = redis.StrictRedis(host=host, port=port, db=db)
def _key(self, tile):
x, y, z = tile.coord
return self.prefix + '-%d-%d-%d' % (z, x, y)
def is_cached(self, tile):
if tile.coord is None or tile.source:
return True
return self.r.exists(self._key(tile))
def store_tile(self, tile):
if tile.stored:
return True
key = self._key(tile)
with tile_buffer(tile) as buf:
data = buf.read()
r = self.r.set(key, data)
if self.ttl:
# use ms expire times for unit-tests
self.r.pexpire(key, int(self.ttl * 1000))
return r
def load_tile(self, tile, with_metadata=False):
if tile.source or tile.coord is None:
return True
key = self._key(tile)
tile_data = self.r.get(key)
if tile_data:
tile.source = ImageSource(BytesIO(tile_data))
return True
return False
def remove_tile(self, tile):
if tile.coord is None:
return True
key = self._key(tile)
self.r.delete(key)
return True
| {
"pile_set_name": "Github"
} |
# SetBreakpointCommand
Sets the command to execute when a software breakpoint is hit. If the command condition is not specified, it will be executed when the debugger breaks, otherwise it will be executed when the condition is satisfied.
## arguments
`arg1` The address of the breakpoint.
`[arg2]` The command (empty when not specified).
## result
This command does not set any result variables.
| {
"pile_set_name": "Github"
} |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Buffers;
using System.Threading.Tasks;
namespace System.IO.Pipelines
{
// TODO (pri 3): Would be nice to add to the platform (but NetStandard does not support the stream APIs)
static class PipelinesExtensions
{
/// <summary>
/// Copies bytes from ReadOnlySequence to a Stream
/// </summary>
public static async Task WriteAsync(this Stream stream, ReadOnlySequence<byte> buffer)
{
for (SequencePosition position = buffer.Start; buffer.TryGet(ref position, out var memory);)
{
await stream.WriteAsync(memory).ConfigureAwait(false);
}
}
/// <summary>
/// Copies bytes from PipeReader to a Stream
/// </summary>
public static async Task WriteAsync(this Stream stream, PipeReader reader, ulong bytes)
{
while (bytes > 0)
{
ReadResult result = await reader.ReadAsync();
ReadOnlySequence<byte> bodyBuffer = result.Buffer;
if (bytes < (ulong)bodyBuffer.Length)
{
throw new NotImplementedException();
}
bytes -= (ulong)bodyBuffer.Length;
await stream.WriteAsync(bodyBuffer).ConfigureAwait(false);
await stream.FlushAsync().ConfigureAwait(false);
reader.AdvanceTo(bodyBuffer.End);
}
}
/// <summary>
/// Copies bytes from Stream to PipeWriter
/// </summary>
public static async Task WriteAsync(this PipeWriter writer, Stream stream, long bytesToWrite)
{
if (!stream.CanRead) throw new ArgumentException("Stream.CanRead returned false", nameof(stream));
while (bytesToWrite > 0)
{
Memory<byte> buffer = writer.GetMemory();
if (buffer.Length > bytesToWrite)
{
buffer = buffer.Slice(0, (int)bytesToWrite);
}
if (buffer.Length == 0) throw new NotSupportedException("PipeWriter.GetMemory returned an empty buffer.");
int read = await stream.ReadAsync(buffer).ConfigureAwait(false);
if (read == 0) return;
writer.Advance(read);
bytesToWrite -= read;
await writer.FlushAsync();
}
}
}
}
| {
"pile_set_name": "Github"
} |
// SPANISH
var lang = {
"AD": "Andorra",
"AE": "Emiratos Árabes Unidos (los)",
"AF": "Afganistán",
"AG": "Antigua y Barbuda",
"AI": "Anguila",
"AL": "Albania",
"AM": "Armenia",
"AO": "Angola",
"AQ": "Antártida",
"AR": "Argentina",
"AS": "Samoa Americana",
"AT": "Austria",
"AU": "Australia",
"AW": "Aruba",
"AX": "Åland, Islas",
"AZ": "Azerbaiyán",
"BA": "Bosnia y Herzegovina",
"BB": "Barbados",
"BD": "Bangladesh",
"BE": "Bélgica",
"BF": "Burkina Faso",
"BG": "Bulgaria",
"BH": "Bahréin",
"BI": "Burundi",
"BJ": "Benín",
"BL": "Saint Barthélemy",
"BM": "Bermudas",
"BN": "Brunéi",
"BO": "Bolivia (Estado Plurinacional de)",
"BQ": "Bonaire, San Eustaquio y Saba",
"BR": "Brasil",
"BS": "Bahamas (las)",
"BT": "Bhután",
"BV": "Bouvet, Isla",
"BW": "Botswana",
"BY": "Belarús",
"BZ": "Belice",
"CA": "Canadá",
"CC": "Cocos / Keeling, (las) Islas",
"CD": "Congo (la República Democrática del)",
"CF": "República Centroafricana (la)",
"CG": "Congo (el)",
"CH": "Suiza",
"CI": "Côte d'Ivoire",
"CK": "Cook, (las) Islas",
"CL": "Chile",
"CM": "Camerún",
"CN": "China",
"CO": "Colombia",
"CR": "Costa Rica",
"CU": "Cuba",
"CV": "Cabo Verde",
"CW": "Curaçao",
"CX": "Navidad, Isla de",
"CY": "Chipre",
"CZ": "República Checa (la)",
"DE": "Alemania",
"DJ": "Djibouti",
"DK": "Dinamarca",
"DM": "Dominica",
"DO": "Dominicana, (la) República",
"DZ": "Argelia",
"EC": "Ecuador",
"EE": "Estonia",
"EG": "Egipto",
"EH": "Sahara Occidental",
"ER": "Eritrea",
"ES": "España",
"ET": "Etiopía",
"FI": "Finlandia",
"FJ": "Fiji",
"FK": "Malvinas [Falkland], (las) Islas",
"FM": "Micronesia (Estados Federados de)",
"FO": "Feroe, (las) Islas",
"FR": "Francia",
"GA": "Gabón",
"GB": "Reino Unido de Gran Bretaña e Irlanda del Norte (el)",
"GD": "Granada",
"GE": "Georgia",
"GF": "Guayana Francesa",
"GG": "Guernsey",
"GH": "Ghana",
"GI": "Gibraltar",
"GL": "Groenlandia",
"GM": "Gambia (la)",
"GN": "Guinea",
"GP": " Guadeloupe",
"GQ": "Guinea Ecuatorial",
"GR": "Grecia",
"GS": "Georgia del Sur (la) y las Islas Sandwich del Sur",
"GT": "Guatemala",
"GU": "Guam",
"GW": "Guinea Bissau",
"GY": "Guyana",
"HK": "Hong Kong",
"HM": "Heard (Isla) e Islas McDonald",
"HN": "Honduras",
"HR": "Croacia",
"HT": "Haití",
"HU": "Hungría",
"ID": "Indonesia",
"IE": "Irlanda",
"IL": "Israel",
"IM": "Isla de Man",
"IN": "India",
"IO": "Territorio Británico del Océano Índico (el)",
"IQ": "Iraq",
"IR": "Irán (República Islámica de)",
"IS": "Islandia",
"IT": "Italia",
"JE": "Jersey",
"JM": "Jamaica",
"JO": "Jordania",
"JP": "Japón",
"KE": "Kenya",
"KG": "Kirguistán",
"KH": "Camboya",
"KI": "Kiribati",
"KM": "Comoras (las)",
"KN": "Saint Kitts y Nevis",
"KP": "Corea (la República Popular Democrática de)",
"KR": "Corea (la República de)",
"KW": "Kuwait",
"KY": "Caimán, (las) Islas",
"KZ": "Kazajstán",
"LA": "Lao, (la) República Democrática Popular",
"LB": "Líbano",
"LC": "Santa Lucía",
"LI": "Liechtenstein",
"LK": "Sri Lanka",
"LR": "Liberia",
"LS": "Lesotho",
"LT": "Lituania",
"LU": "Luxemburgo",
"LV": "Letonia",
"LY": "Libia",
"MA": "Marruecos",
"MC": "Mónaco",
"MD": "Moldova (la República de)",
"ME": "Montenegro",
"MF": "Saint Martin (parte francesa)",
"MG": "Madagascar",
"MH": "Marshall, (las) Islas",
"MK": "Macedonia (la ex República Yugoslava de)",
"ML": "Mali",
"MM": "Birmania",
"MN": "Mongolia",
"MO": "Región Administrativa Especial de Macao de la República Popular China",
"MP": "Marianas del Norte, (las) Islas",
"MQ": "Martinique",
"MR": "Mauritania",
"MS": "Montserrat",
"MT": "Malta",
"MU": "Mauricio",
"MV": "Maldivas",
"MW": "Malawi",
"MX": "México",
"MY": "Malasia",
"MZ": "Mozambique",
"NA": "Namibia",
"NC": "Nueva Caledonia",
"NE": "Níger (el)",
"NF": "Norfolk, Isla",
"NG": "Nigeria",
"NI": "Nicaragua",
"NL": "Países Bajos (los)",
"NO": "Noruega",
"NP": "Nepal",
"NR": "Nauru",
"NU": "Isla Niue",
"NZ": "Nueva Zelandia",
"OM": "Omán",
"PA": "Panamá",
"PE": "Perú",
"PF": "Polinesia Francesa",
"PG": "Papúa Nueva Guinea",
"PH": "Filipinas (las)",
"PK": "Pakistán",
"PL": "Polonia",
"PM": "San Pedro y Miquelón",
"PN": "Pitcairn",
"PR": "Puerto Rico",
"PS": "Palestina, Estado de",
"PT": "Portugal",
"PW": "Palau",
"PY": "Paraguay",
"QA": "Qatar",
"RE": "Reunión",
"RO": "Rumanía",
"RS": "Serbia",
"RU": "Rusia, (la) Federación de",
"RW": "Rwanda",
"SA": "Arabia Saudita",
"SB": "Salomón, Islas",
"SC": "Seychelles",
"SD": "Sudán (el)",
"SE": "Suecia",
"SG": "Singapur",
"SH": "Santa Helena, Ascensión y Tristán de Acuña",
"SI": "Eslovenia",
"SJ": "Svalbard y Jan Mayen",
"SK": "Eslovaquia",
"SL": "Sierra Leona",
"SM": "San Marino",
"SN": "Senegal",
"SO": "Somalia",
"SR": "Suriname",
"SS": "Sudán del Sur",
"ST": "Santo Tomé y Príncipe",
"SV": "El Salvador",
"SX": "Sint Maarten (parte neerlandesa)",
"SY": "República Árabe Siria",
"SZ": "Suazilandia",
"TC": "Turcas y Caicos, (las) Islas",
"TD": "Chad",
"TF": "Tierras Australes Francesas (las)",
"TG": "Togo",
"TH": "Tailandia",
"TJ": "Tayikistán",
"TK": "Tokelau",
"TL": "Timor-Leste",
"TM": "Turkmenistán",
"TN": "Túnez",
"TO": "Tonga",
"TR": "Turquía",
"TT": "Trinidad y Tobago",
"TV": "Tuvalu",
"TW": "Taiwán (Provincia de China)",
"TZ": "Tanzania, República Unida de",
"UA": "Ucrania",
"UG": "Uganda",
"UM": "Islas Ultramarinas Menores de los Estados Unidos (las)",
"US": "Estados Unidos de América (los)",
"UY": "Uruguay",
"UZ": "Uzbekistán",
"VA": "Santa Sede (la)",
"VC": "San Vicente y las Granadinas",
"VE": "Venezuela (República Bolivariana de)",
"VG": "Vírgenes británicas, Islas",
"VI": "Vírgenes de los Estados Unidos, Islas",
"VN": "Viet Nam",
"VU": "Vanuatu",
"WF": "Wallis y Futuna",
"WS": "Samoa",
"YE": "Yemen",
"YT": "Mayotte",
"ZA": "Sudáfrica",
"ZM": "Zambia",
"ZW": "Zimbabwe",
};
export default lang;
| {
"pile_set_name": "Github"
} |
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s -check-prefix=AMDGCN
void use(char *a);
__attribute__((always_inline)) void helper_no_markers() {
char a;
use(&a);
}
void lifetime_test() {
// CHECK: @llvm.lifetime.start.p0i
// AMDGCN: @llvm.lifetime.start.p5i
helper_no_markers();
}
| {
"pile_set_name": "Github"
} |
#source: plt2.s
#as: --32
#ld: -z now -melf_i386
#readelf: -SW
#target: i?86-*-*
#...
+\[ *[0-9]+\] \.plt +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+30 +.* +AX +0 +0 +16
#pass
| {
"pile_set_name": "Github"
} |
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^3.0.0/components/context.jsonld",
{
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
"carrhq": "npmd:@comunica/actor-rdf-resolve-hypermedia-qpf/",
"files-carrhq": "carrhq:^1.0.0/",
"ActorRdfResolveHypermediaQpf": "carrhq:Actor/RdfResolveHypermedia/Qpf",
"subjectUri": "carrhq:Actor/RdfResolveHypermedia/Qpf/subjectUri",
"predicateUri": "carrhq:Actor/RdfResolveHypermedia/Qpf/predicateUri",
"objectUri": "carrhq:Actor/RdfResolveHypermedia/Qpf/objectUri",
"graphUri": "carrhq:Actor/RdfResolveHypermedia/Qpf/graphUri"
}
]
}
| {
"pile_set_name": "Github"
} |
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 4145
Content-Type: text/html; charset=utf-8
Date: Thu, 05 Oct 2017 12:40:18 GMT
Expires: -1
P3p: CP="NON COR ADMa CURa DEVa OUR IND COM UNI NAV INT PRE LOC ONL PHY STA ONL"
Pragma: no-cache
Set-Cookie: .ASPXAUTH=; expires=Tue, 12-Oct-1999 00:00:00 GMT; path=/; secure; HttpOnly antixss=-IYdy9o4PZXLv9crR6S4acg__; path=/; secure sessdata=L3dVTFVtOXZkRWx1WkdWNE9qRUM0V1Y0Z2tWdlhKNlArSit0RHVLcmhIb1JYTWVyaTc1SVQxdlNtSEpndWRpS3R3eURCMk9UY2NMY1F6UW1hRy82dFVLeTZJdWtiWmF2NXJWWUtnV2ZMV0tiSlhxd0p1MzV1MTVoem8rQ3lwWT0_; path=/; secure; HttpOnly
X-Cfy-Tx-Dt: MTAvNS8yMDE3IDEyOjQwOjE4IFBN
X-Cfy-Tx-Id: c1abcd94d39245518889bcfe43bbf9d8
X-Cfy-Tx-Pn: Pod4
X-Cfy-Tx-Tm: 149
X-Frame-Options: SAMEORIGIN
X-Robots-Tag: noindex, nofollow
X-Ua-Compatible: IE=8,9,10
| {
"pile_set_name": "Github"
} |
package org.thoughtcrime.securesms.util;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public final class BottomSheetUtil {
public static final String STANDARD_BOTTOM_SHEET_FRAGMENT_TAG = "BOTTOM";
private BottomSheetUtil() {}
/**
* Show preventing a possible IllegalStateException.
*/
public static void show(@NonNull FragmentManager manager,
@Nullable String tag,
@NonNull BottomSheetDialogFragment dialog)
{
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(dialog, tag);
transaction.commitAllowingStateLoss();
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Box2D: b2Mat33 Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="icon.gif"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">Box2D
 <span id="projectnumber">2.2.1</span>
</div>
<div id="projectbrief">A 2D Physics Engine for Games</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pub-attribs">Public Attributes</a> </div>
<div class="headertitle">
<div class="title">b2Mat33 Struct Reference</div> </div>
</div>
<div class="contents">
<!-- doxytag: class="b2Mat33" -->
<p>A 3-by-3 matrix. Stored in column-major order.
<a href="structb2_mat33.html#details">More...</a></p>
<p><code>#include <<a class="el" href="b2_math_8h_source.html">b2Math.h</a>></code></p>
<p><a href="structb2_mat33-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1f4d7ddf1c8a202fc08ec64dfe191463"></a><!-- doxytag: member="b2Mat33::b2Mat33" ref="a1f4d7ddf1c8a202fc08ec64dfe191463" args="()" -->
 </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a1f4d7ddf1c8a202fc08ec64dfe191463">b2Mat33</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">The default constructor does nothing (for performance). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a36d99a037008776c8d09fe0aeb5c759c"></a><!-- doxytag: member="b2Mat33::b2Mat33" ref="a36d99a037008776c8d09fe0aeb5c759c" args="(const b2Vec3 &c1, const b2Vec3 &c2, const b2Vec3 &c3)" -->
 </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a36d99a037008776c8d09fe0aeb5c759c">b2Mat33</a> (const <a class="el" href="structb2_vec3.html">b2Vec3</a> &c1, const <a class="el" href="structb2_vec3.html">b2Vec3</a> &c2, const <a class="el" href="structb2_vec3.html">b2Vec3</a> &c3)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Construct this matrix using columns. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a42fc6953b025e1c8b59717d0ee7accde"></a><!-- doxytag: member="b2Mat33::SetZero" ref="a42fc6953b025e1c8b59717d0ee7accde" args="()" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a42fc6953b025e1c8b59717d0ee7accde">SetZero</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set this matrix to all zeros. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structb2_vec3.html">b2Vec3</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a478872c7b6a3bedd13fbedd3ec7a2edb">Solve33</a> (const <a class="el" href="structb2_vec3.html">b2Vec3</a> &b) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structb2_vec2.html">b2Vec2</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a2580ac2afadc48028a63ed4c8a1f16bc">Solve22</a> (const <a class="el" href="structb2_vec2.html">b2Vec2</a> &b) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a9eb5090b15d08ab495458adfec50e7cb">GetInverse22</a> (<a class="el" href="structb2_mat33.html">b2Mat33</a> *M) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="structb2_mat33.html#a501f85edde8f080e4e9ecff0ec2ee27e">GetSymInverse33</a> (<a class="el" href="structb2_mat33.html">b2Mat33</a> *M) const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the zero matrix if singular. <a href="#a501f85edde8f080e4e9ecff0ec2ee27e"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a132f00e6550d1e19c75fb60ce1229638"></a><!-- doxytag: member="b2Mat33::ex" ref="a132f00e6550d1e19c75fb60ce1229638" args="" -->
<a class="el" href="structb2_vec3.html">b2Vec3</a> </td><td class="memItemRight" valign="bottom"><b>ex</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ababc69c718c73a04a651f7a6a981ecf4"></a><!-- doxytag: member="b2Mat33::ey" ref="ababc69c718c73a04a651f7a6a981ecf4" args="" -->
<a class="el" href="structb2_vec3.html">b2Vec3</a> </td><td class="memItemRight" valign="bottom"><b>ey</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae700fc46f679b4ef211a2517005b0557"></a><!-- doxytag: member="b2Mat33::ez" ref="ae700fc46f679b4ef211a2517005b0557" args="" -->
<a class="el" href="structb2_vec3.html">b2Vec3</a> </td><td class="memItemRight" valign="bottom"><b>ez</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A 3-by-3 matrix. Stored in column-major order. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a9eb5090b15d08ab495458adfec50e7cb"></a><!-- doxytag: member="b2Mat33::GetInverse22" ref="a9eb5090b15d08ab495458adfec50e7cb" args="(b2Mat33 *M) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void b2Mat33::GetInverse22 </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structb2_mat33.html">b2Mat33</a> * </td>
<td class="paramname"><em>M</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Get the inverse of this matrix as a 2-by-2. Returns the zero matrix if singular. </p>
</div>
</div>
<a class="anchor" id="a501f85edde8f080e4e9ecff0ec2ee27e"></a><!-- doxytag: member="b2Mat33::GetSymInverse33" ref="a501f85edde8f080e4e9ecff0ec2ee27e" args="(b2Mat33 *M) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void b2Mat33::GetSymInverse33 </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structb2_mat33.html">b2Mat33</a> * </td>
<td class="paramname"><em>M</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the zero matrix if singular. </p>
<p>Get the symmetric inverse of this matrix as a 3-by-3. Returns the zero matrix if singular. </p>
</div>
</div>
<a class="anchor" id="a2580ac2afadc48028a63ed4c8a1f16bc"></a><!-- doxytag: member="b2Mat33::Solve22" ref="a2580ac2afadc48028a63ed4c8a1f16bc" args="(const b2Vec2 &b) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structb2_vec2.html">b2Vec2</a> b2Mat33::Solve22 </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structb2_vec2.html">b2Vec2</a> & </td>
<td class="paramname"><em>b</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases. Solve only the upper 2-by-2 matrix equation.</p>
<p>Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases. </p>
</div>
</div>
<a class="anchor" id="a478872c7b6a3bedd13fbedd3ec7a2edb"></a><!-- doxytag: member="b2Mat33::Solve33" ref="a478872c7b6a3bedd13fbedd3ec7a2edb" args="(const b2Vec3 &b) const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="structb2_vec3.html">b2Vec3</a> b2Mat33::Solve33 </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structb2_vec3.html">b2Vec3</a> & </td>
<td class="paramname"><em>b</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases. </p>
</div>
</div>
<hr/>The documentation for this struct was generated from the following files:<ul>
<li><a class="el" href="b2_math_8h_source.html">b2Math.h</a></li>
<li>b2Math.cpp</li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr class="footer"/><address class="footer"><small>
Generated on Sat Sep 17 2011 17:35:56 for Box2D by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>
</body>
</html>
| {
"pile_set_name": "Github"
} |
using System;
using System.Collections.Generic;
using System.Text;
using Windows.Foundation;
using Windows.UI.Xaml.Media;
namespace Windows.UI.Xaml.Controls.Primitives
{
public sealed partial class SplitViewTemplateSettings : DependencyObject
{
public SplitViewTemplateSettings(SplitView splitView)
{
InitializeBinder();
if (splitView != null)
{
CompactPaneLength = splitView.CompactPaneLength;
OpenPaneLength = splitView.OpenPaneLength;
}
else
{
CompactPaneLength = (double)SplitView.CompactPaneLengthProperty.GetMetadata(typeof(SplitView)).DefaultValue;
OpenPaneLength = (double)SplitView.OpenPaneLengthProperty.GetMetadata(typeof(SplitView)).DefaultValue;
}
}
public GridLength CompactPaneGridLength { get { return new GridLength((float)CompactPaneLength, GridUnitType.Pixel); } }
public GridLength OpenPaneGridLength { get { return new GridLength((float)OpenPaneLength, GridUnitType.Pixel); } }
public double NegativeOpenPaneLength { get { return -OpenPaneLength; } }
public double NegativeOpenPaneLengthMinusCompactLength { get { return NegativeOpenPaneLength - CompactPaneLength; } }
public double OpenPaneLengthMinusCompactLength { get { return OpenPaneLength - CompactPaneLength; } }
public double OpenPaneLength { get; }
public double CompactPaneLength { get; }
/// <summary>
/// These properties were added to facilitate clipping while RectangleGeometry.Transform is not supported
/// TODO: Remove and use NegativeOpenPaneLengthMinusCompactLength and OpenPaneLengthMinusCompactLength instead
/// </summary>
public RectangleGeometry LeftClip { get { return new RectangleGeometry { Rect = new Rect(0, 0, CompactPaneLength, ViewHeight) }; } }
public RectangleGeometry RightClip { get { return new RectangleGeometry { Rect = new Rect(OpenPaneLengthMinusCompactLength, 0, CompactPaneLength, ViewHeight) }; } }
public double ViewHeight { get; internal set; } = 2000;
}
} | {
"pile_set_name": "Github"
} |
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2016-2017 Hisilicon Limited. */
#ifndef __HCLGE_MBX_H
#define __HCLGE_MBX_H
#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/types.h>
#define HCLGE_MBX_VF_MSG_DATA_NUM 16
enum HCLGE_MBX_OPCODE {
HCLGE_MBX_RESET = 0x01, /* (VF -> PF) assert reset */
HCLGE_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset*/
HCLGE_MBX_SET_UNICAST, /* (VF -> PF) set UC addr */
HCLGE_MBX_SET_MULTICAST, /* (VF -> PF) set MC addr */
HCLGE_MBX_SET_VLAN, /* (VF -> PF) set VLAN */
HCLGE_MBX_MAP_RING_TO_VECTOR, /* (VF -> PF) map ring-to-vector */
HCLGE_MBX_UNMAP_RING_TO_VECTOR, /* (VF -> PF) unamp ring-to-vector */
HCLGE_MBX_SET_PROMISC_MODE, /* (VF -> PF) set promiscuous mode */
HCLGE_MBX_SET_MACVLAN, /* (VF -> PF) set unicast filter */
HCLGE_MBX_API_NEGOTIATE, /* (VF -> PF) negotiate API version */
HCLGE_MBX_GET_QINFO, /* (VF -> PF) get queue config */
HCLGE_MBX_GET_TCINFO, /* (VF -> PF) get TC config */
HCLGE_MBX_GET_RETA, /* (VF -> PF) get RETA */
HCLGE_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */
HCLGE_MBX_GET_MAC_ADDR, /* (VF -> PF) get MAC addr */
HCLGE_MBX_PF_VF_RESP, /* (PF -> VF) generate respone to VF */
HCLGE_MBX_GET_BDNUM, /* (VF -> PF) get BD num */
HCLGE_MBX_GET_BUFSIZE, /* (VF -> PF) get buffer size */
HCLGE_MBX_GET_STREAMID, /* (VF -> PF) get stream id */
HCLGE_MBX_SET_AESTART, /* (VF -> PF) start ae */
HCLGE_MBX_SET_TSOSTATS, /* (VF -> PF) get tso stats */
HCLGE_MBX_LINK_STAT_CHANGE, /* (PF -> VF) link status has changed */
HCLGE_MBX_GET_BASE_CONFIG, /* (VF -> PF) get config */
HCLGE_MBX_BIND_FUNC_QUEUE, /* (VF -> PF) bind function and queue */
HCLGE_MBX_GET_LINK_STATUS, /* (VF -> PF) get link status */
HCLGE_MBX_QUEUE_RESET, /* (VF -> PF) reset queue */
};
/* below are per-VF mac-vlan subcodes */
enum hclge_mbx_mac_vlan_subcode {
HCLGE_MBX_MAC_VLAN_UC_MODIFY = 0, /* modify UC mac addr */
HCLGE_MBX_MAC_VLAN_UC_ADD, /* add a new UC mac addr */
HCLGE_MBX_MAC_VLAN_UC_REMOVE, /* remove a new UC mac addr */
HCLGE_MBX_MAC_VLAN_MC_MODIFY, /* modify MC mac addr */
HCLGE_MBX_MAC_VLAN_MC_ADD, /* add new MC mac addr */
HCLGE_MBX_MAC_VLAN_MC_REMOVE, /* remove MC mac addr */
HCLGE_MBX_MAC_VLAN_MC_FUNC_MTA_ENABLE, /* config func MTA enable */
HCLGE_MBX_MAC_VLAN_MTA_TYPE_READ, /* read func MTA type */
HCLGE_MBX_MAC_VLAN_MTA_STATUS_UPDATE, /* update MTA status */
};
/* below are per-VF vlan cfg subcodes */
enum hclge_mbx_vlan_cfg_subcode {
HCLGE_MBX_VLAN_FILTER = 0, /* set vlan filter */
HCLGE_MBX_VLAN_TX_OFF_CFG, /* set tx side vlan offload */
HCLGE_MBX_VLAN_RX_OFF_CFG, /* set rx side vlan offload */
};
#define HCLGE_MBX_MAX_MSG_SIZE 16
#define HCLGE_MBX_MAX_RESP_DATA_SIZE 8
#define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM 3
#define HCLGE_MBX_RING_NODE_VARIABLE_NUM 3
struct hclgevf_mbx_resp_status {
struct mutex mbx_mutex; /* protects against contending sync cmd resp */
u32 origin_mbx_msg;
bool received_resp;
int resp_status;
u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
};
struct hclge_mbx_vf_to_pf_cmd {
u8 rsv;
u8 mbx_src_vfid; /* Auto filled by IMP */
u8 rsv1[2];
u8 msg_len;
u8 rsv2[3];
u8 msg[HCLGE_MBX_MAX_MSG_SIZE];
};
struct hclge_mbx_pf_to_vf_cmd {
u8 dest_vfid;
u8 rsv[3];
u8 msg_len;
u8 rsv1[3];
u16 msg[8];
};
/* used by VF to store the received Async responses from PF */
struct hclgevf_mbx_arq_ring {
#define HCLGE_MBX_MAX_ARQ_MSG_SIZE 8
#define HCLGE_MBX_MAX_ARQ_MSG_NUM 1024
struct hclgevf_dev *hdev;
u32 head;
u32 tail;
u32 count;
u16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE];
};
#define hclge_mbx_ring_ptr_move_crq(crq) \
(crq->next_to_use = (crq->next_to_use + 1) % crq->desc_num)
#define hclge_mbx_tail_ptr_move_arq(arq) \
(arq.tail = (arq.tail + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
#define hclge_mbx_head_ptr_move_arq(arq) \
(arq.head = (arq.head + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
#endif
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env sh
exec "$(dirname "$0")/../../gradlew" "$@"
| {
"pile_set_name": "Github"
} |
I18NEditModelView = require './I18NEditModelView'
Poll = require 'models/Poll'
module.exports = class I18NEditPollView extends I18NEditModelView
id: "i18n-edit-poll-view"
modelClass: Poll
buildTranslationList: ->
lang = @selectedLanguage
# name, description
if i18n = @model.get('i18n')
if name = @model.get('name')
@wrapRow "Poll name", ['name'], name, i18n[lang]?.name, []
if description = @model.get('description')
@wrapRow "Poll description", ['description'], description, i18n[lang]?.description, []
# answers
for answer, index in @model.get('answers') ? []
if i18n = answer.i18n
@wrapRow 'Answer', ['text'], answer.text, i18n[lang]?.text, ['answers', index]
| {
"pile_set_name": "Github"
} |
//===-- Internals.h - Implementation Details---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
#define LLVM_CLANG_LIB_ARCMIGRATE_INTERNALS_H
#include "clang/ARCMigrate/ARCMT.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include <list>
namespace clang {
class Sema;
class Stmt;
namespace arcmt {
class CapturedDiagList {
typedef std::list<StoredDiagnostic> ListTy;
ListTy List;
public:
void push_back(const StoredDiagnostic &diag) { List.push_back(diag); }
bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
bool hasDiagnostic(ArrayRef<unsigned> IDs, SourceRange range) const;
void reportDiagnostics(DiagnosticsEngine &diags) const;
bool hasErrors() const;
typedef ListTy::const_iterator iterator;
iterator begin() const { return List.begin(); }
iterator end() const { return List.end(); }
};
void writeARCDiagsToPlist(const std::string &outPath,
ArrayRef<StoredDiagnostic> diags,
SourceManager &SM, const LangOptions &LangOpts);
class TransformActions {
DiagnosticsEngine &Diags;
CapturedDiagList &CapturedDiags;
void *Impl; // TransformActionsImpl.
public:
TransformActions(DiagnosticsEngine &diag, CapturedDiagList &capturedDiags,
ASTContext &ctx, Preprocessor &PP);
~TransformActions();
void startTransaction();
bool commitTransaction();
void abortTransaction();
void insert(SourceLocation loc, StringRef text);
void insertAfterToken(SourceLocation loc, StringRef text);
void remove(SourceRange range);
void removeStmt(Stmt *S);
void replace(SourceRange range, StringRef text);
void replace(SourceRange range, SourceRange replacementRange);
void replaceStmt(Stmt *S, StringRef text);
void replaceText(SourceLocation loc, StringRef text,
StringRef replacementText);
void increaseIndentation(SourceRange range,
SourceLocation parentIndent);
bool clearDiagnostic(ArrayRef<unsigned> IDs, SourceRange range);
bool clearAllDiagnostics(SourceRange range) {
return clearDiagnostic(None, range);
}
bool clearDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) {
unsigned IDs[] = { ID1, ID2 };
return clearDiagnostic(IDs, range);
}
bool clearDiagnostic(unsigned ID1, unsigned ID2, unsigned ID3,
SourceRange range) {
unsigned IDs[] = { ID1, ID2, ID3 };
return clearDiagnostic(IDs, range);
}
bool hasDiagnostic(unsigned ID, SourceRange range) {
return CapturedDiags.hasDiagnostic(ID, range);
}
bool hasDiagnostic(unsigned ID1, unsigned ID2, SourceRange range) {
unsigned IDs[] = { ID1, ID2 };
return CapturedDiags.hasDiagnostic(IDs, range);
}
DiagnosticBuilder report(SourceLocation loc, unsigned diagId,
SourceRange range = SourceRange());
void reportError(StringRef error, SourceLocation loc,
SourceRange range = SourceRange());
void reportWarning(StringRef warning, SourceLocation loc,
SourceRange range = SourceRange());
void reportNote(StringRef note, SourceLocation loc,
SourceRange range = SourceRange());
bool hasReportedErrors() const {
return Diags.hasUnrecoverableErrorOccurred();
}
class RewriteReceiver {
public:
virtual ~RewriteReceiver();
virtual void insert(SourceLocation loc, StringRef text) = 0;
virtual void remove(CharSourceRange range) = 0;
virtual void increaseIndentation(CharSourceRange range,
SourceLocation parentIndent) = 0;
};
void applyRewrites(RewriteReceiver &receiver);
};
class Transaction {
TransformActions &TA;
bool Aborted;
public:
Transaction(TransformActions &TA) : TA(TA), Aborted(false) {
TA.startTransaction();
}
~Transaction() {
if (!isAborted())
TA.commitTransaction();
}
void abort() {
TA.abortTransaction();
Aborted = true;
}
bool isAborted() const { return Aborted; }
};
class MigrationPass {
public:
ASTContext &Ctx;
LangOptions::GCMode OrigGCMode;
MigratorOptions MigOptions;
Sema &SemaRef;
TransformActions &TA;
const CapturedDiagList &CapturedDiags;
std::vector<SourceLocation> &ARCMTMacroLocs;
Optional<bool> EnableCFBridgeFns;
MigrationPass(ASTContext &Ctx, LangOptions::GCMode OrigGCMode,
Sema &sema, TransformActions &TA,
const CapturedDiagList &capturedDiags,
std::vector<SourceLocation> &ARCMTMacroLocs)
: Ctx(Ctx), OrigGCMode(OrigGCMode), MigOptions(),
SemaRef(sema), TA(TA), CapturedDiags(capturedDiags),
ARCMTMacroLocs(ARCMTMacroLocs) { }
const CapturedDiagList &getDiags() const { return CapturedDiags; }
bool isGCMigration() const { return OrigGCMode != LangOptions::NonGC; }
bool noFinalizeRemoval() const { return MigOptions.NoFinalizeRemoval; }
void setNoFinalizeRemoval(bool val) {MigOptions.NoFinalizeRemoval = val; }
bool CFBridgingFunctionsDefined();
};
static inline StringRef getARCMTMacroName() {
return "__IMPL_ARCMT_REMOVED_EXPR__";
}
} // end namespace arcmt
} // end namespace clang
#endif
| {
"pile_set_name": "Github"
} |
/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
* Copyright 2020 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <osgEarth/PolygonizeLines>
#include <osgEarth/FeatureSourceIndexNode>
#include <osgEarth/FilterContext>
#include <osgEarth/MeshConsolidator>
#include <osgEarth/VirtualProgram>
#include <osgEarth/Utils>
#include <osgEarth/CullingUtils>
#define LC "[PolygonizeLines] "
using namespace osgEarth;
#define OV(p) "("<<p.x()<<","<<p.y()<<")"
#define ATTR_LOCATION osg::Drawable::ATTRIBUTE_7
namespace
{
typedef std::pair<osg::Vec3,osg::Vec3> Segment;
// Given two rays (point + direction vector), find the intersection
// of those rays in 2D space and put the result in [out]. Return true
// if they intersect, false if they do not.
bool interesctRays(const osg::Vec3& p0, const osg::Vec3& pd, // point, dir
const osg::Vec3& q0, const osg::Vec3& qd, // point, dir
const osg::Vec3& normal, // normal at control point
osg::Vec3& out)
{
// make the conversion quats:
osg::Quat toLocal, toWorld;
toLocal.makeRotate( normal, osg::Vec3(0,0,1) );
toWorld.makeRotate( osg::Vec3(0,0,1), normal );
// convert the inputs:
osg::Vec3 p0r = p0; //toLocal*p0; //(p0-cp);
osg::Vec3 pdr = toLocal*pd;
osg::Vec3 q0r = q0; //toLocal*q0; //(q0-cp);
osg::Vec3 qdr = toLocal*qd;
// this epsilon will cause us to skip invalid or colinear rays.
const float epsilon = 0.001f;
float det = pdr.y()*qdr.x()-pdr.x()*qdr.y();
if ( osg::equivalent(det, 0.0f, epsilon) )
return false;
float u = (qdr.x()*(q0r.y()-p0r.y())+qdr.y()*(p0r.x()-q0r.x()))/det;
if ( u < epsilon )
return false;
float v = (pdr.x()*(q0r.y()-p0r.y())+pdr.y()*(p0r.x()-q0r.x()))/det;
if ( v < epsilon )
return false;
out = /*cp +*/ (toWorld * (p0r + pdr*u));
return true;
}
// Rotate the directional vector [in] counter-clockwise by [angle] radians
// and return the result in [out].
inline void rotate(const osg::Vec3& in, float angle, const osg::Vec3& normal, osg::Vec3& out)
{
osg::Quat rot( angle, normal );
out = rot * in;
}
// Add two triangles to an EBO vector; [side] controls the winding
// direction.
inline void addTris(std::vector<unsigned>& ebo, unsigned i, unsigned prev_i, unsigned current, float side)
{
if ( side < 0.0f )
{
ebo.push_back( i-1 );
ebo.push_back( i );
ebo.push_back( prev_i );
ebo.push_back( prev_i );
ebo.push_back( i );
ebo.push_back( current );
}
else
{
ebo.push_back( i-1 );
ebo.push_back( prev_i );
ebo.push_back( i );
ebo.push_back( prev_i );
ebo.push_back( current );
ebo.push_back( i );
}
}
// Add a triangle to an EBO vector; [side] control the winding
// direction.
inline void addTri(std::vector<unsigned>& ebo, unsigned i0, unsigned i1, unsigned i2, float side)
{
ebo.push_back( i0 );
ebo.push_back( side < 0.0f ? i1 : i2 );
ebo.push_back( side < 0.0f ? i2 : i1 );
}
}
PolygonizeLinesOperator::PolygonizeLinesOperator(const Stroke& stroke) :
_stroke( stroke )
{
//nop
}
osg::Geometry*
PolygonizeLinesOperator::operator()(osg::Vec3Array* verts,
osg::Vec3Array* normals,
Callback* callback,
bool twosided) const
{
// number of verts on the original line.
unsigned lineSize = verts->size();
// cannot generate a line with less than 2 verts.
if ( lineSize < 2 )
return 0L;
float width = Distance(*_stroke.width(), *_stroke.widthUnits()).as(Units::METERS);
float halfWidth = 0.5f * width;
float maxRoundingAngle = asin( _stroke.roundingRatio().get() );
float minPixelSize = _stroke.minPixels().getOrUse( 0.0f );
bool autoScale = minPixelSize > 0.0f;
osg::Geometry* geom = new osg::Geometry();
geom->setUseVertexBufferObjects(true);
// Add the input verts to the geometry. This forms the "spine" of the
// polygonized line. We need the spine so we can affect proper clamping,
// texturing and vertex attribution.
geom->setVertexArray( verts );
// Set up the normals array
if ( !normals )
{
normals = new osg::Vec3Array(osg::Array::BIND_PER_VERTEX, verts->size());
normals->assign( normals->size(), osg::Vec3(0,0,1) );
}
geom->setNormalArray( normals );
// run the callback on the initial spine.
if (callback)
{
for (unsigned i = 0; i<verts->size(); ++i)
(*callback)(i);
}
// Set up the buffering vector attribute array.
osg::Vec3Array* spine = 0L;
if ( autoScale )
{
spine = new osg::Vec3Array( *verts );
geom->setVertexAttribArray ( ATTR_LOCATION, spine );
}
// initialize the texture coordinates.
float spineLen = 0.0f;
osg::Vec2Array* tverts = new osg::Vec2Array( lineSize );
geom->setTexCoordArray( 0, tverts );
(*tverts)[0].set( 0.5f, 0.0f );
for( unsigned i=1; i<lineSize; ++i )
{
Segment seg ( (*verts)[i-1], (*verts)[i] ); // current segment.
osg::Vec3 dir = seg.second - seg.first;
spineLen += dir.length();
(*tverts)[i].set( 0.5f, spineLen * 1.0f/width );
}
// triangulate the points into a mesh.
std::vector<unsigned> ebo;
// buffer the left side:
unsigned i;
osg::Vec3 prevBufVert;
osg::Vec3 prevBufVec;
unsigned prevBufVertPtr;
unsigned eboPtr = 0;
osg::Vec3 prevDir;
osg::Vec3 up(0,0,1);
// iterate over both "sides" of the center line:
int firstside = 0;
int lastside = twosided ? 1 : 0;
const float RIGHT_SIDE = 1.0f;
const float LEFT_SIDE = -1.0f;
for( int ss=firstside; ss<=lastside; ++ss )
{
float side = ss == 0 ? RIGHT_SIDE : LEFT_SIDE;
float tx = side == RIGHT_SIDE? 1.0f : 0.0f;
// iterate over each line segment.
for( i=0; i<lineSize-1; ++i )
{
// establish the normal for this point, which will help us calculate a
// 3D buffering vector.
const osg::Vec3& normal = (*normals)[i];
// calculate the directional vector of this segment.
Segment seg ( (*verts)[i], (*verts)[i+1] );
osg::Vec3 dir = seg.second - seg.first;
dir.normalize();
// the buffering vector is orthogonal to the direction vector and the normal;
// flip it depending on the current side.
osg::Vec3 bufVecUnit = (dir ^ up) * side;
bufVecUnit.normalize();
// scale the buffering vector to half the stroke width.
osg::Vec3 bufVec = bufVecUnit * halfWidth;
// calculate the starting buffered vertex
osg::Vec3 bufVert = (*verts)[i] + bufVec;
if ( i == 0 )
{
// first vert-- no corner to check, just make the buffered vert.
verts->push_back( bufVert );
prevBufVert = bufVert;
prevBufVertPtr = verts->size() - 1;
// first tex coord:
// TODO: revisit. I believe we have them going x = [-1..1] instead of [0..1] -gw
//tverts->push_back( osg::Vec2f(1.0*side, (*tverts)[i].y()) );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
// first normal
normals->push_back( (*normals)[i] );
// buffering vector.
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
// render the front end-cap.
if ( _stroke.lineCap() == Stroke::LINECAP_ROUND )
{
float angle = osg::PI_2;
int steps = (int)ceil(angle/maxRoundingAngle);
float step = angle/(float)steps;
osg::Vec3 circlevec = verts->back() - (*verts)[i];
for( int j=1; j<=steps; ++j )
{
osg::Vec3 v;
float a = step * (float)j;
//rotate( circlevec, -(side)*a, (*normals)[i], v );
rotate( circlevec, -(side)*a, up, v );
verts->push_back( (*verts)[i] + v );
addTri( ebo, i, verts->size()-2, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
}
}
else if ( _stroke.lineCap() == Stroke::LINECAP_SQUARE )
{
float cornerWidth = sqrt(2.0*halfWidth*halfWidth);
verts->push_back( verts->back() - dir*halfWidth );
addTri( ebo, i, verts->size()-2, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( normals->back() );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
verts->push_back( (*verts)[i] - dir*halfWidth );
addTri( ebo, i, verts->size()-2, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (verts->back() - (*verts)[i]) * sqrt(2.0f) );
if (callback) (*callback)(i);
}
}
else
{
// does the new segment turn create a reflex angle (>180deg)?
osg::Vec3f cp = prevDir ^ dir;
float z = cp.z();
bool isOutside = side == LEFT_SIDE ? z <= 0.0 : z >= 0.0;
bool isInside = !isOutside;
// if this is an inside angle (or we're using mitered corners)
// calculate the corner point by finding the convergance of the two
// vectors enimating from the previous and next buffered points.
if ( isInside || _stroke.lineJoin() == Stroke::LINEJOIN_MITRE )
{
bool addedVertex = false;
{
osg::Vec3 nextBufVert = seg.second + bufVec;
OE_DEBUG
<< "\n"
<< "point " << i << " : \n"
<< "seg f: " << seg.first.x() << ", " << seg.first.y() << "\n"
<< "seg s: " << seg.second.x() << ", " << seg.second.y() << "\n"
<< "pnt 1: " << prevBufVert.x() << ", " << prevBufVert.y() << "\n"
<< "ray 1: " << prevDir.x() << ", " << prevDir.y() << "\n"
<< "pnt 2: " << nextBufVert.x() << ", " << nextBufVert.y() << "\n"
<< "ray 2: " << -dir.x() << ", " << -dir.y() << "\n"
<< "bufvec: " << bufVec.x() << ", " << bufVec.y() << "\n"
<< "\n";
// find the 2D intersection of these two vectors. Check for the
// special case of colinearity.
osg::Vec3 isect;
if ( interesctRays(prevBufVert, prevDir, nextBufVert, -dir, up, isect) )//(*normals)[i], isect) )
{
verts->push_back(isect);
addedVertex = true;
}
}
if ( !addedVertex )
{
verts->push_back(bufVert);
}
// now that we have the current buffered point, build triangles
// for *previous* segment.
//if ( addedVertex )
addTris( ebo, i, prevBufVertPtr, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
}
else if ( _stroke.lineJoin() == Stroke::LINEJOIN_ROUND )
{
// for a rounded corner, first create the first rim point:
osg::Vec3 start = (*verts)[i] + prevBufVec;
verts->push_back( start );
addTris( ebo, i, prevBufVertPtr, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
// insert the edge-rounding points:
float angle = acosf( (prevBufVec * bufVec)/(halfWidth*halfWidth) );
int steps = (int)ceil(angle/maxRoundingAngle);
float step = angle/(float)steps;
osg::Vec3 circlevec = start - (*verts)[i];
for( int j=1; j<=steps; ++j )
{
osg::Vec3 v;
float a = step * (float)j;
rotate( circlevec, side*a, up, v );
//rotate( circlevec, side*a, (*normals)[i], v );
verts->push_back( (*verts)[i] + v );
addTri( ebo, i, verts->size()-1, verts->size()-2, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
}
}
// record these for the next segment.
prevBufVert = verts->back();
prevBufVertPtr = verts->size() - 1;
}
// record these for the next segment.
prevDir = dir;
prevBufVec = bufVec;
}
// record the final point data.
verts->push_back( (*verts)[i] + prevBufVec );
addTris( ebo, i, prevBufVertPtr, verts->size()-1, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
if ( _stroke.lineCap() == Stroke::LINECAP_ROUND )
{
float angle = osg::PI_2;
int steps = (int)ceil(angle/maxRoundingAngle);
float step = angle/(float)steps;
osg::Vec3 circlevec = verts->back() - (*verts)[i];
// tessellate half of a rounded end camp:
for( int j=1; j<=steps; ++j )
{
osg::Vec3 v;
float a = step * (float)j;
//rotate( circlevec, (side)*a, (*normals)[i], v );
rotate( circlevec, (side)*a, up, v );
verts->push_back( (*verts)[i] + v );
addTri( ebo, i, verts->size()-1, verts->size()-2, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
}
}
else if ( _stroke.lineCap() == Stroke::LINECAP_SQUARE )
{
float cornerWidth = sqrt(2.0*halfWidth*halfWidth);
verts->push_back( verts->back() + prevDir*halfWidth );
addTri( ebo, i, verts->size()-1, verts->size()-2, side );
tverts->push_back( osg::Vec2f(tx, (*tverts)[i].y()) );
normals->push_back( normals->back() );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
verts->push_back( (*verts)[i] + prevDir*halfWidth );
addTri( ebo, i, verts->size()-1, verts->size()-2, side );
tverts->push_back( osg::Vec2f(1.0*side, (*tverts)[i].y()) );
normals->push_back( (*normals)[i] );
if ( spine ) spine->push_back( (*verts)[i] );
if (callback) (*callback)(i);
}
}
// copy the ebo into a primitive set of appropriate size:
osg::DrawElements* primset =
verts->size() > 0xFFFF ? (osg::DrawElements*)new osg::DrawElementsUInt ( GL_TRIANGLES ) :
verts->size() > 0xFF ? (osg::DrawElements*)new osg::DrawElementsUShort( GL_TRIANGLES ) :
(osg::DrawElements*)new osg::DrawElementsUByte ( GL_TRIANGLES );
primset->reserveElements( ebo.size() );
for(i=0; i<ebo.size(); ++i )
primset->addElement( ebo[i] );
geom->addPrimitiveSet( primset );
// generate colors
{
osg::Vec4Array* colors = new osg::Vec4Array( osg::Array::BIND_PER_VERTEX, verts->size() );
colors->assign( colors->size(), _stroke.color() );
geom->setColorArray( colors );
}
return geom;
}
#define SHADER_NAME "osgEarth::PolygonizeLinesAutoScale"
namespace
{
struct PixelSizeVectorCullCallback : public osg::NodeCallback
{
PixelSizeVectorCullCallback(osg::StateSet* stateset)
{
_frameNumber = 0;
_pixelSizeVectorUniform = new osg::Uniform(osg::Uniform::FLOAT_VEC4, "oe_PixelSizeVector");
stateset->addUniform( _pixelSizeVectorUniform.get() );
}
void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osgUtil::CullVisitor* cv = Culling::asCullVisitor(nv);
// temporary patch to prevent uniform overwrite -gw
if ( nv->getFrameStamp() && (int)nv->getFrameStamp()->getFrameNumber() > _frameNumber )
{
_pixelSizeVectorUniform->set( cv->getCurrentCullingSet().getPixelSizeVector() );
_frameNumber = nv->getFrameStamp()->getFrameNumber();
}
traverse(node, nv);
}
osg::ref_ptr<osg::Uniform> _pixelSizeVectorUniform;
int _frameNumber;
};
class PixelScalingGeode : public osg::Geode
{
public:
void traverse(osg::NodeVisitor& nv)
{
osgUtil::CullVisitor* cv = 0L;
if (nv.getVisitorType() == nv.CULL_VISITOR &&
(cv = Culling::asCullVisitor(nv)) != 0L &&
cv->getCurrentCamera() )
{
osg::ref_ptr<osg::StateSet>& ss = _stateSets.get( cv->getCurrentCamera() );
if ( !ss.valid() )
ss = new osg::StateSet();
ss->getOrCreateUniform("oe_PixelSizeVector", osg::Uniform::FLOAT_VEC4)->set(
cv->getCurrentCullingSet().getPixelSizeVector() );
}
osg::Geode::traverse( nv );
}
PerObjectFastMap<osg::Camera*, osg::ref_ptr<osg::StateSet> > _stateSets;
};
}
void
PolygonizeLinesOperator::installShaders(osg::Node* node) const
{
if ( !node )
return;
float minPixels = _stroke.minPixels().getOrUse( 0.0f );
if ( minPixels <= 0.0f )
return;
osg::StateSet* stateset = node->getOrCreateStateSet();
VirtualProgram* vp = VirtualProgram::getOrCreate(stateset);
// bail if already installed.
if ( vp->getName().compare( SHADER_NAME ) == 0 )
return;
vp->setName( SHADER_NAME );
const char* vs =
"#version " GLSL_VERSION_STR "\n"
GLSL_DEFAULT_PRECISION_FLOAT "\n"
"in vec3 oe_polyline_center; \n"
"uniform float oe_polyline_scale; \n"
"uniform float oe_polyline_min_pixels; \n"
"uniform vec4 oe_PixelSizeVector; \n"
"void oe_polyline_scalelines(inout vec4 vertex_model4) \n"
"{ \n"
" const float epsilon = 0.0001; \n"
" vec4 center = vec4(oe_polyline_center, 1.0); \n"
" vec3 vector = vertex_model4.xyz - center.xyz; \n"
" float r = length(vector); \n"
" float activate = step(epsilon, r*oe_polyline_min_pixels);\n"
" float pixelSize = max(epsilon, 2.0*abs(r/dot(center, oe_PixelSizeVector))); \n"
" float min_scale = max(oe_polyline_min_pixels/pixelSize, 1.0); \n"
" float scale = mix(1.0, max(oe_polyline_scale, min_scale), activate); \n"
" vertex_model4.xyz = center.xyz + vector*scale; \n"
"} \n";
vp->setFunction( "oe_polyline_scalelines", vs, ShaderComp::LOCATION_VERTEX_MODEL, 0.5f );
vp->addBindAttribLocation( "oe_polyline_center", ATTR_LOCATION );
// add the default scaling uniform.
// good way to test:
// osgearth_viewer earthfile --uniform oe_polyline_scale 1.0 10.0
osg::Uniform* scaleU = new osg::Uniform(osg::Uniform::FLOAT, "oe_polyline_scale");
scaleU->set( 1.0f );
stateset->addUniform( scaleU, 1 );
// the default "min pixels" uniform.
osg::Uniform* minPixelsU = new osg::Uniform(osg::Uniform::FLOAT, "oe_polyline_min_pixels");
minPixelsU->set( minPixels );
stateset->addUniform( minPixelsU, 1 );
// this will install and update the oe_PixelSizeVector uniform.
node->addCullCallback( new PixelSizeVectorCullCallback(stateset) );
}
//------------------------------------------------------------------------
PolygonizeLinesFilter::PolygonizeLinesFilter(const Style& style) :
_style( style )
{
//nop
}
osg::Node*
PolygonizeLinesFilter::push(FeatureList& input, FilterContext& cx)
{
// compute the coordinate localization matrices.
computeLocalizers( cx );
// establish some things
bool makeECEF = false;
const SpatialReference* featureSRS = 0L;
const SpatialReference* mapSRS = 0L;
if ( cx.isGeoreferenced() )
{
makeECEF = cx.getSession()->isMapGeocentric();
featureSRS = cx.extent()->getSRS();
mapSRS = cx.getSession()->getMapSRS();
}
// The operator we'll use to make lines into polygons.
const LineSymbol* line = _style.get<LineSymbol>();
PolygonizeLinesOperator polygonize( line ? (*line->stroke()) : Stroke() );
// Geode to hold all the geometries.
osg::Geode* geode = new PixelScalingGeode(); //osg::Geode();
// iterate over all features.
for( FeatureList::iterator i = input.begin(); i != input.end(); ++i )
{
Feature* f = i->get();
// iterate over all the feature's geometry parts. We will treat
// them as lines strings.
GeometryIterator parts( f->getGeometry(), false );
while( parts.hasMore() )
{
Geometry* part = parts.next();
// skip empty geometry
if ( part->size() == 0 )
continue;
// transform the geometry into the target SRS and localize it about
// a local reference point.
osg::Vec3Array* verts = new osg::Vec3Array();
osg::Vec3Array* normals = new osg::Vec3Array();
transformAndLocalize( part->asVector(), featureSRS, verts, normals, mapSRS, _world2local, makeECEF );
// turn the lines into polygons.
osg::Geometry* geom = polygonize( verts, normals );
// install.
geode->addDrawable( geom );
// record the geometry's primitive set(s) in the index:
if ( cx.featureIndex() )
cx.featureIndex()->tagDrawable( geom, f );
}
}
// attempt to combine geometries for better performance
MeshConsolidator::run( *geode );
// GPU performance optimization:
VertexCacheOptimizer vco;
geode->accept( vco );
// If we're auto-scaling, we need a shader
polygonize.installShaders( geode );
return delocalize( geode );
}
| {
"pile_set_name": "Github"
} |
# /* **************************************************************************
# * *
# * (C) Copyright Paul Mensonides 2002.
# * 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)
# * *
# ************************************************************************** */
#
# /* See http://www.boost.org for most recent version. */
#
# include <boost/preprocessor/slot/detail/shared.hpp>
#
# undef BOOST_PP_SLOT_1
#
# undef BOOST_PP_SLOT_1_DIGIT_1
# undef BOOST_PP_SLOT_1_DIGIT_2
# undef BOOST_PP_SLOT_1_DIGIT_3
# undef BOOST_PP_SLOT_1_DIGIT_4
# undef BOOST_PP_SLOT_1_DIGIT_5
# undef BOOST_PP_SLOT_1_DIGIT_6
# undef BOOST_PP_SLOT_1_DIGIT_7
# undef BOOST_PP_SLOT_1_DIGIT_8
# undef BOOST_PP_SLOT_1_DIGIT_9
# undef BOOST_PP_SLOT_1_DIGIT_10
#
# if BOOST_PP_SLOT_TEMP_10 == 0
# define BOOST_PP_SLOT_1_DIGIT_10 0
# elif BOOST_PP_SLOT_TEMP_10 == 1
# define BOOST_PP_SLOT_1_DIGIT_10 1
# elif BOOST_PP_SLOT_TEMP_10 == 2
# define BOOST_PP_SLOT_1_DIGIT_10 2
# elif BOOST_PP_SLOT_TEMP_10 == 3
# define BOOST_PP_SLOT_1_DIGIT_10 3
# elif BOOST_PP_SLOT_TEMP_10 == 4
# define BOOST_PP_SLOT_1_DIGIT_10 4
# elif BOOST_PP_SLOT_TEMP_10 == 5
# define BOOST_PP_SLOT_1_DIGIT_10 5
# elif BOOST_PP_SLOT_TEMP_10 == 6
# define BOOST_PP_SLOT_1_DIGIT_10 6
# elif BOOST_PP_SLOT_TEMP_10 == 7
# define BOOST_PP_SLOT_1_DIGIT_10 7
# elif BOOST_PP_SLOT_TEMP_10 == 8
# define BOOST_PP_SLOT_1_DIGIT_10 8
# elif BOOST_PP_SLOT_TEMP_10 == 9
# define BOOST_PP_SLOT_1_DIGIT_10 9
# endif
#
# if BOOST_PP_SLOT_TEMP_9 == 0
# define BOOST_PP_SLOT_1_DIGIT_9 0
# elif BOOST_PP_SLOT_TEMP_9 == 1
# define BOOST_PP_SLOT_1_DIGIT_9 1
# elif BOOST_PP_SLOT_TEMP_9 == 2
# define BOOST_PP_SLOT_1_DIGIT_9 2
# elif BOOST_PP_SLOT_TEMP_9 == 3
# define BOOST_PP_SLOT_1_DIGIT_9 3
# elif BOOST_PP_SLOT_TEMP_9 == 4
# define BOOST_PP_SLOT_1_DIGIT_9 4
# elif BOOST_PP_SLOT_TEMP_9 == 5
# define BOOST_PP_SLOT_1_DIGIT_9 5
# elif BOOST_PP_SLOT_TEMP_9 == 6
# define BOOST_PP_SLOT_1_DIGIT_9 6
# elif BOOST_PP_SLOT_TEMP_9 == 7
# define BOOST_PP_SLOT_1_DIGIT_9 7
# elif BOOST_PP_SLOT_TEMP_9 == 8
# define BOOST_PP_SLOT_1_DIGIT_9 8
# elif BOOST_PP_SLOT_TEMP_9 == 9
# define BOOST_PP_SLOT_1_DIGIT_9 9
# endif
#
# if BOOST_PP_SLOT_TEMP_8 == 0
# define BOOST_PP_SLOT_1_DIGIT_8 0
# elif BOOST_PP_SLOT_TEMP_8 == 1
# define BOOST_PP_SLOT_1_DIGIT_8 1
# elif BOOST_PP_SLOT_TEMP_8 == 2
# define BOOST_PP_SLOT_1_DIGIT_8 2
# elif BOOST_PP_SLOT_TEMP_8 == 3
# define BOOST_PP_SLOT_1_DIGIT_8 3
# elif BOOST_PP_SLOT_TEMP_8 == 4
# define BOOST_PP_SLOT_1_DIGIT_8 4
# elif BOOST_PP_SLOT_TEMP_8 == 5
# define BOOST_PP_SLOT_1_DIGIT_8 5
# elif BOOST_PP_SLOT_TEMP_8 == 6
# define BOOST_PP_SLOT_1_DIGIT_8 6
# elif BOOST_PP_SLOT_TEMP_8 == 7
# define BOOST_PP_SLOT_1_DIGIT_8 7
# elif BOOST_PP_SLOT_TEMP_8 == 8
# define BOOST_PP_SLOT_1_DIGIT_8 8
# elif BOOST_PP_SLOT_TEMP_8 == 9
# define BOOST_PP_SLOT_1_DIGIT_8 9
# endif
#
# if BOOST_PP_SLOT_TEMP_7 == 0
# define BOOST_PP_SLOT_1_DIGIT_7 0
# elif BOOST_PP_SLOT_TEMP_7 == 1
# define BOOST_PP_SLOT_1_DIGIT_7 1
# elif BOOST_PP_SLOT_TEMP_7 == 2
# define BOOST_PP_SLOT_1_DIGIT_7 2
# elif BOOST_PP_SLOT_TEMP_7 == 3
# define BOOST_PP_SLOT_1_DIGIT_7 3
# elif BOOST_PP_SLOT_TEMP_7 == 4
# define BOOST_PP_SLOT_1_DIGIT_7 4
# elif BOOST_PP_SLOT_TEMP_7 == 5
# define BOOST_PP_SLOT_1_DIGIT_7 5
# elif BOOST_PP_SLOT_TEMP_7 == 6
# define BOOST_PP_SLOT_1_DIGIT_7 6
# elif BOOST_PP_SLOT_TEMP_7 == 7
# define BOOST_PP_SLOT_1_DIGIT_7 7
# elif BOOST_PP_SLOT_TEMP_7 == 8
# define BOOST_PP_SLOT_1_DIGIT_7 8
# elif BOOST_PP_SLOT_TEMP_7 == 9
# define BOOST_PP_SLOT_1_DIGIT_7 9
# endif
#
# if BOOST_PP_SLOT_TEMP_6 == 0
# define BOOST_PP_SLOT_1_DIGIT_6 0
# elif BOOST_PP_SLOT_TEMP_6 == 1
# define BOOST_PP_SLOT_1_DIGIT_6 1
# elif BOOST_PP_SLOT_TEMP_6 == 2
# define BOOST_PP_SLOT_1_DIGIT_6 2
# elif BOOST_PP_SLOT_TEMP_6 == 3
# define BOOST_PP_SLOT_1_DIGIT_6 3
# elif BOOST_PP_SLOT_TEMP_6 == 4
# define BOOST_PP_SLOT_1_DIGIT_6 4
# elif BOOST_PP_SLOT_TEMP_6 == 5
# define BOOST_PP_SLOT_1_DIGIT_6 5
# elif BOOST_PP_SLOT_TEMP_6 == 6
# define BOOST_PP_SLOT_1_DIGIT_6 6
# elif BOOST_PP_SLOT_TEMP_6 == 7
# define BOOST_PP_SLOT_1_DIGIT_6 7
# elif BOOST_PP_SLOT_TEMP_6 == 8
# define BOOST_PP_SLOT_1_DIGIT_6 8
# elif BOOST_PP_SLOT_TEMP_6 == 9
# define BOOST_PP_SLOT_1_DIGIT_6 9
# endif
#
# if BOOST_PP_SLOT_TEMP_5 == 0
# define BOOST_PP_SLOT_1_DIGIT_5 0
# elif BOOST_PP_SLOT_TEMP_5 == 1
# define BOOST_PP_SLOT_1_DIGIT_5 1
# elif BOOST_PP_SLOT_TEMP_5 == 2
# define BOOST_PP_SLOT_1_DIGIT_5 2
# elif BOOST_PP_SLOT_TEMP_5 == 3
# define BOOST_PP_SLOT_1_DIGIT_5 3
# elif BOOST_PP_SLOT_TEMP_5 == 4
# define BOOST_PP_SLOT_1_DIGIT_5 4
# elif BOOST_PP_SLOT_TEMP_5 == 5
# define BOOST_PP_SLOT_1_DIGIT_5 5
# elif BOOST_PP_SLOT_TEMP_5 == 6
# define BOOST_PP_SLOT_1_DIGIT_5 6
# elif BOOST_PP_SLOT_TEMP_5 == 7
# define BOOST_PP_SLOT_1_DIGIT_5 7
# elif BOOST_PP_SLOT_TEMP_5 == 8
# define BOOST_PP_SLOT_1_DIGIT_5 8
# elif BOOST_PP_SLOT_TEMP_5 == 9
# define BOOST_PP_SLOT_1_DIGIT_5 9
# endif
#
# if BOOST_PP_SLOT_TEMP_4 == 0
# define BOOST_PP_SLOT_1_DIGIT_4 0
# elif BOOST_PP_SLOT_TEMP_4 == 1
# define BOOST_PP_SLOT_1_DIGIT_4 1
# elif BOOST_PP_SLOT_TEMP_4 == 2
# define BOOST_PP_SLOT_1_DIGIT_4 2
# elif BOOST_PP_SLOT_TEMP_4 == 3
# define BOOST_PP_SLOT_1_DIGIT_4 3
# elif BOOST_PP_SLOT_TEMP_4 == 4
# define BOOST_PP_SLOT_1_DIGIT_4 4
# elif BOOST_PP_SLOT_TEMP_4 == 5
# define BOOST_PP_SLOT_1_DIGIT_4 5
# elif BOOST_PP_SLOT_TEMP_4 == 6
# define BOOST_PP_SLOT_1_DIGIT_4 6
# elif BOOST_PP_SLOT_TEMP_4 == 7
# define BOOST_PP_SLOT_1_DIGIT_4 7
# elif BOOST_PP_SLOT_TEMP_4 == 8
# define BOOST_PP_SLOT_1_DIGIT_4 8
# elif BOOST_PP_SLOT_TEMP_4 == 9
# define BOOST_PP_SLOT_1_DIGIT_4 9
# endif
#
# if BOOST_PP_SLOT_TEMP_3 == 0
# define BOOST_PP_SLOT_1_DIGIT_3 0
# elif BOOST_PP_SLOT_TEMP_3 == 1
# define BOOST_PP_SLOT_1_DIGIT_3 1
# elif BOOST_PP_SLOT_TEMP_3 == 2
# define BOOST_PP_SLOT_1_DIGIT_3 2
# elif BOOST_PP_SLOT_TEMP_3 == 3
# define BOOST_PP_SLOT_1_DIGIT_3 3
# elif BOOST_PP_SLOT_TEMP_3 == 4
# define BOOST_PP_SLOT_1_DIGIT_3 4
# elif BOOST_PP_SLOT_TEMP_3 == 5
# define BOOST_PP_SLOT_1_DIGIT_3 5
# elif BOOST_PP_SLOT_TEMP_3 == 6
# define BOOST_PP_SLOT_1_DIGIT_3 6
# elif BOOST_PP_SLOT_TEMP_3 == 7
# define BOOST_PP_SLOT_1_DIGIT_3 7
# elif BOOST_PP_SLOT_TEMP_3 == 8
# define BOOST_PP_SLOT_1_DIGIT_3 8
# elif BOOST_PP_SLOT_TEMP_3 == 9
# define BOOST_PP_SLOT_1_DIGIT_3 9
# endif
#
# if BOOST_PP_SLOT_TEMP_2 == 0
# define BOOST_PP_SLOT_1_DIGIT_2 0
# elif BOOST_PP_SLOT_TEMP_2 == 1
# define BOOST_PP_SLOT_1_DIGIT_2 1
# elif BOOST_PP_SLOT_TEMP_2 == 2
# define BOOST_PP_SLOT_1_DIGIT_2 2
# elif BOOST_PP_SLOT_TEMP_2 == 3
# define BOOST_PP_SLOT_1_DIGIT_2 3
# elif BOOST_PP_SLOT_TEMP_2 == 4
# define BOOST_PP_SLOT_1_DIGIT_2 4
# elif BOOST_PP_SLOT_TEMP_2 == 5
# define BOOST_PP_SLOT_1_DIGIT_2 5
# elif BOOST_PP_SLOT_TEMP_2 == 6
# define BOOST_PP_SLOT_1_DIGIT_2 6
# elif BOOST_PP_SLOT_TEMP_2 == 7
# define BOOST_PP_SLOT_1_DIGIT_2 7
# elif BOOST_PP_SLOT_TEMP_2 == 8
# define BOOST_PP_SLOT_1_DIGIT_2 8
# elif BOOST_PP_SLOT_TEMP_2 == 9
# define BOOST_PP_SLOT_1_DIGIT_2 9
# endif
#
# if BOOST_PP_SLOT_TEMP_1 == 0
# define BOOST_PP_SLOT_1_DIGIT_1 0
# elif BOOST_PP_SLOT_TEMP_1 == 1
# define BOOST_PP_SLOT_1_DIGIT_1 1
# elif BOOST_PP_SLOT_TEMP_1 == 2
# define BOOST_PP_SLOT_1_DIGIT_1 2
# elif BOOST_PP_SLOT_TEMP_1 == 3
# define BOOST_PP_SLOT_1_DIGIT_1 3
# elif BOOST_PP_SLOT_TEMP_1 == 4
# define BOOST_PP_SLOT_1_DIGIT_1 4
# elif BOOST_PP_SLOT_TEMP_1 == 5
# define BOOST_PP_SLOT_1_DIGIT_1 5
# elif BOOST_PP_SLOT_TEMP_1 == 6
# define BOOST_PP_SLOT_1_DIGIT_1 6
# elif BOOST_PP_SLOT_TEMP_1 == 7
# define BOOST_PP_SLOT_1_DIGIT_1 7
# elif BOOST_PP_SLOT_TEMP_1 == 8
# define BOOST_PP_SLOT_1_DIGIT_1 8
# elif BOOST_PP_SLOT_TEMP_1 == 9
# define BOOST_PP_SLOT_1_DIGIT_1 9
# endif
#
# if BOOST_PP_SLOT_1_DIGIT_10
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_10(BOOST_PP_SLOT_1_DIGIT_10, BOOST_PP_SLOT_1_DIGIT_9, BOOST_PP_SLOT_1_DIGIT_8, BOOST_PP_SLOT_1_DIGIT_7, BOOST_PP_SLOT_1_DIGIT_6, BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_9
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_9(BOOST_PP_SLOT_1_DIGIT_9, BOOST_PP_SLOT_1_DIGIT_8, BOOST_PP_SLOT_1_DIGIT_7, BOOST_PP_SLOT_1_DIGIT_6, BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_8
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_8(BOOST_PP_SLOT_1_DIGIT_8, BOOST_PP_SLOT_1_DIGIT_7, BOOST_PP_SLOT_1_DIGIT_6, BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_7
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_7(BOOST_PP_SLOT_1_DIGIT_7, BOOST_PP_SLOT_1_DIGIT_6, BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_6
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_6(BOOST_PP_SLOT_1_DIGIT_6, BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_5
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_5(BOOST_PP_SLOT_1_DIGIT_5, BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_4
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_4(BOOST_PP_SLOT_1_DIGIT_4, BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_3
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_3(BOOST_PP_SLOT_1_DIGIT_3, BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# elif BOOST_PP_SLOT_1_DIGIT_2
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_CC_2(BOOST_PP_SLOT_1_DIGIT_2, BOOST_PP_SLOT_1_DIGIT_1)
# else
# define BOOST_PP_SLOT_1() BOOST_PP_SLOT_1_DIGIT_1
# endif
| {
"pile_set_name": "Github"
} |
// <copyright>
// Copyright by the Spark Development Network
//
// Licensed under the Rock Community License (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.rockrms.com/license
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Entity;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Rock;
using Rock.Attribute;
using Rock.Chart;
using Rock.Constants;
using Rock.Data;
using Rock.Model;
using Rock.Security;
using Rock.Utility;
using Rock.Web;
using Rock.Web.Cache;
using Rock.Web.UI;
using Rock.Web.UI.Controls;
using Attribute = Rock.Model.Attribute;
namespace RockWeb.Blocks.Steps
{
[DisplayName( "Step Type Detail" )]
[Category( "Steps" )]
[Description( "Displays the details of the given Step Type for editing." )]
#region Block Attributes
[BooleanField
( "Show Chart",
Key = AttributeKey.ShowChart,
DefaultValue = "true",
Order = 0 )]
[DefinedValueField
( Rock.SystemGuid.DefinedType.CHART_STYLES,
"Chart Style",
Key = AttributeKey.ChartStyle,
DefaultValue = Rock.SystemGuid.DefinedValue.CHART_STYLE_ROCK,
Order = 1 )]
[SlidingDateRangeField
( "Default Chart Date Range",
Key = AttributeKey.SlidingDateRange,
DefaultValue = "Current||Year||",
EnabledSlidingDateRangeTypes = "Last,Previous,Current,DateRange",
Order = 2 )]
[CategoryField(
"Data View Categories",
Key = AttributeKey.DataViewCategories,
Description = "The categories from which the Audience and Autocomplete data view options can be selected. If empty, all data views will be available.",
AllowMultiple = true,
EntityTypeName = "Rock.Model.DataView",
EntityTypeQualifierColumn = "",
EntityTypeQualifierValue = "",
IsRequired = false,
DefaultValue = "",
Category = "",
Order = 7 )]
[LinkedPage(
name: "Bulk Entry Page",
description: "The page to use for bulk entry of steps data",
required: false,
order: 8,
key: AttributeKey.BulkEntryPage )]
#endregion Block Attributes
public partial class StepTypeDetail : RockBlock, IDetailBlock
{
#region Attribute Keys
/// <summary>
/// Keys to use for Block Attributes
/// </summary>
private static class AttributeKey
{
/// <summary>
/// The show chart
/// </summary>
public const string ShowChart = "ShowChart";
/// <summary>
/// The chart style
/// </summary>
public const string ChartStyle = "ChartStyle";
/// <summary>
/// The sliding date range
/// </summary>
public const string SlidingDateRange = "SlidingDateRange";
/// <summary>
/// The data view categories
/// </summary>
public const string DataViewCategories = "DataViewCategories";
/// <summary>
/// The bulk entry page
/// </summary>
public const string BulkEntryPage = "BulkEntryPage";
}
#endregion Attribute Keys
#region Page Parameter Keys
/// <summary>
/// Keys to use for Page Parameters
/// </summary>
private static class PageParameterKey
{
/// <summary>
/// The step type identifier
/// </summary>
public const string StepTypeId = "StepTypeId";
/// <summary>
/// The step program identifier
/// </summary>
public const string StepProgramId = "ProgramId";
}
#endregion Page Parameter Keys
#region Properties
private List<Attribute> AttributesState { get; set; }
private List<StepWorkflowTriggerViewModel> WorkflowsState { get; set; }
#endregion
#region Private Variables
private int _stepProgramId = 0;
private int _stepTypeId = 0;
private RockContext _dataContext = null;
private bool _blockContextIsValid = false;
#endregion Private Variables
#region Control Methods
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
InitializeBlockNotification( nbBlockStatus, pnlDetails );
InitializeSettingsNotification( upStepType );
_blockContextIsValid = InitializeBlockContext();
if ( !_blockContextIsValid )
{
return;
}
InitializeChartScripts();
InitializeChartFilter();
dvpAutocomplete.EntityTypeId = EntityTypeCache.Get( typeof( Rock.Model.Person ) ).Id;
dvpAutocomplete.CategoryGuids = GetAttributeValue( AttributeKey.DataViewCategories ).SplitDelimitedValues().AsGuidList();
dvpAudience.EntityTypeId = EntityTypeCache.Get( typeof( Rock.Model.Person ) ).Id;
dvpAudience.CategoryGuids = GetAttributeValue( AttributeKey.DataViewCategories ).SplitDelimitedValues().AsGuidList();
bool editAllowed = IsUserAuthorized( Authorization.EDIT );
InitializeAttributesGrid( editAllowed );
InitializeWorkflowGrid( editAllowed );
btnDelete.Attributes["onclick"] = string.Format( "javascript: return Rock.dialogs.confirmDelete(event, '{0}', 'This will also delete the associated step participants.');", StepType.FriendlyTypeName );
btnSecurity.EntityTypeId = EntityTypeCache.Get( typeof( Rock.Model.StepType ) ).Id;
}
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( !_blockContextIsValid )
{
return;
}
if ( !Page.IsPostBack )
{
ShowDetail( _stepTypeId );
}
else
{
RefreshChart();
}
}
/// <summary>
/// Restores the view-state information from a previous user control request that was saved by the <see cref="M:System.Web.UI.UserControl.SaveViewState" /> method.
/// </summary>
/// <param name="savedState">An <see cref="T:System.Object" /> that represents the user control state to be restored.</param>
protected override void LoadViewState( object savedState )
{
base.LoadViewState( savedState );
LoadAttributesViewState();
var json = ViewState["WorkflowsState"] as string ?? string.Empty;
this.WorkflowsState = JsonConvert.DeserializeObject<List<StepWorkflowTriggerViewModel>>( json ) ?? new List<StepWorkflowTriggerViewModel>();
}
/// <summary>
/// Saves any user control view-state changes that have occurred since the last page postback.
/// </summary>
/// <returns>
/// Returns the user control's current view state. If there is no view state associated with the control, it returns null.
/// </returns>
protected override object SaveViewState()
{
var jsonSetting = new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
NullValueHandling = NullValueHandling.Ignore
};
var json = JsonConvert.SerializeObject( WorkflowsState, Formatting.None, jsonSetting );
SaveAttributesViewState( jsonSetting );
ViewState["WorkflowsState"] = json;
return base.SaveViewState();
}
/// <summary>
/// Returns breadcrumbs specific to the block that should be added to navigation
/// based on the current page reference. This function is called during the page's
/// oninit to load any initial breadcrumbs
/// </summary>
/// <param name="pageReference">The page reference.</param>
/// <returns></returns>
public override List<BreadCrumb> GetBreadCrumbs( PageReference pageReference )
{
var breadCrumbs = new List<BreadCrumb>();
int? stepTypeId = PageParameter( pageReference, PageParameterKey.StepTypeId ).AsIntegerOrNull();
if ( stepTypeId != null )
{
var dataContext = GetDataContext();
var stepType = new StepTypeService( dataContext ).Get( stepTypeId.Value );
if ( stepType != null )
{
breadCrumbs.Add( new BreadCrumb( stepType.Name, pageReference ) );
}
else
{
breadCrumbs.Add( new BreadCrumb( "New Step Type", pageReference ) );
}
}
else
{
// don't show a breadcrumb if we don't have a pageparam to work with
}
return breadCrumbs;
}
/// <summary>
/// Navigate to the step program page
/// </summary>
private void GoToStepProgramPage()
{
NavigateToParentPage( new Dictionary<string, string> { { PageParameterKey.StepProgramId, _stepProgramId.ToString() } } );
}
#endregion
#region Events
#region Control Events
/// <summary>
/// Handles the Click event of the btnBulkEntry control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void btnBulkEntry_Click( object sender, EventArgs e )
{
var stepType = GetStepType();
var queryParams = new Dictionary<string, string>();
if ( stepType != null )
{
queryParams[PageParameterKey.StepTypeId] = stepType.Id.ToString();
}
NavigateToLinkedPage( AttributeKey.BulkEntryPage, queryParams );
}
/// <summary>
/// Refresh the Steps Activity Chart.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnRefreshChart_Click( object sender, EventArgs e )
{
RefreshChart();
}
/// <summary>
/// Handles the Click event of the btnEdit control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnEdit_Click( object sender, EventArgs e )
{
var stepType = GetStepType();
ShowEditDetails( stepType );
}
/// <summary>
/// Handles the Click event of the btnDelete control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void btnDelete_Click( object sender, EventArgs e )
{
DeleteRecord();
}
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSave_Click( object sender, EventArgs e )
{
var recordId = SaveRecord();
if ( recordId <= 0 )
{
return;
}
// Update the query string for this page and reload.
var qryParams = new Dictionary<string, string>();
qryParams[PageParameterKey.StepTypeId] = recordId.ToString();
NavigateToPage( RockPage.Guid, qryParams );
}
/// <summary>
/// Save the current record.
/// </summary>
/// <returns>The Id of the new record, or -1 if the process could not be completed.</returns>
private int SaveRecord()
{
StepType stepType;
var rockContext = GetDataContext();
var stepTypeService = new StepTypeService( rockContext );
var stepWorkflowService = new StepWorkflowService( rockContext );
var stepWorkflowTriggerService = new StepWorkflowTriggerService( rockContext );
int stepTypeId = int.Parse( hfStepTypeId.Value );
if ( stepTypeId == 0 )
{
stepType = new StepType();
stepType.StepProgramId = _stepProgramId;
stepTypeService.Add( stepType );
}
else
{
stepType = stepTypeService.Queryable()
.Include( x => x.StepWorkflowTriggers )
.Where( c => c.Id == stepTypeId )
.FirstOrDefault();
}
// Workflow Triggers: Remove deleted triggers.
var uiWorkflows = WorkflowsState.Select( l => l.Guid );
var deletedTriggers = stepType.StepWorkflowTriggers.Where( l => !uiWorkflows.Contains( l.Guid ) ).ToList();
foreach ( var trigger in deletedTriggers )
{
// Remove the Step workflows associated with this trigger.
var stepWorkflows = stepWorkflowService.Queryable().Where( w => w.StepWorkflowTriggerId == trigger.Id );
foreach ( var requestWorkflow in stepWorkflows )
{
stepWorkflowService.Delete( requestWorkflow );
}
// Remove the trigger.
stepType.StepWorkflowTriggers.Remove( trigger );
stepWorkflowTriggerService.Delete( trigger );
}
// Workflow Triggers: Update modified triggers.
foreach ( var stateTrigger in WorkflowsState )
{
var workflowTrigger = stepType.StepWorkflowTriggers.Where( a => a.Guid == stateTrigger.Guid ).FirstOrDefault();
if ( workflowTrigger == null )
{
workflowTrigger = new StepWorkflowTrigger();
workflowTrigger.StepProgramId = stepType.StepProgramId;
stepType.StepWorkflowTriggers.Add( workflowTrigger );
}
workflowTrigger.Guid = stateTrigger.Guid;
workflowTrigger.WorkflowTypeId = stateTrigger.WorkflowTypeId;
workflowTrigger.TriggerType = stateTrigger.TriggerType;
workflowTrigger.TypeQualifier = stateTrigger.TypeQualifier;
workflowTrigger.WorkflowTypeId = stateTrigger.WorkflowTypeId;
workflowTrigger.WorkflowName = stateTrigger.WorkflowTypeName;
}
// Update Basic properties
stepType.Name = tbName.Text;
stepType.IsActive = cbIsActive.Checked;
stepType.Description = tbDescription.Text;
stepType.IconCssClass = tbIconCssClass.Text;
stepType.HighlightColor = cpHighlight.Value;
stepType.ShowCountOnBadge = cbShowBadgeCount.Checked;
stepType.HasEndDate = cbHasDuration.Checked;
stepType.AllowMultiple = cbAllowMultiple.Checked;
// Update Prerequisites
var uiPrerequisiteStepTypeIds = cblPrerequsities.SelectedValuesAsInt;
var stepTypes = stepTypeService.Queryable().ToList();
var removePrerequisiteStepTypes = stepType.StepTypePrerequisites.Where( x => !uiPrerequisiteStepTypeIds.Contains( x.PrerequisiteStepTypeId ) ).ToList();
var prerequisiteService = new StepTypePrerequisiteService( rockContext );
foreach ( var prerequisiteStepType in removePrerequisiteStepTypes )
{
stepType.StepTypePrerequisites.Remove( prerequisiteStepType );
prerequisiteService.Delete( prerequisiteStepType );
}
var existingPrerequisiteStepTypeIds = stepType.StepTypePrerequisites.Select( x => x.PrerequisiteStepTypeId ).ToList();
var addPrerequisiteStepTypeIds = stepTypes.Where( x => uiPrerequisiteStepTypeIds.Contains( x.Id )
&& !existingPrerequisiteStepTypeIds.Contains( x.Id ) )
.Select( x => x.Id )
.ToList();
foreach ( var prerequisiteStepTypeId in addPrerequisiteStepTypeIds )
{
var newPrerequisite = new StepTypePrerequisite();
newPrerequisite.StepTypeId = stepType.Id;
newPrerequisite.PrerequisiteStepTypeId = prerequisiteStepTypeId;
stepType.StepTypePrerequisites.Add( newPrerequisite );
}
// Validate Prerequisites.
// This is necessary because other Step Types may have been modified after this record edit was started.
if ( _stepTypeId > 0 )
{
var eligibleStepTypeIdList = stepTypeService.GetEligiblePrerequisiteStepTypes( _stepTypeId ).Select(x => x.Id).ToList();
foreach ( var prerequisite in stepType.StepTypePrerequisites )
{
if ( !eligibleStepTypeIdList.Contains( prerequisite.PrerequisiteStepTypeId ) )
{
var prerequisiteStepType = stepTypeService.Get( prerequisite.PrerequisiteStepTypeId );
cvStepType.IsValid = false;
cvStepType.ErrorMessage = string.Format( "This Step Type cannot have prerequisite \"{0}\" because it is already a prerequisite of that Step Type.", prerequisiteStepType.Name );
return 0;
}
}
}
// Update Advanced Settings
stepType.AutoCompleteDataViewId = dvpAutocomplete.SelectedValueAsId();
stepType.AudienceDataViewId = dvpAudience.SelectedValueAsId();
stepType.AllowManualEditing = cbAllowEdit.Checked;
stepType.CardLavaTemplate = ceCardTemplate.Text;
if ( !stepType.IsValid )
{
// Controls will render the error messages
return -1;
}
// Save the Step Type and the associated Attributes.
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
Helper.SaveAttributeEdits( AttributesState, new Step().TypeId, "StepTypeId", stepType.Id.ToString(), rockContext );
} );
return stepType.Id;
}
/// <summary>
/// Handles the Click event of the btnCancel control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnCancel_Click( object sender, EventArgs e )
{
if ( hfStepTypeId.Value.Equals( "0" ) )
{
GoToStepProgramPage();
}
else
{
ShowReadonlyDetails( GetStepType() );
}
}
/// <summary>
/// Handles the BlockUpdated event of the control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void Block_BlockUpdated( object sender, EventArgs e )
{
this.NavigateToCurrentPageReference();
}
#endregion
#region StepWorkflow Events
/// <summary>
/// Handles the SaveClick event of the dlgStepWorkflow control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void dlgStepWorkflow_SaveClick( object sender, EventArgs e )
{
SaveWorkflowProperties();
}
/// <summary>
/// Handles the Delete event of the gWorkflows control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
protected void gWorkflows_Delete( object sender, RowEventArgs e )
{
Guid rowGuid = ( Guid ) e.RowKeyValue;
var workflowTypeStateObj = WorkflowsState.Where( g => g.Guid.Equals( rowGuid ) ).FirstOrDefault();
if ( workflowTypeStateObj != null )
{
WorkflowsState.Remove( workflowTypeStateObj );
}
BindStepWorkflowsGrid();
}
/// <summary>
/// Handles the GridRebind event of the gWorkflows control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void gWorkflows_GridRebind( object sender, EventArgs e )
{
BindStepWorkflowsGrid();
}
/// <summary>
/// Handles the Edit event of the gWorkflows control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
protected void gWorkflows_Edit( object sender, RowEventArgs e )
{
Guid stepWorkflowGuid = ( Guid ) e.RowKeyValue;
gWorkflows_ShowEdit( stepWorkflowGuid );
}
/// <summary>
/// Show the edit dialog for the specified Workflow Trigger.
/// </summary>
/// <param name="triggerGuid">The workflow trigger unique identifier.</param>
protected void gWorkflows_ShowEdit( Guid triggerGuid )
{
ShowWorkflowTriggerPropertiesDialog( triggerGuid );
}
/// <summary>
/// Handles the Add event of the gWorkflows control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void gWorkflows_Add( object sender, EventArgs e )
{
gWorkflows_ShowEdit( Guid.Empty );
}
/// <summary>
/// Handles the SelectedIndexChanged event of the ddlTriggerType control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void ddlTriggerType_SelectedIndexChanged( object sender, EventArgs e )
{
UpdateTriggerQualifiers();
}
/// <summary>
/// Show the edit dialog for the specified Workflow Trigger.
/// </summary>
/// <param name="triggerGuid">The workflow trigger unique identifier.</param>
private void ShowWorkflowTriggerPropertiesDialog( Guid triggerGuid )
{
var workflowTrigger = WorkflowsState.FirstOrDefault( l => l.Guid.Equals( triggerGuid ) );
if ( workflowTrigger != null )
{
wpWorkflowType.SetValue( workflowTrigger.WorkflowTypeId );
ddlTriggerType.SelectedValue = workflowTrigger.TriggerType.ToString();
}
else
{
// Set default values
wpWorkflowType.SetValue( null );
ddlTriggerType.SelectedValue = StepWorkflowTrigger.WorkflowTriggerCondition.IsComplete.ToString();
}
hfAddStepWorkflowGuid.Value = triggerGuid.ToString();
ShowDialog( "StepWorkflows", true );
UpdateTriggerQualifiers();
}
/// <summary>
/// Save changes to the Workflow Trigger currently displayed in the Workflow properties dialog.
/// </summary>
private void SaveWorkflowProperties()
{
StepWorkflowTriggerViewModel workflowTrigger = null;
var guid = hfAddStepWorkflowGuid.Value.AsGuid();
if ( !guid.IsEmpty() )
{
workflowTrigger = WorkflowsState.FirstOrDefault( l => l.Guid.Equals( guid ) );
}
if ( workflowTrigger == null )
{
workflowTrigger = new StepWorkflowTriggerViewModel();
workflowTrigger.Guid = Guid.NewGuid();
WorkflowsState.Add( workflowTrigger );
}
workflowTrigger.WorkflowTypeId = wpWorkflowType.SelectedValueAsId().Value;
workflowTrigger.TriggerType = ddlTriggerType.SelectedValueAsEnum<StepWorkflowTrigger.WorkflowTriggerCondition>();
var qualifierSettings = new StepWorkflowTrigger.StatusChangeTriggerSettings
{
FromStatusId = ddlPrimaryQualifier.SelectedValue.AsIntegerOrNull(),
ToStatusId = ddlSecondaryQualifier.SelectedValue.AsIntegerOrNull()
};
workflowTrigger.TypeQualifier = qualifierSettings.ToSelectionString();
var dataContext = GetDataContext();
var workflowTypeService = new WorkflowTypeService( dataContext );
var workflowTypeId = wpWorkflowType.SelectedValueAsId().GetValueOrDefault( 0 );
var workflowType = workflowTypeService.Queryable().AsNoTracking().FirstOrDefault( x => x.Id == workflowTypeId );
workflowTrigger.WorkflowTypeName = ( workflowType == null ) ? "(Unknown)" : workflowType.Name;
BindStepWorkflowsGrid();
HideDialog();
}
/// <summary>
/// Updates the trigger qualifiers.
/// </summary>
private void UpdateTriggerQualifiers()
{
var dataContext = GetDataContext();
var workflowTrigger = WorkflowsState.FirstOrDefault( l => l.Guid.Equals( hfAddStepWorkflowGuid.Value.AsGuid() ) );
var sStepWorkflowTriggerType = ddlTriggerType.SelectedValueAsEnum<StepWorkflowTrigger.WorkflowTriggerCondition>();
if ( sStepWorkflowTriggerType == StepWorkflowTrigger.WorkflowTriggerCondition.StatusChanged )
{
// Populate the selection lists for "To Status" and "From Status".
var stepType = GetStepType();
var statusList = new StepStatusService( dataContext ).Queryable().Where( s => s.StepProgramId == stepType.StepProgramId ).ToList();
ddlPrimaryQualifier.Label = "From";
ddlPrimaryQualifier.Visible = true;
ddlPrimaryQualifier.Items.Clear();
ddlPrimaryQualifier.Items.Add( new ListItem( string.Empty, string.Empty ) );
foreach ( var status in statusList )
{
ddlPrimaryQualifier.Items.Add( new ListItem( status.Name, status.Id.ToString().ToUpper() ) );
}
ddlSecondaryQualifier.Label = "To";
ddlSecondaryQualifier.Visible = true;
ddlSecondaryQualifier.Items.Clear();
ddlSecondaryQualifier.Items.Add( new ListItem( string.Empty, string.Empty ) );
foreach ( var status in statusList )
{
ddlSecondaryQualifier.Items.Add( new ListItem( status.Name, status.Id.ToString().ToUpper() ) );
}
}
else
{
ddlPrimaryQualifier.Visible = false;
ddlPrimaryQualifier.Items.Clear();
ddlSecondaryQualifier.Visible = false;
ddlSecondaryQualifier.Items.Clear();
}
// Set the qualifier values.
if ( workflowTrigger != null )
{
if ( workflowTrigger.TriggerType == sStepWorkflowTriggerType )
{
var qualifierSettings = new StepWorkflowTrigger.StatusChangeTriggerSettings( workflowTrigger.TypeQualifier );
ddlPrimaryQualifier.SelectedValue = qualifierSettings.FromStatusId.ToStringSafe();
ddlSecondaryQualifier.SelectedValue = qualifierSettings.ToStatusId.ToStringSafe();
}
}
}
/// <summary>
/// Binds the workflow triggers grid.
/// </summary>
private void BindStepWorkflowsGrid()
{
if ( WorkflowsState != null )
{
SetStepWorkflowListOrder( WorkflowsState );
// Set the description for the trigger.
var stepService = new StepWorkflowTriggerService( new RockContext() );
foreach ( var workflowTrigger in WorkflowsState )
{
var qualifierSettings = new StepWorkflowTrigger.StatusChangeTriggerSettings( workflowTrigger.TypeQualifier );
workflowTrigger.TriggerDescription = stepService.GetTriggerSettingsDescription( workflowTrigger.TriggerType, qualifierSettings );
}
gWorkflows.DataSource = WorkflowsState;
}
gWorkflows.DataBind();
}
/// <summary>
/// Sets the workflow triggers list order.
/// </summary>
/// <param name="stepWorkflowList">The workflow trigger list.</param>
private void SetStepWorkflowListOrder( List<StepWorkflowTriggerViewModel> stepWorkflowList )
{
if ( stepWorkflowList != null )
{
if ( stepWorkflowList.Any() )
{
stepWorkflowList.OrderBy( c => c.WorkflowTypeName ).ThenBy( c => c.TriggerType.ConvertToString() ).ToList();
}
}
}
/// <summary>
/// Configure the Workflow grid control.
/// </summary>
private void InitializeWorkflowGrid( bool showAdd )
{
gWorkflows.DataKeyNames = new string[] { "Guid" };
gWorkflows.Actions.ShowAdd = showAdd;
gWorkflows.Actions.AddClick += gWorkflows_Add;
gWorkflows.GridRebind += gWorkflows_GridRebind;
}
#endregion
#endregion
#region Attributes Grid and Picker (Custom)
/// <summary>
/// Get the implementing type of the Attribute Definition.
/// This is the type to which the attribute definition is attached, not the type with which the attribute values are associated.
/// </summary>
/// <returns></returns>
private Type GetAttributeParentEntityType()
{
return typeof( StepType );
}
/// <summary>
/// Get the prompt shown in the Attribute Definition dialog for the current parent entity.
/// </summary>
/// <returns></returns>
private string GetAttributeDefinitionDialogPrompt()
{
return string.Format( "Edit Attribute for Participants in Step Type \"{0}\"", tbName.Text );
}
#endregion
#region Attributes Grid and Picker (Common)
// Code in this region should be capable of being reused in other blocks without modification.
/// <summary>
/// Save the Attribute Definition currently displayed in the properties dialog.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void SaveAttributeDefinition()
{
Rock.Model.Attribute attribute = new Rock.Model.Attribute();
edtAttributes.GetAttributeProperties( attribute );
// Controls will show warnings
if ( !attribute.IsValid )
{
return;
}
if ( AttributesState.Any( a => a.Guid.Equals( attribute.Guid ) ) )
{
attribute.Order = AttributesState.Where( a => a.Guid.Equals( attribute.Guid ) ).FirstOrDefault().Order;
AttributesState.RemoveEntity( attribute.Guid );
}
else
{
attribute.Order = AttributesState.Any() ? AttributesState.Max( a => a.Order ) + 1 : 0;
}
AttributesState.Add( attribute );
ReOrderAttributes( AttributesState );
BindAttributesGrid();
HideDialog();
}
/// <summary>
/// Loads the state details.
/// </summary>
/// <param name="connectionType">Type of the connection.</param>
/// <param name="rockContext">The rock context.</param>
private void LoadAttributeDefinitions( int targetEntityTypeId, string targetEntityParentForeignKeyName, int targetEntityParentId )
{
if ( targetEntityParentId == 0 )
{
// If this is a new step type, then there are no attributes to load
AttributesState = new List<Attribute>();
return;
}
var dataContext = this.GetDataContext();
var attributeService = new AttributeService( dataContext );
AttributesState = attributeService
.GetByEntityTypeId( targetEntityTypeId, true ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( targetEntityParentForeignKeyName, StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( targetEntityParentId.ToString() ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList();
}
/// <summary>
/// Load the Attribute Definitions associated with the current record from ViewState.
/// </summary>
private void LoadAttributesViewState()
{
string json = ViewState["AttributesState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
AttributesState = new List<Attribute>();
}
else
{
AttributesState = JsonConvert.DeserializeObject<List<Attribute>>( json );
}
}
/// <summary>
/// Save the Attribute Definitions associated with the current record into ViewState.
/// </summary>
private void SaveAttributesViewState( JsonSerializerSettings jsonSetting )
{
ViewState["AttributesState"] = JsonConvert.SerializeObject( AttributesState, Formatting.None, jsonSetting );
}
/// <summary>
/// Set the properties of the Attributes grid.
/// </summary>
/// <param name="showAdd"></param>
private void InitializeAttributesGrid( bool showAdd )
{
gAttributes.DataKeyNames = new string[] { "Guid" };
gAttributes.AllowPaging = false;
gAttributes.DisplayType = GridDisplayType.Light;
gAttributes.ShowConfirmDeleteDialog = false;
gAttributes.EmptyDataText = Server.HtmlEncode( None.Text );
gAttributes.Actions.ShowAdd = showAdd;
gAttributes.Actions.AddClick += gAttributes_Add;
gAttributes.GridRebind += gAttributes_GridRebind;
gAttributes.GridReorder += gAttributes_GridReorder;
}
/// <summary>
/// Handles the Add event of the gAttributes control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void gAttributes_Add( object sender, EventArgs e )
{
gAttributes_ShowEdit( Guid.Empty );
}
/// <summary>
/// Handles the Edit event of the gAttributes control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gAttributes_Edit( object sender, RowEventArgs e )
{
var attributeGuid = ( Guid ) e.RowKeyValue;
gAttributes_ShowEdit( attributeGuid );
}
/// <summary>
/// Shows the edit attribute dialog.
/// </summary>
/// <param name="attributeGuid">The attribute unique identifier.</param>
protected void gAttributes_ShowEdit( Guid attributeGuid )
{
var entityType = GetAttributeParentEntityType();
var prompt = GetAttributeDefinitionDialogPrompt();
this.ShowAttributeDefinitionDialog( attributeGuid, entityType, prompt );
}
/// <summary>
/// Handles the GridReorder event of the gAttributes control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
protected void gAttributes_GridReorder( object sender, GridReorderEventArgs e )
{
SortAttributes( AttributesState, e.OldIndex, e.NewIndex );
BindAttributesGrid();
}
/// <summary>
/// Handles the Delete event of the gAttributes control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
/// <exception cref="System.NotImplementedException"></exception>
protected void gAttributes_Delete( object sender, RowEventArgs e )
{
var attributeGuid = ( Guid ) e.RowKeyValue;
AttributesState.RemoveEntity( attributeGuid );
BindAttributesGrid();
}
/// <summary>
/// Handles the GridRebind event of the gAttributes control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void gAttributes_GridRebind( object sender, EventArgs e )
{
BindAttributesGrid();
}
/// <summary>
/// Show the Attribute Definition Properties Dialog.
/// </summary>
private void ShowAttributeDefinitionDialog( Guid attributeGuid, Type attachToEntityType, string title )
{
Attribute attribute;
if ( attributeGuid.Equals( Guid.Empty ) )
{
attribute = new Attribute();
attribute.FieldTypeId = FieldTypeCache.Get( Rock.SystemGuid.FieldType.TEXT ).Id;
}
else
{
attribute = AttributesState.First( a => a.Guid.Equals( attributeGuid ) );
}
edtAttributes.ActionTitle = title;
var reservedKeyNames = new List<string>();
AttributesState.Where( a => !a.Guid.Equals( attributeGuid ) ).Select( a => a.Key ).ToList().ForEach( a => reservedKeyNames.Add( a ) );
edtAttributes.AllowSearchVisible = true;
edtAttributes.ReservedKeyNames = reservedKeyNames.ToList();
edtAttributes.SetAttributeProperties( attribute, attachToEntityType );
hfActiveDialog.Value = "ATTRIBUTES";
dlgAttribute.Show();
}
/// <summary>
/// Hide the Attribute Definition Properties Dialog.
/// </summary>
private void HideAttributeDefinitionDialog()
{
dlgAttribute.Hide();
hfActiveDialog.Value = string.Empty;
}
/// <summary>
/// Handles the SaveClick event of the dlgConnectionTypeAttribute control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void dlgAttribute_SaveClick( object sender, EventArgs e )
{
Rock.Model.Attribute attribute = new Rock.Model.Attribute();
edtAttributes.GetAttributeProperties( attribute );
// Controls will show warnings
if ( !attribute.IsValid )
{
return;
}
if ( AttributesState.Any( a => a.Guid.Equals( attribute.Guid ) ) )
{
attribute.Order = AttributesState.Where( a => a.Guid.Equals( attribute.Guid ) ).FirstOrDefault().Order;
AttributesState.RemoveEntity( attribute.Guid );
}
else
{
attribute.Order = AttributesState.Any() ? AttributesState.Max( a => a.Order ) + 1 : 0;
}
AttributesState.Add( attribute );
ReOrderAttributes( AttributesState );
BindAttributesGrid();
HideAttributeDefinitionDialog();
}
/// <summary>
/// Binds the Connection Type attributes grid.
/// </summary>
private void BindAttributesGrid()
{
gAttributes.DataSource = AttributesState
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.Select( a => new
{
a.Id,
a.Guid,
a.Name,
a.Description,
FieldType = FieldTypeCache.GetName( a.FieldTypeId ),
a.IsRequired,
a.IsGridColumn,
a.AllowSearch
} )
.ToList();
gAttributes.DataBind();
}
/// <summary>
/// Reorders the attribute list.
/// </summary>
/// <param name="itemList">The item list.</param>
/// <param name="oldIndex">The old index.</param>
/// <param name="newIndex">The new index.</param>
private void SortAttributes( List<Attribute> attributeList, int oldIndex, int newIndex )
{
var movedItem = attributeList.Where( a => a.Order == oldIndex ).FirstOrDefault();
if ( movedItem != null )
{
if ( newIndex < oldIndex )
{
// Moved up
foreach ( var otherItem in attributeList.Where( a => a.Order < oldIndex && a.Order >= newIndex ) )
{
otherItem.Order = otherItem.Order + 1;
}
}
else
{
// Moved Down
foreach ( var otherItem in attributeList.Where( a => a.Order > oldIndex && a.Order <= newIndex ) )
{
otherItem.Order = otherItem.Order - 1;
}
}
movedItem.Order = newIndex;
}
}
/// <summary>
/// Reorders the attributes.
/// </summary>
/// <param name="attributeList">The attribute list.</param>
private void ReOrderAttributes( List<Attribute> attributeList )
{
attributeList = attributeList.OrderBy( a => a.Order ).ToList();
int order = 0;
attributeList.ForEach( a => a.Order = order++ );
}
#endregion
#region Internal Methods
/// <summary>
/// Retrieve a singleton data context for data operations in this block.
/// </summary>
/// <returns></returns>
private RockContext GetDataContext()
{
if ( _dataContext == null )
{
_dataContext = new RockContext();
}
return _dataContext;
}
/// <summary>
/// Initialize handlers for block configuration changes.
/// </summary>
/// <param name="triggerPanel"></param>
private void InitializeSettingsNotification( UpdatePanel triggerPanel )
{
// Set up Block Settings change notification.
BlockUpdated += Block_BlockUpdated;
AddConfigurationUpdateTrigger( triggerPanel );
}
/// <summary>
/// Initialize the essential context in which this block is operating.
/// </summary>
/// <returns>True, if the block context is valid.</returns>
private bool InitializeBlockContext()
{
_stepProgramId = PageParameter( PageParameterKey.StepProgramId ).AsInteger();
_stepTypeId = PageParameter( PageParameterKey.StepTypeId ).AsInteger();
if ( _stepProgramId == 0
&& _stepTypeId == 0 )
{
ShowNotification( "A new Step cannot be added because there is no Step Program available in this context.", NotificationBoxType.Danger, true );
return false;
}
return true;
}
/// <summary>
/// Populate the selection list for Workflow Trigger Types.
/// </summary>
private void LoadWorkflowTriggerTypesSelectionList()
{
ddlTriggerType.Items.Add( new ListItem( "Step Completed", StepWorkflowTrigger.WorkflowTriggerCondition.IsComplete.ToString() ) );
ddlTriggerType.Items.Add( new ListItem( "Status Changed", StepWorkflowTrigger.WorkflowTriggerCondition.StatusChanged.ToString() ) );
ddlTriggerType.Items.Add( new ListItem( "Manual", StepWorkflowTrigger.WorkflowTriggerCondition.Manual.ToString() ) );
}
/// <summary>
/// Populate the selection list for Prerequisite Steps.
/// </summary>
private void LoadPrerequisiteStepsList()
{
var dataContext = GetDataContext();
// Load available Prerequisite Steps.
var stepType = GetStepType();
int programId = 0;
if ( stepType != null )
{
programId = stepType.StepProgramId;
}
if ( programId == 0 )
{
programId = _stepProgramId;
}
var stepsService = new StepTypeService( dataContext );
List<StepType> prerequisiteStepTypes;
if ( _stepTypeId == 0 )
{
prerequisiteStepTypes = stepsService.Queryable().Where( x => x.StepProgramId == programId && x.IsActive ).ToList();
}
else
{
prerequisiteStepTypes = stepsService.GetEligiblePrerequisiteStepTypes( _stepTypeId ).ToList();
}
cblPrerequsities.DataSource = prerequisiteStepTypes;
cblPrerequsities.DataBind();
cblPrerequsities.Visible = prerequisiteStepTypes.Count > 0;
}
/// <summary>
/// Shows the detail panel containing the main content of the block.
/// </summary>
/// <param name="stepTypeId">The entity id of the item to be shown.</param>
public void ShowDetail( int stepTypeId )
{
pnlDetails.Visible = false;
var dataContext = GetDataContext();
// Get the Step Type data model
var stepType = GetStepType( stepTypeId );
if ( stepType.Id != 0 )
{
pdAuditDetails.SetEntity( stepType, ResolveRockUrl( "~" ) );
}
else
{
// hide the panel drawer that show created and last modified dates
pdAuditDetails.Visible = false;
}
// Admin rights are required to edit a Step Type. Edit rights only allow adding/removing items.
bool adminAllowed = UserCanAdministrate || stepType.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
pnlDetails.Visible = true;
hfStepTypeId.Value = stepType.Id.ToString();
lIcon.Text = string.Format( "<i class='{0}'></i>", stepType.IconCssClass );
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !adminAllowed )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( StepProgram.FriendlyTypeName );
}
if ( readOnly )
{
btnEdit.Visible = false;
btnDelete.Visible = false;
btnSecurity.Visible = false;
ShowReadonlyDetails( stepType );
}
else
{
btnEdit.Visible = true;
btnDelete.Visible = true;
btnSecurity.Visible = true;
btnSecurity.Title = "Secure " + stepType.Name;
btnSecurity.EntityId = stepType.Id;
if ( !stepTypeId.Equals( 0 ) )
{
ShowReadonlyDetails( stepType );
}
else
{
ShowEditDetails( stepType );
}
}
// Set availability of Bulk Entry action.
var showBulkEntry = GetAttributeValue( AttributeKey.BulkEntryPage ).IsNotNullOrWhiteSpace()
&& this.UserCanEdit
&& stepType.IsAuthorized( Authorization.EDIT, CurrentPerson );
btnBulkEntry.Visible = showBulkEntry;
}
/// <summary>
/// Shows the edit details.
/// </summary>
/// <param name="stepType">The entity instance to be displayed.</param>
private void ShowEditDetails( StepType stepType )
{
if ( stepType == null )
{
stepType = new StepType();
stepType.IconCssClass = "fa fa-compress";
}
if ( stepType.Id == 0 )
{
lReadOnlyTitle.Text = ActionTitle.Add( StepType.FriendlyTypeName ).FormatAsHtmlTitle();
}
else
{
lReadOnlyTitle.Text = stepType.Name.FormatAsHtmlTitle();
}
SetEditMode( true );
LoadAttributeDefinitions( new Step().TypeId, "StepTypeId", stepType.Id );
LoadPrerequisiteStepsList();
LoadWorkflowTriggerTypesSelectionList();
// General properties
tbName.Text = stepType.Name;
cbIsActive.Checked = stepType.IsActive;
tbDescription.Text = stepType.Description;
tbIconCssClass.Text = stepType.IconCssClass;
cpHighlight.Text = stepType.HighlightColor;
cbAllowMultiple.Checked = stepType.AllowMultiple;
cbHasDuration.Checked = stepType.HasEndDate;
cbShowBadgeCount.Checked = stepType.ShowCountOnBadge;
// Pre-requisites
if ( stepType.StepTypePrerequisites != null )
{
cblPrerequsities.SetValues( stepType.StepTypePrerequisites.Select( x => x.PrerequisiteStepTypeId ) );
}
// Advanced Settings
dvpAutocomplete.SetValue( stepType.AutoCompleteDataViewId );
dvpAudience.SetValue( stepType.AudienceDataViewId );
cbAllowEdit.Checked = stepType.AllowManualEditing;
ceCardTemplate.Text = stepType.CardLavaTemplate;
// Workflow Triggers
WorkflowsState = new List<StepWorkflowTriggerViewModel>();
foreach ( var trigger in stepType.StepWorkflowTriggers )
{
var newItem = new StepWorkflowTriggerViewModel( trigger );
WorkflowsState.Add( newItem );
}
BindAttributesGrid();
BindStepWorkflowsGrid();
}
/// <summary>
/// Shows the readonly details.
/// </summary>
/// <param name="stepType">The entity instance to be displayed.</param>
private void ShowReadonlyDetails( StepType stepType )
{
SetEditMode( false );
hfStepTypeId.SetValue( stepType.Id );
WorkflowsState = null;
lReadOnlyTitle.Text = stepType.Name.FormatAsHtmlTitle();
// Create the read-only description text.
var descriptionListMain = new DescriptionList();
descriptionListMain.Add( "Description", stepType.Description );
lStepTypeDescription.Text = descriptionListMain.Html;
// Configure Label: Inactive
hlInactive.Visible = !stepType.IsActive;
RefreshChart();
}
/// <summary>
/// Delete the current record.
/// </summary>
private void DeleteRecord()
{
var rockContext = GetDataContext();
var stepTypeService = new StepTypeService( rockContext );
var stepType = GetStepType( forceLoadFromContext: true );
if ( stepType != null )
{
if ( !stepType.IsAuthorized( Authorization.ADMINISTRATE, this.CurrentPerson ) )
{
mdDeleteWarning.Show( "You are not authorized to delete this item.", ModalAlertType.Information );
return;
}
string errorMessage;
if ( !stepTypeService.CanDelete( stepType, out errorMessage ) )
{
mdDeleteWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
stepTypeService.Delete( stepType );
rockContext.SaveChanges();
}
GoToStepProgramPage();
}
/// <summary>
/// Gets the specified Step Type data model, or the current model if none is specified.
/// </summary>
/// <param name="stepType">The entity id of the instance to be retrieved.</param>
/// <returns></returns>
private StepType GetStepType( int? stepTypeId = null, bool forceLoadFromContext = false )
{
if ( stepTypeId == null )
{
stepTypeId = hfStepTypeId.ValueAsInt();
}
string key = string.Format( "StepType:{0}", stepTypeId );
StepType stepType = null;
if ( !forceLoadFromContext )
{
stepType = RockPage.GetSharedItem( key ) as StepType;
}
if ( stepType == null )
{
var dataContext = GetDataContext();
stepType = new StepTypeService( dataContext ).Queryable()
.Where( c => c.Id == stepTypeId )
.FirstOrDefault();
if ( stepType == null )
{
stepType = new StepType { Id = 0 };
}
RockPage.SaveSharedItem( key, stepType );
}
if ( _stepProgramId == default( int ) )
{
_stepProgramId = stepType.StepProgramId;
}
return stepType;
}
private int GetActiveStepTypeId()
{
return hfStepTypeId.ValueAsInt();
}
/// <summary>
/// Sets the edit mode.
/// </summary>
/// <param name="editable">if set to <c>true</c> [editable].</param>
private void SetEditMode( bool editable )
{
pnlEditDetails.Visible = editable;
pnlViewDetails.Visible = !editable;
HideSecondaryBlocks( editable );
}
/// <summary>
/// Shows the dialog.
/// </summary>
/// <param name="dialog">The dialog.</param>
/// <param name="setValues">if set to <c>true</c> [set values].</param>
private void ShowDialog( string dialog, bool setValues = false )
{
hfActiveDialog.Value = dialog.ToUpper().Trim();
ShowDialog( setValues );
}
/// <summary>
/// Shows the dialog.
/// </summary>
/// <param name="setValues">if set to <c>true</c> [set values].</param>
private void ShowDialog( bool setValues = false )
{
switch ( hfActiveDialog.Value )
{
case "STEPWORKFLOWS":
dlgStepWorkflow.Show();
break;
}
}
/// <summary>
/// Hides the dialog.
/// </summary>
private void HideDialog()
{
switch ( hfActiveDialog.Value )
{
case "STEPWORKFLOWS":
dlgStepWorkflow.Hide();
break;
}
hfActiveDialog.Value = string.Empty;
}
#endregion
#region Step Activity Chart
/// <summary>
/// Add scripts for Chart.js components
/// </summary>
private void InitializeChartScripts()
{
// NOTE: moment.js must be loaded before Chart.js
RockPage.AddScriptLink( "~/Scripts/moment.min.js", true );
RockPage.AddScriptLink( "~/Scripts/Chartjs/Chart.js", true );
}
/// <summary>
/// Initialize the chart by applying block configuration settings.
/// </summary>
private void InitializeChartFilter()
{
// Set the default Date Range from the block settings.
var dateRangeSettings = GetAttributeValue( AttributeKey.SlidingDateRange );
if ( !string.IsNullOrEmpty( dateRangeSettings ) )
{
drpSlidingDateRange.DelimitedValues = dateRangeSettings;
}
if ( drpSlidingDateRange.SlidingDateRangeMode == SlidingDateRangePicker.SlidingDateRangeType.All )
{
// Default to current year
drpSlidingDateRange.SlidingDateRangeMode = SlidingDateRangePicker.SlidingDateRangeType.Current;
drpSlidingDateRange.TimeUnit = SlidingDateRangePicker.TimeUnitType.Year;
}
}
/// <summary>
/// Refresh the chart using the current filter settings.
/// </summary>
private void RefreshChart()
{
// Set the visibility of the Activity Summary chart.
bool showActivitySummary = GetAttributeValue( AttributeKey.ShowChart ).AsBoolean( true );
if ( showActivitySummary )
{
// If the Step Type does not have any activity, hide the Activity Summary.
var dataContext = GetDataContext();
var stepService = new StepService( dataContext );
var stepsQuery = stepService.Queryable().AsNoTracking()
.Where( x => x.StepTypeId == _stepTypeId );
showActivitySummary = stepsQuery.Any();
}
pnlActivitySummary.Visible = showActivitySummary;
if ( !showActivitySummary )
{
return;
}
// Get chart data and set visibility of related elements.
var reportPeriod = new TimePeriod( drpSlidingDateRange.DelimitedValues );
var chartFactory = this.GetChartJsFactory( reportPeriod );
chartCanvas.Visible = chartFactory.HasData;
nbActivityChartMessage.Visible = !chartFactory.HasData;
if ( !chartFactory.HasData )
{
// If no data, show a notification.
nbActivityChartMessage.Text = "There are no Steps matching the current filter.";
return;
}
// Add client script to construct the chart.
var chartDataJson = chartFactory.GetJson( sizeToFitContainerWidth: true, maintainAspectRatio: false );
string script = string.Format( @"
var barCtx = $('#{0}')[0].getContext('2d');
var barChart = new Chart(barCtx, {1});",
chartCanvas.ClientID,
chartDataJson );
ScriptManager.RegisterStartupScript( this.Page, this.GetType(), "stepTypeActivityChartScript", script, true );
}
/// <summary>
/// Gets a configured factory that creates the data required for the chart.
/// </summary>
/// <returns></returns>
public ChartJsTimeSeriesDataFactory<ChartJsTimeSeriesDataPoint> GetChartJsFactory( TimePeriod reportPeriod )
{
var dataContext = GetDataContext();
var stepService = new StepService( dataContext );
// Get the Steps associated with the current Step Type.
var stepsStartedQuery = stepService.Queryable().AsNoTracking()
.Where( x => x.StepTypeId == _stepTypeId && x.StepType.IsActive && x.StartDateTime != null );
var stepsCompletedQuery = stepService.Queryable().AsNoTracking()
.Where( x => x.StepTypeId == _stepTypeId && x.StepType.IsActive && x.CompletedDateTime != null );
var dateRange = reportPeriod.GetDateRange();
var startDate = dateRange.Start;
var endDate = dateRange.End;
if ( startDate != null )
{
startDate = startDate.Value.Date;
stepsStartedQuery = stepsStartedQuery.Where( x => x.StartDateTime >= startDate );
stepsCompletedQuery = stepsCompletedQuery.Where( x => x.CompletedDateTime >= startDate );
}
if ( endDate != null )
{
var compareDate = endDate.Value.Date.AddDays( 1 );
stepsStartedQuery = stepsStartedQuery.Where( x => x.StartDateTime < compareDate );
stepsCompletedQuery = stepsCompletedQuery.Where( x => x.CompletedDateTime < compareDate );
}
// Initialize a new Chart Factory.
var factory = new ChartJsTimeSeriesDataFactory<ChartJsTimeSeriesDataPoint>();
if ( reportPeriod.TimeUnit == TimePeriodUnitSpecifier.Year )
{
factory.TimeScale = ChartJsTimeSeriesTimeScaleSpecifier.Month;
}
else
{
factory.TimeScale = ChartJsTimeSeriesTimeScaleSpecifier.Day;
}
factory.StartDateTime = startDate;
factory.EndDateTime = endDate;
factory.ChartStyle = ChartJsTimeSeriesChartStyleSpecifier.Line;
// Determine the appropriate date grouping for the chart data points.
Func<Step, DateTime> groupKeySelector;
if ( factory.TimeScale == ChartJsTimeSeriesTimeScaleSpecifier.Day )
{
// Group Steps by Start Date.
groupKeySelector = ( x => x.StartDateTime.Value.Date );
}
else
{
// Group Steps by Start Date rounded to beginning of the month.
groupKeySelector = ( x => new DateTime( x.StartDateTime.Value.Year, x.StartDateTime.Value.Month, 1 ) );
}
// Add data series for Steps started.
var startedSeriesDataPoints = stepsStartedQuery.ToList()
.GroupBy( groupKeySelector )
.Select( x => new ChartDatasetInfo
{
DatasetName = "Started",
DateTime = x.Key,
Value = x.Count(),
SortKey = "1"
} );
if ( factory.TimeScale == ChartJsTimeSeriesTimeScaleSpecifier.Day )
{
// Group Steps by Completed Date.
groupKeySelector = ( x => x.CompletedDateTime.Value.Date );
}
else
{
// Group Steps by Completed Date rounded to beginning of the month.
groupKeySelector = ( x => new DateTime( x.CompletedDateTime.Value.Year, x.CompletedDateTime.Value.Month, 1 ) );
}
// Add data series for Steps completed.
var completedSeriesDataPoints = stepsCompletedQuery.ToList()
.GroupBy( groupKeySelector )
.Select( x => new ChartDatasetInfo
{
DatasetName = "Completed",
DateTime = x.Key,
Value = x.Count(),
SortKey = "2"
} );
var allDataPoints = startedSeriesDataPoints.Union( completedSeriesDataPoints ).OrderBy( x => x.SortKey ).ThenBy( x => x.DateTime );
var dataSetNames = allDataPoints.Select( x => x.DatasetName ).Distinct().ToList();
// Add Dataset for Steps Started.
var colorStarted = new RockColor( ChartJsConstants.Colors.Blue );
var startedDataset = this.CreateDataSet( allDataPoints, "Started", colorStarted.ToHex() );
factory.Datasets.Add( startedDataset );
// Add Dataset for Steps Completed.
var colorCompleted = new RockColor( ChartJsConstants.Colors.Green );
var completedDataset = this.CreateDataSet( allDataPoints, "Completed", colorCompleted.ToHex() );
factory.Datasets.Add( completedDataset );
return factory;
}
private ChartJsTimeSeriesDataset CreateDataSet( IOrderedEnumerable<ChartDatasetInfo> allDataPoints, string datasetName, string colorString )
{
var dataset = new ChartJsTimeSeriesDataset();
dataset.Name = datasetName;
dataset.DataPoints = allDataPoints
.Where( x => x.DatasetName == datasetName )
.Select( x => new ChartJsTimeSeriesDataPoint { DateTime = x.DateTime, Value = x.Value } )
.Cast<IChartJsTimeSeriesDataPoint>()
.ToList();
dataset.BorderColor = colorString;
return dataset;
}
#endregion
#region Support Classes
[Serializable]
private class StepWorkflowTriggerViewModel
{
public int Id { get; set; }
public Guid Guid { get; set; }
public string WorkflowTypeName { get; set; }
public int? StepTypeId { get; set; }
public int WorkflowTypeId { get; set; }
public StepWorkflowTrigger.WorkflowTriggerCondition TriggerType { get; set; }
public string TypeQualifier { get; set; }
public string TriggerDescription { get; set; }
public StepWorkflowTriggerViewModel()
{
//
}
public StepWorkflowTriggerViewModel( StepWorkflowTrigger trigger )
{
Id = trigger.Id;
Guid = trigger.Guid;
StepTypeId = trigger.StepTypeId;
TriggerType = trigger.TriggerType;
TypeQualifier = trigger.TypeQualifier;
if ( trigger.WorkflowType != null )
{
WorkflowTypeId = trigger.WorkflowType.Id;
WorkflowTypeName = trigger.WorkflowType.Name;
}
}
}
/// <summary>
/// Stores information about a dataset to be displayed on a chart.
/// </summary>
private class ChartDatasetInfo
{
public string DatasetName { get; set; }
public DateTime DateTime { get; set; }
public int Value { get; set; }
public string SortKey { get; set; }
}
#endregion
#region Block Notifications
private NotificationBox _notificationControl;
private Control _detailContainerControl;
/// <summary>
/// Initialize block-level notification message handlers for block configuration changes.
/// </summary>
/// <param name="triggerPanel"></param>
private void InitializeBlockNotification( NotificationBox notificationControl, Control detailContainerControl )
{
_notificationControl = notificationControl;
_detailContainerControl = detailContainerControl;
ClearBlockNotification();
}
/// <summary>
/// Reset the notification message for the block.
/// </summary>
public void ClearBlockNotification()
{
_notificationControl.Visible = false;
_detailContainerControl.Visible = true;
}
/// <summary>
/// Show a notification message for the block.
/// </summary>
/// <param name="notificationControl"></param>
/// <param name="message"></param>
/// <param name="notificationType"></param>
public void ShowNotification( string message, NotificationBoxType notificationType = NotificationBoxType.Info, bool hideBlockContent = false )
{
_notificationControl.Text = message;
_notificationControl.NotificationBoxType = notificationType;
_notificationControl.Visible = true;
_detailContainerControl.Visible = !hideBlockContent;
}
#endregion
}
} | {
"pile_set_name": "Github"
} |
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Server types will answer with all instance types available in a given zone.
Each of these types will contains all the features of the instance (CPU, RAM, Storage) with their associated pricing.
USAGE:
scw instance server-type <command>
AVAILABLE COMMANDS:
list List server types
FLAGS:
-h, --help help for server-type
GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Use "scw instance server-type [command] --help" for more information about a command.
| {
"pile_set_name": "Github"
} |
% Meridian 59, Copyright 1994-2012 Andrew Kirmse and Chris Kirmse.
% All rights reserved.
%
% This software is distributed under a license that is described in
% the LICENSE file that accompanies it.
%
% Meridian is a registered trademark.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GroundWormQueen is GroundWorm
constants:
include blakston.khd
resources:
GroundWormQueen_name_rsc = "groundworm queen"
GroundWormQueen_koc_name_rsc = "koslithic"
GroundWormQueen_icon_rsc = worml.bgf
GroundWormQueen_desc_rsc = \
"The largest of the groundworms, the queen is a feared monster. "
"After growing over long periods of time, groundworms need increasing "
"amounts of food to sustain themselves. The queens are driven mad "
"by an overwhelming desire to consume food to satiate their immense "
"hunger. Occasionally groundworm queens lay eggs in corpses that "
"hatch into groundworm larva."
GroundWormQueen_dead_icon_rsc = wormlX.bgf
GroundWormQueen_dead_name_rsc = "slain groundworm queen"
GroundWormQueen_sound_aware = gwrm2awr.wav
classvars:
vrKocName = GroundWormQueen_koc_name_rsc
vrName = GroundWormQueen_name_rsc
vrIcon = GroundWormQueen_icon_rsc
vrDesc = GroundWormQueen_desc_rsc
vrDead_icon = GroundWormQueen_dead_icon_rsc
vrDead_name = GroundWormQueen_dead_name_rsc
vrSound_aware = GroundWormQueen_sound_aware
viTreasure_type = TID_WORM_QUEEN
viSpeed = SPEED_SLOW
viAttack_spell = ATCK_SPELL_ACID
viLevel = 130
viDifficulty = 7
viKarma = -30
viDefault_behavior = AI_FIGHT_HYPERAGGRESSIVE | AI_FIGHT_SINGLEMINDED
viGender = GENDER_FEMALE
viTrailLength = 4
vbTrailLarge = TRUE
properties:
messages:
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
| {
"pile_set_name": "Github"
} |
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#define foreach(x,v) for(typeof ((v).begin()) x = (v).begin(); x != (v).end() ; ++x)
using namespace std;
const int MP = 10001;
int visited[MP];
int prev[MP], low[MP], d[MP];
vector< vector<int> > g;
vector< pair<int,int> > bridges;
int n, ticks;
void dfs(int u){
visited[u] = true;
d[u] = low[u] = ticks++;
for (int i=0; i<g[u].size(); ++i){
int v = g[u][i];
if (prev[u] != v){
if(!visited[v]){
prev[v] = u;
dfs(v);
if (d[u] < low[v]){
bridges.push_back(make_pair(min(u,v),max(u,v)));
}
low[u] = min(low[u], low[v]);
}else{
low[u] = min(low[u], d[v]);
}
}
}
}
int main(){
int ncases;scanf("%d",&ncases);
for(int id = 1 ; id<=ncases; ++id){
printf("Case %d:\n",id);
scanf("%d",&n);
memset(visited,false,sizeof(visited));
memset(prev,-1,sizeof(prev));
g.assign(n, vector<int>());
bridges.clear();
if (n == 0){ printf("0 critical links\n"); continue; }
for (int i=0; i<n; ++i){
int node, deg;
scanf("%d (%d)", &node, °);
g[node].resize(deg);
for (int k=0, x; k<deg; ++k){
scanf("%d", &x);
g[node][k] = x;
}
}
ticks = 0;
for (int i=0; i<n; ++i){
if (!visited[i]){
dfs(i);
}
}
sort(bridges.begin(), bridges.end());
printf("%d critical links\n", bridges.size());
foreach(p, bridges)
printf("%d - %d\n", p->first, p->second);
}
return 0;
}
| {
"pile_set_name": "Github"
} |
// Copyright 2017 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.
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
[CustomPropertyDrawer(typeof(GvrPointerScrollInput), true)]
public class GvrPointerScrollInputEditor : PropertyDrawer {
private bool isExpanded = true;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
EditorGUI.BeginProperty(position, label, property);
int rows = GetNumRows(property);
float totalHeight = position.height;
float rowHeight = totalHeight / rows;
position.height = rowHeight;
isExpanded = EditorGUI.Foldout(position, isExpanded, label);
if (isExpanded) {
EditorGUI.indentLevel++;
// Inertia property.
SerializedProperty inertia =
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_INERTIA);
position.y += rowHeight;
EditorGUI.PropertyField(position, inertia);
if (inertia.boolValue) {
EditorGUI.indentLevel++;
// Deceleration rate property.
SerializedProperty decelerationRate =
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_DECELERATION_RATE);
position.y += rowHeight;
EditorGUI.PropertyField(position, decelerationRate);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
return base.GetPropertyHeight(property, label) * GetNumRows(property);
}
private int GetNumRows(SerializedProperty property) {
SerializedProperty inertia =
property.FindPropertyRelative(GvrPointerScrollInput.PROPERTY_NAME_INERTIA);
if (!isExpanded) {
return 1;
} else if (!inertia.boolValue) {
return 2;
} else {
return 3;
}
}
} | {
"pile_set_name": "Github"
} |
// Copyright 2004-present Facebook. All Rights Reserved.
#include "src/fft/CuFFTConvolution.cuh"
#include "THCTensor.h"
#include "cuda/DeviceTensor.cuh"
#include "src/CuBLASWrapper.h"
#include "src/DeviceTensorUtils.h"
#include "src/MM.h"
#include "src/fft/CuFFTStrategy.h"
#include "src/fft/CuFFTWrapper.cuh"
#include "src/fft/FBFFTHost.h"
#include "src/fft/Utils.h"
#include <cublas_v2.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <folly/Bits.h>
#include <folly/Memory.h>
#include <folly/ScopeGuard.h>
#include <glog/logging.h>
#include <unordered_map>
#include <unordered_set>
using namespace facebook::deeplearning::torch;
using namespace std;
namespace facebook { namespace deeplearning { namespace torch {
typedef CuFFTConvolution::CudaRealTensor CudaRealTensor;
typedef CuFFTConvolution::CudaComplexTensor CudaComplexTensor;
THParams::THParams(THCState* s,
THCudaTensor* in,
THCudaTensor* wei,
THCudaTensor* out,
THCudaTensor* b,
float sc,
THBuffers bufs) :
state(s),
input(in),
weight(wei),
output(out),
bias(b),
scale(sc),
buffers(bufs) {}
void THParams::free() {
THCudaTensor_free(state, input);
input = nullptr;
THCudaTensor_free(state, weight);
weight = nullptr;
THCudaTensor_free(state, output);
output = nullptr;
THCudaTensor_free(state, bias);
bias = nullptr;
buffers = THBuffers(); // Managed in lua land
}
ProblemSizes::ProblemSizes(const THParams& params, ConvolutionPass p) {
pass = p;
if (pass.pass == ConvolutionPass::kUpdateOutput) {
// Output is sometimes not allocated here, recover its size from the
// input sizes
batchSize = THCudaTensor_size(params.state, params.input, 0);
filterSize = THCudaTensor_size(params.state, params.weight, 0);
planeSize = THCudaTensor_size(params.state, params.input, 1);
inputSizeRow = THCudaTensor_size(params.state, params.input, 2);
inputSizeCol = THCudaTensor_size(params.state, params.input, 3);
weightSizeRow = THCudaTensor_size(params.state, params.weight, 2);
weightSizeCol = THCudaTensor_size(params.state, params.weight, 3);
outputSizeRow = (inputSizeRow - weightSizeRow) + 1;
outputSizeCol = (inputSizeCol - weightSizeCol) + 1;
} else if (pass.pass == ConvolutionPass::kUpdateGradInput) {
// Input is sometimes not allocated here, recover its size from the
// output sizes
batchSize = THCudaTensor_size(params.state, params.output, 0);
filterSize = THCudaTensor_size(params.state, params.output, 1);
planeSize = THCudaTensor_size(params.state, params.weight, 1);
outputSizeRow = THCudaTensor_size(params.state, params.output, 2);
outputSizeCol = THCudaTensor_size(params.state, params.output, 3);
weightSizeRow = THCudaTensor_size(params.state, params.weight, 2);
weightSizeCol = THCudaTensor_size(params.state, params.weight, 3);
inputSizeRow = (outputSizeRow - 1) + weightSizeRow;
inputSizeCol = (outputSizeCol - 1) + weightSizeCol;
} else {
// All 3 tensors are allocated here
CHECK(pass.pass == ConvolutionPass::kAccGradParameters);
batchSize = THCudaTensor_size(params.state, params.input, 0);
filterSize = THCudaTensor_size(params.state, params.weight, 0);
planeSize = THCudaTensor_size(params.state, params.input, 1);
inputSizeRow = THCudaTensor_size(params.state, params.input, 2);
inputSizeCol = THCudaTensor_size(params.state, params.input, 3);
weightSizeRow = THCudaTensor_size(params.state, params.weight, 2);
weightSizeCol = THCudaTensor_size(params.state, params.weight, 3);
outputSizeRow = THCudaTensor_size(params.state, params.output, 2);
outputSizeCol = THCudaTensor_size(params.state, params.output, 3);
}
expandedSizeRow = std::max(std::max(inputSizeRow, outputSizeRow),
weightSizeRow);
expandedSizeCol = std::max(std::max(inputSizeCol, outputSizeCol),
weightSizeCol);
buffers = params.buffers;
}
// This is used for autotuning, given a problem size fit
THParams ProblemSizes::makeTensors(THCState* state) const {
auto input = makeTHCudaTensorFull(
state,
{batchSize, planeSize, inputSizeRow, inputSizeCol});
auto filters = makeTHCudaTensorFull(
state,
{filterSize, planeSize, weightSizeRow, weightSizeCol});
auto output = makeTHCudaTensorFull(
state,
{batchSize, filterSize, outputSizeRow, outputSizeCol});
auto bias = makeTHCudaTensorFull(state, {filterSize});
return THParams(state,
input.release(),
filters.release(),
output.release(),
bias.release(),
0.0f,
buffers);
}
namespace {
bool containsOtherPrimes(long i, const std::vector<long>& primeFactors) {
DCHECK_LE(1, i);
for (auto f : primeFactors) {
while (i % f == 0) {
i /= f;
}
}
return i > 1;
}
// Returns a vector of powers of "primeFactors" greater than i for FFT size
// candidates.
// In the particular case where i is already a power of 2, just returns i.
// @param primeFactors should contain unique prime factors. This method will
// sort the factors for its internal use but will otherwise make no checks on
// whether factors are prime or unique.
vector<long> makePowersGreaterThan(long i, std::vector<long> primeFactors) {
DCHECK_LT(0, i);
// FBFFT does not support sizes < 2, just force size of 2 instead
// TODO (#4948477): Catch this earlier and avoid FFT altogether if
// convolution is really of size 1.
if (i == 1) {i = 2;}
auto msb = folly::findLastSet(i);
auto msbVal = 1 << (msb - 1);
DCHECK_GE(i, msbVal);
DCHECK_LE(i, msbVal << 1);
if (msbVal == i) {
return vector<long>({i});
}
std::sort(primeFactors.begin(), primeFactors.end());
// If not a power of 2, produce all multiples of 2.3.5.7
// in range[i, (msbVal << 1)]
vector<long> result({msbVal << 1, i});
unordered_set<long> candidates;
for (auto p : primeFactors) {
for (auto f = std::max(1L, i / primeFactors.back()); f < i; ++f) {
if (containsOtherPrimes(f, primeFactors)) {
continue;
}
auto val = f * p;
if (val <= i || val >= (msbVal << 1)) {
continue;
}
if (candidates.count(val) > 0) {
continue;
}
candidates.insert(val);
result.push_back(val);
}
}
return result;
}
}
std::vector<long> ProblemSizes::sizes() const {
return std::vector<long>({rows(), cols()});
}
std::vector<CuFFTStrategy> CuFFTStrategy::makeStrategies() const {
std::vector<CuFFTStrategy> res({*this});
{
// Add batch vs many mode
auto copy = res;
res.clear();
for (auto b : {
CuFFTStrategy::MMVersion::batchMM,
CuFFTStrategy::MMVersion::manyMM,
CuFFTStrategy::MMVersion::fbTransposeMM }) {
for (auto strat : copy) {
res.push_back(strat.withMM(b));
}
}
}
{
// Add rows
auto copy = res;
res.clear();
for (auto strat : copy) {
for (auto row : makePowersGreaterThan(strat.sizes.rows(),
vector<long>({2, 3, 5, 7}))) {
auto s = strat;
s.sizes.withExpandedSizeRow(row);
res.push_back(s);
}
}
}
{
// Add cols
auto copy = res;
res.clear();
for (auto strat : copy) {
for (auto col : makePowersGreaterThan(strat.sizes.cols(),
vector<long>({2, 3, 5, 7}))) {
auto s = strat;
s.sizes.withExpandedSizeCol(col);
if (s.maxDataElements() <= CuFFTStrategy::kMaxElements) {
res.push_back(s);
}
}
}
}
{
for (auto b : {
CuFFTStrategy::MMVersion::batchMM,
CuFFTStrategy::MMVersion::manyMM,
CuFFTStrategy::MMVersion::fbTransposeMM
}) {
// Add FBFFT variants
CuFFTStrategy s(*this);
// TODO (#4948477): No need to take the max, just take the msb for each
// size -> FBFFT needs to support rectangular patches first
auto maxSquareSize = std::max(
makePowersGreaterThan(s.sizes.rows(),
vector<long>({2}))[0],
makePowersGreaterThan(s.sizes.cols(),
vector<long>({2}))[0]);
s.sizes.withExpandedSizeRow(maxSquareSize)
.withExpandedSizeCol(maxSquareSize);
res.push_back(s.withMM(b)
.withFFT(FFTParameters::FFTVersion::fbfft));
}
}
return res;
}
std::ostream& operator<<(std::ostream& os, const CuFFTStrategy& s) {
if (s.batchmm()) {
os << "(Batch ";
} else if (s.manymm()) {
os << "(Many ";
} else if (s.fbmm()) {
os << "(FBMM ";
} else {
os << "(Unknown ";
}
if (s.fbfft()) {
os << "FBFFT";
} else if (s.cufft()) {
os << "cuFFT";
} else {
os << "Unknown";
}
os << ") " << s.sizes;
return os;
}
std::ostream& operator<<(std::ostream& os, const ProblemSizes& pbs) {
os << "(b x p x f) = " << pbs.batchSize << "x" <<
pbs.planeSize << "x" << pbs.filterSize << " ";
os << "(input rows x cols) = " << pbs.inputSizeRow << "x" <<
pbs.inputSizeCol << " ";
os << "(filter rows x cols) = " << pbs.weightSizeRow << "x" <<
pbs.weightSizeCol << " ";
os << "(common rows x cols) = " << pbs.rows() << "x" << pbs.cols() << " ";
return os;
}
CuFFTConvolution&
CuFFTConvolution::withInputAndBuffers(
THCState* state,
THCudaTensor* inputTH,
THCudaTensor* inputComplexTH,
THCudaTensor* inputComplexTrTH,
THCudaTensor* inputComplexBufferTH,
cufftHandle* plan,
cufftHandle* planInverse) {
if (convPass_.pass == ConvolutionPass::kUpdateOutput) {
B_ = torchToDeviceTensor<float, 4>(state, inputTH);
BComplex_ = torchToDeviceTensor<float, 5>(state, inputComplexTH);
BComplexT_ = torchToDeviceTensor<float, 5>(state, inputComplexTrTH);
if (inputComplexBufferTH) {
BComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, inputComplexBufferTH);
}
fftPlanB_ = plan;
fftPlanInverseB_ = planInverse;
} else if (convPass_.pass == ConvolutionPass::kAccGradParameters) {
A_ = torchToDeviceTensor<float, 4>(state, inputTH);
AComplex_ = torchToDeviceTensor<float, 5>(state, inputComplexTH);
AComplexT_ = torchToDeviceTensor<float, 5>(state, inputComplexTrTH);
if (inputComplexBufferTH) {
AComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, inputComplexBufferTH);
}
fftPlanA_ = plan;
fftPlanInverseA_ = planInverse;
} else {
DCHECK_EQ(ConvolutionPass::kUpdateGradInput, convPass_.pass);
C_ = torchToDeviceTensor<float, 4>(state, inputTH);
CComplex_ = torchToDeviceTensor<float, 5>(state, inputComplexTH);
CComplexT_ = torchToDeviceTensor<float, 5>(state, inputComplexTrTH);
if (inputComplexBufferTH) {
CComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, inputComplexBufferTH);
}
fftPlanC_ = plan;
}
return *this;
}
CuFFTConvolution&
CuFFTConvolution::withOutputAndBuffers(
THCState* state,
THCudaTensor* outputTH,
THCudaTensor* outputComplexTH,
THCudaTensor* outputComplexTrTH,
THCudaTensor* outputComplexBufferTH,
cufftHandle* plan,
cufftHandle* planInverse) {
if (convPass_.pass == ConvolutionPass::kUpdateOutput) {
C_ = torchToDeviceTensor<float, 4>(state, outputTH);
CComplex_ = torchToDeviceTensor<float, 5>(state, outputComplexTH);
CComplexT_ = torchToDeviceTensor<float, 5>(state, outputComplexTrTH);
if (outputComplexBufferTH) {
CComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, outputComplexBufferTH);
}
fftPlanC_ = plan;
} else if (convPass_.pass == ConvolutionPass::kAccGradParameters) {
B_ = torchToDeviceTensor<float, 4>(state, outputTH);
BComplex_ = torchToDeviceTensor<float, 5>(state, outputComplexTH);
BComplexT_ = torchToDeviceTensor<float, 5>(state, outputComplexTrTH);
if (outputComplexBufferTH) {
BComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, outputComplexBufferTH);
}
fftPlanB_ = plan;
fftPlanInverseB_ = planInverse;
} else {
DCHECK_EQ(ConvolutionPass::kUpdateGradInput, convPass_.pass);
B_ = torchToDeviceTensor<float, 4>(state, outputTH);
BComplex_ = torchToDeviceTensor<float, 5>(state, outputComplexTH);
BComplexT_ = torchToDeviceTensor<float, 5>(state, outputComplexTrTH);
if (outputComplexBufferTH) {
BComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, outputComplexBufferTH);
}
fftPlanB_ = plan;
fftPlanInverseB_ = planInverse;
}
return *this;
}
CuFFTConvolution&
CuFFTConvolution::withFiltersAndBuffers(
THCState* state,
THCudaTensor* filtersTH,
THCudaTensor* filtersComplexTH,
THCudaTensor* filtersComplexTrTH,
THCudaTensor* filtersComplexBufferTH,
cufftHandle* plan,
cufftHandle* planInverse) {
if (convPass_.pass == ConvolutionPass::kUpdateOutput) {
A_ = torchToDeviceTensor<float, 4>(state, filtersTH);
AComplex_ = torchToDeviceTensor<float, 5>(state, filtersComplexTH);
AComplexT_ = torchToDeviceTensor<float, 5>(state, filtersComplexTrTH);
if (filtersComplexBufferTH) {
AComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, filtersComplexBufferTH);
}
fftPlanA_ = plan;
fftPlanInverseA_ = planInverse;
} else if (convPass_.pass == ConvolutionPass::kAccGradParameters) {
C_ = torchToDeviceTensor<float, 4>(state, filtersTH);
CComplex_ = torchToDeviceTensor<float, 5>(state, filtersComplexTH);
CComplexT_ = torchToDeviceTensor<float, 5>(state, filtersComplexTrTH);
if (filtersComplexBufferTH) {
CComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, filtersComplexBufferTH);
}
fftPlanC_ = plan;
} else {
DCHECK_EQ(ConvolutionPass::kUpdateGradInput, convPass_.pass);
A_ = torchToDeviceTensor<float, 4>(state, filtersTH);
AComplex_ = torchToDeviceTensor<float, 5>(state, filtersComplexTH);
AComplexT_ = torchToDeviceTensor<float, 5>(state, filtersComplexTrTH);
if (filtersComplexBufferTH) {
AComplexBuffer_ =
torchToDeviceTensor<float, 5>(state, filtersComplexBufferTH);
}
fftPlanA_ = plan;
fftPlanInverseA_ = planInverse;
}
return *this;
}
namespace {
class CuFFTBuffers {
public:
int currentDevice() {
int currentDevice;
THCudaCheck(cudaGetDevice(¤tDevice));
return currentDevice;
}
static CuFFTBuffers& singleton() {
static CuFFTBuffers bufs;
return bufs;
}
enum struct MatrixName : int {
A = 1,
B,
C
};
// Matrix name is 'A', 'B' or 'C', make it into a type if more needed
template <typename ElemPtr>
ElemPtr* devNamesToAlloc(MatrixName name,
ElemPtr first,
ElemPtr last,
cudaStream_t stream,
cudaEvent_t event) {
DCHECK_LE((int)MatrixName::A, (int)name);
DCHECK_GE((int)MatrixName::C, (int)name);
auto kSize = (last - first + 1) * sizeof(void*);
DCHECK_LT(0, kSize);
DeviceMatrixName key(currentDevice(), (int)name);
// If we need to resize just delete and realloc, this is monotonic in the
// size and only happens a negligible number of times.
bool alloc = true;
if (devNamesToAlloc_.count(key) > 0) {
DCHECK_EQ(1, devNamesToAlloc_.count(key)); // collisions not allowed
if (devNamesToAlloc_[key].size < kSize) {
cudaFree(devNamesToAlloc_[key].devicePtr);
devNamesToAlloc_.erase(key);
} else {
// Enough space, just reuse
alloc = false;
}
}
if (alloc) {
// If first time or realloc, increase size only
devNamesToAlloc_[key].size = kSize;
devNamesToAlloc_[key].devicePtr = nullptr;
CHECK_EQ(cudaSuccess,
cudaMalloc(&devNamesToAlloc_[key].devicePtr,
kSize * sizeof(void*)));
DCHECK(devNamesToAlloc_[key].devicePtr);
}
// Enough size must be allocated on device
DCHECK_LE(kSize, devNamesToAlloc_[key].size);
DCHECK(devNamesToAlloc_[key].devicePtr);
if (stream) {
DCHECK(event);
CHECK_EQ(cudaSuccess,
cudaMemcpyAsync(devNamesToAlloc_[key].devicePtr,
// std::vector storage is contiguous in memory
first,
kSize,
cudaMemcpyHostToDevice,
stream
));
THCudaCheck(cudaEventRecord(event, stream));
} else {
// No stream, pay the price
CHECK_EQ(cudaSuccess,
cudaMemcpy(devNamesToAlloc_[key].devicePtr,
// std::vector storage is contiguous in memory
first,
kSize,
cudaMemcpyHostToDevice
));
}
return (ElemPtr*)(devNamesToAlloc_[key].devicePtr);
}
void reset() {
for (auto& kvp : devNamesToAlloc_) {
cudaFree(kvp.second.devicePtr);
}
devNamesToAlloc_.clear();
}
private:
CuFFTBuffers(const CuFFTBuffers&) = delete;
CuFFTBuffers& operator=(CuFFTBuffers&) = delete;
CuFFTBuffers() {}
~CuFFTBuffers() {
reset();
}
typedef int cudaDevice_t;
typedef int matrixName_t;
struct DevicePointerSize {
size_t size;
void* devicePtr;
};
typedef std::tuple<cudaDevice_t, matrixName_t> DeviceMatrixName;
std::unordered_map<DeviceMatrixName, DevicePointerSize> devNamesToAlloc_;
};
} // namespace
void CuFFTConvolution::reset() {
CuFFTBuffers::singleton().reset();
}
void CuFFTConvolution::allToAllWait() {
// Register every stream to its event and make stream 0 wait for them
// Don't screw up asynchrony
// If no events from above, then just cudaDeviceSynchronize
if (!cudaStreams_.empty() && !cudaEvents_.empty()) {
kWaitsOnAll(0);
allWaitOnK(0);
} else {
THCudaCheck(cudaDeviceSynchronize());
}
THCudaCheck(cudaGetLastError());
}
void CuFFTConvolution::kWaitsOnL(int k, int l) {
// Register stream l to its event and make stream k wait for it
// Don't screw up asynchrony
// If no events from above, then just cudaDeviceSynchronize
if (cudaStreams_.size() > std::max(k, l) &&
cudaEvents_.size() > std::max(k, l)) {
DCHECK_EQ(cudaEvents_.size(), cudaStreams_.size());
CHECK_EQ(cudaSuccess,
cudaEventRecord(getEvent(l), getStream(l)));
CHECK_EQ(cudaSuccess,
cudaStreamWaitEvent(getStream(k), getEvent(l), 0));
} else {
THCudaCheck(cudaDeviceSynchronize());
}
THCudaCheck(cudaGetLastError());
}
void CuFFTConvolution::kWaitsOnAll(int k) {
// Register every stream to its event and make stream k wait for them
// Don't screw up asynchrony
// If no events from above, then just cudaDeviceSynchronize
if (!cudaStreams_.empty() && !cudaEvents_.empty()) {
DCHECK_EQ(cudaEvents_.size(), cudaStreams_.size());
for (int i = 0; i < cudaStreams_.size(); ++i) {
CHECK_EQ(cudaSuccess,
cudaEventRecord(getEvent(i), getStream(i)));
CHECK_EQ(cudaSuccess,
cudaStreamWaitEvent(getStream(k), getEvent(i), 0));
}
} else {
THCudaCheck(cudaDeviceSynchronize());
}
THCudaCheck(cudaGetLastError());
}
void CuFFTConvolution::allWaitOnK(int k) {
// Register every stream to its event and make them wait for stream k
// Don't screw up asynchrony
// If no events from above, then just cudaDeviceSynchronize
if (!cudaStreams_.empty() && !cudaEvents_.empty()) {
DCHECK_EQ(cudaEvents_.size(), cudaStreams_.size());
CHECK_EQ(cudaSuccess,
cudaEventRecord(getEvent(k), getStream(k)));
for (int i = 0; i < cudaStreams_.size(); ++i) {
CHECK_EQ(cudaSuccess,
cudaStreamWaitEvent(getStream(i), getEvent(k), 0));
}
} else {
THCudaCheck(cudaDeviceSynchronize());
}
THCudaCheck(cudaGetLastError());
}
void CuFFTConvolution::CuFFTConvolutionMxMBatch(
const std::vector<cublasHandle_t>& handles) {
CHECK_LE(1, handles.size());
auto handle = handles[0];
auto& A_ = AComplexT_;
auto& B_ = BComplexT_;
auto& C_ = CComplexT_;
// All have same row / cols in Fourier domain, at this point, transposition
// must have occurred
const int kNumRows = A_.getSize(0);
const int kNumCols = A_.getSize(1);
// Complex storage already exploits hermitian symmetry along cols
const auto kNumHermitianCols = kNumCols;
DCHECK_EQ(kNumRows, B_.getSize(0));
DCHECK_EQ(kNumCols, B_.getSize(1));
DCHECK_EQ(kNumRows, C_.getSize(0));
DCHECK_EQ(kNumCols, C_.getSize(1));
std::vector<const cuFloatComplex*> APtrVec;
std::vector<const cuFloatComplex*> BPtrVec;
std::vector<cuFloatComplex*> CPtrVec;
for (int row = 0; row < kNumRows; ++row) {
for (int col = 0; col < kNumHermitianCols; ++col) {
auto APtr = A_[0].dataAs<cuFloatComplex>();
APtr += (row * kNumCols + col) * A_.getSize(2) * A_.getSize(3);
APtrVec.push_back(APtr);
auto BPtr = B_[0].dataAs<cuFloatComplex>();
BPtr += (row * kNumCols + col) * B_.getSize(2) * B_.getSize(3);
BPtrVec.push_back(BPtr);
auto CPtr = C_[0].dataAs<cuFloatComplex>();
CPtr += (row * kNumCols + col) * C_.getSize(2) * C_.getSize(3);
CPtrVec.push_back(CPtr);
}
}
auto& buf = CuFFTBuffers::singleton();
// Even seemingly insignificant thrust host->device ptr copies can cause
// painful synchronizations
auto APtrCtrDevice = (const cuComplex**)
buf.devNamesToAlloc(CuFFTBuffers::MatrixName::A, &APtrVec.front(),
&APtrVec.back(), getStream(0), getEvent(0));
auto BPtrCtrDevice = (const cuComplex**)
buf.devNamesToAlloc(CuFFTBuffers::MatrixName::B, &BPtrVec.front(),
&BPtrVec.back(), getStream(1), getEvent(1));
auto CPtrCtrDevice = (cuComplex**)
buf.devNamesToAlloc(CuFFTBuffers::MatrixName::C, &CPtrVec.front(),
&CPtrVec.back(), getStream(2), getEvent(2));
DCHECK_EQ(kNumRows * kNumHermitianCols, APtrVec.size());
// Synchronize streams
if (!cudaStreams_.empty() && !cudaEvents_.empty()) {
for (int i = 0; i < 3; ++i) {
CHECK_EQ(cudaSuccess,
cudaStreamWaitEvent(getStream(0), getEvent(i), 0));
}
// And run MxM on stream 0
cublasSetStream(handle, getStream(0));
}
auto zero = make_cuComplex(0.0f, 0.0f);
auto res =
cublasCgemmBatched(handle,
transA_,
transB_,
C_.getSize(3),
C_.getSize(2),
mmReductionSize_,
&norm_,
&APtrCtrDevice[0],
fastestVaryingSizeA_,
&BPtrCtrDevice[0],
fastestVaryingSizeB_,
&zero,
&CPtrCtrDevice[0],
C_.getSize(3),
kNumRows * kNumHermitianCols
);
DCHECK_EQ(CUBLAS_STATUS_SUCCESS, res);
}
void CuFFTConvolution::CuFFTConvolutionMxMMany() {
auto& A_ = AComplexT_;
auto& B_ = BComplexT_;
auto& C_ = CComplexT_;
// All have same row / cols in Fourier domain, at this point, permutation
// has occurred
const int kNumRows = A_.getSize(0);
const int kNumCols = A_.getSize(1);
// Complex storage already exploits hermitian symmetry along cols
const auto kNumHermitianCols = kNumCols;
DCHECK_EQ(kNumRows, B_.getSize(0));
DCHECK_EQ(kNumCols, B_.getSize(1));
DCHECK_EQ(kNumRows, C_.getSize(0));
DCHECK_EQ(kNumCols, C_.getSize(1));
// If you want this version you need as many streams as you have handles
CHECK(!cudaStreams_.empty());
CHECK_EQ(cudaStreams_.size(), cublasHandles_.size());
{
const auto zero = make_cuComplex(0.0f, 0.0f);
for (int i = 0; i < cudaStreams_.size(); ++i) {
{
// Prepare async cgemm calls
auto res =
cublasSetStream(cublasHandles_[i], getStream(i));
DCHECK_EQ(CUBLAS_STATUS_SUCCESS, res);
}
}
for (int row = 0; row < kNumRows; ++row) {
for (int col = 0; col < kNumHermitianCols; ++col) {
auto ind = (row * kNumHermitianCols + col) % cudaStreams_.size();
auto APtr = A_[0].dataAs<cuFloatComplex>();
APtr += (row * kNumCols + col) * A_.getSize(2) * A_.getSize(3);
auto BPtr = B_[0].dataAs<cuFloatComplex>();
BPtr += (row * kNumCols + col) * B_.getSize(2) * B_.getSize(3);
auto CPtr = C_[0].dataAs<cuFloatComplex>();
CPtr += (row * kNumCols + col) * C_.getSize(2) * C_.getSize(3);
auto res = cublasCgemm(cublasHandles_[ind],
transA_,
transB_,
C_.getSize(3),
C_.getSize(2),
mmReductionSize_,
&norm_,
APtr,
fastestVaryingSizeA_,
BPtr,
fastestVaryingSizeB_,
&zero,
CPtr,
C_.getSize(3)
);
DCHECK_EQ(CUBLAS_STATUS_SUCCESS, res);
}
}
}
}
void CuFFTConvolution::CuFFTConvolutionMxM() {
if (strategy_->batchmm()) {
// Create local handle if not passed during configuration
// If no handle from above this will implicitly create a synchronization on
// destruction.
auto localHandles = cublasHandles_;
if (localHandles.empty()) {
if (cudaStreams_.empty()) {
localHandles.push_back(cublasHandle_t());
cublasCreate(&(localHandles.back()));
} else {
for (int i = 0; i < cudaStreams_.size(); ++i) {
localHandles.push_back(cublasHandle_t());
cublasCreate(&(localHandles.back()));
}
}
} else {
// Need one handle per stream
CHECK_EQ(cudaStreams_.size(), cublasHandles_.size());
localHandles = cublasHandles_;
}
SCOPE_EXIT {
if (cublasHandles_.empty()) {
for (auto& h : localHandles) {
cublasDestroy(h);
}
}
};
CuFFTConvolutionMxMBatch(localHandles);
} else if (strategy_->manymm()) {
// If you want this version you must set up streams properly
CuFFTConvolutionMxMMany();
} else if (strategy_->fbmm()) {
// A, B and C nomenclature is relative to cuBLAS' column-major.
// In row-major fbmm, this is reversed.
if (convPass_.pass == ConvolutionPass::kUpdateOutput) {
transposeMM<5, false, true, false>(
BComplex_, AComplex_, CComplex_, norm_.x, getStream(0));
} else if (convPass_.pass == ConvolutionPass::kUpdateGradInput) {
transposeMM<5, false, false, false>(
BComplex_, AComplex_, CComplex_, norm_.x, getStream(0));
} else if (convPass_.pass == ConvolutionPass::kAccGradParameters) {
transposeMM<5, true, false, false>(
BComplex_, AComplex_, CComplex_, norm_.x, getStream(0));
} else {
throw std::runtime_error("Invalid pass for CuFFTConvolution");
}
} else {
throw std::runtime_error("Invalid MM mode for CuFFTConvolution");
}
}
void CuFFTConvolution::run() {
if (!strategy_) {
strategy_ = &CuFFTStrategy::defaultStrategy();
}
DCHECK(nullptr != A_.data());
DCHECK(nullptr != B_.data());
DCHECK(nullptr != C_.data());
DCHECK(nullptr != AComplex_.data());
DCHECK(nullptr != BComplex_.data());
DCHECK(nullptr != CComplex_.data());
DCHECK(strategy_->fbmm() || nullptr != AComplexT_.data());
DCHECK(strategy_->fbmm() || nullptr != BComplexT_.data());
DCHECK(strategy_->fbmm() || nullptr != CComplexT_.data());
VLOG(2) << A_ << " @ " << A_.data()
<< AComplex_ << " @ " << AComplex_.data()
<< AComplexT_ << " @ " << AComplexT_.data();
VLOG(2) << B_ << " @ " << B_.data()
<< BComplex_ << " @ " << BComplex_.data()
<< BComplexT_ << " @ " << BComplexT_.data();
VLOG(2) << C_ << " @ " << C_.data()
<< CComplex_ << " @ " << CComplex_.data()
<< CComplexT_ << " @ " << CComplexT_.data();
// 1. Setup MxM properties from pass
if (convPass_.pass == ConvolutionPass::kUpdateOutput) {
mmReductionSize_ = A_.getSize(1); // numInputPlanes
fastestVaryingSizeA_ = A_.getSize(1); // numInputPlanes
fastestVaryingSizeB_ = B_.getSize(1); // numInputPlanes
transA_ = CUBLAS_OP_C;
transB_ = CUBLAS_OP_N;
} else if (convPass_.pass == ConvolutionPass::kAccGradParameters) {
mmReductionSize_ = A_.getSize(0); // numBatches
fastestVaryingSizeA_ = A_.getSize(1); // numInputPlanes
fastestVaryingSizeB_ = B_.getSize(1); // numFilters
transA_ = CUBLAS_OP_N;
transB_ = CUBLAS_OP_C;
} else {
DCHECK_EQ(ConvolutionPass::kUpdateGradInput, convPass_.pass);
mmReductionSize_ = A_.getSize(0); // numFilters
fastestVaryingSizeA_ = A_.getSize(1); // numInputPlanes
fastestVaryingSizeB_ = B_.getSize(1); // numFilters
transA_ = CUBLAS_OP_N;
transB_ = CUBLAS_OP_N;
}
if (strategy_->cufft()) {
DCHECK_EQ(A_.getSize(2), B_.getSize(2));
DCHECK_EQ(A_.getSize(3), B_.getSize(3));
DCHECK_EQ(C_.getSize(2), B_.getSize(2));
DCHECK_EQ(C_.getSize(3), B_.getSize(3));
}
norm_ = (strategy_->cufft()) ?
make_cuComplex(scale_ / (A_.getSize(2) * A_.getSize(3)), 0.0f) :
make_cuComplex(scale_ / (AComplex_.getSize(3) * AComplex_.getSize(3)),
0.0f);
cudaStream_t s0 = getStream(0);
cudaStream_t s1 = getStream(1);
auto handle0 = getCircular(cublasHandles_, 0);
// FFT followed by transpose in same stream
if (strategy_->cufft()) {
fft2d<2>(A_, AComplex_, FFTParameters().forward(), fftPlanA_, s0);
} else {
auto dA = A_.template downcastOuter<3>();
auto dAC = AComplex_.template downcastOuter<4>();
facebook::cuda::DeviceTensor<float, 4> dACB;
facebook::cuda::DeviceTensor<float, 4>* pdACB;
if (AComplexBuffer_.data()) {
dACB = AComplexBuffer_.template downcastOuter<4>();
pdACB = &dACB;
} else {
pdACB = nullptr;
}
fbfft2dHost<1>(dA,
dAC,
pdACB,
FFTParameters().withFbfft().forward(),
s0);
}
if (!strategy_->fbmm()) {
// Transpose A_ (? ? y x) -> (y x ? ?) (row-major formulation)
transposeAsComplex(AComplex_, AComplexT_, 2, true, handle0, s0);
}
auto handle1 = getCircular(cublasHandles_, 1);
// FFT followed by transpose in same stream
if (strategy_->cufft()) {
fft2d<2>(B_, BComplex_, FFTParameters().forward(), fftPlanB_, s1);
} else {
auto dB = B_.template downcastOuter<3>();
auto dBC = BComplex_.template downcastOuter<4>();
facebook::cuda::DeviceTensor<float, 4> dBCB;
facebook::cuda::DeviceTensor<float, 4>* pdBCB;
if (BComplexBuffer_.data()) {
dBCB = BComplexBuffer_.template downcastOuter<4>();
pdBCB = &dBCB;
} else {
pdBCB = nullptr;
}
fbfft2dHost<1>(dB,
dBC,
pdBCB,
FFTParameters().withFbfft().forward(),
s1);
}
if (!strategy_->fbmm()) {
// Transpose A_ (? ? y x) -> (y x ? ?) (row-major formulation)
transposeAsComplex(BComplex_, BComplexT_, 2, true, handle1, s1);
// Here, both CComplex_ and CComplexT_ contain garbage that we will
// overwrite and that we preemptively size to (y x ? ?)..
// This is just resizing, not actual transposition since we don't need to
// move garbage data anywhere.
std::vector<int> perm({2, 3, 0, 1, 4});
// This is a shallow permutation at the CudaTensor level, no data is moved.
CComplex_.permuteDims(perm);
CComplexT_.permuteDims(perm);
}
if (strategy_->manymm()) {
allWaitOnK(0);
allWaitOnK(1);
} else {
kWaitsOnL(0, 1);
}
// Run MxM
CuFFTConvolutionMxM();
if (strategy_->manymm()) {
kWaitsOnAll(0);
}
cudaStream_t s = getStream(0);
if (!strategy_->fbmm()) {
auto handle = getCircular(cublasHandles_, 0);
// Transpose followed by IFFT in same stream s0 as the MxM
// Transpose input (y x ? ?) -> (? ? y x) (row-major formulation)
transposeAsComplex(CComplexT_, CComplex_, 2, true, handle, s);
}
if (strategy_->cufft()) {
fft2d<2>(C_, CComplex_, FFTParameters().inverse().normalize(false),
fftPlanC_, s);
} else {
auto dC = C_.template downcastOuter<3>();
auto dCC = CComplex_.template downcastOuter<4>();
facebook::cuda::DeviceTensor<float, 4> dCCB;
facebook::cuda::DeviceTensor<float, 4>* pdCCB;
if (CComplexBuffer_.data()) {
dCCB = CComplexBuffer_.template downcastOuter<4>();
pdCCB = &dCCB;
} else {
pdCCB = nullptr;
}
fbfft2dHost<1>(dC,
dCC,
pdCCB,
FFTParameters().withFbfft().inverse().normalize(false),
s);
}
// Everything is transitively synchronized on stream0 at this point
}
} } } // namespace
| {
"pile_set_name": "Github"
} |
using Aardvark.Base;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Aardvark.Tests
{
[TestFixture]
public static class EuclideanTests
{
[Test]
public static void FromM33dAndV3d()
=> TrafoTesting.GenericTest(rnd =>
{
var a = TrafoTesting.GetRandomEuclidean(rnd);
var m = (M33d)a.Rot;
var t = a.Trans;
var restored = Euclidean3d.FromM33dAndV3d(m, t);
TrafoTesting.AreEqual(a, restored);
});
[Test]
public static void FromM34d()
=> TrafoTesting.GenericConversionTest(TrafoTesting.GetRandomEuclidean, a => (M34d)a, b => Euclidean3d.FromM34d(b));
[Test]
public static void FromM44d()
=> TrafoTesting.GenericConversionTest(TrafoTesting.GetRandomEuclidean, a => (M44d)a, b => Euclidean3d.FromM44d(b));
[Test]
public static void FromSimilarity3d()
=> TrafoTesting.GenericConversionTest(TrafoTesting.GetRandomEuclidean, a => (Similarity3d)a, b => Euclidean3d.FromSimilarity3d(b));
[Test]
public static void FromAffine3d()
=> TrafoTesting.GenericConversionTest(TrafoTesting.GetRandomEuclidean, a => (Affine3d)a, b => Euclidean3d.FromAffine3d(b));
[Test]
public static void FromTrafo3d()
=> TrafoTesting.GenericConversionTest(TrafoTesting.GetRandomEuclidean, a => (Trafo3d)a, b => Euclidean3d.FromTrafo3d(b));
[Test]
public static void Comparison()
=> TrafoTesting.GenericComparisonTest(TrafoTesting.GetRandomEuclidean, a => new Euclidean3d(a.Rot, a.Trans + V3d.OII));
[Test]
public static void InverseTest()
=> TrafoTesting.GenericTest(rnd =>
{
var e = TrafoTesting.GetRandomEuclidean(rnd);
var p = rnd.UniformV3d() * rnd.UniformInt(1000);
var q = e.TransformPos(p);
// Inverse property
var res = e.Inverse.TransformPos(q);
// Invert method
Euclidean.Invert(ref e);
var res2 = e.TransformPos(q);
TrafoTesting.AreEqual(p, res);
TrafoTesting.AreEqual(p, res2);
});
[Test]
public static void Multiplication3x3Test()
=> TrafoTesting.GenericMatrixMultiplicationTest<Euclidean3d, M33d, M34d>(
rnd => TrafoTesting.GetRandomEuclidean(rnd, false),
Euclidean.TransformPos,
Mat.Transform,
Mat.TransformPos,
(a, v) => (a * new V4d(v, 1)).XYZ,
(m, v) => m * v,
(m, v) => m * new V4d(v, 1));
[Test]
public static void Multiplication3x4Test()
=> TrafoTesting.Generic3x4MultiplicationTest(
TrafoTesting.GetRandomEuclidean,
Euclidean.TransformPos,
(a, v) => (a * new V4d(v, 1)).XYZ);
[Test]
public static void Multiplication4x4Test()
=> TrafoTesting.Generic4x4MultiplicationTest(
TrafoTesting.GetRandomEuclidean,
Euclidean.TransformPos,
(a, v) => (a * new V4d(v, 1)).XYZ);
[Test]
public static void MultiplicationFull4x4Test()
=> TrafoTesting.GenericFull4x4MultiplicationTest(TrafoTesting.GetRandomEuclidean);
[Test]
public static void ConsistentWithMatrixRotationAndShiftTest()
=> TrafoTesting.GenericTest(rnd =>
{
var trans = rnd.UniformV3d() * 10;
var axis = rnd.UniformV3dDirection();
var angle = rnd.UniformDouble() * Constant.PiTimesTwo;
var m = M44d.Translation(trans) * M44d.Rotation(axis, angle);
var e = new Euclidean3d(Rot3d.Rotation(axis, angle), trans);
var p = rnd.UniformV3d() * rnd.UniformInt(1000);
var res = m.TransformPos(p);
var res2 = e.TransformPos(p);
TrafoTesting.AreEqual(res, res2);
});
[Test]
public static void MultiplicationEuclideanTest()
=> TrafoTesting.GenericMultiplicationTest<Euclidean3d, Euclidean3d, Euclidean3d>(TrafoTesting.GetRandomEuclidean, TrafoTesting.GetRandomEuclidean, Euclidean.TransformPos);
[Test]
public static void MultiplicationRotTest()
=> TrafoTesting.GenericMultiplicationTest<Euclidean3d, Rot3d, Euclidean3d>(TrafoTesting.GetRandomEuclidean, TrafoTesting.GetRandomRot3, Euclidean.TransformPos);
[Test]
public static void MultiplicationShiftTest()
=> TrafoTesting.GenericMultiplicationTest<Euclidean3d, Shift3d, Euclidean3d>(TrafoTesting.GetRandomEuclidean, TrafoTesting.GetRandomShift3, Euclidean.TransformPos);
[Test]
public static void MultiplicationScaleTest()
=> TrafoTesting.GenericMultiplicationTest<Euclidean3d, Scale3d, Affine3d>(TrafoTesting.GetRandomEuclidean, TrafoTesting.GetRandomScale3, Affine.TransformPos);
[Test]
public static void ToStringAndParse()
=> TrafoTesting.GenericToStringAndParseTest(TrafoTesting.GetRandomEuclidean, Euclidean3d.Parse);
}
}
| {
"pile_set_name": "Github"
} |
# From http://lists.x.org/archives/xorg-announce/2015-April/002567.html
sha256 e5585361bb8b6a05bb814a8d0e444ee93e0f00180881d3070aff4571e97f67c6 xcmsdb-1.0.5.tar.bz2
# Locally computed
sha256 c3bd4ac91beb08fee5272b17a3ddee8d2791cc5eaee5bce5271042a45fa4fa6a COPYING
| {
"pile_set_name": "Github"
} |
# frozen_string_literal: true
require_relative "helper"
class TestPipeliningCommands < Minitest::Test
include Helper::Client
def test_bulk_commands
r.pipelined do
r.lpush "foo", "s1"
r.lpush "foo", "s2"
end
assert_equal 2, r.llen("foo")
assert_equal "s2", r.lpop("foo")
assert_equal "s1", r.lpop("foo")
end
def test_multi_bulk_commands
r.pipelined do
r.mset("foo", "s1", "bar", "s2")
r.mset("baz", "s3", "qux", "s4")
end
assert_equal "s1", r.get("foo")
assert_equal "s2", r.get("bar")
assert_equal "s3", r.get("baz")
assert_equal "s4", r.get("qux")
end
def test_bulk_and_multi_bulk_commands_mixed
r.pipelined do
r.lpush "foo", "s1"
r.lpush "foo", "s2"
r.mset("baz", "s3", "qux", "s4")
end
assert_equal 2, r.llen("foo")
assert_equal "s2", r.lpop("foo")
assert_equal "s1", r.lpop("foo")
assert_equal "s3", r.get("baz")
assert_equal "s4", r.get("qux")
end
def test_multi_bulk_and_bulk_commands_mixed
r.pipelined do
r.mset("baz", "s3", "qux", "s4")
r.lpush "foo", "s1"
r.lpush "foo", "s2"
end
assert_equal 2, r.llen("foo")
assert_equal "s2", r.lpop("foo")
assert_equal "s1", r.lpop("foo")
assert_equal "s3", r.get("baz")
assert_equal "s4", r.get("qux")
end
def test_pipelined_with_an_empty_block
r.pipelined do
end
assert_equal 0, r.dbsize
end
def test_returning_the_result_of_a_pipeline
result = r.pipelined do
r.set "foo", "bar"
r.get "foo"
r.get "bar"
end
assert_equal ["OK", "bar", nil], result
end
def test_assignment_of_results_inside_the_block
r.pipelined do
@first = r.sadd("foo", 1)
@second = r.sadd("foo", 1)
end
assert_equal true, @first.value
assert_equal false, @second.value
end
# Although we could support accessing the values in these futures,
# it doesn't make a lot of sense.
def test_assignment_of_results_inside_the_block_with_errors
assert_raises(Redis::CommandError) do
r.pipelined do
r.doesnt_exist
@first = r.sadd("foo", 1)
@second = r.sadd("foo", 1)
end
end
assert_raises(Redis::FutureNotReady) { @first.value }
assert_raises(Redis::FutureNotReady) { @second.value }
end
def test_assignment_of_results_inside_a_nested_block
r.pipelined do
@first = r.sadd("foo", 1)
r.pipelined do
@second = r.sadd("foo", 1)
end
end
assert_equal true, @first.value
assert_equal false, @second.value
end
def test_futures_raise_when_confused_with_something_else
r.pipelined do
@result = r.sadd("foo", 1)
end
assert_raises(NoMethodError) { @result.to_s }
end
def test_futures_raise_when_trying_to_access_their_values_too_early
r.pipelined do
assert_raises(Redis::FutureNotReady) do
r.sadd("foo", 1).value
end
end
end
def test_futures_raise_when_command_errors_and_needs_transformation
assert_raises(Redis::CommandError) do
r.pipelined do
@result = r.zrange("a", "b", 5, with_scores: true)
end
end
end
def test_futures_warn_when_tested_for_equality
r.pipelined do
@result = r.sadd("foo", 1)
end
assert_output(nil, /deprecated/) do
@result == 1
end
end
def test_futures_can_be_identified
r.pipelined do
@result = r.sadd("foo", 1)
end
assert_equal true, @result.is_a?(Redis::Future)
assert_equal true, @result.is_a?(::BasicObject)
assert_equal Redis::Future, @result.class
end
def test_returning_the_result_of_an_empty_pipeline
result = r.pipelined do
end
assert_equal [], result
end
def test_nesting_pipeline_blocks
r.pipelined do
r.set("foo", "s1")
r.pipelined do
r.set("bar", "s2")
end
end
assert_equal "s1", r.get("foo")
assert_equal "s2", r.get("bar")
end
def test_info_in_a_pipeline_returns_hash
result = r.pipelined do
r.info
end
assert result.first.is_a?(Hash)
end
def test_config_get_in_a_pipeline_returns_hash
result = r.pipelined do
r.config(:get, "*")
end
assert result.first.is_a?(Hash)
end
def test_hgetall_in_a_pipeline_returns_hash
r.hmset("hash", "field", "value")
result = r.pipelined do
r.hgetall("hash")
end
assert_equal result.first, { "field" => "value" }
end
def test_keys_in_a_pipeline
r.set("key", "value")
result = r.pipelined do
r.keys("*")
end
assert_equal ["key"], result.first
end
def test_pipeline_yields_a_connection
r.pipelined do |p|
p.set("foo", "bar")
end
assert_equal "bar", r.get("foo")
end
def test_pipeline_select
r.select 1
r.set("db", "1")
r.pipelined do |p|
p.select 2
p.set("db", "2")
end
r.select 1
assert_equal "1", r.get("db")
r.select 2
assert_equal "2", r.get("db")
end
def test_pipeline_select_client_db
r.select 1
r.pipelined do |p2|
p2.select 2
end
assert_equal 2, r._client.db
end
def test_nested_pipeline_select_client_db
r.select 1
r.pipelined do |p2|
p2.select 2
p2.pipelined do |p3|
p3.select 3
end
end
assert_equal 3, r._client.db
end
def test_pipeline_interrupt_preserves_client
original = r._client
Redis::Pipeline.stubs(:new).raises(Interrupt)
assert_raises(Interrupt) { r.pipelined {} }
assert_equal r._client, original
end
end
| {
"pile_set_name": "Github"
} |
<?php
/**
* The template for the content bottom widget areas on posts and pages
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
if ( ! is_active_sidebar( 'sidebar-2' ) && ! is_active_sidebar( 'sidebar-3' ) ) {
return;
}
// If we get this far, we have widgets. Let's do this.
?>
<aside id="content-bottom-widgets" class="content-bottom-widgets" role="complementary">
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div class="widget-area">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div><!-- .widget-area -->
<?php endif; ?>
<?php if ( is_active_sidebar( 'sidebar-3' ) ) : ?>
<div class="widget-area">
<?php dynamic_sidebar( 'sidebar-3' ); ?>
</div><!-- .widget-area -->
<?php endif; ?>
</aside><!-- .content-bottom-widgets -->
| {
"pile_set_name": "Github"
} |
# Example for use of GNU gettext.
# This file is in the public domain.
#
# Makefile configuration - processed by automake.
# General automake options.
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
# The list of subdirectories containing Makefiles.
SUBDIRS = m4 po
# The list of programs that are built.
bin_SCRIPTS = hello
# Compilation of Common Lisp programs.
SUFFIXES = .lisp .fas
.lisp.fas:
clisp -norc -q -c $< -o $@
CLEANFILES = *.fas *.lib
# Making a Common Lisp program executable.
hello: hello.fas
(echo '#!@CLISP@'; cat $<) > $@
chmod a+x $@
CLEANFILES += hello
# Additional files to be distributed.
EXTRA_DIST = autogen.sh autoclean.sh
| {
"pile_set_name": "Github"
} |
.TH dbe 1 "ndbm(3) EDITOR"
.SH NAME
dbe \- Edit a ndbm(3) database
.SH USAGE
dbe <database> [-m r|w|rw] [-crtvx] -a|-d|-f|-F|-s [<key> [<content>]]
.SH DESCRIPTION
\fIdbme\fP operates on ndbm(3) databases.
It can be used to create them, look at them or change them.
When specifying the value of a key or the content of its associated entry,
\\nnn, \\0, \\n, \\t, \\f and \\r are interpreted as usual.
When displaying key/content pairs, non-printable characters are displayed
using the \\nnn notation.
.SH OPTIONS
.IP -a
List all entries in the database.
.IP -c
Create the database if it does not exist.
.IP -d
Delete the entry associated with the specified key.
.IP -f
Fetch and display the entry associated with the specified key.
.IP -F
Fetch and display all the entries whose key match the specified
regular-expression
.IP "-m r|w|rw"
Open the database in read-only, write-only or read-write mode
.IP -r
Replace the entry associated with the specified key if it already exists.
See option -s.
.IP -s
Store an entry under a specific key.
An error occurs if the key already exists and the option -r was not specified.
.IP -t
Re-initialize the database before executing the command.
.IP -v
Verbose mode.
Confirm stores and deletions.
.IP -x
If option -x is used with option -c, then if the database already exists,
an error occurs.
This can be used to implement a simple exclusive access locking mechanism.
.SH SEE ALSO
ndbm(3)
.SH AUTHOR
[email protected]
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.