code
stringlengths
4
991k
repo_name
stringlengths
6
116
path
stringlengths
4
249
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
4
991k
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
# # $Id$ # # Copyright (c) 1999, 2008 Daniel J. Gregor, Jr., All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY DANIEL J. GREGOR, JR. ``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 DANIEL J. GREGOR, JR. 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. # # Homepage for OpenNMS: # http://www.opennms.org/ # # You can get the source at: # XXX fill this in XXX # all: build package build: ( cd .. && ./compile.pl clean && ./compile.pl -Dopennms.home=/opt/opennms install ) package: ( cd .. && ./assemble.pl clean && ./assemble.pl -Dopennms.home=/opt/opennms -Dbuild.profile=full -Denable.snapshots=true -DupdatePolicy=always install ) ${MAKE} -f opennms.Makefile package
rdkgit/opennms
solaris/Makefile
Makefile
agpl-3.0
1,763
[ 30522, 1001, 1001, 1002, 8909, 1002, 1001, 1001, 9385, 1006, 1039, 1007, 2639, 1010, 2263, 3817, 1046, 1012, 16973, 1010, 3781, 1012, 1010, 2035, 2916, 9235, 1012, 1001, 1001, 25707, 1998, 2224, 1999, 3120, 1998, 12441, 3596, 1010, 2007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.dolphinemu.dolphinemu.features.settings.ui.viewholder; import android.view.View; import android.widget.TextView; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.model.view.SliderSetting; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; public final class SliderViewHolder extends SettingViewHolder { private SliderSetting mItem; private TextView mTextSettingName; private TextView mTextSettingDescription; public SliderViewHolder(View itemView, SettingsAdapter adapter) { super(itemView, adapter); } @Override protected void findViews(View root) { mTextSettingName = (TextView) root.findViewById(R.id.text_setting_name); mTextSettingDescription = (TextView) root.findViewById(R.id.text_setting_description); } @Override public void bind(SettingsItem item) { mItem = (SliderSetting) item; mTextSettingName.setText(item.getNameId()); if (item.getDescriptionId() > 0) { mTextSettingDescription.setText(item.getDescriptionId()); } } @Override public void onClick(View clicked) { getAdapter().onSliderClick(mItem); } }
riking/dolphin
Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java
Java
gpl-2.0
1,213
[ 30522, 7427, 8917, 1012, 17801, 6633, 2226, 1012, 17801, 6633, 2226, 1012, 2838, 1012, 10906, 1012, 21318, 1012, 3193, 14528, 1025, 12324, 11924, 1012, 3193, 1012, 3193, 1025, 12324, 11924, 1012, 15536, 24291, 1012, 3793, 8584, 1025, 12324, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_ #define CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_ #include "base/basictypes.h" class ChromeProxyConfigService; class CommandLine; class PrefProxyConfigTrackerImpl; class PrefService; #if defined(OS_CHROMEOS) namespace chromeos { class ProxyConfigServiceImpl; } #endif // defined(OS_CHROMEOS) namespace net { class NetLog; class ProxyConfigService; class ProxyService; class URLRequestContext; } // namespace net class ProxyServiceFactory { public: // Creates a ProxyConfigService that delivers the system preferences // (or the respective ChromeOS equivalent). // The ChromeProxyConfigService returns "pending" until it has been informed // about the proxy configuration by calling its UpdateProxyConfig method. static ChromeProxyConfigService* CreateProxyConfigService(); #if defined(OS_CHROMEOS) static chromeos::ProxyConfigServiceImpl* CreatePrefProxyConfigTracker( PrefService* pref_service); #else static PrefProxyConfigTrackerImpl* CreatePrefProxyConfigTracker( PrefService* pref_service); #endif // defined(OS_CHROMEOS) // Create a proxy service according to the options on command line. static net::ProxyService* CreateProxyService( net::NetLog* net_log, net::URLRequestContext* context, net::ProxyConfigService* proxy_config_service, const CommandLine& command_line); private: DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyServiceFactory); }; #endif // CHROME_BROWSER_NET_PROXY_SERVICE_FACTORY_H_
nacl-webkit/chrome_deps
chrome/browser/net/proxy_service_factory.h
C
bsd-3-clause
1,691
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2249, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#! /usr/bin/env python3 # suff # # show different suffixes amongst arguments import sys def main(): files = sys.argv[1:] suffixes = {} for filename in files: suff = getsuffix(filename) suffixes.setdefault(suff, []).append(filename) for suff, filenames in sorted(suffixes.items()): print(repr(suff), len(filenames)) def getsuffix(filename): name, sep, suff = filename.rpartition('.') return sep + suff if sep else '' if __name__ == '__main__': main()
Orav/kbengine
kbe/src/lib/python/Tools/scripts/suff.py
Python
lgpl-3.0
536
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 18750, 2509, 1001, 10514, 4246, 1001, 1001, 2265, 2367, 16809, 2229, 5921, 9918, 12324, 25353, 2015, 13366, 2364, 1006, 1007, 1024, 6764, 1027, 25353, 2015, 1012, 12098, 2290...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#pragma once #include "SceneNode.h" #include "D3dShader.h" #include "Geometry.h" namespace engiX { class D3dGeneratedMeshNode : public SceneNode { public: typedef std::vector<D3D11Vertex_PositionColored> VertexList; typedef std::vector<UINT> IndexList; D3dGeneratedMeshNode(_In_ ActorID actorId, _In_ const GeometryGenerator::MeshData& mesh, _In_ Color3 color, _In_ GameScene* pScene); ~D3dGeneratedMeshNode(); HRESULT OnPreRender(); HRESULT OnConstruct(); void OnRender(); ID3D11Buffer* VertextBuffer() { return m_pVertexBuffer; } ID3D11Buffer* IndexBuffer() { return m_pIndexBuffer; } size_t VertexCount() const { return m_vertices.size(); } size_t IndexCount() const { return m_indices.size(); } bool RenderWireframe() const { return m_rasterizeDesc.FillMode == D3D11_FILL_WIREFRAME; } bool RenderBackface() const { return m_rasterizeDesc.CullMode != D3D11_CULL_BACK; } protected: VertexList m_vertices; IndexList m_indices; D3dShader m_shader; ID3D11Buffer* m_pVertexBuffer; ID3D11Buffer* m_pIndexBuffer; D3D11_RASTERIZER_DESC m_rasterizeDesc; ID3D11RasterizerState* m_pRasterizeState; }; }
MHesham/engiX
src/engiX/view/D3dGeneratedMeshNode.h
C
apache-2.0
1,279
[ 30522, 1001, 10975, 8490, 2863, 2320, 1001, 2421, 1000, 3496, 3630, 3207, 1012, 1044, 1000, 1001, 2421, 1000, 1040, 29097, 7377, 4063, 1012, 1044, 1000, 1001, 2421, 1000, 10988, 1012, 1044, 1000, 3415, 15327, 25540, 7646, 1063, 2465, 1040, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
*> \brief \b DGEJSV * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DGEJSV + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgejsv.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgejsv.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgejsv.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DGEJSV( JOBA, JOBU, JOBV, JOBR, JOBT, JOBP, * M, N, A, LDA, SVA, U, LDU, V, LDV, * WORK, LWORK, IWORK, INFO ) * * .. Scalar Arguments .. * IMPLICIT NONE * INTEGER INFO, LDA, LDU, LDV, LWORK, M, N * .. * .. Array Arguments .. * DOUBLE PRECISION A( LDA, * ), SVA( N ), U( LDU, * ), V( LDV, * ), * $ WORK( LWORK ) * INTEGER IWORK( * ) * CHARACTER*1 JOBA, JOBP, JOBR, JOBT, JOBU, JOBV * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DGEJSV computes the singular value decomposition (SVD) of a real M-by-N *> matrix [A], where M >= N. The SVD of [A] is written as *> *> [A] = [U] * [SIGMA] * [V]^t, *> *> where [SIGMA] is an N-by-N (M-by-N) matrix which is zero except for its N *> diagonal elements, [U] is an M-by-N (or M-by-M) orthonormal matrix, and *> [V] is an N-by-N orthogonal matrix. The diagonal elements of [SIGMA] are *> the singular values of [A]. The columns of [U] and [V] are the left and *> the right singular vectors of [A], respectively. The matrices [U] and [V] *> are computed and stored in the arrays U and V, respectively. The diagonal *> of [SIGMA] is computed and stored in the array SVA. *> \endverbatim * * Arguments: * ========== * *> \param[in] JOBA *> \verbatim *> JOBA is CHARACTER*1 *> Specifies the level of accuracy: *> = 'C': This option works well (high relative accuracy) if A = B * D, *> with well-conditioned B and arbitrary diagonal matrix D. *> The accuracy cannot be spoiled by COLUMN scaling. The *> accuracy of the computed output depends on the condition of *> B, and the procedure aims at the best theoretical accuracy. *> The relative error max_{i=1:N}|d sigma_i| / sigma_i is *> bounded by f(M,N)*epsilon* cond(B), independent of D. *> The input matrix is preprocessed with the QRF with column *> pivoting. This initial preprocessing and preconditioning by *> a rank revealing QR factorization is common for all values of *> JOBA. Additional actions are specified as follows: *> = 'E': Computation as with 'C' with an additional estimate of the *> condition number of B. It provides a realistic error bound. *> = 'F': If A = D1 * C * D2 with ill-conditioned diagonal scalings *> D1, D2, and well-conditioned matrix C, this option gives *> higher accuracy than the 'C' option. If the structure of the *> input matrix is not known, and relative accuracy is *> desirable, then this option is advisable. The input matrix A *> is preprocessed with QR factorization with FULL (row and *> column) pivoting. *> = 'G' Computation as with 'F' with an additional estimate of the *> condition number of B, where A=D*B. If A has heavily weighted *> rows, then using this condition number gives too pessimistic *> error bound. *> = 'A': Small singular values are the noise and the matrix is treated *> as numerically rank defficient. The error in the computed *> singular values is bounded by f(m,n)*epsilon*||A||. *> The computed SVD A = U * S * V^t restores A up to *> f(m,n)*epsilon*||A||. *> This gives the procedure the licence to discard (set to zero) *> all singular values below N*epsilon*||A||. *> = 'R': Similar as in 'A'. Rank revealing property of the initial *> QR factorization is used do reveal (using triangular factor) *> a gap sigma_{r+1} < epsilon * sigma_r in which case the *> numerical RANK is declared to be r. The SVD is computed with *> absolute error bounds, but more accurately than with 'A'. *> \endverbatim *> *> \param[in] JOBU *> \verbatim *> JOBU is CHARACTER*1 *> Specifies whether to compute the columns of U: *> = 'U': N columns of U are returned in the array U. *> = 'F': full set of M left sing. vectors is returned in the array U. *> = 'W': U may be used as workspace of length M*N. See the description *> of U. *> = 'N': U is not computed. *> \endverbatim *> *> \param[in] JOBV *> \verbatim *> JOBV is CHARACTER*1 *> Specifies whether to compute the matrix V: *> = 'V': N columns of V are returned in the array V; Jacobi rotations *> are not explicitly accumulated. *> = 'J': N columns of V are returned in the array V, but they are *> computed as the product of Jacobi rotations. This option is *> allowed only if JOBU .NE. 'N', i.e. in computing the full SVD. *> = 'W': V may be used as workspace of length N*N. See the description *> of V. *> = 'N': V is not computed. *> \endverbatim *> *> \param[in] JOBR *> \verbatim *> JOBR is CHARACTER*1 *> Specifies the RANGE for the singular values. Issues the licence to *> set to zero small positive singular values if they are outside *> specified range. If A .NE. 0 is scaled so that the largest singular *> value of c*A is around DSQRT(BIG), BIG=SLAMCH('O'), then JOBR issues *> the licence to kill columns of A whose norm in c*A is less than *> DSQRT(SFMIN) (for JOBR.EQ.'R'), or less than SMALL=SFMIN/EPSLN, *> where SFMIN=SLAMCH('S'), EPSLN=SLAMCH('E'). *> = 'N': Do not kill small columns of c*A. This option assumes that *> BLAS and QR factorizations and triangular solvers are *> implemented to work in that range. If the condition of A *> is greater than BIG, use DGESVJ. *> = 'R': RESTRICTED range for sigma(c*A) is [DSQRT(SFMIN), DSQRT(BIG)] *> (roughly, as described above). This option is recommended. *> ~~~~~~~~~~~~~~~~~~~~~~~~~~~ *> For computing the singular values in the FULL range [SFMIN,BIG] *> use DGESVJ. *> \endverbatim *> *> \param[in] JOBT *> \verbatim *> JOBT is CHARACTER*1 *> If the matrix is square then the procedure may determine to use *> transposed A if A^t seems to be better with respect to convergence. *> If the matrix is not square, JOBT is ignored. This is subject to *> changes in the future. *> The decision is based on two values of entropy over the adjoint *> orbit of A^t * A. See the descriptions of WORK(6) and WORK(7). *> = 'T': transpose if entropy test indicates possibly faster *> convergence of Jacobi process if A^t is taken as input. If A is *> replaced with A^t, then the row pivoting is included automatically. *> = 'N': do not speculate. *> This option can be used to compute only the singular values, or the *> full SVD (U, SIGMA and V). For only one set of singular vectors *> (U or V), the caller should provide both U and V, as one of the *> matrices is used as workspace if the matrix A is transposed. *> The implementer can easily remove this constraint and make the *> code more complicated. See the descriptions of U and V. *> \endverbatim *> *> \param[in] JOBP *> \verbatim *> JOBP is CHARACTER*1 *> Issues the licence to introduce structured perturbations to drown *> denormalized numbers. This licence should be active if the *> denormals are poorly implemented, causing slow computation, *> especially in cases of fast convergence (!). For details see [1,2]. *> For the sake of simplicity, this perturbations are included only *> when the full SVD or only the singular values are requested. The *> implementer/user can easily add the perturbation for the cases of *> computing one set of singular vectors. *> = 'P': introduce perturbation *> = 'N': do not perturb *> \endverbatim *> *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the input matrix A. M >= 0. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the input matrix A. M >= N >= 0. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,N) *> On entry, the M-by-N matrix A. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,M). *> \endverbatim *> *> \param[out] SVA *> \verbatim *> SVA is DOUBLE PRECISION array, dimension (N) *> On exit, *> - For WORK(1)/WORK(2) = ONE: The singular values of A. During the *> computation SVA contains Euclidean column norms of the *> iterated matrices in the array A. *> - For WORK(1) .NE. WORK(2): The singular values of A are *> (WORK(1)/WORK(2)) * SVA(1:N). This factored form is used if *> sigma_max(A) overflows or if small singular values have been *> saved from underflow by scaling the input matrix A. *> - If JOBR='R' then some of the singular values may be returned *> as exact zeros obtained by "set to zero" because they are *> below the numerical rank threshold or are denormalized numbers. *> \endverbatim *> *> \param[out] U *> \verbatim *> U is DOUBLE PRECISION array, dimension ( LDU, N ) *> If JOBU = 'U', then U contains on exit the M-by-N matrix of *> the left singular vectors. *> If JOBU = 'F', then U contains on exit the M-by-M matrix of *> the left singular vectors, including an ONB *> of the orthogonal complement of the Range(A). *> If JOBU = 'W' .AND. (JOBV.EQ.'V' .AND. JOBT.EQ.'T' .AND. M.EQ.N), *> then U is used as workspace if the procedure *> replaces A with A^t. In that case, [V] is computed *> in U as left singular vectors of A^t and then *> copied back to the V array. This 'W' option is just *> a reminder to the caller that in this case U is *> reserved as workspace of length N*N. *> If JOBU = 'N' U is not referenced. *> \endverbatim *> *> \param[in] LDU *> \verbatim *> LDU is INTEGER *> The leading dimension of the array U, LDU >= 1. *> IF JOBU = 'U' or 'F' or 'W', then LDU >= M. *> \endverbatim *> *> \param[out] V *> \verbatim *> V is DOUBLE PRECISION array, dimension ( LDV, N ) *> If JOBV = 'V', 'J' then V contains on exit the N-by-N matrix of *> the right singular vectors; *> If JOBV = 'W', AND (JOBU.EQ.'U' AND JOBT.EQ.'T' AND M.EQ.N), *> then V is used as workspace if the pprocedure *> replaces A with A^t. In that case, [U] is computed *> in V as right singular vectors of A^t and then *> copied back to the U array. This 'W' option is just *> a reminder to the caller that in this case V is *> reserved as workspace of length N*N. *> If JOBV = 'N' V is not referenced. *> \endverbatim *> *> \param[in] LDV *> \verbatim *> LDV is INTEGER *> The leading dimension of the array V, LDV >= 1. *> If JOBV = 'V' or 'J' or 'W', then LDV >= N. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is DOUBLE PRECISION array, dimension at least LWORK. *> On exit, if N.GT.0 .AND. M.GT.0 (else not referenced), *> WORK(1) = SCALE = WORK(2) / WORK(1) is the scaling factor such *> that SCALE*SVA(1:N) are the computed singular values *> of A. (See the description of SVA().) *> WORK(2) = See the description of WORK(1). *> WORK(3) = SCONDA is an estimate for the condition number of *> column equilibrated A. (If JOBA .EQ. 'E' or 'G') *> SCONDA is an estimate of DSQRT(||(R^t * R)^(-1)||_1). *> It is computed using DPOCON. It holds *> N^(-1/4) * SCONDA <= ||R^(-1)||_2 <= N^(1/4) * SCONDA *> where R is the triangular factor from the QRF of A. *> However, if R is truncated and the numerical rank is *> determined to be strictly smaller than N, SCONDA is *> returned as -1, thus indicating that the smallest *> singular values might be lost. *> *> If full SVD is needed, the following two condition numbers are *> useful for the analysis of the algorithm. They are provied for *> a developer/implementer who is familiar with the details of *> the method. *> *> WORK(4) = an estimate of the scaled condition number of the *> triangular factor in the first QR factorization. *> WORK(5) = an estimate of the scaled condition number of the *> triangular factor in the second QR factorization. *> The following two parameters are computed if JOBT .EQ. 'T'. *> They are provided for a developer/implementer who is familiar *> with the details of the method. *> *> WORK(6) = the entropy of A^t*A :: this is the Shannon entropy *> of diag(A^t*A) / Trace(A^t*A) taken as point in the *> probability simplex. *> WORK(7) = the entropy of A*A^t. *> \endverbatim *> *> \param[in] LWORK *> \verbatim *> LWORK is INTEGER *> Length of WORK to confirm proper allocation of work space. *> LWORK depends on the job: *> *> If only SIGMA is needed ( JOBU.EQ.'N', JOBV.EQ.'N' ) and *> -> .. no scaled condition estimate required (JOBE.EQ.'N'): *> LWORK >= max(2*M+N,4*N+1,7). This is the minimal requirement. *> ->> For optimal performance (blocked code) the optimal value *> is LWORK >= max(2*M+N,3*N+(N+1)*NB,7). Here NB is the optimal *> block size for DGEQP3 and DGEQRF. *> In general, optimal LWORK is computed as *> LWORK >= max(2*M+N,N+LWORK(DGEQP3),N+LWORK(DGEQRF), 7). *> -> .. an estimate of the scaled condition number of A is *> required (JOBA='E', 'G'). In this case, LWORK is the maximum *> of the above and N*N+4*N, i.e. LWORK >= max(2*M+N,N*N+4*N,7). *> ->> For optimal performance (blocked code) the optimal value *> is LWORK >= max(2*M+N,3*N+(N+1)*NB, N*N+4*N, 7). *> In general, the optimal length LWORK is computed as *> LWORK >= max(2*M+N,N+LWORK(DGEQP3),N+LWORK(DGEQRF), *> N+N*N+LWORK(DPOCON),7). *> *> If SIGMA and the right singular vectors are needed (JOBV.EQ.'V'), *> -> the minimal requirement is LWORK >= max(2*M+N,4*N+1,7). *> -> For optimal performance, LWORK >= max(2*M+N,3*N+(N+1)*NB,7), *> where NB is the optimal block size for DGEQP3, DGEQRF, DGELQ, *> DORMLQ. In general, the optimal length LWORK is computed as *> LWORK >= max(2*M+N,N+LWORK(DGEQP3), N+LWORK(DPOCON), *> N+LWORK(DGELQ), 2*N+LWORK(DGEQRF), N+LWORK(DORMLQ)). *> *> If SIGMA and the left singular vectors are needed *> -> the minimal requirement is LWORK >= max(2*M+N,4*N+1,7). *> -> For optimal performance: *> if JOBU.EQ.'U' :: LWORK >= max(2*M+N,3*N+(N+1)*NB,7), *> if JOBU.EQ.'F' :: LWORK >= max(2*M+N,3*N+(N+1)*NB,N+M*NB,7), *> where NB is the optimal block size for DGEQP3, DGEQRF, DORMQR. *> In general, the optimal length LWORK is computed as *> LWORK >= max(2*M+N,N+LWORK(DGEQP3),N+LWORK(DPOCON), *> 2*N+LWORK(DGEQRF), N+LWORK(DORMQR)). *> Here LWORK(DORMQR) equals N*NB (for JOBU.EQ.'U') or *> M*NB (for JOBU.EQ.'F'). *> *> If the full SVD is needed: (JOBU.EQ.'U' or JOBU.EQ.'F') and *> -> if JOBV.EQ.'V' *> the minimal requirement is LWORK >= max(2*M+N,6*N+2*N*N). *> -> if JOBV.EQ.'J' the minimal requirement is *> LWORK >= max(2*M+N, 4*N+N*N,2*N+N*N+6). *> -> For optimal performance, LWORK should be additionally *> larger than N+M*NB, where NB is the optimal block size *> for DORMQR. *> \endverbatim *> *> \param[out] IWORK *> \verbatim *> IWORK is INTEGER array, dimension M+3*N. *> On exit, *> IWORK(1) = the numerical rank determined after the initial *> QR factorization with pivoting. See the descriptions *> of JOBA and JOBR. *> IWORK(2) = the number of the computed nonzero singular values *> IWORK(3) = if nonzero, a warning message: *> If IWORK(3).EQ.1 then some of the column norms of A *> were denormalized floats. The requested high accuracy *> is not warranted by the data. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> < 0 : if INFO = -i, then the i-th argument had an illegal value. *> = 0 : successfull exit; *> > 0 : DGEJSV did not converge in the maximal allowed number *> of sweeps. The computed values may be inaccurate. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doubleGEsing * *> \par Further Details: * ===================== *> *> \verbatim *> *> DGEJSV implements a preconditioned Jacobi SVD algorithm. It uses DGEQP3, *> DGEQRF, and DGELQF as preprocessors and preconditioners. Optionally, an *> additional row pivoting can be used as a preprocessor, which in some *> cases results in much higher accuracy. An example is matrix A with the *> structure A = D1 * C * D2, where D1, D2 are arbitrarily ill-conditioned *> diagonal matrices and C is well-conditioned matrix. In that case, complete *> pivoting in the first QR factorizations provides accuracy dependent on the *> condition number of C, and independent of D1, D2. Such higher accuracy is *> not completely understood theoretically, but it works well in practice. *> Further, if A can be written as A = B*D, with well-conditioned B and some *> diagonal D, then the high accuracy is guaranteed, both theoretically and *> in software, independent of D. For more details see [1], [2]. *> The computational range for the singular values can be the full range *> ( UNDERFLOW,OVERFLOW ), provided that the machine arithmetic and the BLAS *> & LAPACK routines called by DGEJSV are implemented to work in that range. *> If that is not the case, then the restriction for safe computation with *> the singular values in the range of normalized IEEE numbers is that the *> spectral condition number kappa(A)=sigma_max(A)/sigma_min(A) does not *> overflow. This code (DGEJSV) is best used in this restricted range, *> meaning that singular values of magnitude below ||A||_2 / DLAMCH('O') are *> returned as zeros. See JOBR for details on this. *> Further, this implementation is somewhat slower than the one described *> in [1,2] due to replacement of some non-LAPACK components, and because *> the choice of some tuning parameters in the iterative part (DGESVJ) is *> left to the implementer on a particular machine. *> The rank revealing QR factorization (in this code: DGEQP3) should be *> implemented as in [3]. We have a new version of DGEQP3 under development *> that is more robust than the current one in LAPACK, with a cleaner cut in *> rank defficient cases. It will be available in the SIGMA library [4]. *> If M is much larger than N, it is obvious that the inital QRF with *> column pivoting can be preprocessed by the QRF without pivoting. That *> well known trick is not used in DGEJSV because in some cases heavy row *> weighting can be treated with complete pivoting. The overhead in cases *> M much larger than N is then only due to pivoting, but the benefits in *> terms of accuracy have prevailed. The implementer/user can incorporate *> this extra QRF step easily. The implementer can also improve data movement *> (matrix transpose, matrix copy, matrix transposed copy) - this *> implementation of DGEJSV uses only the simplest, naive data movement. *> \endverbatim * *> \par Contributors: * ================== *> *> Zlatko Drmac (Zagreb, Croatia) and Kresimir Veselic (Hagen, Germany) * *> \par References: * ================ *> *> \verbatim *> *> [1] Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD algorithm I. *> SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1322-1342. *> LAPACK Working note 169. *> [2] Z. Drmac and K. Veselic: New fast and accurate Jacobi SVD algorithm II. *> SIAM J. Matrix Anal. Appl. Vol. 35, No. 2 (2008), pp. 1343-1362. *> LAPACK Working note 170. *> [3] Z. Drmac and Z. Bujanovic: On the failure of rank-revealing QR *> factorization software - a case study. *> ACM Trans. Math. Softw. Vol. 35, No 2 (2008), pp. 1-28. *> LAPACK Working note 176. *> [4] Z. Drmac: SIGMA - mathematical software library for accurate SVD, PSV, *> QSVD, (H,K)-SVD computations. *> Department of Mathematics, University of Zagreb, 2008. *> \endverbatim * *> \par Bugs, examples and comments: * ================================= *> *> Please report all bugs and send interesting examples and/or comments to *> drmac@math.hr. Thank you. *> * ===================================================================== SUBROUTINE DGEJSV( JOBA, JOBU, JOBV, JOBR, JOBT, JOBP, $ M, N, A, LDA, SVA, U, LDU, V, LDV, $ WORK, LWORK, IWORK, INFO ) * * -- LAPACK computational routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. IMPLICIT NONE INTEGER INFO, LDA, LDU, LDV, LWORK, M, N * .. * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ), SVA( N ), U( LDU, * ), V( LDV, * ), $ WORK( LWORK ) INTEGER IWORK( * ) CHARACTER*1 JOBA, JOBP, JOBR, JOBT, JOBU, JOBV * .. * * =========================================================================== * * .. Local Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 ) * .. * .. Local Scalars .. DOUBLE PRECISION AAPP, AAQQ, AATMAX, AATMIN, BIG, BIG1, COND_OK, $ CONDR1, CONDR2, ENTRA, ENTRAT, EPSLN, MAXPRJ, SCALEM, $ SCONDA, SFMIN, SMALL, TEMP1, USCAL1, USCAL2, XSC INTEGER IERR, N1, NR, NUMRANK, p, q, WARNING LOGICAL ALMORT, DEFR, ERREST, GOSCAL, JRACC, KILL, LSVEC, $ L2ABER, L2KILL, L2PERT, L2RANK, L2TRAN, $ NOSCAL, ROWPIV, RSVEC, TRANSP * .. * .. Intrinsic Functions .. INTRINSIC DABS, DLOG, DMAX1, DMIN1, DBLE, $ MAX0, MIN0, IDNINT, DSIGN, DSQRT * .. * .. External Functions .. DOUBLE PRECISION DLAMCH, DNRM2 INTEGER IDAMAX LOGICAL LSAME EXTERNAL IDAMAX, LSAME, DLAMCH, DNRM2 * .. * .. External Subroutines .. EXTERNAL DCOPY, DGELQF, DGEQP3, DGEQRF, DLACPY, DLASCL, $ DLASET, DLASSQ, DLASWP, DORGQR, DORMLQ, $ DORMQR, DPOCON, DSCAL, DSWAP, DTRSM, XERBLA * EXTERNAL DGESVJ * .. * * Test the input arguments * LSVEC = LSAME( JOBU, 'U' ) .OR. LSAME( JOBU, 'F' ) JRACC = LSAME( JOBV, 'J' ) RSVEC = LSAME( JOBV, 'V' ) .OR. JRACC ROWPIV = LSAME( JOBA, 'F' ) .OR. LSAME( JOBA, 'G' ) L2RANK = LSAME( JOBA, 'R' ) L2ABER = LSAME( JOBA, 'A' ) ERREST = LSAME( JOBA, 'E' ) .OR. LSAME( JOBA, 'G' ) L2TRAN = LSAME( JOBT, 'T' ) L2KILL = LSAME( JOBR, 'R' ) DEFR = LSAME( JOBR, 'N' ) L2PERT = LSAME( JOBP, 'P' ) * IF ( .NOT.(ROWPIV .OR. L2RANK .OR. L2ABER .OR. $ ERREST .OR. LSAME( JOBA, 'C' ) )) THEN INFO = - 1 ELSE IF ( .NOT.( LSVEC .OR. LSAME( JOBU, 'N' ) .OR. $ LSAME( JOBU, 'W' )) ) THEN INFO = - 2 ELSE IF ( .NOT.( RSVEC .OR. LSAME( JOBV, 'N' ) .OR. $ LSAME( JOBV, 'W' )) .OR. ( JRACC .AND. (.NOT.LSVEC) ) ) THEN INFO = - 3 ELSE IF ( .NOT. ( L2KILL .OR. DEFR ) ) THEN INFO = - 4 ELSE IF ( .NOT. ( L2TRAN .OR. LSAME( JOBT, 'N' ) ) ) THEN INFO = - 5 ELSE IF ( .NOT. ( L2PERT .OR. LSAME( JOBP, 'N' ) ) ) THEN INFO = - 6 ELSE IF ( M .LT. 0 ) THEN INFO = - 7 ELSE IF ( ( N .LT. 0 ) .OR. ( N .GT. M ) ) THEN INFO = - 8 ELSE IF ( LDA .LT. M ) THEN INFO = - 10 ELSE IF ( LSVEC .AND. ( LDU .LT. M ) ) THEN INFO = - 13 ELSE IF ( RSVEC .AND. ( LDV .LT. N ) ) THEN INFO = - 14 ELSE IF ( (.NOT.(LSVEC .OR. RSVEC .OR. ERREST).AND. & (LWORK .LT. MAX0(7,4*N+1,2*M+N))) .OR. & (.NOT.(LSVEC .OR. RSVEC) .AND. ERREST .AND. & (LWORK .LT. MAX0(7,4*N+N*N,2*M+N))) .OR. & (LSVEC .AND. (.NOT.RSVEC) .AND. (LWORK .LT. MAX0(7,2*M+N,4*N+1))) & .OR. & (RSVEC .AND. (.NOT.LSVEC) .AND. (LWORK .LT. MAX0(7,2*M+N,4*N+1))) & .OR. & (LSVEC .AND. RSVEC .AND. (.NOT.JRACC) .AND. & (LWORK.LT.MAX0(2*M+N,6*N+2*N*N))) & .OR. (LSVEC .AND. RSVEC .AND. JRACC .AND. & LWORK.LT.MAX0(2*M+N,4*N+N*N,2*N+N*N+6))) & THEN INFO = - 17 ELSE * #:) INFO = 0 END IF * IF ( INFO .NE. 0 ) THEN * #:( CALL XERBLA( 'DGEJSV', - INFO ) RETURN END IF * * Quick return for void matrix (Y3K safe) * #:) IF ( ( M .EQ. 0 ) .OR. ( N .EQ. 0 ) ) RETURN * * Determine whether the matrix U should be M x N or M x M * IF ( LSVEC ) THEN N1 = N IF ( LSAME( JOBU, 'F' ) ) N1 = M END IF * * Set numerical parameters * *! NOTE: Make sure DLAMCH() does not fail on the target architecture. * EPSLN = DLAMCH('Epsilon') SFMIN = DLAMCH('SafeMinimum') SMALL = SFMIN / EPSLN BIG = DLAMCH('O') * BIG = ONE / SFMIN * * Initialize SVA(1:N) = diag( ||A e_i||_2 )_1^N * *(!) If necessary, scale SVA() to protect the largest norm from * overflow. It is possible that this scaling pushes the smallest * column norm left from the underflow threshold (extreme case). * SCALEM = ONE / DSQRT(DBLE(M)*DBLE(N)) NOSCAL = .TRUE. GOSCAL = .TRUE. DO 1874 p = 1, N AAPP = ZERO AAQQ = ONE CALL DLASSQ( M, A(1,p), 1, AAPP, AAQQ ) IF ( AAPP .GT. BIG ) THEN INFO = - 9 CALL XERBLA( 'DGEJSV', -INFO ) RETURN END IF AAQQ = DSQRT(AAQQ) IF ( ( AAPP .LT. (BIG / AAQQ) ) .AND. NOSCAL ) THEN SVA(p) = AAPP * AAQQ ELSE NOSCAL = .FALSE. SVA(p) = AAPP * ( AAQQ * SCALEM ) IF ( GOSCAL ) THEN GOSCAL = .FALSE. CALL DSCAL( p-1, SCALEM, SVA, 1 ) END IF END IF 1874 CONTINUE * IF ( NOSCAL ) SCALEM = ONE * AAPP = ZERO AAQQ = BIG DO 4781 p = 1, N AAPP = DMAX1( AAPP, SVA(p) ) IF ( SVA(p) .NE. ZERO ) AAQQ = DMIN1( AAQQ, SVA(p) ) 4781 CONTINUE * * Quick return for zero M x N matrix * #:) IF ( AAPP .EQ. ZERO ) THEN IF ( LSVEC ) CALL DLASET( 'G', M, N1, ZERO, ONE, U, LDU ) IF ( RSVEC ) CALL DLASET( 'G', N, N, ZERO, ONE, V, LDV ) WORK(1) = ONE WORK(2) = ONE IF ( ERREST ) WORK(3) = ONE IF ( LSVEC .AND. RSVEC ) THEN WORK(4) = ONE WORK(5) = ONE END IF IF ( L2TRAN ) THEN WORK(6) = ZERO WORK(7) = ZERO END IF IWORK(1) = 0 IWORK(2) = 0 IWORK(3) = 0 RETURN END IF * * Issue warning if denormalized column norms detected. Override the * high relative accuracy request. Issue licence to kill columns * (set them to zero) whose norm is less than sigma_max / BIG (roughly). * #:( WARNING = 0 IF ( AAQQ .LE. SFMIN ) THEN L2RANK = .TRUE. L2KILL = .TRUE. WARNING = 1 END IF * * Quick return for one-column matrix * #:) IF ( N .EQ. 1 ) THEN * IF ( LSVEC ) THEN CALL DLASCL( 'G',0,0,SVA(1),SCALEM, M,1,A(1,1),LDA,IERR ) CALL DLACPY( 'A', M, 1, A, LDA, U, LDU ) * computing all M left singular vectors of the M x 1 matrix IF ( N1 .NE. N ) THEN CALL DGEQRF( M, N, U,LDU, WORK, WORK(N+1),LWORK-N,IERR ) CALL DORGQR( M,N1,1, U,LDU,WORK,WORK(N+1),LWORK-N,IERR ) CALL DCOPY( M, A(1,1), 1, U(1,1), 1 ) END IF END IF IF ( RSVEC ) THEN V(1,1) = ONE END IF IF ( SVA(1) .LT. (BIG*SCALEM) ) THEN SVA(1) = SVA(1) / SCALEM SCALEM = ONE END IF WORK(1) = ONE / SCALEM WORK(2) = ONE IF ( SVA(1) .NE. ZERO ) THEN IWORK(1) = 1 IF ( ( SVA(1) / SCALEM) .GE. SFMIN ) THEN IWORK(2) = 1 ELSE IWORK(2) = 0 END IF ELSE IWORK(1) = 0 IWORK(2) = 0 END IF IF ( ERREST ) WORK(3) = ONE IF ( LSVEC .AND. RSVEC ) THEN WORK(4) = ONE WORK(5) = ONE END IF IF ( L2TRAN ) THEN WORK(6) = ZERO WORK(7) = ZERO END IF RETURN * END IF * TRANSP = .FALSE. L2TRAN = L2TRAN .AND. ( M .EQ. N ) * AATMAX = -ONE AATMIN = BIG IF ( ROWPIV .OR. L2TRAN ) THEN * * Compute the row norms, needed to determine row pivoting sequence * (in the case of heavily row weighted A, row pivoting is strongly * advised) and to collect information needed to compare the * structures of A * A^t and A^t * A (in the case L2TRAN.EQ..TRUE.). * IF ( L2TRAN ) THEN DO 1950 p = 1, M XSC = ZERO TEMP1 = ONE CALL DLASSQ( N, A(p,1), LDA, XSC, TEMP1 ) * DLASSQ gets both the ell_2 and the ell_infinity norm * in one pass through the vector WORK(M+N+p) = XSC * SCALEM WORK(N+p) = XSC * (SCALEM*DSQRT(TEMP1)) AATMAX = DMAX1( AATMAX, WORK(N+p) ) IF (WORK(N+p) .NE. ZERO) AATMIN = DMIN1(AATMIN,WORK(N+p)) 1950 CONTINUE ELSE DO 1904 p = 1, M WORK(M+N+p) = SCALEM*DABS( A(p,IDAMAX(N,A(p,1),LDA)) ) AATMAX = DMAX1( AATMAX, WORK(M+N+p) ) AATMIN = DMIN1( AATMIN, WORK(M+N+p) ) 1904 CONTINUE END IF * END IF * * For square matrix A try to determine whether A^t would be better * input for the preconditioned Jacobi SVD, with faster convergence. * The decision is based on an O(N) function of the vector of column * and row norms of A, based on the Shannon entropy. This should give * the right choice in most cases when the difference actually matters. * It may fail and pick the slower converging side. * ENTRA = ZERO ENTRAT = ZERO IF ( L2TRAN ) THEN * XSC = ZERO TEMP1 = ONE CALL DLASSQ( N, SVA, 1, XSC, TEMP1 ) TEMP1 = ONE / TEMP1 * ENTRA = ZERO DO 1113 p = 1, N BIG1 = ( ( SVA(p) / XSC )**2 ) * TEMP1 IF ( BIG1 .NE. ZERO ) ENTRA = ENTRA + BIG1 * DLOG(BIG1) 1113 CONTINUE ENTRA = - ENTRA / DLOG(DBLE(N)) * * Now, SVA().^2/Trace(A^t * A) is a point in the probability simplex. * It is derived from the diagonal of A^t * A. Do the same with the * diagonal of A * A^t, compute the entropy of the corresponding * probability distribution. Note that A * A^t and A^t * A have the * same trace. * ENTRAT = ZERO DO 1114 p = N+1, N+M BIG1 = ( ( WORK(p) / XSC )**2 ) * TEMP1 IF ( BIG1 .NE. ZERO ) ENTRAT = ENTRAT + BIG1 * DLOG(BIG1) 1114 CONTINUE ENTRAT = - ENTRAT / DLOG(DBLE(M)) * * Analyze the entropies and decide A or A^t. Smaller entropy * usually means better input for the algorithm. * TRANSP = ( ENTRAT .LT. ENTRA ) * * If A^t is better than A, transpose A. * IF ( TRANSP ) THEN * In an optimal implementation, this trivial transpose * should be replaced with faster transpose. DO 1115 p = 1, N - 1 DO 1116 q = p + 1, N TEMP1 = A(q,p) A(q,p) = A(p,q) A(p,q) = TEMP1 1116 CONTINUE 1115 CONTINUE DO 1117 p = 1, N WORK(M+N+p) = SVA(p) SVA(p) = WORK(N+p) 1117 CONTINUE TEMP1 = AAPP AAPP = AATMAX AATMAX = TEMP1 TEMP1 = AAQQ AAQQ = AATMIN AATMIN = TEMP1 KILL = LSVEC LSVEC = RSVEC RSVEC = KILL IF ( LSVEC ) N1 = N * ROWPIV = .TRUE. END IF * END IF * END IF L2TRAN * * Scale the matrix so that its maximal singular value remains less * than DSQRT(BIG) -- the matrix is scaled so that its maximal column * has Euclidean norm equal to DSQRT(BIG/N). The only reason to keep * DSQRT(BIG) instead of BIG is the fact that DGEJSV uses LAPACK and * BLAS routines that, in some implementations, are not capable of * working in the full interval [SFMIN,BIG] and that they may provoke * overflows in the intermediate results. If the singular values spread * from SFMIN to BIG, then DGESVJ will compute them. So, in that case, * one should use DGESVJ instead of DGEJSV. * BIG1 = DSQRT( BIG ) TEMP1 = DSQRT( BIG / DBLE(N) ) * CALL DLASCL( 'G', 0, 0, AAPP, TEMP1, N, 1, SVA, N, IERR ) IF ( AAQQ .GT. (AAPP * SFMIN) ) THEN AAQQ = ( AAQQ / AAPP ) * TEMP1 ELSE AAQQ = ( AAQQ * TEMP1 ) / AAPP END IF TEMP1 = TEMP1 * SCALEM CALL DLASCL( 'G', 0, 0, AAPP, TEMP1, M, N, A, LDA, IERR ) * * To undo scaling at the end of this procedure, multiply the * computed singular values with USCAL2 / USCAL1. * USCAL1 = TEMP1 USCAL2 = AAPP * IF ( L2KILL ) THEN * L2KILL enforces computation of nonzero singular values in * the restricted range of condition number of the initial A, * sigma_max(A) / sigma_min(A) approx. DSQRT(BIG)/DSQRT(SFMIN). XSC = DSQRT( SFMIN ) ELSE XSC = SMALL * * Now, if the condition number of A is too big, * sigma_max(A) / sigma_min(A) .GT. DSQRT(BIG/N) * EPSLN / SFMIN, * as a precaution measure, the full SVD is computed using DGESVJ * with accumulated Jacobi rotations. This provides numerically * more robust computation, at the cost of slightly increased run * time. Depending on the concrete implementation of BLAS and LAPACK * (i.e. how they behave in presence of extreme ill-conditioning) the * implementor may decide to remove this switch. IF ( ( AAQQ.LT.DSQRT(SFMIN) ) .AND. LSVEC .AND. RSVEC ) THEN JRACC = .TRUE. END IF * END IF IF ( AAQQ .LT. XSC ) THEN DO 700 p = 1, N IF ( SVA(p) .LT. XSC ) THEN CALL DLASET( 'A', M, 1, ZERO, ZERO, A(1,p), LDA ) SVA(p) = ZERO END IF 700 CONTINUE END IF * * Preconditioning using QR factorization with pivoting * IF ( ROWPIV ) THEN * Optional row permutation (Bjoerck row pivoting): * A result by Cox and Higham shows that the Bjoerck's * row pivoting combined with standard column pivoting * has similar effect as Powell-Reid complete pivoting. * The ell-infinity norms of A are made nonincreasing. DO 1952 p = 1, M - 1 q = IDAMAX( M-p+1, WORK(M+N+p), 1 ) + p - 1 IWORK(2*N+p) = q IF ( p .NE. q ) THEN TEMP1 = WORK(M+N+p) WORK(M+N+p) = WORK(M+N+q) WORK(M+N+q) = TEMP1 END IF 1952 CONTINUE CALL DLASWP( N, A, LDA, 1, M-1, IWORK(2*N+1), 1 ) END IF * * End of the preparation phase (scaling, optional sorting and * transposing, optional flushing of small columns). * * Preconditioning * * If the full SVD is needed, the right singular vectors are computed * from a matrix equation, and for that we need theoretical analysis * of the Businger-Golub pivoting. So we use DGEQP3 as the first RR QRF. * In all other cases the first RR QRF can be chosen by other criteria * (eg speed by replacing global with restricted window pivoting, such * as in SGEQPX from TOMS # 782). Good results will be obtained using * SGEQPX with properly (!) chosen numerical parameters. * Any improvement of DGEQP3 improves overal performance of DGEJSV. * * A * P1 = Q1 * [ R1^t 0]^t: DO 1963 p = 1, N * .. all columns are free columns IWORK(p) = 0 1963 CONTINUE CALL DGEQP3( M,N,A,LDA, IWORK,WORK, WORK(N+1),LWORK-N, IERR ) * * The upper triangular matrix R1 from the first QRF is inspected for * rank deficiency and possibilities for deflation, or possible * ill-conditioning. Depending on the user specified flag L2RANK, * the procedure explores possibilities to reduce the numerical * rank by inspecting the computed upper triangular factor. If * L2RANK or L2ABER are up, then DGEJSV will compute the SVD of * A + dA, where ||dA|| <= f(M,N)*EPSLN. * NR = 1 IF ( L2ABER ) THEN * Standard absolute error bound suffices. All sigma_i with * sigma_i < N*EPSLN*||A|| are flushed to zero. This is an * agressive enforcement of lower numerical rank by introducing a * backward error of the order of N*EPSLN*||A||. TEMP1 = DSQRT(DBLE(N))*EPSLN DO 3001 p = 2, N IF ( DABS(A(p,p)) .GE. (TEMP1*DABS(A(1,1))) ) THEN NR = NR + 1 ELSE GO TO 3002 END IF 3001 CONTINUE 3002 CONTINUE ELSE IF ( L2RANK ) THEN * .. similarly as above, only slightly more gentle (less agressive). * Sudden drop on the diagonal of R1 is used as the criterion for * close-to-rank-defficient. TEMP1 = DSQRT(SFMIN) DO 3401 p = 2, N IF ( ( DABS(A(p,p)) .LT. (EPSLN*DABS(A(p-1,p-1))) ) .OR. $ ( DABS(A(p,p)) .LT. SMALL ) .OR. $ ( L2KILL .AND. (DABS(A(p,p)) .LT. TEMP1) ) ) GO TO 3402 NR = NR + 1 3401 CONTINUE 3402 CONTINUE * ELSE * The goal is high relative accuracy. However, if the matrix * has high scaled condition number the relative accuracy is in * general not feasible. Later on, a condition number estimator * will be deployed to estimate the scaled condition number. * Here we just remove the underflowed part of the triangular * factor. This prevents the situation in which the code is * working hard to get the accuracy not warranted by the data. TEMP1 = DSQRT(SFMIN) DO 3301 p = 2, N IF ( ( DABS(A(p,p)) .LT. SMALL ) .OR. $ ( L2KILL .AND. (DABS(A(p,p)) .LT. TEMP1) ) ) GO TO 3302 NR = NR + 1 3301 CONTINUE 3302 CONTINUE * END IF * ALMORT = .FALSE. IF ( NR .EQ. N ) THEN MAXPRJ = ONE DO 3051 p = 2, N TEMP1 = DABS(A(p,p)) / SVA(IWORK(p)) MAXPRJ = DMIN1( MAXPRJ, TEMP1 ) 3051 CONTINUE IF ( MAXPRJ**2 .GE. ONE - DBLE(N)*EPSLN ) ALMORT = .TRUE. END IF * * SCONDA = - ONE CONDR1 = - ONE CONDR2 = - ONE * IF ( ERREST ) THEN IF ( N .EQ. NR ) THEN IF ( RSVEC ) THEN * .. V is available as workspace CALL DLACPY( 'U', N, N, A, LDA, V, LDV ) DO 3053 p = 1, N TEMP1 = SVA(IWORK(p)) CALL DSCAL( p, ONE/TEMP1, V(1,p), 1 ) 3053 CONTINUE CALL DPOCON( 'U', N, V, LDV, ONE, TEMP1, $ WORK(N+1), IWORK(2*N+M+1), IERR ) ELSE IF ( LSVEC ) THEN * .. U is available as workspace CALL DLACPY( 'U', N, N, A, LDA, U, LDU ) DO 3054 p = 1, N TEMP1 = SVA(IWORK(p)) CALL DSCAL( p, ONE/TEMP1, U(1,p), 1 ) 3054 CONTINUE CALL DPOCON( 'U', N, U, LDU, ONE, TEMP1, $ WORK(N+1), IWORK(2*N+M+1), IERR ) ELSE CALL DLACPY( 'U', N, N, A, LDA, WORK(N+1), N ) DO 3052 p = 1, N TEMP1 = SVA(IWORK(p)) CALL DSCAL( p, ONE/TEMP1, WORK(N+(p-1)*N+1), 1 ) 3052 CONTINUE * .. the columns of R are scaled to have unit Euclidean lengths. CALL DPOCON( 'U', N, WORK(N+1), N, ONE, TEMP1, $ WORK(N+N*N+1), IWORK(2*N+M+1), IERR ) END IF SCONDA = ONE / DSQRT(TEMP1) * SCONDA is an estimate of DSQRT(||(R^t * R)^(-1)||_1). * N^(-1/4) * SCONDA <= ||R^(-1)||_2 <= N^(1/4) * SCONDA ELSE SCONDA = - ONE END IF END IF * L2PERT = L2PERT .AND. ( DABS( A(1,1)/A(NR,NR) ) .GT. DSQRT(BIG1) ) * If there is no violent scaling, artificial perturbation is not needed. * * Phase 3: * IF ( .NOT. ( RSVEC .OR. LSVEC ) ) THEN * * Singular Values only * * .. transpose A(1:NR,1:N) DO 1946 p = 1, MIN0( N-1, NR ) CALL DCOPY( N-p, A(p,p+1), LDA, A(p+1,p), 1 ) 1946 CONTINUE * * The following two DO-loops introduce small relative perturbation * into the strict upper triangle of the lower triangular matrix. * Small entries below the main diagonal are also changed. * This modification is useful if the computing environment does not * provide/allow FLUSH TO ZERO underflow, for it prevents many * annoying denormalized numbers in case of strongly scaled matrices. * The perturbation is structured so that it does not introduce any * new perturbation of the singular values, and it does not destroy * the job done by the preconditioner. * The licence for this perturbation is in the variable L2PERT, which * should be .FALSE. if FLUSH TO ZERO underflow is active. * IF ( .NOT. ALMORT ) THEN * IF ( L2PERT ) THEN * XSC = DSQRT(SMALL) XSC = EPSLN / DBLE(N) DO 4947 q = 1, NR TEMP1 = XSC*DABS(A(q,q)) DO 4949 p = 1, N IF ( ( (p.GT.q) .AND. (DABS(A(p,q)).LE.TEMP1) ) $ .OR. ( p .LT. q ) ) $ A(p,q) = DSIGN( TEMP1, A(p,q) ) 4949 CONTINUE 4947 CONTINUE ELSE CALL DLASET( 'U', NR-1,NR-1, ZERO,ZERO, A(1,2),LDA ) END IF * * .. second preconditioning using the QR factorization * CALL DGEQRF( N,NR, A,LDA, WORK, WORK(N+1),LWORK-N, IERR ) * * .. and transpose upper to lower triangular DO 1948 p = 1, NR - 1 CALL DCOPY( NR-p, A(p,p+1), LDA, A(p+1,p), 1 ) 1948 CONTINUE * END IF * * Row-cyclic Jacobi SVD algorithm with column pivoting * * .. again some perturbation (a "background noise") is added * to drown denormals IF ( L2PERT ) THEN * XSC = DSQRT(SMALL) XSC = EPSLN / DBLE(N) DO 1947 q = 1, NR TEMP1 = XSC*DABS(A(q,q)) DO 1949 p = 1, NR IF ( ( (p.GT.q) .AND. (DABS(A(p,q)).LE.TEMP1) ) $ .OR. ( p .LT. q ) ) $ A(p,q) = DSIGN( TEMP1, A(p,q) ) 1949 CONTINUE 1947 CONTINUE ELSE CALL DLASET( 'U', NR-1, NR-1, ZERO, ZERO, A(1,2), LDA ) END IF * * .. and one-sided Jacobi rotations are started on a lower * triangular matrix (plus perturbation which is ignored in * the part which destroys triangular form (confusing?!)) * CALL DGESVJ( 'L', 'NoU', 'NoV', NR, NR, A, LDA, SVA, $ N, V, LDV, WORK, LWORK, INFO ) * SCALEM = WORK(1) NUMRANK = IDNINT(WORK(2)) * * ELSE IF ( RSVEC .AND. ( .NOT. LSVEC ) ) THEN * * -> Singular Values and Right Singular Vectors <- * IF ( ALMORT ) THEN * * .. in this case NR equals N DO 1998 p = 1, NR CALL DCOPY( N-p+1, A(p,p), LDA, V(p,p), 1 ) 1998 CONTINUE CALL DLASET( 'Upper', NR-1, NR-1, ZERO, ZERO, V(1,2), LDV ) * CALL DGESVJ( 'L','U','N', N, NR, V,LDV, SVA, NR, A,LDA, $ WORK, LWORK, INFO ) SCALEM = WORK(1) NUMRANK = IDNINT(WORK(2)) ELSE * * .. two more QR factorizations ( one QRF is not enough, two require * accumulated product of Jacobi rotations, three are perfect ) * CALL DLASET( 'Lower', NR-1, NR-1, ZERO, ZERO, A(2,1), LDA ) CALL DGELQF( NR, N, A, LDA, WORK, WORK(N+1), LWORK-N, IERR) CALL DLACPY( 'Lower', NR, NR, A, LDA, V, LDV ) CALL DLASET( 'Upper', NR-1, NR-1, ZERO, ZERO, V(1,2), LDV ) CALL DGEQRF( NR, NR, V, LDV, WORK(N+1), WORK(2*N+1), $ LWORK-2*N, IERR ) DO 8998 p = 1, NR CALL DCOPY( NR-p+1, V(p,p), LDV, V(p,p), 1 ) 8998 CONTINUE CALL DLASET( 'Upper', NR-1, NR-1, ZERO, ZERO, V(1,2), LDV ) * CALL DGESVJ( 'Lower', 'U','N', NR, NR, V,LDV, SVA, NR, U, $ LDU, WORK(N+1), LWORK, INFO ) SCALEM = WORK(N+1) NUMRANK = IDNINT(WORK(N+2)) IF ( NR .LT. N ) THEN CALL DLASET( 'A',N-NR, NR, ZERO,ZERO, V(NR+1,1), LDV ) CALL DLASET( 'A',NR, N-NR, ZERO,ZERO, V(1,NR+1), LDV ) CALL DLASET( 'A',N-NR,N-NR,ZERO,ONE, V(NR+1,NR+1), LDV ) END IF * CALL DORMLQ( 'Left', 'Transpose', N, N, NR, A, LDA, WORK, $ V, LDV, WORK(N+1), LWORK-N, IERR ) * END IF * DO 8991 p = 1, N CALL DCOPY( N, V(p,1), LDV, A(IWORK(p),1), LDA ) 8991 CONTINUE CALL DLACPY( 'All', N, N, A, LDA, V, LDV ) * IF ( TRANSP ) THEN CALL DLACPY( 'All', N, N, V, LDV, U, LDU ) END IF * ELSE IF ( LSVEC .AND. ( .NOT. RSVEC ) ) THEN * * .. Singular Values and Left Singular Vectors .. * * .. second preconditioning step to avoid need to accumulate * Jacobi rotations in the Jacobi iterations. DO 1965 p = 1, NR CALL DCOPY( N-p+1, A(p,p), LDA, U(p,p), 1 ) 1965 CONTINUE CALL DLASET( 'Upper', NR-1, NR-1, ZERO, ZERO, U(1,2), LDU ) * CALL DGEQRF( N, NR, U, LDU, WORK(N+1), WORK(2*N+1), $ LWORK-2*N, IERR ) * DO 1967 p = 1, NR - 1 CALL DCOPY( NR-p, U(p,p+1), LDU, U(p+1,p), 1 ) 1967 CONTINUE CALL DLASET( 'Upper', NR-1, NR-1, ZERO, ZERO, U(1,2), LDU ) * CALL DGESVJ( 'Lower', 'U', 'N', NR,NR, U, LDU, SVA, NR, A, $ LDA, WORK(N+1), LWORK-N, INFO ) SCALEM = WORK(N+1) NUMRANK = IDNINT(WORK(N+2)) * IF ( NR .LT. M ) THEN CALL DLASET( 'A', M-NR, NR,ZERO, ZERO, U(NR+1,1), LDU ) IF ( NR .LT. N1 ) THEN CALL DLASET( 'A',NR, N1-NR, ZERO, ZERO, U(1,NR+1), LDU ) CALL DLASET( 'A',M-NR,N1-NR,ZERO,ONE,U(NR+1,NR+1), LDU ) END IF END IF * CALL DORMQR( 'Left', 'No Tr', M, N1, N, A, LDA, WORK, U, $ LDU, WORK(N+1), LWORK-N, IERR ) * IF ( ROWPIV ) $ CALL DLASWP( N1, U, LDU, 1, M-1, IWORK(2*N+1), -1 ) * DO 1974 p = 1, N1 XSC = ONE / DNRM2( M, U(1,p), 1 ) CALL DSCAL( M, XSC, U(1,p), 1 ) 1974 CONTINUE * IF ( TRANSP ) THEN CALL DLACPY( 'All', N, N, U, LDU, V, LDV ) END IF * ELSE * * .. Full SVD .. * IF ( .NOT. JRACC ) THEN * IF ( .NOT. ALMORT ) THEN * * Second Preconditioning Step (QRF [with pivoting]) * Note that the composition of TRANSPOSE, QRF and TRANSPOSE is * equivalent to an LQF CALL. Since in many libraries the QRF * seems to be better optimized than the LQF, we do explicit * transpose and use the QRF. This is subject to changes in an * optimized implementation of DGEJSV. * DO 1968 p = 1, NR CALL DCOPY( N-p+1, A(p,p), LDA, V(p,p), 1 ) 1968 CONTINUE * * .. the following two loops perturb small entries to avoid * denormals in the second QR factorization, where they are * as good as zeros. This is done to avoid painfully slow * computation with denormals. The relative size of the perturbation * is a parameter that can be changed by the implementer. * This perturbation device will be obsolete on machines with * properly implemented arithmetic. * To switch it off, set L2PERT=.FALSE. To remove it from the * code, remove the action under L2PERT=.TRUE., leave the ELSE part. * The following two loops should be blocked and fused with the * transposed copy above. * IF ( L2PERT ) THEN XSC = DSQRT(SMALL) DO 2969 q = 1, NR TEMP1 = XSC*DABS( V(q,q) ) DO 2968 p = 1, N IF ( ( p .GT. q ) .AND. ( DABS(V(p,q)) .LE. TEMP1 ) $ .OR. ( p .LT. q ) ) $ V(p,q) = DSIGN( TEMP1, V(p,q) ) IF ( p .LT. q ) V(p,q) = - V(p,q) 2968 CONTINUE 2969 CONTINUE ELSE CALL DLASET( 'U', NR-1, NR-1, ZERO, ZERO, V(1,2), LDV ) END IF * * Estimate the row scaled condition number of R1 * (If R1 is rectangular, N > NR, then the condition number * of the leading NR x NR submatrix is estimated.) * CALL DLACPY( 'L', NR, NR, V, LDV, WORK(2*N+1), NR ) DO 3950 p = 1, NR TEMP1 = DNRM2(NR-p+1,WORK(2*N+(p-1)*NR+p),1) CALL DSCAL(NR-p+1,ONE/TEMP1,WORK(2*N+(p-1)*NR+p),1) 3950 CONTINUE CALL DPOCON('Lower',NR,WORK(2*N+1),NR,ONE,TEMP1, $ WORK(2*N+NR*NR+1),IWORK(M+2*N+1),IERR) CONDR1 = ONE / DSQRT(TEMP1) * .. here need a second oppinion on the condition number * .. then assume worst case scenario * R1 is OK for inverse <=> CONDR1 .LT. DBLE(N) * more conservative <=> CONDR1 .LT. DSQRT(DBLE(N)) * COND_OK = DSQRT(DBLE(NR)) *[TP] COND_OK is a tuning parameter. IF ( CONDR1 .LT. COND_OK ) THEN * .. the second QRF without pivoting. Note: in an optimized * implementation, this QRF should be implemented as the QRF * of a lower triangular matrix. * R1^t = Q2 * R2 CALL DGEQRF( N, NR, V, LDV, WORK(N+1), WORK(2*N+1), $ LWORK-2*N, IERR ) * IF ( L2PERT ) THEN XSC = DSQRT(SMALL)/EPSLN DO 3959 p = 2, NR DO 3958 q = 1, p - 1 TEMP1 = XSC * DMIN1(DABS(V(p,p)),DABS(V(q,q))) IF ( DABS(V(q,p)) .LE. TEMP1 ) $ V(q,p) = DSIGN( TEMP1, V(q,p) ) 3958 CONTINUE 3959 CONTINUE END IF * IF ( NR .NE. N ) $ CALL DLACPY( 'A', N, NR, V, LDV, WORK(2*N+1), N ) * .. save ... * * .. this transposed copy should be better than naive DO 1969 p = 1, NR - 1 CALL DCOPY( NR-p, V(p,p+1), LDV, V(p+1,p), 1 ) 1969 CONTINUE * CONDR2 = CONDR1 * ELSE * * .. ill-conditioned case: second QRF with pivoting * Note that windowed pivoting would be equaly good * numerically, and more run-time efficient. So, in * an optimal implementation, the next call to DGEQP3 * should be replaced with eg. CALL SGEQPX (ACM TOMS #782) * with properly (carefully) chosen parameters. * * R1^t * P2 = Q2 * R2 DO 3003 p = 1, NR IWORK(N+p) = 0 3003 CONTINUE CALL DGEQP3( N, NR, V, LDV, IWORK(N+1), WORK(N+1), $ WORK(2*N+1), LWORK-2*N, IERR ) ** CALL DGEQRF( N, NR, V, LDV, WORK(N+1), WORK(2*N+1), ** $ LWORK-2*N, IERR ) IF ( L2PERT ) THEN XSC = DSQRT(SMALL) DO 3969 p = 2, NR DO 3968 q = 1, p - 1 TEMP1 = XSC * DMIN1(DABS(V(p,p)),DABS(V(q,q))) IF ( DABS(V(q,p)) .LE. TEMP1 ) $ V(q,p) = DSIGN( TEMP1, V(q,p) ) 3968 CONTINUE 3969 CONTINUE END IF * CALL DLACPY( 'A', N, NR, V, LDV, WORK(2*N+1), N ) * IF ( L2PERT ) THEN XSC = DSQRT(SMALL) DO 8970 p = 2, NR DO 8971 q = 1, p - 1 TEMP1 = XSC * DMIN1(DABS(V(p,p)),DABS(V(q,q))) V(p,q) = - DSIGN( TEMP1, V(q,p) ) 8971 CONTINUE 8970 CONTINUE ELSE CALL DLASET( 'L',NR-1,NR-1,ZERO,ZERO,V(2,1),LDV ) END IF * Now, compute R2 = L3 * Q3, the LQ factorization. CALL DGELQF( NR, NR, V, LDV, WORK(2*N+N*NR+1), $ WORK(2*N+N*NR+NR+1), LWORK-2*N-N*NR-NR, IERR ) * .. and estimate the condition number CALL DLACPY( 'L',NR,NR,V,LDV,WORK(2*N+N*NR+NR+1),NR ) DO 4950 p = 1, NR TEMP1 = DNRM2( p, WORK(2*N+N*NR+NR+p), NR ) CALL DSCAL( p, ONE/TEMP1, WORK(2*N+N*NR+NR+p), NR ) 4950 CONTINUE CALL DPOCON( 'L',NR,WORK(2*N+N*NR+NR+1),NR,ONE,TEMP1, $ WORK(2*N+N*NR+NR+NR*NR+1),IWORK(M+2*N+1),IERR ) CONDR2 = ONE / DSQRT(TEMP1) * IF ( CONDR2 .GE. COND_OK ) THEN * .. save the Householder vectors used for Q3 * (this overwrittes the copy of R2, as it will not be * needed in this branch, but it does not overwritte the * Huseholder vectors of Q2.). CALL DLACPY( 'U', NR, NR, V, LDV, WORK(2*N+1), N ) * .. and the rest of the information on Q3 is in * WORK(2*N+N*NR+1:2*N+N*NR+N) END IF * END IF * IF ( L2PERT ) THEN XSC = DSQRT(SMALL) DO 4968 q = 2, NR TEMP1 = XSC * V(q,q) DO 4969 p = 1, q - 1 * V(p,q) = - DSIGN( TEMP1, V(q,p) ) V(p,q) = - DSIGN( TEMP1, V(p,q) ) 4969 CONTINUE 4968 CONTINUE ELSE CALL DLASET( 'U', NR-1,NR-1, ZERO,ZERO, V(1,2), LDV ) END IF * * Second preconditioning finished; continue with Jacobi SVD * The input matrix is lower trinagular. * * Recover the right singular vectors as solution of a well * conditioned triangular matrix equation. * IF ( CONDR1 .LT. COND_OK ) THEN * CALL DGESVJ( 'L','U','N',NR,NR,V,LDV,SVA,NR,U, $ LDU,WORK(2*N+N*NR+NR+1),LWORK-2*N-N*NR-NR,INFO ) SCALEM = WORK(2*N+N*NR+NR+1) NUMRANK = IDNINT(WORK(2*N+N*NR+NR+2)) DO 3970 p = 1, NR CALL DCOPY( NR, V(1,p), 1, U(1,p), 1 ) CALL DSCAL( NR, SVA(p), V(1,p), 1 ) 3970 CONTINUE * .. pick the right matrix equation and solve it * IF ( NR .EQ. N ) THEN * :)) .. best case, R1 is inverted. The solution of this matrix * equation is Q2*V2 = the product of the Jacobi rotations * used in DGESVJ, premultiplied with the orthogonal matrix * from the second QR factorization. CALL DTRSM( 'L','U','N','N', NR,NR,ONE, A,LDA, V,LDV ) ELSE * .. R1 is well conditioned, but non-square. Transpose(R2) * is inverted to get the product of the Jacobi rotations * used in DGESVJ. The Q-factor from the second QR * factorization is then built in explicitly. CALL DTRSM('L','U','T','N',NR,NR,ONE,WORK(2*N+1), $ N,V,LDV) IF ( NR .LT. N ) THEN CALL DLASET('A',N-NR,NR,ZERO,ZERO,V(NR+1,1),LDV) CALL DLASET('A',NR,N-NR,ZERO,ZERO,V(1,NR+1),LDV) CALL DLASET('A',N-NR,N-NR,ZERO,ONE,V(NR+1,NR+1),LDV) END IF CALL DORMQR('L','N',N,N,NR,WORK(2*N+1),N,WORK(N+1), $ V,LDV,WORK(2*N+N*NR+NR+1),LWORK-2*N-N*NR-NR,IERR) END IF * ELSE IF ( CONDR2 .LT. COND_OK ) THEN * * :) .. the input matrix A is very likely a relative of * the Kahan matrix :) * The matrix R2 is inverted. The solution of the matrix equation * is Q3^T*V3 = the product of the Jacobi rotations (appplied to * the lower triangular L3 from the LQ factorization of * R2=L3*Q3), pre-multiplied with the transposed Q3. CALL DGESVJ( 'L', 'U', 'N', NR, NR, V, LDV, SVA, NR, U, $ LDU, WORK(2*N+N*NR+NR+1), LWORK-2*N-N*NR-NR, INFO ) SCALEM = WORK(2*N+N*NR+NR+1) NUMRANK = IDNINT(WORK(2*N+N*NR+NR+2)) DO 3870 p = 1, NR CALL DCOPY( NR, V(1,p), 1, U(1,p), 1 ) CALL DSCAL( NR, SVA(p), U(1,p), 1 ) 3870 CONTINUE CALL DTRSM('L','U','N','N',NR,NR,ONE,WORK(2*N+1),N,U,LDU) * .. apply the permutation from the second QR factorization DO 873 q = 1, NR DO 872 p = 1, NR WORK(2*N+N*NR+NR+IWORK(N+p)) = U(p,q) 872 CONTINUE DO 874 p = 1, NR U(p,q) = WORK(2*N+N*NR+NR+p) 874 CONTINUE 873 CONTINUE IF ( NR .LT. N ) THEN CALL DLASET( 'A',N-NR,NR,ZERO,ZERO,V(NR+1,1),LDV ) CALL DLASET( 'A',NR,N-NR,ZERO,ZERO,V(1,NR+1),LDV ) CALL DLASET( 'A',N-NR,N-NR,ZERO,ONE,V(NR+1,NR+1),LDV ) END IF CALL DORMQR( 'L','N',N,N,NR,WORK(2*N+1),N,WORK(N+1), $ V,LDV,WORK(2*N+N*NR+NR+1),LWORK-2*N-N*NR-NR,IERR ) ELSE * Last line of defense. * #:( This is a rather pathological case: no scaled condition * improvement after two pivoted QR factorizations. Other * possibility is that the rank revealing QR factorization * or the condition estimator has failed, or the COND_OK * is set very close to ONE (which is unnecessary). Normally, * this branch should never be executed, but in rare cases of * failure of the RRQR or condition estimator, the last line of * defense ensures that DGEJSV completes the task. * Compute the full SVD of L3 using DGESVJ with explicit * accumulation of Jacobi rotations. CALL DGESVJ( 'L', 'U', 'V', NR, NR, V, LDV, SVA, NR, U, $ LDU, WORK(2*N+N*NR+NR+1), LWORK-2*N-N*NR-NR, INFO ) SCALEM = WORK(2*N+N*NR+NR+1) NUMRANK = IDNINT(WORK(2*N+N*NR+NR+2)) IF ( NR .LT. N ) THEN CALL DLASET( 'A',N-NR,NR,ZERO,ZERO,V(NR+1,1),LDV ) CALL DLASET( 'A',NR,N-NR,ZERO,ZERO,V(1,NR+1),LDV ) CALL DLASET( 'A',N-NR,N-NR,ZERO,ONE,V(NR+1,NR+1),LDV ) END IF CALL DORMQR( 'L','N',N,N,NR,WORK(2*N+1),N,WORK(N+1), $ V,LDV,WORK(2*N+N*NR+NR+1),LWORK-2*N-N*NR-NR,IERR ) * CALL DORMLQ( 'L', 'T', NR, NR, NR, WORK(2*N+1), N, $ WORK(2*N+N*NR+1), U, LDU, WORK(2*N+N*NR+NR+1), $ LWORK-2*N-N*NR-NR, IERR ) DO 773 q = 1, NR DO 772 p = 1, NR WORK(2*N+N*NR+NR+IWORK(N+p)) = U(p,q) 772 CONTINUE DO 774 p = 1, NR U(p,q) = WORK(2*N+N*NR+NR+p) 774 CONTINUE 773 CONTINUE * END IF * * Permute the rows of V using the (column) permutation from the * first QRF. Also, scale the columns to make them unit in * Euclidean norm. This applies to all cases. * TEMP1 = DSQRT(DBLE(N)) * EPSLN DO 1972 q = 1, N DO 972 p = 1, N WORK(2*N+N*NR+NR+IWORK(p)) = V(p,q) 972 CONTINUE DO 973 p = 1, N V(p,q) = WORK(2*N+N*NR+NR+p) 973 CONTINUE XSC = ONE / DNRM2( N, V(1,q), 1 ) IF ( (XSC .LT. (ONE-TEMP1)) .OR. (XSC .GT. (ONE+TEMP1)) ) $ CALL DSCAL( N, XSC, V(1,q), 1 ) 1972 CONTINUE * At this moment, V contains the right singular vectors of A. * Next, assemble the left singular vector matrix U (M x N). IF ( NR .LT. M ) THEN CALL DLASET( 'A', M-NR, NR, ZERO, ZERO, U(NR+1,1), LDU ) IF ( NR .LT. N1 ) THEN CALL DLASET('A',NR,N1-NR,ZERO,ZERO,U(1,NR+1),LDU) CALL DLASET('A',M-NR,N1-NR,ZERO,ONE,U(NR+1,NR+1),LDU) END IF END IF * * The Q matrix from the first QRF is built into the left singular * matrix U. This applies to all cases. * CALL DORMQR( 'Left', 'No_Tr', M, N1, N, A, LDA, WORK, U, $ LDU, WORK(N+1), LWORK-N, IERR ) * The columns of U are normalized. The cost is O(M*N) flops. TEMP1 = DSQRT(DBLE(M)) * EPSLN DO 1973 p = 1, NR XSC = ONE / DNRM2( M, U(1,p), 1 ) IF ( (XSC .LT. (ONE-TEMP1)) .OR. (XSC .GT. (ONE+TEMP1)) ) $ CALL DSCAL( M, XSC, U(1,p), 1 ) 1973 CONTINUE * * If the initial QRF is computed with row pivoting, the left * singular vectors must be adjusted. * IF ( ROWPIV ) $ CALL DLASWP( N1, U, LDU, 1, M-1, IWORK(2*N+1), -1 ) * ELSE * * .. the initial matrix A has almost orthogonal columns and * the second QRF is not needed * CALL DLACPY( 'Upper', N, N, A, LDA, WORK(N+1), N ) IF ( L2PERT ) THEN XSC = DSQRT(SMALL) DO 5970 p = 2, N TEMP1 = XSC * WORK( N + (p-1)*N + p ) DO 5971 q = 1, p - 1 WORK(N+(q-1)*N+p)=-DSIGN(TEMP1,WORK(N+(p-1)*N+q)) 5971 CONTINUE 5970 CONTINUE ELSE CALL DLASET( 'Lower',N-1,N-1,ZERO,ZERO,WORK(N+2),N ) END IF * CALL DGESVJ( 'Upper', 'U', 'N', N, N, WORK(N+1), N, SVA, $ N, U, LDU, WORK(N+N*N+1), LWORK-N-N*N, INFO ) * SCALEM = WORK(N+N*N+1) NUMRANK = IDNINT(WORK(N+N*N+2)) DO 6970 p = 1, N CALL DCOPY( N, WORK(N+(p-1)*N+1), 1, U(1,p), 1 ) CALL DSCAL( N, SVA(p), WORK(N+(p-1)*N+1), 1 ) 6970 CONTINUE * CALL DTRSM( 'Left', 'Upper', 'NoTrans', 'No UD', N, N, $ ONE, A, LDA, WORK(N+1), N ) DO 6972 p = 1, N CALL DCOPY( N, WORK(N+p), N, V(IWORK(p),1), LDV ) 6972 CONTINUE TEMP1 = DSQRT(DBLE(N))*EPSLN DO 6971 p = 1, N XSC = ONE / DNRM2( N, V(1,p), 1 ) IF ( (XSC .LT. (ONE-TEMP1)) .OR. (XSC .GT. (ONE+TEMP1)) ) $ CALL DSCAL( N, XSC, V(1,p), 1 ) 6971 CONTINUE * * Assemble the left singular vector matrix U (M x N). * IF ( N .LT. M ) THEN CALL DLASET( 'A', M-N, N, ZERO, ZERO, U(N+1,1), LDU ) IF ( N .LT. N1 ) THEN CALL DLASET( 'A',N, N1-N, ZERO, ZERO, U(1,N+1),LDU ) CALL DLASET( 'A',M-N,N1-N, ZERO, ONE,U(N+1,N+1),LDU ) END IF END IF CALL DORMQR( 'Left', 'No Tr', M, N1, N, A, LDA, WORK, U, $ LDU, WORK(N+1), LWORK-N, IERR ) TEMP1 = DSQRT(DBLE(M))*EPSLN DO 6973 p = 1, N1 XSC = ONE / DNRM2( M, U(1,p), 1 ) IF ( (XSC .LT. (ONE-TEMP1)) .OR. (XSC .GT. (ONE+TEMP1)) ) $ CALL DSCAL( M, XSC, U(1,p), 1 ) 6973 CONTINUE * IF ( ROWPIV ) $ CALL DLASWP( N1, U, LDU, 1, M-1, IWORK(2*N+1), -1 ) * END IF * * end of the >> almost orthogonal case << in the full SVD * ELSE * * This branch deploys a preconditioned Jacobi SVD with explicitly * accumulated rotations. It is included as optional, mainly for * experimental purposes. It does perfom well, and can also be used. * In this implementation, this branch will be automatically activated * if the condition number sigma_max(A) / sigma_min(A) is predicted * to be greater than the overflow threshold. This is because the * a posteriori computation of the singular vectors assumes robust * implementation of BLAS and some LAPACK procedures, capable of working * in presence of extreme values. Since that is not always the case, ... * DO 7968 p = 1, NR CALL DCOPY( N-p+1, A(p,p), LDA, V(p,p), 1 ) 7968 CONTINUE * IF ( L2PERT ) THEN XSC = DSQRT(SMALL/EPSLN) DO 5969 q = 1, NR TEMP1 = XSC*DABS( V(q,q) ) DO 5968 p = 1, N IF ( ( p .GT. q ) .AND. ( DABS(V(p,q)) .LE. TEMP1 ) $ .OR. ( p .LT. q ) ) $ V(p,q) = DSIGN( TEMP1, V(p,q) ) IF ( p .LT. q ) V(p,q) = - V(p,q) 5968 CONTINUE 5969 CONTINUE ELSE CALL DLASET( 'U', NR-1, NR-1, ZERO, ZERO, V(1,2), LDV ) END IF CALL DGEQRF( N, NR, V, LDV, WORK(N+1), WORK(2*N+1), $ LWORK-2*N, IERR ) CALL DLACPY( 'L', N, NR, V, LDV, WORK(2*N+1), N ) * DO 7969 p = 1, NR CALL DCOPY( NR-p+1, V(p,p), LDV, U(p,p), 1 ) 7969 CONTINUE IF ( L2PERT ) THEN XSC = DSQRT(SMALL/EPSLN) DO 9970 q = 2, NR DO 9971 p = 1, q - 1 TEMP1 = XSC * DMIN1(DABS(U(p,p)),DABS(U(q,q))) U(p,q) = - DSIGN( TEMP1, U(q,p) ) 9971 CONTINUE 9970 CONTINUE ELSE CALL DLASET('U', NR-1, NR-1, ZERO, ZERO, U(1,2), LDU ) END IF CALL DGESVJ( 'G', 'U', 'V', NR, NR, U, LDU, SVA, $ N, V, LDV, WORK(2*N+N*NR+1), LWORK-2*N-N*NR, INFO ) SCALEM = WORK(2*N+N*NR+1) NUMRANK = IDNINT(WORK(2*N+N*NR+2)) IF ( NR .LT. N ) THEN CALL DLASET( 'A',N-NR,NR,ZERO,ZERO,V(NR+1,1),LDV ) CALL DLASET( 'A',NR,N-NR,ZERO,ZERO,V(1,NR+1),LDV ) CALL DLASET( 'A',N-NR,N-NR,ZERO,ONE,V(NR+1,NR+1),LDV ) END IF CALL DORMQR( 'L','N',N,N,NR,WORK(2*N+1),N,WORK(N+1), $ V,LDV,WORK(2*N+N*NR+NR+1),LWORK-2*N-N*NR-NR,IERR ) * * Permute the rows of V using the (column) permutation from the * first QRF. Also, scale the columns to make them unit in * Euclidean norm. This applies to all cases. * TEMP1 = DSQRT(DBLE(N)) * EPSLN DO 7972 q = 1, N DO 8972 p = 1, N WORK(2*N+N*NR+NR+IWORK(p)) = V(p,q) 8972 CONTINUE DO 8973 p = 1, N V(p,q) = WORK(2*N+N*NR+NR+p) 8973 CONTINUE XSC = ONE / DNRM2( N, V(1,q), 1 ) IF ( (XSC .LT. (ONE-TEMP1)) .OR. (XSC .GT. (ONE+TEMP1)) ) $ CALL DSCAL( N, XSC, V(1,q), 1 ) 7972 CONTINUE * * At this moment, V contains the right singular vectors of A. * Next, assemble the left singular vector matrix U (M x N). * IF ( NR .LT. M ) THEN CALL DLASET( 'A', M-NR, NR, ZERO, ZERO, U(NR+1,1), LDU ) IF ( NR .LT. N1 ) THEN CALL DLASET( 'A',NR, N1-NR, ZERO, ZERO, U(1,NR+1),LDU ) CALL DLASET( 'A',M-NR,N1-NR, ZERO, ONE,U(NR+1,NR+1),LDU ) END IF END IF * CALL DORMQR( 'Left', 'No Tr', M, N1, N, A, LDA, WORK, U, $ LDU, WORK(N+1), LWORK-N, IERR ) * IF ( ROWPIV ) $ CALL DLASWP( N1, U, LDU, 1, M-1, IWORK(2*N+1), -1 ) * * END IF IF ( TRANSP ) THEN * .. swap U and V because the procedure worked on A^t DO 6974 p = 1, N CALL DSWAP( N, U(1,p), 1, V(1,p), 1 ) 6974 CONTINUE END IF * END IF * end of the full SVD * * Undo scaling, if necessary (and possible) * IF ( USCAL2 .LE. (BIG/SVA(1))*USCAL1 ) THEN CALL DLASCL( 'G', 0, 0, USCAL1, USCAL2, NR, 1, SVA, N, IERR ) USCAL1 = ONE USCAL2 = ONE END IF * IF ( NR .LT. N ) THEN DO 3004 p = NR+1, N SVA(p) = ZERO 3004 CONTINUE END IF * WORK(1) = USCAL2 * SCALEM WORK(2) = USCAL1 IF ( ERREST ) WORK(3) = SCONDA IF ( LSVEC .AND. RSVEC ) THEN WORK(4) = CONDR1 WORK(5) = CONDR2 END IF IF ( L2TRAN ) THEN WORK(6) = ENTRA WORK(7) = ENTRAT END IF * IWORK(1) = NR IWORK(2) = NUMRANK IWORK(3) = WARNING * RETURN * .. * .. END OF DGEJSV * .. END *
zhmz90/OpenBLAS
lapack-netlib/SRC/dgejsv.f
FORTRAN
bsd-3-clause
72,388
[ 30522, 1008, 1028, 1032, 4766, 1032, 1038, 1040, 3351, 22578, 2615, 1008, 1008, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 12653, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1008, 1008, 3784, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Belkyra</title> <!-- Bootstrap Core CSS --> <link href="../css/bootstrap.min.css" rel="stylesheet"> <!-- Custom CSS --> <link href="../css/services.css" rel="stylesheet"> <!-- Import fonts --> <link href="https://fonts.googleapis.com/css?family=Alegreya+Sans+SC|Open+Sans" rel="stylesheet"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <!-- Navigation --> <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <!-- contact-bar --> <div class="contact-bar container"> <div class="contact-info"> <div class="phone-number"> <a id="facebook-icon" href="https://www.facebook.com/mdlaserskinclinic"> <img width="20px" height="20px" src="https://cdn1.iconfinder.com/data/icons/logotypes/32/square-facebook-512.png"> </a> <p>416-445-7546</p> </div> </div> </div> <div class="container"> <div class="navbar-header page-scroll"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <div class="navbar-header"> <a class= "navbar-brand logo page-scroll" href="../index.html"> <img id="MD-logo" alt="logo" src="../css/imgs/logo.png"> </a> <a id="title" class= "navbar-brand text page-scroll" href="../index.html"> Laser Skin Clinic </br> and medi-spa </a> </div> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav navbar-right"> <!-- Hidden li included to remove active class from about link when scrolled up past about section --> <li class="hidden"> <a class="page-scroll" href="../index.html#page-top"></a> </li> <li> <a class="page-scroll" href="../index.html#about">about</a> </li> <li> <a class="page-scroll" href="../index.html#treatments">treatments</a> </li> <li> <a class="page-scroll" href="../index.html#products">products</a> </li> <li> <a class="page-scroll" href="../index.html#specials">specials</a> </li> <li> <a class="page-scroll" href="../index.html#staff"> staff </a> </li> <li> <a class="page-scroll" href="../index.html#contact">contact</a> </li> </ul> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> <div class="container information"> <div class="row"> <h1>BELKYRA®</h1> <div class="col-sm-8"> <p class="description">BELKYRA® is an innovative injection treatment for both men and women who want to permanently reduce the appearance of a mild to moderate “double chin”, (that is, the fat area under the mandible), without surgery. BELKYRA® is the first and only Health Canada approved injectable treatment for this purpose, meeting research-based, safety requirements. It is not recommended for the treatment of severe fat accumulation in the chin and neck. </p> <br><br> </div> <div class="col-sm-4 photo"> <img src="../css/imgs/belkyra-add.png"> </div> </div> <div class="row"> <div class="faq col-sm-8"> <h3>How does BELKYRA® work?</h3> <p> The active ingredient in BELKYRA® is deoxycholic acid, a naturally occurring molecule in the body that aids in the breakdown and absorption of dietary fat. Once it is injected into the skin under the submental chin area, BELKYRA® targets and eliminates fat cells when injected into the area under your chin over a period of 6-8 weeks. Many patients treated with BELKYRA® experience visible improvement with 2 – 4 treatments. Very rarely, up to a maximum of 6 treatments are needed to achieve ideal results. </p> <br> <h3>How is BELKYRA® administered?</h3> <p> BELKYRA® is given in a series of small injections into the skin under the chin, requiring about 15-20mins to complete. It is relatively painless, but some burning sensation within the first 15-20 mins is expected and desired. </p> <br> <h3>What are the side effects and is there downtime?</h3> <p> For most people, the downtime is minimal and occurs most after the first treatment session. As with other injectible treatments, you may experience some post-op transient pain, bruising and numbness under the chin after the procedure. . In most cases, the use of ice packs will make the injection procedure completely tolerable without using topical anaesthetic creams. In clinical trials, mild burning pain after treatment was gone within 15-30 minutes of treatment. <br> However, the main side-effect from the procedure is immediate swelling in the area due to injecting fluid under the chin, and later, due to inflammation as the fat cells melt down and are disposed by the immune system. Therefore, it is important to expect that things will look worse, before it gets better. Given that the result is permanent without surgery, the side effects are insignificant. </p> <br> <h3>How much does it cost?</h3> <p> BELKYRA® injections require a minimum of 2 to 4 treatments to have efficacy to reduce a double chin depending on the size of the area to be treated. The maximum number of treatments is six, according to the approved guidelines. At MD Laser Skin Clinic, we charge $2200 for the first 2 sessions (spaced 6-8 weeks apart), and $800 for any subsequent treatments, up to a maximum of 6. </p> <br> <p> For more information and an assessment if BELKYRA therapy is the right treatment for you, please call us for a consultation with our trained medical professional. </p> <a id="book-btn" href="../index.html#contact"><button type="button" class="btn btn-default"> Book Today </button></a> </div> <div class="treatments-menu col-sm-4"> <h3>More Treatments:</h3> <ul> <li><a href="botox-for-wrinkles.html">Botox Cosmetic®</a></li> <li><a href="filler.html">Fillers</a></li> <li><a href="botox-for-sweating.html">Botox Therapeutic® (exessive sweating)</a></li> <li><a href="laser-IPL-hair-removal.html">Laser Hair Removal</a></li> <li><a href="botox-for-tmjd.html">Botox Therapeutic® (TMJ muscle pain)</a></li> <li><a href="microneedling.html">Microneedling</a></li> <li><a href="medical-facials.html">Medical Facials</a></li> <li><a href="IPL-photofacial.html">IPL Photofacial Rejuvenation</a></li> <li><a href="chemical-peel.html">Chemical Peeling</a></li> <li><a href="belkyra.html">Belkyra®</a></li> </ul> </div> </div> </div> <footer> <div class="row container"> <div class="col-md-4 nav"> <h4> MD Laser Skin Clinic</h4> <a href="../index.html#about">About</a> </br> <a href="../index.html#treatments">Treatments</a></br> <a href="../index.html#products">Products</a></br> <a href="../index.html#staff">Staff</a></br> <a href="../index.html#specials">Specials</a></br> <a href="../index.html#contact">Contact</a></br> </div> <div class="col-md-4 contact-info"> <h4>Contact Us</h4> <p> Call: 416-445-7546</p> <p> Email: smilestoronto@bellnet.ca</p> <p id="trademark">BOTOX COSMETIC® is a registered trademark of Allergan Inc. <br> LATISSE® is a registered trademark of Allergan Inc. <br> SOFT LIFT™ is a trademark of Allergan Inc. <br> JUVEDERM® is a registered trademark of Allergan Holdings France SAS <br> VOLBELLA™ is a trademark of Allergan Inc. <br> VOLUMA® is a registered trademark of Allergan Inc. </p> <a href="../disclaimer.html">disclaimer</a> </div> <div class="col-md-4 address"> <h4>Address</h4> <p>1200 Lawrence Avenue East</p> <p>Suite 204</p> <p>North York, Ontario</p> <p>M3A 1C1</p> </div> </div> </footer> <!-- jQuery --> <script src="js/jquery.js"></script> <script src="js/custom-jquery.js"></script> <!-- Bootstrap Core JavaScript --> <script src="js/bootstrap.min.js"></script> <!-- Scrolling Nav JavaScript --> <script src="js/jquery.easing.min.js"></script> <script src="js/scrolling-nav.js"></script> </body> </html>
tjlam/tjlam.github.io
services/belkyra.html
HTML
apache-2.0
10,799
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 1060, 1011, 25423, 1011, 11...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // Copyright (C) 2011 Vicente J. Botet Escriba // // 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) // <future> // class promise<R> // promise(promise&& rhs); #define BOOST_THREAD_VERSION 3 #include <boost/thread/future.hpp> #include <boost/detail/lightweight_test.hpp> boost::mutex m; int main() { { typedef int T; boost::promise<T> p; boost::future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future()); boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(f.valid()); } { typedef int T; boost::future<T> f0; boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(!f.valid()); } { typedef int& T; boost::promise<T> p; boost::future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future()); boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(f.valid()); } { typedef int& T; boost::future<T> f0; boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(!f.valid()); } { typedef void T; boost::promise<T> p; boost::future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future()); boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(f.valid()); } { typedef void T; boost::future<T> f0; boost::future<T> f = boost::move(f0); BOOST_TEST(!f0.valid()); BOOST_TEST(!f.valid()); } return boost::report_errors(); }
djsedulous/namecoind
libs/boost_1_50_0/libs/thread/test/sync/futures/future/move_ctor_pass.cpp
C++
mit
1,982
[ 30522, 1013, 1013, 1027, 1027, 1027, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import {PlatformLiveSyncServiceBase} from "./platform-livesync-service-base"; class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase { constructor(_liveSyncData: ILiveSyncData, protected $devicesService: Mobile.IDevicesService, protected $mobileHelper: Mobile.IMobileHelper, protected $logger: ILogger, protected $options: IOptions, protected $deviceAppDataFactory: Mobile.IDeviceAppDataFactory, protected $fs: IFileSystem, protected $injector: IInjector, protected $projectFilesManager: IProjectFilesManager, protected $projectFilesProvider: IProjectFilesProvider, protected $platformService: IPlatformService, protected $liveSyncProvider: ILiveSyncProvider) { super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $platformService, $liveSyncProvider); } public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> { return (() => { let appIdentifier = this.liveSyncData.appIdentifier; let platform = this.liveSyncData.platform; let projectFilesPath = this.liveSyncData.projectFilesPath; let canExecute = this.getCanExecuteAction(platform, appIdentifier); let action = (device: Mobile.IDevice): IFuture<void> => { return (() => { let deviceLiveSyncService = this.resolveDeviceSpecificLiveSyncService(platform, device); let deviceAppData = this.$deviceAppDataFactory.create(appIdentifier, this.$mobileHelper.normalizePlatformName(platform), device); deviceLiveSyncService.beforeLiveSyncAction(deviceAppData).wait();; let installed = this.tryInstallApplication(device, deviceAppData).wait(); let localToDevicePaths = this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, null, this.liveSyncData.excludedProjectDirsAndFiles); let afterSyncAction: () => IFuture<void>; if (installed) { deviceLiveSyncService.afterInstallApplicationAction(deviceAppData, localToDevicePaths).wait(); afterSyncAction = () => device.applicationManager.tryStartApplication(deviceAppData.appIdentifier); } else { this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, true).wait(); afterSyncAction = () => this.refreshApplication(deviceAppData, localToDevicePaths); } if (postAction) { this.finishLivesync(deviceAppData).wait(); return postAction(deviceAppData, localToDevicePaths).wait(); } afterSyncAction().wait(); this.finishLivesync(deviceAppData).wait(); }).future<void>()(); }; this.$devicesService.execute(action, canExecute).wait(); }).future<void>()(); } } $injector.register("androidPlatformLiveSyncServiceLocator", {factory: AndroidPlatformLiveSyncService});
tsvetie/nativescript-cli
lib/services/livesync/android-platform-livesync-service.ts
TypeScript
apache-2.0
2,894
[ 30522, 12324, 1063, 4132, 3669, 6961, 6038, 6169, 2121, 7903, 15878, 11022, 1065, 2013, 1000, 1012, 1013, 4132, 1011, 3268, 6038, 2278, 1011, 2326, 1011, 2918, 1000, 1025, 2465, 11924, 24759, 4017, 14192, 3669, 6961, 6038, 6169, 2121, 7903,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Qafoo\ChangeTrack\FISCalculator; class TransactionDatabase { /** * Row based data set * * @var array */ private $data; /** * Items that occur in this data base * * @var string[] */ private $items = array(); /** * @param array $data */ public function __construct(array $data = array()) { foreach ($data as $transactionIndex => $transaction) { foreach ($transaction as $item) { $this->addItem($transactionIndex, $item); } } } /** * Adds $item to the transaction with $transactionIndex * * @param string $transactionIndex * @param \Qafoo\ChangeTrack\FISCalculator\Item $item */ public function addItem($transactionIndex, Item $item) { if (!isset($this->data[$transactionIndex])) { $this->data[$transactionIndex] = array(); } $this->data[$transactionIndex][$item->getHash()] = true; $this->items[$item->getHash()] = $item; } /** * Calculates the support for $itemSet * * @param array $itemSet * @return float */ public function support(Set $itemSet) { $occurrences = 0; foreach ($this->data as $transaction) { foreach ($itemSet as $item) { if (!isset($transaction[$item->getHash()])) { continue 2; } } $occurrences++; } return $occurrences / count($this->data); } /** * Returns the items used in this transaction data base. * * @return \Qafoo\ChangeTrack\FISCalculator\Item[] */ public function getItems() { return array_values($this->items); } }
Qafoo/changetrack
src/main/Qafoo/ChangeTrack/FISCalculator/TransactionDatabase.php
PHP
mit
1,795
[ 30522, 1026, 1029, 25718, 3415, 15327, 1053, 10354, 9541, 1032, 2689, 6494, 3600, 1032, 10807, 19879, 4263, 1025, 2465, 12598, 2850, 2696, 15058, 1063, 1013, 1008, 1008, 1008, 5216, 2241, 2951, 2275, 1008, 1008, 1030, 13075, 9140, 1008, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * linux/mm/vmscan.c * * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds * * Swap reorganised 29.12.95, Stephen Tweedie. * kswapd added: 7.1.96 sct * Removed kswapd_ctl limits, and swap out as many pages as needed * to bring the system back to freepages.high: 2.4.97, Rik van Riel. * Zone aware kswapd started 02/00, Kanoj Sarcar (kanoj@sgi.com). * Multiqueue VM started 5.8.00, Rik van Riel. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/mm.h> #include <linux/module.h> #include <linux/gfp.h> #include <linux/kernel_stat.h> #include <linux/swap.h> #include <linux/pagemap.h> #include <linux/init.h> #include <linux/highmem.h> #include <linux/vmpressure.h> #include <linux/vmstat.h> #include <linux/file.h> #include <linux/writeback.h> #include <linux/blkdev.h> #include <linux/buffer_head.h> /* for try_to_release_page(), buffer_heads_over_limit */ #include <linux/mm_inline.h> #include <linux/backing-dev.h> #include <linux/rmap.h> #include <linux/topology.h> #include <linux/cpu.h> #include <linux/cpuset.h> #include <linux/compaction.h> #include <linux/notifier.h> #include <linux/rwsem.h> #include <linux/delay.h> #include <linux/kthread.h> #include <linux/freezer.h> #include <linux/memcontrol.h> #include <linux/delayacct.h> #include <linux/sysctl.h> #include <linux/oom.h> #include <linux/prefetch.h> #include <linux/printk.h> #include <asm/tlbflush.h> #include <asm/div64.h> #include <linux/swapops.h> #include <linux/balloon_compaction.h> #include "internal.h" #define CREATE_TRACE_POINTS #include <trace/events/vmscan.h> struct scan_control { /* How many pages shrink_list() should reclaim */ unsigned long nr_to_reclaim; /* This context's GFP mask */ gfp_t gfp_mask; /* Allocation order */ int order; /* * Nodemask of nodes allowed by the caller. If NULL, all nodes * are scanned. */ nodemask_t *nodemask; /* * The memory cgroup that hit its limit and as a result is the * primary target of this reclaim invocation. */ struct mem_cgroup *target_mem_cgroup; /* Scan (total_size >> priority) pages at once */ int priority; unsigned int may_writepage:1; /* Can mapped pages be reclaimed? */ unsigned int may_unmap:1; /* Can pages be swapped as part of reclaim? */ unsigned int may_swap:1; /* Can cgroups be reclaimed below their normal consumption range? */ unsigned int may_thrash:1; unsigned int hibernation_mode:1; /* One of the zones is ready for compaction */ unsigned int compaction_ready:1; /* Incremented by the number of inactive pages that were scanned */ unsigned long nr_scanned; /* Number of pages freed so far during a call to shrink_zones() */ unsigned long nr_reclaimed; }; #define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru)) #ifdef ARCH_HAS_PREFETCH #define prefetch_prev_lru_page(_page, _base, _field) \ do { \ if ((_page)->lru.prev != _base) { \ struct page *prev; \ \ prev = lru_to_page(&(_page->lru)); \ prefetch(&prev->_field); \ } \ } while (0) #else #define prefetch_prev_lru_page(_page, _base, _field) do { } while (0) #endif #ifdef ARCH_HAS_PREFETCHW #define prefetchw_prev_lru_page(_page, _base, _field) \ do { \ if ((_page)->lru.prev != _base) { \ struct page *prev; \ \ prev = lru_to_page(&(_page->lru)); \ prefetchw(&prev->_field); \ } \ } while (0) #else #define prefetchw_prev_lru_page(_page, _base, _field) do { } while (0) #endif /* * From 0 .. 100. Higher means more swappy. */ int vm_swappiness = 60; /* * The total number of pages which are beyond the high watermark within all * zones. */ unsigned long vm_total_pages; static LIST_HEAD(shrinker_list); static DECLARE_RWSEM(shrinker_rwsem); #ifdef CONFIG_MEMCG static bool global_reclaim(struct scan_control *sc) { return !sc->target_mem_cgroup; } /** * sane_reclaim - is the usual dirty throttling mechanism operational? * @sc: scan_control in question * * The normal page dirty throttling mechanism in balance_dirty_pages() is * completely broken with the legacy memcg and direct stalling in * shrink_page_list() is used for throttling instead, which lacks all the * niceties such as fairness, adaptive pausing, bandwidth proportional * allocation and configurability. * * This function tests whether the vmscan currently in progress can assume * that the normal dirty throttling mechanism is operational. */ static bool sane_reclaim(struct scan_control *sc) { struct mem_cgroup *memcg = sc->target_mem_cgroup; if (!memcg) return true; #ifdef CONFIG_CGROUP_WRITEBACK if (cgroup_on_dfl(mem_cgroup_css(memcg)->cgroup)) return true; #endif return false; } #else static bool global_reclaim(struct scan_control *sc) { return true; } static bool sane_reclaim(struct scan_control *sc) { return true; } #endif static unsigned long zone_reclaimable_pages(struct zone *zone) { int nr; nr = zone_page_state(zone, NR_ACTIVE_FILE) + zone_page_state(zone, NR_INACTIVE_FILE); if (get_nr_swap_pages() > 0) nr += zone_page_state(zone, NR_ACTIVE_ANON) + zone_page_state(zone, NR_INACTIVE_ANON); return nr; } bool zone_reclaimable(struct zone *zone) { return zone_page_state(zone, NR_PAGES_SCANNED) < zone_reclaimable_pages(zone) * 6; } static unsigned long get_lru_size(struct lruvec *lruvec, enum lru_list lru) { if (!mem_cgroup_disabled()) return mem_cgroup_get_lru_size(lruvec, lru); return zone_page_state(lruvec_zone(lruvec), NR_LRU_BASE + lru); } /* * Add a shrinker callback to be called from the vm. */ int register_shrinker(struct shrinker *shrinker) { size_t size = sizeof(*shrinker->nr_deferred); /* * If we only have one possible node in the system anyway, save * ourselves the trouble and disable NUMA aware behavior. This way we * will save memory and some small loop time later. */ if (nr_node_ids == 1) shrinker->flags &= ~SHRINKER_NUMA_AWARE; if (shrinker->flags & SHRINKER_NUMA_AWARE) size *= nr_node_ids; shrinker->nr_deferred = kzalloc(size, GFP_KERNEL); if (!shrinker->nr_deferred) return -ENOMEM; down_write(&shrinker_rwsem); list_add_tail(&shrinker->list, &shrinker_list); up_write(&shrinker_rwsem); return 0; } EXPORT_SYMBOL(register_shrinker); /* * Remove one */ void unregister_shrinker(struct shrinker *shrinker) { down_write(&shrinker_rwsem); list_del(&shrinker->list); up_write(&shrinker_rwsem); kfree(shrinker->nr_deferred); } EXPORT_SYMBOL(unregister_shrinker); #define SHRINK_BATCH 128 static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, struct shrinker *shrinker, unsigned long nr_scanned, unsigned long nr_eligible) { unsigned long freed = 0; unsigned long long delta; long total_scan; long freeable; long nr; long new_nr; int nid = shrinkctl->nid; long batch_size = shrinker->batch ? shrinker->batch : SHRINK_BATCH; freeable = shrinker->count_objects(shrinker, shrinkctl); if (freeable == 0) return 0; /* * copy the current shrinker scan count into a local variable * and zero it so that other concurrent shrinker invocations * don't also do this scanning work. */ nr = atomic_long_xchg(&shrinker->nr_deferred[nid], 0); total_scan = nr; delta = (4 * nr_scanned) / shrinker->seeks; delta *= freeable; do_div(delta, nr_eligible + 1); total_scan += delta; if (total_scan < 0) { pr_err("shrink_slab: %pF negative objects to delete nr=%ld\n", shrinker->scan_objects, total_scan); total_scan = freeable; } /* * We need to avoid excessive windup on filesystem shrinkers * due to large numbers of GFP_NOFS allocations causing the * shrinkers to return -1 all the time. This results in a large * nr being built up so when a shrink that can do some work * comes along it empties the entire cache due to nr >>> * freeable. This is bad for sustaining a working set in * memory. * * Hence only allow the shrinker to scan the entire cache when * a large delta change is calculated directly. */ if (delta < freeable / 4) total_scan = min(total_scan, freeable / 2); /* * Avoid risking looping forever due to too large nr value: * never try to free more than twice the estimate number of * freeable entries. */ if (total_scan > freeable * 2) total_scan = freeable * 2; trace_mm_shrink_slab_start(shrinker, shrinkctl, nr, nr_scanned, nr_eligible, freeable, delta, total_scan); /* * Normally, we should not scan less than batch_size objects in one * pass to avoid too frequent shrinker calls, but if the slab has less * than batch_size objects in total and we are really tight on memory, * we will try to reclaim all available objects, otherwise we can end * up failing allocations although there are plenty of reclaimable * objects spread over several slabs with usage less than the * batch_size. * * We detect the "tight on memory" situations by looking at the total * number of objects we want to scan (total_scan). If it is greater * than the total number of objects on slab (freeable), we must be * scanning at high prio and therefore should try to reclaim as much as * possible. */ while (total_scan >= batch_size || total_scan >= freeable) { unsigned long ret; unsigned long nr_to_scan = min(batch_size, total_scan); shrinkctl->nr_to_scan = nr_to_scan; ret = shrinker->scan_objects(shrinker, shrinkctl); if (ret == SHRINK_STOP) break; freed += ret; count_vm_events(SLABS_SCANNED, nr_to_scan); total_scan -= nr_to_scan; cond_resched(); } /* * move the unused scan count back into the shrinker in a * manner that handles concurrent updates. If we exhausted the * scan, there is no need to do an update. */ if (total_scan > 0) new_nr = atomic_long_add_return(total_scan, &shrinker->nr_deferred[nid]); else new_nr = atomic_long_read(&shrinker->nr_deferred[nid]); trace_mm_shrink_slab_end(shrinker, nid, freed, nr, new_nr, total_scan); return freed; } /** * shrink_slab - shrink slab caches * @gfp_mask: allocation context * @nid: node whose slab caches to target * @memcg: memory cgroup whose slab caches to target * @nr_scanned: pressure numerator * @nr_eligible: pressure denominator * * Call the shrink functions to age shrinkable caches. * * @nid is passed along to shrinkers with SHRINKER_NUMA_AWARE set, * unaware shrinkers will receive a node id of 0 instead. * * @memcg specifies the memory cgroup to target. If it is not NULL, * only shrinkers with SHRINKER_MEMCG_AWARE set will be called to scan * objects from the memory cgroup specified. Otherwise all shrinkers * are called, and memcg aware shrinkers are supposed to scan the * global list then. * * @nr_scanned and @nr_eligible form a ratio that indicate how much of * the available objects should be scanned. Page reclaim for example * passes the number of pages scanned and the number of pages on the * LRU lists that it considered on @nid, plus a bias in @nr_scanned * when it encountered mapped pages. The ratio is further biased by * the ->seeks setting of the shrink function, which indicates the * cost to recreate an object relative to that of an LRU page. * * Returns the number of reclaimed slab objects. */ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, unsigned long nr_scanned, unsigned long nr_eligible) { struct shrinker *shrinker; unsigned long freed = 0; if (memcg && !memcg_kmem_is_active(memcg)) return 0; if (nr_scanned == 0) nr_scanned = SWAP_CLUSTER_MAX; if (!down_read_trylock(&shrinker_rwsem)) { /* * If we would return 0, our callers would understand that we * have nothing else to shrink and give up trying. By returning * 1 we keep it going and assume we'll be able to shrink next * time. */ freed = 1; goto out; } list_for_each_entry(shrinker, &shrinker_list, list) { struct shrink_control sc = { .gfp_mask = gfp_mask, .nid = nid, .memcg = memcg, }; if (memcg && !(shrinker->flags & SHRINKER_MEMCG_AWARE)) continue; if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) sc.nid = 0; freed += do_shrink_slab(&sc, shrinker, nr_scanned, nr_eligible); } up_read(&shrinker_rwsem); out: cond_resched(); return freed; } void drop_slab_node(int nid) { unsigned long freed; do { struct mem_cgroup *memcg = NULL; freed = 0; do { freed += shrink_slab(GFP_KERNEL, nid, memcg, 1000, 1000); } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); } while (freed > 10); } void drop_slab(void) { int nid; for_each_online_node(nid) drop_slab_node(nid); } static inline int is_page_cache_freeable(struct page *page) { /* * A freeable page cache page is referenced only by the caller * that isolated the page, the page cache radix tree and * optional buffer heads at page->private. */ return page_count(page) - page_has_private(page) == 2; } static int may_write_to_inode(struct inode *inode, struct scan_control *sc) { if (current->flags & PF_SWAPWRITE) return 1; if (!inode_write_congested(inode)) return 1; if (inode_to_bdi(inode) == current->backing_dev_info) return 1; return 0; } /* * We detected a synchronous write error writing a page out. Probably * -ENOSPC. We need to propagate that into the address_space for a subsequent * fsync(), msync() or close(). * * The tricky part is that after writepage we cannot touch the mapping: nothing * prevents it from being freed up. But we have a ref on the page and once * that page is locked, the mapping is pinned. * * We're allowed to run sleeping lock_page() here because we know the caller has * __GFP_FS. */ static void handle_write_error(struct address_space *mapping, struct page *page, int error) { lock_page(page); if (page_mapping(page) == mapping) mapping_set_error(mapping, error); unlock_page(page); } /* possible outcome of pageout() */ typedef enum { /* failed to write page out, page is locked */ PAGE_KEEP, /* move page to the active list, page is locked */ PAGE_ACTIVATE, /* page has been sent to the disk successfully, page is unlocked */ PAGE_SUCCESS, /* page is clean and locked */ PAGE_CLEAN, } pageout_t; /* * pageout is called by shrink_page_list() for each dirty page. * Calls ->writepage(). */ static pageout_t pageout(struct page *page, struct address_space *mapping, struct scan_control *sc) { /* * If the page is dirty, only perform writeback if that write * will be non-blocking. To prevent this allocation from being * stalled by pagecache activity. But note that there may be * stalls if we need to run get_block(). We could test * PagePrivate for that. * * If this process is currently in __generic_file_write_iter() against * this page's queue, we can perform writeback even if that * will block. * * If the page is swapcache, write it back even if that would * block, for some throttling. This happens by accident, because * swap_backing_dev_info is bust: it doesn't reflect the * congestion state of the swapdevs. Easy to fix, if needed. */ if (!is_page_cache_freeable(page)) return PAGE_KEEP; if (!mapping) { /* * Some data journaling orphaned pages can have * page->mapping == NULL while being dirty with clean buffers. */ if (page_has_private(page)) { if (try_to_free_buffers(page)) { ClearPageDirty(page); pr_info("%s: orphaned page\n", __func__); return PAGE_CLEAN; } } return PAGE_KEEP; } if (mapping->a_ops->writepage == NULL) return PAGE_ACTIVATE; if (!may_write_to_inode(mapping->host, sc)) return PAGE_KEEP; if (clear_page_dirty_for_io(page)) { int res; struct writeback_control wbc = { .sync_mode = WB_SYNC_NONE, .nr_to_write = SWAP_CLUSTER_MAX, .range_start = 0, .range_end = LLONG_MAX, .for_reclaim = 1, }; SetPageReclaim(page); res = mapping->a_ops->writepage(page, &wbc); if (res < 0) handle_write_error(mapping, page, res); if (res == AOP_WRITEPAGE_ACTIVATE) { ClearPageReclaim(page); return PAGE_ACTIVATE; } if (!PageWriteback(page)) { /* synchronous write or broken a_ops? */ ClearPageReclaim(page); } trace_mm_vmscan_writepage(page, trace_reclaim_flags(page)); inc_zone_page_state(page, NR_VMSCAN_WRITE); return PAGE_SUCCESS; } return PAGE_CLEAN; } /* * Same as remove_mapping, but if the page is removed from the mapping, it * gets returned with a refcount of 0. */ static int __remove_mapping(struct address_space *mapping, struct page *page, bool reclaimed) { unsigned long flags; struct mem_cgroup *memcg; BUG_ON(!PageLocked(page)); BUG_ON(mapping != page_mapping(page)); memcg = mem_cgroup_begin_page_stat(page); spin_lock_irqsave(&mapping->tree_lock, flags); /* * The non racy check for a busy page. * * Must be careful with the order of the tests. When someone has * a ref to the page, it may be possible that they dirty it then * drop the reference. So if PageDirty is tested before page_count * here, then the following race may occur: * * get_user_pages(&page); * [user mapping goes away] * write_to(page); * !PageDirty(page) [good] * SetPageDirty(page); * put_page(page); * !page_count(page) [good, discard it] * * [oops, our write_to data is lost] * * Reversing the order of the tests ensures such a situation cannot * escape unnoticed. The smp_rmb is needed to ensure the page->flags * load is not satisfied before that of page->_count. * * Note that if SetPageDirty is always performed via set_page_dirty, * and thus under tree_lock, then this ordering is not required. */ if (!page_freeze_refs(page, 2)) goto cannot_free; /* note: atomic_cmpxchg in page_freeze_refs provides the smp_rmb */ if (unlikely(PageDirty(page))) { page_unfreeze_refs(page, 2); goto cannot_free; } if (PageSwapCache(page)) { swp_entry_t swap = { .val = page_private(page) }; mem_cgroup_swapout(page, swap); __delete_from_swap_cache(page); spin_unlock_irqrestore(&mapping->tree_lock, flags); mem_cgroup_end_page_stat(memcg); swapcache_free(swap); } else { void (*freepage)(struct page *); void *shadow = NULL; freepage = mapping->a_ops->freepage; /* * Remember a shadow entry for reclaimed file cache in * order to detect refaults, thus thrashing, later on. * * But don't store shadows in an address space that is * already exiting. This is not just an optizimation, * inode reclaim needs to empty out the radix tree or * the nodes are lost. Don't plant shadows behind its * back. */ if (reclaimed && page_is_file_cache(page) && !mapping_exiting(mapping)) shadow = workingset_eviction(mapping, page); __delete_from_page_cache(page, shadow, memcg); spin_unlock_irqrestore(&mapping->tree_lock, flags); mem_cgroup_end_page_stat(memcg); if (freepage != NULL) freepage(page); } return 1; cannot_free: spin_unlock_irqrestore(&mapping->tree_lock, flags); mem_cgroup_end_page_stat(memcg); return 0; } /* * Attempt to detach a locked page from its ->mapping. If it is dirty or if * someone else has a ref on the page, abort and return 0. If it was * successfully detached, return 1. Assumes the caller has a single ref on * this page. */ int remove_mapping(struct address_space *mapping, struct page *page) { if (__remove_mapping(mapping, page, false)) { /* * Unfreezing the refcount with 1 rather than 2 effectively * drops the pagecache ref for us without requiring another * atomic operation. */ page_unfreeze_refs(page, 1); return 1; } return 0; } /** * putback_lru_page - put previously isolated page onto appropriate LRU list * @page: page to be put back to appropriate lru list * * Add previously isolated @page to appropriate LRU list. * Page may still be unevictable for other reasons. * * lru_lock must not be held, interrupts must be enabled. */ void putback_lru_page(struct page *page) { bool is_unevictable; int was_unevictable = PageUnevictable(page); VM_BUG_ON_PAGE(PageLRU(page), page); redo: ClearPageUnevictable(page); if (page_evictable(page)) { /* * For evictable pages, we can use the cache. * In event of a race, worst case is we end up with an * unevictable page on [in]active list. * We know how to handle that. */ is_unevictable = false; lru_cache_add(page); } else { /* * Put unevictable pages directly on zone's unevictable * list. */ is_unevictable = true; add_page_to_unevictable_list(page); /* * When racing with an mlock or AS_UNEVICTABLE clearing * (page is unlocked) make sure that if the other thread * does not observe our setting of PG_lru and fails * isolation/check_move_unevictable_pages, * we see PG_mlocked/AS_UNEVICTABLE cleared below and move * the page back to the evictable list. * * The other side is TestClearPageMlocked() or shmem_lock(). */ smp_mb(); } /* * page's status can change while we move it among lru. If an evictable * page is on unevictable list, it never be freed. To avoid that, * check after we added it to the list, again. */ if (is_unevictable && page_evictable(page)) { if (!isolate_lru_page(page)) { put_page(page); goto redo; } /* This means someone else dropped this page from LRU * So, it will be freed or putback to LRU again. There is * nothing to do here. */ } if (was_unevictable && !is_unevictable) count_vm_event(UNEVICTABLE_PGRESCUED); else if (!was_unevictable && is_unevictable) count_vm_event(UNEVICTABLE_PGCULLED); put_page(page); /* drop ref from isolate */ } enum page_references { PAGEREF_RECLAIM, PAGEREF_RECLAIM_CLEAN, PAGEREF_KEEP, PAGEREF_ACTIVATE, }; static enum page_references page_check_references(struct page *page, struct scan_control *sc) { int referenced_ptes, referenced_page; unsigned long vm_flags; referenced_ptes = page_referenced(page, 1, sc->target_mem_cgroup, &vm_flags); referenced_page = TestClearPageReferenced(page); /* * Mlock lost the isolation race with us. Let try_to_unmap() * move the page to the unevictable list. */ if (vm_flags & VM_LOCKED) return PAGEREF_RECLAIM; if (referenced_ptes) { if (PageSwapBacked(page)) return PAGEREF_ACTIVATE; /* * All mapped pages start out with page table * references from the instantiating fault, so we need * to look twice if a mapped file page is used more * than once. * * Mark it and spare it for another trip around the * inactive list. Another page table reference will * lead to its activation. * * Note: the mark is set for activated pages as well * so that recently deactivated but used pages are * quickly recovered. */ SetPageReferenced(page); if (referenced_page || referenced_ptes > 1) return PAGEREF_ACTIVATE; /* * Activate file-backed executable pages after first usage. */ if (vm_flags & VM_EXEC) return PAGEREF_ACTIVATE; return PAGEREF_KEEP; } /* Reclaim if clean, defer dirty pages to writeback */ if (referenced_page && !PageSwapBacked(page)) return PAGEREF_RECLAIM_CLEAN; return PAGEREF_RECLAIM; } /* Check if a page is dirty or under writeback */ static void page_check_dirty_writeback(struct page *page, bool *dirty, bool *writeback) { struct address_space *mapping; /* * Anonymous pages are not handled by flushers and must be written * from reclaim context. Do not stall reclaim based on them */ if (!page_is_file_cache(page)) { *dirty = false; *writeback = false; return; } /* By default assume that the page flags are accurate */ *dirty = PageDirty(page); *writeback = PageWriteback(page); /* Verify dirty/writeback state if the filesystem supports it */ if (!page_has_private(page)) return; mapping = page_mapping(page); if (mapping && mapping->a_ops->is_dirty_writeback) mapping->a_ops->is_dirty_writeback(page, dirty, writeback); } /* * shrink_page_list() returns the number of reclaimed pages */ static unsigned long shrink_page_list(struct list_head *page_list, struct zone *zone, struct scan_control *sc, enum ttu_flags ttu_flags, unsigned long *ret_nr_dirty, unsigned long *ret_nr_unqueued_dirty, unsigned long *ret_nr_congested, unsigned long *ret_nr_writeback, unsigned long *ret_nr_immediate, bool force_reclaim) { LIST_HEAD(ret_pages); LIST_HEAD(free_pages); int pgactivate = 0; unsigned long nr_unqueued_dirty = 0; unsigned long nr_dirty = 0; unsigned long nr_congested = 0; unsigned long nr_reclaimed = 0; unsigned long nr_writeback = 0; unsigned long nr_immediate = 0; cond_resched(); while (!list_empty(page_list)) { struct address_space *mapping; struct page *page; int may_enter_fs; enum page_references references = PAGEREF_RECLAIM_CLEAN; bool dirty, writeback; cond_resched(); page = lru_to_page(page_list); list_del(&page->lru); if (!trylock_page(page)) goto keep; VM_BUG_ON_PAGE(PageActive(page), page); VM_BUG_ON_PAGE(page_zone(page) != zone, page); sc->nr_scanned++; if (unlikely(!page_evictable(page))) goto cull_mlocked; if (!sc->may_unmap && page_mapped(page)) goto keep_locked; /* Double the slab pressure for mapped and swapcache pages */ if (page_mapped(page) || PageSwapCache(page)) sc->nr_scanned++; may_enter_fs = (sc->gfp_mask & __GFP_FS) || (PageSwapCache(page) && (sc->gfp_mask & __GFP_IO)); /* * The number of dirty pages determines if a zone is marked * reclaim_congested which affects wait_iff_congested. kswapd * will stall and start writing pages if the tail of the LRU * is all dirty unqueued pages. */ page_check_dirty_writeback(page, &dirty, &writeback); if (dirty || writeback) nr_dirty++; if (dirty && !writeback) nr_unqueued_dirty++; /* * Treat this page as congested if the underlying BDI is or if * pages are cycling through the LRU so quickly that the * pages marked for immediate reclaim are making it to the * end of the LRU a second time. */ mapping = page_mapping(page); if (((dirty || writeback) && mapping && inode_write_congested(mapping->host)) || (writeback && PageReclaim(page))) nr_congested++; /* * If a page at the tail of the LRU is under writeback, there * are three cases to consider. * * 1) If reclaim is encountering an excessive number of pages * under writeback and this page is both under writeback and * PageReclaim then it indicates that pages are being queued * for IO but are being recycled through the LRU before the * IO can complete. Waiting on the page itself risks an * indefinite stall if it is impossible to writeback the * page due to IO error or disconnected storage so instead * note that the LRU is being scanned too quickly and the * caller can stall after page list has been processed. * * 2) Global or new memcg reclaim encounters a page that is * not marked for immediate reclaim, or the caller does not * have __GFP_FS (or __GFP_IO if it's simply going to swap, * not to fs). In this case mark the page for immediate * reclaim and continue scanning. * * Require may_enter_fs because we would wait on fs, which * may not have submitted IO yet. And the loop driver might * enter reclaim, and deadlock if it waits on a page for * which it is needed to do the write (loop masks off * __GFP_IO|__GFP_FS for this reason); but more thought * would probably show more reasons. * * 3) Legacy memcg encounters a page that is not already marked * PageReclaim. memcg does not have any dirty pages * throttling so we could easily OOM just because too many * pages are in writeback and there is nothing else to * reclaim. Wait for the writeback to complete. */ if (PageWriteback(page)) { /* Case 1 above */ if (current_is_kswapd() && PageReclaim(page) && test_bit(ZONE_WRITEBACK, &zone->flags)) { nr_immediate++; goto keep_locked; /* Case 2 above */ } else if (sane_reclaim(sc) || !PageReclaim(page) || !may_enter_fs) { /* * This is slightly racy - end_page_writeback() * might have just cleared PageReclaim, then * setting PageReclaim here end up interpreted * as PageReadahead - but that does not matter * enough to care. What we do want is for this * page to have PageReclaim set next time memcg * reclaim reaches the tests above, so it will * then wait_on_page_writeback() to avoid OOM; * and it's also appropriate in global reclaim. */ SetPageReclaim(page); nr_writeback++; goto keep_locked; /* Case 3 above */ } else { wait_on_page_writeback(page); } } if (!force_reclaim) references = page_check_references(page, sc); switch (references) { case PAGEREF_ACTIVATE: goto activate_locked; case PAGEREF_KEEP: goto keep_locked; case PAGEREF_RECLAIM: case PAGEREF_RECLAIM_CLEAN: ; /* try to reclaim the page below */ } /* * Anonymous process memory has backing store? * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { if (!(sc->gfp_mask & __GFP_IO)) goto keep_locked; if (!add_to_swap(page, page_list)) goto activate_locked; may_enter_fs = 1; /* Adding to swap updated mapping */ mapping = page_mapping(page); } /* * The page is mapped into the page tables of one or more * processes. Try to unmap it here. */ if (page_mapped(page) && mapping) { switch (try_to_unmap(page, ttu_flags)) { case SWAP_FAIL: goto activate_locked; case SWAP_AGAIN: goto keep_locked; case SWAP_MLOCK: goto cull_mlocked; case SWAP_SUCCESS: ; /* try to free the page below */ } } if (PageDirty(page)) { /* * Only kswapd can writeback filesystem pages to * avoid risk of stack overflow but only writeback * if many dirty pages have been encountered. */ if (page_is_file_cache(page) && (!current_is_kswapd() || !test_bit(ZONE_DIRTY, &zone->flags))) { /* * Immediately reclaim when written back. * Similar in principal to deactivate_page() * except we already have the page isolated * and know it's dirty */ inc_zone_page_state(page, NR_VMSCAN_IMMEDIATE); SetPageReclaim(page); goto keep_locked; } if (references == PAGEREF_RECLAIM_CLEAN) goto keep_locked; if (!may_enter_fs) goto keep_locked; if (!sc->may_writepage) goto keep_locked; /* Page is dirty, try to write it out here */ switch (pageout(page, mapping, sc)) { case PAGE_KEEP: goto keep_locked; case PAGE_ACTIVATE: goto activate_locked; case PAGE_SUCCESS: if (PageWriteback(page)) goto keep; if (PageDirty(page)) goto keep; /* * A synchronous write - probably a ramdisk. Go * ahead and try to reclaim the page. */ if (!trylock_page(page)) goto keep; if (PageDirty(page) || PageWriteback(page)) goto keep_locked; mapping = page_mapping(page); case PAGE_CLEAN: ; /* try to free the page below */ } } /* * If the page has buffers, try to free the buffer mappings * associated with this page. If we succeed we try to free * the page as well. * * We do this even if the page is PageDirty(). * try_to_release_page() does not perform I/O, but it is * possible for a page to have PageDirty set, but it is actually * clean (all its buffers are clean). This happens if the * buffers were written out directly, with submit_bh(). ext3 * will do this, as well as the blockdev mapping. * try_to_release_page() will discover that cleanness and will * drop the buffers and mark the page clean - it can be freed. * * Rarely, pages can have buffers and no ->mapping. These are * the pages which were not successfully invalidated in * truncate_complete_page(). We try to drop those buffers here * and if that worked, and the page is no longer mapped into * process address space (page_count == 1) it can be freed. * Otherwise, leave the page on the LRU so it is swappable. */ if (page_has_private(page)) { if (!try_to_release_page(page, sc->gfp_mask)) goto activate_locked; if (!mapping && page_count(page) == 1) { unlock_page(page); if (put_page_testzero(page)) goto free_it; else { /* * rare race with speculative reference. * the speculative reference will free * this page shortly, so we may * increment nr_reclaimed here (and * leave it off the LRU). */ nr_reclaimed++; continue; } } } if (!mapping || !__remove_mapping(mapping, page, true)) goto keep_locked; /* * At this point, we have no other references and there is * no way to pick any more up (removed from LRU, removed * from pagecache). Can use non-atomic bitops now (and * we obviously don't have to worry about waking up a process * waiting on the page lock, because there are no references. */ __clear_page_locked(page); free_it: nr_reclaimed++; /* * Is there need to periodically free_page_list? It would * appear not as the counts should be low */ list_add(&page->lru, &free_pages); continue; cull_mlocked: if (PageSwapCache(page)) try_to_free_swap(page); unlock_page(page); list_add(&page->lru, &ret_pages); continue; activate_locked: /* Not a candidate for swapping, so reclaim swap space. */ if (PageSwapCache(page) && vm_swap_full()) try_to_free_swap(page); VM_BUG_ON_PAGE(PageActive(page), page); SetPageActive(page); pgactivate++; keep_locked: unlock_page(page); keep: list_add(&page->lru, &ret_pages); VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page), page); } mem_cgroup_uncharge_list(&free_pages); free_hot_cold_page_list(&free_pages, true); list_splice(&ret_pages, page_list); count_vm_events(PGACTIVATE, pgactivate); *ret_nr_dirty += nr_dirty; *ret_nr_congested += nr_congested; *ret_nr_unqueued_dirty += nr_unqueued_dirty; *ret_nr_writeback += nr_writeback; *ret_nr_immediate += nr_immediate; return nr_reclaimed; } unsigned long reclaim_clean_pages_from_list(struct zone *zone, struct list_head *page_list) { struct scan_control sc = { .gfp_mask = GFP_KERNEL, .priority = DEF_PRIORITY, .may_unmap = 1, }; unsigned long ret, dummy1, dummy2, dummy3, dummy4, dummy5; struct page *page, *next; LIST_HEAD(clean_pages); list_for_each_entry_safe(page, next, page_list, lru) { if (page_is_file_cache(page) && !PageDirty(page) && !isolated_balloon_page(page)) { ClearPageActive(page); list_move(&page->lru, &clean_pages); } } ret = shrink_page_list(&clean_pages, zone, &sc, TTU_UNMAP|TTU_IGNORE_ACCESS, &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, true); list_splice(&clean_pages, page_list); mod_zone_page_state(zone, NR_ISOLATED_FILE, -ret); return ret; } /* * Attempt to remove the specified page from its LRU. Only take this page * if it is of the appropriate PageActive status. Pages which are being * freed elsewhere are also ignored. * * page: page to consider * mode: one of the LRU isolation modes defined above * * returns 0 on success, -ve errno on failure. */ int __isolate_lru_page(struct page *page, isolate_mode_t mode) { int ret = -EINVAL; /* Only take pages on the LRU. */ if (!PageLRU(page)) return ret; /* Compaction should not handle unevictable pages but CMA can do so */ if (PageUnevictable(page) && !(mode & ISOLATE_UNEVICTABLE)) return ret; ret = -EBUSY; /* * To minimise LRU disruption, the caller can indicate that it only * wants to isolate pages it will be able to operate on without * blocking - clean pages for the most part. * * ISOLATE_CLEAN means that only clean pages should be isolated. This * is used by reclaim when it is cannot write to backing storage * * ISOLATE_ASYNC_MIGRATE is used to indicate that it only wants to pages * that it is possible to migrate without blocking */ if (mode & (ISOLATE_CLEAN|ISOLATE_ASYNC_MIGRATE)) { /* All the caller can do on PageWriteback is block */ if (PageWriteback(page)) return ret; if (PageDirty(page)) { struct address_space *mapping; /* ISOLATE_CLEAN means only clean pages */ if (mode & ISOLATE_CLEAN) return ret; /* * Only pages without mappings or that have a * ->migratepage callback are possible to migrate * without blocking */ mapping = page_mapping(page); if (mapping && !mapping->a_ops->migratepage) return ret; } } if ((mode & ISOLATE_UNMAPPED) && page_mapped(page)) return ret; if (likely(get_page_unless_zero(page))) { /* * Be careful not to clear PageLRU until after we're * sure the page is not being freed elsewhere -- the * page release code relies on it. */ ClearPageLRU(page); ret = 0; } return ret; } /* * zone->lru_lock is heavily contended. Some of the functions that * shrink the lists perform better by taking out a batch of pages * and working on them outside the LRU lock. * * For pagecache intensive workloads, this function is the hottest * spot in the kernel (apart from copy_*_user functions). * * Appropriate locks must be held before calling this function. * * @nr_to_scan: The number of pages to look through on the list. * @lruvec: The LRU vector to pull pages from. * @dst: The temp list to put pages on to. * @nr_scanned: The number of pages that were scanned. * @sc: The scan_control struct for this reclaim session * @mode: One of the LRU isolation modes * @lru: LRU list id for isolating * * returns how many pages were moved onto *@dst. */ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, struct lruvec *lruvec, struct list_head *dst, unsigned long *nr_scanned, struct scan_control *sc, isolate_mode_t mode, enum lru_list lru) { struct list_head *src = &lruvec->lists[lru]; unsigned long nr_taken = 0; unsigned long scan; for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) { struct page *page; int nr_pages; page = lru_to_page(src); prefetchw_prev_lru_page(page, src, flags); VM_BUG_ON_PAGE(!PageLRU(page), page); switch (__isolate_lru_page(page, mode)) { case 0: nr_pages = hpage_nr_pages(page); mem_cgroup_update_lru_size(lruvec, lru, -nr_pages); list_move(&page->lru, dst); nr_taken += nr_pages; break; case -EBUSY: /* else it is being freed elsewhere */ list_move(&page->lru, src); continue; default: BUG(); } } *nr_scanned = scan; trace_mm_vmscan_lru_isolate(sc->order, nr_to_scan, scan, nr_taken, mode, is_file_lru(lru)); return nr_taken; } /** * isolate_lru_page - tries to isolate a page from its LRU list * @page: page to isolate from its LRU list * * Isolates a @page from an LRU list, clears PageLRU and adjusts the * vmstat statistic corresponding to whatever LRU list the page was on. * * Returns 0 if the page was removed from an LRU list. * Returns -EBUSY if the page was not on an LRU list. * * The returned page will have PageLRU() cleared. If it was found on * the active list, it will have PageActive set. If it was found on * the unevictable list, it will have the PageUnevictable bit set. That flag * may need to be cleared by the caller before letting the page go. * * The vmstat statistic corresponding to the list on which the page was * found will be decremented. * * Restrictions: * (1) Must be called with an elevated refcount on the page. This is a * fundamentnal difference from isolate_lru_pages (which is called * without a stable reference). * (2) the lru_lock must not be held. * (3) interrupts must be enabled. */ int isolate_lru_page(struct page *page) { int ret = -EBUSY; VM_BUG_ON_PAGE(!page_count(page), page); if (PageLRU(page)) { struct zone *zone = page_zone(page); struct lruvec *lruvec; spin_lock_irq(&zone->lru_lock); lruvec = mem_cgroup_page_lruvec(page, zone); if (PageLRU(page)) { int lru = page_lru(page); get_page(page); ClearPageLRU(page); del_page_from_lru_list(page, lruvec, lru); ret = 0; } spin_unlock_irq(&zone->lru_lock); } return ret; } /* * A direct reclaimer may isolate SWAP_CLUSTER_MAX pages from the LRU list and * then get resheduled. When there are massive number of tasks doing page * allocation, such sleeping direct reclaimers may keep piling up on each CPU, * the LRU list will go small and be scanned faster than necessary, leading to * unnecessary swapping, thrashing and OOM. */ static int too_many_isolated(struct zone *zone, int file, struct scan_control *sc) { unsigned long inactive, isolated; if (current_is_kswapd()) return 0; if (!sane_reclaim(sc)) return 0; if (file) { inactive = zone_page_state(zone, NR_INACTIVE_FILE); isolated = zone_page_state(zone, NR_ISOLATED_FILE); } else { inactive = zone_page_state(zone, NR_INACTIVE_ANON); isolated = zone_page_state(zone, NR_ISOLATED_ANON); } /* * GFP_NOIO/GFP_NOFS callers are allowed to isolate more pages, so they * won't get blocked by normal direct-reclaimers, forming a circular * deadlock. */ if ((sc->gfp_mask & GFP_IOFS) == GFP_IOFS) inactive >>= 3; return isolated > inactive; } static noinline_for_stack void putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) { struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; struct zone *zone = lruvec_zone(lruvec); LIST_HEAD(pages_to_free); /* * Put back any unfreeable pages. */ while (!list_empty(page_list)) { struct page *page = lru_to_page(page_list); int lru; VM_BUG_ON_PAGE(PageLRU(page), page); list_del(&page->lru); if (unlikely(!page_evictable(page))) { spin_unlock_irq(&zone->lru_lock); putback_lru_page(page); spin_lock_irq(&zone->lru_lock); continue; } lruvec = mem_cgroup_page_lruvec(page, zone); SetPageLRU(page); lru = page_lru(page); add_page_to_lru_list(page, lruvec, lru); if (is_active_lru(lru)) { int file = is_file_lru(lru); int numpages = hpage_nr_pages(page); reclaim_stat->recent_rotated[file] += numpages; } if (put_page_testzero(page)) { __ClearPageLRU(page); __ClearPageActive(page); del_page_from_lru_list(page, lruvec, lru); if (unlikely(PageCompound(page))) { spin_unlock_irq(&zone->lru_lock); mem_cgroup_uncharge(page); (*get_compound_page_dtor(page))(page); spin_lock_irq(&zone->lru_lock); } else list_add(&page->lru, &pages_to_free); } } /* * To save our caller's stack, now use input list for pages to free. */ list_splice(&pages_to_free, page_list); } /* * If a kernel thread (such as nfsd for loop-back mounts) services * a backing device by writing to the page cache it sets PF_LESS_THROTTLE. * In that case we should only throttle if the backing device it is * writing to is congested. In other cases it is safe to throttle. */ static int current_may_throttle(void) { return !(current->flags & PF_LESS_THROTTLE) || current->backing_dev_info == NULL || bdi_write_congested(current->backing_dev_info); } /* * shrink_inactive_list() is a helper for shrink_zone(). It returns the number * of reclaimed pages */ static noinline_for_stack unsigned long shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, struct scan_control *sc, enum lru_list lru) { LIST_HEAD(page_list); unsigned long nr_scanned; unsigned long nr_reclaimed = 0; unsigned long nr_taken; unsigned long nr_dirty = 0; unsigned long nr_congested = 0; unsigned long nr_unqueued_dirty = 0; unsigned long nr_writeback = 0; unsigned long nr_immediate = 0; isolate_mode_t isolate_mode = 0; int file = is_file_lru(lru); struct zone *zone = lruvec_zone(lruvec); struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; while (unlikely(too_many_isolated(zone, file, sc))) { congestion_wait(BLK_RW_ASYNC, HZ/10); /* We are about to die and free our memory. Return now. */ if (fatal_signal_pending(current)) return SWAP_CLUSTER_MAX; } lru_add_drain(); if (!sc->may_unmap) isolate_mode |= ISOLATE_UNMAPPED; if (!sc->may_writepage) isolate_mode |= ISOLATE_CLEAN; spin_lock_irq(&zone->lru_lock); nr_taken = isolate_lru_pages(nr_to_scan, lruvec, &page_list, &nr_scanned, sc, isolate_mode, lru); __mod_zone_page_state(zone, NR_LRU_BASE + lru, -nr_taken); __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, nr_taken); if (global_reclaim(sc)) { __mod_zone_page_state(zone, NR_PAGES_SCANNED, nr_scanned); if (current_is_kswapd()) __count_zone_vm_events(PGSCAN_KSWAPD, zone, nr_scanned); else __count_zone_vm_events(PGSCAN_DIRECT, zone, nr_scanned); } spin_unlock_irq(&zone->lru_lock); if (nr_taken == 0) return 0; nr_reclaimed = shrink_page_list(&page_list, zone, sc, TTU_UNMAP, &nr_dirty, &nr_unqueued_dirty, &nr_congested, &nr_writeback, &nr_immediate, false); spin_lock_irq(&zone->lru_lock); reclaim_stat->recent_scanned[file] += nr_taken; if (global_reclaim(sc)) { if (current_is_kswapd()) __count_zone_vm_events(PGSTEAL_KSWAPD, zone, nr_reclaimed); else __count_zone_vm_events(PGSTEAL_DIRECT, zone, nr_reclaimed); } putback_inactive_pages(lruvec, &page_list); __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken); spin_unlock_irq(&zone->lru_lock); mem_cgroup_uncharge_list(&page_list); free_hot_cold_page_list(&page_list, true); /* * If reclaim is isolating dirty pages under writeback, it implies * that the long-lived page allocation rate is exceeding the page * laundering rate. Either the global limits are not being effective * at throttling processes due to the page distribution throughout * zones or there is heavy usage of a slow backing device. The * only option is to throttle from reclaim context which is not ideal * as there is no guarantee the dirtying process is throttled in the * same way balance_dirty_pages() manages. * * Once a zone is flagged ZONE_WRITEBACK, kswapd will count the number * of pages under pages flagged for immediate reclaim and stall if any * are encountered in the nr_immediate check below. */ if (nr_writeback && nr_writeback == nr_taken) set_bit(ZONE_WRITEBACK, &zone->flags); /* * Legacy memcg will stall in page writeback so avoid forcibly * stalling here. */ if (sane_reclaim(sc)) { /* * Tag a zone as congested if all the dirty pages scanned were * backed by a congested BDI and wait_iff_congested will stall. */ if (nr_dirty && nr_dirty == nr_congested) set_bit(ZONE_CONGESTED, &zone->flags); /* * If dirty pages are scanned that are not queued for IO, it * implies that flushers are not keeping up. In this case, flag * the zone ZONE_DIRTY and kswapd will start writing pages from * reclaim context. */ if (nr_unqueued_dirty == nr_taken) set_bit(ZONE_DIRTY, &zone->flags); /* * If kswapd scans pages marked marked for immediate * reclaim and under writeback (nr_immediate), it implies * that pages are cycling through the LRU faster than * they are written so also forcibly stall. */ if (nr_immediate && current_may_throttle()) congestion_wait(BLK_RW_ASYNC, HZ/10); } /* * Stall direct reclaim for IO completions if underlying BDIs or zone * is congested. Allow kswapd to continue until it starts encountering * unqueued dirty pages or cycling through the LRU too quickly. */ if (!sc->hibernation_mode && !current_is_kswapd() && current_may_throttle()) wait_iff_congested(zone, BLK_RW_ASYNC, HZ/10); trace_mm_vmscan_lru_shrink_inactive(zone->zone_pgdat->node_id, zone_idx(zone), nr_scanned, nr_reclaimed, sc->priority, trace_shrink_flags(file)); return nr_reclaimed; } /* * This moves pages from the active list to the inactive list. * * We move them the other way if the page is referenced by one or more * processes, from rmap. * * If the pages are mostly unmapped, the processing is fast and it is * appropriate to hold zone->lru_lock across the whole operation. But if * the pages are mapped, the processing is slow (page_referenced()) so we * should drop zone->lru_lock around each page. It's impossible to balance * this, so instead we remove the pages from the LRU while processing them. * It is safe to rely on PG_active against the non-LRU pages in here because * nobody will play with that bit on a non-LRU page. * * The downside is that we have to touch page->_count against each page. * But we had to alter page->flags anyway. */ static void move_active_pages_to_lru(struct lruvec *lruvec, struct list_head *list, struct list_head *pages_to_free, enum lru_list lru) { struct zone *zone = lruvec_zone(lruvec); unsigned long pgmoved = 0; struct page *page; int nr_pages; while (!list_empty(list)) { page = lru_to_page(list); lruvec = mem_cgroup_page_lruvec(page, zone); VM_BUG_ON_PAGE(PageLRU(page), page); SetPageLRU(page); nr_pages = hpage_nr_pages(page); mem_cgroup_update_lru_size(lruvec, lru, nr_pages); list_move(&page->lru, &lruvec->lists[lru]); pgmoved += nr_pages; if (put_page_testzero(page)) { __ClearPageLRU(page); __ClearPageActive(page); del_page_from_lru_list(page, lruvec, lru); if (unlikely(PageCompound(page))) { spin_unlock_irq(&zone->lru_lock); mem_cgroup_uncharge(page); (*get_compound_page_dtor(page))(page); spin_lock_irq(&zone->lru_lock); } else list_add(&page->lru, pages_to_free); } } __mod_zone_page_state(zone, NR_LRU_BASE + lru, pgmoved); if (!is_active_lru(lru)) __count_vm_events(PGDEACTIVATE, pgmoved); } static void shrink_active_list(unsigned long nr_to_scan, struct lruvec *lruvec, struct scan_control *sc, enum lru_list lru) { unsigned long nr_taken; unsigned long nr_scanned; unsigned long vm_flags; LIST_HEAD(l_hold); /* The pages which were snipped off */ LIST_HEAD(l_active); LIST_HEAD(l_inactive); struct page *page; struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; unsigned long nr_rotated = 0; isolate_mode_t isolate_mode = 0; int file = is_file_lru(lru); struct zone *zone = lruvec_zone(lruvec); lru_add_drain(); if (!sc->may_unmap) isolate_mode |= ISOLATE_UNMAPPED; if (!sc->may_writepage) isolate_mode |= ISOLATE_CLEAN; spin_lock_irq(&zone->lru_lock); nr_taken = isolate_lru_pages(nr_to_scan, lruvec, &l_hold, &nr_scanned, sc, isolate_mode, lru); if (global_reclaim(sc)) __mod_zone_page_state(zone, NR_PAGES_SCANNED, nr_scanned); reclaim_stat->recent_scanned[file] += nr_taken; __count_zone_vm_events(PGREFILL, zone, nr_scanned); __mod_zone_page_state(zone, NR_LRU_BASE + lru, -nr_taken); __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, nr_taken); spin_unlock_irq(&zone->lru_lock); while (!list_empty(&l_hold)) { cond_resched(); page = lru_to_page(&l_hold); list_del(&page->lru); if (unlikely(!page_evictable(page))) { putback_lru_page(page); continue; } if (unlikely(buffer_heads_over_limit)) { if (page_has_private(page) && trylock_page(page)) { if (page_has_private(page)) try_to_release_page(page, 0); unlock_page(page); } } if (page_referenced(page, 0, sc->target_mem_cgroup, &vm_flags)) { nr_rotated += hpage_nr_pages(page); /* * Identify referenced, file-backed active pages and * give them one more trip around the active list. So * that executable code get better chances to stay in * memory under moderate memory pressure. Anon pages * are not likely to be evicted by use-once streaming * IO, plus JVM can create lots of anon VM_EXEC pages, * so we ignore them here. */ if ((vm_flags & VM_EXEC) && page_is_file_cache(page)) { list_add(&page->lru, &l_active); continue; } } ClearPageActive(page); /* we are de-activating */ list_add(&page->lru, &l_inactive); } /* * Move pages back to the lru list. */ spin_lock_irq(&zone->lru_lock); /* * Count referenced pages from currently used mappings as rotated, * even though only some of them are actually re-activated. This * helps balance scan pressure between file and anonymous pages in * get_scan_count. */ reclaim_stat->recent_rotated[file] += nr_rotated; move_active_pages_to_lru(lruvec, &l_active, &l_hold, lru); move_active_pages_to_lru(lruvec, &l_inactive, &l_hold, lru - LRU_ACTIVE); __mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken); spin_unlock_irq(&zone->lru_lock); mem_cgroup_uncharge_list(&l_hold); free_hot_cold_page_list(&l_hold, true); } #ifdef CONFIG_SWAP static int inactive_anon_is_low_global(struct zone *zone) { unsigned long active, inactive; active = zone_page_state(zone, NR_ACTIVE_ANON); inactive = zone_page_state(zone, NR_INACTIVE_ANON); if (inactive * zone->inactive_ratio < active) return 1; return 0; } /** * inactive_anon_is_low - check if anonymous pages need to be deactivated * @lruvec: LRU vector to check * * Returns true if the zone does not have enough inactive anon pages, * meaning some active anon pages need to be deactivated. */ static int inactive_anon_is_low(struct lruvec *lruvec) { /* * If we don't have swap space, anonymous page deactivation * is pointless. */ if (!total_swap_pages) return 0; if (!mem_cgroup_disabled()) return mem_cgroup_inactive_anon_is_low(lruvec); return inactive_anon_is_low_global(lruvec_zone(lruvec)); } #else static inline int inactive_anon_is_low(struct lruvec *lruvec) { return 0; } #endif /** * inactive_file_is_low - check if file pages need to be deactivated * @lruvec: LRU vector to check * * When the system is doing streaming IO, memory pressure here * ensures that active file pages get deactivated, until more * than half of the file pages are on the inactive list. * * Once we get to that situation, protect the system's working * set from being evicted by disabling active file page aging. * * This uses a different ratio than the anonymous pages, because * the page cache uses a use-once replacement algorithm. */ static int inactive_file_is_low(struct lruvec *lruvec) { unsigned long inactive; unsigned long active; inactive = get_lru_size(lruvec, LRU_INACTIVE_FILE); active = get_lru_size(lruvec, LRU_ACTIVE_FILE); return active > inactive; } static int inactive_list_is_low(struct lruvec *lruvec, enum lru_list lru) { if (is_file_lru(lru)) return inactive_file_is_low(lruvec); else return inactive_anon_is_low(lruvec); } static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, struct lruvec *lruvec, struct scan_control *sc) { if (is_active_lru(lru)) { if (inactive_list_is_low(lruvec, lru)) shrink_active_list(nr_to_scan, lruvec, sc, lru); return 0; } return shrink_inactive_list(nr_to_scan, lruvec, sc, lru); } enum scan_balance { SCAN_EQUAL, SCAN_FRACT, SCAN_ANON, SCAN_FILE, }; /* * Determine how aggressively the anon and file LRU lists should be * scanned. The relative value of each set of LRU lists is determined * by looking at the fraction of the pages scanned we did rotate back * onto the active list instead of evict. * * nr[0] = anon inactive pages to scan; nr[1] = anon active pages to scan * nr[2] = file inactive pages to scan; nr[3] = file active pages to scan */ static void get_scan_count(struct lruvec *lruvec, int swappiness, struct scan_control *sc, unsigned long *nr, unsigned long *lru_pages) { struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; u64 fraction[2]; u64 denominator = 0; /* gcc */ struct zone *zone = lruvec_zone(lruvec); unsigned long anon_prio, file_prio; enum scan_balance scan_balance; unsigned long anon, file; bool force_scan = false; unsigned long ap, fp; enum lru_list lru; bool some_scanned; int pass; /* * If the zone or memcg is small, nr[l] can be 0. This * results in no scanning on this priority and a potential * priority drop. Global direct reclaim can go to the next * zone and tends to have no problems. Global kswapd is for * zone balancing and it needs to scan a minimum amount. When * reclaiming for a memcg, a priority drop can cause high * latencies, so it's better to scan a minimum amount there as * well. */ if (current_is_kswapd()) { if (!zone_reclaimable(zone)) force_scan = true; if (!mem_cgroup_lruvec_online(lruvec)) force_scan = true; } if (!global_reclaim(sc)) force_scan = true; /* If we have no swap space, do not bother scanning anon pages. */ if (!sc->may_swap || (get_nr_swap_pages() <= 0)) { scan_balance = SCAN_FILE; goto out; } /* * Global reclaim will swap to prevent OOM even with no * swappiness, but memcg users want to use this knob to * disable swapping for individual groups completely when * using the memory controller's swap limit feature would be * too expensive. */ if (!global_reclaim(sc) && !swappiness) { scan_balance = SCAN_FILE; goto out; } /* * Do not apply any pressure balancing cleverness when the * system is close to OOM, scan both anon and file equally * (unless the swappiness setting disagrees with swapping). */ if (!sc->priority && swappiness) { scan_balance = SCAN_EQUAL; goto out; } /* * Prevent the reclaimer from falling into the cache trap: as * cache pages start out inactive, every cache fault will tip * the scan balance towards the file LRU. And as the file LRU * shrinks, so does the window for rotation from references. * This means we have a runaway feedback loop where a tiny * thrashing file LRU becomes infinitely more attractive than * anon pages. Try to detect this based on file LRU size. */ if (global_reclaim(sc)) { unsigned long zonefile; unsigned long zonefree; zonefree = zone_page_state(zone, NR_FREE_PAGES); zonefile = zone_page_state(zone, NR_ACTIVE_FILE) + zone_page_state(zone, NR_INACTIVE_FILE); if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) { scan_balance = SCAN_ANON; goto out; } } /* * There is enough inactive page cache, do not reclaim * anything from the anonymous working set right now. */ if (!inactive_file_is_low(lruvec)) { scan_balance = SCAN_FILE; goto out; } scan_balance = SCAN_FRACT; /* * With swappiness at 100, anonymous and file have the same priority. * This scanning priority is essentially the inverse of IO cost. */ anon_prio = swappiness; file_prio = 200 - anon_prio; /* * OK, so we have swap space and a fair amount of page cache * pages. We use the recently rotated / recently scanned * ratios to determine how valuable each cache is. * * Because workloads change over time (and to avoid overflow) * we keep these statistics as a floating average, which ends * up weighing recent references more than old ones. * * anon in [0], file in [1] */ anon = get_lru_size(lruvec, LRU_ACTIVE_ANON) + get_lru_size(lruvec, LRU_INACTIVE_ANON); file = get_lru_size(lruvec, LRU_ACTIVE_FILE) + get_lru_size(lruvec, LRU_INACTIVE_FILE); spin_lock_irq(&zone->lru_lock); if (unlikely(reclaim_stat->recent_scanned[0] > anon / 4)) { reclaim_stat->recent_scanned[0] /= 2; reclaim_stat->recent_rotated[0] /= 2; } if (unlikely(reclaim_stat->recent_scanned[1] > file / 4)) { reclaim_stat->recent_scanned[1] /= 2; reclaim_stat->recent_rotated[1] /= 2; } /* * The amount of pressure on anon vs file pages is inversely * proportional to the fraction of recently scanned pages on * each list that were recently referenced and in active use. */ ap = anon_prio * (reclaim_stat->recent_scanned[0] + 1); ap /= reclaim_stat->recent_rotated[0] + 1; fp = file_prio * (reclaim_stat->recent_scanned[1] + 1); fp /= reclaim_stat->recent_rotated[1] + 1; spin_unlock_irq(&zone->lru_lock); fraction[0] = ap; fraction[1] = fp; denominator = ap + fp + 1; out: some_scanned = false; /* Only use force_scan on second pass. */ for (pass = 0; !some_scanned && pass < 2; pass++) { *lru_pages = 0; for_each_evictable_lru(lru) { int file = is_file_lru(lru); unsigned long size; unsigned long scan; size = get_lru_size(lruvec, lru); scan = size >> sc->priority; if (!scan && pass && force_scan) scan = min(size, SWAP_CLUSTER_MAX); switch (scan_balance) { case SCAN_EQUAL: /* Scan lists relative to size */ break; case SCAN_FRACT: /* * Scan types proportional to swappiness and * their relative recent reclaim efficiency. */ scan = div64_u64(scan * fraction[file], denominator); break; case SCAN_FILE: case SCAN_ANON: /* Scan one type exclusively */ if ((scan_balance == SCAN_FILE) != file) { size = 0; scan = 0; } break; default: /* Look ma, no brain */ BUG(); } *lru_pages += size; nr[lru] = scan; /* * Skip the second pass and don't force_scan, * if we found something to scan. */ some_scanned |= !!scan; } } } /* * This is a basic per-zone page freer. Used by both kswapd and direct reclaim. */ static void shrink_lruvec(struct lruvec *lruvec, int swappiness, struct scan_control *sc, unsigned long *lru_pages) { unsigned long nr[NR_LRU_LISTS]; unsigned long targets[NR_LRU_LISTS]; unsigned long nr_to_scan; enum lru_list lru; unsigned long nr_reclaimed = 0; unsigned long nr_to_reclaim = sc->nr_to_reclaim; struct blk_plug plug; bool scan_adjusted; get_scan_count(lruvec, swappiness, sc, nr, lru_pages); /* Record the original scan target for proportional adjustments later */ memcpy(targets, nr, sizeof(nr)); /* * Global reclaiming within direct reclaim at DEF_PRIORITY is a normal * event that can occur when there is little memory pressure e.g. * multiple streaming readers/writers. Hence, we do not abort scanning * when the requested number of pages are reclaimed when scanning at * DEF_PRIORITY on the assumption that the fact we are direct * reclaiming implies that kswapd is not keeping up and it is best to * do a batch of work at once. For memcg reclaim one check is made to * abort proportional reclaim if either the file or anon lru has already * dropped to zero at the first pass. */ scan_adjusted = (global_reclaim(sc) && !current_is_kswapd() && sc->priority == DEF_PRIORITY); blk_start_plug(&plug); while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || nr[LRU_INACTIVE_FILE]) { unsigned long nr_anon, nr_file, percentage; unsigned long nr_scanned; for_each_evictable_lru(lru) { if (nr[lru]) { nr_to_scan = min(nr[lru], SWAP_CLUSTER_MAX); nr[lru] -= nr_to_scan; nr_reclaimed += shrink_list(lru, nr_to_scan, lruvec, sc); } } if (nr_reclaimed < nr_to_reclaim || scan_adjusted) continue; /* * For kswapd and memcg, reclaim at least the number of pages * requested. Ensure that the anon and file LRUs are scanned * proportionally what was requested by get_scan_count(). We * stop reclaiming one LRU and reduce the amount scanning * proportional to the original scan target. */ nr_file = nr[LRU_INACTIVE_FILE] + nr[LRU_ACTIVE_FILE]; nr_anon = nr[LRU_INACTIVE_ANON] + nr[LRU_ACTIVE_ANON]; /* * It's just vindictive to attack the larger once the smaller * has gone to zero. And given the way we stop scanning the * smaller below, this makes sure that we only make one nudge * towards proportionality once we've got nr_to_reclaim. */ if (!nr_file || !nr_anon) break; if (nr_file > nr_anon) { unsigned long scan_target = targets[LRU_INACTIVE_ANON] + targets[LRU_ACTIVE_ANON] + 1; lru = LRU_BASE; percentage = nr_anon * 100 / scan_target; } else { unsigned long scan_target = targets[LRU_INACTIVE_FILE] + targets[LRU_ACTIVE_FILE] + 1; lru = LRU_FILE; percentage = nr_file * 100 / scan_target; } /* Stop scanning the smaller of the LRU */ nr[lru] = 0; nr[lru + LRU_ACTIVE] = 0; /* * Recalculate the other LRU scan count based on its original * scan target and the percentage scanning already complete */ lru = (lru == LRU_FILE) ? LRU_BASE : LRU_FILE; nr_scanned = targets[lru] - nr[lru]; nr[lru] = targets[lru] * (100 - percentage) / 100; nr[lru] -= min(nr[lru], nr_scanned); lru += LRU_ACTIVE; nr_scanned = targets[lru] - nr[lru]; nr[lru] = targets[lru] * (100 - percentage) / 100; nr[lru] -= min(nr[lru], nr_scanned); scan_adjusted = true; } blk_finish_plug(&plug); sc->nr_reclaimed += nr_reclaimed; /* * Even if we did not try to evict anon pages at all, we want to * rebalance the anon lru active/inactive ratio. */ if (inactive_anon_is_low(lruvec)) shrink_active_list(SWAP_CLUSTER_MAX, lruvec, sc, LRU_ACTIVE_ANON); throttle_vm_writeout(sc->gfp_mask); } /* Use reclaim/compaction for costly allocs or under memory pressure */ static bool in_reclaim_compaction(struct scan_control *sc) { if (IS_ENABLED(CONFIG_COMPACTION) && sc->order && (sc->order > PAGE_ALLOC_COSTLY_ORDER || sc->priority < DEF_PRIORITY - 2)) return true; return false; } /* * Reclaim/compaction is used for high-order allocation requests. It reclaims * order-0 pages before compacting the zone. should_continue_reclaim() returns * true if more pages should be reclaimed such that when the page allocator * calls try_to_compact_zone() that it will have enough free pages to succeed. * It will give up earlier than that if there is difficulty reclaiming pages. */ static inline bool should_continue_reclaim(struct zone *zone, unsigned long nr_reclaimed, unsigned long nr_scanned, struct scan_control *sc) { unsigned long pages_for_compaction; unsigned long inactive_lru_pages; /* If not in reclaim/compaction mode, stop */ if (!in_reclaim_compaction(sc)) return false; /* Consider stopping depending on scan and reclaim activity */ if (sc->gfp_mask & __GFP_REPEAT) { /* * For __GFP_REPEAT allocations, stop reclaiming if the * full LRU list has been scanned and we are still failing * to reclaim pages. This full LRU scan is potentially * expensive but a __GFP_REPEAT caller really wants to succeed */ if (!nr_reclaimed && !nr_scanned) return false; } else { /* * For non-__GFP_REPEAT allocations which can presumably * fail without consequence, stop if we failed to reclaim * any pages from the last SWAP_CLUSTER_MAX number of * pages that were scanned. This will return to the * caller faster at the risk reclaim/compaction and * the resulting allocation attempt fails */ if (!nr_reclaimed) return false; } /* * If we have not reclaimed enough pages for compaction and the * inactive lists are large enough, continue reclaiming */ pages_for_compaction = (2UL << sc->order); inactive_lru_pages = zone_page_state(zone, NR_INACTIVE_FILE); if (get_nr_swap_pages() > 0) inactive_lru_pages += zone_page_state(zone, NR_INACTIVE_ANON); if (sc->nr_reclaimed < pages_for_compaction && inactive_lru_pages > pages_for_compaction) return true; /* If compaction would go ahead or the allocation would succeed, stop */ switch (compaction_suitable(zone, sc->order, 0, 0)) { case COMPACT_PARTIAL: case COMPACT_CONTINUE: return false; default: return true; } } static bool shrink_zone(struct zone *zone, struct scan_control *sc, bool is_classzone) { struct reclaim_state *reclaim_state = current->reclaim_state; unsigned long nr_reclaimed, nr_scanned; bool reclaimable = false; do { struct mem_cgroup *root = sc->target_mem_cgroup; struct mem_cgroup_reclaim_cookie reclaim = { .zone = zone, .priority = sc->priority, }; unsigned long zone_lru_pages = 0; struct mem_cgroup *memcg; nr_reclaimed = sc->nr_reclaimed; nr_scanned = sc->nr_scanned; memcg = mem_cgroup_iter(root, NULL, &reclaim); do { unsigned long lru_pages; unsigned long scanned; struct lruvec *lruvec; int swappiness; if (mem_cgroup_low(root, memcg)) { if (!sc->may_thrash) continue; mem_cgroup_events(memcg, MEMCG_LOW, 1); } lruvec = mem_cgroup_zone_lruvec(zone, memcg); swappiness = mem_cgroup_swappiness(memcg); scanned = sc->nr_scanned; shrink_lruvec(lruvec, swappiness, sc, &lru_pages); zone_lru_pages += lru_pages; if (memcg && is_classzone) shrink_slab(sc->gfp_mask, zone_to_nid(zone), memcg, sc->nr_scanned - scanned, lru_pages); /* * Direct reclaim and kswapd have to scan all memory * cgroups to fulfill the overall scan target for the * zone. * * Limit reclaim, on the other hand, only cares about * nr_to_reclaim pages to be reclaimed and it will * retry with decreasing priority if one round over the * whole hierarchy is not sufficient. */ if (!global_reclaim(sc) && sc->nr_reclaimed >= sc->nr_to_reclaim) { mem_cgroup_iter_break(root, memcg); break; } } while ((memcg = mem_cgroup_iter(root, memcg, &reclaim))); /* * Shrink the slab caches in the same proportion that * the eligible LRU pages were scanned. */ if (global_reclaim(sc) && is_classzone) shrink_slab(sc->gfp_mask, zone_to_nid(zone), NULL, sc->nr_scanned - nr_scanned, zone_lru_pages); if (reclaim_state) { sc->nr_reclaimed += reclaim_state->reclaimed_slab; reclaim_state->reclaimed_slab = 0; } vmpressure(sc->gfp_mask, sc->target_mem_cgroup, sc->nr_scanned - nr_scanned, sc->nr_reclaimed - nr_reclaimed); if (sc->nr_reclaimed - nr_reclaimed) reclaimable = true; } while (should_continue_reclaim(zone, sc->nr_reclaimed - nr_reclaimed, sc->nr_scanned - nr_scanned, sc)); return reclaimable; } /* * Returns true if compaction should go ahead for a high-order request, or * the high-order allocation would succeed without compaction. */ static inline bool compaction_ready(struct zone *zone, int order) { unsigned long balance_gap, watermark; bool watermark_ok; /* * Compaction takes time to run and there are potentially other * callers using the pages just freed. Continue reclaiming until * there is a buffer of free pages available to give compaction * a reasonable chance of completing and allocating the page */ balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP( zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO)); watermark = high_wmark_pages(zone) + balance_gap + (2UL << order); watermark_ok = zone_watermark_ok_safe(zone, 0, watermark, 0, 0); /* * If compaction is deferred, reclaim up to a point where * compaction will have a chance of success when re-enabled */ if (compaction_deferred(zone, order)) return watermark_ok; /* * If compaction is not ready to start and allocation is not likely * to succeed without it, then keep reclaiming. */ if (compaction_suitable(zone, order, 0, 0) == COMPACT_SKIPPED) return false; return watermark_ok; } /* * This is the direct reclaim path, for page-allocating processes. We only * try to reclaim pages from zones which will satisfy the caller's allocation * request. * * We reclaim from a zone even if that zone is over high_wmark_pages(zone). * Because: * a) The caller may be trying to free *extra* pages to satisfy a higher-order * allocation or * b) The target zone may be at high_wmark_pages(zone) but the lower zones * must go *over* high_wmark_pages(zone) to satisfy the `incremental min' * zone defense algorithm. * * If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. * * Returns true if a zone was reclaimable. */ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc) { struct zoneref *z; struct zone *zone; unsigned long nr_soft_reclaimed; unsigned long nr_soft_scanned; gfp_t orig_mask; enum zone_type requested_highidx = gfp_zone(sc->gfp_mask); bool reclaimable = false; /* * If the number of buffer_heads in the machine exceeds the maximum * allowed level, force direct reclaim to scan the highmem zone as * highmem pages could be pinning lowmem pages storing buffer_heads */ orig_mask = sc->gfp_mask; if (buffer_heads_over_limit) sc->gfp_mask |= __GFP_HIGHMEM; for_each_zone_zonelist_nodemask(zone, z, zonelist, requested_highidx, sc->nodemask) { enum zone_type classzone_idx; if (!populated_zone(zone)) continue; classzone_idx = requested_highidx; while (!populated_zone(zone->zone_pgdat->node_zones + classzone_idx)) classzone_idx--; /* * Take care memory controller reclaiming has small influence * to global LRU. */ if (global_reclaim(sc)) { if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) continue; if (sc->priority != DEF_PRIORITY && !zone_reclaimable(zone)) continue; /* Let kswapd poll it */ /* * If we already have plenty of memory free for * compaction in this zone, don't free any more. * Even though compaction is invoked for any * non-zero order, only frequent costly order * reclamation is disruptive enough to become a * noticeable problem, like transparent huge * page allocations. */ if (IS_ENABLED(CONFIG_COMPACTION) && sc->order > PAGE_ALLOC_COSTLY_ORDER && zonelist_zone_idx(z) <= requested_highidx && compaction_ready(zone, sc->order)) { sc->compaction_ready = true; continue; } /* * This steals pages from memory cgroups over softlimit * and returns the number of reclaimed pages and * scanned pages. This works for global memory pressure * and balancing, not for a memcg's limit. */ nr_soft_scanned = 0; nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, sc->order, sc->gfp_mask, &nr_soft_scanned); sc->nr_reclaimed += nr_soft_reclaimed; sc->nr_scanned += nr_soft_scanned; if (nr_soft_reclaimed) reclaimable = true; /* need some check for avoid more shrink_zone() */ } if (shrink_zone(zone, sc, zone_idx(zone) == classzone_idx)) reclaimable = true; if (global_reclaim(sc) && !reclaimable && zone_reclaimable(zone)) reclaimable = true; } /* * Restore to original mask to avoid the impact on the caller if we * promoted it to __GFP_HIGHMEM. */ sc->gfp_mask = orig_mask; return reclaimable; } /* * This is the main entry point to direct page reclaim. * * If a full scan of the inactive list fails to free enough memory then we * are "out of memory" and something needs to be killed. * * If the caller is !__GFP_FS then the probability of a failure is reasonably * high - the zone may be full of dirty or under-writeback pages, which this * caller can't do much about. We kick the writeback threads and take explicit * naps in the hope that some of these pages can be written. But if the * allocating task holds filesystem locks which prevent writeout this might not * work, and the allocation attempt will fail. * * returns: 0, if no pages reclaimed * else, the number of pages reclaimed */ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, struct scan_control *sc) { int initial_priority = sc->priority; unsigned long total_scanned = 0; unsigned long writeback_threshold; bool zones_reclaimable; retry: delayacct_freepages_start(); if (global_reclaim(sc)) count_vm_event(ALLOCSTALL); do { vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup, sc->priority); sc->nr_scanned = 0; zones_reclaimable = shrink_zones(zonelist, sc); total_scanned += sc->nr_scanned; if (sc->nr_reclaimed >= sc->nr_to_reclaim) break; if (sc->compaction_ready) break; /* * If we're getting trouble reclaiming, start doing * writepage even in laptop mode. */ if (sc->priority < DEF_PRIORITY - 2) sc->may_writepage = 1; /* * Try to write back as many pages as we just scanned. This * tends to cause slow streaming writers to write data to the * disk smoothly, at the dirtying rate, which is nice. But * that's undesirable in laptop mode, where we *want* lumpy * writeout. So in laptop mode, write out the whole world. */ writeback_threshold = sc->nr_to_reclaim + sc->nr_to_reclaim / 2; if (total_scanned > writeback_threshold) { wakeup_flusher_threads(laptop_mode ? 0 : total_scanned, WB_REASON_TRY_TO_FREE_PAGES); sc->may_writepage = 1; } } while (--sc->priority >= 0); delayacct_freepages_end(); if (sc->nr_reclaimed) return sc->nr_reclaimed; /* Aborted reclaim to try compaction? don't OOM, then */ if (sc->compaction_ready) return 1; /* Untapped cgroup reserves? Don't OOM, retry. */ if (!sc->may_thrash) { sc->priority = initial_priority; sc->may_thrash = 1; goto retry; } /* Any of the zones still reclaimable? Don't OOM. */ if (zones_reclaimable) return 1; return 0; } static bool pfmemalloc_watermark_ok(pg_data_t *pgdat) { struct zone *zone; unsigned long pfmemalloc_reserve = 0; unsigned long free_pages = 0; int i; bool wmark_ok; for (i = 0; i <= ZONE_NORMAL; i++) { zone = &pgdat->node_zones[i]; if (!populated_zone(zone) || zone_reclaimable_pages(zone) == 0) continue; pfmemalloc_reserve += min_wmark_pages(zone); free_pages += zone_page_state(zone, NR_FREE_PAGES); } /* If there are no reserves (unexpected config) then do not throttle */ if (!pfmemalloc_reserve) return true; wmark_ok = free_pages > pfmemalloc_reserve / 2; /* kswapd must be awake if processes are being throttled */ if (!wmark_ok && waitqueue_active(&pgdat->kswapd_wait)) { pgdat->classzone_idx = min(pgdat->classzone_idx, (enum zone_type)ZONE_NORMAL); wake_up_interruptible(&pgdat->kswapd_wait); } return wmark_ok; } /* * Throttle direct reclaimers if backing storage is backed by the network * and the PFMEMALLOC reserve for the preferred node is getting dangerously * depleted. kswapd will continue to make progress and wake the processes * when the low watermark is reached. * * Returns true if a fatal signal was delivered during throttling. If this * happens, the page allocator should not consider triggering the OOM killer. */ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, nodemask_t *nodemask) { struct zoneref *z; struct zone *zone; pg_data_t *pgdat = NULL; /* * Kernel threads should not be throttled as they may be indirectly * responsible for cleaning pages necessary for reclaim to make forward * progress. kjournald for example may enter direct reclaim while * committing a transaction where throttling it could forcing other * processes to block on log_wait_commit(). */ if (current->flags & PF_KTHREAD) goto out; /* * If a fatal signal is pending, this process should not throttle. * It should return quickly so it can exit and free its memory */ if (fatal_signal_pending(current)) goto out; /* * Check if the pfmemalloc reserves are ok by finding the first node * with a usable ZONE_NORMAL or lower zone. The expectation is that * GFP_KERNEL will be required for allocating network buffers when * swapping over the network so ZONE_HIGHMEM is unusable. * * Throttling is based on the first usable node and throttled processes * wait on a queue until kswapd makes progress and wakes them. There * is an affinity then between processes waking up and where reclaim * progress has been made assuming the process wakes on the same node. * More importantly, processes running on remote nodes will not compete * for remote pfmemalloc reserves and processes on different nodes * should make reasonable progress. */ for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(gfp_mask), nodemask) { if (zone_idx(zone) > ZONE_NORMAL) continue; /* Throttle based on the first usable node */ pgdat = zone->zone_pgdat; if (pfmemalloc_watermark_ok(pgdat)) goto out; break; } /* If no zone was usable by the allocation flags then do not throttle */ if (!pgdat) goto out; /* Account for the throttling */ count_vm_event(PGSCAN_DIRECT_THROTTLE); /* * If the caller cannot enter the filesystem, it's possible that it * is due to the caller holding an FS lock or performing a journal * transaction in the case of a filesystem like ext[3|4]. In this case, * it is not safe to block on pfmemalloc_wait as kswapd could be * blocked waiting on the same lock. Instead, throttle for up to a * second before continuing. */ if (!(gfp_mask & __GFP_FS)) { wait_event_interruptible_timeout(pgdat->pfmemalloc_wait, pfmemalloc_watermark_ok(pgdat), HZ); goto check_pending; } /* Throttle until kswapd wakes the process */ wait_event_killable(zone->zone_pgdat->pfmemalloc_wait, pfmemalloc_watermark_ok(pgdat)); check_pending: if (fatal_signal_pending(current)) return true; out: return false; } unsigned long try_to_free_pages(struct zonelist *zonelist, int order, gfp_t gfp_mask, nodemask_t *nodemask) { unsigned long nr_reclaimed; struct scan_control sc = { .nr_to_reclaim = SWAP_CLUSTER_MAX, .gfp_mask = (gfp_mask = memalloc_noio_flags(gfp_mask)), .order = order, .nodemask = nodemask, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = 1, }; /* * Do not enter reclaim if fatal signal was delivered while throttled. * 1 is returned so that the page allocator does not OOM kill at this * point. */ if (throttle_direct_reclaim(gfp_mask, zonelist, nodemask)) return 1; trace_mm_vmscan_direct_reclaim_begin(order, sc.may_writepage, gfp_mask); nr_reclaimed = do_try_to_free_pages(zonelist, &sc); trace_mm_vmscan_direct_reclaim_end(nr_reclaimed); return nr_reclaimed; } #ifdef CONFIG_MEMCG unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *memcg, gfp_t gfp_mask, bool noswap, struct zone *zone, unsigned long *nr_scanned) { struct scan_control sc = { .nr_to_reclaim = SWAP_CLUSTER_MAX, .target_mem_cgroup = memcg, .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = !noswap, }; struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg); int swappiness = mem_cgroup_swappiness(memcg); unsigned long lru_pages; sc.gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK); trace_mm_vmscan_memcg_softlimit_reclaim_begin(sc.order, sc.may_writepage, sc.gfp_mask); /* * NOTE: Although we can get the priority field, using it * here is not a good idea, since it limits the pages we can scan. * if we don't reclaim here, the shrink_zone from balance_pgdat * will pick up pages from other mem cgroup's as well. We hack * the priority and make it zero. */ shrink_lruvec(lruvec, swappiness, &sc, &lru_pages); trace_mm_vmscan_memcg_softlimit_reclaim_end(sc.nr_reclaimed); *nr_scanned = sc.nr_scanned; return sc.nr_reclaimed; } unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, unsigned long nr_pages, gfp_t gfp_mask, bool may_swap) { struct zonelist *zonelist; unsigned long nr_reclaimed; int nid; struct scan_control sc = { .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = (gfp_mask & GFP_RECLAIM_MASK) | (GFP_HIGHUSER_MOVABLE & ~GFP_RECLAIM_MASK), .target_mem_cgroup = memcg, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = may_swap, }; /* * Unlike direct reclaim via alloc_pages(), memcg's reclaim doesn't * take care of from where we get pages. So the node where we start the * scan does not need to be the current node. */ nid = mem_cgroup_select_victim_node(memcg); zonelist = NODE_DATA(nid)->node_zonelists; trace_mm_vmscan_memcg_reclaim_begin(0, sc.may_writepage, sc.gfp_mask); nr_reclaimed = do_try_to_free_pages(zonelist, &sc); trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); return nr_reclaimed; } #endif static void age_active_anon(struct zone *zone, struct scan_control *sc) { struct mem_cgroup *memcg; if (!total_swap_pages) return; memcg = mem_cgroup_iter(NULL, NULL, NULL); do { struct lruvec *lruvec = mem_cgroup_zone_lruvec(zone, memcg); if (inactive_anon_is_low(lruvec)) shrink_active_list(SWAP_CLUSTER_MAX, lruvec, sc, LRU_ACTIVE_ANON); memcg = mem_cgroup_iter(NULL, memcg, NULL); } while (memcg); } static bool zone_balanced(struct zone *zone, int order, unsigned long balance_gap, int classzone_idx) { if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone) + balance_gap, classzone_idx, 0)) return false; if (IS_ENABLED(CONFIG_COMPACTION) && order && compaction_suitable(zone, order, 0, classzone_idx) == COMPACT_SKIPPED) return false; return true; } /* * pgdat_balanced() is used when checking if a node is balanced. * * For order-0, all zones must be balanced! * * For high-order allocations only zones that meet watermarks and are in a * zone allowed by the callers classzone_idx are added to balanced_pages. The * total of balanced pages must be at least 25% of the zones allowed by * classzone_idx for the node to be considered balanced. Forcing all zones to * be balanced for high orders can cause excessive reclaim when there are * imbalanced zones. * The choice of 25% is due to * o a 16M DMA zone that is balanced will not balance a zone on any * reasonable sized machine * o On all other machines, the top zone must be at least a reasonable * percentage of the middle zones. For example, on 32-bit x86, highmem * would need to be at least 256M for it to be balance a whole node. * Similarly, on x86-64 the Normal zone would need to be at least 1G * to balance a node on its own. These seemed like reasonable ratios. */ static bool pgdat_balanced(pg_data_t *pgdat, int order, int classzone_idx) { unsigned long managed_pages = 0; unsigned long balanced_pages = 0; int i; /* Check the watermark levels */ for (i = 0; i <= classzone_idx; i++) { struct zone *zone = pgdat->node_zones + i; if (!populated_zone(zone)) continue; managed_pages += zone->managed_pages; /* * A special case here: * * balance_pgdat() skips over all_unreclaimable after * DEF_PRIORITY. Effectively, it considers them balanced so * they must be considered balanced here as well! */ if (!zone_reclaimable(zone)) { balanced_pages += zone->managed_pages; continue; } if (zone_balanced(zone, order, 0, i)) balanced_pages += zone->managed_pages; else if (!order) return false; } if (order) return balanced_pages >= (managed_pages >> 2); else return true; } /* * Prepare kswapd for sleeping. This verifies that there are no processes * waiting in throttle_direct_reclaim() and that watermarks have been met. * * Returns true if kswapd is ready to sleep */ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining, int classzone_idx) { /* If a direct reclaimer woke kswapd within HZ/10, it's premature */ if (remaining) return false; /* * The throttled processes are normally woken up in balance_pgdat() as * soon as pfmemalloc_watermark_ok() is true. But there is a potential * race between when kswapd checks the watermarks and a process gets * throttled. There is also a potential race if processes get * throttled, kswapd wakes, a large process exits thereby balancing the * zones, which causes kswapd to exit balance_pgdat() before reaching * the wake up checks. If kswapd is going to sleep, no process should * be sleeping on pfmemalloc_wait, so wake them now if necessary. If * the wake up is premature, processes will wake kswapd and get * throttled again. The difference from wake ups in balance_pgdat() is * that here we are under prepare_to_wait(). */ if (waitqueue_active(&pgdat->pfmemalloc_wait)) wake_up_all(&pgdat->pfmemalloc_wait); return pgdat_balanced(pgdat, order, classzone_idx); } /* * kswapd shrinks the zone by the number of pages required to reach * the high watermark. * * Returns true if kswapd scanned at least the requested number of pages to * reclaim or if the lack of progress was due to pages under writeback. * This is used to determine if the scanning priority needs to be raised. */ static bool kswapd_shrink_zone(struct zone *zone, int classzone_idx, struct scan_control *sc, unsigned long *nr_attempted) { int testorder = sc->order; unsigned long balance_gap; bool lowmem_pressure; /* Reclaim above the high watermark. */ sc->nr_to_reclaim = max(SWAP_CLUSTER_MAX, high_wmark_pages(zone)); /* * Kswapd reclaims only single pages with compaction enabled. Trying * too hard to reclaim until contiguous free pages have become * available can hurt performance by evicting too much useful data * from memory. Do not reclaim more than needed for compaction. */ if (IS_ENABLED(CONFIG_COMPACTION) && sc->order && compaction_suitable(zone, sc->order, 0, classzone_idx) != COMPACT_SKIPPED) testorder = 0; /* * We put equal pressure on every zone, unless one zone has way too * many pages free already. The "too many pages" is defined as the * high wmark plus a "gap" where the gap is either the low * watermark or 1% of the zone, whichever is smaller. */ balance_gap = min(low_wmark_pages(zone), DIV_ROUND_UP( zone->managed_pages, KSWAPD_ZONE_BALANCE_GAP_RATIO)); /* * If there is no low memory pressure or the zone is balanced then no * reclaim is necessary */ lowmem_pressure = (buffer_heads_over_limit && is_highmem(zone)); if (!lowmem_pressure && zone_balanced(zone, testorder, balance_gap, classzone_idx)) return true; shrink_zone(zone, sc, zone_idx(zone) == classzone_idx); /* Account for the number of pages attempted to reclaim */ *nr_attempted += sc->nr_to_reclaim; clear_bit(ZONE_WRITEBACK, &zone->flags); /* * If a zone reaches its high watermark, consider it to be no longer * congested. It's possible there are dirty pages backed by congested * BDIs but as pressure is relieved, speculatively avoid congestion * waits. */ if (zone_reclaimable(zone) && zone_balanced(zone, testorder, 0, classzone_idx)) { clear_bit(ZONE_CONGESTED, &zone->flags); clear_bit(ZONE_DIRTY, &zone->flags); } return sc->nr_scanned >= sc->nr_to_reclaim; } /* * For kswapd, balance_pgdat() will work across all this node's zones until * they are all at high_wmark_pages(zone). * * Returns the final order kswapd was reclaiming at * * There is special handling here for zones which are full of pinned pages. * This can happen if the pages are all mlocked, or if they are all used by * device drivers (say, ZONE_DMA). Or if they are all in use by hugetlb. * What we do is to detect the case where all pages in the zone have been * scanned twice and there has been zero successful reclaim. Mark the zone as * dead and from now on, only perform a short scan. Basically we're polling * the zone for when the problem goes away. * * kswapd scans the zones in the highmem->normal->dma direction. It skips * zones which have free_pages > high_wmark_pages(zone), but once a zone is * found to have free_pages <= high_wmark_pages(zone), we scan that zone and the * lower zones regardless of the number of free pages in the lower zones. This * interoperates with the page allocator fallback scheme to ensure that aging * of pages is balanced across the zones. */ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, int *classzone_idx) { int i; int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */ unsigned long nr_soft_reclaimed; unsigned long nr_soft_scanned; struct scan_control sc = { .gfp_mask = GFP_KERNEL, .order = order, .priority = DEF_PRIORITY, .may_writepage = !laptop_mode, .may_unmap = 1, .may_swap = 1, }; count_vm_event(PAGEOUTRUN); do { unsigned long nr_attempted = 0; bool raise_priority = true; bool pgdat_needs_compaction = (order > 0); sc.nr_reclaimed = 0; /* * Scan in the highmem->dma direction for the highest * zone which needs scanning */ for (i = pgdat->nr_zones - 1; i >= 0; i--) { struct zone *zone = pgdat->node_zones + i; if (!populated_zone(zone)) continue; if (sc.priority != DEF_PRIORITY && !zone_reclaimable(zone)) continue; /* * Do some background aging of the anon list, to give * pages a chance to be referenced before reclaiming. */ age_active_anon(zone, &sc); /* * If the number of buffer_heads in the machine * exceeds the maximum allowed level and this node * has a highmem zone, force kswapd to reclaim from * it to relieve lowmem pressure. */ if (buffer_heads_over_limit && is_highmem_idx(i)) { end_zone = i; break; } if (!zone_balanced(zone, order, 0, 0)) { end_zone = i; break; } else { /* * If balanced, clear the dirty and congested * flags */ clear_bit(ZONE_CONGESTED, &zone->flags); clear_bit(ZONE_DIRTY, &zone->flags); } } if (i < 0) goto out; for (i = 0; i <= end_zone; i++) { struct zone *zone = pgdat->node_zones + i; if (!populated_zone(zone)) continue; /* * If any zone is currently balanced then kswapd will * not call compaction as it is expected that the * necessary pages are already available. */ if (pgdat_needs_compaction && zone_watermark_ok(zone, order, low_wmark_pages(zone), *classzone_idx, 0)) pgdat_needs_compaction = false; } /* * If we're getting trouble reclaiming, start doing writepage * even in laptop mode. */ if (sc.priority < DEF_PRIORITY - 2) sc.may_writepage = 1; /* * Now scan the zone in the dma->highmem direction, stopping * at the last zone which needs scanning. * * We do this because the page allocator works in the opposite * direction. This prevents the page allocator from allocating * pages behind kswapd's direction of progress, which would * cause too much scanning of the lower zones. */ for (i = 0; i <= end_zone; i++) { struct zone *zone = pgdat->node_zones + i; if (!populated_zone(zone)) continue; if (sc.priority != DEF_PRIORITY && !zone_reclaimable(zone)) continue; sc.nr_scanned = 0; nr_soft_scanned = 0; /* * Call soft limit reclaim before calling shrink_zone. */ nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, order, sc.gfp_mask, &nr_soft_scanned); sc.nr_reclaimed += nr_soft_reclaimed; /* * There should be no need to raise the scanning * priority if enough pages are already being scanned * that that high watermark would be met at 100% * efficiency. */ if (kswapd_shrink_zone(zone, end_zone, &sc, &nr_attempted)) raise_priority = false; } /* * If the low watermark is met there is no need for processes * to be throttled on pfmemalloc_wait as they should not be * able to safely make forward progress. Wake them */ if (waitqueue_active(&pgdat->pfmemalloc_wait) && pfmemalloc_watermark_ok(pgdat)) wake_up_all(&pgdat->pfmemalloc_wait); /* * Fragmentation may mean that the system cannot be rebalanced * for high-order allocations in all zones. If twice the * allocation size has been reclaimed and the zones are still * not balanced then recheck the watermarks at order-0 to * prevent kswapd reclaiming excessively. Assume that a * process requested a high-order can direct reclaim/compact. */ if (order && sc.nr_reclaimed >= 2UL << order) order = sc.order = 0; /* Check if kswapd should be suspending */ if (try_to_freeze() || kthread_should_stop()) break; /* * Compact if necessary and kswapd is reclaiming at least the * high watermark number of pages as requsted */ if (pgdat_needs_compaction && sc.nr_reclaimed > nr_attempted) compact_pgdat(pgdat, order); /* * Raise priority if scanning rate is too low or there was no * progress in reclaiming pages */ if (raise_priority || !sc.nr_reclaimed) sc.priority--; } while (sc.priority >= 1 && !pgdat_balanced(pgdat, order, *classzone_idx)); out: /* * Return the order we were reclaiming at so prepare_kswapd_sleep() * makes a decision on the order we were last reclaiming at. However, * if another caller entered the allocator slow path while kswapd * was awake, order will remain at the higher level */ *classzone_idx = end_zone; return order; } static void kswapd_try_to_sleep(pg_data_t *pgdat, int order, int classzone_idx) { long remaining = 0; DEFINE_WAIT(wait); if (freezing(current) || kthread_should_stop()) return; prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE); /* Try to sleep for a short interval */ if (prepare_kswapd_sleep(pgdat, order, remaining, classzone_idx)) { remaining = schedule_timeout(HZ/10); finish_wait(&pgdat->kswapd_wait, &wait); prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE); } /* * After a short sleep, check if it was a premature sleep. If not, then * go fully to sleep until explicitly woken up. */ if (prepare_kswapd_sleep(pgdat, order, remaining, classzone_idx)) { trace_mm_vmscan_kswapd_sleep(pgdat->node_id); /* * vmstat counters are not perfectly accurate and the estimated * value for counters such as NR_FREE_PAGES can deviate from the * true value by nr_online_cpus * threshold. To avoid the zone * watermarks being breached while under pressure, we reduce the * per-cpu vmstat threshold while kswapd is awake and restore * them before going back to sleep. */ set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold); /* * Compaction records what page blocks it recently failed to * isolate pages from and skips them in the future scanning. * When kswapd is going to sleep, it is reasonable to assume * that pages and compaction may succeed so reset the cache. */ reset_isolation_suitable(pgdat); if (!kthread_should_stop()) schedule(); set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold); } else { if (remaining) count_vm_event(KSWAPD_LOW_WMARK_HIT_QUICKLY); else count_vm_event(KSWAPD_HIGH_WMARK_HIT_QUICKLY); } finish_wait(&pgdat->kswapd_wait, &wait); } /* * The background pageout daemon, started as a kernel thread * from the init process. * * This basically trickles out pages so that we have _some_ * free memory available even if there is no other activity * that frees anything up. This is needed for things like routing * etc, where we otherwise might have all activity going on in * asynchronous contexts that cannot page things out. * * If there are applications that are active memory-allocators * (most normal use), this basically shouldn't matter. */ static int kswapd(void *p) { unsigned long order, new_order; unsigned balanced_order; int classzone_idx, new_classzone_idx; int balanced_classzone_idx; pg_data_t *pgdat = (pg_data_t*)p; struct task_struct *tsk = current; struct reclaim_state reclaim_state = { .reclaimed_slab = 0, }; const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); lockdep_set_current_reclaim_state(GFP_KERNEL); if (!cpumask_empty(cpumask)) set_cpus_allowed_ptr(tsk, cpumask); current->reclaim_state = &reclaim_state; /* * Tell the memory management that we're a "memory allocator", * and that if we need more memory we should get access to it * regardless (see "__alloc_pages()"). "kswapd" should * never get caught in the normal page freeing logic. * * (Kswapd normally doesn't need memory anyway, but sometimes * you need a small amount of memory in order to be able to * page out something else, and this flag essentially protects * us from recursively trying to free more memory as we're * trying to free the first piece of memory in the first place). */ tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; set_freezable(); order = new_order = 0; balanced_order = 0; classzone_idx = new_classzone_idx = pgdat->nr_zones - 1; balanced_classzone_idx = classzone_idx; for ( ; ; ) { bool ret; /* * If the last balance_pgdat was unsuccessful it's unlikely a * new request of a similar or harder type will succeed soon * so consider going to sleep on the basis we reclaimed at */ if (balanced_classzone_idx >= new_classzone_idx && balanced_order == new_order) { new_order = pgdat->kswapd_max_order; new_classzone_idx = pgdat->classzone_idx; pgdat->kswapd_max_order = 0; pgdat->classzone_idx = pgdat->nr_zones - 1; } if (order < new_order || classzone_idx > new_classzone_idx) { /* * Don't sleep if someone wants a larger 'order' * allocation or has tigher zone constraints */ order = new_order; classzone_idx = new_classzone_idx; } else { kswapd_try_to_sleep(pgdat, balanced_order, balanced_classzone_idx); order = pgdat->kswapd_max_order; classzone_idx = pgdat->classzone_idx; new_order = order; new_classzone_idx = classzone_idx; pgdat->kswapd_max_order = 0; pgdat->classzone_idx = pgdat->nr_zones - 1; } ret = try_to_freeze(); if (kthread_should_stop()) break; /* * We can speed up thawing tasks if we don't call balance_pgdat * after returning from the refrigerator */ if (!ret) { trace_mm_vmscan_kswapd_wake(pgdat->node_id, order); balanced_classzone_idx = classzone_idx; balanced_order = balance_pgdat(pgdat, order, &balanced_classzone_idx); } } tsk->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD); current->reclaim_state = NULL; lockdep_clear_current_reclaim_state(); return 0; } /* * A zone is low on free memory, so wake its kswapd task to service it. */ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx) { pg_data_t *pgdat; if (!populated_zone(zone)) return; if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) return; pgdat = zone->zone_pgdat; if (pgdat->kswapd_max_order < order) { pgdat->kswapd_max_order = order; pgdat->classzone_idx = min(pgdat->classzone_idx, classzone_idx); } if (!waitqueue_active(&pgdat->kswapd_wait)) return; if (zone_balanced(zone, order, 0, 0)) return; trace_mm_vmscan_wakeup_kswapd(pgdat->node_id, zone_idx(zone), order); wake_up_interruptible(&pgdat->kswapd_wait); } #ifdef CONFIG_HIBERNATION /* * Try to free `nr_to_reclaim' of memory, system-wide, and return the number of * freed pages. * * Rather than trying to age LRUs the aim is to preserve the overall * LRU order by reclaiming preferentially * inactive > active > active referenced > active mapped */ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) { struct reclaim_state reclaim_state; struct scan_control sc = { .nr_to_reclaim = nr_to_reclaim, .gfp_mask = GFP_HIGHUSER_MOVABLE, .priority = DEF_PRIORITY, .may_writepage = 1, .may_unmap = 1, .may_swap = 1, .hibernation_mode = 1, }; struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask); struct task_struct *p = current; unsigned long nr_reclaimed; p->flags |= PF_MEMALLOC; lockdep_set_current_reclaim_state(sc.gfp_mask); reclaim_state.reclaimed_slab = 0; p->reclaim_state = &reclaim_state; nr_reclaimed = do_try_to_free_pages(zonelist, &sc); p->reclaim_state = NULL; lockdep_clear_current_reclaim_state(); p->flags &= ~PF_MEMALLOC; return nr_reclaimed; } #endif /* CONFIG_HIBERNATION */ /* It's optimal to keep kswapds on the same CPUs as their memory, but not required for correctness. So if the last cpu in a node goes away, we get changed to run anywhere: as the first one comes back, restore their cpu bindings. */ static int cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { int nid; if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) { for_each_node_state(nid, N_MEMORY) { pg_data_t *pgdat = NODE_DATA(nid); const struct cpumask *mask; mask = cpumask_of_node(pgdat->node_id); if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) /* One of our CPUs online: restore mask */ set_cpus_allowed_ptr(pgdat->kswapd, mask); } } return NOTIFY_OK; } /* * This kswapd start function will be called by init and node-hot-add. * On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added. */ int kswapd_run(int nid) { pg_data_t *pgdat = NODE_DATA(nid); int ret = 0; if (pgdat->kswapd) return 0; pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid); if (IS_ERR(pgdat->kswapd)) { /* failure at boot is fatal */ BUG_ON(system_state == SYSTEM_BOOTING); pr_err("Failed to start kswapd on node %d\n", nid); ret = PTR_ERR(pgdat->kswapd); pgdat->kswapd = NULL; } return ret; } /* * Called by memory hotplug when all memory in a node is offlined. Caller must * hold mem_hotplug_begin/end(). */ void kswapd_stop(int nid) { struct task_struct *kswapd = NODE_DATA(nid)->kswapd; if (kswapd) { kthread_stop(kswapd); NODE_DATA(nid)->kswapd = NULL; } } static int __init kswapd_init(void) { int nid; swap_setup(); for_each_node_state(nid, N_MEMORY) kswapd_run(nid); hotcpu_notifier(cpu_callback, 0); return 0; } module_init(kswapd_init) #ifdef CONFIG_NUMA /* * Zone reclaim mode * * If non-zero call zone_reclaim when the number of free pages falls below * the watermarks. */ int zone_reclaim_mode __read_mostly; #define RECLAIM_OFF 0 #define RECLAIM_ZONE (1<<0) /* Run shrink_inactive_list on the zone */ #define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */ #define RECLAIM_UNMAP (1<<2) /* Unmap pages during reclaim */ /* * Priority for ZONE_RECLAIM. This determines the fraction of pages * of a node considered for each zone_reclaim. 4 scans 1/16th of * a zone. */ #define ZONE_RECLAIM_PRIORITY 4 /* * Percentage of pages in a zone that must be unmapped for zone_reclaim to * occur. */ int sysctl_min_unmapped_ratio = 1; /* * If the number of slab pages in a zone grows beyond this percentage then * slab reclaim needs to occur. */ int sysctl_min_slab_ratio = 5; static inline unsigned long zone_unmapped_file_pages(struct zone *zone) { unsigned long file_mapped = zone_page_state(zone, NR_FILE_MAPPED); unsigned long file_lru = zone_page_state(zone, NR_INACTIVE_FILE) + zone_page_state(zone, NR_ACTIVE_FILE); /* * It's possible for there to be more file mapped pages than * accounted for by the pages on the file LRU lists because * tmpfs pages accounted for as ANON can also be FILE_MAPPED */ return (file_lru > file_mapped) ? (file_lru - file_mapped) : 0; } /* Work out how many page cache pages we can reclaim in this reclaim_mode */ static long zone_pagecache_reclaimable(struct zone *zone) { long nr_pagecache_reclaimable; long delta = 0; /* * If RECLAIM_UNMAP is set, then all file pages are considered * potentially reclaimable. Otherwise, we have to worry about * pages like swapcache and zone_unmapped_file_pages() provides * a better estimate */ if (zone_reclaim_mode & RECLAIM_UNMAP) nr_pagecache_reclaimable = zone_page_state(zone, NR_FILE_PAGES); else nr_pagecache_reclaimable = zone_unmapped_file_pages(zone); /* If we can't clean pages, remove dirty pages from consideration */ if (!(zone_reclaim_mode & RECLAIM_WRITE)) delta += zone_page_state(zone, NR_FILE_DIRTY); /* Watch for any possible underflows due to delta */ if (unlikely(delta > nr_pagecache_reclaimable)) delta = nr_pagecache_reclaimable; return nr_pagecache_reclaimable - delta; } /* * Try to free up some pages from this zone through reclaim. */ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) { /* Minimum pages needed in order to stay on node */ const unsigned long nr_pages = 1 << order; struct task_struct *p = current; struct reclaim_state reclaim_state; struct scan_control sc = { .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = (gfp_mask = memalloc_noio_flags(gfp_mask)), .order = order, .priority = ZONE_RECLAIM_PRIORITY, .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE), .may_unmap = !!(zone_reclaim_mode & RECLAIM_UNMAP), .may_swap = 1, }; cond_resched(); /* * We need to be able to allocate from the reserves for RECLAIM_UNMAP * and we also need to be able to write out pages for RECLAIM_WRITE * and RECLAIM_UNMAP. */ p->flags |= PF_MEMALLOC | PF_SWAPWRITE; lockdep_set_current_reclaim_state(gfp_mask); reclaim_state.reclaimed_slab = 0; p->reclaim_state = &reclaim_state; if (zone_pagecache_reclaimable(zone) > zone->min_unmapped_pages) { /* * Free memory by calling shrink zone with increasing * priorities until we have enough memory freed. */ do { shrink_zone(zone, &sc, true); } while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0); } p->reclaim_state = NULL; current->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE); lockdep_clear_current_reclaim_state(); return sc.nr_reclaimed >= nr_pages; } int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) { int node_id; int ret; /* * Zone reclaim reclaims unmapped file backed pages and * slab pages if we are over the defined limits. * * A small portion of unmapped file backed pages is needed for * file I/O otherwise pages read by file I/O will be immediately * thrown out if the zone is overallocated. So we do not reclaim * if less than a specified percentage of the zone is used by * unmapped file backed pages. */ if (zone_pagecache_reclaimable(zone) <= zone->min_unmapped_pages && zone_page_state(zone, NR_SLAB_RECLAIMABLE) <= zone->min_slab_pages) return ZONE_RECLAIM_FULL; if (!zone_reclaimable(zone)) return ZONE_RECLAIM_FULL; /* * Do not scan if the allocation should not be delayed. */ if (!(gfp_mask & __GFP_WAIT) || (current->flags & PF_MEMALLOC)) return ZONE_RECLAIM_NOSCAN; /* * Only run zone reclaim on the local zone or on zones that do not * have associated processors. This will favor the local processor * over remote processors and spread off node memory allocations * as wide as possible. */ node_id = zone_to_nid(zone); if (node_state(node_id, N_CPU) && node_id != numa_node_id()) return ZONE_RECLAIM_NOSCAN; if (test_and_set_bit(ZONE_RECLAIM_LOCKED, &zone->flags)) return ZONE_RECLAIM_NOSCAN; ret = __zone_reclaim(zone, gfp_mask, order); clear_bit(ZONE_RECLAIM_LOCKED, &zone->flags); if (!ret) count_vm_event(PGSCAN_ZONE_RECLAIM_FAILED); return ret; } #endif /* * page_evictable - test whether a page is evictable * @page: the page to test * * Test whether page is evictable--i.e., should be placed on active/inactive * lists vs unevictable list. * * Reasons page might not be evictable: * (1) page's mapping marked unevictable * (2) page is part of an mlocked VMA * */ int page_evictable(struct page *page) { return !mapping_unevictable(page_mapping(page)) && !PageMlocked(page); } #ifdef CONFIG_SHMEM /** * check_move_unevictable_pages - check pages for evictability and move to appropriate zone lru list * @pages: array of pages to check * @nr_pages: number of pages to check * * Checks pages for evictability and moves them to the appropriate lru list. * * This function is only used for SysV IPC SHM_UNLOCK. */ void check_move_unevictable_pages(struct page **pages, int nr_pages) { struct lruvec *lruvec; struct zone *zone = NULL; int pgscanned = 0; int pgrescued = 0; int i; for (i = 0; i < nr_pages; i++) { struct page *page = pages[i]; struct zone *pagezone; pgscanned++; pagezone = page_zone(page); if (pagezone != zone) { if (zone) spin_unlock_irq(&zone->lru_lock); zone = pagezone; spin_lock_irq(&zone->lru_lock); } lruvec = mem_cgroup_page_lruvec(page, zone); if (!PageLRU(page) || !PageUnevictable(page)) continue; if (page_evictable(page)) { enum lru_list lru = page_lru_base_type(page); VM_BUG_ON_PAGE(PageActive(page), page); ClearPageUnevictable(page); del_page_from_lru_list(page, lruvec, LRU_UNEVICTABLE); add_page_to_lru_list(page, lruvec, lru); pgrescued++; } } if (zone) { __count_vm_events(UNEVICTABLE_PGRESCUED, pgrescued); __count_vm_events(UNEVICTABLE_PGSCANNED, pgscanned); spin_unlock_irq(&zone->lru_lock); } } #endif /* CONFIG_SHMEM */
Basler/linux-usb-zerocopy
mm/vmscan.c
C
gpl-2.0
112,737
[ 30522, 1013, 1008, 1008, 11603, 1013, 3461, 1013, 1058, 5244, 9336, 1012, 1039, 1008, 1008, 9385, 1006, 1039, 1007, 2889, 1010, 2826, 1010, 2857, 1010, 2807, 11409, 2271, 17153, 10175, 5104, 1008, 1008, 19948, 2128, 21759, 7088, 6924, 2756,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package cmdji type Compound struct { KanjiCompound string KanaCompound string CompoundMeanings []string } type kanjiStruct struct { Kanji string `json:"kanji"` Meanings []string `json:"meanings"` Onyomis []string `json:"onyomis"` Kunyomis []string `json:"kunyomis` Nanoris []string `json:"nanoris"` Joyo bool `json:"joyo"` Jlpt int `json:"jlpt"` Newspaper_rank int `json:"newspaper_rank"` On_compounds [][]interface{} `json:"on_compounds"` Kun_compounds [][]interface{} `json:"kun_compounds"` Max_newspaper_rank int `json:"max_newspaper_rank"` Published_at string `json:"published_at"` Image []string `json:"image"` Source_url string `json:"source_url"` } type KanjiADay struct { Kanji kanjiStruct `json:"kanji"` Home_url string `json:"home_url"` }
ProfOak/cmdji
go-bindings/types.go
GO
mit
1,020
[ 30522, 7427, 4642, 2094, 4478, 2828, 7328, 2358, 6820, 6593, 1063, 22827, 25008, 25377, 28819, 5164, 22827, 22684, 8737, 28819, 5164, 7328, 4168, 7088, 3070, 2015, 1031, 1033, 5164, 1065, 2828, 22827, 4478, 3367, 6820, 6593, 2358, 6820, 659...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package net.minecraftplus.mcp_glowing_slime; import net.minecraftplus._api.MCS; import net.minecraftplus._api.base.Proxy; public class _CommonProxy extends Proxy { @Override public void Initialize() { MCS.entity(EntityGlowingSlimeball.class, "GlowingSlimeball", 0, _Glowing_Slime.INSTANCE, 80, 10, true); super.Initialize(); } }
andykuo1/mcplus_mods
java/net/minecraftplus/mcp_glowing_slime/_CommonProxy.java
Java
gpl-2.0
339
[ 30522, 7427, 5658, 1012, 3067, 10419, 24759, 2271, 1012, 11338, 2361, 1035, 10156, 1035, 11754, 2063, 1025, 12324, 5658, 1012, 3067, 10419, 24759, 2271, 1012, 1035, 17928, 1012, 11338, 2015, 1025, 12324, 5658, 1012, 3067, 10419, 24759, 2271, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "editaddressdialog.h" #include "ui_editaddressdialog.h" #include "addresstablemodel.h" #include "guiutil.h" #include <QDataWidgetMapper> #include <QMessageBox> EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) { ui->setupUi(this); GUIUtil::setupAddressWidget(ui->addressEdit, this); switch(mode) { case NewReceivingAddress: setWindowTitle(tr("New receiving address")); ui->addressEdit->setEnabled(false); break; case NewSendingAddress: setWindowTitle(tr("New sending address")); break; case EditReceivingAddress: setWindowTitle(tr("Edit receiving address")); ui->addressEdit->setEnabled(false); break; case EditSendingAddress: setWindowTitle(tr("Edit sending address")); break; } mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); } EditAddressDialog::~EditAddressDialog() { delete ui; } void EditAddressDialog::setModel(AddressTableModel *model) { this->model = model; if(!model) return; mapper->setModel(model); mapper->addMapping(ui->labelEdit, AddressTableModel::Label); mapper->addMapping(ui->addressEdit, AddressTableModel::Address); } void EditAddressDialog::loadRow(int row) { mapper->setCurrentIndex(row); } bool EditAddressDialog::saveCurrentRow() { if(!model) return false; switch(mode) { case NewReceivingAddress: case NewSendingAddress: address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, ui->labelEdit->text(), ui->addressEdit->text()); break; case EditReceivingAddress: case EditSendingAddress: if(mapper->submit()) { address = ui->addressEdit->text(); } break; } return !address.isEmpty(); } void EditAddressDialog::accept() { if(!model) return; if(!saveCurrentRow()) { switch(model->getEditStatus()) { case AddressTableModel::OK: // Failed with unknown reason. Just reject. break; case AddressTableModel::NO_CHANGES: // No changes were made during edit operation. Just reject. break; case AddressTableModel::INVALID_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is not a valid Palestinecoin address.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::DUPLICATE_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::WALLET_UNLOCK_FAILURE: QMessageBox::critical(this, windowTitle(), tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::KEY_GENERATION_FAILURE: QMessageBox::critical(this, windowTitle(), tr("New key generation failed."), QMessageBox::Ok, QMessageBox::Ok); break; } return; } QDialog::accept(); } QString EditAddressDialog::getAddress() const { return address; } void EditAddressDialog::setAddress(const QString &address) { this->address = address; ui->addressEdit->setText(address); }
PalestineCoin/Palestinecoin
src/qt/editaddressdialog.cpp
C++
mit
3,736
[ 30522, 1001, 2421, 1000, 10086, 4215, 16200, 4757, 27184, 8649, 1012, 1044, 1000, 1001, 2421, 1000, 21318, 1035, 10086, 4215, 16200, 4757, 27184, 8649, 1012, 1044, 1000, 1001, 2421, 1000, 4769, 10880, 5302, 9247, 1012, 1044, 1000, 1001, 242...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * 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.hadoop.hdfs.server.namenode; import java.io.File; import java.io.IOException; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.PermissionStatus; import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.common.GenerationStamp; import org.apache.hadoop.hdfs.server.common.Storage; /** * * CreateEditsLog * Synopsis: CreateEditsLog -f numFiles StartingBlockId numBlocksPerFile * [-r replicafactor] [-d editsLogDirectory] * Default replication factor is 1 * Default edits log directory is /tmp/EditsLogOut * * Create a name node's edits log in /tmp/EditsLogOut. * The file /tmp/EditsLogOut/current/edits can be copied to a name node's * dfs.namenode.name.dir/current direcotry and the name node can be started as usual. * * The files are created in /createdViaInjectingInEditsLog * The file names contain the starting and ending blockIds; hence once can * create multiple edits logs using this command using non overlapping * block ids and feed the files to a single name node. * * See Also @link #DataNodeCluster for injecting a set of matching * blocks created with this command into a set of simulated data nodes. * */ public class CreateEditsLog { static final String BASE_PATH = "/createdViaInjectingInEditsLog"; static final String EDITS_DIR = "/tmp/EditsLogOut"; static String edits_dir = EDITS_DIR; static final public long BLOCK_GENERATION_STAMP = GenerationStamp.LAST_RESERVED_STAMP; static void addFiles(FSEditLog editLog, int numFiles, short replication, int blocksPerFile, long startingBlockId, long blockSize, FileNameGenerator nameGenerator) { PermissionStatus p = new PermissionStatus("joeDoe", "people", new FsPermission((short)0777)); INodeId inodeId = new INodeId(); INodeDirectory dirInode = new INodeDirectory(inodeId.nextValue(), null, p, 0L); editLog.logMkDir(BASE_PATH, dirInode); BlockInfo[] blocks = new BlockInfo[blocksPerFile]; for (int iB = 0; iB < blocksPerFile; ++iB) { blocks[iB] = new BlockInfo(new Block(0, blockSize, BLOCK_GENERATION_STAMP), replication); } long currentBlockId = startingBlockId; long bidAtSync = startingBlockId; for (int iF = 0; iF < numFiles; iF++) { for (int iB = 0; iB < blocksPerFile; ++iB) { blocks[iB].setBlockId(currentBlockId++); } final INodeFile inode = new INodeFile(inodeId.nextValue(), null, p, 0L, 0L, blocks, replication, blockSize, (byte)0); inode.toUnderConstruction("", ""); // Append path to filename with information about blockIDs String path = "_" + iF + "_B" + blocks[0].getBlockId() + "_to_B" + blocks[blocksPerFile-1].getBlockId() + "_"; String filePath = nameGenerator.getNextFileName(""); filePath = filePath + path; // Log the new sub directory in edits if ((iF % nameGenerator.getFilesPerDirectory()) == 0) { String currentDir = nameGenerator.getCurrentDir(); dirInode = new INodeDirectory(inodeId.nextValue(), null, p, 0L); editLog.logMkDir(currentDir, dirInode); } INodeFile fileUc = new INodeFile(inodeId.nextValue(), null, p, 0L, 0L, BlockInfo.EMPTY_ARRAY, replication, blockSize, (byte)0); fileUc.toUnderConstruction("", ""); editLog.logOpenFile(filePath, fileUc, false, false); editLog.logCloseFile(filePath, inode); if (currentBlockId - bidAtSync >= 2000) { // sync every 2K blocks editLog.logSync(); bidAtSync = currentBlockId; } } System.out.println("Created edits log in directory " + edits_dir); System.out.println(" containing " + numFiles + " File-Creates, each file with " + blocksPerFile + " blocks"); System.out.println(" blocks range: " + startingBlockId + " to " + (currentBlockId-1)); } static final String usage = "Usage: createditlogs " + " -f numFiles startingBlockIds NumBlocksPerFile [-r replicafactor] " + "[-d editsLogDirectory]\n" + " Default replication factor is 1\n" + " Default edits log direcory is " + EDITS_DIR + "\n"; static void printUsageExit() { System.out.println(usage); System.exit(-1); } static void printUsageExit(String err) { System.out.println(err); printUsageExit(); } /** * @param args arguments * @throws IOException */ public static void main(String[] args) throws IOException { long startingBlockId = 1; int numFiles = 0; short replication = 1; int numBlocksPerFile = 0; long blockSize = 10; if (args.length == 0) { printUsageExit(); } for (int i = 0; i < args.length; i++) { // parse command line if (args[i].equals("-h")) printUsageExit(); if (args[i].equals("-f")) { if (i + 3 >= args.length || args[i+1].startsWith("-") || args[i+2].startsWith("-") || args[i+3].startsWith("-")) { printUsageExit( "Missing num files, starting block and/or number of blocks"); } numFiles = Integer.parseInt(args[++i]); startingBlockId = Integer.parseInt(args[++i]); numBlocksPerFile = Integer.parseInt(args[++i]); if (numFiles <=0 || numBlocksPerFile <= 0) { printUsageExit("numFiles and numBlocksPerFile most be greater than 0"); } } else if (args[i].equals("-l")) { if (i + 1 >= args.length) { printUsageExit( "Missing block length"); } blockSize = Long.parseLong(args[++i]); } else if (args[i].equals("-r") || args[i+1].startsWith("-")) { if (i + 1 >= args.length) { printUsageExit( "Missing replication factor"); } replication = Short.parseShort(args[++i]); } else if (args[i].equals("-d")) { if (i + 1 >= args.length || args[i+1].startsWith("-")) { printUsageExit("Missing edits logs directory"); } edits_dir = args[++i]; } else { printUsageExit(); } } File editsLogDir = new File(edits_dir); File subStructureDir = new File(edits_dir + "/" + Storage.STORAGE_DIR_CURRENT); if ( !editsLogDir.exists() ) { if ( !editsLogDir.mkdir()) { System.out.println("cannot create " + edits_dir); System.exit(-1); } } if ( !subStructureDir.exists() ) { if ( !subStructureDir.mkdir()) { System.out.println("cannot create subdirs of " + edits_dir); System.exit(-1); } } FileNameGenerator nameGenerator = new FileNameGenerator(BASE_PATH, 100); FSEditLog editLog = FSImageTestUtil.createStandaloneEditLog(editsLogDir); editLog.openForWrite(); addFiles(editLog, numFiles, replication, numBlocksPerFile, startingBlockId, blockSize, nameGenerator); editLog.logSync(); editLog.close(); } }
ZhangXFeng/hadoop
src/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/CreateEditsLog.java
Java
apache-2.0
8,019
[ 30522, 1013, 1008, 1008, 1008, 7000, 2000, 1996, 15895, 4007, 3192, 1006, 2004, 2546, 1007, 2104, 2028, 1008, 2030, 2062, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, 1008, 5500, 2007, 2023, 2147, 2005, 3176, 2592, 1008, 4953, 9385, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!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"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>LEGATO: Timer API</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="fonts.css" rel="stylesheet" type="text/css" /> <link href="legato.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jquery.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> $(document).ready(initResizable); $(window).load(resizeHeight); </script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { init_search(); }); </script> <script type="text/javascript"> //<![CDATA[ // Detect if doc is served by eclipse if( ( (window.location.hostname == "127.0.0.1") || (window.location.hostname == "localhost") ) && ( (window.location.port != "") && (window.location.port != 80) && (window.location.port != 443) ) ) { // Inhibit init function from navtree initNavTree = function(toroot,relpath) {} $(document).ready(function(){ navTree = document.getElementById("side-nav"); if(navTree) { navTree.parentElement.removeChild(navTree); } $("#doc-content").css('margin-left',10); }); } //]]> </script> <link rel="icon" type="image/png" href="favicon.ico" /> </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"> <a href="index.html" title="Legato"> <img alt="Logo" src="legatoLogo.png"/> </a> <div id="projectbrief">Simplifying IoT development</div> </td> <td> <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> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.8.9.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> $(document).ready(function(){initNavTree('c_timer.html','');}); </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </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> <div class="header"> <div class="headertitle"> <div class="title">Timer API </div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><p><a class="el" href="le__timer_8h.html">API Reference</a></p> <hr/> <p>This module provides an API for managing and using timers.</p> <dl class="section note"><dt>Note</dt><dd>This is an initial version of the API that only provides support for relative timers (e.g., expires in 10 seconds). Absolute timers allow a specific time/date to be used, and will be supported in a future version of this API.</dd></dl> <h1><a class="anchor" id="timer_objects"></a> Creating/Deleting Timer Objects</h1> <p>Timers are created using <a class="el" href="le__timer_8h.html#aee41169a210378b369f440cf99146522">le_timer_Create</a>. The timer name is used for logging purposes only.</p> <p>The following attributes of the timer can be set:</p><ul> <li><a class="el" href="le__timer_8h.html#abbf8d4c3c78d7bf5801b94071adcb6c6">le_timer_SetHandler</a></li> <li><a class="el" href="le__timer_8h.html#a0a103d5cef5e83fc9088859d527bbd43">le_timer_SetInterval</a></li> <li><a class="el" href="le__timer_8h.html#a292b0a7d6dc0796a36a54fd04c6a7eeb">le_timer_SetRepeat</a></li> <li><a class="el" href="le__timer_8h.html#af6900bdb4653ff95f7f7be918b9e482d">le_timer_SetContextPtr</a></li> </ul> <p>The repeat count defaults to 1, so that the timer is initially a one-shot timer. All the other attributes must be explicitly set. At a minimum, the interval must be set before the timer can be used. Note that these attributes can only be set if the timer is not currently running; otherwise, an error will be returned.</p> <p>A timer is deleted using <a class="el" href="le__timer_8h.html#ae103f6736bf855e77e5e59bbad1e27a7">le_timer_Delete</a>. If the timer is currently running, then it will be stopped first, before being deleted.</p> <h1><a class="anchor" id="timer_usage"></a> Using Timers</h1> <p>A timer can be started using <a class="el" href="le__timer_8h.html#ada2ce7f8cb1e76ed959e323ae94bbfc0">le_timer_Start</a>. If it's already running, then it won't be modified; instead an error will be returned. To restart a currently running timer, use <a class="el" href="le__timer_8h.html#ab6b83d6302095a46b6046160c0a479bb">le_timer_Restart</a>.</p> <p>A timer can be stopped using <a class="el" href="le__timer_8h.html#af310daa378bd6ca39373a47e073f2243">le_timer_Stop</a>. If it's not currently running, an error will be returned, and nothing more will be done.</p> <p>To determine if the timer is currently running, use <a class="el" href="le__timer_8h.html#ab33b8568fd394d38274b778130111f70">le_timer_IsRunning</a>.</p> <p>When a timer expires, if the timer expiry handler is set by <a class="el" href="le__timer_8h.html#abbf8d4c3c78d7bf5801b94071adcb6c6">le_timer_SetHandler</a>, the handler will be called with a reference to the expired timer. If additional data is required in the handler, <a class="el" href="le__timer_8h.html#af6900bdb4653ff95f7f7be918b9e482d">le_timer_SetContextPtr</a> can be used to set the appropriate context before starting the timer, and <a class="el" href="le__timer_8h.html#aa0432dbabb32b546c0c0e6ced5ba9d3d">le_timer_GetContextPtr</a> can be used to retrieve the context while in the handler.</p> <p>The number of times that a timer has expired can be retrieved by <a class="el" href="le__timer_8h.html#a554cff1d11525bb60115291248f3ff53">le_timer_GetExpiryCount</a>. This count is independent of whether there is an expiry handler for the timer.</p> <h1><a class="anchor" id="le_timer_thread"></a> Thread Support</h1> <p>A timer should only be used by the thread that created it. It's not safe for a thread to use or manipulate a timer that belongs to another thread. The timer expiry handler is called by the event loop of the thread that starts the timer.</p> <p>See <a class="el" href="c_event_loop.html">Event Loop API</a> for details on running the event loop of a thread.</p> <h1><a class="anchor" id="timer_errors"></a> Fatal Errors</h1> <p>The process will exit under any of the following conditions:</p><ul> <li>If an invalid timer object is given to:<ul> <li><a class="el" href="le__timer_8h.html#ae103f6736bf855e77e5e59bbad1e27a7">le_timer_Delete</a></li> <li><a class="el" href="le__timer_8h.html#abbf8d4c3c78d7bf5801b94071adcb6c6">le_timer_SetHandler</a></li> <li><a class="el" href="le__timer_8h.html#a0a103d5cef5e83fc9088859d527bbd43">le_timer_SetInterval</a></li> <li><a class="el" href="le__timer_8h.html#a292b0a7d6dc0796a36a54fd04c6a7eeb">le_timer_SetRepeat</a></li> <li><a class="el" href="le__timer_8h.html#ada2ce7f8cb1e76ed959e323ae94bbfc0">le_timer_Start</a></li> <li><a class="el" href="le__timer_8h.html#af310daa378bd6ca39373a47e073f2243">le_timer_Stop</a></li> <li><a class="el" href="le__timer_8h.html#ab6b83d6302095a46b6046160c0a479bb">le_timer_Restart</a></li> <li><a class="el" href="le__timer_8h.html#af6900bdb4653ff95f7f7be918b9e482d">le_timer_SetContextPtr</a></li> <li><a class="el" href="le__timer_8h.html#aa0432dbabb32b546c0c0e6ced5ba9d3d">le_timer_GetContextPtr</a></li> <li><a class="el" href="le__timer_8h.html#a554cff1d11525bb60115291248f3ff53">le_timer_GetExpiryCount</a></li> </ul> </li> </ul> <h1><a class="anchor" id="timer_troubleshooting"></a> Troubleshooting</h1> <p>Timers can be traced by enabling the log trace keyword "timers" in the "framework" component.</p> <p>See <a class="el" href="c_logging.html#c_log_controlling">Log Controls</a> for more information.</p> <hr/> <p>Copyright (C) Sierra Wireless Inc. Use of this work is subject to license. </p> </div></div><!-- contents --> </div><!-- doc-content --> <div class="footer"> <div> <a href="https://www.sierrawireless.com/"> <img src="swi-ico-medium.png" width="24" alt="" /> &nbsp;Sierra Wireless </a> &nbsp;-&nbsp; Generated by Doxygen 1.8.9.1 </div> </div> </body> </html>
legatoproject/legato-docs
15_10/c_timer.html
HTML
mpl-2.0
10,134
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.wikiup.plugins.wmdk.action; import java.util.Iterator; import org.wikiup.core.Wikiup; import org.wikiup.core.impl.Null; import org.wikiup.core.inf.Attribute; import org.wikiup.core.inf.BeanContainer; import org.wikiup.core.inf.Document; import org.wikiup.core.util.Documents; import org.wikiup.core.util.Interfaces; import org.wikiup.core.util.StringUtil; import org.wikiup.core.util.ValueUtil; import org.wikiup.servlet.ServletProcessorContext; import org.wikiup.servlet.exception.ServiceNotImplementException; import org.wikiup.servlet.util.ProcessorContexts; public class ContextServletAction { public void get(ServletProcessorContext context) { Document resp = context.getResponseXML(); String name = context.getParameter("name"); Documents.setAttributeValue(resp, "value", context.get(name)); } public void contexts(ServletProcessorContext context) { String node = context.getParameter("node"); int pos = node.indexOf('@'); String uri = pos == -1 ? node : node.substring(0, pos); String objectName = pos == -1 ? null : node.substring(pos + 1); Document resp = context.getResponseXML(); ServletProcessorContext ctx = getRequestedContext(context, uri); if(ctx != null) if(objectName == null) { Object globalContext = Wikiup.getInstance().get("wk.servlet.context"); Document rScope = ctx.getRequestContextConf(); Document sScope = ctx.getServletContextConf(); Iterable<Object> iterable = Interfaces.getModel(globalContext, Iterable.class); if(sScope != null) mergeContext(uri, sScope, resp); if(rScope != null) mergeContext(uri, rScope, resp); if(iterable != null) for(Object obj : iterable) { String name = ValueUtil.toString(obj); appendContextNode(resp, "context", uri + '@' + name, name, false); } } else { ctx.doInit(); Iterator<Object> iterator = getIterator(ctx, objectName); while(iterator != null && iterator.hasNext()) { String name = ValueUtil.toString(iterator.next()); String p = StringUtil.connect(objectName, name, ':'); appendContextNode(resp, "item", uri + '@' + p, name, getIterator(ctx, p) == null); } } } private ServletProcessorContext getRequestedContext(ServletProcessorContext context, String uri) { ServletProcessorContext ctx = null; try { ctx = new ServletProcessorContext(context, uri); } catch(ServiceNotImplementException e) { } return ctx; } private void appendContextNode(Document resp, String nodeName, String id, String text, boolean isLeaf) { Document doc = resp.addChild(nodeName); Documents.setAttributeValue(doc, "text", text); Documents.setAttributeValue(doc, "id", id); Documents.setAttributeValue(doc, "leaf", isLeaf); } public void actions(ServletProcessorContext context) { String uri = context.getParameter("uri", "/"); ServletProcessorContext ctx = getRequestedContext(context, uri); Document resp = context.getResponseXML(); if(ctx != null) { Document rScope = ctx.getRequestContextConf().getChild("context-action"); Document sScope = ctx.getServletContextConf().getChild("context-action"); if(sScope != null) mergeContext(uri, sScope, resp); if(rScope != null) { if(!rScope.getChildren().iterator().hasNext()) mergeAction(rScope, resp.addChild("action")); else mergeAction(rScope, resp); for(Document doc : resp.getChildren()) Documents.setChildValue(doc, "scope", "Request"); } } } private void mergeAction(Document action, Document resp) { for(Attribute attr : action.getAttributes()) Documents.setChildValue(resp, attr.getName(), attr.toString()); } private Iterator<Object> getIterator(ServletProcessorContext ctx, String path) { try { BeanContainer mc = ProcessorContexts.getBeanContainer(ctx, path, Null.getInstance()); return mc != null ? mc.query(Iterator.class) : null; } catch(Exception e) { return null; } } private void mergeContext(String uri, Document sScope, Document resp) { for(Document item : sScope.getChildren("context")) { Document node = resp.addChild("context"); String name = Documents.getAttributeValue(item, "name"); Documents.setAttributeValue(node, "text", name); Documents.setAttributeValue(node, "id", uri + '@' + name); Documents.setAttributeValue(node, "leaf", false); } } }
smantinc/wikiup
plugins/wmdk/src/org/wikiup/plugins/wmdk/action/ContextServletAction.java
Java
apache-2.0
5,203
[ 30522, 7427, 8917, 1012, 15536, 3211, 6279, 1012, 13354, 7076, 1012, 1059, 26876, 2243, 1012, 2895, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 2009, 6906, 4263, 1025, 12324, 8917, 1012, 15536, 3211, 6279, 1012, 4563, 1012, 15536, 3211, 627...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
@font-face { font-family: 'layouter'; src: url('../fonts/layouter.eot?42hzee'); src: url('../fonts/layouter.eot?42hzee#iefix') format('embedded-opentype'), url('../fonts/layouter.ttf?42hzee') format('truetype'), url('../fonts/layouter.woff?42hzee') format('woff'), url('../fonts/layouter.svg?42hzee#icomoon') format('svg'); font-weight: normal; font-style: normal; } [class^="icon-"], [class*=" icon-"] { /* use !important to prevent issues with browser extensions that change fonts */ font-family: 'layouter' !important; speak: none; font-size: 1.5em; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; vertical-align: middle; /* Better Font Rendering =========== */ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .layouterRow--outer + .layouter-row--outer { margin-top: 2px; } .layouterRow--inner { background-size: cover; background-repeat: no-repeat; } .layouterRow--parallax { background-attachment: fixed; background-position: center; } .layouterRow--inner.show-grid [class^=col-] { border: 2px dashed #1F5E8E; margin-bottom: -4px; } #id_container_type li { display: inline-block; width: 250px; text-align: center; border: 0; padding-bottom: 15px; user-select: none; } #id_container_type li span { padding-bottom: 7px; display: inline-block; } #id_container_type li.checked { border: 1px solid black; margin-bottom: -1px; margin-right: -1px; margin-left: -1px; margin-top: -1px; } #id_container_type input[type=radio] { display: none; } .quarter:before { content: "\e900"; } .third:before { content: "\e901"; } .half:before { content: "\e903"; } .two-third:before { content: "\e904"; } .three-quarter:before { content: "\e905"; } .full-width:before { content: "\e906"; } .layouterRow--equalHeight { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; }
Blueshoe/djangocms-layouter
layouter/static/layouter/css/layouter.css
CSS
mit
1,983
[ 30522, 1030, 15489, 1011, 2227, 1063, 15489, 1011, 2155, 1024, 1005, 9621, 2121, 1005, 1025, 5034, 2278, 1024, 24471, 2140, 1006, 1005, 1012, 1012, 1013, 15489, 2015, 1013, 9621, 2121, 1012, 1041, 4140, 1029, 4413, 2232, 23940, 1005, 1007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
"use strict"; var _foob, _foob$test; var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); }; (_foob = foob).add.apply(_foob, [foo, bar].concat(_toArray(numbers))); (_foob$test = foob.test).add.apply(_foob$test, [foo, bar].concat(_toArray(numbers)));
stefanpenner/6to5
test/fixtures/transformation/es6-spread/contexted-method-call-multiple-args/expected.js
JavaScript
mit
281
[ 30522, 1000, 2224, 9384, 1000, 1025, 13075, 1035, 29379, 2497, 1010, 1035, 29379, 2497, 1002, 3231, 1025, 13075, 1035, 2000, 2906, 9447, 1027, 3853, 1006, 12098, 2099, 1007, 1063, 2709, 9140, 1012, 18061, 11335, 2100, 1006, 12098, 2099, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * SonarQube, open source software quality management tool. * Copyright (C) 2008-2013 SonarSource * mailto:contact AT sonarsource DOT com * * SonarQube is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * SonarQube is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.sonar.wsclient.services; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.sonar.wsclient.JdkUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; import static org.fest.assertions.Assertions.assertThat; public class TimeMachineQueryTest extends QueryTestCase { private TimeZone systemTimeZone; @Before public void before() { systemTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); WSUtils.setInstance(new JdkUtils()); } @After public void after() { TimeZone.setDefault(systemTimeZone); } @Test public void should_get_url() { TimeMachineQuery query = TimeMachineQuery.createForMetrics("12345", "ncloc", "coverage"); assertThat(query.getUrl()).isEqualTo("/api/timemachine?resource=12345&metrics=ncloc,coverage&"); } @Test public void should_set_period() throws ParseException { Date from = new SimpleDateFormat("yyyy-MM-dd").parse("2010-02-18"); Date to = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2010-03-25 14:59"); TimeMachineQuery query = TimeMachineQuery.createForMetrics("12345", "ncloc").setFrom(from).setTo(to); assertThat(query.getUrl()).isEqualTo( "/api/timemachine?resource=12345&metrics=ncloc&fromDateTime=2010-02-18T00%3A00%3A00%2B0000&toDateTime=2010-03-25T14%3A59%3A00%2B0000&"); } @Test public void should_create_query_from_resource() { TimeMachineQuery query = TimeMachineQuery.createForMetrics(new Resource().setId(1), "ncloc"); assertThat(query.getUrl()).isEqualTo("/api/timemachine?resource=1&metrics=ncloc&"); } @Test public void should_not_create_query_from_resource_without_id() { try { TimeMachineQuery.createForMetrics(new Resource()); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalArgumentException.class); } } }
xinghuangxu/xinghuangxu.sonarqube
sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java
Java
lgpl-3.0
2,818
[ 30522, 1013, 1008, 1008, 24609, 28940, 4783, 1010, 2330, 3120, 4007, 3737, 2968, 6994, 1012, 1008, 9385, 1006, 1039, 1007, 2263, 1011, 2286, 24609, 6499, 3126, 3401, 1008, 5653, 3406, 1024, 3967, 2012, 24609, 6499, 3126, 3401, 11089, 4012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd. *************************************************************************** * * * FreeRTOS tutorial books are available in pdf and paperback. * * Complete, revised, and edited pdf reference manuals are also * * available. * * * * Purchasing FreeRTOS documentation will not only help you, by * * ensuring you get running as quickly as possible and with an * * in-depth knowledge of how to use FreeRTOS, it will also help * * the FreeRTOS project to continue with its mission of providing * * professional grade, cross platform, de facto standard solutions * * for microcontrollers - completely free of charge! * * * * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * * * * Thank you for using FreeRTOS, and thank you for your support! * * * *************************************************************************** This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation AND MODIFIED BY the FreeRTOS exception. >>>NOTE<<< The modification to the GPL is included to allow you to distribute a combined work that includes FreeRTOS without being obliged to provide the source code for proprietary components outside of the FreeRTOS kernel. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License and the FreeRTOS license exception along with FreeRTOS; if not it can be viewed here: http://www.freertos.org/a00114.html and also obtained by writing to Richard Barry, contact details for whom are available on the FreeRTOS WEB site. 1 tab == 4 spaces! http://www.FreeRTOS.org - Documentation, latest information, license and contact details. http://www.SafeRTOS.com - A version that is certified for use in safety critical systems. http://www.OpenRTOS.com - Commercial support, development, porting, licensing and training services. */ /* The tasks defined on this page demonstrate the use of recursive mutexes. For recursive mutex functionality the created mutex should be created using xSemaphoreCreateRecursiveMutex(), then be manipulated using the xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() API functions. This demo creates three tasks all of which access the same recursive mutex: prvRecursiveMutexControllingTask() has the highest priority so executes first and grabs the mutex. It then performs some recursive accesses - between each of which it sleeps for a short period to let the lower priority tasks execute. When it has completed its demo functionality it gives the mutex back before suspending itself. prvRecursiveMutexBlockingTask() attempts to access the mutex by performing a blocking 'take'. The blocking task has a lower priority than the controlling task so by the time it executes the mutex has already been taken by the controlling task, causing the blocking task to block. It does not unblock until the controlling task has given the mutex back, and it does not actually run until the controlling task has suspended itself (due to the relative priorities). When it eventually does obtain the mutex all it does is give the mutex back prior to also suspending itself. At this point both the controlling task and the blocking task are suspended. prvRecursiveMutexPollingTask() runs at the idle priority. It spins round a tight loop attempting to obtain the mutex with a non-blocking call. As the lowest priority task it will not successfully obtain the mutex until both the controlling and blocking tasks are suspended. Once it eventually does obtain the mutex it first unsuspends both the controlling task and blocking task prior to giving the mutex back - resulting in the polling task temporarily inheriting the controlling tasks priority. */ /* Scheduler include files. */ #include "FreeRTOS.h" #include "task.h" #include "semphr.h" /* Demo app include files. */ #include "recmutex.h" /* Priorities assigned to the three tasks. */ #define recmuCONTROLLING_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define recmuBLOCKING_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define recmuPOLLING_TASK_PRIORITY ( tskIDLE_PRIORITY + 0 ) /* The recursive call depth. */ #define recmuMAX_COUNT ( 10 ) /* Misc. */ #define recmuSHORT_DELAY ( 20 / portTICK_RATE_MS ) #define recmuNO_DELAY ( ( portTickType ) 0 ) #define recmuTWO_TICK_DELAY ( ( portTickType ) 2 ) /* The three tasks as described at the top of this file. */ static void prvRecursiveMutexControllingTask( void *pvParameters ); static void prvRecursiveMutexBlockingTask( void *pvParameters ); static void prvRecursiveMutexPollingTask( void *pvParameters ); /* The mutex used by the demo. */ static xSemaphoreHandle xMutex; /* Variables used to detect and latch errors. */ static volatile portBASE_TYPE xErrorOccurred = pdFALSE, xControllingIsSuspended = pdFALSE, xBlockingIsSuspended = pdFALSE; static volatile unsigned portBASE_TYPE uxControllingCycles = 0, uxBlockingCycles = 0, uxPollingCycles = 0; /* Handles of the two higher priority tasks, required so they can be resumed (unsuspended). */ static xTaskHandle xControllingTaskHandle, xBlockingTaskHandle; /*-----------------------------------------------------------*/ void vStartRecursiveMutexTasks( void ) { /* Just creates the mutex and the three tasks. */ xMutex = xSemaphoreCreateRecursiveMutex(); /* vQueueAddToRegistry() adds the mutex to the registry, if one is in use. The registry is provided as a means for kernel aware debuggers to locate mutex and has no purpose if a kernel aware debugger is not being used. The call to vQueueAddToRegistry() will be removed by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is defined to be less than 1. */ vQueueAddToRegistry( ( xQueueHandle ) xMutex, ( signed portCHAR * ) "Recursive_Mutex" ); if( xMutex != NULL ) { xTaskCreate( prvRecursiveMutexControllingTask, ( signed portCHAR * ) "Rec1", configMINIMAL_STACK_SIZE, NULL, recmuCONTROLLING_TASK_PRIORITY, &xControllingTaskHandle ); xTaskCreate( prvRecursiveMutexBlockingTask, ( signed portCHAR * ) "Rec2", configMINIMAL_STACK_SIZE, NULL, recmuBLOCKING_TASK_PRIORITY, &xBlockingTaskHandle ); xTaskCreate( prvRecursiveMutexPollingTask, ( signed portCHAR * ) "Rec3", configMINIMAL_STACK_SIZE, NULL, recmuPOLLING_TASK_PRIORITY, NULL ); } } /*-----------------------------------------------------------*/ static void prvRecursiveMutexControllingTask( void *pvParameters ) { unsigned portBASE_TYPE ux; /* Just to remove compiler warning. */ ( void ) pvParameters; for( ;; ) { /* Should not be able to 'give' the mutex, as we have not yet 'taken' it. The first time through, the mutex will not have been used yet, subsequent times through, at this point the mutex will be held by the polling task. */ if( xSemaphoreGiveRecursive( xMutex ) == pdPASS ) { xErrorOccurred = pdTRUE; } for( ux = 0; ux < recmuMAX_COUNT; ux++ ) { /* We should now be able to take the mutex as many times as we like. The first time through the mutex will be immediately available, on subsequent times through the mutex will be held by the polling task at this point and this Take will cause the polling task to inherit the priority of this task. In this case the block time must be long enough to ensure the polling task will execute again before the block time expires. If the block time does expire then the error flag will be set here. */ if( xSemaphoreTakeRecursive( xMutex, recmuTWO_TICK_DELAY ) != pdPASS ) { xErrorOccurred = pdTRUE; } /* Ensure the other task attempting to access the mutex (and the other demo tasks) are able to execute to ensure they either block (where a block time is specified) or return an error (where no block time is specified) as the mutex is held by this task. */ vTaskDelay( recmuSHORT_DELAY ); } /* For each time we took the mutex, give it back. */ for( ux = 0; ux < recmuMAX_COUNT; ux++ ) { /* Ensure the other task attempting to access the mutex (and the other demo tasks) are able to execute. */ vTaskDelay( recmuSHORT_DELAY ); /* We should now be able to give the mutex as many times as we took it. When the mutex is available again the Blocking task should be unblocked but not run because it has a lower priority than this task. The polling task should also not run at this point as it too has a lower priority than this task. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { xErrorOccurred = pdTRUE; } } /* Having given it back the same number of times as it was taken, we should no longer be the mutex owner, so the next give sh ould fail. */ if( xSemaphoreGiveRecursive( xMutex ) == pdPASS ) { xErrorOccurred = pdTRUE; } /* Keep count of the number of cycles this task has performed so a stall can be detected. */ uxControllingCycles++; /* Suspend ourselves to the blocking task can execute. */ xControllingIsSuspended = pdTRUE; vTaskSuspend( NULL ); xControllingIsSuspended = pdFALSE; } } /*-----------------------------------------------------------*/ static void prvRecursiveMutexBlockingTask( void *pvParameters ) { /* Just to remove compiler warning. */ ( void ) pvParameters; for( ;; ) { /* This task will run while the controlling task is blocked, and the controlling task will block only once it has the mutex - therefore this call should block until the controlling task has given up the mutex, and not actually execute past this call until the controlling task is suspended. */ if( xSemaphoreTakeRecursive( xMutex, portMAX_DELAY ) == pdPASS ) { if( xControllingIsSuspended != pdTRUE ) { /* Did not expect to execute until the controlling task was suspended. */ xErrorOccurred = pdTRUE; } else { /* Give the mutex back before suspending ourselves to allow the polling task to obtain the mutex. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { xErrorOccurred = pdTRUE; } xBlockingIsSuspended = pdTRUE; vTaskSuspend( NULL ); xBlockingIsSuspended = pdFALSE; } } else { /* We should not leave the xSemaphoreTakeRecursive() function until the mutex was obtained. */ xErrorOccurred = pdTRUE; } /* The controlling and blocking tasks should be in lock step. */ if( uxControllingCycles != ( uxBlockingCycles + 1 ) ) { xErrorOccurred = pdTRUE; } /* Keep count of the number of cycles this task has performed so a stall can be detected. */ uxBlockingCycles++; } } /*-----------------------------------------------------------*/ static void prvRecursiveMutexPollingTask( void *pvParameters ) { /* Just to remove compiler warning. */ ( void ) pvParameters; for( ;; ) { /* Keep attempting to obtain the mutex. We should only obtain it when the blocking task has suspended itself, which in turn should only happen when the controlling task is also suspended. */ if( xSemaphoreTakeRecursive( xMutex, recmuNO_DELAY ) == pdPASS ) { /* Is the blocking task suspended? */ if( ( xBlockingIsSuspended != pdTRUE ) || ( xControllingIsSuspended != pdTRUE ) ) { xErrorOccurred = pdTRUE; } else { /* Keep count of the number of cycles this task has performed so a stall can be detected. */ uxPollingCycles++; /* We can resume the other tasks here even though they have a higher priority than the polling task. When they execute they will attempt to obtain the mutex but fail because the polling task is still the mutex holder. The polling task (this task) will then inherit the higher priority. The Blocking task will block indefinitely when it attempts to obtain the mutex, the Controlling task will only block for a fixed period and an error will be latched if the polling task has not returned the mutex by the time this fixed period has expired. */ vTaskResume( xBlockingTaskHandle ); vTaskResume( xControllingTaskHandle ); /* The other two tasks should now have executed and no longer be suspended. */ if( ( xBlockingIsSuspended == pdTRUE ) || ( xControllingIsSuspended == pdTRUE ) ) { xErrorOccurred = pdTRUE; } /* Release the mutex, disinheriting the higher priority again. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { xErrorOccurred = pdTRUE; } } } #if configUSE_PREEMPTION == 0 { taskYIELD(); } #endif } } /*-----------------------------------------------------------*/ /* This is called to check that all the created tasks are still running. */ portBASE_TYPE xAreRecursiveMutexTasksStillRunning( void ) { portBASE_TYPE xReturn; static unsigned portBASE_TYPE uxLastControllingCycles = 0, uxLastBlockingCycles = 0, uxLastPollingCycles = 0; /* Is the controlling task still cycling? */ if( uxLastControllingCycles == uxControllingCycles ) { xErrorOccurred = pdTRUE; } else { uxLastControllingCycles = uxControllingCycles; } /* Is the blocking task still cycling? */ if( uxLastBlockingCycles == uxBlockingCycles ) { xErrorOccurred = pdTRUE; } else { uxLastBlockingCycles = uxBlockingCycles; } /* Is the polling task still cycling? */ if( uxLastPollingCycles == uxPollingCycles ) { xErrorOccurred = pdTRUE; } else { uxLastPollingCycles = uxPollingCycles; } if( xErrorOccurred == pdTRUE ) { xReturn = pdFAIL; } else { xReturn = pdTRUE; } return xReturn; }
Beck-Sisyphus/EE472
Lab5/Demo/Common/Minimal/recmutex.c
C
mit
14,572
[ 30522, 1013, 1008, 2489, 5339, 2891, 1058, 2581, 1012, 1014, 1012, 1015, 1011, 9385, 1006, 1039, 1007, 2249, 2613, 2051, 6145, 5183, 1012, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2015 Mikhail Sapozhnikov * * This file is part of scriba-android. * * scriba-android is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * scriba-android is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with scriba-android. If not, see <http://www.gnu.org/licenses/>. * */ package org.scribacrm.scriba; import org.scribacrm.libscriba.*; import android.app.Activity; import android.util.Log; import android.app.Fragment; import android.widget.TextView; import android.view.LayoutInflater; import android.view.ViewGroup; import android.view.View; import android.os.Bundle; import android.widget.EditText; import android.widget.ArrayAdapter; import android.content.Loader; import android.app.LoaderManager; import android.widget.AdapterView; import android.widget.Spinner; import java.util.Date; import java.text.DateFormat; import java.util.UUID; import java.util.Set; import java.util.HashSet; import android.widget.LinearLayout; public class EditEntryFragment extends Fragment implements CompanySpinnerHandler.OnSelectedListener, DateTimeHandler.OnDateChangedListener, ReminderDialog.ReminderSetListener { private class ReminderListClickListener implements View.OnClickListener { private EventAlarm _alarm = null; public ReminderListClickListener(EventAlarm alarm) { _alarm = alarm; } @Override public void onClick(View v) { // remove alarm from adapter and its view from reminder list _eventAlarmAdapter.remove(_alarm); LinearLayout reminderList = (LinearLayout)getActivity(). findViewById(R.id.event_reminder_list); reminderList.removeView(v); } } // entry data for each entry type private Company _company = null; private Event _event = null; private Project _project = null; private POC _poc = null; // company spinner handler instance private CompanySpinnerHandler _companySpinnerHandler = null; // project state spinner handler instance private ProjectStateSpinnerHandler _projectStateSpinnerHandler = null; // POC spinner handler instance private POCSpinnerHandler _pocSpinnerHandler = null; // project spinner handler instance private ProjectSpinnerHandler _projectSpinnerHandler = null; // currency spinner handler instance private CurrencySpinnerHandler _currencySpinnerHandler = null; // event type spinner handler instance private EventTypeSpinnerHandler _eventTypeSpinnerHandler = null; // event state spinner handler instance private EventStateSpinnerHandler _eventStateSpinnerHandler = null; // event date private Date _eventDate = null; // date/time handler instance private DateTimeHandler _dateTimeHandler = null; // event reminder adapter private ArrayAdapter<EventAlarm> _eventAlarmAdapter = null; public EditEntryFragment(Company company) { _company = company; } public EditEntryFragment(Event event) { _event = event; } public EditEntryFragment(Project project) { _project = project; } public EditEntryFragment(POC poc) { _poc = poc; } // save changes made by user public void save() { if (_company != null) { saveCompanyData(); } else if (_event != null) { saveEventData(); } else if (_project != null) { saveProjectData(); } else if (_poc != null) { savePOCData(); } else { Log.e("[Scriba]", "EditEntryFragment.save() called, but there's no entry data"); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = null; if (_company != null) { view = inflater.inflate(R.layout.add_company, container, false); } else if (_event != null) { view = inflater.inflate(R.layout.add_event, container, false); } else if (_project != null) { view = inflater.inflate(R.layout.add_project, container, false); } else if (_poc != null) { view = inflater.inflate(R.layout.add_poc, container, false); } else { Log.e("[Scriba]", "Cannot create EditEntryFragment view, no data passed to fragment"); } return view; } @Override public void onStart() { if (_company != null) { populateCompanyView(); } else if (_event != null) { populateEventView(); } else if (_project != null) { populateProjectView(); } else if (_poc != null) { populatePOCView(); } getActivity().invalidateOptionsMenu(); super.onStart(); } // CompanySpinnerHandler.OnSelectedListener implementation @Override public void onCompanySelected(UUID companyId) { // only for event editor if (_event != null) { // populate poc spinner with people for currently selected company Spinner pocSpinner = (Spinner)getActivity().findViewById(R.id.event_poc_spinner); _pocSpinnerHandler.load(pocSpinner, companyId, _event.poc_id); // populate project spinner with projects for currently selected company Spinner projectSpinner = (Spinner)getActivity().findViewById(R.id.event_project_spinner); _projectSpinnerHandler.load(projectSpinner, companyId, _event.project_id); } } // DateTimeHandler.OnDateChangedListener implementation @Override public void onDateChanged(Date newDate) { _eventDate = newDate; TextView dateText = (TextView)getActivity().findViewById(R.id.event_date_text); TextView timeText = (TextView)getActivity().findViewById(R.id.event_time_text); DateFormat dateFormat = DateFormat.getDateInstance(); DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT); dateText.setText(dateFormat.format(_eventDate)); timeText.setText(timeFormat.format(_eventDate)); } // ReminderDialog.ReminderSetListener implementation @Override public void onReminderSet(byte type, long value) { if (_eventAlarmAdapter == null) { // this is the first one, create adapter _eventAlarmAdapter = new ArrayAdapter<EventAlarm>(getActivity(), R.layout.reminder_item, R.id.event_reminder_text); } EventAlarm alarm = new EventAlarm(getActivity(), value, type, _eventDate.getTime()); _eventAlarmAdapter.add(alarm); // get view and add it to the reminder list int pos = _eventAlarmAdapter.getPosition(alarm); LinearLayout reminderList = (LinearLayout)getActivity(). findViewById(R.id.event_reminder_list); View alarmView = _eventAlarmAdapter.getView(pos, null, (ViewGroup)reminderList); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); reminderList.addView(alarmView, params); alarmView.setOnClickListener(new ReminderListClickListener(alarm)); } // populate view with company data private void populateCompanyView() { EditText txt = (EditText)getActivity().findViewById(R.id.company_name_text); txt.setText(_company.name); txt = (EditText)getActivity().findViewById(R.id.company_jur_name_text); txt.setText(_company.jur_name); txt = (EditText)getActivity().findViewById(R.id.company_address_text); txt.setText(_company.address); txt = (EditText)getActivity().findViewById(R.id.company_inn_text); txt.setText(_company.inn); txt = (EditText)getActivity().findViewById(R.id.company_phonenum_text); txt.setText(_company.phonenum); txt = (EditText)getActivity().findViewById(R.id.company_email_text); txt.setText(_company.email); } // populate view with event data private void populateEventView() { EditText txt = (EditText)getActivity().findViewById(R.id.event_descr_text); txt.setText(_event.descr); // setup company spinner _companySpinnerHandler = new CompanySpinnerHandler(getActivity(), getLoaderManager(), this); Spinner companySpinner = (Spinner)getActivity().findViewById(R.id.event_company_spinner); _companySpinnerHandler.load(companySpinner, _event.company_id); // setup poc spinner _pocSpinnerHandler = new POCSpinnerHandler(getActivity(), getLoaderManager()); // load() for poc spinner is called when company spinner reports selection // setup project spinner _projectSpinnerHandler = new ProjectSpinnerHandler(getActivity(), getLoaderManager()); // load() for project spinner is called when company spinner reports selection // setup event type spinner _eventTypeSpinnerHandler = new EventTypeSpinnerHandler(getActivity()); Spinner eventTypeSpinner = (Spinner)getActivity().findViewById(R.id.event_type_spinner); _eventTypeSpinnerHandler.populateSpinner(eventTypeSpinner, _event.type); // setup event state spinner _eventStateSpinnerHandler = new EventStateSpinnerHandler(getActivity()); Spinner eventStateSpinner = (Spinner)getActivity().findViewById(R.id.event_state_spinner); _eventStateSpinnerHandler.populateSpinner(eventStateSpinner, _event.state); // event outcome txt = (EditText)getActivity().findViewById(R.id.event_outcome_text); txt.setText(_event.outcome); // setup event date and time _eventDate = new Date(_event.timestamp * 1000); _dateTimeHandler = new DateTimeHandler(_eventDate, getActivity(), getActivity().getFragmentManager(), this); View dateView = getActivity().findViewById(R.id.event_date); View timeView = getActivity().findViewById(R.id.event_time); dateView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _dateTimeHandler.showDatePicker(); } }); timeView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _dateTimeHandler.showTimePicker(); } }); // populate date and time text fields - onDateChanged() will do the job onDateChanged(_eventDate); // setup "add reminder" button View reminderView = getActivity().findViewById(R.id.event_add_reminder); reminderView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ReminderDialog dialog = new ReminderDialog(EditEntryFragment.this, getActivity()); dialog.show(getActivity().getFragmentManager(), "ReminderDialog"); } }); // create views for already existing reminders EventAlarmMgr eventAlarmMgr = new EventAlarmMgr(getActivity()); Set<Long> existingAlarms = eventAlarmMgr.getAlarms(_event.id); if (existingAlarms != null) { for (Long ts : existingAlarms) { EventAlarm eventAlarm = new EventAlarm(getActivity(), ts.longValue(), _event.timestamp); // onReminderSet will create the view for each reminder onReminderSet(eventAlarm.getIntervalType(), eventAlarm.getInterval()); } } } // populate view with project data private void populateProjectView() { EditText txt = (EditText)getActivity().findViewById(R.id.project_title_text); txt.setText(_project.title); txt = (EditText)getActivity().findViewById(R.id.project_descr_text); txt.setText(_project.descr); // setup company spinner _companySpinnerHandler = new CompanySpinnerHandler(getActivity(), getLoaderManager(), this); Spinner companySpinner = (Spinner)getActivity().findViewById(R.id.project_company_spinner); _companySpinnerHandler.load(companySpinner, _project.company_id); // setup project state spinner Spinner projStateSpinner = (Spinner)getActivity().findViewById(R.id.project_state_spinner); _projectStateSpinnerHandler = new ProjectStateSpinnerHandler(getActivity()); _projectStateSpinnerHandler.populateSpinner(projStateSpinner, _project.state); // setup currency spinner Spinner currencySpinner = (Spinner)getActivity().findViewById(R.id.project_currency_spinner); _currencySpinnerHandler = new CurrencySpinnerHandler(getActivity()); _currencySpinnerHandler.populateSpinner(currencySpinner, _project.currency); txt = (EditText)getActivity().findViewById(R.id.project_cost_text); txt.setText((new Long(_project.cost)).toString()); } // populate view with poc data private void populatePOCView() { EditText txt = (EditText)getActivity().findViewById(R.id.poc_firstname_text); txt.setText(_poc.firstname); txt = (EditText)getActivity().findViewById(R.id.poc_secondname_text); txt.setText(_poc.secondname); txt = (EditText)getActivity().findViewById(R.id.poc_lastname_text); txt.setText(_poc.lastname); txt = (EditText)getActivity().findViewById(R.id.poc_mobilenum_text); txt.setText(_poc.mobilenum); txt = (EditText)getActivity().findViewById(R.id.poc_phonenum_text); txt.setText(_poc.phonenum); txt = (EditText)getActivity().findViewById(R.id.poc_email_text); txt.setText(_poc.email); txt = (EditText)getActivity().findViewById(R.id.poc_position_text); txt.setText(_poc.position); // setup company spinner _companySpinnerHandler = new CompanySpinnerHandler(getActivity(), getLoaderManager(), this); Spinner companySpinner = (Spinner)getActivity().findViewById(R.id.poc_company_spinner); _companySpinnerHandler.load(companySpinner, _poc.company_id); } // save company modifications private void saveCompanyData() { EditText txt = (EditText)getActivity().findViewById(R.id.company_name_text); String companyName = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.company_jur_name_text); String companyJurName = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.company_address_text); String companyAddress = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.company_inn_text); String companyInn = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.company_phonenum_text); String companyPhonenum = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.company_email_text); String companyEmail = txt.getText().toString(); Company company = new Company(_company.id, companyName, companyJurName, companyAddress, companyInn, companyPhonenum, companyEmail); // update company data ScribaDBManager.useDB(getActivity()); ScribaDB.updateCompany(company); ScribaDBManager.releaseDB(); } // save event modifications private void saveEventData() { EditText txt = (EditText)getActivity().findViewById(R.id.event_descr_text); String descr = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.event_outcome_text); String outcome = txt.getText().toString(); UUID companyId = _companySpinnerHandler.getSelectedCompanyId(); UUID pocId = _pocSpinnerHandler.getSelectedPOCId(); UUID projectId = _projectSpinnerHandler.getSelectedProjectId(); byte type = _eventTypeSpinnerHandler.getSelectedType(); byte state = _eventStateSpinnerHandler.getSelectedState(); // libscriba expects timestamp in seconds long timestamp = _eventDate.getTime() / 1000; Event event = new Event(_event.id, descr, companyId, pocId, projectId, type, outcome, timestamp, state); ScribaDBManager.useDB(getActivity()); ScribaDB.updateEvent(event); ScribaDBManager.releaseDB(); saveEventReminders(event); } // save event reminder modifications private void saveEventReminders(Event event) { EventAlarmMgr evtAlarmMgr = new EventAlarmMgr(getActivity()); if (_eventAlarmAdapter != null) { // remove all alarms and add only those that are present // in the alarm adapter evtAlarmMgr.removeAlarms(event.id); for (int i = 0; i < _eventAlarmAdapter.getCount(); i++) { EventAlarm alarm = _eventAlarmAdapter.getItem(i); // event timestamp may have changed since EventAlarm object // creation, so make new object with updated event time EventAlarm updAlarm = new EventAlarm(getActivity(), alarm.getInterval(), alarm.getIntervalType(), event.timestamp); evtAlarmMgr.addAlarm(event.id, updAlarm.getAlarmTimestamp()); } } // if the alarm adapter is not instantiated at this moment, it // means there were no reminders set for this event, so do nothing } // save project modifications private void saveProjectData() { EditText txt = (EditText)getActivity().findViewById(R.id.project_title_text); String title = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.project_descr_text); String descr = txt.getText().toString(); UUID selectedCompanyId = _companySpinnerHandler.getSelectedCompanyId(); byte selectedState = _projectStateSpinnerHandler.getSelectedState(); byte selectedCurrency = _currencySpinnerHandler.getSelectedCurrency(); txt = (EditText)getActivity().findViewById(R.id.project_cost_text); long cost = Long.parseLong(txt.getText().toString(), 10); long mod_time = _project.mod_time; // if project state has changed, update mod_time if (_projectStateSpinnerHandler.hasChanged()) { mod_time = (new Date()).getTime() / 1000; // convert to seconds } Project project = new Project(_project.id, title, descr, selectedCompanyId, selectedState, selectedCurrency, cost, _project.start_time, mod_time); ScribaDBManager.useDB(getActivity()); ScribaDB.updateProject(project); ScribaDBManager.releaseDB(); } // save poc modifications private void savePOCData() { EditText txt = (EditText)getActivity().findViewById(R.id.poc_firstname_text); String firstname = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_secondname_text); String secondname = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_lastname_text); String lastname = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_mobilenum_text); String mobilenum = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_phonenum_text); String phonenum = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_email_text); String email = txt.getText().toString(); txt = (EditText)getActivity().findViewById(R.id.poc_position_text); String position = txt.getText().toString(); UUID selectedCompanyId = _companySpinnerHandler.getSelectedCompanyId(); POC poc = new POC(_poc.id, firstname, secondname, lastname, mobilenum, phonenum, email, position, selectedCompanyId); ScribaDBManager.useDB(getActivity()); ScribaDB.updatePOC(poc); ScribaDBManager.releaseDB(); } }
MooseTheBrown/scriba-android
src/org/scribacrm/scriba/EditEntryFragment.java
Java
gpl-3.0
21,596
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2325, 11318, 20066, 18153, 7295, 12676, 2615, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 8040, 3089, 3676, 1011, 11924, 1012, 1008, 1008, 8040, 3089, 3676, 1011, 11924, 2003, 2489, 4007, 1024,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/bin/sh # Checks if a given cert on disk will expire soon # Copyright 2009 Peter Palfrader # # 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. set -u set -e # warn if expires within 2 weeks, critical if within a day or already is expired warn=1209600 crit=86400 if [ "$#" != 1 ]; then echo "Usage: $0 <certfile>" >&2 exit 3 fi cert="$1" if ! [ -r "$cert" ] ; then echo "Cert file ($cert) does not exist or is not readable" >&2 exit 3 fi expires=`openssl x509 -enddate -noout < "$cert"` if openssl x509 -checkend "$warn" -noout < "$cert" ; then echo "OK: $expires" exit 0 fi if openssl x509 -checkend "$crit" -noout < "$cert" ; then echo "WARN: $expires" exit 1 fi echo "CRITICAL: $expires" exit 2
KyleJHarper/puppet-icinga
files/usr/local/lib/nagios/plugins/check_cert.sh
Shell
apache-2.0
1,723
[ 30522, 1001, 999, 1013, 8026, 1013, 14021, 1001, 14148, 2065, 1037, 2445, 8292, 5339, 2006, 9785, 2097, 4654, 20781, 2574, 1001, 9385, 2268, 2848, 14412, 27843, 4063, 1001, 1001, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.ssmcontacts.model; import java.io.Serializable; import javax.annotation.Generated; import com.amazonaws.AmazonWebServiceRequest; /** * * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/ssm-contacts-2021-05-03/ActivateContactChannel" * target="_top">AWS API Documentation</a> */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class ActivateContactChannelRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable { /** * <p> * The Amazon Resource Name (ARN) of the contact channel. * </p> */ private String contactChannelId; /** * <p> * The code sent to the contact channel when it was created in the contact. * </p> */ private String activationCode; /** * <p> * The Amazon Resource Name (ARN) of the contact channel. * </p> * * @param contactChannelId * The Amazon Resource Name (ARN) of the contact channel. */ public void setContactChannelId(String contactChannelId) { this.contactChannelId = contactChannelId; } /** * <p> * The Amazon Resource Name (ARN) of the contact channel. * </p> * * @return The Amazon Resource Name (ARN) of the contact channel. */ public String getContactChannelId() { return this.contactChannelId; } /** * <p> * The Amazon Resource Name (ARN) of the contact channel. * </p> * * @param contactChannelId * The Amazon Resource Name (ARN) of the contact channel. * @return Returns a reference to this object so that method calls can be chained together. */ public ActivateContactChannelRequest withContactChannelId(String contactChannelId) { setContactChannelId(contactChannelId); return this; } /** * <p> * The code sent to the contact channel when it was created in the contact. * </p> * * @param activationCode * The code sent to the contact channel when it was created in the contact. */ public void setActivationCode(String activationCode) { this.activationCode = activationCode; } /** * <p> * The code sent to the contact channel when it was created in the contact. * </p> * * @return The code sent to the contact channel when it was created in the contact. */ public String getActivationCode() { return this.activationCode; } /** * <p> * The code sent to the contact channel when it was created in the contact. * </p> * * @param activationCode * The code sent to the contact channel when it was created in the contact. * @return Returns a reference to this object so that method calls can be chained together. */ public ActivateContactChannelRequest withActivationCode(String activationCode) { setActivationCode(activationCode); return this; } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getContactChannelId() != null) sb.append("ContactChannelId: ").append(getContactChannelId()).append(","); if (getActivationCode() != null) sb.append("ActivationCode: ").append(getActivationCode()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ActivateContactChannelRequest == false) return false; ActivateContactChannelRequest other = (ActivateContactChannelRequest) obj; if (other.getContactChannelId() == null ^ this.getContactChannelId() == null) return false; if (other.getContactChannelId() != null && other.getContactChannelId().equals(this.getContactChannelId()) == false) return false; if (other.getActivationCode() == null ^ this.getActivationCode() == null) return false; if (other.getActivationCode() != null && other.getActivationCode().equals(this.getActivationCode()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getContactChannelId() == null) ? 0 : getContactChannelId().hashCode()); hashCode = prime * hashCode + ((getActivationCode() == null) ? 0 : getActivationCode().hashCode()); return hashCode; } @Override public ActivateContactChannelRequest clone() { return (ActivateContactChannelRequest) super.clone(); } }
aws/aws-sdk-java
aws-java-sdk-ssmcontacts/src/main/java/com/amazonaws/services/ssmcontacts/model/ActivateContactChannelRequest.java
Java
apache-2.0
5,688
[ 30522, 1013, 1008, 1008, 9385, 2418, 1011, 16798, 2475, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- title: P --- ## Paragraphs Paragraphs should be kept short on web pages. Research shows that most people will scan a web page. Heavy blocks of text are not easy to read on screen and vital points can be missed. Use a bulleted list to emphasise the main points wherever possible. ## Parents and carers Use 'parents and carers' instead of 'parents and guardians'. Spell out 'and' rather than using 'parents/carers'. ## Plain English Aim to be as clear and concise as possible. Using plain English does not mean you are dumbing down your text, rather you are delivering your message in the clearest way possible. Don?t forget that often you are writing for a mixed audience whose first language may not be English. see <a href="http://www.plainenglish.co.uk/">The Plain English Campaign</a>
richardwiggins/ncc-test
src/docs/Content Style Guide/P.md
Markdown
mit
799
[ 30522, 1011, 1011, 1011, 2516, 1024, 1052, 1011, 1011, 1011, 1001, 1001, 20423, 2015, 20423, 2015, 2323, 2022, 2921, 2460, 2006, 4773, 5530, 1012, 2470, 3065, 2008, 2087, 2111, 2097, 13594, 1037, 4773, 3931, 1012, 3082, 5991, 1997, 3793, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# GDWCalc A gross die per wafer (GDW) calculator. Plots up a wafer map of rectangular die based on the die size, wafer diameter, and exclusion zones. Die are colored by their status (good to probe, crosses edge exclusion, crosses flat exclusion, or falls off due to the wafer flat. Knows about SEMI SPEC M1-0302 which defines wafer flat sizes. ## Changelog See CHANGELOG.md
dougthor42/GDWCalc
README.md
Markdown
gpl-2.0
379
[ 30522, 1001, 1043, 2094, 16526, 2389, 2278, 1037, 7977, 3280, 2566, 11333, 7512, 1006, 1043, 2094, 2860, 1007, 10250, 19879, 4263, 1012, 14811, 2039, 1037, 11333, 7512, 4949, 1997, 10806, 3280, 2241, 2006, 1996, 3280, 2946, 1010, 11333, 751...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Training utility functions.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from six import string_types import random import re import json import numpy as np import traceback from cognitive import stim_generator as sg import cognitive.constants as const _R_MEAN = 123.68 _G_MEAN = 116.78 _B_MEAN = 103.94 def convert_to_grid(xy_coord, prefs): """Given a x-y coordinate, return the target activity for a grid of neurons. Args: xy_coord : numpy 2-D array (batch_size, 2) prefs: numpy 2-D array (n_out_pnt, 2). x and y preferences. Returns: activity: numpy array (batch_size, GRID_SIZE**2) """ sigma2 = 0.02 # 2*sigma-squared activity = np.exp(-((xy_coord[:, 0:1] - prefs[:, 0])**2 + (xy_coord[:, 1:2] - prefs[:, 1])**2) / sigma2) activity = (activity.T / np.sum(activity, axis=1)).T return activity def map_sentence2ints(sentence): """Map a sentence to a list of words.""" word_list = re.findall(r"[\w']+|[.,!?;]", sentence) int_list = [const.INPUTVOCABULARY.index(word) for word in word_list] return np.array(int_list).astype(np.int32) def preprocess(in_imgs_, vis_type): """Pre-process images.""" if (vis_type == 'vgg') or (vis_type == 'vgg_pretrain'): in_imgs_ -= np.array([_R_MEAN, _G_MEAN, _B_MEAN], dtype=np.float32) else: in_imgs_ /= 255. in_imgs_ -= np.mean(in_imgs_) return in_imgs_ def tasks_to_rules(tasks): """Generate in_rule and seq_length arrays. Args: tasks: a list of tg.Task instances or string rules, length is batch_size. """ batch_size = len(tasks) in_rule = np.zeros((const.MAXSEQLENGTH, batch_size), dtype=np.int64) seq_length = np.zeros((batch_size,), dtype=np.int64) for i_task, task in enumerate(tasks): word_list = re.findall(r"[\w']+|[.,!?;]", str(task)) seq_length[i_task] = len(word_list) for i_word, word in enumerate(word_list): in_rule[i_word, i_task] = const.INPUTVOCABULARY.index(word) return in_rule, seq_length def set_outputs_from_tasks(n_epoch, tasks, objsets, out_pnt_xy, out_word, mask_pnt, mask_word): j = 0 for epoch_now in range(n_epoch): for task, objset in zip(tasks, objsets): target = task(objset, epoch_now) if target is const.INVALID: # For invalid target, no loss is used. Everything remains zero. pass elif isinstance(target, sg.Loc): # minimize point loss out_pnt_xy[j, :] = target.value mask_pnt[j] = 1. elif isinstance(target, bool) or isinstance(target, sg.Attribute): if isinstance(target, bool): target = 'true' if target else 'false' else: target = target.value # For boolean target, only minimize word loss out_word[j] = const.OUTPUTVOCABULARY.index(target) mask_word[j] = 1. else: raise TypeError('Unknown target type.') j += 1 def set_outputs_from_targets(n_epoch, objsets, out_pnt_xy, out_word, mask_pnt, mask_word): j = 0 for epoch_now in range(n_epoch): for objset in objsets: target = objset.targets[epoch_now] if target == 'invalid': # For invalid target, no loss is used. Everything remains zero. pass elif isinstance(target, (list, tuple)): assert len(target) == 2, "Expected 2-D target. Got " + str(target) # minimize point loss out_pnt_xy[j, :] = target mask_pnt[j] = 1. elif isinstance(target, string_types): out_word[j] = const.OUTPUTVOCABULARY.index(target) mask_word[j] = 1. else: raise TypeError('Unknown target type: %s %s' % (type(target), target)) j += 1 def generate_batch(tasks, n_epoch=30, img_size=224, objsets=None, n_distractor=1, average_memory_span=2): """Generate a batch of trials. Return numpy arrays to feed the tensorflow placeholders. Args: tasks: a list of tg.Task instances, length is batch_size. n_epoch: int, number of epochs img_size: int, image size objsets: None or list of ObjectSet/StaticObjectSet instances n_distractor: int, number of distractors to add average_memory_span: int, the average number of epochs by which an object need to be held in working memory, if needed at all Returns: All variables are numpy array of float32 in_imgs: (n_epoch*batch_size, img_size, img_size, 3) in_rule: (max_seq_length, batch_size) the rule language input, type int32 seq_length: (batch_size,) the length of each task instruction out_pnt: (n_epoch*batch_size, n_out_pnt) out_pnt_xy: (n_epoch*batch_size, 2) out_word: (n_epoch*batch_size, n_out_word) mask_pnt: (n_epoch*batch_size) mask_word: (n_epoch*batch_size) Raises: TypeError: when target type is incorrect. """ batch_size = len(tasks) if objsets is None: objsets = list() for task in tasks: objsets.append( task.generate_objset(n_epoch, n_distractor=n_distractor, average_memory_span=average_memory_span)) max_objset_epoch = max([objset.n_epoch for objset in objsets]) assert max_objset_epoch == n_epoch, '%d != %d' % (max_objset_epoch, n_epoch) in_imgs = sg.render(objsets, img_size) # The rendered images are batch major in_imgs = np.reshape(in_imgs, [batch_size, n_epoch, img_size, img_size, 3]) # Swap to time major in_imgs = np.swapaxes(in_imgs, 0, 1) # Outputs and masks out_pnt_xy = np.zeros((n_epoch * batch_size, 2), dtype=np.float32) out_word = np.zeros((n_epoch * batch_size), dtype=np.int64) mask_pnt = np.zeros((n_epoch * batch_size), dtype=np.float32) mask_word = np.zeros((n_epoch * batch_size), dtype=np.float32) if isinstance(objsets[0], sg.StaticObjectSet): set_outputs_from_targets(n_epoch, objsets, out_pnt_xy, out_word, mask_pnt, mask_word) else: set_outputs_from_tasks(n_epoch, tasks, objsets, out_pnt_xy, out_word, mask_pnt, mask_word) # Process outputs out_pnt = convert_to_grid(out_pnt_xy, const.PREFS) # Generate rule inputs, padded to maximum number of words in a sentence in_rule, seq_length = tasks_to_rules(tasks) return (in_imgs, in_rule, seq_length, out_pnt, out_pnt_xy, out_word, mask_pnt, mask_word) def static_objsets_from_examples(examples): """Returns a list of StaticObjectSet objects. Args: examples: an iterable of dictionaries decoded from json examples. """ static_objsets = [] for e in examples: static_objs = [o for multi_epoch_obj in e['objects'] for o in sg.static_objects_from_dict(multi_epoch_obj)] static_objset = sg.StaticObjectSet(n_epoch=e['epochs'], static_objects=static_objs, targets=e['answers']) static_objsets.append(static_objset) return static_objsets def json_to_feeds(json_examples): if isinstance(json_examples, string_types): json_examples = [json_examples] examples = [] families = [] rules = [] for je in json_examples: try: e = json.loads(je) except (ValueError, TypeError): traceback.print_exc() raise rules.append(e['question']) examples.append(e) families.append(e['family']) epochs = examples[0]['epochs'] static_objsets = static_objsets_from_examples(examples) values = generate_batch(rules, n_epoch=epochs, img_size=112, objsets=static_objsets, # not used when objsets are given n_distractor=0, # not used when objsets are given average_memory_span=0) values = values + (families,) return values def generate_feeds(tasks, hparams, dataparams=None): """Generate feed dict for placeholders. Args: tasks: a list of tg.Task instances, length is batch_size. hparams: hyperparameters in tf.HParams format. dataparams: dictionary of parameters for the dataset Returns: feed_dict: the tensorflow feed_dict dictionary """ if isinstance(hparams.n_epoch, int): n_epoch = hparams.n_epoch else: n_epoch = random.randrange(hparams.n_epoch[0], hparams.n_epoch[1] + 1) # in_imgs, in_rule, seq_length, out_pnt, out_pnt_xy, out_word, mask_pnt, # mask_word return generate_batch( tasks, n_epoch=n_epoch, img_size=112, n_distractor=dataparams['n_distractor'], average_memory_span=dataparams['average_memory_span'] )
google/cog
cognitive/train_utils.py
Python
apache-2.0
9,504
[ 30522, 1001, 9385, 2760, 8224, 11775, 1001, 1001, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1001, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12646, 2007, 1996, 6105, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * The Alphanum Algorithm is an improved sorting algorithm for strings * containing numbers. Instead of sorting numbers in ASCII order like * a standard sort, this algorithm sorts numbers in numeric order. * * The Alphanum Algorithm is discussed at http://www.DaveKoelle.com * * Based on the Java implementation of Dave Koelle's Alphanum algorithm. * Contributed by Jonathan Ruckwood <jonathan.ruckwood@gmail.com> * * Adapted by Dominik Hurnaus <dominik.hurnaus@gmail.com> to * - correctly sort words where one word starts with another word * - have slightly better performance * * Made generic by Ragg @ 30.03.2015 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ using System; using System.Collections.Generic; using System.Text; /* * Please compare against the latest Java version at http://www.DaveKoelle.com * to see the most recent modifications */ namespace AlphanumComparator { public class AlphanumComparator<T> : IComparer<T> { public int Compare(T x, T y) { if (x == null && y == null) { return 0; } if (x == null) { return -1; } if (y == null) { return 1; } var s1 = x.ToString(); var s2 = y.ToString(); int thisMarker = 0, thisNumericChunk = 0; int thatMarker = 0, thatNumericChunk = 0; while ((thisMarker < s1.Length) || (thatMarker < s2.Length)) { if (thisMarker >= s1.Length) { return -1; } if (thatMarker >= s2.Length) { return 1; } var thisCh = s1[thisMarker]; var thatCh = s2[thatMarker]; var thisChunk = new StringBuilder(); var thatChunk = new StringBuilder(); while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || InChunk(thisCh, thisChunk[0]))) { thisChunk.Append(thisCh); thisMarker++; if (thisMarker < s1.Length) { thisCh = s1[thisMarker]; } } while ((thatMarker < s2.Length) && (thatChunk.Length == 0 || InChunk(thatCh, thatChunk[0]))) { thatChunk.Append(thatCh); thatMarker++; if (thatMarker < s2.Length) { thatCh = s2[thatMarker]; } } var result = 0; // If both chunks contain numeric characters, sort them numerically if (char.IsDigit(thisChunk[0]) && char.IsDigit(thatChunk[0])) { thisNumericChunk = Convert.ToInt32(thisChunk.ToString()); thatNumericChunk = Convert.ToInt32(thatChunk.ToString()); if (thisNumericChunk < thatNumericChunk) { result = -1; } if (thisNumericChunk > thatNumericChunk) { result = 1; } } else { result = thisChunk.ToString().CompareTo(thatChunk.ToString()); } if (result != 0) { return result; } } return 0; } private bool InChunk(char ch, char otherCh) { var type = ChunkType.Alphanumeric; if (char.IsDigit(otherCh)) { type = ChunkType.Numeric; } if ((type == ChunkType.Alphanumeric && char.IsDigit(ch)) || (type == ChunkType.Numeric && !char.IsDigit(ch))) { return false; } return true; } private enum ChunkType { Alphanumeric, Numeric }; } }
Ragg/poecv
PoECV/AlphanumComparator.cs
C#
mit
4,944
[ 30522, 1013, 1008, 1008, 1996, 6541, 19172, 9896, 2003, 2019, 5301, 22210, 9896, 2005, 7817, 1008, 4820, 3616, 1012, 2612, 1997, 22210, 3616, 1999, 2004, 6895, 2072, 2344, 2066, 1008, 1037, 3115, 4066, 1010, 2023, 9896, 11901, 3616, 1999, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 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. */ /* * Copyright (c) 2012, The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 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. */ #ifndef WLAN_QCT_TLI_BA_H #define WLAN_QCT_TLI_BA_H /*=========================================================================== W L A N T R A N S P O R T L A Y E R B L O C K A C K I N T E R N A L A P I DESCRIPTION This file contains the internal declarations used within wlan transport layer module for BA session support, AMSDU de-aggregation and MSDU reordering. Copyright (c) 2008 QUALCOMM Incorporated. All Rights Reserved. Qualcomm Confidential and Proprietary ===========================================================================*/ /*=========================================================================== EDIT HISTORY FOR FILE This section contains comments describing changes made to the module. Notice that changes are listed in reverse chronological order. $Header:$ $DateTime: $ $Author: $ when who what, where, why -------- --- ---------------------------------------------------------- 08/22/08 sch Update based on unit test 07/31/08 lti Created module. ===========================================================================*/ /*=========================================================================== INCLUDE FILES FOR MODULE ===========================================================================*/ /*---------------------------------------------------------------------------- * Include Files * -------------------------------------------------------------------------*/ #include "wlan_qct_tli.h" /*--------------------------------------------------------------------------- Re-order opcode filled in by RPE !!! fix me: (check with RPE doc if the codes are correct) ---------------------------------------------------------------------------*/ typedef enum { WLANTL_OPCODE_INVALID = 0, WLANTL_OPCODE_QCUR_FWDBUF = 1, WLANTL_OPCODE_FWDBUF_FWDCUR = 2, WLANTL_OPCODE_QCUR = 3, WLANTL_OPCODE_FWDBUF_QUEUECUR = 4, WLANTL_OPCODE_FWDBUF_DROPCUR = 5, WLANTL_OPCODE_FWDALL_DROPCUR = 6, WLANTL_OPCODE_FWDALL_QCUR = 7, WLANTL_OPCODE_TEARDOWN = 8, WLANTL_OPCODE_DROPCUR = 9, WLANTL_OPCODE_MAX }WLANTL_OpCodeEnumType; void WLANTL_InitBAReorderBuffer ( v_PVOID_t pvosGCtx ); /*========================================================================== FUNCTION WLANTL_BaSessionAdd DESCRIPTION HAL notifies TL when a new Block Ack session is being added. DEPENDENCIES A BA session on Rx needs to be added in TL before the response is being sent out PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to TL's control block can be extracted from its context ucSTAId: identifier of the station for which requested the BA session ucTid: Tspec ID for the new BA session uSize: size of the reordering window RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_INVAL: Input parameters are invalid VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to TL cb is NULL ; access would cause a page fault VOS_STATUS_E_EXISTS: Station was not registered or BA session already exists VOS_STATUS_E_NOSUPPORT: Not yet supported SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_BaSessionAdd ( v_PVOID_t pvosGCtx, v_U16_t sessionID, v_U32_t ucSTAId, v_U8_t ucTid, v_U32_t uBufferSize, v_U32_t winSize, v_U32_t SSN ); /*========================================================================== FUNCTION WLANTL_BaSessionDel DESCRIPTION HAL notifies TL when a new Block Ack session is being deleted. DEPENDENCIES PARAMETERS IN pvosGCtx: pointer to the global vos context; a handle to TL's control block can be extracted from its context ucSTAId: identifier of the station for which requested the BA session ucTid: Tspec ID for the new BA session RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_INVAL: Input parameters are invalid VOS_STATUS_E_FAULT: Station ID is outside array boundaries or pointer to TL cb is NULL ; access would cause a page fault VOS_STATUS_E_EXISTS: Station was not registered or BA session already exists VOS_STATUS_E_NOSUPPORT: Not yet supported SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_BaSessionDel ( v_PVOID_t pvosGCtx, v_U16_t ucSTAId, v_U8_t ucTid ); /*========================================================================== FUNCTION WLANTL_AMSDUProcess DESCRIPTION Process A-MSDU sub-frame. Start of chain if marked as first frame. Linked at the end of the existing AMSDU chain. DEPENDENCIES PARAMETERS IN/OUT: vosDataBuff: vos packet for the received data outgoing contains the root of the chain for the rx aggregated MSDU if the frame is marked as last; otherwise NULL IN pAdapter: pointer to the global adapter context; a handle to TL's control block can be extracted from its context pvBDHeader: pointer to the BD header ucSTAId: STAtion ID RETURN VALUE The result code associated with performing the operation SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_AMSDUProcess ( v_PVOID_t pvosGCtx, vos_pkt_t** ppVosDataBuff, v_PVOID_t pvBDHeader, v_U8_t ucSTAId, v_U8_t ucMPDUHLen, v_U16_t usMPDULen ); /*========================================================================== FUNCTION WLANTL_MSDUReorder DESCRIPTION MSDU reordering DEPENDENCIES PARAMETERS IN vosDataBuff: vos packet for the received data pvBDHeader: pointer to the BD header ucSTAId: STAtion ID RETURN VALUE The result code associated with performing the operation SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_MSDUReorder ( WLANTL_CbType *pTLCb, vos_pkt_t **vosDataBuff, v_PVOID_t pvBDHeader, v_U8_t ucSTAId, v_U8_t ucTid ); /*========================================================================== Utility functions ==========================================================================*/ /*========================================================================== FUNCTION WLANTL_AMSDUCompleteFrame DESCRIPTION Complete AMSDU de-aggregation DEPENDENCIES PARAMETERS IN/OUT: vosDataBuff: vos packet for the received data IN pvBDHeader: pointer to the BD header ucSTAId: STAtion ID RETURN VALUE The result code associated with performing the operation SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_AMSDUCompleteFrame ( vos_pkt_t* vosDataBuff, v_U8_t ucMPDUHLen, v_U16_t usMPDULen ); /*========================================================================== FUNCTION WLANTL_QueueCurrent DESCRIPTION It will queue a packet at a given slot index in the MSDU reordering list. DEPENDENCIES PARAMETERS IN pwBaReorder: pointer to the BA reordering session info vosDataBuff: data buffer to be queued ucSlotIndex: slot index RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_SUCCESS: Everything is OK SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_QueueCurrent ( WLANTL_BAReorderType* pwBaReorder, vos_pkt_t** vosDataBuff, v_U8_t ucSlotIndex ); /*========================================================================== FUNCTION WLANTL_ChainFrontPkts DESCRIPTION It will remove all the packets from the front of a vos list and chain them to a vos pkt . DEPENDENCIES PARAMETERS IN ucCount: number of packets to extract pwBaReorder: pointer to the BA reordering session info OUT vosDataBuff: data buffer containing the extracted chain of packets RETURN VALUE The result code associated with performing the operation VOS_STATUS_E_SUCCESS: Everything is OK SIDE EFFECTS ============================================================================*/ VOS_STATUS WLANTL_ChainFrontPkts ( v_U32_t fwdIndex, v_U8_t opCode, vos_pkt_t **vosDataBuff, WLANTL_BAReorderType *pwBaReorder, WLANTL_CbType *pTLCb ); #ifdef ANI_CHIPSET_VOLANS /*========================================================================== FUNCTION WLANTL_FillReplayCounter DESCRIPTION It will fill repaly counter at a given slot index in the MSDU reordering list. DEPENDENCIES PARAMETERS IN pwBaReorder : pointer to the BA reordering session info replayCounter: replay counter to be filled ucSlotIndex : slot index RETURN VALUE NONE SIDE EFFECTS NONE ============================================================================*/ void WLANTL_FillReplayCounter ( WLANTL_BAReorderType* pwBaReorder, v_U64_t replayCounter, v_U8_t ucSlotIndex ); #endif /*ANI_CHIPSET_VOLANS*/ #endif /* #ifndef WLAN_QCT_TLI_H */
edoko/Air_Kernel-Mako
drivers/staging/prima/CORE/TL/src/wlan_qct_tli_ba.h
C
gpl-2.0
12,133
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2262, 1011, 2286, 1010, 1996, 11603, 3192, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 3130, 7000, 2104, 1996, 2003, 2278, 6105, 2011, 24209, 2389, 9006, 2213, 2012, 5886, 2891, 1010, 4297, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#! /bin/bash defaults write com.apple.finder AppleShowAllFiles FALSE killall Finder
worp1900/niftySnippets
console/bash/mac/hideHiddenFilesInFinder.sh
Shell
mit
84
[ 30522, 1001, 999, 1013, 8026, 1013, 24234, 12398, 2015, 4339, 4012, 1012, 6207, 1012, 2424, 2121, 18108, 14406, 8095, 8873, 4244, 6270, 3102, 8095, 2424, 2121, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * VITacademics * Copyright (C) 2015 Aneesh Neelam <neelam.aneesh@gmail.com> * Copyright (C) 2015 Saurabh Joshi <saurabhjoshi94@outlook.com> * Copyright (C) 2015 Gaurav Agerwala <gauravagerwala@gmail.com> * Copyright (C) 2015 Karthik Balakrishnan <karthikb351@gmail.com> * Copyright (C) 2015 Pulkit Juneja <pulkit.16296@gmail.com> * Copyright (C) 2015 Hemant Jain <hemanham@gmail.com> * Copyright (C) 2015 Darshan Mehta <darshanmehta17@gmail.com> * * This file is part of VITacademics. * * VITacademics is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VITacademics is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VITacademics. If not, see <http://www.gnu.org/licenses/>. */ package com.karthikb351.vitinfo2.customwidget; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; import android.support.v4.content.ContextCompat; import android.util.AttributeSet; import android.view.View; import com.karthikb351.vitinfo2.R; public class TimeLineView extends View { public static final int STATE_FINISHED = 0X01; public static final int STATE_CURRENT = 0X02; public static final int STATE_SCHEDULED = 0X03; public static final int TYPE_INITIAL = 0x04; public static final int TYPE_INNER = 0x05; public static final int TYPE_END = 0x06; private float PADDING_TOP = 12; private float CIRCLE_RADIUS = 6; private float BORDER_THICKNESS = 4; private float STROKE_WIDTH_RING = 3.33f; private float STROKE_WIDTH_BORDER = 10; private float STROKE_WIDTH_LINE = 2; private int widgetState; private int widgetType; private Paint paintRing; private Paint paintDot; private Paint paintBorder; private Paint paintLine; private float cx; private float cy; private float height; private float width; private float density; private RectF rectF; private Path mPath; @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); width = getWidth(); height = getHeight(); cx = width / 2; cy = PADDING_TOP + CIRCLE_RADIUS; switch (widgetState){ case STATE_CURRENT: rectF.set(cx - BORDER_THICKNESS, cy - BORDER_THICKNESS, cx + BORDER_THICKNESS, cy + BORDER_THICKNESS); mPath.reset(); for (int i = 0; i <= 360; i++) { mPath.addArc(rectF, i, 1); } canvas.drawPath(mPath, paintBorder); case STATE_SCHEDULED: rectF.set(cx - CIRCLE_RADIUS, cy - CIRCLE_RADIUS, cx + CIRCLE_RADIUS, cy + CIRCLE_RADIUS); mPath.reset(); for (int i = 0; i <= 360; i += 1) { mPath.addArc(rectF, i, 1); } canvas.drawPath(mPath, paintRing); break; case STATE_FINISHED: canvas.drawCircle(cx, cy, CIRCLE_RADIUS, paintDot); break; } switch (widgetType){ case TYPE_INITIAL: canvas.drawLine(cx, cy + (11 * density), cx, height, paintLine); break; case TYPE_INNER: canvas.drawLine(cx, cy - (11 * density), cx, 0, paintLine); canvas.drawLine(cx, cy + (11 * density), cx, height, paintLine); break; case TYPE_END: canvas.drawLine(cx, cy - (11 * density), cx, 0, paintLine); break; } } private void initialize(){ density = getContext().getResources().getDisplayMetrics().density; PADDING_TOP *= density; BORDER_THICKNESS += CIRCLE_RADIUS; BORDER_THICKNESS *= density; CIRCLE_RADIUS *= density; STROKE_WIDTH_RING *= density; STROKE_WIDTH_BORDER *= density; STROKE_WIDTH_LINE *= density; paintDot = new Paint(); paintDot.setColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); paintDot.setFlags(Paint.ANTI_ALIAS_FLAG); paintRing = new Paint(); paintRing.setColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); paintRing.setFlags(Paint.ANTI_ALIAS_FLAG); paintRing.setStrokeWidth(STROKE_WIDTH_RING); paintRing.setStyle(Paint.Style.FILL_AND_STROKE); paintBorder = new Paint(); paintBorder.setColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); paintBorder.setAlpha(90); paintBorder.setFlags(Paint.ANTI_ALIAS_FLAG); paintBorder.setStrokeWidth(STROKE_WIDTH_BORDER); paintBorder.setStyle(Paint.Style.FILL_AND_STROKE); paintLine = new Paint(); paintLine.setColor(ContextCompat.getColor(getContext(), R.color.text_secondary)); paintLine.setAlpha(70); paintLine.setFlags(Paint.ANTI_ALIAS_FLAG); paintLine.setStrokeWidth(STROKE_WIDTH_LINE); paintLine.setStyle(Paint.Style.FILL_AND_STROKE); widgetState = STATE_SCHEDULED; widgetType = TYPE_INNER; rectF = new RectF(); mPath = new Path(); } public void setState(int state){ switch (state){ case STATE_CURRENT: widgetState = STATE_CURRENT; break; case STATE_SCHEDULED: widgetState = STATE_SCHEDULED; break; case STATE_FINISHED: widgetState = STATE_FINISHED; break; default: break; } invalidate(); } public void setType(int type){ switch (type){ case TYPE_INITIAL: widgetType = TYPE_INITIAL; break; case TYPE_INNER: widgetType = TYPE_INNER; break; case TYPE_END: widgetType = TYPE_END; break; default: break; } invalidate(); } public TimeLineView(Context context) { super(context); initialize(); } public TimeLineView(Context context, AttributeSet attrs) { super(context, attrs); initialize(); } }
saurabhsjoshi/VITacademics-for-Android
app/src/main/java/com/karthikb351/vitinfo2/customwidget/TimeLineView.java
Java
gpl-3.0
6,833
[ 30522, 1013, 1008, 1008, 19300, 21869, 22924, 1008, 9385, 1006, 1039, 1007, 2325, 2019, 10285, 2232, 7663, 10278, 1026, 7663, 10278, 1012, 2019, 10285, 2232, 1030, 20917, 4014, 1012, 4012, 1028, 1008, 9385, 1006, 1039, 1007, 2325, 7842, 464...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Communicator client code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /** Author: Eric D Vaughan **/ #ifndef nsGridRowGroupLayout_h___ #define nsGridRowGroupLayout_h___ #include "nsGridRowLayout.h" /** * The nsIBoxLayout implementation for nsGridRowGroupFrame. */ class nsGridRowGroupLayout : public nsGridRowLayout { public: friend already_AddRefed<nsIBoxLayout> NS_NewGridRowGroupLayout(); virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return this; } virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState); virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState); virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState); virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount); virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState); virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows); virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal); virtual PRInt32 GetRowCount() { return mRowCount; } virtual Type GetType() { return eRowGroup; } protected: nsGridRowGroupLayout(); virtual ~nsGridRowGroupLayout(); virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState); static void AddWidth(nsSize& aSize, nscoord aSize2, PRBool aIsHorizontal); private: nsGridRow* mRowColumn; PRInt32 mRowCount; }; #endif
akiellor/selenium
third_party/gecko-2/win32/include/nsGridRowGroupLayout.h
C
apache-2.0
3,136
[ 30522, 1013, 1008, 1011, 1008, 1011, 5549, 1024, 1039, 1009, 1009, 1025, 21628, 1011, 9381, 1024, 1016, 1025, 27427, 4765, 1011, 21628, 2015, 1011, 5549, 1024, 9152, 2140, 1025, 1039, 1011, 3937, 1011, 16396, 1024, 1016, 1011, 1008, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
## State Machine Sequences and Wave-forms This section provides additional explanation to particular functions of [API Functions](readme.md#functions) by presenting screenshots of state machine sequence diagrams and wave-forms. All wave-forms were taken during operation of application with DimSwitch library controlling OSRAM QUICKTRONIC - INTELLIGENT QTi DALI 2x28/54 DIM electronic ballast. ### Table of Contents * [Toggle Relay](#toggle-relay) * [Sequence](#toggle-relay-sequence) * [Wave-forms](#toggle-relay-wave-forms) * [Power On](#power-on) * [Sequence](#power-on-sequence) * [Wave-forms](#power-on-wave-forms) * [Power Off](#power-off) * [Sequence](#power-off-sequence) * [Wave-forms](#power-off-wave-forms) * [Calibrate](#calibrate) * [Sequence](#calibrate-sequence) * [Wave-forms](#calibrate-wave-forms) * [Set Intensity](#set-intensity) * [Sequence](#set-intensity-sequence) * [Wave-forms](#set-intensity-wave-forms) ### Toggle Relay #### Toggle Relay Sequence ![State Machine Sequence - Toggle Relay](pictures/sms-toggle-on.png) #### Toggle Relay Wave-forms ![Wave-forms - Toggle Relay](pictures/wvf-1-power-on.png) ### Power On #### Power On Sequence ![State Machine Sequence - Power On](pictures/sms-power-on.png) #### Power On Wave-forms ![Wave-forms - Power On](pictures/wvf-1-power-on.png) ### Power Off #### Power Off Sequence ![State Machine Sequence - Power Off](pictures/sms-power-off.png) #### Power Off Wave-forms ![Wave-forms - Power Off](pictures/wvf-2-power-off-max.png) ![Wave-forms - Power Off](pictures/wvf-3-power-off-min.png) ### Calibrate #### Calibrate Sequence ![State Machine Sequence - Calibrate](pictures/sms-calibrate.png) #### Calibrate Wave-forms ![Wave-forms - Calibrate](pictures/wvf-8-calibrate.png) ![Wave-forms - Calibrate](pictures/wvf-9-calibrate-another.png) ### Set Intensity #### Set Intensity Sequence ![State Machine Sequence - Set Intensity](pictures/sms-set-intensity.png) #### Set Intensity Wave-forms Sequence of setting light intensity depends on initial lamp state (if it is off or already on) and initial direction of intensity change. In later case if initial direction is opposite from desired, the relay is momentary toggled off to change it. See the following wave-forms that illustrate particular cases. Set the light intensity when the lamp is initially off (below). ![Wave-forms - Set Intensity](pictures/wvf-4-set-intensity-from-off.png) Set the light intensity when the lamp is already on (below). ![Wave-forms - Set Intensity](pictures/wvf-5-set-intensity-when-on.png) Set the light intensity with altering direction change (below). ![Wave-forms - Set Intensity](pictures/wvf-6-set-intensity-altering.png) Set the light intensity with altering direction change - another example (below). ![Wave-forms - Set Intensity](pictures/wvf-7-set-intensity-altering-another.png)
krzychb/DimSwitch
extras/sms-and-wvf.md
Markdown
lgpl-2.1
2,907
[ 30522, 1001, 1001, 2110, 3698, 10071, 1998, 4400, 1011, 3596, 2023, 2930, 3640, 3176, 7526, 2000, 3327, 4972, 1997, 1031, 17928, 4972, 1033, 1006, 3191, 4168, 1012, 9108, 1001, 4972, 1007, 2011, 10886, 12117, 12326, 2015, 1997, 2110, 3698, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Copyright 2012-2013 Greg Horn # # This file is part of rawesome. # # rawesome is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # rawesome 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 rawesome. If not, see <http://www.gnu.org/licenses/>. import numpy as np import time #from pylab import * import casadi as C import nmheMaps from ocputils import Constraints from newton import Newton from collocation import LagrangePoly class Nmhe(object): def __init__(self,dae,nk): self.dae = dae self.nk = nk self._gaussNewtonObjF = [] mapSize = len(self.dae.xNames())*(self.nk+1) + len(self.dae.pNames()) V = C.msym('dvs',mapSize) self._dvMap = nmheMaps.VectorizedReadOnlyNmheMap(self.dae,self.nk,V) self._boundMap = nmheMaps.WriteableNmheMap(self.dae,self.nk) self._guessMap = nmheMaps.WriteableNmheMap(self.dae,self.nk) self._U = C.msym('u',self.nk,len(self.dae.uNames())) self._outputMapGenerator = nmheMaps.NmheOutputMapGenerator(self,self._U) self._outputMap = nmheMaps.NmheOutputMap(self._outputMapGenerator, self._dvMap.vectorize(), self._U) self._constraints = Constraints() def __call__(self,*args,**kwargs): return self.lookup(*args,**kwargs) def lookup(self,name,timestep=None): try: return self._dvMap.lookup(name,timestep=timestep) except NameError: pass try: return self._outputMap.lookup(name,timestep) except NameError: pass raise NameError("unrecognized name \""+name+"\"") def bound(self,name,(lb,ub),timestep=None): self._boundMap.setVal(name,(lb,ub),timestep=timestep) def guess(self,name,val,timestep=None): self._guessMap.setVal(name,val,timestep=timestep) def constrain(self,lhs,comparison,rhs,tag=('unnamed_constraint',None)): self._constraints.add(lhs,comparison,rhs,tag) def setObj(self,obj): if hasattr(self,'_obj'): raise ValueError("don't change the objective function") self._obj = obj def addGaussNewtonObjF(self,gnF): self._gaussNewtonObjF.append(gnF) def _setupDynamicsConstraints(self,endTime,traj): # Todo: add parallelization # Todo: get endTime right g = [] nicp = 1 deg = 4 p = self._dvMap.pVec() for k in range(self.nk): newton = Newton(LagrangePoly,self.dae,1,nicp,deg,'RADAU') newton.setupStuff(endTime) X0_i = self._dvMap.xVec(k) U_i = self._U[k,:].T # guess if traj is None: newton.isolver.setOutput(1,0) else: X = C.DMatrix([[traj.lookup(name,timestep=k,degIdx=j) for j in range(1,traj.dvMap._deg+1)] \ for name in traj.dvMap._xNames]) Z = C.DMatrix([[traj.lookup(name,timestep=k,degIdx=j) for j in range(1,traj.dvMap._deg+1)] \ for name in traj.dvMap._zNames]) newton.isolver.setOutput(C.veccat([X,Z]),0) _, Xf_i = newton.isolver.call([X0_i,U_i,p]) X0_i_plus = self._dvMap.xVec(k+1) g.append(Xf_i-X0_i_plus) return g def makeSolver(self,endTime,traj=None): # make sure all bounds are set (xMissing,pMissing) = self._boundMap.getMissing() msg = [] for name in xMissing: msg.append("you forgot to set a bound on \""+name+"\" at timesteps: "+str(xMissing[name])) for name in pMissing: msg.append("you forgot to set a bound on \""+name+"\"") if len(msg)>0: raise ValueError('\n'.join(msg)) # constraints: g = self._constraints.getG() glb = self._constraints.getLb() gub = self._constraints.getUb() gDyn = self._setupDynamicsConstraints(endTime,traj) gDynLb = gDynUb = [C.DMatrix.zeros(gg.shape) for gg in gDyn] g = C.veccat([g]+gDyn) glb = C.veccat([glb]+gDynLb) gub = C.veccat([gub]+gDynUb) self.glb = glb self.gub = gub # design vars V = self._dvMap.vectorize() # gradient of arbitraryObj if hasattr(self,'_obj'): arbitraryObj = self._obj else: arbitraryObj = 0 gradF = C.gradient(arbitraryObj,V) # hessian of lagrangian: Js = [C.jacobian(gnf,V) for gnf in self._gaussNewtonObjF] gradFgns = [C.mul(J.T,F) for (F,J) in zip(self._gaussNewtonObjF, Js)] gaussNewtonHess = sum([C.mul(J.T,J) for J in Js]) hessL = gaussNewtonHess + C.jacobian(gradF,V) gradF += sum(gradFgns) # equality/inequality constraint jacobian gfcn = C.MXFunction([V,self._U],[g]) gfcn.init() jacobG = gfcn.jacobian(0,0) jacobG.init() # function which generates everything needed f = sum([f_*f_ for f_ in self._gaussNewtonObjF]) if hasattr(self,'_obj'): f += self._obj self.masterFun = C.MXFunction([V,self._U],[hessL, gradF, g, jacobG.call([V,self._U])[0], f]) self.masterFun.init() # self.qp = C.CplexSolver(hessL.sparsity(),jacobG.output(0).sparsity()) self.qp = C.NLPQPSolver(hessL.sparsity(),jacobG.output(0).sparsity()) self.qp.setOption('nlp_solver',C.IpoptSolver) self.qp.setOption('nlp_solver_options',{'print_level':0,'print_time':False}) self.qp.init() def runSolver(self,U,trajTrue=None): # make sure all bounds are set (xMissing,pMissing) = self._guessMap.getMissing() msg = [] for name in xMissing: msg.append("you forgot to set a guess for \""+name+"\" at timesteps: "+str(xMissing[name])) for name in pMissing: msg.append("you forgot to set a guess for \""+name+"\"") if len(msg)>0: raise ValueError('\n'.join(msg)) lbx,ubx = zip(*(self._boundMap.vectorize())) xk = C.DMatrix(list(self._guessMap.vectorize())) for k in range(100): ############# plot stuff ############### print "iteration: ",k # import nmheMaps # xOpt = np.array(xk).squeeze() # traj = nmheMaps.VectorizedReadOnlyNmheMap(self.dae,self.nk,xOpt) # # xsT = np.array([trajTrue.lookup('x',timestep=kk) for kk in range(self.nk+1)] ) # ysT = np.array([trajTrue.lookup('y',timestep=kk) for kk in range(self.nk+1)] ) # zsT = np.array([trajTrue.lookup('z',timestep=kk) for kk in range(self.nk+1)] ) # # xs = np.array([traj.lookup('x',timestep=kk) for kk in range(self.nk+1)] ) # ys = np.array([traj.lookup('y',timestep=kk) for kk in range(self.nk+1)] ) # zs = np.array([traj.lookup('z',timestep=kk) for kk in range(self.nk+1)] ) # # outputMap = nmheMaps.NmheOutputMap(self._outputMapGenerator, xOpt, U) # c = np.array([outputMap.lookup('c',timestep=kk) for kk in range(self.nk)]) # cdot = np.array([outputMap.lookup('cdot',timestep=kk) for kk in range(self.nk)]) # # figure() # title(str(float(k))) # subplot(3,2,1) # plot(xs) # plot(xsT) # ylabel('x '+str(k)) # # subplot(3,2,3) # plot(ys) # plot(ysT) # ylabel('y '+str(k)) # # subplot(3,2,5) # plot(zs) # plot(zsT) # ylabel('z '+str(k)) # ## subplot(2,2,2) ## plot(dxs,-dzs) ## ylabel('vel') ## axis('equal') # # subplot(3,2,2) # plot(c) # ylabel('c') # # subplot(3,2,4) # plot(cdot) # ylabel('cdot') # ########################################## self.masterFun.setInput(xk,0) self.masterFun.setInput(U,1) t0 = time.time() try: self.masterFun.evaluate() except RuntimeError as e: print "ERRRRRRRRRRRRROR" show() raise e t1 = time.time() masterFunTime = (t1-t0)*1000 hessL = self.masterFun.output(0) gradF = self.masterFun.output(1) g = self.masterFun.output(2) jacobG = self.masterFun.output(3) f = self.masterFun.output(4) self.qp.setInput(0, C.QP_X_INIT) self.qp.setInput(hessL, C.QP_H) self.qp.setInput(jacobG, C.QP_A) self.qp.setInput(gradF, C.QP_G) assert all((lbx-xk) <= 0), "lower bounds violation" assert all((ubx-xk) >= 0), "upper bounds violation" self.qp.setInput(lbx-xk,C.QP_LBX) self.qp.setInput(ubx-xk,C.QP_UBX) self.qp.setInput(self.glb-g, C.QP_LBA) self.qp.setInput(self.gub-g, C.QP_UBA) t0 = time.time() self.qp.evaluate() t1 = time.time() # print "gradF: ",gradF # print 'dim(jacobG): "gra # print "rank: ",np.linalg.matrix_rank(jacobG) print "masterFun delta time: %.3f ms" % masterFunTime print "f: ",f,'\tmax constraint: ',max(C.fabs(g)) print "qp delta time: %.3f ms" % ((t1-t0)*1000) print "" deltaX = self.qp.output(C.QP_PRIMAL) # import scipy.io # scipy.io.savemat('hessL.mat',{'hessL':np.array(hessL), # 'gradF':np.array(gradF), # 'x0':0*np.array(deltaX), # 'xopt':np.array(deltaX), # 'lbx':np.array(lbx-xk), # 'ubx':np.array(ubx-xk), # 'jacobG':np.array(jacobG), # 'lba':np.array(self.glb-g), # 'uba':np.array(self.gub-g)}) # import sys; sys.exit() # print deltaX xk += deltaX # show()
ghorn/rawesome
rawe/newton/nmhe.py
Python
lgpl-3.0
10,700
[ 30522, 1001, 9385, 2262, 1011, 2286, 6754, 7109, 1001, 1001, 2023, 5371, 2003, 2112, 1997, 6315, 2229, 8462, 1012, 1001, 1001, 6315, 2229, 8462, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 199...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. module AWS module Core class PageResult < Array # @return [Collection] Returns the collection that was used to # populated this page of results. attr_reader :collection # @return [Integer] Returns the maximum number of results per page. # The final page in a collection may return fewer than +:per_page+ # items (e.g. +:per_page+ is 10 and there are only 7 items). attr_reader :per_page # @return [String] An opaque token that can be passed the #page method # of the collection that returned this page of results. This next # token behaves as a pseudo offset. If +next_token+ is +nil+ then # there are no more results for the collection. attr_reader :next_token # @param [Collection] collection The collection that was used to # request this page of results. The collection should respond to # #page and accept a :next_token option. # # @param [Array] items An array of result items that represent a # page of results. # # @param [Integer] per_page The number of requested items for this # page of results. If the count of items is smaller than +per_page+ # then this is the last page of results. # # @param [String] next_token (nil) A token that can be passed to the # def initialize collection, items, per_page, next_token @collection = collection @per_page = per_page @next_token = next_token super(items) end # @return [PageResult] # @raise [RuntimeError] Raises a runtime error when called against # a collection that has no more results (i.e. #last_page? == true). def next_page if last_page? raise 'unable to get the next page, already at the last page' end collection.page(:per_page => per_page, :next_token => next_token) end # @return [Boolean] Returns +true+ if this is the last page of results. def last_page? next_token.nil? end # @return [Boolean] Returns +true+ if there are more pages of results. def more? !!next_token end end end end
usmschuck/canvas
vendor/bundle/ruby/1.9.1/gems/aws-sdk-1.8.3.1/lib/aws/core/page_result.rb
Ruby
agpl-3.0
2,790
[ 30522, 1001, 9385, 2249, 1011, 2286, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1001, 1001, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1012, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import Social from './Social' export default Social
luisma1989/portfolio-react
src/components/Social/index.js
JavaScript
mit
53
[ 30522, 12324, 2591, 2013, 1005, 1012, 1013, 2591, 1005, 9167, 12398, 2591, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.fordprog.matrix.interpreter.type; public enum Type { RATIONAL, MATRIX, FUNCTION, VOID }
daergoth/MatrixC
src/main/java/com/fordprog/matrix/interpreter/type/Type.java
Java
apache-2.0
115
[ 30522, 7427, 4012, 1012, 4811, 21572, 2290, 1012, 8185, 1012, 19555, 1012, 2828, 1025, 2270, 4372, 2819, 2828, 1063, 11581, 1010, 8185, 1010, 3853, 1010, 11675, 1065, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * CakePHP Tags Plugin * * Copyright 2009 - 2010, Cake Development Corporation * 1785 E. Sahara Avenue, Suite 490-423 * Las Vegas, Nevada 89104 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @copyright 2009 - 2010, Cake Development Corporation (http://cakedc.com) * @link http://github.com/CakeDC/Tags * @package plugins.tags * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ $map = array( 1 => array( '001_initialize_tags_schema' => 'M49ac311a54844a9d87o822502jedc423'), 2 => array( '002_create_times_tagged_field' => 'M4c0d42bcd12c4db099c105f40e8f3d6d'), 3 => array( '003_occurrence_fields_for_tags' => 'M8d01880f01c11e0be500800200c9a66'), ); ?>
steinkel/tags
Config/Migration/map.php
PHP
mit
823
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 9850, 8458, 2361, 22073, 13354, 2378, 1008, 1008, 9385, 2268, 1011, 2230, 1010, 9850, 2458, 3840, 1008, 17262, 1041, 1012, 19604, 3927, 1010, 7621, 22288, 1011, 4413, 2509, 1008, 5869, 7136,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
opt.coef_L2 = 1e-5 opt.use_cosine = false model_name = 'l2_interaction_direct' obj['corr'] = true obj['pos'] = true obj['neg'] = true
germank/compatibility-naacl2015
model/torch/run_configs/conf_05.lua
Lua
mit
134
[ 30522, 23569, 1012, 24873, 2546, 1035, 1048, 2475, 1027, 1015, 2063, 1011, 1019, 23569, 1012, 2224, 1035, 2522, 11493, 2063, 1027, 6270, 2944, 1035, 2171, 1027, 1005, 1048, 2475, 1035, 8290, 1035, 3622, 1005, 27885, 3501, 1031, 1005, 2522, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Sensio\Bundle\GeneratorBundle\Tests\Generator; use Sensio\Bundle\GeneratorBundle\Generator\CommandGenerator; class CommandGeneratorTest extends GeneratorTest { public function testGenerateController() { $commandName = 'app:foo-bar'; $commandFile = 'Command/AppFooBarCommand.php'; $commandPath = $this->tmpDir.'/'.$commandFile; $this->getGenerator()->generate($this->getBundle(), $commandName); $this->assertTrue(file_exists($commandPath), sprintf('%s file has been generated.', $commandFile)); $commandContent = file_get_contents($commandPath); $strings = array( 'namespace Foo\\BarBundle\\Command', 'class AppFooBarCommand extends ContainerAwareCommand', sprintf("->setName('%s')", $commandName), ); foreach ($strings as $string) { $this->assertContains($string, $commandContent); } } /** * @dataProvider getNames */ public function testClassify($commandName, $className) { $generator = $this->getGenerator(); $this->assertEquals($className, $generator->classify($commandName)); } public function getNames() { return array( array('app', 'App'), array('app-foo', 'AppFoo'), array('app_foo', 'AppFoo'), array('app:foo-bar', 'AppFooBar'), array('app:foo:bar', 'AppFooBar'), array('app:foo:bar-baz', 'AppFooBarBaz'), array('app:foo:bar_baz', 'AppFooBarBaz'), array('app-foo:bar-baz:foo-bar', 'AppFooBarBazFooBar'), ); } protected function getGenerator() { $generator = new CommandGenerator($this->filesystem); $generator->setSkeletonDirs(__DIR__.'/../../Resources/skeleton'); return $generator; } protected function getBundle() { <<<<<<< HEAD $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); ======= $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface'); >>>>>>> master $bundle->expects($this->any())->method('getPath')->will($this->returnValue($this->tmpDir)); $bundle->expects($this->any())->method('getName')->will($this->returnValue('FooBarBundle')); $bundle->expects($this->any())->method('getNamespace')->will($this->returnValue('Foo\BarBundle')); return $bundle; } }
HeySoftware/ServiQS
vendor/sensio/generator-bundle/Tests/Generator/CommandGeneratorTest.php
PHP
gpl-3.0
2,708
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 25353, 2213, 14876, 4890, 7427, 1012, 1008, 1008, 1006, 1039, 1007, 6904, 11283, 2078, 8962, 2368, 19562, 1026, 6904, 11283, 2078, 30524, 13103, 1025, 2224, 124...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2000-2009 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.intellij.util.ui; import javax.swing.*; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.util.TreeMap; public class GeometryUtil implements SwingConstants { private static final int myArrowSize = 9; private static final Shape myArrowPolygon = new Polygon(new int[] {0, myArrowSize, 0, 0}, new int[] {0, myArrowSize /2, myArrowSize, 0}, 4); public static Point getIntersectionPoint(Line2D aSegment, Rectangle aRectangle) { if (segmentOutsideRectangle(aRectangle, aSegment)) { throw new IllegalArgumentException("Segment " + toString(aSegment) + " lies out of rectangle " + aRectangle + " or intersects more than one bound"); } if (segmentInsideRectangle(aRectangle, aSegment)) { return null; } Line2D[] bounds = new Line2D[4]; bounds[0] = getTopOf(aRectangle); bounds[1] = getRightOf(aRectangle); bounds[2] = getBottomOf(aRectangle); bounds[3] = getLeftOf(aRectangle); for (Line2D bound : bounds) { if (bound.intersectsLine(aSegment)) { return getIntersectionPoint(aSegment, bound); } } return null; } public static Line2D.Double getLeftOf(Rectangle aRectangle) { return new Line2D.Double(aRectangle.getX(), aRectangle.getY(), aRectangle.getX(), aRectangle.getY() + aRectangle.getHeight()); } public static Line2D.Double getBottomOf(Rectangle aRectangle) { return new Line2D.Double(aRectangle.getX(), aRectangle.getY() + aRectangle.getHeight(), aRectangle.getX() + aRectangle.getWidth(), aRectangle.getY() + aRectangle.getHeight()); } public static Line2D.Double getRightOf(Rectangle aRectangle) { return new Line2D.Double(aRectangle.getX() + aRectangle.getWidth(), aRectangle.getY(), aRectangle.getX() + aRectangle.getWidth(), aRectangle.getY() + aRectangle.getHeight()); } public static Line2D.Double getTopOf(Rectangle aRectangle) { return new Line2D.Double(aRectangle.getX(), aRectangle.getY(), aRectangle.getX() + aRectangle.getWidth(), aRectangle.getY()); } private static boolean segmentInsideRectangle(Rectangle aRectangle, Line2D aSegment) { return isWithin(aRectangle, aSegment.getP1()) && isWithin(aRectangle, aSegment.getP2()); } private static boolean segmentOutsideRectangle(Rectangle aRectangle, Line2D aSegment) { return (!isWithin(aRectangle, aSegment.getP1())) && (!isWithin(aRectangle, aSegment.getP2())); } public static boolean isWithin(Rectangle aRectangle, Point2D aPoint) { return (aPoint.getX() > aRectangle.getX()) && (aPoint.getX() < aRectangle.getX() + aRectangle.getBounds().width) && ((aPoint.getY() > aRectangle.getY()) && (aPoint.getY() < aRectangle.getY() + aRectangle.getBounds().height)); } public static Point getIntersectionPoint(Line2D aFirst, Line2D aSecond) { double firstDeltaX = aFirst.getX2() - aFirst.getX1(); double firstDeltaY = aFirst.getY2() - aFirst.getY1(); double kFirst = firstDeltaY / firstDeltaX; double bFirst = aFirst.getY1() - kFirst * aFirst.getX1(); double secondDeltaX = aSecond.getX2() - aSecond.getX1(); double secondDeltaY = aSecond.getY2() - aSecond.getY1(); double kSecond = secondDeltaY / secondDeltaX; double bSecond = aSecond.getY1() - kSecond * aSecond.getX1(); double xIntersection; double yIntersection; double deltaK = (kFirst - kSecond); if (linesAreAngledAndParallel(kFirst, kSecond)) { return null; } if (Double.isInfinite(deltaK) || (0 == deltaK)) { if (firstDeltaX == secondDeltaX && 0 == firstDeltaX) { return null; } if (firstDeltaY == secondDeltaY && 0 == firstDeltaY) { return null; } if ((0 == firstDeltaX) && (0 == secondDeltaY)) { xIntersection = aFirst.getX1(); yIntersection = aSecond.getY1(); } else if ((0 == secondDeltaX) && (0 == firstDeltaY)) { xIntersection = aSecond.getX1(); yIntersection = aFirst.getY1(); } else { if (0 == firstDeltaX) { xIntersection = aFirst.getX1(); yIntersection = kSecond * xIntersection + bSecond; } else { xIntersection = aSecond.getX1(); yIntersection = kFirst * xIntersection + bFirst; } } } else { xIntersection = (bSecond - bFirst) / deltaK; yIntersection = kFirst * xIntersection + bFirst; } return new Point((int) xIntersection, (int) yIntersection); } private static boolean linesAreAngledAndParallel(double aKFirst, double aKSecond) { return (aKFirst == aKSecond) && (0 != aKFirst); } public static String toString(Line2D aLine) { return aLine.getP1() + ":" + aLine.getP2(); } public static boolean intersects(Rectangle aRectangle, Line2D aLine) { if (aLine == null || aRectangle == null) { return false; } return (!segmentOutsideRectangle(aRectangle, aLine)) && (!segmentInsideRectangle(aRectangle, aLine)); } public static int getPointPositionOnRectangle(Rectangle aRectangle, Point aPoint, int aEpsilon) { final int ERROR_CODE = Integer.MIN_VALUE; if (pointOnBound(getTopOf(aRectangle), aPoint, aEpsilon)) { return TOP; } else if (pointOnBound(getBottomOf(aRectangle), aPoint, aEpsilon)) { return BOTTOM; } else if (pointOnBound(getLeftOf(aRectangle), aPoint, aEpsilon)) { return LEFT; } else if (pointOnBound(getRightOf(aRectangle), aPoint, aEpsilon)) { return RIGHT; } else { return ERROR_CODE; } } private static boolean pointOnBound(Line2D aTop, Point aPoint, int aEpsilon) { return withinRange(aTop.getX1(), aTop.getX2(), aPoint.getX(), aEpsilon) && withinRange(aTop.getY1(), aTop.getY2(), aPoint.getY(), aEpsilon); } private static boolean withinRange(double aLeft, double aRight, double aValue, int aEpsilon) { return ((aLeft - aEpsilon) <= aValue) && ((aRight + aEpsilon) >= aValue); } // public static Point shiftByY(Line2D aLine, Point aPoint, int aPointDeltaY) { // return new Point((int) (aPoint.getX() + getShiftByY(aLine, aPointDeltaY)), (int) (aPoint.getY() + aPointDeltaY)); // } // // public static Point shiftByX(Line2D aLine, Point aPoint, int aPointDeltaX) { // return new Point((int) (aPoint.getX() + aPointDeltaX), (int) (aPoint.getY() + getShiftByX(aLine, aPointDeltaX))); // } public static double getShiftByY(Line2D aLine, double aPointDeltaY) { return aPointDeltaY * ((aLine.getX2() - aLine.getX1()) / (aLine.getY2() - aLine.getY1())); } public static double getShiftByX(Line2D aLine, double aPointDeltaX) { double width = aLine.getX2() - aLine.getX1(); double height = aLine.getY2() - aLine.getY1(); return aPointDeltaX * (height / width); } public static Shape getArrowShape(Line2D line, Point2D intersectionPoint) { final double deltaY = line.getP2().getY() - line.getP1().getY(); final double length = Math.sqrt(Math.pow(deltaY, 2) + Math.pow(line.getP2().getX() - line.getP1().getX(), 2)); double theta = Math.asin(deltaY / length); if (line.getP1().getX() > line.getP2().getX()) { theta = Math.PI - theta; } AffineTransform rotate = AffineTransform.getRotateInstance(theta, myArrowSize, myArrowSize / 2); Shape polygon = rotate.createTransformedShape(myArrowPolygon); AffineTransform move = AffineTransform.getTranslateInstance(intersectionPoint.getX() - myArrowSize, intersectionPoint.getY() - myArrowSize /2); polygon = move.createTransformedShape(polygon); return polygon; } private static class OrientedPoint extends Point { private final int myOrientation; OrientedPoint(double x, double y, int aOrientation) { super((int) x, (int) y); myOrientation = aOrientation; } public int getOrientation() { return myOrientation; } } public static int getClosestToLineRectangleCorner(Rectangle aRectangle, Line2D aSegment) { Point northWest = new OrientedPoint(aRectangle.getX(), aRectangle.getY(), NORTH_WEST); Point northEast = new OrientedPoint(aRectangle.getMaxX(), aRectangle.getY(), NORTH_EAST); Point southEast = new OrientedPoint(aRectangle.getMaxX(), aRectangle.getMaxY(), SOUTH_EAST); Point southWest = new OrientedPoint(aRectangle.getX(), aRectangle.getMaxY(), SOUTH_WEST); TreeMap sorter = new TreeMap(); sorter.put(getDistance(aSegment, northWest), northWest); sorter.put(getDistance(aSegment, southWest), southWest); sorter.put(getDistance(aSegment, southEast), southEast); sorter.put(getDistance(aSegment, northEast), northEast); return ((OrientedPoint) sorter.get(sorter.firstKey())).getOrientation(); } private static Double getDistance(Line2D aSegment, Point aPoint) { double length1 = getLineLength(aSegment.getX1(), aSegment.getY1(), aPoint.getX(), aPoint.getY()); double length2 = getLineLength(aSegment.getX2(), aSegment.getY2(), aPoint.getX(), aPoint.getY()); return new Double(length1 + length2); } public static double getLineLength(double aX1, double aY1, double aX2, double aY2) { double deltaX = aX2 - aX1; double deltaY = aY2 - aY1; return Math.hypot(deltaX, deltaY); } public static double cos(Line2D aLine) { final double length = getLineLength(aLine.getX1(), aLine.getY1(), aLine.getX2(), aLine.getY2()); if (length == 0) { throw new IllegalArgumentException(toString(aLine) + " has a zero length"); } double deltaX = aLine.getX2() - aLine.getX1(); return deltaX / length; } public static double sin(Line2D aLine) { final double length = getLineLength(aLine.getX1(), aLine.getY1(), aLine.getX2(), aLine.getY2()); if (length == 0) { throw new IllegalArgumentException(toString(aLine) + " has a zero length"); } double deltaY = aLine.getY2() - aLine.getY1(); return deltaY / length; } }
paplorinc/intellij-community
platform/util/src/com/intellij/util/ui/GeometryUtil.java
Java
apache-2.0
10,570
[ 30522, 1013, 1008, 1008, 9385, 2456, 1011, 2268, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Authorization ============= Authorization is the process of verifying that user has enough permissions to do something. Yii provides several methods of controlling it. Access control basics --------------------- Basic access control is very simple to implement using [[\yii\web\AccessControl]]: ```php class SiteController extends Controller { public function behaviors() { return [ 'access' => [ 'class' => \yii\web\AccessControl::className(), 'only' => ['login', 'logout', 'signup'], 'rules' => [ [ 'actions' => ['login', 'signup'], 'allow' => true, 'roles' => ['?'], ], [ 'actions' => ['logout'], 'allow' => true, 'roles' => ['@'], ], ], ], ]; } // ... ``` In the code above we're attaching access control behavior to a controller. Since there's `only` option specified, it will be applied to 'login', 'logout' and 'signup' actions only. A set of rules that are basically options for [[\yii\web\AccessRule]] reads as follows: - Allow all guest (not yet authenticated) users to access 'login' and 'signup' actions. - Allow authenticated users to access 'logout' action. Rules are checked one by one from top to bottom. If rule matches, action takes place immediately. If not, next rule is checked. If no rules matched access is denied. [[\yii\web\AccessRule]] is quite flexible and allows additionally to what was demonstrated checking IPs and request method (i.e. POST, GET). If it's not enough you can specify your own check via anonymous function: ```php class SiteController extends Controller { public function behaviors() { return [ 'access' => [ 'class' => \yii\web\AccessControl::className(), 'only' => ['special-callback'], 'rules' => [ [ 'actions' => ['special-callback'], 'allow' => true, 'matchCallback' => function ($rule, $action) { return date('d-m') === '31-10'; } ], ``` And the action: ```php // ... // Match callback called! This page can be accessed only each October 31st public function actionSpecialCallback() { return $this->render('happy-halloween'); } ``` Sometimes you want a custom action to be taken when access is denied. In this case you can specify `denyCallback`. Role based access control (RBAC) -------------------------------- Role based access control is very flexible approach to controlling access that is a perfect match for complex systems where permissions are customizable. ### Using file-based config for RBAC In order to start using it some extra steps are required. First of all we need to configure `authManager` application component in application config file (`web.php` or `main.php` depending on template you've used): ```php 'authManager' => [ 'class' => 'app\components\PhpManager', 'defaultRoles' => ['guest'], ], ``` Often use role is stored in the same database table as other user data. In this case we may defined it by creating our own component (`app/components/PhpManager.php`): ```php <?php namespace app\components; use Yii; class PhpManager extends \yii\rbac\PhpManager { public function init() { parent::init(); if (!Yii::$app->user->isGuest) { // we suppose that user's role is stored in identity $this->assign(Yii::$app->user->identity->id, Yii::$app->user->identity->role); } } } ``` Then create permissions hierarchy in `@app/data/rbac.php`: ```php <?php use yii\rbac\Item; return [ // HERE ARE YOUR MANAGEMENT TASKS 'manageThing0' => ['type' => Item::TYPE_OPERATION, 'description' => '...', 'bizRule' => NULL, 'data' => NULL], 'manageThing1' => ['type' => Item::TYPE_OPERATION, 'description' => '...', 'bizRule' => NULL, 'data' => NULL], 'manageThing2' => ['type' => Item::TYPE_OPERATION, 'description' => '...', 'bizRule' => NULL, 'data' => NULL], 'manageThing2' => ['type' => Item::TYPE_OPERATION, 'description' => '...', 'bizRule' => NULL, 'data' => NULL], // AND THE ROLES 'guest' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Guest', 'bizRule' => NULL, 'data' => NULL ], 'user' => [ 'type' => Item::TYPE_ROLE, 'description' => 'User', 'children' => [ 'guest', 'manageThing0', // User can edit thing0 ], 'bizRule' => 'return !Yii::$app->user->isGuest;', 'data' => NULL ], 'moderator' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Moderator', 'children' => [ 'user', // Can manage all that user can 'manageThing1', // and also thing1 ], 'bizRule' => NULL, 'data' => NULL ], 'admin' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Admin', 'children' => [ 'moderator', // can do all the stuff that moderator can 'manageThing2', // and also manage thing2 ], 'bizRule' => NULL, 'data' => NULL ], 'godmode' => [ 'type' => Item::TYPE_ROLE, 'description' => 'Super admin', 'children' => [ 'admin', // can do all that admin can 'manageThing3', // and also thing3 ], 'bizRule' => NULL, 'data' => NULL ], ]; ``` Now you can specify roles from RBAC in controller's access control configuration: ```php public function behaviors() { return [ 'access' => [ 'class' => 'yii\web\AccessControl', 'except' => ['something'], 'rules' => [ [ 'allow' => true, 'roles' => ['manageThing1'], ], ], ], ]; } ``` Another way is to call [[yii\web\User::checkAccess()]] where appropriate. ### Using DB-based storage for RBAC Storing RBAC hierarchy in database is less efficient performancewise but is much more flexible. It is easier to create a good management UI for it so in case you need permissions structure that is managed by end user DB is your choice. In order to get started you need to configure database connection in `db` component. After it is done [get `schema-*.sql` file for your database](https://github.com/yiisoft/yii2/tree/master/framework/rbac) and execute it. Next step is to configure `authManager` application component in application config file (`web.php` or `main.php` depending on template you've used): ```php 'authManager' => [ 'class' => 'yii\rbac\DbManager', 'defaultRoles' => ['guest'], ], ``` TBD ### How it works TBD: write about how it works with pictures :) ### Avoiding too much RBAC In order to keep auth hierarchy simple and efficient you should avoid creating and using too much nodes. Most of the time simple checks could be used instead. For example such code that uses RBAC: ```php public function editArticle($id) { $article = Article::find($id); if (!$article) { throw new NotFoundHttpException; } if (!\Yii::$app->user->checkAccess('edit_article', ['article' => $article])) { throw new ForbiddenHttpException; } // ... } ``` can be replaced with simpler code that doesn't use RBAC: ```php public function editArticle($id) { $article = Article::find(['id' => $id, 'author_id' => \Yii::$app->user->id]); if (!$article) { throw new NotFoundHttpException; } // ... } ```
vipxieliang/yii2
docs/guide/authorization.md
Markdown
bsd-3-clause
7,434
[ 30522, 20104, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 20104, 2003, 1996, 2832, 1997, 20410, 2075, 2008, 5310, 2038, 2438, 6656, 2015, 2000, 2079, 2242, 1012, 12316, 2072, 3640, 2195, 4725, 1997, 9756, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package hr.fer.zemris.jcms.caching.impl; import hr.fer.zemris.jcms.JCMSSettings; import hr.fer.zemris.jcms.beans.cached.CourseScoreTable; import hr.fer.zemris.jcms.beans.cached.Dependencies; import hr.fer.zemris.jcms.caching.IJCMSCache; import java.io.File; import java.io.IOException; import java.util.Properties; import com.opensymphony.oscache.base.NeedsRefreshException; import com.opensymphony.oscache.general.GeneralCacheAdministrator; public class JCMSCacheOSImpl implements IJCMSCache { private GeneralCacheAdministrator gcaScoreTable; private GeneralCacheAdministrator gcaDependencies; public JCMSCacheOSImpl(Properties p) { gcaScoreTable = new GeneralCacheAdministrator(p); gcaDependencies = new GeneralCacheAdministrator(p); } public JCMSCacheOSImpl() throws IOException { File rootDir = JCMSSettings.getSettings().getRootDir(); File cacheDir = new File(rootDir,"jcms-oscache"); cacheDir.mkdir(); createCacheScoreTable(cacheDir); createCacheDependencies(cacheDir); } private void createCacheScoreTable(File cacheDir) throws IOException { File cacheDir1 = new File(cacheDir,"scoreTables"); cacheDir1.mkdir(); Properties p = new Properties(); p.setProperty("cache.memory", "true"); p.setProperty("cache.persistence.class", "com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener"); p.setProperty("cache.path", cacheDir1.getCanonicalPath()); p.setProperty("cache.persistence.overflow.only", "false"); p.setProperty("cache.algorithm", "com.opensymphony.oscache.base.algorithm.LRUCache"); p.setProperty("cache.blocking", "false"); p.setProperty("cache.capacity", "2"); p.setProperty("cache.unlimited.disk", "true"); gcaScoreTable = new GeneralCacheAdministrator(p); } private void createCacheDependencies(File cacheDir) throws IOException { File cacheDir1 = new File(cacheDir,"dependencies"); cacheDir1.mkdir(); Properties p = new Properties(); p.setProperty("cache.memory", "true"); p.setProperty("cache.persistence.class", "com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener"); p.setProperty("cache.path", cacheDir1.getCanonicalPath()); p.setProperty("cache.persistence.overflow.only", "false"); p.setProperty("cache.algorithm", "com.opensymphony.oscache.base.algorithm.LRUCache"); p.setProperty("cache.blocking", "false"); p.setProperty("cache.capacity", "100"); p.setProperty("cache.unlimited.disk", "true"); gcaDependencies = new GeneralCacheAdministrator(p); } @Override public CourseScoreTable getCourseScoreTable(String courseInstanceID) { String key = "CST:"+courseInstanceID; CourseScoreTable table; try { table = (CourseScoreTable)gcaScoreTable.getFromCache(key); } catch (NeedsRefreshException e) { table = (CourseScoreTable)e.getCacheContent(); gcaScoreTable.cancelUpdate(key); } return table; } @Override public void put(CourseScoreTable table) { gcaScoreTable.putInCache("CST:"+table.getCourseInstanceID(), table); } @Override public Dependencies getDependencies(String courseInstanceID) { String key = "DEP:"+courseInstanceID; Dependencies dep; try { dep = (Dependencies)gcaDependencies.getFromCache(key); } catch (NeedsRefreshException e) { dep = (Dependencies)e.getCacheContent(); gcaDependencies.cancelUpdate(key); } return dep; } @Override public void put(Dependencies dependencies) { gcaDependencies.putInCache("DEP:"+dependencies.getCourseInstanceID(), dependencies); } }
KarloKnezevic/Ferko
src/java/hr/fer/zemris/jcms/caching/impl/JCMSCacheOSImpl.java
Java
apache-2.0
3,489
[ 30522, 7427, 17850, 1012, 10768, 2099, 1012, 27838, 2213, 6935, 1012, 29175, 5244, 1012, 6187, 8450, 1012, 17727, 2140, 1025, 12324, 17850, 1012, 10768, 2099, 1012, 27838, 2213, 6935, 1012, 29175, 5244, 1012, 29175, 5244, 21678, 8613, 1025, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/***************************************************************************** * rtmp.c: RTMP output. ***************************************************************************** * Copyright (C) URJC - LADyR - Luis Lopez Fernandez * * Author: Miguel Angel Cabrera Moya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <vlc_common.h> #include <vlc_plugin.h> #include <vlc_sout.h> #include <vlc_network.h> /* DOWN: #include <network.h> */ #include <vlc_url.h> #include <vlc_block.h> #include "../access/rtmp/rtmp_amf_flv.h" /***************************************************************************** * Module descriptor *****************************************************************************/ #define RTMP_CONNECT_TEXT N_( "Active TCP connection" ) #define RTMP_CONNECT_LONGTEXT N_( \ "If enabled, VLC will connect to a remote destination instead of " \ "waiting for an incoming connection." ) static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); #define SOUT_CFG_PREFIX "sout-rtmp-" vlc_module_begin () set_description( N_("RTMP stream output") ) set_shortname( N_("RTMP" ) ) set_capability( "sout access", 0 ) set_category( CAT_SOUT ) set_subcategory( SUBCAT_SOUT_STREAM ) add_shortcut( "rtmp" ) set_callbacks( Open, Close ) add_bool( "rtmp-connect", false, RTMP_CONNECT_TEXT, RTMP_CONNECT_LONGTEXT, false ) vlc_module_end () /***************************************************************************** * Local prototypes *****************************************************************************/ static ssize_t Write( sout_access_out_t *, block_t * ); static int Seek ( sout_access_out_t *, off_t ); static void* ThreadControl( void * ); struct sout_access_out_sys_t { int active; /* thread for filtering and handling control messages */ rtmp_control_thread_t *p_thread; }; /***************************************************************************** * Open: open the rtmp connection *****************************************************************************/ static int Open( vlc_object_t *p_this ) { sout_access_out_t *p_access = (sout_access_out_t *) p_this; sout_access_out_sys_t *p_sys; char *psz, *p; int length_path, length_media_name; int i; if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) ) return VLC_ENOMEM; p_access->p_sys = p_sys; p_sys->p_thread = vlc_object_create( p_access, sizeof( rtmp_control_thread_t ) ); if( !p_sys->p_thread ) { free( p_sys ); return VLC_ENOMEM; } /* Parse URI - remove spaces */ p = psz = strdup( p_access->psz_path ); while( ( p = strchr( p, ' ' ) ) != NULL ) *p = '+'; vlc_UrlParse( &p_sys->p_thread->url, psz, 0 ); free( psz ); if( p_sys->p_thread->url.psz_host == NULL || *p_sys->p_thread->url.psz_host == '\0' ) { msg_Warn( p_access, "invalid host" ); goto error; } if( p_sys->p_thread->url.i_port <= 0 ) p_sys->p_thread->url.i_port = 1935; if ( p_sys->p_thread->url.psz_path == NULL ) { msg_Warn( p_access, "invalid path" ); goto error; } length_path = strlen( p_sys->p_thread->url.psz_path ); char* psz_tmp = strrchr( p_sys->p_thread->url.psz_path, '/' ); if( !psz_tmp ) goto error; length_media_name = strlen( psz_tmp ) - 1; p_sys->p_thread->psz_application = strndup( p_sys->p_thread->url.psz_path + 1, length_path - length_media_name - 2 ); p_sys->p_thread->psz_media = strdup( p_sys->p_thread->url.psz_path + ( length_path - length_media_name ) ); msg_Dbg( p_access, "rtmp: host='%s' port=%d path='%s'", p_sys->p_thread->url.psz_host, p_sys->p_thread->url.i_port, p_sys->p_thread->url.psz_path ); if( p_sys->p_thread->url.psz_username && *p_sys->p_thread->url.psz_username ) { msg_Dbg( p_access, " user='%s'", p_sys->p_thread->url.psz_username ); } /* Initialize thread variables */ p_sys->p_thread->b_error= 0; p_sys->p_thread->p_fifo_input = block_FifoNew(); p_sys->p_thread->p_empty_blocks = block_FifoNew(); p_sys->p_thread->has_audio = 0; p_sys->p_thread->has_video = 0; p_sys->p_thread->metadata_received = 0; p_sys->p_thread->first_media_packet = 1; p_sys->p_thread->flv_tag_previous_tag_size = 0x00000000; /* FLV_TAG_FIRST_PREVIOUS_TAG_SIZE */ p_sys->p_thread->flv_body = rtmp_body_new( -1 ); p_sys->p_thread->flv_length_body = 0; p_sys->p_thread->chunk_size_recv = 128; /* RTMP_DEFAULT_CHUNK_SIZE */ p_sys->p_thread->chunk_size_send = 128; /* RTMP_DEFAULT_CHUNK_SIZE */ for(i = 0; i < 64; i++) { memset( &p_sys->p_thread->rtmp_headers_recv[i], 0, sizeof( rtmp_packet_t ) ); p_sys->p_thread->rtmp_headers_send[i].length_header = -1; p_sys->p_thread->rtmp_headers_send[i].stream_index = -1; p_sys->p_thread->rtmp_headers_send[i].timestamp = -1; p_sys->p_thread->rtmp_headers_send[i].timestamp_relative = -1; p_sys->p_thread->rtmp_headers_send[i].length_encoded = -1; p_sys->p_thread->rtmp_headers_send[i].length_body = -1; p_sys->p_thread->rtmp_headers_send[i].content_type = -1; p_sys->p_thread->rtmp_headers_send[i].src_dst = -1; p_sys->p_thread->rtmp_headers_send[i].body = NULL; } vlc_cond_init( &p_sys->p_thread->wait ); vlc_mutex_init( &p_sys->p_thread->lock ); p_sys->p_thread->result_connect = 1; /* p_sys->p_thread->result_publish = only used on access */ p_sys->p_thread->result_play = 1; p_sys->p_thread->result_stop = 0; p_sys->p_thread->fd = -1; /* Open connection */ if( var_CreateGetBool( p_access, "rtmp-connect" ) > 0 ) { #if 0 p_sys->p_thread->fd = net_ConnectTCP( p_access, p_sys->p_thread->url.psz_host, p_sys->p_thread->url.i_port ); #endif msg_Err( p_access, "to be implemented" ); goto error2; } else { int *p_fd_listen; p_sys->active = 0; p_fd_listen = net_ListenTCP( p_access, p_sys->p_thread->url.psz_host, p_sys->p_thread->url.i_port ); if( p_fd_listen == NULL ) { msg_Warn( p_access, "cannot listen to %s port %i", p_sys->p_thread->url.psz_host, p_sys->p_thread->url.i_port ); goto error2; } do p_sys->p_thread->fd = net_Accept( p_access, p_fd_listen ); while( p_sys->p_thread->fd == -1 ); net_ListenClose( p_fd_listen ); if( rtmp_handshake_passive( p_this, p_sys->p_thread->fd ) < 0 ) { msg_Err( p_access, "handshake passive failed"); goto error2; } } if( vlc_clone( &p_sys->p_thread->thread, ThreadControl, p_sys->p_thread, VLC_THREAD_PRIORITY_INPUT ) ) { msg_Err( p_access, "cannot spawn rtmp control thread" ); goto error2; } if( !p_sys->active ) { if( rtmp_connect_passive( p_sys->p_thread ) < 0 ) { msg_Err( p_access, "connect passive failed"); vlc_cancel( p_sys->p_thread->thread ); vlc_join( p_sys->p_thread->thread, NULL ); goto error2; } } p_access->pf_write = Write; p_access->pf_seek = Seek; return VLC_SUCCESS; error2: vlc_cond_destroy( &p_sys->p_thread->wait ); vlc_mutex_destroy( &p_sys->p_thread->lock ); free( p_sys->p_thread->psz_application ); free( p_sys->p_thread->psz_media ); if( p_sys->p_thread->fd != -1 ) net_Close( p_sys->p_thread->fd ); error: vlc_UrlClean( &p_sys->p_thread->url ); vlc_object_release( p_sys->p_thread ); free( p_sys ); return VLC_EGENERIC; } /***************************************************************************** * Close: close the target *****************************************************************************/ static void Close( vlc_object_t * p_this ) { sout_access_out_t *p_access = (sout_access_out_t *) p_this; sout_access_out_sys_t *p_sys = p_access->p_sys; int i; vlc_cancel( p_sys->p_thread->thread ); vlc_join( p_sys->p_thread->thread, NULL ); vlc_cond_destroy( &p_sys->p_thread->wait ); vlc_mutex_destroy( &p_sys->p_thread->lock ); block_FifoRelease( p_sys->p_thread->p_fifo_input ); block_FifoRelease( p_sys->p_thread->p_empty_blocks ); for( i = 0; i < 64; i++ ) /* RTMP_HEADER_STREAM_INDEX_MASK */ { if( p_sys->p_thread->rtmp_headers_recv[i].body != NULL ) { free( p_sys->p_thread->rtmp_headers_recv[i].body->body ); free( p_sys->p_thread->rtmp_headers_recv[i].body ); } } net_Close( p_sys->p_thread->fd ); vlc_object_release( p_sys->p_thread ); vlc_UrlClean( &p_sys->p_thread->url ); free( p_sys->p_thread->psz_application ); free( p_sys->p_thread->psz_media ); free( p_sys ); } /***************************************************************************** * Write: standard write on a file descriptor. *****************************************************************************/ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer ) { rtmp_packet_t *rtmp_packet; uint8_t *tmp_buffer; ssize_t i_ret; ssize_t i_write = 0; if( p_access->p_sys->p_thread->first_media_packet ) { /* 13 == FLV_HEADER_SIZE + PreviousTagSize*/ memmove( p_buffer->p_buffer, p_buffer->p_buffer + 13, p_buffer->i_buffer - 13 ); p_buffer = block_Realloc( p_buffer, 0, p_buffer->i_buffer - 13 ); p_access->p_sys->p_thread->first_media_packet = 0; } while( p_buffer ) { block_t *p_next = p_buffer->p_next; ////////////////////////////// /*msg_Warn(p_access, "XXXXXXXXXXXXXXXXX"); int i; for(i = 0; i < p_buffer->i_buffer; i += 16) { msg_Warn(p_access,"%.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x %.2x%.2x", p_buffer->p_buffer[i], p_buffer->p_buffer[i+1], p_buffer->p_buffer[i+2], p_buffer->p_buffer[i+3], p_buffer->p_buffer[i+4], p_buffer->p_buffer[i+5], p_buffer->p_buffer[i+6], p_buffer->p_buffer[i+7], p_buffer->p_buffer[i+8], p_buffer->p_buffer[i+9], p_buffer->p_buffer[i+10], p_buffer->p_buffer[i+11], p_buffer->p_buffer[i+12], p_buffer->p_buffer[i+13], p_buffer->p_buffer[i+14], p_buffer->p_buffer[i+15]); }*/ //////////////////////// msg_Warn(p_access, "rtmp.c:360 i_dts %"PRIu64" i_pts %"PRIu64, p_buffer->i_dts, p_buffer->i_pts); rtmp_packet = rtmp_build_flv_over_rtmp( p_access->p_sys->p_thread, p_buffer ); if( rtmp_packet ) { tmp_buffer = rtmp_encode_packet( p_access->p_sys->p_thread, rtmp_packet ); i_ret = net_Write( p_access->p_sys->p_thread, p_access->p_sys->p_thread->fd, NULL, tmp_buffer, rtmp_packet->length_encoded ); if( i_ret != rtmp_packet->length_encoded ) { free( rtmp_packet->body->body ); free( rtmp_packet->body ); free( rtmp_packet ); free( tmp_buffer ); msg_Err( p_access->p_sys->p_thread, "failed send flv packet" ); return -1; } free( rtmp_packet->body->body ); free( rtmp_packet->body ); free( rtmp_packet ); free( tmp_buffer ); } i_write += p_buffer->i_buffer; p_buffer = p_next; } return i_write; } /********************a********************************************************* * Seek: seek to a specific location in a file *****************************************************************************/ static int Seek( sout_access_out_t *p_access, off_t i_pos ) { (void)i_pos; msg_Err( p_access, "RTMP sout access cannot seek" ); return -1; } /***************************************************************************** * ThreadControl: manage control messages and pipe media to Read *****************************************************************************/ static void* ThreadControl( void *p_this ) { rtmp_control_thread_t *p_thread = p_this; rtmp_packet_t *rtmp_packet; int canc = vlc_savecancel (); rtmp_init_handler( p_thread->rtmp_handler ); for( ;; ) { vlc_restorecancel( canc ); rtmp_packet = rtmp_read_net_packet( p_thread ); canc = vlc_savecancel( ); if( rtmp_packet != NULL ) { if( rtmp_packet->content_type < 0x01 /* RTMP_CONTENT_TYPE_CHUNK_SIZE */ || rtmp_packet->content_type > 0x14 ) /* RTMP_CONTENT_TYPE_INVOKE */ { free( rtmp_packet->body->body ); free( rtmp_packet->body ); free( rtmp_packet ); msg_Warn( p_thread, "unknown content type received" ); } else p_thread->rtmp_handler[rtmp_packet->content_type]( p_thread, rtmp_packet ); } else { /* Sometimes server close connection too soon */ #warning Locking bug here. if( p_thread->result_connect ) { vlc_mutex_lock( &p_thread->lock ); vlc_cond_signal( &p_thread->wait ); vlc_mutex_unlock( &p_thread->lock ); } break; } } vlc_restorecancel (canc); return NULL; }
matthiasbock/VideoLAN-for-Allwinner-A10-VPU
modules/access_output/rtmp.c
C
gpl-2.0
14,588
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- title: கிறிஸ்தவனும் வேலையும் date: 05/12/2020 --- ### இவ்வார ஆராய்ச்சிக்கு: ஆதி 3:19; உபா 16:15; யாத் 25:10-30:38; கலா 5:22-26; பிர 9:10; 1கொரி 10:31. > <p>மனன வசனம்</p> > ஆகையால், எனக்குப் பிரியமான சகோதரரே, கர்த்தருக்குள் நீங் கள் படுகிற பிரயாசம் விருதாவாயிராதென்று அறிந்து, நீங்கள் உறுதிப்பட்டவர்களாயும், அசையாதவர்களாயும், கர்த்தருடைய கிரியையிலே எப்பொழுதும் பெருகுகிறவர்களாயும் இருப்பீர்களாக. 1கொரிந்தியர் 15:58. தேவனுடைய யோசனையில் உருவான ஒன்று வேலை. பாவத்தின் முன் பிருந்த இலட்சிய உலகத்தில், ஆதாமுக்கும் ஏவாளுக்கும் தோட்டத்தைப் பண் படுத்துகிற வேலையை தேவன் கொடுத்தார். ஆதி 2:15. சிருஷ்டிகருடைய சாய லில் படைக்கப்பட்டவர்கள், அவரைப் போலவே ஆக்கப்பூர்வ வேலைகளிலும் அன்பின் சேவையிலும் ஈடுபடவேண்டியதிருந்தது. அதாவது, விழுந்துபோகாத உலகில், பாவமும் மரணமும் பாடுகளும் இல்லாத ஓர் உலகத்தில்கூட மனி தர்கள் வேலைசெய்ய வேண்டியதிருந்தது. பாவமில்லாதிருந்த உலகத்திற்குப்பிறகு, இயேசு மீண்டும் வருவதற்கு முன்பு இருக்கிற இந்த ‘இடைப்பட்ட காலத்தில்’, தேவனுடைய ஆசீர்வாதங் களில் ஒன்றாக வேலை இருக்கிறது. யூதர்கள் ஒவ்வொரு பிள்ளைக்கும் ஏதா வது ஒரு தொழில் கற்றுக்கொடுத்தார்கள். மகனுக்கு தொழில் கற்றுக்கொடுக்காத தந்தை, அவனைக் குற்றவாளியாக வளர்க்கிறான் என்றும் சொல்வார்கள். தேவகுமாரனாகிய இயேசு தம் பிதாவின் சித்தப்படி செய்து, ஒரு திறமையான கைவினைஞராக பல வருடங்கள் நேர்மையாக உழைத்தார். மாற்கு 6:3. அதுவும் ஊழியத்திற்கு அவரைத் தயார்படுத்துகிற பயிற்சியே. ஆக்கில்லா, பிரிஸ்கில் லாளுடன் தங்கியிருந்து ஊழியம்செய்த பவுல் அப்போஸ்தலன் ஒன்றரை வரு டம் கூடாரவேலை செய்தார். ஓய்வுநாள்தோறும் ஜெபாலயங்களில் சம்பா ஷணை பண்ணினார். அப் 18:1-4; 2தெச 3:8-12. வேலைபற்றியும், கிறிஸ்தவக் கல்வியில் அதன் பங்குபற்றியும் இந்த வாரம் பார்ப்போம். 2020, டிசம்பர் 12 வகுப்புக்காகப் படிக்கவேண்டிய பாடம்
imasaru/sabbath-school-lessons
src/ta/2020-04/11/01.md
Markdown
mit
4,277
[ 30522, 1011, 1011, 1011, 2516, 1024, 100, 1394, 29934, 29928, 29935, 29926, 29933, 29925, 3058, 1024, 5709, 1013, 2260, 1013, 12609, 1011, 1011, 1011, 1001, 1001, 1001, 100, 100, 1024, 100, 1017, 1024, 2539, 1025, 100, 2385, 1024, 2321, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Who Owns Kenya</title> <link href="style/main.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="favicon.ico"> <link rel="apple-touch-icon" href="meta/apple-touch-icon.png"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="HandheldFriendly" content="True"> <meta name="MobileOptimized" content="320"> <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui"> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-10804158-5', 'sasagichuki.github.io'); ga('send', 'pageview'); </script> </head> <body> <div class="container"> <div class="heading"> <h1 class="title">Who Owns Kenya</h1> <div class="scores-container"> <div class="score-container">0</div> <div class="best-container">0</div> </div> </div> <!-- <p class="game-intro">Double the Money <strong>and Win</strong></p> --> <div class="game-container"> <div class="game-message"> <p></p> <div class="lower"> <a class="keep-playing-button">Keep going</a> <a class="retry-button">Try again</a> </div> <div class="score-sharing"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://sasagichuki.github.io/who_owns_kenya/" data-text="Do you know who owns Kenya ? Play this game and find out" data-via="kibee" data-size="large">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> </div> </div> <div class="grid-container"> <div class="grid-row"> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> </div> <div class="grid-row"> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> </div> <div class="grid-row"> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> </div> <div class="grid-row"> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> <div class="grid-cell"></div> </div> </div> <div class="tile-container"> </div> </div> <p class="game-explanation"> <strong class="important">How to play:</strong> Use your <strong>arrow keys</strong> to move the Rich Dudes. When two Rich dudes with the same money touch they merge into <strong>One dude with Double their Money</strong>. Keep playing to find out who owns Kenya. </p> <hr> <p> <strong class="important">Note:</strong> This is just a joke, it's not that serious. Enjoy with caution. </p> <hr> <p> Created by <a href="http://www.chaos.co.ke" target="_blank">Chaos.</a> Based on 2048 by <a href="http://gabrielecirulli.com" target="_blank">Gabriele Cirulli.</a> Who based his on <a href="https://itunes.apple.com/us/app/1024!/id823499224" target="_blank">1024 by Veewo Studio</a> and conceptually similar to <a href="http://asherv.com/threes/" target="_blank">Threes by Asher Vollmer.</a> </p> </div> <script src="js/animframe_polyfill.js"></script> <script src="js/keyboard_input_manager.js"></script> <script src="js/html_actuator.js"></script> <script src="js/grid.js"></script> <script src="js/tile.js"></script> <script src="js/local_score_manager.js"></script> <script src="js/game_manager.js"></script> <script src="js/application.js"></script> </body> </html>
sasagichuki/who_owns_kenya
index.html
HTML
mit
4,365
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 2516, 30524, 1027, 1000, 2460, 12690, 12696, 1000, 17850, 12879, 1027, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * High-level sync()-related operations */ #include <linux/kernel.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/slab.h> #include <linux/export.h> #include <linux/namei.h> #include <linux/sched.h> #include <linux/writeback.h> #include <linux/syscalls.h> #include <linux/linkage.h> #include <linux/pagemap.h> #include <linux/quotaops.h> #include <linux/backing-dev.h> #include "internal.h" #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ SYNC_FILE_RANGE_WAIT_AFTER) /* * Do the filesystem syncing work. For simple filesystems * writeback_inodes_sb(sb) just dirties buffers with inodes so we have to * submit IO for these buffers via __sync_blockdev(). This also speeds up the * wait == 1 case since in that case write_inode() functions do * sync_dirty_buffer() and thus effectively write one block at a time. */ static int __sync_filesystem(struct super_block *sb, int wait) { /* * This should be safe, as we require bdi backing to actually * write out data in the first place */ if (sb->s_bdi == &noop_backing_dev_info) return 0; if (sb->s_qcop && sb->s_qcop->quota_sync) sb->s_qcop->quota_sync(sb, -1, wait); if (wait) sync_inodes_sb(sb); else writeback_inodes_sb(sb, WB_REASON_SYNC); if (sb->s_op->sync_fs) sb->s_op->sync_fs(sb, wait); return __sync_blockdev(sb->s_bdev, wait); } /* * Write out and wait upon all dirty data associated with this * superblock. Filesystem data as well as the underlying block * device. Takes the superblock lock. */ int sync_filesystem(struct super_block *sb) { int ret; /* * We need to be protected against the filesystem going from * r/o to r/w or vice versa. */ WARN_ON(!rwsem_is_locked(&sb->s_umount)); /* * No point in syncing out anything if the filesystem is read-only. */ if (sb->s_flags & MS_RDONLY) return 0; ret = __sync_filesystem(sb, 0); if (ret < 0) return ret; return __sync_filesystem(sb, 1); } EXPORT_SYMBOL_GPL(sync_filesystem); static void sync_one_sb(struct super_block *sb, void *arg) { if (!(sb->s_flags & MS_RDONLY)) __sync_filesystem(sb, *(int *)arg); } /* * Sync all the data for all the filesystems (called by sys_sync() and * emergency sync) */ void sync_filesystems(int wait) { iterate_supers(sync_one_sb, &wait); } /* * sync everything. Start out by waking pdflush, because that writes back * all queues in parallel. */ SYSCALL_DEFINE0(sync) { wakeup_flusher_threads(0, WB_REASON_SYNC); sync_filesystems(0); sync_filesystems(1); if (unlikely(laptop_mode)) laptop_sync_completion(); return 0; } static void do_sync_work(struct work_struct *work) { /* * Sync twice to reduce the possibility we skipped some inodes / pages * because they were temporarily locked */ sync_filesystems(0); sync_filesystems(0); printk("Emergency Sync complete\n"); kfree(work); } void emergency_sync(void) { struct work_struct *work; work = kmalloc(sizeof(*work), GFP_ATOMIC); if (work) { INIT_WORK(work, do_sync_work); schedule_work(work); } } /* * sync a single super */ SYSCALL_DEFINE1(syncfs, int, fd) { struct file *file; struct super_block *sb; int ret; int fput_needed; file = fget_light(fd, &fput_needed); if (!file) return -EBADF; sb = file->f_dentry->d_sb; down_read(&sb->s_umount); ret = sync_filesystem(sb); up_read(&sb->s_umount); fput_light(file, fput_needed); return ret; } /** * vfs_fsync_range - helper to sync a range of data & metadata to disk * @file: file to sync * @start: offset in bytes of the beginning of data range to sync * @end: offset in bytes of the end of data range (inclusive) * @datasync: perform only datasync * * Write back data in range @start..@end and metadata for @file to disk. If * @datasync is set only metadata needed to access modified file data is * written. */ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) { if (!file->f_op || !file->f_op->fsync) return -EINVAL; return file->f_op->fsync(file, start, end, datasync); } EXPORT_SYMBOL(vfs_fsync_range); /** * vfs_fsync - perform a fsync or fdatasync on a file * @file: file to sync * @datasync: only perform a fdatasync operation * * Write back data and metadata for @file to disk. If @datasync is * set only metadata needed to access modified file data is written. */ int vfs_fsync(struct file *file, int datasync) { return vfs_fsync_range(file, 0, LLONG_MAX, datasync); } EXPORT_SYMBOL(vfs_fsync); static int do_fsync(unsigned int fd, int datasync) { struct file *file; int ret = -EBADF; file = fget(fd); if (file) { ret = vfs_fsync(file, datasync); fput(file); } return ret; } SYSCALL_DEFINE1(fsync, unsigned int, fd) { return do_fsync(fd, 0); } SYSCALL_DEFINE1(fdatasync, unsigned int, fd) { return do_fsync(fd, 1); } /** * generic_write_sync - perform syncing after a write if file / inode is sync * @file: file to which the write happened * @pos: offset where the write started * @count: length of the write * * This is just a simple wrapper about our general syncing function. */ int generic_write_sync(struct file *file, loff_t pos, loff_t count) { if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host)) return 0; return vfs_fsync_range(file, pos, pos + count - 1, (file->f_flags & __O_SYNC) ? 0 : 1); } EXPORT_SYMBOL(generic_write_sync); /* * sys_sync_file_range() permits finely controlled syncing over a segment of * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is * zero then sys_sync_file_range() will operate from offset out to EOF. * * The flag bits are: * * SYNC_FILE_RANGE_WAIT_BEFORE: wait upon writeout of all pages in the range * before performing the write. * * SYNC_FILE_RANGE_WRITE: initiate writeout of all those dirty pages in the * range which are not presently under writeback. Note that this may block for * significant periods due to exhaustion of disk request structures. * * SYNC_FILE_RANGE_WAIT_AFTER: wait upon writeout of all pages in the range * after performing the write. * * Useful combinations of the flag bits are: * * SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE: ensures that all pages * in the range which were dirty on entry to sys_sync_file_range() are placed * under writeout. This is a start-write-for-data-integrity operation. * * SYNC_FILE_RANGE_WRITE: start writeout of all dirty pages in the range which * are not presently under writeout. This is an asynchronous flush-to-disk * operation. Not suitable for data integrity operations. * * SYNC_FILE_RANGE_WAIT_BEFORE (or SYNC_FILE_RANGE_WAIT_AFTER): wait for * completion of writeout of all pages in the range. This will be used after an * earlier SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE operation to wait * for that operation to complete and to return the result. * * SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER: * a traditional sync() operation. This is a write-for-data-integrity operation * which will ensure that all pages in the range which were dirty on entry to * sys_sync_file_range() are committed to disk. * * * SYNC_FILE_RANGE_WAIT_BEFORE and SYNC_FILE_RANGE_WAIT_AFTER will detect any * I/O errors or ENOSPC conditions and will return those to the caller, after * clearing the EIO and ENOSPC flags in the address_space. * * It should be noted that none of these operations write out the file's * metadata. So unless the application is strictly performing overwrites of * already-instantiated disk blocks, there are no guarantees here that the data * will be available after a crash. */ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, unsigned int flags) { int ret; struct file *file; struct address_space *mapping; loff_t endbyte; /* inclusive */ int fput_needed; umode_t i_mode; ret = -EINVAL; if (flags & ~VALID_FLAGS) goto out; endbyte = offset + nbytes; if ((s64)offset < 0) goto out; if ((s64)endbyte < 0) goto out; if (endbyte < offset) goto out; if (sizeof(pgoff_t) == 4) { if (offset >= (0x100000000ULL << PAGE_CACHE_SHIFT)) { /* * The range starts outside a 32 bit machine's * pagecache addressing capabilities. Let it "succeed" */ ret = 0; goto out; } if (endbyte >= (0x100000000ULL << PAGE_CACHE_SHIFT)) { /* * Out to EOF */ nbytes = 0; } } if (nbytes == 0) endbyte = LLONG_MAX; else endbyte--; /* inclusive */ ret = -EBADF; file = fget_light(fd, &fput_needed); if (!file) goto out; i_mode = file->f_path.dentry->d_inode->i_mode; ret = -ESPIPE; if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) && !S_ISLNK(i_mode)) goto out_put; mapping = file->f_mapping; if (!mapping) { ret = -EINVAL; goto out_put; } ret = 0; if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { ret = filemap_fdatawait_range(mapping, offset, endbyte); if (ret < 0) goto out_put; } if (flags & SYNC_FILE_RANGE_WRITE) { ret = filemap_fdatawrite_range(mapping, offset, endbyte); if (ret < 0) goto out_put; } if (flags & SYNC_FILE_RANGE_WAIT_AFTER) ret = filemap_fdatawait_range(mapping, offset, endbyte); out_put: fput_light(file, fput_needed); out: return ret; } #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS asmlinkage long SyS_sync_file_range(long fd, loff_t offset, loff_t nbytes, long flags) { return SYSC_sync_file_range((int) fd, offset, nbytes, (unsigned int) flags); } SYSCALL_ALIAS(sys_sync_file_range, SyS_sync_file_range); #endif /* It would be nice if people remember that not all the world's an i386 when they introduce new system calls */ SYSCALL_DEFINE(sync_file_range2)(int fd, unsigned int flags, loff_t offset, loff_t nbytes) { return sys_sync_file_range(fd, offset, nbytes, flags); } #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS asmlinkage long SyS_sync_file_range2(long fd, long flags, loff_t offset, loff_t nbytes) { return SYSC_sync_file_range2((int) fd, (unsigned int) flags, offset, nbytes); } SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); #endif
LiquidSmokeX64/android_kernel_oneplus_msm8974-UR3.6
fs/sync.c
C
gpl-2.0
10,123
[ 30522, 1013, 1008, 1008, 2152, 1011, 2504, 26351, 1006, 1007, 1011, 3141, 3136, 1008, 1013, 1001, 2421, 1026, 11603, 1013, 16293, 1012, 1044, 1028, 1001, 2421, 1026, 11603, 1013, 5371, 1012, 1044, 1028, 1001, 2421, 1026, 11603, 1013, 1042, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* *** Trajectory Commands *** src/command/trajectory.cpp Copyright T. Youngs 2007-2018 This file is part of Aten. Aten is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Aten is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Aten. If not, see <http://www.gnu.org/licenses/>. */ #include "command/commands.h" #include "parser/commandnode.h" #include "main/aten.h" #include "model/model.h" #include "gui/mainwindow.h" #include "gui/opentrajectory.h" ATEN_USING_NAMESPACE // Add new frame to the current model's trajectory bool Commands::function_AddFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; obj.m->addTrajectoryFrame(); obj.m->setRenderSource(Model::TrajectorySource); if (c->hasArg(0)) obj.rs()->setName(c->argc(0)); rv.set(VTypes::ModelData, obj.rs()); return true; } // Clear any trajectory data in the current model bool Commands::function_ClearTrajectory(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.rs() != obj.m) { Messenger::print("Current model is a trajectory frame - resetting to the parent model..."); obj.m->setRenderSource(Model::ModelSource); } obj.m->clearTrajectory(); rv.reset(); return true; } // Skip to first frame ('firstframe') bool Commands::function_FirstFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.m->nTrajectoryFrames() == 0) { Messenger::print("No trajectory associated to model '%s'.", qPrintable(obj.m->name())); return false; } obj.m->seekFirstTrajectoryFrame(); rv.reset(); return true; } // Skip to last frame ('lastframe') bool Commands::function_LastFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.m->nTrajectoryFrames() == 0) { Messenger::print("No trajectory associated to model '%s'.", qPrintable(obj.m->name())); return false; } obj.m->seekLastTrajectoryFrame(); rv.reset(); return true; } // Open and associate trajectory ('loadtrajectory <file>') bool Commands::function_LoadTrajectory(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; bool result = aten_.importTrajectory(obj.m, c->argc(0), NULL, FilePluginStandardImportOptions()); rv.set(result); return true; } // Go to next frame ('nextframe') bool Commands::function_NextFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.m->nTrajectoryFrames() == 0) { Messenger::print("No trajectory associated to model '%s'.", qPrintable(obj.m->name())); return false; } obj.m->seekNextTrajectoryFrame(); rv.reset(); return true; } // Go to previous frame ('prevframe') bool Commands::function_PrevFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.m->nTrajectoryFrames() == 0) { Messenger::print("No trajectory associated to model '%s'.", qPrintable(obj.m->name())); return false; } obj.m->seekPreviousTrajectoryFrame(); rv.reset(); return true; } // Seek to specified frame ('seekframe <n>') bool Commands::function_SeekFrame(CommandNode* c, Bundle& obj, ReturnValue& rv) { if (obj.notifyNull(Bundle::ModelPointer)) return false; if (obj.m->nTrajectoryFrames() == 0) { Messenger::print("No trajectory associated to model '%s'.", qPrintable(obj.m->name())); return false; } obj.m->seekTrajectoryFrame(c->argi(0)-1); rv.reset(); return true; }
trisyoungs/aten
src/command/trajectory.cpp
C++
gpl-2.0
4,024
[ 30522, 1013, 1008, 1008, 1008, 1008, 22793, 10954, 1008, 1008, 1008, 5034, 2278, 1013, 3094, 1013, 22793, 1012, 18133, 2361, 9385, 1056, 1012, 2402, 2015, 2289, 1011, 2760, 2023, 5371, 2003, 2112, 1997, 8823, 2078, 1012, 8823, 2078, 2003, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 // protoc v3.16.0 // source: envoy/api/v2/core/event_service_config.proto package envoy_api_v2_core import ( _ "github.com/cncf/xds/go/udpa/annotations" _ "github.com/envoyproxy/protoc-gen-validate/validate" proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // This is a compile-time assertion that a sufficiently up-to-date version // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 // [#not-implemented-hide:] // Configuration of the event reporting service endpoint. type EventServiceConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to ConfigSourceSpecifier: // *EventServiceConfig_GrpcService ConfigSourceSpecifier isEventServiceConfig_ConfigSourceSpecifier `protobuf_oneof:"config_source_specifier"` } func (x *EventServiceConfig) Reset() { *x = EventServiceConfig{} if protoimpl.UnsafeEnabled { mi := &file_envoy_api_v2_core_event_service_config_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *EventServiceConfig) String() string { return protoimpl.X.MessageStringOf(x) } func (*EventServiceConfig) ProtoMessage() {} func (x *EventServiceConfig) ProtoReflect() protoreflect.Message { mi := &file_envoy_api_v2_core_event_service_config_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use EventServiceConfig.ProtoReflect.Descriptor instead. func (*EventServiceConfig) Descriptor() ([]byte, []int) { return file_envoy_api_v2_core_event_service_config_proto_rawDescGZIP(), []int{0} } func (m *EventServiceConfig) GetConfigSourceSpecifier() isEventServiceConfig_ConfigSourceSpecifier { if m != nil { return m.ConfigSourceSpecifier } return nil } func (x *EventServiceConfig) GetGrpcService() *GrpcService { if x, ok := x.GetConfigSourceSpecifier().(*EventServiceConfig_GrpcService); ok { return x.GrpcService } return nil } type isEventServiceConfig_ConfigSourceSpecifier interface { isEventServiceConfig_ConfigSourceSpecifier() } type EventServiceConfig_GrpcService struct { // Specifies the gRPC service that hosts the event reporting service. GrpcService *GrpcService `protobuf:"bytes,1,opt,name=grpc_service,json=grpcService,proto3,oneof"` } func (*EventServiceConfig_GrpcService) isEventServiceConfig_ConfigSourceSpecifier() {} var File_envoy_api_v2_core_event_service_config_proto protoreflect.FileDescriptor var file_envoy_api_v2_core_event_service_config_proto_rawDesc = []byte{ 0x0a, 0x2c, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x24, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x79, 0x0a, 0x12, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x43, 0x0a, 0x0c, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x67, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x1e, 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x42, 0x60, 0x0a, 0x1f, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x17, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0xf2, 0x98, 0xfe, 0x8f, 0x05, 0x16, 0x12, 0x14, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x33, 0xba, 0x80, 0xc8, 0xd1, 0x06, 0x02, 0x10, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_envoy_api_v2_core_event_service_config_proto_rawDescOnce sync.Once file_envoy_api_v2_core_event_service_config_proto_rawDescData = file_envoy_api_v2_core_event_service_config_proto_rawDesc ) func file_envoy_api_v2_core_event_service_config_proto_rawDescGZIP() []byte { file_envoy_api_v2_core_event_service_config_proto_rawDescOnce.Do(func() { file_envoy_api_v2_core_event_service_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_envoy_api_v2_core_event_service_config_proto_rawDescData) }) return file_envoy_api_v2_core_event_service_config_proto_rawDescData } var file_envoy_api_v2_core_event_service_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_envoy_api_v2_core_event_service_config_proto_goTypes = []interface{}{ (*EventServiceConfig)(nil), // 0: envoy.api.v2.core.EventServiceConfig (*GrpcService)(nil), // 1: envoy.api.v2.core.GrpcService } var file_envoy_api_v2_core_event_service_config_proto_depIdxs = []int32{ 1, // 0: envoy.api.v2.core.EventServiceConfig.grpc_service:type_name -> envoy.api.v2.core.GrpcService 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } func init() { file_envoy_api_v2_core_event_service_config_proto_init() } func file_envoy_api_v2_core_event_service_config_proto_init() { if File_envoy_api_v2_core_event_service_config_proto != nil { return } file_envoy_api_v2_core_grpc_service_proto_init() if !protoimpl.UnsafeEnabled { file_envoy_api_v2_core_event_service_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*EventServiceConfig); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } } file_envoy_api_v2_core_event_service_config_proto_msgTypes[0].OneofWrappers = []interface{}{ (*EventServiceConfig_GrpcService)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_envoy_api_v2_core_event_service_config_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_envoy_api_v2_core_event_service_config_proto_goTypes, DependencyIndexes: file_envoy_api_v2_core_event_service_config_proto_depIdxs, MessageInfos: file_envoy_api_v2_core_event_service_config_proto_msgTypes, }.Build() File_envoy_api_v2_core_event_service_config_proto = out.File file_envoy_api_v2_core_event_service_config_proto_rawDesc = nil file_envoy_api_v2_core_event_service_config_proto_goTypes = nil file_envoy_api_v2_core_event_service_config_proto_depIdxs = nil }
knative-sandbox/eventing-awssqs
vendor/github.com/envoyproxy/go-control-plane/envoy/api/v2/core/event_service_config.pb.go
GO
apache-2.0
8,657
[ 30522, 1013, 1013, 3642, 7013, 2011, 15053, 2278, 1011, 8991, 1011, 2175, 1012, 2079, 2025, 10086, 1012, 1013, 1013, 4617, 1024, 1013, 1013, 15053, 2278, 1011, 8991, 1011, 2175, 1058, 2487, 1012, 2423, 1012, 1014, 1013, 1013, 15053, 2278, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using NServiceBus; using NServiceBus.Logging; static class Program { static void Main() { LogManager.Use<DefaultFactory>().Level(LogLevel.Info); BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.PubSub.Subscriber1"); busConfiguration.UseSerialization<JsonSerializer>(); busConfiguration.UsePersistence<InMemoryPersistence>(); busConfiguration.EnableInstallers(); using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } } }
pedroreys/docs.particular.net
samples/pubsub/Version_5/Subscriber1/Program.cs
C#
apache-2.0
652
[ 30522, 2478, 2291, 1025, 2478, 24978, 2121, 7903, 15878, 2271, 1025, 2478, 24978, 2121, 7903, 15878, 2271, 1012, 15899, 1025, 10763, 2465, 2565, 1063, 10763, 11675, 2364, 1006, 1007, 1063, 8833, 24805, 4590, 1012, 2224, 1026, 12398, 21450, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/****************************************************************************** * * Copyright (C) 1997-2013 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #include <stdlib.h> #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qintdict.h> #include "xmlgen.h" #include "doxygen.h" #include "message.h" #include "config.h" #include "classlist.h" #include "util.h" #include "defargs.h" #include "outputgen.h" #include "dot.h" #include "pagedef.h" #include "filename.h" #include "version.h" #include "xmldocvisitor.h" #include "docparser.h" #include "language.h" #include "parserintf.h" #include "arguments.h" #include "memberlist.h" #include "groupdef.h" #include "memberdef.h" #include "namespacedef.h" #include "membername.h" #include "membergroup.h" #include "dirdef.h" #include "section.h" // no debug info #define XML_DB(x) do {} while(0) // debug to stdout //#define XML_DB(x) printf x // debug inside output //#define XML_DB(x) QCString __t;__t.sprintf x;m_t << __t //------------------ static const char index_xsd[] = #include "index_xsd.h" ; //------------------ // static const char compound_xsd[] = #include "compound_xsd.h" ; //------------------ /** Helper class mapping MemberList::ListType to a string representing */ class XmlSectionMapper : public QIntDict<char> { public: XmlSectionMapper() : QIntDict<char>(47) { insert(MemberListType_pubTypes,"public-type"); insert(MemberListType_pubMethods,"public-func"); insert(MemberListType_pubAttribs,"public-attrib"); insert(MemberListType_pubSlots,"public-slot"); insert(MemberListType_signals,"signal"); insert(MemberListType_dcopMethods,"dcop-func"); insert(MemberListType_properties,"property"); insert(MemberListType_events,"event"); insert(MemberListType_pubStaticMethods,"public-static-func"); insert(MemberListType_pubStaticAttribs,"public-static-attrib"); insert(MemberListType_proTypes,"protected-type"); insert(MemberListType_proMethods,"protected-func"); insert(MemberListType_proAttribs,"protected-attrib"); insert(MemberListType_proSlots,"protected-slot"); insert(MemberListType_proStaticMethods,"protected-static-func"); insert(MemberListType_proStaticAttribs,"protected-static-attrib"); insert(MemberListType_pacTypes,"package-type"); insert(MemberListType_pacMethods,"package-func"); insert(MemberListType_pacAttribs,"package-attrib"); insert(MemberListType_pacStaticMethods,"package-static-func"); insert(MemberListType_pacStaticAttribs,"package-static-attrib"); insert(MemberListType_priTypes,"private-type"); insert(MemberListType_priMethods,"private-func"); insert(MemberListType_priAttribs,"private-attrib"); insert(MemberListType_priSlots,"private-slot"); insert(MemberListType_priStaticMethods,"private-static-func"); insert(MemberListType_priStaticAttribs,"private-static-attrib"); insert(MemberListType_friends,"friend"); insert(MemberListType_related,"related"); insert(MemberListType_decDefineMembers,"define"); insert(MemberListType_decProtoMembers,"prototype"); insert(MemberListType_decTypedefMembers,"typedef"); insert(MemberListType_decEnumMembers,"enum"); insert(MemberListType_decFuncMembers,"func"); insert(MemberListType_decVarMembers,"var"); } }; static XmlSectionMapper g_xmlSectionMapper; inline void writeXMLString(FTextStream &t,const char *s) { t << convertToXML(s); } inline void writeXMLCodeString(FTextStream &t,const char *s, int &col) { char c; while ((c=*s++)) { switch(c) { case '\t': { static int tabSize = Config_getInt("TAB_SIZE"); int spacesToNextTabStop = tabSize - (col%tabSize); col+=spacesToNextTabStop; while (spacesToNextTabStop--) t << "<sp/>"; break; } case ' ': t << "<sp/>"; col++; break; case '<': t << "&lt;"; col++; break; case '>': t << "&gt;"; col++; break; case '&': t << "&amp;"; col++; break; case '\'': t << "&apos;"; col++; break; case '"': t << "&quot;"; col++; break; default: t << c; col++; break; } } } static void writeXMLHeader(FTextStream &t) { t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; t << "<doxygen xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"compound.xsd\" "; t << "version=\"" << versionString << "\">" << endl; } static void writeCombineScript() { QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/combine.xslt"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); t << "<!-- XSLT script to combine the generated output into a single file. \n" " If you have xsltproc you could use:\n" " xsltproc combine.xslt index.xml >all.xml\n" "-->\n" "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n" " <xsl:output method=\"xml\" version=\"1.0\" indent=\"no\" standalone=\"yes\" />\n" " <xsl:template match=\"/\">\n" " <doxygen version=\"{doxygenindex/@version}\">\n" " <!-- Load all doxgen generated xml files -->\n" " <xsl:for-each select=\"doxygenindex/compound\">\n" " <xsl:copy-of select=\"document( concat( @refid, '.xml' ) )/doxygen/*\" />\n" " </xsl:for-each>\n" " </doxygen>\n" " </xsl:template>\n" "</xsl:stylesheet>\n"; } void writeXMLLink(FTextStream &t,const char *extRef,const char *compoundId, const char *anchorId,const char *text,const char *tooltip) { t << "<ref refid=\"" << compoundId; if (anchorId) t << "_1" << anchorId; t << "\" kindref=\""; if (anchorId) t << "member"; else t << "compound"; t << "\""; if (extRef) t << " external=\"" << extRef << "\""; if (tooltip) t << " tooltip=\"" << convertToXML(tooltip) << "\""; t << ">"; writeXMLString(t,text); t << "</ref>"; } /** Implements TextGeneratorIntf for an XML stream. */ class TextGeneratorXMLImpl : public TextGeneratorIntf { public: TextGeneratorXMLImpl(FTextStream &t): m_t(t) {} void writeString(const char *s,bool /*keepSpaces*/) const { writeXMLString(m_t,s); } void writeBreak(int) const {} void writeLink(const char *extRef,const char *file, const char *anchor,const char *text ) const { writeXMLLink(m_t,extRef,file,anchor,text,0); } private: FTextStream &m_t; }; /** Helper class representing a stack of objects stored by value */ template<class T> class ValStack { public: ValStack() : m_values(10), m_sp(0), m_size(10) {} virtual ~ValStack() {} ValStack(const ValStack<T> &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; } ValStack &operator=(const ValStack<T> &s) { m_values=s.m_values.copy(); m_sp=s.m_sp; m_size=s.m_size; return *this; } void push(T v) { m_sp++; if (m_sp>=m_size) { m_size+=10; m_values.resize(m_size); } m_values[m_sp]=v; } T pop() { ASSERT(m_sp!=0); return m_values[m_sp--]; } T& top() { ASSERT(m_sp!=0); return m_values[m_sp]; } bool isEmpty() { return m_sp==0; } uint count() const { return m_sp; } private: QArray<T> m_values; int m_sp; int m_size; }; /** Generator for producing XML formatted source code. */ class XMLCodeGenerator : public CodeOutputInterface { public: XMLCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), m_insideSpecialHL(FALSE) {} virtual ~XMLCodeGenerator() { } void codify(const char *text) { XML_DB(("(codify \"%s\")\n",text)); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } writeXMLCodeString(m_t,text,col); } void writeCodeLink(const char *ref,const char *file, const char *anchor,const char *name, const char *tooltip) { XML_DB(("(writeCodeLink)\n")); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } writeXMLLink(m_t,ref,file,anchor,name,tooltip); col+=qstrlen(name); } void startCodeLine(bool) { XML_DB(("(startCodeLine)\n")); m_t << "<codeline"; if (m_lineNumber!=-1) { m_t << " lineno=\"" << m_lineNumber << "\""; if (!m_refId.isEmpty()) { m_t << " refid=\"" << m_refId << "\""; if (m_isMemberRef) { m_t << " refkind=\"member\""; } else { m_t << " refkind=\"compound\""; } } if (!m_external.isEmpty()) { m_t << " external=\"" << m_external << "\""; } } m_t << ">"; m_insideCodeLine=TRUE; col=0; } void endCodeLine() { XML_DB(("(endCodeLine)\n")); if (!m_insideSpecialHL && !m_normalHLNeedStartTag) { m_t << "</highlight>"; m_normalHLNeedStartTag=TRUE; } m_t << "</codeline>" << endl; // non DocBook m_lineNumber = -1; m_refId.resize(0); m_external.resize(0); m_insideCodeLine=FALSE; } void startCodeAnchor(const char *id) { XML_DB(("(startCodeAnchor)\n")); if (m_insideCodeLine && !m_insideSpecialHL && m_normalHLNeedStartTag) { m_t << "<highlight class=\"normal\">"; m_normalHLNeedStartTag=FALSE; } m_t << "<anchor id=\"" << id << "\">"; } void endCodeAnchor() { XML_DB(("(endCodeAnchor)\n")); m_t << "</anchor>"; } void startFontClass(const char *colorClass) { XML_DB(("(startFontClass)\n")); if (m_insideCodeLine && !m_insideSpecialHL && !m_normalHLNeedStartTag) { m_t << "</highlight>"; m_normalHLNeedStartTag=TRUE; } m_t << "<highlight class=\"" << colorClass << "\">"; // non DocBook m_insideSpecialHL=TRUE; } void endFontClass() { XML_DB(("(endFontClass)\n")); m_t << "</highlight>"; // non DocBook m_insideSpecialHL=FALSE; } void writeCodeAnchor(const char *) { XML_DB(("(writeCodeAnchor)\n")); } void writeLineNumber(const char *extRef,const char *compId, const char *anchorId,int l) { XML_DB(("(writeLineNumber)\n")); // we remember the information provided here to use it // at the <codeline> start tag. m_lineNumber = l; if (compId) { m_refId=compId; if (anchorId) m_refId+=(QCString)"_1"+anchorId; m_isMemberRef = anchorId!=0; if (extRef) m_external=extRef; } } void linkableSymbol(int, const char *,Definition *,Definition *) { } void setCurrentDoc(Definition *,const char *,bool) { } void addWord(const char *,bool) { } void finish() { if (m_insideCodeLine) endCodeLine(); } private: FTextStream &m_t; QCString m_refId; QCString m_external; int m_lineNumber; bool m_isMemberRef; int col; bool m_insideCodeLine; bool m_normalHLNeedStartTag; bool m_insideSpecialHL; }; static void writeTemplateArgumentList(ArgumentList *al, FTextStream &t, Definition *scope, FileDef *fileScope, int indent) { QCString indentStr; indentStr.fill(' ',indent); if (al) { t << indentStr << "<templateparamlist>" << endl; ArgumentListIterator ali(*al); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << indentStr << " <param>" << endl; if (!a->type.isEmpty()) { t << indentStr << " <type>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->type); t << "</type>" << endl; } if (!a->name.isEmpty()) { t << indentStr << " <declname>" << a->name << "</declname>" << endl; t << indentStr << " <defname>" << a->name << "</defname>" << endl; } if (!a->defval.isEmpty()) { t << indentStr << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a->defval); t << "</defval>" << endl; } t << indentStr << " </param>" << endl; } t << indentStr << "</templateparamlist>" << endl; } } static void writeMemberTemplateLists(MemberDef *md,FTextStream &t) { LockingPtr<ArgumentList> templMd = md->templateArguments(); if (templMd!=0) // function template prefix { writeTemplateArgumentList(templMd.pointer(),t,md->getClassDef(),md->getFileDef(),8); } } static void writeTemplateList(ClassDef *cd,FTextStream &t) { writeTemplateArgumentList(cd->templateArguments(),t,cd,0,4); } static void writeXMLDocBlock(FTextStream &t, const QCString &fileName, int lineNr, Definition *scope, MemberDef * md, const QCString &text) { QCString stext = text.stripWhiteSpace(); if (stext.isEmpty()) return; // convert the documentation string into an abstract syntax tree DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,text+"\n",FALSE,FALSE); // create a code generator XMLCodeGenerator *xmlCodeGen = new XMLCodeGenerator(t); // create a parse tree visitor for XML XmlDocVisitor *visitor = new XmlDocVisitor(t,*xmlCodeGen); // visit all nodes root->accept(visitor); // clean up delete visitor; delete xmlCodeGen; delete root; } void writeXMLCodeBlock(FTextStream &t,FileDef *fd) { ParserInterface *pIntf=Doxygen::parserManager->getParser(fd->getDefFileExtension()); pIntf->resetCodeParserState(); XMLCodeGenerator *xmlGen = new XMLCodeGenerator(t); pIntf->parseCode(*xmlGen, // codeOutIntf 0, // scopeName fileToString(fd->absFilePath(),Config_getBool("FILTER_SOURCE_FILES")), FALSE, // isExampleBlock 0, // exampleName fd, // fileDef -1, // startLine -1, // endLine FALSE, // inlineFragement 0, // memberDef TRUE // showLineNumbers ); xmlGen->finish(); delete xmlGen; } static void writeMemberReference(FTextStream &t,Definition *def,MemberDef *rmd,const char *tagName) { QCString scope = rmd->getScopeString(); QCString name = rmd->name(); if (!scope.isEmpty() && scope!=def->name()) { name.prepend(scope+getLanguageSpecificSeparator(rmd->getLanguage())); } t << " <" << tagName << " refid=\""; t << rmd->getOutputFileBase() << "_1" << rmd->anchor() << "\""; if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef()) { t << " compoundref=\"" << rmd->getBodyDef()->getOutputFileBase() << "\""; t << " startline=\"" << rmd->getStartBodyLine() << "\""; if (rmd->getEndBodyLine()!=-1) { t << " endline=\"" << rmd->getEndBodyLine() << "\""; } } t << ">" << convertToXML(name) << "</" << tagName << ">" << endl; } static void stripQualifiers(QCString &typeStr) { bool done=FALSE; while (!done) { if (typeStr.stripPrefix("static ")); else if (typeStr.stripPrefix("virtual ")); else if (typeStr.stripPrefix("volatile ")); else if (typeStr=="virtual") typeStr=""; else done=TRUE; } } static QCString classOutputFileBase(ClassDef *cd) { //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES"); //if (inlineGroupedClasses && cd->partOfGroups()!=0) return cd->getOutputFileBase(); //else // return cd->getOutputFileBase(); } static QCString memberOutputFileBase(MemberDef *md) { //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES"); //if (inlineGroupedClasses && md->getClassDef() && md->getClassDef()->partOfGroups()!=0) // return md->getClassDef()->getXmlOutputFileBase(); //else // return md->getOutputFileBase(); return md->getOutputFileBase(); } static void generateXMLForMember(MemberDef *md,FTextStream &ti,FTextStream &t,Definition *def) { // + declaration/definition arg lists // + reimplements // + reimplementedBy // + exceptions // + const/volatile specifiers // - examples // + source definition // + source references // + source referenced by // - body code // + template arguments // (templateArguments(), definitionTemplateParameterLists()) // - call graph // enum values are written as part of the enum if (md->memberType()==MemberType_EnumValue) return; if (md->isHidden()) return; //if (md->name().at(0)=='@') return; // anonymous member // group members are only visible in their group //if (def->definitionType()!=Definition::TypeGroup && md->getGroupDef()) return; QCString memType; bool isFunc=FALSE; switch (md->memberType()) { case MemberType_Define: memType="define"; break; case MemberType_EnumValue: ASSERT(0); break; case MemberType_Property: memType="property"; break; case MemberType_Event: memType="event"; break; case MemberType_Variable: memType="variable"; break; case MemberType_Typedef: memType="typedef"; break; case MemberType_Enumeration: memType="enum"; break; case MemberType_Function: memType="function"; isFunc=TRUE; break; case MemberType_Signal: memType="signal"; isFunc=TRUE; break; case MemberType_Friend: memType="friend"; isFunc=TRUE; break; case MemberType_DCOP: memType="dcop"; isFunc=TRUE; break; case MemberType_Slot: memType="slot"; isFunc=TRUE; break; } ti << " <member refid=\"" << memberOutputFileBase(md) << "_1" << md->anchor() << "\" kind=\"" << memType << "\"><name>" << convertToXML(md->name()) << "</name></member>" << endl; QCString scopeName; if (md->getClassDef()) scopeName=md->getClassDef()->name(); else if (md->getNamespaceDef()) scopeName=md->getNamespaceDef()->name(); t << " <memberdef kind=\""; //enum { define_t,variable_t,typedef_t,enum_t,function_t } xmlType = function_t; t << memType << "\" id=\""; if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup) { t << md->getGroupDef()->getOutputFileBase(); } else { t << memberOutputFileBase(md); } t << "_1" // encoded `:' character (see util.cpp:convertNameToFile) << md->anchor(); t << "\" prot=\""; switch(md->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\""; t << " static=\""; if (md->isStatic()) t << "yes"; else t << "no"; t << "\""; if (isFunc) { LockingPtr<ArgumentList> al = md->argumentList(); t << " const=\""; if (al!=0 && al->constSpecifier) t << "yes"; else t << "no"; t << "\""; t << " explicit=\""; if (md->isExplicit()) t << "yes"; else t << "no"; t << "\""; t << " inline=\""; if (md->isInline()) t << "yes"; else t << "no"; t << "\""; if (md->isFinal()) { t << " final=\"yes\""; } if (md->isSealed()) { t << " sealed=\"yes\""; } if (md->isNew()) { t << " new=\"yes\""; } if (md->isOptional()) { t << " optional=\"yes\""; } if (md->isRequired()) { t << " required=\"yes\""; } t << " virt=\""; switch (md->virtualness()) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; default: ASSERT(0); } t << "\""; } if (md->memberType() == MemberType_Variable) { //ArgumentList *al = md->argumentList(); //t << " volatile=\""; //if (al && al->volatileSpecifier) t << "yes"; else t << "no"; t << " mutable=\""; if (md->isMutable()) t << "yes"; else t << "no"; t << "\""; if (md->isInitonly()) { t << " initonly=\"yes\""; } } else if (md->memberType() == MemberType_Property) { t << " readable=\""; if (md->isReadable()) t << "yes"; else t << "no"; t << "\""; t << " writable=\""; if (md->isWritable()) t << "yes"; else t << "no"; t << "\""; t << " gettable=\""; if (md->isGettable()) t << "yes"; else t << "no"; t << "\""; t << " settable=\""; if (md->isSettable()) t << "yes"; else t << "no"; t << "\""; if (md->isAssign() || md->isCopy() || md->isRetain() || md->isStrong() || md->isWeak()) { t << " accessor=\""; if (md->isAssign()) t << "assign"; else if (md->isCopy()) t << "copy"; else if (md->isRetain()) t << "retain"; else if (md->isStrong()) t << "strong"; else if (md->isWeak()) t << "weak"; t << "\""; } } else if (md->memberType() == MemberType_Event) { t << " add=\""; if (md->isAddable()) t << "yes"; else t << "no"; t << "\""; t << " remove=\""; if (md->isRemovable()) t << "yes"; else t << "no"; t << "\""; t << " raise=\""; if (md->isRaisable()) t << "yes"; else t << "no"; t << "\""; } t << ">" << endl; if (md->memberType()!=MemberType_Define && md->memberType()!=MemberType_Enumeration ) { if (md->memberType()!=MemberType_Typedef) { writeMemberTemplateLists(md,t); } QCString typeStr = md->typeString(); //replaceAnonymousScopes(md->typeString()); stripQualifiers(typeStr); t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,typeStr); t << "</type>" << endl; t << " <definition>" << convertToXML(md->definition()) << "</definition>" << endl; t << " <argsstring>" << convertToXML(md->argsString()) << "</argsstring>" << endl; } t << " <name>" << convertToXML(md->name()) << "</name>" << endl; if (md->memberType() == MemberType_Property) { if (md->isReadable()) t << " <read>" << convertToXML(md->getReadAccessor()) << "</read>" << endl; if (md->isWritable()) t << " <write>" << convertToXML(md->getWriteAccessor()) << "</write>" << endl; } if (md->memberType()==MemberType_Variable && md->bitfieldString()) { QCString bitfield = md->bitfieldString(); if (bitfield.at(0)==':') bitfield=bitfield.mid(1); t << " <bitfield>" << bitfield << "</bitfield>" << endl; } MemberDef *rmd = md->reimplements(); if (rmd) { t << " <reimplements refid=\"" << memberOutputFileBase(rmd) << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << "</reimplements>" << endl; } LockingPtr<MemberList> rbml = md->reimplementedBy(); if (rbml!=0) { MemberListIterator mli(*rbml); for (mli.toFirst();(rmd=mli.current());++mli) { t << " <reimplementedby refid=\"" << memberOutputFileBase(rmd) << "_1" << rmd->anchor() << "\">" << convertToXML(rmd->name()) << "</reimplementedby>" << endl; } } if (isFunc) //function { LockingPtr<ArgumentList> declAl = md->declArgumentList(); LockingPtr<ArgumentList> defAl = md->argumentList(); if (declAl!=0 && declAl->count()>0) { ArgumentListIterator declAli(*declAl); ArgumentListIterator defAli(*defAl); Argument *a; for (declAli.toFirst();(a=declAli.current());++declAli) { Argument *defArg = defAli.current(); t << " <param>" << endl; if (!a->attrib.isEmpty()) { t << " <attributes>"; writeXMLString(t,a->attrib); t << "</attributes>" << endl; } if (!a->type.isEmpty()) { t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->type); t << "</type>" << endl; } if (!a->name.isEmpty()) { t << " <declname>"; writeXMLString(t,a->name); t << "</declname>" << endl; } if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name) { t << " <defname>"; writeXMLString(t,defArg->name); t << "</defname>" << endl; } if (!a->array.isEmpty()) { t << " <array>"; writeXMLString(t,a->array); t << "</array>" << endl; } if (!a->defval.isEmpty()) { t << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a->defval); t << "</defval>" << endl; } if (defArg && defArg->hasDocumentation()) { t << " <briefdescription>"; writeXMLDocBlock(t,md->getDefFileName(),md->getDefLine(), md->getOuterScope(),md,defArg->docs); t << "</briefdescription>" << endl; } t << " </param>" << endl; if (defArg) ++defAli; } } } else if (md->memberType()==MemberType_Define && md->argsString()) // define { if (md->argumentList()->count()==0) // special case for "foo()" to // disguish it from "foo". { t << " <param></param>" << endl; } else { ArgumentListIterator ali(*md->argumentList()); Argument *a; for (ali.toFirst();(a=ali.current());++ali) { t << " <param><defname>" << a->type << "</defname></param>" << endl; } } } // avoid that extremely large tables are written to the output. // todo: it's better to adhere to MAX_INITIALIZER_LINES. if (!md->initializer().isEmpty() && md->initializer().length()<2000) { t << " <initializer>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->initializer()); t << "</initializer>" << endl; } if (md->excpString()) { t << " <exceptions>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->excpString()); t << "</exceptions>" << endl; } if (md->memberType()==MemberType_Enumeration) // enum { LockingPtr<MemberList> enumFields = md->enumFieldList(); if (enumFields!=0) { MemberListIterator emli(*enumFields); MemberDef *emd; for (emli.toFirst();(emd=emli.current());++emli) { ti << " <member refid=\"" << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\" kind=\"enumvalue\"><name>" << convertToXML(emd->name()) << "</name></member>" << endl; t << " <enumvalue id=\"" << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\" prot=\""; switch (emd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\">" << endl; t << " <name>"; writeXMLString(t,emd->name()); t << "</name>" << endl; if (!emd->initializer().isEmpty()) { t << " <initializer>"; writeXMLString(t,emd->initializer()); t << "</initializer>" << endl; } t << " <briefdescription>" << endl; writeXMLDocBlock(t,emd->briefFile(),emd->briefLine(),emd->getOuterScope(),emd,emd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,emd->docFile(),emd->docLine(),emd->getOuterScope(),emd,emd->documentation()); t << " </detaileddescription>" << endl; t << " </enumvalue>" << endl; } } } t << " <briefdescription>" << endl; writeXMLDocBlock(t,md->briefFile(),md->briefLine(),md->getOuterScope(),md,md->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation()); t << " </detaileddescription>" << endl; t << " <inbodydescription>" << endl; writeXMLDocBlock(t,md->docFile(),md->inbodyLine(),md->getOuterScope(),md,md->inbodyDocumentation()); t << " </inbodydescription>" << endl; if (md->getDefLine()!=-1) { t << " <location file=\"" << md->getDefFileName() << "\" line=\"" << md->getDefLine() << "\""; if (md->getStartBodyLine()!=-1) { FileDef *bodyDef = md->getBodyDef(); if (bodyDef) { t << " bodyfile=\"" << bodyDef->absFilePath() << "\""; } t << " bodystart=\"" << md->getStartBodyLine() << "\" bodyend=\"" << md->getEndBodyLine() << "\""; } t << "/>" << endl; } //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers()); LockingPtr<MemberSDict> mdict = md->getReferencesMembers(); if (mdict!=0) { MemberSDict::Iterator mdi(*mdict); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"references"); } } mdict = md->getReferencedByMembers(); if (mdict!=0) { MemberSDict::Iterator mdi(*mdict); MemberDef *rmd; for (mdi.toFirst();(rmd=mdi.current());++mdi) { writeMemberReference(t,def,rmd,"referencedby"); } } t << " </memberdef>" << endl; } static void generateXMLSection(Definition *d,FTextStream &ti,FTextStream &t, MemberList *ml,const char *kind,const char *header=0, const char *documentation=0) { if (ml==0) return; MemberListIterator mli(*ml); MemberDef *md; int count=0; for (mli.toFirst();(md=mli.current());++mli) { // namespace members are also inserted in the file scope, but // to prevent this duplication in the XML output, we filter those here. if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) { count++; } } if (count==0) return; // empty list t << " <sectiondef kind=\"" << kind << "\">" << endl; if (header) { t << " <header>" << convertToXML(header) << "</header>" << endl; } if (documentation) { t << " <description>"; writeXMLDocBlock(t,d->docFile(),d->docLine(),d,0,documentation); t << "</description>" << endl; } for (mli.toFirst();(md=mli.current());++mli) { // namespace members are also inserted in the file scope, but // to prevent this duplication in the XML output, we filter those here. if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) { generateXMLForMember(md,ti,t,d); } } t << " </sectiondef>" << endl; } static void writeListOfAllMembers(ClassDef *cd,FTextStream &t) { t << " <listofallmembers>" << endl; if (cd->memberNameInfoSDict()) { MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict()); MemberNameInfo *mni; for (mnii.toFirst();(mni=mnii.current());++mnii) { MemberNameInfoIterator mii(*mni); MemberInfo *mi; for (mii.toFirst();(mi=mii.current());++mii) { MemberDef *md=mi->memberDef; if (md->name().at(0)!='@') // skip anonymous members { Protection prot = mi->prot; Specifier virt=md->virtualness(); t << " <member refid=\"" << memberOutputFileBase(md) << "_1" << md->anchor() << "\" prot=\""; switch (prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\" virt=\""; switch(virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\""; if (!mi->ambiguityResolutionScope.isEmpty()) { t << " ambiguityscope=\"" << convertToXML(mi->ambiguityResolutionScope) << "\""; } t << "><scope>" << convertToXML(cd->name()) << "</scope><name>" << convertToXML(md->name()) << "</name></member>" << endl; } } } } t << " </listofallmembers>" << endl; } static void writeInnerClasses(const ClassSDict *cl,FTextStream &t) { if (cl) { ClassSDict::Iterator cli(*cl); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { if (!cd->isHidden() && cd->name().find('@')==-1) // skip anonymous scopes { t << " <innerclass refid=\"" << classOutputFileBase(cd) << "\" prot=\""; switch(cd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } t << "\">" << convertToXML(cd->name()) << "</innerclass>" << endl; } } } } static void writeInnerNamespaces(const NamespaceSDict *nl,FTextStream &t) { if (nl) { NamespaceSDict::Iterator nli(*nl); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { if (!nd->isHidden() && nd->name().find('@')==-1) // skip anonymouse scopes { t << " <innernamespace refid=\"" << nd->getOutputFileBase() << "\">" << convertToXML(nd->name()) << "</innernamespace>" << endl; } } } } static void writeInnerFiles(const FileList *fl,FTextStream &t) { if (fl) { QListIterator<FileDef> fli(*fl); FileDef *fd; for (fli.toFirst();(fd=fli.current());++fli) { t << " <innerfile refid=\"" << fd->getOutputFileBase() << "\">" << convertToXML(fd->name()) << "</innerfile>" << endl; } } } static void writeInnerPages(const PageSDict *pl,FTextStream &t) { if (pl) { PageSDict::Iterator pli(*pl); PageDef *pd; for (pli.toFirst();(pd=pli.current());++pli) { t << " <innerpage refid=\"" << pd->getOutputFileBase(); if (pd->getGroupDef()) { t << "_" << pd->name(); } t << "\">" << convertToXML(pd->title()) << "</innerpage>" << endl; } } } static void writeInnerGroups(const GroupList *gl,FTextStream &t) { if (gl) { GroupListIterator gli(*gl); GroupDef *sgd; for (gli.toFirst();(sgd=gli.current());++gli) { t << " <innergroup refid=\"" << sgd->getOutputFileBase() << "\">" << convertToXML(sgd->groupTitle()) << "</innergroup>" << endl; } } } static void writeInnerDirs(const DirList *dl,FTextStream &t) { if (dl) { QListIterator<DirDef> subdirs(*dl); DirDef *subdir; for (subdirs.toFirst();(subdir=subdirs.current());++subdirs) { t << " <innerdir refid=\"" << subdir->getOutputFileBase() << "\">" << convertToXML(subdir->displayName()) << "</innerdir>" << endl; } } } static void generateXMLForClass(ClassDef *cd,FTextStream &ti) { // + brief description // + detailed description // + template argument list(s) // - include file // + member groups // + inheritance diagram // + list of direct super classes // + list of direct sub classes // + list of inner classes // + collaboration diagram // + list of all members // + user defined member sections // + standard member sections // + detailed member documentation // - examples using the class if (cd->isReference()) return; // skip external references. if (cd->isHidden()) return; // skip hidden classes. if (cd->name().find('@')!=-1) return; // skip anonymous compounds. if (cd->templateMaster()!=0) return; // skip generated template instances. if (cd->isArtificial()) return; // skip artificially created classes msg("Generating XML output for class %s\n",cd->name().data()); ti << " <compound refid=\"" << classOutputFileBase(cd) << "\" kind=\"" << cd->compoundTypeString() << "\"><name>" << convertToXML(cd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+ classOutputFileBase(cd)+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << classOutputFileBase(cd) << "\" kind=\"" << cd->compoundTypeString() << "\" prot=\""; switch (cd->protection()) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: t << "package"; break; } if (cd->isFinal()) t << "\" final=\"yes"; if (cd->isSealed()) t << "\" sealed=\"yes"; if (cd->isAbstract()) t << "\" abstract=\"yes"; t << "\">" << endl; t << " <compoundname>"; writeXMLString(t,cd->name()); t << "</compoundname>" << endl; if (cd->baseClasses()) { BaseClassListIterator bcli(*cd->baseClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " <basecompoundref "; if (bcd->classDef->isLinkable()) { t << "refid=\"" << classOutputFileBase(bcd->classDef) << "\" "; } t << "prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: ASSERT(0); break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t <<"pure-virtual"; break; } t << "\">"; if (!bcd->templSpecifiers.isEmpty()) { t << convertToXML( insertTemplateSpecifierInScope( bcd->classDef->name(),bcd->templSpecifiers) ); } else { t << convertToXML(bcd->classDef->displayName()); } t << "</basecompoundref>" << endl; } } if (cd->subClasses()) { BaseClassListIterator bcli(*cd->subClasses()); BaseClassDef *bcd; for (bcli.toFirst();(bcd=bcli.current());++bcli) { t << " <derivedcompoundref refid=\"" << classOutputFileBase(bcd->classDef) << "\" prot=\""; switch (bcd->prot) { case Public: t << "public"; break; case Protected: t << "protected"; break; case Private: t << "private"; break; case Package: ASSERT(0); break; } t << "\" virt=\""; switch(bcd->virt) { case Normal: t << "non-virtual"; break; case Virtual: t << "virtual"; break; case Pure: t << "pure-virtual"; break; } t << "\">" << convertToXML(bcd->classDef->displayName()) << "</derivedcompoundref>" << endl; } } IncludeInfo *ii=cd->includeInfo(); if (ii) { QCString nm = ii->includeName; if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName(); if (!nm.isEmpty()) { t << " <includes"; if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << ii->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (ii->local ? "yes" : "no") << "\">"; t << nm; t << "</includes>" << endl; } } writeInnerClasses(cd->getClassSDict(),t); writeTemplateList(cd,t); if (cd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(cd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(cd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_detailedLists)==0) { generateXMLSection(cd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(cd,ti,t,cd->pubTypes,"public-type"); generateXMLSection(cd,ti,t,cd->pubMethods,"public-func"); generateXMLSection(cd,ti,t,cd->pubAttribs,"public-attrib"); generateXMLSection(cd,ti,t,cd->pubSlots,"public-slot"); generateXMLSection(cd,ti,t,cd->signals,"signal"); generateXMLSection(cd,ti,t,cd->dcopMethods,"dcop-func"); generateXMLSection(cd,ti,t,cd->properties,"property"); generateXMLSection(cd,ti,t,cd->events,"event"); generateXMLSection(cd,ti,t,cd->pubStaticMethods,"public-static-func"); generateXMLSection(cd,ti,t,cd->pubStaticAttribs,"public-static-attrib"); generateXMLSection(cd,ti,t,cd->proTypes,"protected-type"); generateXMLSection(cd,ti,t,cd->proMethods,"protected-func"); generateXMLSection(cd,ti,t,cd->proAttribs,"protected-attrib"); generateXMLSection(cd,ti,t,cd->proSlots,"protected-slot"); generateXMLSection(cd,ti,t,cd->proStaticMethods,"protected-static-func"); generateXMLSection(cd,ti,t,cd->proStaticAttribs,"protected-static-attrib"); generateXMLSection(cd,ti,t,cd->pacTypes,"package-type"); generateXMLSection(cd,ti,t,cd->pacMethods,"package-func"); generateXMLSection(cd,ti,t,cd->pacAttribs,"package-attrib"); generateXMLSection(cd,ti,t,cd->pacStaticMethods,"package-static-func"); generateXMLSection(cd,ti,t,cd->pacStaticAttribs,"package-static-attrib"); generateXMLSection(cd,ti,t,cd->priTypes,"private-type"); generateXMLSection(cd,ti,t,cd->priMethods,"private-func"); generateXMLSection(cd,ti,t,cd->priAttribs,"private-attrib"); generateXMLSection(cd,ti,t,cd->priSlots,"private-slot"); generateXMLSection(cd,ti,t,cd->priStaticMethods,"private-static-func"); generateXMLSection(cd,ti,t,cd->priStaticAttribs,"private-static-attrib"); generateXMLSection(cd,ti,t,cd->friends,"friend"); generateXMLSection(cd,ti,t,cd->related,"related"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,cd->briefFile(),cd->briefLine(),cd,0,cd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,cd->docFile(),cd->docLine(),cd,0,cd->documentation()); t << " </detaileddescription>" << endl; DotClassGraph inheritanceGraph(cd,DotNode::Inheritance); if (!inheritanceGraph.isTrivial()) { t << " <inheritancegraph>" << endl; inheritanceGraph.writeXML(t); t << " </inheritancegraph>" << endl; } DotClassGraph collaborationGraph(cd,DotNode::Collaboration); if (!collaborationGraph.isTrivial()) { t << " <collaborationgraph>" << endl; collaborationGraph.writeXML(t); t << " </collaborationgraph>" << endl; } t << " <location file=\"" << cd->getDefFileName() << "\" line=\"" << cd->getDefLine() << "\""; if (cd->getStartBodyLine()!=-1) { FileDef *bodyDef = cd->getBodyDef(); if (bodyDef) { t << " bodyfile=\"" << bodyDef->absFilePath() << "\""; } t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\"" << cd->getEndBodyLine() << "\""; } t << "/>" << endl; writeListOfAllMembers(cd,t); t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForNamespace(NamespaceDef *nd,FTextStream &ti) { // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + location // - files containing (parts of) the namespace definition if (nd->isReference() || nd->isHidden()) return; // skip external references ti << " <compound refid=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\"" << "><name>" << convertToXML(nd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+nd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\">" << endl; t << " <compoundname>"; writeXMLString(t,nd->name()); t << "</compoundname>" << endl; writeInnerClasses(nd->getClassSDict(),t); writeInnerNamespaces(nd->getNamespaceSDict(),t); if (nd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(nd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(nd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(nd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(nd,ti,t,&nd->decDefineMembers,"define"); generateXMLSection(nd,ti,t,&nd->decProtoMembers,"prototype"); generateXMLSection(nd,ti,t,&nd->decTypedefMembers,"typedef"); generateXMLSection(nd,ti,t,&nd->decEnumMembers,"enum"); generateXMLSection(nd,ti,t,&nd->decFuncMembers,"func"); generateXMLSection(nd,ti,t,&nd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,nd->docFile(),nd->docLine(),nd,0,nd->documentation()); t << " </detaileddescription>" << endl; t << " <location file=\"" << nd->getDefFileName() << "\" line=\"" << nd->getDefLine() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForFile(FileDef *fd,FTextStream &ti) { // + includes files // + includedby files // + include graph // + included by graph // + contained class definitions // + contained namespace definitions // + member groups // + normal members // + brief desc // + detailed desc // + source code // + location // - number of lines if (fd->isReference()) return; // skip external references ti << " <compound refid=\"" << fd->getOutputFileBase() << "\" kind=\"file\"><name>" << convertToXML(fd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+fd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << fd->getOutputFileBase() << "\" kind=\"file\">" << endl; t << " <compoundname>"; writeXMLString(t,fd->name()); t << "</compoundname>" << endl; IncludeInfo *inc; if (fd->includeFileList()) { QListIterator<IncludeInfo> ili1(*fd->includeFileList()); for (ili1.toFirst();(inc=ili1.current());++ili1) { t << " <includes"; if (inc->fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "</includes>" << endl; } } if (fd->includedByFileList()) { QListIterator<IncludeInfo> ili2(*fd->includedByFileList()); for (ili2.toFirst();(inc=ili2.current());++ili2) { t << " <includedby"; if (inc->fileDef && !inc->fileDef->isReference()) // TODO: support external references { t << " refid=\"" << inc->fileDef->getOutputFileBase() << "\""; } t << " local=\"" << (inc->local ? "yes" : "no") << "\">"; t << inc->includeName; t << "</includedby>" << endl; } } DotInclDepGraph incDepGraph(fd,FALSE); if (!incDepGraph.isTrivial()) { t << " <incdepgraph>" << endl; incDepGraph.writeXML(t); t << " </incdepgraph>" << endl; } DotInclDepGraph invIncDepGraph(fd,TRUE); if (!invIncDepGraph.isTrivial()) { t << " <invincdepgraph>" << endl; invIncDepGraph.writeXML(t); t << " </invincdepgraph>" << endl; } if (fd->getClassSDict()) { writeInnerClasses(fd->getClassSDict(),t); } if (fd->getNamespaceSDict()) { writeInnerNamespaces(fd->getNamespaceSDict(),t); } if (fd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(fd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(fd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(fd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(fd,ti,t,fd->decDefineMembers,"define"); generateXMLSection(fd,ti,t,fd->decProtoMembers,"prototype"); generateXMLSection(fd,ti,t,fd->decTypedefMembers,"typedef"); generateXMLSection(fd,ti,t,fd->decEnumMembers,"enum"); generateXMLSection(fd,ti,t,fd->decFuncMembers,"func"); generateXMLSection(fd,ti,t,fd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,fd->briefFile(),fd->briefLine(),fd,0,fd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,fd->docFile(),fd->docLine(),fd,0,fd->documentation()); t << " </detaileddescription>" << endl; if (Config_getBool("XML_PROGRAMLISTING")) { t << " <programlisting>" << endl; writeXMLCodeBlock(t,fd); t << " </programlisting>" << endl; } t << " <location file=\"" << fd->getDefFileName() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForGroup(GroupDef *gd,FTextStream &ti) { // + members // + member groups // + files // + classes // + namespaces // - packages // + pages // + child groups // - examples // + brief description // + detailed description if (gd->isReference()) return; // skip external references ti << " <compound refid=\"" << gd->getOutputFileBase() << "\" kind=\"group\"><name>" << convertToXML(gd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+gd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << gd->getOutputFileBase() << "\" kind=\"group\">" << endl; t << " <compoundname>" << convertToXML(gd->name()) << "</compoundname>" << endl; t << " <title>" << convertToXML(gd->groupTitle()) << "</title>" << endl; writeInnerFiles(gd->getFiles(),t); writeInnerClasses(gd->getClasses(),t); writeInnerNamespaces(gd->getNamespaces(),t); writeInnerPages(gd->getPages(),t); writeInnerGroups(gd->getSubGroups(),t); if (gd->getMemberGroupSDict()) { MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict()); MemberGroup *mg; for (;(mg=mgli.current());++mgli) { generateXMLSection(gd,ti,t,mg->members(),"user-defined",mg->header(), mg->documentation()); } } QListIterator<MemberList> mli(gd->getMemberLists()); MemberList *ml; for (mli.toFirst();(ml=mli.current());++mli) { if ((ml->listType()&MemberListType_declarationLists)!=0) { generateXMLSection(gd,ti,t,ml,g_xmlSectionMapper.find(ml->listType())); } } #if 0 generateXMLSection(gd,ti,t,&gd->decDefineMembers,"define"); generateXMLSection(gd,ti,t,&gd->decProtoMembers,"prototype"); generateXMLSection(gd,ti,t,&gd->decTypedefMembers,"typedef"); generateXMLSection(gd,ti,t,&gd->decEnumMembers,"enum"); generateXMLSection(gd,ti,t,&gd->decFuncMembers,"func"); generateXMLSection(gd,ti,t,&gd->decVarMembers,"var"); #endif t << " <briefdescription>" << endl; writeXMLDocBlock(t,gd->briefFile(),gd->briefLine(),gd,0,gd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,gd->docFile(),gd->docLine(),gd,0,gd->documentation()); t << " </detaileddescription>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForDir(DirDef *dd,FTextStream &ti) { if (dd->isReference()) return; // skip external references ti << " <compound refid=\"" << dd->getOutputFileBase() << "\" kind=\"dir\"><name>" << convertToXML(dd->displayName()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+dd->getOutputFileBase()+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << dd->getOutputFileBase() << "\" kind=\"dir\">" << endl; t << " <compoundname>" << convertToXML(dd->displayName()) << "</compoundname>" << endl; writeInnerDirs(&dd->subDirs(),t); writeInnerFiles(dd->getFiles(),t); t << " <briefdescription>" << endl; writeXMLDocBlock(t,dd->briefFile(),dd->briefLine(),dd,0,dd->briefDescription()); t << " </briefdescription>" << endl; t << " <detaileddescription>" << endl; writeXMLDocBlock(t,dd->docFile(),dd->docLine(),dd,0,dd->documentation()); t << " </detaileddescription>" << endl; t << " <location file=\"" << dd->name() << "\"/>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) { // + name // + title // + documentation const char *kindName = isExample ? "example" : "page"; if (pd->isReference()) return; QCString pageName = pd->getOutputFileBase(); if (pd->getGroupDef()) { pageName+=(QCString)"_"+pd->name(); } if (pageName=="index") pageName="indexpage"; // to prevent overwriting the generated index page. ti << " <compound refid=\"" << pageName << "\" kind=\"" << kindName << "\"><name>" << convertToXML(pd->name()) << "</name>" << endl; QCString outputDirectory = Config_getString("XML_OUTPUT"); QCString fileName=outputDirectory+"/"+pageName+".xml"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << pageName; t << "\" kind=\"" << kindName << "\">" << endl; t << " <compoundname>" << convertToXML(pd->name()) << "</compoundname>" << endl; if (pd==Doxygen::mainPage) // main page is special { QCString title; if (!pd->title().isEmpty() && pd->title().lower()!="notitle") { title = filterTitle(Doxygen::mainPage->title()); } else { title = Config_getString("PROJECT_NAME"); } t << " <title>" << convertToXML(title) << "</title>" << endl; } else { SectionInfo *si = Doxygen::sectionDict->find(pd->name()); if (si) { t << " <title>" << convertToXML(si->title) << "</title>" << endl; } } writeInnerPages(pd->getSubPages(),t); t << " <detaileddescription>" << endl; if (isExample) { writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, pd->documentation()+"\n\\include "+pd->name()); } else { writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, pd->documentation()); } t << " </detaileddescription>" << endl; t << " </compounddef>" << endl; t << "</doxygen>" << endl; ti << " </compound>" << endl; } void generateXML() { // + classes // + namespaces // + files // + groups // + related pages // - examples QCString outputDirectory = Config_getString("XML_OUTPUT"); if (outputDirectory.isEmpty()) { outputDirectory=QDir::currentDirPath().utf8(); } else { QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("error: tag XML_OUTPUT: Output directory `%s' does not " "exist and cannot be created\n",outputDirectory.data()); exit(1); } else if (!Config_getBool("QUIET")) { err("notice: Output directory `%s' does not exist. " "I have created it for you.\n", outputDirectory.data()); } dir.cd(outputDirectory); } outputDirectory=dir.absPath().utf8(); } QDir dir(outputDirectory); if (!dir.exists()) { dir.setPath(QDir::currentDirPath()); if (!dir.mkdir(outputDirectory)) { err("Cannot create directory %s\n",outputDirectory.data()); return; } } QDir xmlDir(outputDirectory); createSubDirs(xmlDir); QCString fileName=outputDirectory+"/index.xsd"; QFile f(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } f.writeBlock(index_xsd,qstrlen(index_xsd)); f.close(); fileName=outputDirectory+"/compound.xsd"; f.setName(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } f.writeBlock(compound_xsd,qstrlen(compound_xsd)); f.close(); fileName=outputDirectory+"/index.xml"; f.setName(fileName); if (!f.open(IO_WriteOnly)) { err("Cannot open file %s for writing!\n",fileName.data()); return; } FTextStream t(&f); //t.setEncoding(FTextStream::UnicodeUTF8); // write index header t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" "; t << "version=\"" << versionString << "\">" << endl; { ClassSDict::Iterator cli(*Doxygen::classSDict); ClassDef *cd; for (cli.toFirst();(cd=cli.current());++cli) { generateXMLForClass(cd,t); } } //{ // ClassSDict::Iterator cli(Doxygen::hiddenClasses); // ClassDef *cd; // for (cli.toFirst();(cd=cli.current());++cli) // { // msg("Generating XML output for class %s\n",cd->name().data()); // generateXMLForClass(cd,t); // } //} NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict); NamespaceDef *nd; for (nli.toFirst();(nd=nli.current());++nli) { msg("Generating XML output for namespace %s\n",nd->name().data()); generateXMLForNamespace(nd,t); } FileNameListIterator fnli(*Doxygen::inputNameList); FileName *fn; for (;(fn=fnli.current());++fnli) { FileNameIterator fni(*fn); FileDef *fd; for (;(fd=fni.current());++fni) { msg("Generating XML output for file %s\n",fd->name().data()); generateXMLForFile(fd,t); } } GroupSDict::Iterator gli(*Doxygen::groupSDict); GroupDef *gd; for (;(gd=gli.current());++gli) { msg("Generating XML output for group %s\n",gd->name().data()); generateXMLForGroup(gd,t); } { PageSDict::Iterator pdi(*Doxygen::pageSDict); PageDef *pd=0; for (pdi.toFirst();(pd=pdi.current());++pdi) { msg("Generating XML output for page %s\n",pd->name().data()); generateXMLForPage(pd,t,FALSE); } } { DirDef *dir; DirSDict::Iterator sdi(*Doxygen::directories); for (sdi.toFirst();(dir=sdi.current());++sdi) { msg("Generate XML output for dir %s\n",dir->name().data()); generateXMLForDir(dir,t); } } { PageSDict::Iterator pdi(*Doxygen::exampleSDict); PageDef *pd=0; for (pdi.toFirst();(pd=pdi.current());++pdi) { msg("Generating XML output for example %s\n",pd->name().data()); generateXMLForPage(pd,t,TRUE); } } if (Doxygen::mainPage) { msg("Generating XML output for the main page\n"); generateXMLForPage(Doxygen::mainPage,t,FALSE); } //t << " </compoundlist>" << endl; t << "</doxygenindex>" << endl; writeCombineScript(); }
bo0ts/doxygen-fixes
src/xmlgen.cpp
C++
gpl-2.0
62,426
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
 //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by CSGenerator. // </auto-generated> //------------------------------------------------------------------------------ using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using jsval = JSApi.jsval; public class JSB_UnityEngine_GUISkin { ////////////////////// GUISkin /////////////////////////////////////// // constructors static bool GUISkin_GUISkin1(JSVCall vc, int argc) { int _this = JSApi.getObject((int)JSApi.GetType.Arg); JSApi.attachFinalizerObject(_this); --argc; int len = argc; if (len == 0) { JSMgr.addJSCSRel(_this, new UnityEngine.GUISkin()); } return true; } // fields // properties static void GUISkin_font(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.font; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.Font arg0 = (UnityEngine.Font)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.font = arg0; } } static void GUISkin_box(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.box; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.box = arg0; } } static void GUISkin_label(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.label; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.label = arg0; } } static void GUISkin_textField(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.textField; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.textField = arg0; } } static void GUISkin_textArea(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.textArea; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.textArea = arg0; } } static void GUISkin_button(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.button; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.button = arg0; } } static void GUISkin_toggle(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.toggle; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.toggle = arg0; } } static void GUISkin_window(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.window; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.window = arg0; } } static void GUISkin_horizontalSlider(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalSlider; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalSlider = arg0; } } static void GUISkin_horizontalSliderThumb(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalSliderThumb; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalSliderThumb = arg0; } } static void GUISkin_verticalSlider(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalSlider; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalSlider = arg0; } } static void GUISkin_verticalSliderThumb(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalSliderThumb; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalSliderThumb = arg0; } } static void GUISkin_horizontalScrollbar(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalScrollbar; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalScrollbar = arg0; } } static void GUISkin_horizontalScrollbarThumb(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalScrollbarThumb; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalScrollbarThumb = arg0; } } static void GUISkin_horizontalScrollbarLeftButton(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalScrollbarLeftButton; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalScrollbarLeftButton = arg0; } } static void GUISkin_horizontalScrollbarRightButton(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.horizontalScrollbarRightButton; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.horizontalScrollbarRightButton = arg0; } } static void GUISkin_verticalScrollbar(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalScrollbar; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalScrollbar = arg0; } } static void GUISkin_verticalScrollbarThumb(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalScrollbarThumb; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalScrollbarThumb = arg0; } } static void GUISkin_verticalScrollbarUpButton(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalScrollbarUpButton; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalScrollbarUpButton = arg0; } } static void GUISkin_verticalScrollbarDownButton(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.verticalScrollbarDownButton; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.verticalScrollbarDownButton = arg0; } } static void GUISkin_scrollView(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.scrollView; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.scrollView = arg0; } } static void GUISkin_customStyles(JSVCall vc) { if (vc.bGet) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.customStyles; var arrRet = result; for (int i = 0; arrRet != null && i < arrRet.Length; i++) { JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]); JSApi.moveSaveID2Arr(i); } JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true); } else { UnityEngine.GUIStyle[] arg0 = JSDataExchangeMgr.GetJSArg<UnityEngine.GUIStyle[]>(() => { int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg); int length = JSApi.getArrayLength(jsObjID); var ret = new UnityEngine.GUIStyle[length]; for (var i = 0; i < length; i++) { JSApi.getElement(jsObjID, i); ret[i] = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove); } return ret; }); UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; _this.customStyles = arg0; } } static void GUISkin_settings(JSVCall vc) { UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj; var result = _this.settings; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } // methods static bool GUISkin_FindStyle__String(JSVCall vc, int argc) { int len = argc; if (len == 1) { System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); JSMgr.datax.setObject((int)JSApi.SetType.Rval, ((UnityEngine.GUISkin)vc.csObj).FindStyle(arg0)); } return true; } static bool GUISkin_GetEnumerator(JSVCall vc, int argc) { int len = argc; if (len == 0) { JSMgr.datax.setObject((int)JSApi.SetType.Rval, ((UnityEngine.GUISkin)vc.csObj).GetEnumerator()); } return true; } static bool GUISkin_GetStyle__String(JSVCall vc, int argc) { int len = argc; if (len == 1) { System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); JSMgr.datax.setObject((int)JSApi.SetType.Rval, ((UnityEngine.GUISkin)vc.csObj).GetStyle(arg0)); } return true; } //register public static void __Register() { JSMgr.CallbackInfo ci = new JSMgr.CallbackInfo(); ci.type = typeof(UnityEngine.GUISkin); ci.fields = new JSMgr.CSCallbackField[] { }; ci.properties = new JSMgr.CSCallbackProperty[] { GUISkin_font, GUISkin_box, GUISkin_label, GUISkin_textField, GUISkin_textArea, GUISkin_button, GUISkin_toggle, GUISkin_window, GUISkin_horizontalSlider, GUISkin_horizontalSliderThumb, GUISkin_verticalSlider, GUISkin_verticalSliderThumb, GUISkin_horizontalScrollbar, GUISkin_horizontalScrollbarThumb, GUISkin_horizontalScrollbarLeftButton, GUISkin_horizontalScrollbarRightButton, GUISkin_verticalScrollbar, GUISkin_verticalScrollbarThumb, GUISkin_verticalScrollbarUpButton, GUISkin_verticalScrollbarDownButton, GUISkin_scrollView, GUISkin_customStyles, GUISkin_settings, }; ci.constructors = new JSMgr.MethodCallBackInfo[] { new JSMgr.MethodCallBackInfo(GUISkin_GUISkin1, ".ctor"), }; ci.methods = new JSMgr.MethodCallBackInfo[] { new JSMgr.MethodCallBackInfo(GUISkin_FindStyle__String, "FindStyle"), new JSMgr.MethodCallBackInfo(GUISkin_GetEnumerator, "GetEnumerator"), new JSMgr.MethodCallBackInfo(GUISkin_GetStyle__String, "GetStyle"), }; JSMgr.allCallbackInfo.Add(ci); } }
2173/protobuf-for-purejsb
Assets/Standard Assets/JSBinding/Generated/JSB_UnityEngine_GUISkin.cs
C#
mit
15,096
[ 30522, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2010-2020 OpenXcom Developers. * * This file is part of OpenXcom. * * OpenXcom is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenXcom is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>. */ #include "ArticleStateCraft.h" //#include <sstream> #include "../Engine/Game.h" #include "../Engine/LocalizedText.h" //#include "../Engine/Palette.h" #include "../Engine/Surface.h" #include "../Interface/Text.h" #include "../Interface/TextButton.h" #include "../Resource/ResourcePack.h" #include "../Ruleset/ArticleDefinition.h" #include "../Ruleset/RuleCraft.h" #include "../Ruleset/Ruleset.h" namespace OpenXcom { /** * cTor. * @param defs - pointer to ArticleDefinitionCraft (ArticleDefinition.h) */ ArticleStateCraft::ArticleStateCraft(const ArticleDefinitionCraft* const defs) : ArticleState(defs->id) { _txtTitle = new Text(210, 32, 5, 24); setPalette(PAL_UFOPAEDIA); ArticleState::initLayout(false); add(_txtTitle); _game->getResourcePack()->getSurface(defs->image_id)->blit(_bg); _btnOk->setColor(uPed_BLUE_SLATE); _btnPrev->setColor(uPed_BLUE_SLATE); _btnNext->setColor(uPed_BLUE_SLATE); _txtTitle->setText(tr(defs->title)); _txtTitle->setColor(uPed_BLUE_SLATE); _txtTitle->setBig(); _txtInfo = new Text( defs->rect_text.width, defs->rect_text.height, defs->rect_text.x, defs->rect_text.y); add(_txtInfo); _txtInfo->setText(tr(defs->text)); _txtInfo->setColor(uPed_BLUE_SLATE); _txtInfo->setWordWrap(); _txtStats = new Text( defs->rect_stats.width, defs->rect_stats.height, defs->rect_stats.x, defs->rect_stats.y); add(_txtStats); _txtStats->setColor(uPed_BLUE_SLATE); _txtStats->setSecondaryColor(uPed_GREEN_SLATE); const RuleCraft* const crRule (_game->getRuleset()->getCraft(defs->id)); int range (crRule->getFuelCapacity()); if (crRule->getRefuelItem().empty() == false) range *= crRule->getTopSpeed(); range /= 6; // six doses per hour on Geoscape. std::wostringstream woststr; woststr << tr("STR_MAXIMUM_SPEED_") .arg(crRule->getTopSpeed()) << L'\n' << tr("STR_ACCELERATION_") .arg(crRule->getAcceleration()) << L'\n' << tr("STR_FUEL_CAPACITY_") .arg(range) << L'\n' << tr("STR_DAMAGE_CAPACITY_") .arg(crRule->getCraftHullCap()); if (crRule->getWeaponCapacity() != 0u) woststr << L'\n' << tr("STR_WEAPON_PODS_") .arg(crRule->getWeaponCapacity()); if (crRule->getSoldierCapacity() != 0) woststr << L'\n' << tr("STR_CARGO_SPACE_") .arg(crRule->getSoldierCapacity()); if (crRule->getVehicleCapacity() != 0) woststr << L'\n' << tr("STR_HWP_CAPACITY_") .arg(crRule->getVehicleCapacity()); _txtStats->setText(woststr.str()); centerSurfaces(); } /** * dTor. */ ArticleStateCraft::~ArticleStateCraft() // virtual. {} }
kevL/0xC_kL
src/Ufopaedia/ArticleStateCraft.cpp
C++
gpl-3.0
3,278
[ 30522, 1013, 1008, 1008, 9385, 2230, 1011, 12609, 2330, 2595, 9006, 9797, 1012, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 2330, 2595, 9006, 1012, 1008, 1008, 2330, 2595, 9006, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 26...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Boost string_algo library slist_traits.hpp header file ---------------------------// // Copyright Pavol Droba 2002-2003. // // 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 updates, documentation, and revision history. #ifndef BOOST_STRING_STD_SLIST_TRAITS_HPP #define BOOST_STRING_STD_SLIST_TRAITS_HPP #include <boost/algorithm/string/config.hpp> #include <boost/algorithm/string/yes_no_type.hpp> #include BOOST_SLIST_HEADER #include <boost/algorithm/string/sequence_traits.hpp> namespace lslboost { namespace algorithm { // SGI's std::slist<> traits -----------------------------------------------// // stable iterators trait template<typename T, typename AllocT> class has_stable_iterators< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > { public: #if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) enum { value = true }; #else BOOST_STATIC_CONSTANT(bool, value=true); #endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) typedef mpl::bool_<has_stable_iterators<T>::value> type; }; // const time insert trait template<typename T, typename AllocT> class has_const_time_insert< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > { public: #if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) enum { value = true }; #else BOOST_STATIC_CONSTANT(bool, value=true); #endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) typedef mpl::bool_<has_const_time_insert<T>::value> type; }; // const time erase trait template<typename T, typename AllocT> class has_const_time_erase< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > { public: #if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) enum { value = true }; #else BOOST_STATIC_CONSTANT(bool, value=true); #endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) typedef mpl::bool_<has_const_time_erase<T>::value> type; }; } // namespace algorithm } // namespace lslboost #endif // BOOST_STRING_STD_LIST_TRAITS_HPP
nihospr01/OpenSpeechPlatform-UCSD
Sources/liblsl/lslboost/boost/algorithm/string/std/slist_traits.hpp
C++
bsd-2-clause
2,242
[ 30522, 1013, 1013, 12992, 5164, 1035, 2632, 3995, 3075, 22889, 2923, 1035, 12955, 1012, 6522, 2361, 20346, 5371, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.xminds.aws.cognito; /** * Maintains SDK configuration. */ public final class CognitoIdentityProviderClientConfig { /** * Maximum threshold for refresh tokens, in milli seconds. */ private static long REFRESH_THRESHOLD_MAX = 1800 * 1000; /** * Minimum threshold for refresh tokens, in milli seconds. */ private static long REFRESH_THRESHOLD_MIN = 0; /** * Threshold for refresh tokens, in milli seconds. * Tokens are refreshed if the session is valid for less than this value. */ private static long refreshThreshold = 300 * 1000; /** * Set the threshold for token refresh. * * @param threshold REQUIRED: Threshold for token refresh in milli seconds. * @throws CognitoParameterInvalidException */ public static void setRefreshThreshold(long threshold) throws CognitoParameterInvalidException { if (threshold > REFRESH_THRESHOLD_MAX || threshold < REFRESH_THRESHOLD_MIN) { throw new CognitoParameterInvalidException(String.format("The value of refreshThreshold must between %d and %d seconds", REFRESH_THRESHOLD_MIN, REFRESH_THRESHOLD_MAX)); } refreshThreshold = threshold; } public static long getRefreshThreshold() { return refreshThreshold; } }
xminds/cognitowrapper
src/main/java/com/xminds/aws/cognito/CognitoIdentityProviderClientConfig.java
Java
gpl-3.0
1,333
[ 30522, 7427, 4012, 1012, 1060, 23356, 2015, 1012, 22091, 2015, 1012, 2522, 29076, 3406, 1025, 1013, 1008, 1008, 1008, 9319, 17371, 2243, 9563, 1012, 1008, 1013, 2270, 2345, 2465, 2522, 29076, 3406, 5178, 16778, 3723, 21572, 17258, 2121, 204...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2009-2010 Gael Guennebaud <gael.guennebaud@inria.fr> // // 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/. #ifndef EIGEN_PRODUCTBASE_H #define EIGEN_PRODUCTBASE_H namespace Eigen { /** \class ProductBase * \ingroup Core_Module * */ namespace internal { template<typename Derived, typename _Lhs, typename _Rhs> struct traits<ProductBase<Derived,_Lhs,_Rhs> > { typedef MatrixXpr XprKind; typedef typename remove_all<_Lhs>::type Lhs; typedef typename remove_all<_Rhs>::type Rhs; typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; typedef typename promote_storage_type<typename traits<Lhs>::StorageKind, typename traits<Rhs>::StorageKind>::ret StorageKind; typedef typename promote_index_type<typename traits<Lhs>::Index, typename traits<Rhs>::Index>::type Index; enum { RowsAtCompileTime = traits<Lhs>::RowsAtCompileTime, ColsAtCompileTime = traits<Rhs>::ColsAtCompileTime, MaxRowsAtCompileTime = traits<Lhs>::MaxRowsAtCompileTime, MaxColsAtCompileTime = traits<Rhs>::MaxColsAtCompileTime, Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0) | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, // Note that EvalBeforeNestingBit and NestByRefBit // are not used in practice because nested is overloaded for products CoeffReadCost = 0 // FIXME why is it needed ? }; }; } #define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ typedef ProductBase<Derived, Lhs, Rhs > Base; \ EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ typedef typename Base::LhsNested LhsNested; \ typedef typename Base::_LhsNested _LhsNested; \ typedef typename Base::LhsBlasTraits LhsBlasTraits; \ typedef typename Base::ActualLhsType ActualLhsType; \ typedef typename Base::_ActualLhsType _ActualLhsType; \ typedef typename Base::RhsNested RhsNested; \ typedef typename Base::_RhsNested _RhsNested; \ typedef typename Base::RhsBlasTraits RhsBlasTraits; \ typedef typename Base::ActualRhsType ActualRhsType; \ typedef typename Base::_ActualRhsType _ActualRhsType; \ using Base::m_lhs; \ using Base::m_rhs; template<typename Derived, typename Lhs, typename Rhs> class ProductBase : public MatrixBase<Derived> { public: typedef MatrixBase<Derived> Base; EIGEN_DENSE_PUBLIC_INTERFACE(ProductBase) typedef typename Lhs::Nested LhsNested; typedef typename internal::remove_all<LhsNested>::type _LhsNested; typedef internal::blas_traits<_LhsNested> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; typedef typename internal::remove_all<ActualLhsType>::type _ActualLhsType; typedef typename internal::traits<Lhs>::Scalar LhsScalar; typedef typename Rhs::Nested RhsNested; typedef typename internal::remove_all<RhsNested>::type _RhsNested; typedef internal::blas_traits<_RhsNested> RhsBlasTraits; typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; typedef typename internal::remove_all<ActualRhsType>::type _ActualRhsType; typedef typename internal::traits<Rhs>::Scalar RhsScalar; // Diagonal of a product: no need to evaluate the arguments because they are going to be evaluated only once typedef CoeffBasedProduct<LhsNested, RhsNested, 0> FullyLazyCoeffBaseProductType; public: typedef typename Base::PlainObject PlainObject; ProductBase(const Lhs& a_lhs, const Rhs& a_rhs) : m_lhs(a_lhs), m_rhs(a_rhs) { eigen_assert(a_lhs.cols() == a_rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); } inline Index rows() const { return m_lhs.rows(); } inline Index cols() const { return m_rhs.cols(); } template<typename Dest> inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,Scalar(1)); } template<typename Dest> inline void addTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(1)); } template<typename Dest> inline void subTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(-1)); } template<typename Dest> inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { derived().scaleAndAddTo(dst,alpha); } const _LhsNested& lhs() const { return m_lhs; } const _RhsNested& rhs() const { return m_rhs; } // Implicit conversion to the nested type (trigger the evaluation of the product) operator const PlainObject& () const { m_result.resize(m_lhs.rows(), m_rhs.cols()); derived().evalTo(m_result); return m_result; } const Diagonal<const FullyLazyCoeffBaseProductType,0> diagonal() const { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); } template<int Index> const Diagonal<FullyLazyCoeffBaseProductType,Index> diagonal() const { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); } const Diagonal<FullyLazyCoeffBaseProductType,Dynamic> diagonal(Index index) const { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); } // restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isnt a Lvalue expression typename Base::CoeffReturnType coeff(Index row, Index col) const { #ifdef EIGEN2_SUPPORT return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum(); #else EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); Matrix<Scalar,1,1> result = *this; return result.coeff(row,col); #endif } typename Base::CoeffReturnType coeff(Index i) const { EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); Matrix<Scalar,1,1> result = *this; return result.coeff(i); } const Scalar& coeffRef(Index row, Index col) const { EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); return derived().coeffRef(row,col); } const Scalar& coeffRef(Index i) const { EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); return derived().coeffRef(i); } protected: LhsNested m_lhs; RhsNested m_rhs; mutable PlainObject m_result; }; // here we need to overload the nested rule for products // such that the nested type is a const reference to a plain matrix namespace internal { template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject> struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject> { typedef PlainObject const& type; }; } template<typename NestedProduct> class ScaledProduct; // Note that these two operator* functions are not defined as member // functions of ProductBase, because, otherwise we would have to // define all overloads defined in MatrixBase. Furthermore, Using // "using Base::operator*" would not work with MSVC. // // Also note that here we accept any compatible scalar types template<typename Derived,typename Lhs,typename Rhs> const ScaledProduct<Derived> operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::Scalar x) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> typename internal::enable_if<!internal::is_same<typename Derived::Scalar,typename Derived::RealScalar>::value, const ScaledProduct<Derived> >::type operator*(const ProductBase<Derived,Lhs,Rhs>& prod, const typename Derived::RealScalar& x) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> const ScaledProduct<Derived> operator*(typename Derived::Scalar x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> typename internal::enable_if<!internal::is_same<typename Derived::Scalar,typename Derived::RealScalar>::value, const ScaledProduct<Derived> >::type operator*(const typename Derived::RealScalar& x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } namespace internal { template<typename NestedProduct> struct traits<ScaledProduct<NestedProduct> > : traits<ProductBase<ScaledProduct<NestedProduct>, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested> > { typedef typename traits<NestedProduct>::StorageKind StorageKind; }; } template<typename NestedProduct> class ScaledProduct : public ProductBase<ScaledProduct<NestedProduct>, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested> { public: typedef ProductBase<ScaledProduct<NestedProduct>, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested> Base; typedef typename Base::Scalar Scalar; typedef typename Base::PlainObject PlainObject; // EIGEN_PRODUCT_PUBLIC_INTERFACE(ScaledProduct) ScaledProduct(const NestedProduct& prod, Scalar x) : Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {} template<typename Dest> inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst, Scalar(1)); } template<typename Dest> inline void addTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(1)); } template<typename Dest> inline void subTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(-1)); } template<typename Dest> inline void scaleAndAddTo(Dest& dst,Scalar a_alpha) const { m_prod.derived().scaleAndAddTo(dst,a_alpha * m_alpha); } const Scalar& alpha() const { return m_alpha; } protected: const NestedProduct& m_prod; Scalar m_alpha; }; /** \internal * Overloaded to perform an efficient C = (A*B).lazy() */ template<typename Derived> template<typename ProductDerived, typename Lhs, typename Rhs> Derived& MatrixBase<Derived>::lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other) { other.derived().evalTo(derived()); return derived(); } } // end namespace Eigen #endif // EIGEN_PRODUCTBASE_H
anders-dc/cppfem
eigen/Eigen/src/Core/ProductBase.h
C
gpl-3.0
10,519
[ 30522, 1013, 1013, 2023, 5371, 2003, 2112, 1997, 1041, 29206, 1010, 1037, 12038, 1039, 1009, 1009, 23561, 3075, 1013, 1013, 2005, 7399, 11208, 1012, 1013, 1013, 1013, 1013, 9385, 1006, 1039, 1007, 2268, 1011, 2230, 28151, 19739, 24336, 2777...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0-google-v5) on Thu Dec 19 17:42:37 EST 2013 --> <title>ReservationDetailsError</title> <meta name="date" content="2013-12-19"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ReservationDetailsError"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../com/google/api/ads/dfp/v201306/RequiredSizeErrorReason.html" title="class in com.google.api.ads.dfp.v201306"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?com/google/api/ads/dfp/v201306/ReservationDetailsError.html" target="_top">Frames</a></li> <li><a href="ReservationDetailsError.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</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>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</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.google.api.ads.dfp.v201306</div> <h2 title="Class ReservationDetailsError" class="title">Class ReservationDetailsError</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html" title="class in com.google.api.ads.dfp.v201306">com.google.api.ads.dfp.v201306.ApiError</a></li> <li> <ul class="inheritance"> <li>com.google.api.ads.dfp.v201306.ReservationDetailsError</li> </ul> </li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Implemented Interfaces:</dt> <dd>java.io.Serializable</dd> </dl> <hr> <br> <pre>public class <span class="strong">ReservationDetailsError</span> extends <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html" title="class in com.google.api.ads.dfp.v201306">ApiError</a> implements java.io.Serializable</pre> <div class="block">Lists all errors associated with LineItem's reservation details.</div> <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../serialized-form.html#com.google.api.ads.dfp.v201306.ReservationDetailsError">Serialized Form</a></dd></dl> </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>Constructor Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#ReservationDetailsError()">ReservationDetailsError</a></strong>()</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colOne"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#ReservationDetailsError(java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.google.api.ads.dfp.v201306.ReservationDetailsErrorReason)">ReservationDetailsError</a></strong>(java.lang.String&nbsp;fieldPath, java.lang.String&nbsp;trigger, java.lang.String&nbsp;errorString, java.lang.String&nbsp;apiErrorType, <a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a>&nbsp;reason)</code>&nbsp;</td> </tr> </table> </li> </ul> <!-- ========== METHOD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="method_summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>boolean</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#equals(java.lang.Object)">equals</a></strong>(java.lang.Object&nbsp;obj)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>static org.apache.axis.encoding.Deserializer</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#getDeserializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)">getDeserializer</a></strong>(java.lang.String&nbsp;mechType, java.lang.Class&nbsp;_javaType, javax.xml.namespace.QName&nbsp;_xmlType)</code> <div class="block">Get Custom Deserializer</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a></code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#getReason()">getReason</a></strong>()</code> <div class="block">Gets the reason value for this ReservationDetailsError.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>static org.apache.axis.encoding.Serializer</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)">getSerializer</a></strong>(java.lang.String&nbsp;mechType, java.lang.Class&nbsp;_javaType, javax.xml.namespace.QName&nbsp;_xmlType)</code> <div class="block">Get Custom Serializer</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code>static org.apache.axis.description.TypeDesc</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#getTypeDesc()">getTypeDesc</a></strong>()</code> <div class="block">Return type metadata object</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>int</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#hashCode()">hashCode</a></strong>()</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><code><strong><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsError.html#setReason(com.google.api.ads.dfp.v201306.ReservationDetailsErrorReason)">setReason</a></strong>(<a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a>&nbsp;reason)</code> <div class="block">Sets the reason value for this ReservationDetailsError.</div> </td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods_inherited_from_class_com.google.api.ads.dfp.v201306.ApiError"> <!-- --> </a> <h3>Methods inherited from class&nbsp;com.google.api.ads.dfp.v201306.<a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html" title="class in com.google.api.ads.dfp.v201306">ApiError</a></h3> <code><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#getApiErrorType()">getApiErrorType</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#getErrorString()">getErrorString</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#getFieldPath()">getFieldPath</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#getTrigger()">getTrigger</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#setApiErrorType(java.lang.String)">setApiErrorType</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#setErrorString(java.lang.String)">setErrorString</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#setFieldPath(java.lang.String)">setFieldPath</a>, <a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#setTrigger(java.lang.String)">setTrigger</a></code></li> </ul> <ul class="blockList"> <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> <!-- --> </a> <h3>Methods inherited from class&nbsp;java.lang.Object</h3> <code>clone, finalize, getClass, 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>Constructor Detail</h3> <a name="ReservationDetailsError()"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>ReservationDetailsError</h4> <pre>public&nbsp;ReservationDetailsError()</pre> </li> </ul> <a name="ReservationDetailsError(java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.google.api.ads.dfp.v201306.ReservationDetailsErrorReason)"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>ReservationDetailsError</h4> <pre>public&nbsp;ReservationDetailsError(java.lang.String&nbsp;fieldPath, java.lang.String&nbsp;trigger, java.lang.String&nbsp;errorString, java.lang.String&nbsp;apiErrorType, <a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a>&nbsp;reason)</pre> </li> </ul> </li> </ul> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method_detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="getReason()"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getReason</h4> <pre>public&nbsp;<a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a>&nbsp;getReason()</pre> <div class="block">Gets the reason value for this ReservationDetailsError.</div> <dl><dt><span class="strong">Returns:</span></dt><dd>reason * The error reason represented by an enum.</dd></dl> </li> </ul> <a name="setReason(com.google.api.ads.dfp.v201306.ReservationDetailsErrorReason)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>setReason</h4> <pre>public&nbsp;void&nbsp;setReason(<a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306">ReservationDetailsErrorReason</a>&nbsp;reason)</pre> <div class="block">Sets the reason value for this ReservationDetailsError.</div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>reason</code> - * The error reason represented by an enum.</dd></dl> </li> </ul> <a name="equals(java.lang.Object)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>equals</h4> <pre>public&nbsp;boolean&nbsp;equals(java.lang.Object&nbsp;obj)</pre> <dl> <dt><strong>Overrides:</strong></dt> <dd><code><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#equals(java.lang.Object)">equals</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html" title="class in com.google.api.ads.dfp.v201306">ApiError</a></code></dd> </dl> </li> </ul> <a name="hashCode()"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>hashCode</h4> <pre>public&nbsp;int&nbsp;hashCode()</pre> <dl> <dt><strong>Overrides:</strong></dt> <dd><code><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html#hashCode()">hashCode</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../com/google/api/ads/dfp/v201306/ApiError.html" title="class in com.google.api.ads.dfp.v201306">ApiError</a></code></dd> </dl> </li> </ul> <a name="getTypeDesc()"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getTypeDesc</h4> <pre>public static&nbsp;org.apache.axis.description.TypeDesc&nbsp;getTypeDesc()</pre> <div class="block">Return type metadata object</div> </li> </ul> <a name="getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)"> <!-- --> </a> <ul class="blockList"> <li class="blockList"> <h4>getSerializer</h4> <pre>public static&nbsp;org.apache.axis.encoding.Serializer&nbsp;getSerializer(java.lang.String&nbsp;mechType, java.lang.Class&nbsp;_javaType, javax.xml.namespace.QName&nbsp;_xmlType)</pre> <div class="block">Get Custom Serializer</div> </li> </ul> <a name="getDeserializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName)"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>getDeserializer</h4> <pre>public static&nbsp;org.apache.axis.encoding.Deserializer&nbsp;getDeserializer(java.lang.String&nbsp;mechType, java.lang.Class&nbsp;_javaType, javax.xml.namespace.QName&nbsp;_xmlType)</pre> <div class="block">Get Custom Deserializer</div> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../index-all.html">Index</a></li> <li><a href="../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../com/google/api/ads/dfp/v201306/RequiredSizeErrorReason.html" title="class in com.google.api.ads.dfp.v201306"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../../../com/google/api/ads/dfp/v201306/ReservationDetailsErrorReason.html" title="class in com.google.api.ads.dfp.v201306"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?com/google/api/ads/dfp/v201306/ReservationDetailsError.html" target="_top">Frames</a></li> <li><a href="ReservationDetailsError.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</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>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
google-code-export/google-api-dfp-java
docs/com/google/api/ads/dfp/v201306/ReservationDetailsError.html
HTML
apache-2.0
18,144
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/bin/bash EXIT_CODE=0 kill_ffmpeg(){ echo "Killing ffmpeg with PID=$ffmpeg_pid" kill -2 "$ffmpeg_pid" wait "$ffmpeg_pid" mkdir -p /tmp/e2e/report/ cp /tmp/ffmpeg_report/* /tmp/e2e/report/ } set -x # Validate selenium base URL if [ -z "$TS_SELENIUM_BASE_URL" ]; then echo "The \"TS_SELENIUM_BASE_URL\" is not set!"; echo "Please, set the \"TS_SELENIUM_BASE_URL\" environment variable." exit 1 fi # Set testing suite if [ -z "$TEST_SUITE" ]; then TEST_SUITE=test-happy-path fi # Launch display mode and VNC server export DISPLAY=':20' Xvfb :20 -screen 0 1920x1080x24 > /dev/null 2>&1 & x11vnc -display :20 -N -forever > /dev/null 2>&1 & echo '' echo '#######################' echo '' echo 'For remote debug connect to the VNC server 0.0.0.0:5920' echo '' echo '#######################' echo '' # Launch selenium server /usr/bin/supervisord --configuration /etc/supervisord.conf & \ export TS_SELENIUM_REMOTE_DRIVER_URL=http://localhost:4444/wd/hub # Check selenium server launching expectedStatus=200 currentTry=1 maximumAttempts=5 while [ $(curl -s -o /dev/null -w "%{http_code}" --fail http://localhost:4444/wd/hub/status) != $expectedStatus ]; do if (( currentTry > maximumAttempts )); then status=$(curl -s -o /dev/null -w "%{http_code}" --fail http://localhost:4444/wd/hub/status) echo "Exceeded the maximum number of checking attempts," echo "selenium server status is '$status' and it is different from '$expectedStatus'"; exit 1; fi; echo "Wait selenium server availability ..." curentTry=$((curentTry + 1)) sleep 1 done # Print information about launching tests if mount | grep 'e2e'; then echo "The local code is mounted. Executing local code." cd /tmp/e2e || exit npm install else echo "Executing e2e tests from an image." cd /tmp/e2e || exit fi # Launch tests if [ $TS_LOAD_TESTS ]; then timestamp=$(date +%s) user_folder="$TS_SELENIUM_USERNAME-$timestamp" export TS_SELENIUM_REPORT_FOLDER="./$user_folder/report" export TS_SELENIUM_LOAD_TEST_REPORT_FOLDER="./$user_folder/load-test-folder" CONSOLE_LOGS="./$user_folder/console-log.txt" mkdir $user_folder touch $CONSOLE_LOGS npm run $TEST_SUITE 2>&1 | tee $CONSOLE_LOGS echo "Tarring files and sending them via FTP..." tar -cf $user_folder.tar ./$user_folder ftp -vn load-tests-ftp-service << End_script user user pass1234 binary put $user_folder.tar quit End_script echo "Files sent to load-tests-ftp-service." else SCREEN_RECORDING=${VIDEO_RECORDING:-true} if [ "${SCREEN_RECORDING}" == "true" ]; then echo "Starting ffmpeg recording..." mkdir -p /tmp/ffmpeg_report nohup ffmpeg -y -video_size 1920x1080 -framerate 24 -f x11grab -i :20.0 /tmp/ffmpeg_report/output.mp4 2> /tmp/ffmpeg_report/ffmpeg_err.txt > /tmp/ffmpeg_report/ffmpeg_std.txt & ffmpeg_pid=$! trap kill_ffmpeg 2 15 fi echo "Running TEST_SUITE: $TEST_SUITE with user: $TS_SELENIUM_USERNAME" npm run $TEST_SUITE EXIT_CODE=$? if [ "${SCREEN_RECORDING}" == "true" ]; then kill_ffmpeg fi exit $EXIT_CODE fi
codenvy/che
dockerfiles/e2e/entrypoint.sh
Shell
epl-1.0
3,085
[ 30522, 1001, 999, 1013, 8026, 1013, 24234, 6164, 1035, 3642, 1027, 1014, 3102, 1035, 21461, 8737, 13910, 1006, 1007, 1063, 9052, 1000, 4288, 21461, 8737, 13910, 2007, 14255, 2094, 1027, 1002, 21461, 8737, 13910, 1035, 14255, 2094, 1000, 310...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<table width="90%" border="0"><tr><td><script>function openfile(url) {fullwin = window.open(url, "fulltext", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");}</script><div class="layoutclass_pic"><div class="layoutclass_first_pic"><table class="ztable"><tr><th class="ztd1"><b>成語&nbsp;</b></th><td class="ztd2">力爭上游</td></tr> <tr><th class="ztd1"><b>典源&nbsp;</b></th><td class="ztd2"> ※#清.趙翼〈閒居讀書作〉詩六首之五(據<font class="dianuan_mark">《甌北詩鈔.五言古一》</font>引)<font size=-2 color="#999900"><font class="dianyuanfont"><b><i>1></i></b></font></font><br><font size=4 color="#808080">人面僅一尺,竟無一相肖。人心亦如面,意匠戛獨造。同閱一卷書,各自領其奧。同作一題文,各自擅其妙。問此胡為然,各有天在竅。乃知人巧處,亦天工所到。</font>所以才智人,不肯自棄暴。力欲爭上游,性靈乃其要。</font> <br><font class="dianuan_mark2">〔注解〕</font><br></font> <div class="Rulediv"><font class="english_word">(1)</font> 典故或見於清.薛福成〈滇緬分界大概情形疏〉。</font><font size=4 ></div><br><font class="dianuan_mark2">〔參考資料〕</font><br></font> 清.薛福成〈滇緬分界大概情形疏〉(據<font class="dianuan_mark">《庸盦文編.庸盦海外文編.卷二》</font>引)<br>臣因復照會外部,請以大金沙江為界,江東之境,均歸滇屬。明知英人多費兵餉,占此形勝,萬萬不肯輕棄,然必借此一著,方可力爭上游,振起全局。外部果堅拒不應,兩次停商而臣不顧,數次翻議而臣不顧,外部所稍依允者,印度部復出而撓之,印度部所稍鬆勁者,印度總督復出而梗之,印督至進兵盞達邊外之昔馬,攻擊野人,以示不願分地之意,臣相機理論,剛柔互用,外部謂此議非出自總理衙門,與雲貴總督,盡係使臣之私意,臣電請總理衙門向英使歐格訥辯論,以昭畫一。</td></tr> </td></tr></table></div> <!-- layoutclass_first_pic --><div class="layoutclass_second_pic"></div> <!-- layoutclass_second_pic --></div> <!-- layoutclass_pic --></td></tr></table>
BuzzAcademy/idioms-moe-unformatted-data
all-data/0-999/555-31.html
HTML
mit
2,267
[ 30522, 1026, 2795, 9381, 1027, 1000, 3938, 1003, 1000, 3675, 1027, 1000, 1014, 1000, 1028, 1026, 19817, 1028, 1026, 14595, 1028, 1026, 5896, 1028, 3853, 2330, 8873, 2571, 1006, 24471, 2140, 1007, 1063, 2440, 10105, 1027, 3332, 1012, 2330, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf8 -*- ########################################################################### # This is the package latexparser # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ########################################################################### # copyright (c) Laurent Claessens, 2010,2012-2016 # email: laurent@claessens-donadello.eu import codecs from latexparser.InputPaths import InputPaths class Occurrence(object): """ self.as_written : the code as it appears in the file, including \MyMacro, including the backslash. self.position : the position at which this occurrence appears. Example, if we look at the LatexCode Hello word, \MyMacro{first} and then \MyMacro{second} the first occurrence of \MyMacro has position=12 """ def __init__(self,name,arguments,as_written="",position=0): self.arguments = arguments self.number_of_arguments = len(arguments) self.name = name self.as_written = as_written self.arguments_list = arguments self.position = position def configuration(self): r""" Return the way the arguments are separated in as_written. Example, if we have \MyMacro<space>{A}<tab>{B} {C}, we return the list ["<space>","tab","\n"] The following has to be true: self.as_written == self.name+self.configuration()[0]+self.arguments_list[0]+etc. """ l=[] a = self.as_written.split(self.name)[1] for arg in self.arguments_list: split = a.split("{"+arg+"}") separator=split[0] try: a=split[1] except IndexError: print(self.as_written) raise l.append(separator) return l def change_argument(self,num,func): r""" Apply the function <func> to the <n>th argument of self. Then return a new object. """ n=num-1 # Internally, the arguments are numbered from 0. arguments=self.arguments_list configuration=self.configuration() arguments[n]=func(arguments[n]) new_text=self.name if len(arguments) != len(configuration): print("Error : length of the configuration list has to be the same as the number of arguments") raise ValueError for i in range(len(arguments)): new_text=new_text+configuration[i]+"{"+arguments[i]+"}" return Occurrence(self.name,arguments,new_text,self.position) def analyse(self): return globals()["Occurrence_"+self.name[1:]](self) # We have to remove the initial "\" in the name of the macro. def __getitem__(self,a): return self.arguments[a] def __str__(self): return self.as_written class Occurrence_newlabel(object): r""" takes an occurrence of \newlabel and creates an object which contains the information. In the self.section_name we remove "\relax" from the string. """ def __init__(self,occurrence): self.occurrence = occurrence self.arguments = self.occurrence.arguments if len(self.arguments) == 0 : self.name = "Non interesting; probably the definition" self.listoche = [None,None,None,None,None] self.value,self.page,self.section_name,self.fourth,self.fifth=(None,None,None,None,None) else : self.name = self.arguments[0][0] self.listoche = [a[0] for a in SearchArguments(self.arguments[1][0],5)[0]] self.value = self.listoche[0] self.page = self.listoche[1] self.section_name = self.listoche[2].replace(r"\relax","") self.fourth = self.listoche[3] # I don't know the role of the fourth argument of \newlabel self.fifth = self.listoche[4] # I don't know the role of the fifth argument of \newlabel class Occurrence_addInputPath(object): def __init__(self,Occurrence): self.directory=Occurrence[0] class Occurrence_cite(object): def __init__(self,occurrence): self.label = occurrence[0] def entry(self,codeBibtex): return codeBibtex[self.label] class Occurrence_newcommand(object): def __init__(self,occurrence): self.occurrence = occurrence self.number_of_arguments = 0 if self.occurrence[1][1] == "[]": self.number_of_arguments = self.occurrence[1][0] self.name = self.occurrence[0][0]#[0] self.definition = self.occurrence[-1][0] class Occurrence_label(object): def __init__(self,occurrence): self.occurrence=occurrence self.label=self.occurrence.arguments[0] class Occurrence_ref(object): def __init__(self,occurrence): self.occurrence=occurrence self.label=self.occurrence.arguments[0] class Occurrence_eqref(object): def __init__(self,occurrence): self.occurrence=occurrence self.label=self.occurrence.arguments[0] class Occurrence_input(Occurrence): def __init__(self,occurrence): Occurrence.__init__(self,occurrence.name,occurrence.arguments,as_written=occurrence.as_written,position=occurrence.position) self.occurrence = occurrence self.filename = self.occurrence[0] self.input_paths=InputPaths() self._file_content=None # Make file_content "lazy" def file_content(self,input_paths=None): r""" return the content of the file corresponding to this occurrence of \input. This is not recursive. - 'input_path' is the list of paths in which we can search for files. See the macro `\addInputPath` in the file https://github.com/LaurentClaessens/mazhe/blob/master/configuration.tex """ import os.path # Memoize if self._file_content is not None : return self._file_content # At least, we are searching in the current directory : if input_paths is None : raise # Just to know who should do something like that # Creating the filename filename=self.filename strict_filename = filename if "." not in filename: strict_filename=filename+".tex" # Searching for the correct file in the subdirectories fn=input_paths.get_file(strict_filename) try: # Without [:-1] I got an artificial empty line at the end. text = "".join( codecs.open(fn,"r",encoding="utf8") )[:-1] except IOError : print("Warning : file %s not found."%strict_filename) raise self._file_content=text return self._file_content
LaurentClaessens/LaTeXparser
Occurrence.py
Python
gpl-3.0
7,331
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 2620, 1011, 1008, 1011, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
url: http://sanskrit.inria.fr/cgi-bin/SKT/sktreader?t=VH;lex=SH;cache=f;st=t;us=f;cp=t;text=tathaastu;topic=;abs=f;allSol=2;mode=p;cpts=<!DOCTYPE html> <html><head> <meta charset="utf-8"> <title>Sanskrit Reader Companion</title> <meta name="author" content="G&#233;rard Huet"> <meta property="dc:datecopyrighted" content="2016"> <meta property="dc:rightsholder" content="G&#233;rard Huet"> <meta name="keywords" content="dictionary,sanskrit,heritage,dictionnaire,sanscrit,india,inde,indology,linguistics,panini,digital humanities,cultural heritage,computational linguistics,hypertext lexicon"> <link rel="stylesheet" type="text/css" href="http://sanskrit.inria.fr/DICO/style.css" media="screen,tv"> <link rel="shortcut icon" href="http://sanskrit.inria.fr/IMAGES/favicon.ico"> <script type="text/javascript" src="http://sanskrit.inria.fr/DICO/utf82VH.js"></script> </head> <body class="chamois_back"> <br><h1 class="title">The Sanskrit Reader Companion</h1> <table class="chamois_back" border="0" cellpadding="0%" cellspacing="15pt" width="100%"> <tr><td> <p align="center"> <div class="latin16"><a class="green" href="/cgi-bin/SKT/sktgraph?t=VH;lex=SH;cache=f;st=t;us=f;cp=t;text=tathaastu;topic=;abs=f;cpts=;mode=g">&#x2713;</a> Show Summary of Solutions </p> Input: <span class="red16">tath&#257;stu</span><hr> <br> Sentence: <span class="deva16" lang="sa">&#x0924;&#x0925;&#x093E;&#x0938;&#x094D;&#x0924;&#x0941;</span><br> may be analysed as:</div><br> <hr> <span class="blue">Solution 1 : <a class="green" href="/cgi-bin/SKT/sktparser?t=VH;lex=SH;cache=f;st=t;us=f;cp=t;text=tathaastu;topic=;abs=f;cpts=;mode=p;n=1">&#x2713;</a></span><br> [ <span class="blue" title="0"><b>tath&#257;</b></span><table class="mauve_back"> <tr><th><span class="latin12"><tr><th><span class="latin12">{ adv. }[<a class="navy" href="http://sanskrit.inria.fr/DICO/28.html#tathaa"><i>tath&#257;</i></a>]</span></th></tr></span></th></tr></table>&lang;<span class="magenta">&#257;</span><span class="green">|</span><span class="magenta">a</span><span class="blue"> &rarr; </span><span class="red">&#257;</span>&rang;] <br> [ <span class="blue" title="3"><b>astu</b></span><table class="carmin_back"> <tr><th><span class="latin12"><tr><th><span class="latin12">{ imp. [2] ac. sg. 3 }[<a class="navy" href="http://sanskrit.inria.fr/DICO/7.html#as#1"><i>as_1</i></a>]</span></th></tr></span></th></tr></table>&lang;&rang;] <br> <br> <hr> <span class="magenta">1</span><span class="blue"> solution</span><span class="blue"> kept among </span><span class="magenta">1</span><br> <br> <hr> <br> <br> </td></tr></table> <table class="pad60"> <tr><td></td></tr></table> <div class="enpied"> <table class="bandeau"><tr><td> <a href="http://ocaml.org"><img src="http://sanskrit.inria.fr/IMAGES/ocaml.gif" alt="Le chameau Ocaml" height="50"></a> </td><td> <table class="center"> <tr><td> <a href="http://sanskrit.inria.fr/index.fr.html"><b>Top</b></a> | <a href="http://sanskrit.inria.fr/DICO/index.fr.html"><b>Index</b></a> | <a href="http://sanskrit.inria.fr/DICO/index.fr.html#stemmer"><b>Stemmer</b></a> | <a href="http://sanskrit.inria.fr/DICO/grammar.fr.html"><b>Grammar</b></a> | <a href="http://sanskrit.inria.fr/DICO/sandhi.fr.html"><b>Sandhi</b></a> | <a href="http://sanskrit.inria.fr/DICO/reader.fr.html"><b>Reader</b></a> | <a href="http://sanskrit.inria.fr/faq.fr.html"><b>Help</b></a> | <a href="http://sanskrit.inria.fr/portal.fr.html"><b>Portal</b></a> </td></tr><tr><td> &#169; G&#233;rard Huet 1994-2016</td></tr></table></td><td> <a href="http://www.inria.fr/"><img src="http://sanskrit.inria.fr/IMAGES/logo_inria.png" alt="Logo Inria" height="50"></a> <br></td></tr></table></div> </body> </html>
sanskritiitd/sanskrit
uohCorpus.fil/uoh/uoh.filteredcorpus.txt_output/upamiti-3_ext.txt.out.dict_16534_inr.html
HTML
gpl-3.0
3,697
[ 30522, 24471, 2140, 1024, 8299, 1024, 1013, 1013, 11353, 1012, 1999, 4360, 1012, 10424, 1013, 1039, 5856, 1011, 8026, 1013, 15315, 2102, 1013, 15315, 7913, 9648, 2099, 1029, 1056, 1027, 1058, 2232, 1025, 17244, 1027, 14021, 1025, 17053, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* This file is part of the KDE project * Copyright (C) 2009 Elvis Stansvik <elvstone@gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KTABLEFORMAT_H #define KTABLEFORMAT_H #include "kodftext_export.h" #include <QSharedDataPointer> #include <QMap> class KTableFormatPrivate; class QVariant; class QString; class QBrush; /** * The KTableFormat class describes a format for a table component such * as a row or a column. It is the base class for KoTableColumnFormat and * KoTableRowFormat. * * It is not a style, but a format. Very much like the implicitly shared * QTextFormat in Qt. * * \sa KoTableColumnFormat, KoTableRowFormat */ class KODFTEXT_EXPORT KTableFormat { public: /// Creates a new format of type \c InvalidFormat. KTableFormat(); /// Creates a format with the same attributes as \a rhs. KTableFormat(const KTableFormat &rhs); /// Assigns \a rhs to this format and returns a reference to this format. KTableFormat& operator=(const KTableFormat &rhs); /// Destroys this format. ~KTableFormat(); /// Get property \a propertyId as a QVariant. QVariant property(int propertyId) const; /// Set property \a propertyId to \a value. void setProperty(int propertyId, const QVariant &value); /// Clear property \a propertyId. void clearProperty(int propertyId); /// Returns true if this format has property \a propertyId, otherwise false. bool hasProperty(int propertyId) const; /// Returns a map with all properties of this format. QMap<int, QVariant> properties() const; /// Get bool property \a propertyId. bool boolProperty(int propertyId) const; /// Get int property \a propertyId. int intProperty(int propertyId) const; /// Get double property \a propertyId. qreal doubleProperty(int propertyId) const; /// Get string property \a propertyId. QString stringProperty(int propertyId) const; /// Get brush property \a propertyId. QBrush brushProperty(int propertyId) const; private: QSharedDataPointer<KTableFormatPrivate> d; // Shared data pointer. }; #endif // KOTABLEFORMAT_H
KDE/koffice
libs/kotext/styles/KTableFormat.h
C
gpl-2.0
2,868
[ 30522, 1013, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 1047, 3207, 2622, 1008, 9385, 1006, 1039, 1007, 2268, 12280, 9761, 2015, 13309, 1026, 3449, 15088, 5524, 1030, 20917, 4014, 1012, 4012, 1028, 1008, 1008, 2023, 3075, 2003, 2489, 4007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2011 Carl Green * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package info.carlwithak.mpxg2.printing; import info.carlwithak.mpxg2.model.Program; import info.carlwithak.mpxg2.model.RoutingData; import info.carlwithak.mpxg2.model.effects.algorithms.Ambience; import info.carlwithak.mpxg2.model.effects.algorithms.AutoPan; import info.carlwithak.mpxg2.model.effects.algorithms.Chamber; import info.carlwithak.mpxg2.model.effects.algorithms.ChorusAlgorithm; import info.carlwithak.mpxg2.model.effects.algorithms.ChorusPedalVol; import info.carlwithak.mpxg2.model.effects.algorithms.DelayDual; import info.carlwithak.mpxg2.model.effects.algorithms.DetuneDual; import info.carlwithak.mpxg2.model.effects.algorithms.EchoDual; import info.carlwithak.mpxg2.model.effects.algorithms.EqPedalVol; import info.carlwithak.mpxg2.model.effects.algorithms.Overdrive; import info.carlwithak.mpxg2.model.effects.algorithms.Panner; import info.carlwithak.mpxg2.model.effects.algorithms.PedalWah1; import info.carlwithak.mpxg2.model.effects.algorithms.Plate; import info.carlwithak.mpxg2.model.effects.algorithms.Screamer; import info.carlwithak.mpxg2.model.effects.algorithms.ShiftDual; import info.carlwithak.mpxg2.model.effects.algorithms.Tone; import info.carlwithak.mpxg2.model.effects.algorithms.UniVybe; import info.carlwithak.mpxg2.model.effects.algorithms.VolumeDual; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for RoutingPrinter. * * @author Carl Green */ public class RoutingPrinterTest { /** * Test printing a textual representation of the routing. * * G2 Blue is a simple all along the upper route routing. * * @throws PrintException if an error is encountered while printing */ @Test public void testPrintG2Blue() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting8(routing); program.setEffect1(new UniVybe()); program.setEffect2(new PedalWah1()); program.setChorus(new ChorusPedalVol()); program.setDelay(new EchoDual()); program.setReverb(new Ambience()); program.setGain(new Screamer()); String expected = "I=1=2=G=C=D=R=e=O"; assertEquals(expected, RoutingPrinter.print(program)); } /** * Test printing a textual representation of the routing. * * Guitar Solo splits into the lower route. * * @throws PrintException if an error is encountered while printing */ @Test public void testPrintGuitarSolo() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(3); routing.setPathType(0); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(1); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(2); routing.setPathType(1); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting8(routing); program.setEffect1(new DetuneDual()); program.setEffect2(new Panner()); program.setDelay(new EchoDual()); program.setReverb(new Plate()); program.setGain(new Screamer()); String expected = "I=e=c=G=1===R=2=O\n" + " |=D===|"; String actual = RoutingPrinter.print(program); assertEquals(expected, actual); } /** * Test printing a textual representation of the routing. * * Cordovox splits and has mono and stereo paths. * * @throws PrintException if an error is encountered while printing */ @Test public void testPrintCordovox() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(3); routing.setPathType(0); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(4); routing.setRouting(1); routing.setPathType(1); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(3); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(1); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(1); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(1); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(2); routing.setPathType(1); program.setRouting8(routing); program.setEffect1(new AutoPan()); program.setEffect2(new AutoPan()); program.setChorus(new ChorusAlgorithm()); program.setDelay(new EchoDual()); program.setReverb(new Chamber()); program.setEq(new EqPedalVol()); program.setGain(new Tone()); String expected = "I=E=G=C--\\2=D=R=O\n" + " |/1=======|"; String actual = RoutingPrinter.print(program); assertEquals(expected, actual); } /** * Test printing a textual representation of the routing. * * PowerChords has "lower case numbers". * * @throws PrintException if an error is encountered while printing */ @Test public void testPrintPowerChords() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting8(routing); program.setEffect1(new ShiftDual()); program.setDelay(new DelayDual()); program.setReverb(new Chamber()); program.setGain(new Overdrive()); String expected = "I=₂=G=e=1=c=D=R=O"; assertEquals(expected, RoutingPrinter.print(program)); } /** * Test printing a textual representation of the routing. * * Pitch Cascade has inactive effects on the lower routing. * * @throws PrintException if an error is encountered while printing */ @Test public void testPrintPitchCascase() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(3); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(2); routing.setPathType(1); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting8(routing); program.setEffect1(new ShiftDual()); program.setEffect2(new VolumeDual()); program.setDelay(new DelayDual()); program.setReverb(new Ambience()); program.setEq(new EqPedalVol()); program.setGain(new Overdrive()); String expected = "I=G=2=========R=O\n" + " |=E=D=1=c=|"; assertEquals(expected, RoutingPrinter.print(program)); } /** * Test printing an invalid routing where it splits into two routes but * never combines again. * * @throws PrintException if an error is encountered while printing */ @Test(expected = PrintException.class) public void testInvalidRouting() throws PrintException { Program program = new Program(); RoutingData routing = new RoutingData(); routing.setEffectId(8); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting0(routing); routing = new RoutingData(); routing.setEffectId(5); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting1(routing); routing = new RoutingData(); routing.setEffectId(2); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting2(routing); routing = new RoutingData(); routing.setEffectId(6); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(0); routing.setPathType(0); program.setRouting3(routing); routing = new RoutingData(); routing.setEffectId(0); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(3); routing.setPathType(0); program.setRouting4(routing); routing = new RoutingData(); routing.setEffectId(3); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting5(routing); routing = new RoutingData(); routing.setEffectId(4); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting6(routing); routing = new RoutingData(); routing.setEffectId(1); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting7(routing); routing = new RoutingData(); routing.setEffectId(7); routing.setUpperInputConnection(0); routing.setLowerInputConnection(0); routing.setRouting(1); routing.setPathType(1); program.setRouting8(routing); RoutingPrinter.print(program); } }
carlgreen/Lexicon-MPX-G2-Editor
mpxg2-cli/src/test/java/info/carlwithak/mpxg2/printing/RoutingPrinterTest.java
Java
gpl-3.0
20,290
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2249, 5529, 2665, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/**************************************************************** * Licensed to the AOS Community (AOS) under one or more * * contributor license agreements. See the NOTICE file * * distributed with this work for additional information * * regarding copyright ownership. The AOS 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 aos.data.structure; import java.util.Iterator; /** * An iterator to traverse chained hash tables. * * @version $Id: ChainedHashtableIterator.java 8 2006-08-02 19:03:11Z bailey $ * @author, 2001 duane a. bailey */ class ChainedHashtableIterator extends AbstractIterator { /** * The list of values within the table. */ protected List data; /** * The iterator over the elements of the list. */ protected Iterator elements; /** * Construct an iterator over a chained hashtable. * * @post constructs a new hash table iterator * @param table The array of lists to be traversed. */ public ChainedHashtableIterator(List[] table) { int i; int capacity = table.length; data = new SinglyLinkedList(); for (i = 0; i < capacity; i++) { if (table[i] != null) { Iterator els = table[i].iterator(); while (els.hasNext()) { data.addFirst(els.next()); } } } elements = data.iterator(); } /** * Resets the iterator to point to the beginning of the chained table. * * @post resets iterator to beginning of hash table */ public void reset() { ((AbstractIterator)elements).reset(); } /** * Returns true iff there are unconsidered elements within the table. * * @post returns true if there are unvisited elements * * @return True iff there are elements yet to be considered within table. */ public boolean hasNext() { return elements.hasNext(); } /** * Returns current value and increments iterator. * * @pre hasNext() * @post returns current element, increments iterator * * @return The current value, before incrementing. */ public Object next() { return elements.next(); } /** * Get current value of iterator. * * @post returns current element * * @return The current value. */ public Object get() { return ((AbstractIterator)elements).get(); } }
xuzhikethinker/t4f-data
structure/core/src/main/java/aos/data/structure/ChainedHashtableIterator.java
Java
apache-2.0
3,382
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!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></head> <title>HAUNTED MUSEUM, PUMPKIN PATCH, PARADE PLANNED AT STATE MUSEUM</title> <div id="inputted_date">10/14/2005</div> <body> <div id="main"> <p>ALBANY &ndash; Using objects from its extensive collections and exhibit galleries, the New York State Museum will open its Haunted Museum Saturday and Sunday, Oct. 22 and 23; and Oct. 29 and 30, from 10 a.m. to 4 p.m. in the Student Center. </p> <p>Admission is $5 and proceeds will go to the Museum&rsquo;s after-school youth programs, which serve low-income children and depend entirely on grants and contributions. The Haunted Museum is so scary that no one under age 10 will be admitted. Children ages 12 and under must be accompanied by an adult. </p> <p>But, this year for the first time, the Museum will also open a Pumpkin Patch for younger people and the faint of heart. Children are encouraged to wear costumes as they take part in arts and crafts, face painting and a Halloween parade through exhibit halls. The Pumpkin Patch, which costs $2 per person, will be open from noon to 4 p.m. </p> <p>&ldquo;We wanted to provide a place for people to go that is pleasant and light and fun,&rsquo;&rsquo; said Truemaster Trimingham, a Museum educator and the mastermind behind the Halloween events. &ldquo;The Haunted Museum definitely isn&rsquo;t for everyone. &lsquo;&rsquo;</p> <p>As guests wait to enter, stalks of corn quiver unexpectedly, &ldquo;scare-acters&rsquo;&rsquo; appear from nowhere and a piano plays itself. Inside, walls move and horror movies even come to life. Last year, about 900 people visited the Haunted Museum, a number expected to rise as Trimingham makes it bigger and more horrific. </p> <p>A lifelong theme park aficionado, his hobby is traveling the country to see how parks create illusion. But Trimingham also keeps his eyes on the extensive collections and exhibits at his own workplace for props that help convert the 4,000 square foot Student Center into a hall of doom. </p> <p>Cases full of stuffed skunks, foxes and birds are the centerpiece for a &ldquo;Trophy Room,&rsquo;&rsquo; in which a taxidermist shows off his handiwork. Dust-collecting medical and science texts in French and German accessorize the &ldquo;Die-brary.&rsquo;&rsquo; A bust that was once the head of a character in the New York City exhibit now tops a nine-foot scarecrow in the Haunted Museum&rsquo;s &ldquo;Scornfield.&rsquo;&rsquo; Backdrops and d&eacute;cor from fossil </p> <p align="center">-more-<br />-2-</p> <p>exhibits and art shows would hardly be recognizable thanks to the macabre touches added. </p> <p> &ldquo;Coming Soon, You are Dead,&rsquo;&rsquo; reads the movie marquee that invites people in at their own risk to encounter characters from &ldquo;Scream,&rsquo;&rsquo; &ldquo;Friday the 13th&rsquo;&rsquo; and other horror movies. There, visitors sit in real movie theater seats scavenged from an auditorium the Museum no longer uses. </p> <p>Trimingham warns to watch for blood in the &ldquo;Emergency Room.&rsquo;&rsquo; &ldquo;There&rsquo;s &lsquo;Prison Break,&rsquo;&rsquo; he said. &ldquo;You see a guard in a coat of armor and the prisoner. But they&rsquo;ve changed places. The guard is in the electric chair. The criminal is at the controls.&rsquo;&rsquo;</p> <p>A Staten Island native, Trimingham is so enthusiastic about theme parks that he took a part-time job as a Delta Airlines baggage handler in order to use the free travel to visit them. Trimingham received his Bachelor degree at the State University of New York at Albany and a Master of Education at the College of St. Rose. </p> <p> Eight years ago, he turned down a classroom teaching job offer to become an educator at the State Museum. There, he has the creative freedom to engage students in educational projects not found in schools, including the Haunted Museum. </p> <p>&ldquo;The kids participate in some of the construction, and learn about set design and characters and building themes,&rsquo;&rsquo; he said. &ldquo;And, as it has all grown, they are still the first ones through it. Sometimes, if they&rsquo;re really scared I take them through there with the lights on.&rsquo;&rsquo;</p> <p>The New York State Museum is a cultural program of the New York State Department of Education. Founded in 1836, the Museum has the longest continuously operating state natural history research and collection survey in the U.S. Located on Madison Avenue in Albany, the Museum is open daily from 9:30 a.m. to 5 p.m. except on Thanksgiving, Christmas and New Year's Day. Admission is free. Further information can be obtained by calling (518) 474-5877 or visiting the museum website at www.nysm.nysed.gov.</p> <p align="center"># # #</p> </div></body> </html>
mindnut/nicktest
common/nysm/files/pressdir/hauntedmuseum.html
HTML
gpl-2.0
4,935
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/bin/env python import sys import os args = sys.argv[1:] files = args[0:-1] newdir = args[-1] for file in files: cmd = "svn mv %s %s/" % (file,newdir) print cmd os.system(cmd)
chryswoods/Sire
corelib/build/svnmvall.py
Python
gpl-2.0
200
[ 30522, 1001, 999, 1013, 8026, 1013, 4372, 2615, 18750, 12324, 25353, 2015, 12324, 9808, 12098, 5620, 1027, 25353, 2015, 1012, 12098, 2290, 2615, 1031, 1015, 1024, 1033, 30524, 1031, 1014, 1024, 1011, 1015, 1033, 2047, 4305, 2099, 1027, 1209...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Install the Latest WordPress via Applescript ## Note: There are a few assumptions here: * You are on a Mac * You are using the local Apache/PHP environment * You've set up your local Apache/PHP environment to run from your `user/Sites` directory * You are using a local, standalone and complete install of MySQL You shouldn't need to change much in the script if these assumptions are correct. ## Version: v 1.0 ## Setup: * Open `install_default_wp.scpt` in Script Editor (Applications > Utilities > Script Editor) * Edit the first two lines replacing the defaults with your local MySQL user and password * Save the file and then go to File > Export&hellip; * Change the "File Format" field to "Application" * Check the "Run-only" box * Save the file ## Advanced Setup: * If you have MySQL in a custom location you may need to change the `db_path` variable as well. Defaults to `/usr/local/mysql/bin/mysql` * You may also need to update `local_url` if you're running an atypical setup. Defaults to `http://localhost/` ## Use: * Run the exported application file * If you want to use a name other than the default "wordpress" for the folder, change it in the dialog box. (Remember this is used as a folder and database name so keep it simple and machine readable. e.g. lowercase and hyphenated or underscored) * You'll likely be prompted for your password. This is for modifying file ownership and permissions * Once the script has run you'll be presented with the WordPress setup window. Go through the process as per usual. Inserting your database information with the table being the same as the information you entered into the dialog window and your systems user and password. The rest of the process is up to you. Should be easy as permissions are set in the script as well. ## The Code: ``` set db_user to "user" set db_pass to "password" set db_path to "/usr/local/mysql/bin/mysql" set local_url to "http://localhost/" set wp_url to "https://wordpress.org/" set latest_wp to "latest.tar.gz" set posix_path to POSIX path of (path to sites folder from user domain) as text display dialog "New site folder name (e.g. custom-name):" default answer "wordpress" buttons {"Install", "Cancel"} default button 1 if the button returned of the result is "Cancel" then display dialog "Cancelled" else set folder_name to (text returned of the result) end if set curl_command to "curl " & wp_url & latest_wp & " -o " & posix_path & latest_wp do shell script curl_command set tar_command to "tar -xvzf " & posix_path & latest_wp & " -C " & posix_path do shell script tar_command set delete_command to "rm " & posix_path & latest_wp do shell script delete_command if folder_name is not "wordpress" then set rename_command to "mv " & posix_path & "wordpress " & posix_path & folder_name do shell script rename_command end if set own_command to "chown -R _www " & posix_path & folder_name do shell script own_command with administrator privileges set mod_command to "chmod -R g+w " & posix_path & folder_name do shell script mod_command with administrator privileges set database_command to db_path & " -u " & db_user & " -p" & db_pass & " -e 'create database `" & folder_name & "`;'" do shell script database_command set user_name to short user name of (system info) open location local_url & "~" & user_name & "/" & folder_name ``` ## History * v 1.0 - Initial version
jeremyHixon/latest-wordpress-applescript
README.md
Markdown
mit
3,384
[ 30522, 1001, 16500, 1996, 6745, 2773, 20110, 3081, 18108, 23235, 1001, 1001, 3602, 1024, 2045, 2024, 1037, 2261, 17568, 2182, 1024, 1008, 2017, 2024, 2006, 1037, 6097, 1008, 2017, 2024, 2478, 1996, 2334, 15895, 1013, 25718, 4044, 1008, 2017...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module Puppet.Master.Interpreter ( InterpreterWorker , newInterpreterWorker , ask , eval , typeOf ) where import Exception import Control.Monad import GHC import GHC.Paths ( libdir ) import GHCi import GhcMonad import Outputable import Puppet.Master.Worker type InterpreterWorker = Worker Ghc eval :: String -> Ghc String eval e = liftM (either (const "error") (showSDocUnsafe . ppr)) attempt where attempt :: Ghc (Either SomeException [Name]) attempt = gtry $ execStmt e (ExecOptions RunToCompletion "prompr" 0 EvalThis) >>= result result :: ExecResult -> Ghc [Name] result (ExecComplete (Right ns) _) = return ns result _ = return [] typeOf :: String -> Ghc String typeOf e = liftM (either (const "") (showSDocUnsafe . ppr)) attempt where attempt :: Ghc (Either SomeException Type) attempt = gtry $ exprType e initGhc :: Ghc () initGhc = do df <- getSessionDynFlags setSessionDynFlags $ df { hscTarget = HscInterpreted , ghcLink = LinkInMemory } setContext $ map (IIDecl . simpleImportDecl . mkModuleName) [ "Prelude" ] return () newInterpreterWorker :: IO InterpreterWorker newInterpreterWorker = newWorker $ runGhc (Just libdir) . (initGhc >>) >=> const (return ())
jd823592/puppeteer
src/Puppet/Master/Interpreter.hs
Haskell
mit
1,473
[ 30522, 11336, 13997, 1012, 3040, 1012, 19555, 1006, 19555, 6198, 2121, 1010, 2047, 18447, 2121, 28139, 3334, 6198, 2121, 1010, 3198, 1010, 9345, 2140, 1010, 2828, 11253, 1007, 2073, 12324, 6453, 12324, 2491, 1012, 13813, 2094, 12324, 1043, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>vuetify-dropzone</title> <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i"> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <link rel="stylesheet" href="/dist/vuetify-dropzone.css"> </head> <body> <div id="app"></div> <script src="/dist/vuetify-dropzone.js"></script> </body> </html>
lioneil/pluma
core/submodules/Library/assets/vuetify-dropzone/index.html
HTML
mit
676
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 2516, 1028, 24728, 20624, 12031, 1011, 4530, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/***************************************************************************** * * * OpenNI 1.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * * This file is part of OpenNI. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * *****************************************************************************/ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace OpenNI { public static class Log { public static readonly string MASK_ALL = "ALL"; public static void Init() { int status = SafeNativeMethods.xnLogInitSystem(); WrapperUtils.ThrowOnError(status); } public static void InitFromXmlFile(string xmlFile) { int status = SafeNativeMethods.xnLogInitFromXmlFile(xmlFile); WrapperUtils.ThrowOnError(status); } public static void Close() { int status = SafeNativeMethods.xnLogClose(); WrapperUtils.ThrowOnError(status); } public static void SetMaskState(string maskName, bool on) { int status = SafeNativeMethods.xnLogSetMaskState(maskName, on); WrapperUtils.ThrowOnError(status); } public static void SetSeverityFilter(LogSeverity severity) { int status = SafeNativeMethods.xnLogSetSeverityFilter(severity); WrapperUtils.ThrowOnError(status); } public static void SetConsoleOutput(bool on) { int status = SafeNativeMethods.xnLogSetConsoleOutput(on); WrapperUtils.ThrowOnError(status); } public static void SetFileOutput(bool on) { int status = SafeNativeMethods.xnLogSetFileOutput(on); WrapperUtils.ThrowOnError(status); } public static void SetOutputFolder(string folder) { int status = SafeNativeMethods.xnLogSetOutputFolder(folder); WrapperUtils.ThrowOnError(status); } } }
rxl194/OpenNI
Wrappers/OpenNI.net/Log.cs
C#
apache-2.0
3,080
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtOpenGL module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qgl.h" #include "qgl_p.h" #include "qmap.h" #include "qapplication.h" #include "qcolormap.h" #include "qdesktopwidget.h" #include "qpixmap.h" #include "qhash.h" #include "qlibrary.h" #include "qdebug.h" #include <private/qfontengine_ft_p.h> #include <private/qt_x11_p.h> #include <private/qpixmap_x11_p.h> #include <private/qimagepixmapcleanuphooks_p.h> #include <private/qunicodetables_p.h> #ifdef Q_OS_HPUX // for GLXPBuffer #include <private/qglpixelbuffer_p.h> #endif // We always define GLX_EXT_texture_from_pixmap ourselves because // we can't trust system headers to do it properly #define GLX_EXT_texture_from_pixmap 1 #define INT8 dummy_INT8 #define INT32 dummy_INT32 #include <GL/glx.h> #undef INT8 #undef INT32 #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #ifdef Q_OS_VXWORS # ifdef open # undef open # endif # ifdef getpid # undef getpid # endif #endif // Q_OS_VXWORKS #include <X11/Xatom.h> #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) #include <dlfcn.h> #endif QT_BEGIN_NAMESPACE extern Drawable qt_x11Handle(const QPaintDevice *pd); extern const QX11Info *qt_x11Info(const QPaintDevice *pd); #ifndef GLX_ARB_multisample #define GLX_SAMPLE_BUFFERS_ARB 100000 #define GLX_SAMPLES_ARB 100001 #endif #ifndef GLX_TEXTURE_2D_BIT_EXT #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 #define GLX_Y_INVERTED_EXT 0x20D4 #define GLX_TEXTURE_FORMAT_EXT 0x20D5 #define GLX_TEXTURE_TARGET_EXT 0x20D6 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA #define GLX_TEXTURE_2D_EXT 0x20DC #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD #define GLX_FRONT_LEFT_EXT 0x20DE #endif #ifndef GLX_ARB_create_context #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 #define GLX_CONTEXT_FLAGS_ARB 0x2094 #endif #ifndef GLX_ARB_create_context_profile #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 #endif /* The qt_gl_choose_cmap function is internal and used by QGLWidget::setContext() and GLX (not Windows). If the application can't find any sharable colormaps, it must at least create as few colormaps as possible. The dictionary solution below ensures only one colormap is created per visual. Colormaps are also deleted when the application terminates. */ struct QCMapEntry { QCMapEntry(); ~QCMapEntry(); Colormap cmap; bool alloc; XStandardColormap scmap; }; QCMapEntry::QCMapEntry() { cmap = 0; alloc = false; scmap.colormap = 0; } QCMapEntry::~QCMapEntry() { if (alloc) XFreeColormap(X11->display, cmap); } typedef QHash<int, QCMapEntry *> CMapEntryHash; typedef QHash<int, QMap<int, QRgb> > GLCMapHash; static bool mesa_gl = false; static bool first_time = true; static void cleanup_cmaps(); struct QGLCMapCleanupHandler { QGLCMapCleanupHandler() { cmap_hash = new CMapEntryHash; qglcmap_hash = new GLCMapHash; } ~QGLCMapCleanupHandler() { delete cmap_hash; delete qglcmap_hash; } CMapEntryHash *cmap_hash; GLCMapHash *qglcmap_hash; }; Q_GLOBAL_STATIC(QGLCMapCleanupHandler, cmap_handler) static void cleanup_cmaps() { CMapEntryHash *hash = cmap_handler()->cmap_hash; QHash<int, QCMapEntry *>::ConstIterator it = hash->constBegin(); while (it != hash->constEnd()) { delete it.value(); ++it; } hash->clear(); cmap_handler()->qglcmap_hash->clear(); } Colormap qt_gl_choose_cmap(Display *dpy, XVisualInfo *vi) { if (first_time) { const char *v = glXQueryServerString(dpy, vi->screen, GLX_VERSION); if (v) mesa_gl = (strstr(v, "Mesa") != 0); first_time = false; } CMapEntryHash *hash = cmap_handler()->cmap_hash; CMapEntryHash::ConstIterator it = hash->constFind((long) vi->visualid + (vi->screen * 256)); if (it != hash->constEnd()) return it.value()->cmap; // found colormap for visual if (vi->visualid == XVisualIDFromVisual((Visual *) QX11Info::appVisual(vi->screen))) { // qDebug("Using x11AppColormap"); return QX11Info::appColormap(vi->screen); } QCMapEntry *x = new QCMapEntry(); XStandardColormap *c; int n, i; // qDebug("Choosing cmap for vID %0x", vi->visualid); if (mesa_gl) { // we're using MesaGL Atom hp_cmaps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", true); if (hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8) { if (XGetRGBColormaps(dpy,RootWindow(dpy,vi->screen),&c,&n, hp_cmaps)) { i = 0; while (i < n && x->cmap == 0) { if (c[i].visualid == vi->visual->visualid) { x->cmap = c[i].colormap; x->scmap = c[i]; //qDebug("Using HP_RGB scmap"); } i++; } XFree((char *)c); } } } if (!x->cmap) { if (XGetRGBColormaps(dpy,RootWindow(dpy,vi->screen),&c,&n, XA_RGB_DEFAULT_MAP)) { for (int i = 0; i < n && x->cmap == 0; ++i) { if (!c[i].red_max || !c[i].green_max || !c[i].blue_max || !c[i].red_mult || !c[i].green_mult || !c[i].blue_mult) continue; // invalid stdcmap if (c[i].visualid == vi->visualid) { x->cmap = c[i].colormap; x->scmap = c[i]; //qDebug("Using RGB_DEFAULT scmap"); } } XFree((char *)c); } } if (!x->cmap) { // no shared cmap found x->cmap = XCreateColormap(dpy, RootWindow(dpy,vi->screen), vi->visual, AllocNone); x->alloc = true; // qDebug("Allocating cmap"); } // colormap hash should be cleanup only when the QApplication dtor is called if (hash->isEmpty()) qAddPostRoutine(cleanup_cmaps); // associate cmap with visualid hash->insert((long) vi->visualid + (vi->screen * 256), x); return x->cmap; } struct QTransColor { VisualID vis; int screen; long color; }; static QVector<QTransColor> trans_colors; static int trans_colors_init = false; static void find_trans_colors() { struct OverlayProp { long visual; long type; long value; long layer; }; trans_colors_init = true; Display* appDisplay = X11->display; int scr; int lastsize = 0; for (scr = 0; scr < ScreenCount(appDisplay); scr++) { QWidget* rootWin = QApplication::desktop()->screen(scr); if (!rootWin) return; // Should not happen Atom overlayVisualsAtom = XInternAtom(appDisplay, "SERVER_OVERLAY_VISUALS", True); if (overlayVisualsAtom == XNone) return; // Server has no overlays Atom actualType; int actualFormat; ulong nItems; ulong bytesAfter; unsigned char *retval = 0; int res = XGetWindowProperty(appDisplay, rootWin->winId(), overlayVisualsAtom, 0, 10000, False, overlayVisualsAtom, &actualType, &actualFormat, &nItems, &bytesAfter, &retval); if (res != Success || actualType != overlayVisualsAtom || actualFormat != 32 || nItems < 4 || !retval) return; // Error reading property OverlayProp *overlayProps = (OverlayProp *)retval; int numProps = nItems / 4; trans_colors.resize(lastsize + numProps); int j = lastsize; for (int i = 0; i < numProps; i++) { if (overlayProps[i].type == 1) { trans_colors[j].vis = (VisualID)overlayProps[i].visual; trans_colors[j].screen = scr; trans_colors[j].color = (int)overlayProps[i].value; j++; } } XFree(overlayProps); lastsize = j; trans_colors.resize(lastsize); } } /***************************************************************************** QGLFormat UNIX/GLX-specific code *****************************************************************************/ void* qglx_getProcAddress(const char* procName) { // On systems where the GL driver is pluggable (like Mesa), we have to use // the glXGetProcAddressARB extension to resolve other function pointers as // the symbols wont be in the GL library, but rather in a plugin loaded by // the GL library. typedef void* (*qt_glXGetProcAddressARB)(const char *); static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; static bool triedResolvingGlxGetProcAddress = false; if (!triedResolvingGlxGetProcAddress) { triedResolvingGlxGetProcAddress = true; QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); if (extensions.match("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); dlclose(handle); } if (!glXGetProcAddressARB) #endif { #if !defined(QT_NO_LIBRARY) extern const QString qt_gl_library_name(); QLibrary lib(qt_gl_library_name()); lib.setLoadHints(QLibrary::ImprovedSearchHeuristics); glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); #endif } } } void *procAddress = 0; if (glXGetProcAddressARB) procAddress = glXGetProcAddressARB(procName); // If glXGetProcAddress didn't work, try looking the symbol up in the GL library #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) if (!procAddress) { void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { procAddress = dlsym(handle, procName); dlclose(handle); } } #endif #if !defined(QT_NO_LIBRARY) if (!procAddress) { extern const QString qt_gl_library_name(); QLibrary lib(qt_gl_library_name()); lib.setLoadHints(QLibrary::ImprovedSearchHeuristics); procAddress = lib.resolve(procName); } #endif return procAddress; } bool QGLFormat::hasOpenGL() { return glXQueryExtension(X11->display, 0, 0) != 0; } bool QGLFormat::hasOpenGLOverlays() { if (!trans_colors_init) find_trans_colors(); return trans_colors.size() > 0; } static bool buildSpec(int* spec, const QGLFormat& f, QPaintDevice* paintDevice, int bufDepth, bool onlyFBConfig = false) { int i = 0; spec[i++] = GLX_LEVEL; spec[i++] = f.plane(); const QX11Info *xinfo = qt_x11Info(paintDevice); bool useFBConfig = onlyFBConfig; #if defined(GLX_VERSION_1_3) && !defined(QT_NO_XRENDER) && !defined(Q_OS_HPUX) /* HPUX defines GLX_VERSION_1_3 but does not implement the corresponding functions. Specifically glXChooseFBConfig and glXGetVisualFromFBConfig are not implemented. */ QWidget* widget = 0; if (paintDevice->devType() == QInternal::Widget) widget = static_cast<QWidget*>(paintDevice); // Only use glXChooseFBConfig for widgets if we're trying to get an ARGB visual if (widget && widget->testAttribute(Qt::WA_TranslucentBackground) && X11->use_xrender) useFBConfig = true; #endif #if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info) static bool useTranspExt = false; static bool useTranspExtChecked = false; if (f.plane() && !useTranspExtChecked && paintDevice) { QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); useTranspExt = extensions.match("GLX_EXT_visual_info"); //# (A bit simplistic; that could theoretically be a substring) if (useTranspExt) { QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR)); useTranspExt = !cstr.contains("Xi Graphics"); // bug workaround if (useTranspExt) { // bug workaround - some systems (eg. FireGL) refuses to return an overlay // visual if the GLX_TRANSPARENT_TYPE_EXT attribute is specified, even if // the implementation supports transparent overlays int tmpSpec[] = { GLX_LEVEL, f.plane(), GLX_TRANSPARENT_TYPE_EXT, f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT, XNone }; XVisualInfo * vinf = glXChooseVisual(xinfo->display(), xinfo->screen(), tmpSpec); if (!vinf) { useTranspExt = false; } } } useTranspExtChecked = true; } if (f.plane() && useTranspExt && !useFBConfig) { // Required to avoid non-transparent overlay visual(!) on some systems spec[i++] = GLX_TRANSPARENT_TYPE_EXT; spec[i++] = f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT; } #endif #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) // GLX_RENDER_TYPE is only in glx >=1.3 if (useFBConfig) { spec[i++] = GLX_RENDER_TYPE; spec[i++] = f.rgba() ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; } #endif if (f.doubleBuffer()) spec[i++] = GLX_DOUBLEBUFFER; if (useFBConfig) spec[i++] = True; if (f.depth()) { spec[i++] = GLX_DEPTH_SIZE; spec[i++] = f.depthBufferSize() == -1 ? 1 : f.depthBufferSize(); } if (f.stereo()) { spec[i++] = GLX_STEREO; if (useFBConfig) spec[i++] = True; } if (f.stencil()) { spec[i++] = GLX_STENCIL_SIZE; spec[i++] = f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize(); } if (f.rgba()) { if (!useFBConfig) spec[i++] = GLX_RGBA; spec[i++] = GLX_RED_SIZE; spec[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize(); spec[i++] = GLX_GREEN_SIZE; spec[i++] = f.greenBufferSize() == -1 ? 1 : f.greenBufferSize(); spec[i++] = GLX_BLUE_SIZE; spec[i++] = f.blueBufferSize() == -1 ? 1 : f.blueBufferSize(); if (f.alpha()) { spec[i++] = GLX_ALPHA_SIZE; spec[i++] = f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize(); } if (f.accum()) { spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize(); spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize(); spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize(); if (f.alpha()) { spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize(); } } } else { spec[i++] = GLX_BUFFER_SIZE; spec[i++] = bufDepth; } if (f.sampleBuffers()) { spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = 1; spec[i++] = GLX_SAMPLES_ARB; spec[i++] = f.samples() == -1 ? 4 : f.samples(); } #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) if (useFBConfig) { spec[i++] = GLX_DRAWABLE_TYPE; switch(paintDevice->devType()) { case QInternal::Pixmap: spec[i++] = GLX_PIXMAP_BIT; break; case QInternal::Pbuffer: spec[i++] = GLX_PBUFFER_BIT; break; default: qWarning("QGLContext: Unknown paint device type %d", paintDevice->devType()); // Fall-through & assume it's a window case QInternal::Widget: spec[i++] = GLX_WINDOW_BIT; break; }; } #endif spec[i] = XNone; return useFBConfig; } /***************************************************************************** QGLContext UNIX/GLX-specific code *****************************************************************************/ bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); const QX11Info *xinfo = qt_x11Info(d->paintDevice); Display* disp = xinfo->display(); d->vi = chooseVisual(); if (!d->vi) return false; if (deviceIsPixmap() && (((XVisualInfo*)d->vi)->depth != xinfo->depth() || ((XVisualInfo*)d->vi)->screen != xinfo->screen())) { XFree(d->vi); XVisualInfo appVisInfo; memset(&appVisInfo, 0, sizeof(XVisualInfo)); appVisInfo.visualid = XVisualIDFromVisual((Visual *) xinfo->visual()); appVisInfo.screen = xinfo->screen(); int nvis; d->vi = XGetVisualInfo(disp, VisualIDMask | VisualScreenMask, &appVisInfo, &nvis); if (!d->vi) return false; int useGL; glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_USE_GL, &useGL); if (!useGL) return false; //# Chickening out already... } int res; glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_LEVEL, &res); d->glFormat.setPlane(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_DOUBLEBUFFER, &res); d->glFormat.setDoubleBuffer(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_DEPTH_SIZE, &res); d->glFormat.setDepth(res); if (d->glFormat.depth()) d->glFormat.setDepthBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_RGBA, &res); d->glFormat.setRgba(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_RED_SIZE, &res); d->glFormat.setRedBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_GREEN_SIZE, &res); d->glFormat.setGreenBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_BLUE_SIZE, &res); d->glFormat.setBlueBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_ALPHA_SIZE, &res); d->glFormat.setAlpha(res); if (d->glFormat.alpha()) d->glFormat.setAlphaBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_ACCUM_RED_SIZE, &res); d->glFormat.setAccum(res); if (d->glFormat.accum()) d->glFormat.setAccumBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_STENCIL_SIZE, &res); d->glFormat.setStencil(res); if (d->glFormat.stencil()) d->glFormat.setStencilBufferSize(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_STEREO, &res); d->glFormat.setStereo(res); glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_SAMPLE_BUFFERS_ARB, &res); d->glFormat.setSampleBuffers(res); if (d->glFormat.sampleBuffers()) { glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_SAMPLES_ARB, &res); d->glFormat.setSamples(res); } Bool direct = format().directRendering() ? True : False; if (shareContext && (!shareContext->isValid() || !shareContext->d_func()->cx)) { qWarning("QGLContext::chooseContext(): Cannot share with invalid context"); shareContext = 0; } // 1. Sharing between rgba and color-index will give wrong colors. // 2. Contexts cannot be shared btw. direct/non-direct renderers. // 3. Pixmaps cannot share contexts that are set up for direct rendering. // 4. If the contexts are not created on the same screen, they can't be shared if (shareContext && (format().rgba() != shareContext->format().rgba() || (deviceIsPixmap() && glXIsDirect(disp, (GLXContext)shareContext->d_func()->cx)) || (shareContext->d_func()->screen != xinfo->screen()))) { shareContext = 0; } const int major = d->reqFormat.majorVersion(); const int minor = d->reqFormat.minorVersion(); const int profile = d->reqFormat.profile() == QGLFormat::CompatibilityProfile ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : GLX_CONTEXT_CORE_PROFILE_BIT_ARB; d->cx = 0; #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) /* HPUX defines GLX_VERSION_1_3 but does not implement the corresponding functions. Specifically glXChooseFBConfig and glXGetVisualFromFBConfig are not implemented. */ if ((major == 3 && minor >= 2) || major > 3) { QGLTemporaryContext *tmpContext = 0; if (!QGLContext::currentContext()) tmpContext = new QGLTemporaryContext; int attributes[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, major, GLX_CONTEXT_MINOR_VERSION_ARB, minor, GLX_CONTEXT_PROFILE_MASK_ARB, profile, 0 }; typedef GLXContext ( * Q_PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); Q_PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = (Q_PFNGLXCREATECONTEXTATTRIBSARBPROC) qglx_getProcAddress("glXCreateContextAttribsARB"); if (glXCreateContextAttribs) { int spec[45]; glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_BUFFER_SIZE, &res); buildSpec(spec, format(), d->paintDevice, res, true); GLXFBConfig *configs; int configCount = 0; configs = glXChooseFBConfig(disp, xinfo->screen(), spec, &configCount); if (configs && configCount > 0) { d->cx = glXCreateContextAttribs(disp, configs[0], shareContext ? (GLXContext)shareContext->d_func()->cx : 0, direct, attributes); if (!d->cx && shareContext) { shareContext = 0; d->cx = glXCreateContextAttribs(disp, configs[0], 0, direct, attributes); } d->screen = ((XVisualInfo*)d->vi)->screen; } XFree(configs); } else { qWarning("QGLContext::chooseContext(): OpenGL %d.%d is not supported", major, minor); } if (tmpContext) delete tmpContext; } #else Q_UNUSED(major); Q_UNUSED(minor); Q_UNUSED(profile); #endif if (!d->cx && shareContext) { d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi, (GLXContext)shareContext->d_func()->cx, direct); d->screen = ((XVisualInfo*)d->vi)->screen; } if (!d->cx) { d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi, NULL, direct); d->screen = ((XVisualInfo*)d->vi)->screen; shareContext = 0; } if (shareContext && d->cx) { QGLContext *share = const_cast<QGLContext *>(shareContext); d->sharing = true; share->d_func()->sharing = true; } if (!d->cx) return false; d->glFormat.setDirectRendering(glXIsDirect(disp, (GLXContext)d->cx)); if (deviceIsPixmap()) { #if defined(GLX_MESA_pixmap_colormap) && defined(QGL_USE_MESA_EXT) d->gpm = glXCreateGLXPixmapMESA(disp, (XVisualInfo *)d->vi, qt_x11Handle(d->paintDevice), qt_gl_choose_cmap(disp, (XVisualInfo *)d->vi)); #else d->gpm = (quint32)glXCreateGLXPixmap(disp, (XVisualInfo *)d->vi, qt_x11Handle(d->paintDevice)); #endif if (!d->gpm) return false; } QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); if (extensions.match("GLX_SGI_video_sync")) { if (d->glFormat.swapInterval() == -1) d->glFormat.setSwapInterval(0); } else { d->glFormat.setSwapInterval(-1); } return true; } /* See qgl.cpp for qdoc comment. */ void *QGLContext::chooseVisual() { Q_D(QGLContext); static const int bufDepths[] = { 8, 4, 2, 1 }; // Try 16, 12 also? //todo: if pixmap, also make sure that vi->depth == pixmap->depth void* vis = 0; int i = 0; bool fail = false; QGLFormat fmt = format(); bool tryDouble = !fmt.doubleBuffer(); // Some GL impl's only have double bool triedDouble = false; bool triedSample = false; if (fmt.sampleBuffers()) fmt.setSampleBuffers(QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers); while(!fail && !(vis = tryVisual(fmt, bufDepths[i]))) { if (!fmt.rgba() && bufDepths[i] > 1) { i++; continue; } if (tryDouble) { fmt.setDoubleBuffer(true); tryDouble = false; triedDouble = true; continue; } else if (triedDouble) { fmt.setDoubleBuffer(false); triedDouble = false; } if (!triedSample && fmt.sampleBuffers()) { fmt.setSampleBuffers(false); triedSample = true; continue; } if (fmt.stereo()) { fmt.setStereo(false); continue; } if (fmt.accum()) { fmt.setAccum(false); continue; } if (fmt.stencil()) { fmt.setStencil(false); continue; } if (fmt.alpha()) { fmt.setAlpha(false); continue; } if (fmt.depth()) { fmt.setDepth(false); continue; } if (fmt.doubleBuffer()) { fmt.setDoubleBuffer(false); continue; } fail = true; } d->glFormat = fmt; return vis; } /* See qgl.cpp for qdoc comment. */ void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth) { Q_D(QGLContext); int spec[45]; const QX11Info *xinfo = qt_x11Info(d->paintDevice); bool useFBConfig = buildSpec(spec, f, d->paintDevice, bufDepth, false); XVisualInfo* chosenVisualInfo = 0; #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) while (useFBConfig) { GLXFBConfig *configs; int configCount = 0; configs = glXChooseFBConfig(xinfo->display(), xinfo->screen(), spec, &configCount); if (!configs) break; // fallback to trying glXChooseVisual for (int i = 0; i < configCount; ++i) { XVisualInfo* vi; vi = glXGetVisualFromFBConfig(xinfo->display(), configs[i]); if (!vi) continue; #if !defined(QT_NO_XRENDER) QWidget* w = 0; if (d->paintDevice->devType() == QInternal::Widget) w = static_cast<QWidget*>(d->paintDevice); if (w && w->testAttribute(Qt::WA_TranslucentBackground) && f.alpha()) { // Attempt to find a config who's visual has a proper alpha channel XRenderPictFormat *pictFormat; pictFormat = XRenderFindVisualFormat(xinfo->display(), vi->visual); if (pictFormat && (pictFormat->type == PictTypeDirect) && pictFormat->direct.alphaMask) { // The pict format for the visual matching the FBConfig indicates ARGB if (chosenVisualInfo) XFree(chosenVisualInfo); chosenVisualInfo = vi; break; } } else #endif //QT_NO_XRENDER if (chosenVisualInfo) { // If we've got a visual we can use and we're not trying to find one with a // real alpha channel, we might as well just use the one we've got break; } if (!chosenVisualInfo) chosenVisualInfo = vi; // Have something to fall back to else XFree(vi); } XFree(configs); break; } #endif // defined(GLX_VERSION_1_3) if (!chosenVisualInfo) chosenVisualInfo = glXChooseVisual(xinfo->display(), xinfo->screen(), spec); return chosenVisualInfo; } void QGLContext::reset() { Q_D(QGLContext); if (!d->valid) return; d->cleanup(); const QX11Info *xinfo = qt_x11Info(d->paintDevice); doneCurrent(); if (d->gpm) glXDestroyGLXPixmap(xinfo->display(), (GLXPixmap)d->gpm); d->gpm = 0; glXDestroyContext(xinfo->display(), (GLXContext)d->cx); if (d->vi) XFree(d->vi); d->vi = 0; d->cx = 0; d->crWin = false; d->sharing = false; d->valid = false; d->transpColor = QColor(); d->initDone = false; QGLContextGroup::removeShare(this); } void QGLContext::makeCurrent() { Q_D(QGLContext); if (!d->valid) { qWarning("QGLContext::makeCurrent(): Cannot make invalid context current."); return; } const QX11Info *xinfo = qt_x11Info(d->paintDevice); bool ok = true; if (d->paintDevice->devType() == QInternal::Pixmap) { ok = glXMakeCurrent(xinfo->display(), (GLXPixmap)d->gpm, (GLXContext)d->cx); } else if (d->paintDevice->devType() == QInternal::Pbuffer) { ok = glXMakeCurrent(xinfo->display(), (GLXPbuffer)d->pbuf, (GLXContext)d->cx); } else if (d->paintDevice->devType() == QInternal::Widget) { ok = glXMakeCurrent(xinfo->display(), ((QWidget *)d->paintDevice)->internalWinId(), (GLXContext)d->cx); } if (!ok) qWarning("QGLContext::makeCurrent(): Failed."); if (ok) QGLContextPrivate::setCurrentContext(this); } void QGLContext::doneCurrent() { Q_D(QGLContext); glXMakeCurrent(qt_x11Info(d->paintDevice)->display(), 0, 0); QGLContextPrivate::setCurrentContext(0); } void QGLContext::swapBuffers() const { Q_D(const QGLContext); if (!d->valid) return; if (!deviceIsPixmap()) { int interval = d->glFormat.swapInterval(); if (interval > 0) { typedef int (*qt_glXGetVideoSyncSGI)(uint *); typedef int (*qt_glXWaitVideoSyncSGI)(int, int, uint *); static qt_glXGetVideoSyncSGI glXGetVideoSyncSGI = 0; static qt_glXWaitVideoSyncSGI glXWaitVideoSyncSGI = 0; static bool resolved = false; if (!resolved) { const QX11Info *xinfo = qt_x11Info(d->paintDevice); QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen())); if (extensions.match("GLX_SGI_video_sync")) { glXGetVideoSyncSGI = (qt_glXGetVideoSyncSGI)qglx_getProcAddress("glXGetVideoSyncSGI"); glXWaitVideoSyncSGI = (qt_glXWaitVideoSyncSGI)qglx_getProcAddress("glXWaitVideoSyncSGI"); } resolved = true; } if (glXGetVideoSyncSGI && glXWaitVideoSyncSGI) { uint counter; if (!glXGetVideoSyncSGI(&counter)) glXWaitVideoSyncSGI(interval + 1, (counter + interval) % (interval + 1), &counter); } } glXSwapBuffers(qt_x11Info(d->paintDevice)->display(), static_cast<QWidget *>(d->paintDevice)->winId()); } } QColor QGLContext::overlayTransparentColor() const { if (isValid()) return Qt::transparent; return QColor(); // Invalid color } static uint qt_transparent_pixel(VisualID id, int screen) { for (int i = 0; i < trans_colors.size(); i++) { if (trans_colors[i].vis == id && trans_colors[i].screen == screen) return trans_colors[i].color; } return 0; } uint QGLContext::colorIndex(const QColor& c) const { Q_D(const QGLContext); int screen = ((XVisualInfo *)d->vi)->screen; QColormap colmap = QColormap::instance(screen); if (isValid()) { if (format().plane() && c == Qt::transparent) { return qt_transparent_pixel(((XVisualInfo *)d->vi)->visualid, ((XVisualInfo *)d->vi)->screen); } if (((XVisualInfo*)d->vi)->visualid == XVisualIDFromVisual((Visual *) QX11Info::appVisual(screen))) return colmap.pixel(c); // We're using QColor's cmap XVisualInfo *info = (XVisualInfo *) d->vi; CMapEntryHash *hash = cmap_handler()->cmap_hash; CMapEntryHash::ConstIterator it = hash->constFind(long(info->visualid) + (info->screen * 256)); QCMapEntry *x = 0; if (it != hash->constEnd()) x = it.value(); if (x && !x->alloc) { // It's a standard colormap int rf = (int)(((float)c.red() * (x->scmap.red_max+1))/256.0); int gf = (int)(((float)c.green() * (x->scmap.green_max+1))/256.0); int bf = (int)(((float)c.blue() * (x->scmap.blue_max+1))/256.0); uint p = x->scmap.base_pixel + (rf * x->scmap.red_mult) + (gf * x->scmap.green_mult) + (bf * x->scmap.blue_mult); return p; } else { QMap<int, QRgb> &cmap = (*cmap_handler()->qglcmap_hash)[(long)info->visualid]; // already in the map? QRgb target = c.rgb(); QMap<int, QRgb>::Iterator it = cmap.begin(); for (; it != cmap.end(); ++it) { if ((*it) == target) return it.key(); } // need to alloc color unsigned long plane_mask[2]; unsigned long color_map_entry; if (!XAllocColorCells (QX11Info::display(), x->cmap, true, plane_mask, 0, &color_map_entry, 1)) return colmap.pixel(c); XColor col; col.flags = DoRed | DoGreen | DoBlue; col.pixel = color_map_entry; col.red = (ushort)((qRed(c.rgb()) / 255.0) * 65535.0 + 0.5); col.green = (ushort)((qGreen(c.rgb()) / 255.0) * 65535.0 + 0.5); col.blue = (ushort)((qBlue(c.rgb()) / 255.0) * 65535.0 + 0.5); XStoreColor(QX11Info::display(), x->cmap, &col); cmap.insert(color_map_entry, target); return color_map_entry; } } return 0; } #ifndef QT_NO_FONTCONFIG /*! \internal This is basically a substitute for glxUseXFont() which can only handle XLFD fonts. This version relies on freetype to render the glyphs, but it works with all fonts that fontconfig provides - both antialiased and aliased bitmap and outline fonts. */ static void qgl_use_font(QFontEngineFT *engine, int first, int count, int listBase) { GLfloat color[4]; glGetFloatv(GL_CURRENT_COLOR, color); // save the pixel unpack state GLint gl_swapbytes, gl_lsbfirst, gl_rowlength, gl_skiprows, gl_skippixels, gl_alignment; glGetIntegerv (GL_UNPACK_SWAP_BYTES, &gl_swapbytes); glGetIntegerv (GL_UNPACK_LSB_FIRST, &gl_lsbfirst); glGetIntegerv (GL_UNPACK_ROW_LENGTH, &gl_rowlength); glGetIntegerv (GL_UNPACK_SKIP_ROWS, &gl_skiprows); glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &gl_skippixels); glGetIntegerv (GL_UNPACK_ALIGNMENT, &gl_alignment); glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); const bool antialiased = engine->drawAntialiased(); FT_Face face = engine->lockFace(); // start generating font glyphs for (int i = first; i < count; ++i) { int list = listBase + i; GLfloat x0, y0, dx, dy; FT_Error err; err = FT_Load_Glyph(face, FT_Get_Char_Index(face, i), FT_LOAD_DEFAULT); if (err) { qDebug("failed loading glyph %d from font", i); Q_ASSERT(!err); } err = FT_Render_Glyph(face->glyph, (antialiased ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO)); if (err) { qDebug("failed rendering glyph %d from font", i); Q_ASSERT(!err); } FT_Bitmap bm = face->glyph->bitmap; x0 = face->glyph->metrics.horiBearingX >> 6; y0 = (face->glyph->metrics.height - face->glyph->metrics.horiBearingY) >> 6; dx = face->glyph->metrics.horiAdvance >> 6; dy = 0; int sz = bm.pitch * bm.rows; uint *aa_glyph = 0; uchar *ua_glyph = 0; if (antialiased) aa_glyph = new uint[sz]; else ua_glyph = new uchar[sz]; // convert to GL format for (int y = 0; y < bm.rows; ++y) { for (int x = 0; x < bm.pitch; ++x) { int c1 = y*bm.pitch + x; int c2 = (bm.rows - y - 1) > 0 ? (bm.rows-y-1)*bm.pitch + x : x; if (antialiased) { aa_glyph[c1] = (int(color[0]*255) << 24) | (int(color[1]*255) << 16) | (int(color[2]*255) << 8) | bm.buffer[c2]; } else { ua_glyph[c1] = bm.buffer[c2]; } } } glNewList(list, GL_COMPILE); if (antialiased) { // calling glBitmap() is just a trick to move the current // raster pos, since glGet*() won't work in display lists glBitmap(0, 0, 0, 0, x0, -y0, 0); glDrawPixels(bm.pitch, bm.rows, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, aa_glyph); glBitmap(0, 0, 0, 0, dx-x0, y0, 0); } else { glBitmap(bm.pitch*8, bm.rows, -x0, y0, dx, dy, ua_glyph); } glEndList(); antialiased ? delete[] aa_glyph : delete[] ua_glyph; } engine->unlockFace(); // restore pixel unpack settings glPixelStorei(GL_UNPACK_SWAP_BYTES, gl_swapbytes); glPixelStorei(GL_UNPACK_LSB_FIRST, gl_lsbfirst); glPixelStorei(GL_UNPACK_ROW_LENGTH, gl_rowlength); glPixelStorei(GL_UNPACK_SKIP_ROWS, gl_skiprows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, gl_skippixels); glPixelStorei(GL_UNPACK_ALIGNMENT, gl_alignment); } #endif #undef d void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) { QFont f(fnt); QFontEngine *engine = f.d->engineForScript(QUnicodeTables::Common); if (engine->type() == QFontEngine::Multi) engine = static_cast<QFontEngineMulti *>(engine)->engine(0); #ifndef QT_NO_FONTCONFIG if(engine->type() == QFontEngine::Freetype) { qgl_use_font(static_cast<QFontEngineFT *>(engine), 0, 256, listBase); return; } #endif // glXUseXFont() only works with XLFD font structures and a few GL // drivers crash if 0 is passed as the font handle f.setStyleStrategy(QFont::OpenGLCompatible); if (f.handle() && engine->type() == QFontEngine::XLFD) glXUseXFont(static_cast<Font>(f.handle()), 0, 256, listBase); } void *QGLContext::getProcAddress(const QString &proc) const { typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *); static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; static bool resolved = false; if (resolved && !glXGetProcAddressARB) return 0; if (!glXGetProcAddressARB) { QGLExtensionMatcher extensions(glXGetClientString(QX11Info::display(), GLX_EXTENSIONS)); if (extensions.match("GLX_ARB_get_proc_address")) { #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) void *handle = dlopen(NULL, RTLD_LAZY); if (handle) { glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB"); dlclose(handle); } if (!glXGetProcAddressARB) #endif { #if !defined(QT_NO_LIBRARY) extern const QString qt_gl_library_name(); QLibrary lib(qt_gl_library_name()); lib.setLoadHints(QLibrary::ImprovedSearchHeuristics); glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB"); #endif } } resolved = true; } if (!glXGetProcAddressARB) return 0; return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(proc.toLatin1().data())); } /* QGLTemporaryContext implementation */ class QGLTemporaryContextPrivate { public: bool initialized; Window drawable; GLXContext context; GLXDrawable oldDrawable; GLXContext oldContext; }; QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { d->initialized = false; d->oldDrawable = 0; d->oldContext = 0; int screen = 0; int attribs[] = {GLX_RGBA, XNone}; XVisualInfo *vi = glXChooseVisual(X11->display, screen, attribs); if (!vi) { qWarning("QGLTempContext: No GL capable X visuals available."); return; } int useGL; glXGetConfig(X11->display, vi, GLX_USE_GL, &useGL); if (!useGL) { XFree(vi); return; } d->oldDrawable = glXGetCurrentDrawable(); d->oldContext = glXGetCurrentContext(); XSetWindowAttributes a; a.colormap = qt_gl_choose_cmap(X11->display, vi); d->drawable = XCreateWindow(X11->display, RootWindow(X11->display, screen), 0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual, CWColormap, &a); d->context = glXCreateContext(X11->display, vi, 0, True); if (d->context && glXMakeCurrent(X11->display, d->drawable, d->context)) { d->initialized = true; } else { qWarning("QGLTempContext: Unable to create GL context."); XDestroyWindow(X11->display, d->drawable); } XFree(vi); } QGLTemporaryContext::~QGLTemporaryContext() { if (d->initialized) { glXMakeCurrent(X11->display, 0, 0); glXDestroyContext(X11->display, d->context); XDestroyWindow(X11->display, d->drawable); } if (d->oldDrawable && d->oldContext) glXMakeCurrent(X11->display, d->oldDrawable, d->oldContext); } /***************************************************************************** QGLOverlayWidget (Internal overlay class for X11) *****************************************************************************/ class QGLOverlayWidget : public QGLWidget { Q_OBJECT public: QGLOverlayWidget(const QGLFormat& format, QGLWidget* parent, const QGLWidget* shareWidget=0); protected: void initializeGL(); void paintGL(); void resizeGL(int w, int h); bool x11Event(XEvent *e) { return realWidget->x11Event(e); } private: QGLWidget* realWidget; private: Q_DISABLE_COPY(QGLOverlayWidget) }; QGLOverlayWidget::QGLOverlayWidget(const QGLFormat& format, QGLWidget* parent, const QGLWidget* shareWidget) : QGLWidget(format, parent, shareWidget ? shareWidget->d_func()->olw : 0) { setAttribute(Qt::WA_X11OpenGLOverlay); realWidget = parent; } void QGLOverlayWidget::initializeGL() { QColor transparentColor = context()->overlayTransparentColor(); if (transparentColor.isValid()) qglClearColor(transparentColor); else qWarning("QGLOverlayWidget::initializeGL(): Could not get transparent color"); realWidget->initializeOverlayGL(); } void QGLOverlayWidget::resizeGL(int w, int h) { glViewport(0, 0, w, h); realWidget->resizeOverlayGL(w, h); } void QGLOverlayWidget::paintGL() { realWidget->paintOverlayGL(); } #undef Bool QT_BEGIN_INCLUDE_NAMESPACE #include "qgl_x11.moc" QT_END_INCLUDE_NAMESPACE /***************************************************************************** QGLWidget UNIX/GLX-specific code *****************************************************************************/ void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) { Q_Q(QGLWidget); initContext(context, shareWidget); olw = 0; if (q->isValid() && context->format().hasOverlay()) { QString olwName = q->objectName(); olwName += QLatin1String("-QGL_internal_overlay_widget"); olw = new QGLOverlayWidget(QGLFormat::defaultOverlayFormat(), q, shareWidget); olw->setObjectName(olwName); if (olw->isValid()) { olw->setAutoBufferSwap(false); olw->setFocusProxy(q); } else { delete olw; olw = 0; glcx->d_func()->glFormat.setOverlay(false); } } } bool QGLWidgetPrivate::renderCxPm(QPixmap* pm) { Q_Q(QGLWidget); if (((XVisualInfo*)glcx->d_func()->vi)->depth != pm->depth()) return false; GLXPixmap glPm; #if defined(GLX_MESA_pixmap_colormap) && defined(QGL_USE_MESA_EXT) glPm = glXCreateGLXPixmapMESA(X11->display, (XVisualInfo*)glcx->vi, (Pixmap)pm->handle(), qt_gl_choose_cmap(pm->X11->display, (XVisualInfo*)glcx->vi)); #else glPm = (quint32)glXCreateGLXPixmap(X11->display, (XVisualInfo*)glcx->d_func()->vi, (Pixmap)pm->handle()); #endif if (!glXMakeCurrent(X11->display, glPm, (GLXContext)glcx->d_func()->cx)) { glXDestroyGLXPixmap(X11->display, glPm); return false; } glDrawBuffer(GL_FRONT); if (!glcx->initialized()) q->glInit(); q->resizeGL(pm->width(), pm->height()); q->paintGL(); glFlush(); q->makeCurrent(); glXDestroyGLXPixmap(X11->display, glPm); q->resizeGL(q->width(), q->height()); return true; } void QGLWidgetPrivate::cleanupColormaps() { if (!cmap.handle()) { return; } else { XFreeColormap(X11->display, (Colormap) cmap.handle()); cmap.setHandle(0); } } void QGLWidget::setMouseTracking(bool enable) { Q_D(QGLWidget); if (d->olw) d->olw->setMouseTracking(enable); QWidget::setMouseTracking(enable); } void QGLWidget::resizeEvent(QResizeEvent *) { Q_D(QGLWidget); if (!isValid()) return; makeCurrent(); if (!d->glcx->initialized()) glInit(); glXWaitX(); resizeGL(width(), height()); if (d->olw) d->olw->setGeometry(rect()); } const QGLContext* QGLWidget::overlayContext() const { Q_D(const QGLWidget); if (d->olw) return d->olw->context(); else return 0; } void QGLWidget::makeOverlayCurrent() { Q_D(QGLWidget); if (d->olw) d->olw->makeCurrent(); } void QGLWidget::updateOverlayGL() { Q_D(QGLWidget); if (d->olw) d->olw->updateGL(); } /*! \internal Sets a new QGLContext, \a context, for this QGLWidget, using the shared context, \a shareContext. If \a deleteOldContext is true, the original context is deleted; otherwise it is overridden. */ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext) { Q_D(QGLWidget); if (context == 0) { qWarning("QGLWidget::setContext: Cannot set null context"); return; } if (!context->deviceIsPixmap() && context->device() != this) { qWarning("QGLWidget::setContext: Context must refer to this widget"); return; } if (d->glcx) d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; if (parentWidget()) { // force creation of delay-created widgets parentWidget()->winId(); if (parentWidget()->x11Info().screen() != x11Info().screen()) d_func()->xinfo = parentWidget()->d_func()->xinfo; } // If the application has set WA_TranslucentBackground and not explicitly set // the alpha buffer size to zero, modify the format so it have an alpha channel QGLFormat& fmt = d->glcx->d_func()->glFormat; if (testAttribute(Qt::WA_TranslucentBackground) && fmt.alphaBufferSize() == -1) fmt.setAlphaBufferSize(1); bool createFailed = false; if (!d->glcx->isValid()) { if (!d->glcx->create(shareContext ? shareContext : oldcx)) createFailed = true; } if (createFailed) { if (deleteOldContext) delete oldcx; return; } if (d->glcx->windowCreated() || d->glcx->deviceIsPixmap()) { if (deleteOldContext) delete oldcx; return; } bool visible = isVisible(); if (visible) hide(); XVisualInfo *vi = (XVisualInfo*)d->glcx->d_func()->vi; XSetWindowAttributes a; QColormap colmap = QColormap::instance(vi->screen); a.colormap = qt_gl_choose_cmap(QX11Info::display(), vi); // find best colormap a.background_pixel = colmap.pixel(palette().color(backgroundRole())); a.border_pixel = colmap.pixel(Qt::black); Window p = RootWindow(X11->display, vi->screen); if (parentWidget()) p = parentWidget()->winId(); Window w = XCreateWindow(X11->display, p, x(), y(), width(), height(), 0, vi->depth, InputOutput, vi->visual, CWBackPixel|CWBorderPixel|CWColormap, &a); Window *cmw; Window *cmwret; int count; if (XGetWMColormapWindows(X11->display, window()->winId(), &cmwret, &count)) { cmw = new Window[count+1]; memcpy((char *)cmw, (char *)cmwret, sizeof(Window)*count); XFree((char *)cmwret); int i; for (i=0; i<count; i++) { if (cmw[i] == winId()) { // replace old window cmw[i] = w; break; } } if (i >= count) // append new window cmw[count++] = w; } else { count = 1; cmw = new Window[count]; cmw[0] = w; } #if defined(GLX_MESA_release_buffers) && defined(QGL_USE_MESA_EXT) if (oldcx && oldcx->windowCreated()) glXReleaseBuffersMESA(X11->display, winId()); #endif if (deleteOldContext) delete oldcx; oldcx = 0; if (testAttribute(Qt::WA_WState_Created)) create(w); else d->createWinId(w); XSetWMColormapWindows(X11->display, window()->winId(), cmw, count); delete [] cmw; // calling QWidget::create() will always result in a new paint // engine being created - get rid of it and replace it with our // own if (visible) show(); XFlush(X11->display); d->glcx->setWindowCreated(true); } const QGLColormap & QGLWidget::colormap() const { Q_D(const QGLWidget); return d->cmap; } /*\internal Store color values in the given colormap. */ static void qStoreColors(QWidget * tlw, Colormap cmap, const QGLColormap & cols) { Q_UNUSED(tlw); XColor c; QRgb color; for (int i = 0; i < cols.size(); i++) { color = cols.entryRgb(i); c.pixel = i; c.red = (ushort)((qRed(color) / 255.0) * 65535.0 + 0.5); c.green = (ushort)((qGreen(color) / 255.0) * 65535.0 + 0.5); c.blue = (ushort)((qBlue(color) / 255.0) * 65535.0 + 0.5); c.flags = DoRed | DoGreen | DoBlue; XStoreColor(X11->display, cmap, &c); } } /*\internal Check whether the given visual supports dynamic colormaps or not. */ static bool qCanAllocColors(QWidget * w) { bool validVisual = false; int numVisuals; long mask; XVisualInfo templ; XVisualInfo * visuals; VisualID id = XVisualIDFromVisual((Visual *) w->window()->x11Info().visual()); mask = VisualScreenMask; templ.screen = w->x11Info().screen(); visuals = XGetVisualInfo(X11->display, mask, &templ, &numVisuals); for (int i = 0; i < numVisuals; i++) { if (visuals[i].visualid == id) { switch (visuals[i].c_class) { case TrueColor: case StaticColor: case StaticGray: case XGrayScale: validVisual = false; break; case DirectColor: case PseudoColor: validVisual = true; break; } break; } } XFree(visuals); if (!validVisual) return false; return true; } void QGLWidget::setColormap(const QGLColormap & c) { Q_D(QGLWidget); QWidget * tlw = window(); // must return a valid widget d->cmap = c; if (!d->cmap.handle()) return; if (!qCanAllocColors(this)) { qWarning("QGLWidget::setColormap: Cannot create a read/write " "colormap for this visual"); return; } // If the child GL widget is not of the same visual class as the // toplevel widget we will get in trouble.. Window wid = tlw->winId(); Visual * vis = (Visual *) tlw->x11Info().visual();; VisualID cvId = XVisualIDFromVisual((Visual *) x11Info().visual()); VisualID tvId = XVisualIDFromVisual((Visual *) tlw->x11Info().visual()); if (cvId != tvId) { wid = winId(); vis = (Visual *) x11Info().visual(); } if (!d->cmap.handle()) // allocate a cmap if necessary d->cmap.setHandle(XCreateColormap(X11->display, wid, vis, AllocAll)); qStoreColors(this, (Colormap) d->cmap.handle(), c); XSetWindowColormap(X11->display, wid, (Colormap) d->cmap.handle()); // tell the wm that this window has a special colormap Window * cmw; Window * cmwret; int count; if (XGetWMColormapWindows(X11->display, tlw->winId(), &cmwret, &count)) { cmw = new Window[count+1]; memcpy((char *) cmw, (char *) cmwret, sizeof(Window) * count); XFree((char *) cmwret); int i; for (i = 0; i < count; i++) { if (cmw[i] == winId()) { break; } } if (i >= count) // append new window only if not in the list cmw[count++] = winId(); } else { count = 1; cmw = new Window[count]; cmw[0] = winId(); } XSetWMColormapWindows(X11->display, tlw->winId(), cmw, count); delete [] cmw; } // Solaris defines glXBindTexImageEXT as part of the GL library #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) typedef void (*qt_glXBindTexImageEXT)(Display*, GLXDrawable, int, const int*); typedef void (*qt_glXReleaseTexImageEXT)(Display*, GLXDrawable, int); static qt_glXBindTexImageEXT glXBindTexImageEXT = 0; static qt_glXReleaseTexImageEXT glXReleaseTexImageEXT = 0; static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice) { static bool resolvedTextureFromPixmap = false; if (!resolvedTextureFromPixmap) { resolvedTextureFromPixmap = true; // Check to see if we have NPOT texture support if ( !(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)) { return false; // Can't use TFP without NPOT } const QX11Info *xinfo = qt_x11Info(paintDevice); Display *display = xinfo ? xinfo->display() : X11->display; int screen = xinfo ? xinfo->screen() : X11->defaultScreen; QGLExtensionMatcher serverExtensions(glXQueryExtensionsString(display, screen)); QGLExtensionMatcher clientExtensions(glXGetClientString(display, GLX_EXTENSIONS)); if (serverExtensions.match("GLX_EXT_texture_from_pixmap") && clientExtensions.match("GLX_EXT_texture_from_pixmap")) { glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); } } return glXBindTexImageEXT && glXReleaseTexImageEXT; } #endif //defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, const qint64 key, QGLContext::BindOptions options) { #if !defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX) return 0; #else // Check we have GLX 1.3, as it is needed for glXCreatePixmap & glXDestroyPixmap int majorVersion = 0; int minorVersion = 0; glXQueryVersion(X11->display, &majorVersion, &minorVersion); if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 3)) return 0; Q_Q(QGLContext); QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pixmap->data_ptr().data()); Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class); // We can't use TFP if the pixmap has a separate X11 mask if (pixmapData->x11_mask) return 0; if (!qt_resolveTextureFromPixmap(paintDevice)) return 0; const QX11Info &x11Info = pixmapData->xinfo; // Store the configs (Can be static because configs aren't dependent on current context) static GLXFBConfig glxRGBPixmapConfig = 0; static bool RGBConfigInverted = false; static GLXFBConfig glxRGBAPixmapConfig = 0; static bool RGBAConfigInverted = false; bool hasAlpha = pixmapData->hasAlphaChannel(); // Check to see if we need a config if ( (hasAlpha && !glxRGBAPixmapConfig) || (!hasAlpha && !glxRGBPixmapConfig) ) { GLXFBConfig *configList = 0; int configCount = 0; int configAttribs[] = { hasAlpha ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT, True, GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT, // QGLContext::bindTexture() can't return an inverted texture, but QPainter::drawPixmap() can: GLX_Y_INVERTED_EXT, int(options & QGLContext::CanFlipNativePixmapBindOption ? GLX_DONT_CARE : False), XNone }; configList = glXChooseFBConfig(x11Info.display(), x11Info.screen(), configAttribs, &configCount); if (!configList) return 0; int yInv; glXGetFBConfigAttrib(x11Info.display(), configList[0], GLX_Y_INVERTED_EXT, &yInv); if (hasAlpha) { glxRGBAPixmapConfig = configList[0]; RGBAConfigInverted = yInv; } else { glxRGBPixmapConfig = configList[0]; RGBConfigInverted = yInv; } XFree(configList); } // Check to see if the surface is still valid if (pixmapData->gl_surface && hasAlpha != (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha)) { // Surface is invalid! destroyGlSurfaceForPixmap(pixmapData); } // Check to see if we need a surface if (!pixmapData->gl_surface) { GLXPixmap glxPixmap; int pixmapAttribs[] = { GLX_TEXTURE_FORMAT_EXT, hasAlpha ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT, GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, GLX_MIPMAP_TEXTURE_EXT, False, // Maybe needs to be don't care XNone }; // Wrap the X Pixmap into a GLXPixmap: glxPixmap = glXCreatePixmap(x11Info.display(), hasAlpha ? glxRGBAPixmapConfig : glxRGBPixmapConfig, pixmapData->handle(), pixmapAttribs); if (!glxPixmap) return 0; pixmapData->gl_surface = (void*)glxPixmap; // Make sure the cleanup hook gets called so we can delete the glx pixmap QImagePixmapCleanupHooks::enableCleanupHooks(pixmapData); } GLuint textureId; glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0); glBindTexture(GL_TEXTURE_2D, textureId); GLuint filtering = (options & QGLContext::LinearFilteringBindOption) ? GL_LINEAR : GL_NEAREST; glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); if (!((hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted))) options &= ~QGLContext::InvertedYBindOption; QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options); if (texture->options & QGLContext::InvertedYBindOption) pixmapData->flags |= QX11PixmapData::InvertedWhenBoundToTexture; // We assume the cost of bound pixmaps is zero QGLTextureCache::instance()->insert(q, key, texture, 0); return texture; #endif //!defined(GLX_VERSION_1_3) || defined(Q_OS_HPUX) } void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd) { #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) Q_ASSERT(pmd->classId() == QPixmapData::X11Class); QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); if (pixmapData->gl_surface) { glXDestroyPixmap(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface); pixmapData->gl_surface = 0; } #endif } void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd) { #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX) Q_ASSERT(pmd->classId() == QPixmapData::X11Class); Q_ASSERT(QGLContext::currentContext()); QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); if (pixmapData->gl_surface) glXReleaseTexImageEXT(QX11Info::display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT); #endif } QT_END_NAMESPACE
nonrational/qt-everywhere-opensource-src-4.8.6
src/opengl/qgl_x11.cpp
C++
lgpl-2.1
64,669
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: 'Games and Actors (UPDATE)' date: 2005-06-09 13:48 comments: true categories : [] --- So I logon this morning and read over at <a href="http://www.wired.com/news/business/0,1367,67803,00.html?tw=rss.TOP">Wired</a> that there's been a settlement between SAG Actors and video game developers. <blockquote> SAN FRANCISCO -- Hollywood actors unions have reached a contract deal with video game publishers, accepting higher pay instead of the profit-sharing they had demanded, the unions said Wednesday, removing the threat of a strike. The three-and-a-half-year agreements with game companies came as the Screen Actors Guild and American Federation of Television and Radio Artists were preparing to announce the results of a strike vote. Unions had sought to win profit-sharing, known as residual payments, from game publishers.</blockquote> While I'm happy that the Actors are getting a pay raise I still don't agree that they should get a residual payment from every game sold. I do however love the quote from Laura Ingalls. <blockquote>"We will spend the next three-and-a-half years devoting resources to further organize this industry, and return to the bargaining table with renewed strength and vigor to establish a fair participation in the enormous profits generated by video games," said Melissa Gilbert, SAG president.</blockquote> I mean for gods sakes woman...this isn't Little House on the Prairie. At least <a href="http://www.wilwheaton.net/mt/archives/003293.php#003293">Wil Wheaton</a> has the right idea when he says <blockquote><i>"Developers: We're on the same side, guys, and by playing into "Actors vs. Developers," you've let the game producers divide and conquer us. If you're getting screwed, why not organize a union? I seriously doubt they could replace programmers, designers, and developers with Becky and Don from ad sales. You've got to believe in yourself, and not undervalue the importance of your contribution to the final product. We should be talking about the common goals we have, and how we can reach then, rather than arguing about who is more important."</i></blockquote>
fusion94/fusion94.github.io
_posts/2005-06-09-games-and-actors-update.md
Markdown
mit
2,156
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1005, 2399, 1998, 5889, 1006, 10651, 1007, 1005, 3058, 1024, 2384, 1011, 5757, 1011, 5641, 2410, 1024, 4466, 7928, 1024, 2995, 7236, 1024, 1031, 1033, 1011, 1011, 1011, 2061, 1045, 81...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * $Id$ * * Copyright 2008 secure-net-concepts <info@secure-net-concepts.de> * * This file is part of Nagios Administrator http://www.nagiosadmin.de. * * Nagios Administrator is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Nagios Administrator is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Nagios Administrator. If not, see <http://www.gnu.org/licenses/>. * * @package nagiosadmin * @subpackage generator * @license http://www.gnu.org/licenses/gpl.html * @link www.nagiosadmin.de * @version $Revision$ * @author Henrik Westphal <westphal@secure-net-concepts.de> */ ?> </div> </div>
senecon/nagiosadmin
apps/backend/modules/generator/templates/_generator_footer.php
PHP
gpl-3.0
1,088
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 1002, 8909, 1002, 1008, 1008, 9385, 2263, 5851, 1011, 5658, 1011, 8474, 1026, 18558, 1030, 5851, 1011, 5658, 1011, 8474, 1012, 2139, 1028, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 6583, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Purpose: dxf engine for R2007/AC1021 # Created: 12.03.2011 # Copyright (C) , Manfred Moitzi # License: MIT License from __future__ import unicode_literals __author__ = "mozman <mozman@gmx.at>" from .headervars import VARMAP from ..ac1018 import AC1018Factory class AC1021Factory(AC1018Factory): HEADERVARS = dict(VARMAP)
lautr3k/RepRap-iTopie
odmt/ezdxf/ac1021/__init__.py
Python
gpl-3.0
330
[ 30522, 1001, 3800, 1024, 1040, 2595, 2546, 3194, 2005, 1054, 28332, 2581, 1013, 9353, 10790, 17465, 1001, 2580, 1024, 2260, 1012, 6021, 1012, 2249, 1001, 9385, 1006, 1039, 1007, 1010, 19149, 25175, 5753, 2072, 1001, 6105, 1024, 10210, 6105,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <title>Docs For Class PHPExcel_Writer_Excel2007_ContentTypes</title> <link rel="stylesheet" type="text/css" href="../media/style.css"> </head> <body> <table border="0" cellspacing="0" cellpadding="0" height="48" width="100%"> <tr> <td class="header_top">PHPExcel_Writer_Excel2007</td> </tr> <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr> <tr> <td class="header_menu"> [ <a href="../classtrees_PHPExcel_Writer_Excel2007.html" class="menu">class tree: PHPExcel_Writer_Excel2007</a> ] [ <a href="../elementindex_PHPExcel_Writer_Excel2007.html" class="menu">index: PHPExcel_Writer_Excel2007</a> ] [ <a href="../elementindex.html" class="menu">all elements</a> ] </td> </tr> <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="200" class="menu"> <div id="todolist"> <p><a href="../todolist.html">Todo List</a></p> </div> <b>Packages:</b><br /> <a href="../li_PHPExcel.html">PHPExcel</a><br /> <a href="../li_com-tecnick-tcpdf.html">com-tecnick-tcpdf</a><br /> <a href="../li_JAMA.html">JAMA</a><br /> <a href="../li_Math_Stats.html">Math_Stats</a><br /> <a href="../li_PHPExcel_CachedObjectStorage.html">PHPExcel_CachedObjectStorage</a><br /> <a href="../li_PHPExcel_Calculation.html">PHPExcel_Calculation</a><br /> <a href="../li_PHPExcel_Cell.html">PHPExcel_Cell</a><br /> <a href="../li_PHPExcel_Reader.html">PHPExcel_Reader</a><br /> <a href="../li_PHPExcel_Reader_Excel5.html">PHPExcel_Reader_Excel5</a><br /> <a href="../li_PHPExcel_RichText.html">PHPExcel_RichText</a><br /> <a href="../li_PHPExcel_Settings.html">PHPExcel_Settings</a><br /> <a href="../li_PHPExcel_Shared.html">PHPExcel_Shared</a><br /> <a href="../li_PHPExcel_Shared_Best_Fit.html">PHPExcel_Shared_Best_Fit</a><br /> <a href="../li_PHPExcel_Shared_Escher.html">PHPExcel_Shared_Escher</a><br /> <a href="../li_PHPExcel_Shared_OLE.html">PHPExcel_Shared_OLE</a><br /> <a href="../li_PHPExcel_Style.html">PHPExcel_Style</a><br /> <a href="../li_PHPExcel_Worksheet.html">PHPExcel_Worksheet</a><br /> <a href="../li_PHPExcel_Worksheet_Drawing.html">PHPExcel_Worksheet_Drawing</a><br /> <a href="../li_PHPExcel_Writer.html">PHPExcel_Writer</a><br /> <a href="../li_PHPExcel_Writer_Excel5.html">PHPExcel_Writer_Excel5</a><br /> <a href="../li_PHPExcel_Writer_Excel2007.html">PHPExcel_Writer_Excel2007</a><br /> <br /><br /> <b>Files:</b><br /> <div class="package"> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Comments.php.html"> Comments.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---ContentTypes.php.html"> ContentTypes.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---DocProps.php.html"> DocProps.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Drawing.php.html"> Drawing.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007.php.html"> Excel2007.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Rels.php.html"> Rels.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---StringTable.php.html"> StringTable.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Style.php.html"> Style.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Theme.php.html"> Theme.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Workbook.php.html"> Workbook.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---Worksheet.php.html"> Worksheet.php </a><br> <a href="../PHPExcel_Writer_Excel2007/_PHPExcel---Writer---Excel2007---WriterPart.php.html"> WriterPart.php </a><br> </div><br /> <b>Classes:</b><br /> <div class="package"> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007.html">PHPExcel_Writer_Excel2007</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Comments.html">PHPExcel_Writer_Excel2007_Comments</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_ContentTypes.html">PHPExcel_Writer_Excel2007_ContentTypes</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_DocProps.html">PHPExcel_Writer_Excel2007_DocProps</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Drawing.html">PHPExcel_Writer_Excel2007_Drawing</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Rels.html">PHPExcel_Writer_Excel2007_Rels</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_StringTable.html">PHPExcel_Writer_Excel2007_StringTable</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Style.html">PHPExcel_Writer_Excel2007_Style</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Theme.html">PHPExcel_Writer_Excel2007_Theme</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Workbook.html">PHPExcel_Writer_Excel2007_Workbook</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_Worksheet.html">PHPExcel_Writer_Excel2007_Worksheet</a><br /> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_WriterPart.html">PHPExcel_Writer_Excel2007_WriterPart</a><br /> </div> </td> <td> <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top"> <h1>Class: PHPExcel_Writer_Excel2007_ContentTypes</h1> Source Location: /PHPExcel/Writer/Excel2007/ContentTypes.php<br /><br /> <table width="100%" border="0"> <tr><td valign="top"> <h3><a href="#class_details">Class Overview</a></h3> <pre><a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_WriterPart.html">PHPExcel_Writer_Excel2007_WriterPart</a> | --PHPExcel_Writer_Excel2007_ContentTypes</pre><br /> <div class="description">PHPExcel_Writer_Excel2007_ContentTypes</div><br /><br /> <h4>Author(s):</h4> <ul> </ul> <h4>Copyright:</h4> <ul> <li>Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)</li> </ul> </td> <td valign="top"> <h3><a href="#class_methods">Methods</a></h3> <ul> <li><a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_ContentTypes.html#methodwriteContentTypes">writeContentTypes</a></li> </ul> </td> </tr></table> <hr /> <table width="100%" border="0"><tr> <td valign="top"> <h3>Inherited Methods</h3> <div class="tags"> <h4>Class: <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_WriterPart.html">PHPExcel_Writer_Excel2007_WriterPart</a></h4> <dl> <dt> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_WriterPart.html#methodgetParentWriter">PHPExcel_Writer_Excel2007_WriterPart::getParentWriter()</a> </dt> <dd> Get parent IWriter object </dd> <dt> <a href="../PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_WriterPart.html#methodsetParentWriter">PHPExcel_Writer_Excel2007_WriterPart::setParentWriter()</a> </dt> <dd> Set parent IWriter object </dd> </dl> </div> </td> </tr></table> <hr /> <a name="class_details"></a> <h3>Class Details</h3> <div class="tags"> [line <a href="../__filesource/fsource_PHPExcel_Writer_Excel2007__PHPExcelWriterExcel2007ContentTypes.php.html#a36">36</a>]<br /> PHPExcel_Writer_Excel2007_ContentTypes<br /><br /><br /><br /> <h4>Tags:</h4> <div class="tags"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><b>copyright:</b>&nbsp;&nbsp;</td><td>Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)</td> </tr> </table> </div> </div><br /><br /> <div class="top">[ <a href="#top">Top</a> ]</div><br /> <hr /> <a name="class_methods"></a> <h3>Class Methods</h3> <div class="tags"> <hr /> <a name="methodwriteContentTypes"></a> <h3>method writeContentTypes <span class="smalllinenumber">[line <a href="../__filesource/fsource_PHPExcel_Writer_Excel2007__PHPExcelWriterExcel2007ContentTypes.php.html#a45">45</a>]</span></h3> <div class="function"> <table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border"> <table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code"> <code>string writeContentTypes( [ $pPHPExcel = null])</code> </td></tr></table> </td></tr></table><br /> Write content types to XML format<br /><br /><br /><br /> <h4>Tags:</h4> <div class="tags"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td><b>return:</b>&nbsp;&nbsp;</td><td>XML Output</td> </tr> <tr> <td><b>throws:</b>&nbsp;&nbsp;</td><td>Exception</td> </tr> <tr> <td><b>access:</b>&nbsp;&nbsp;</td><td>public</td> </tr> </table> </div> <br /><br /> <h4>Parameters:</h4> <div class="tags"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="type"><a href="../PHPExcel/PHPExcel.html">PHPExcel</a>&nbsp;&nbsp;</td> <td><b>$pPHPExcel</b>&nbsp;&nbsp;</td> <td></td> </tr> </table> </div><br /> <div class="top">[ <a href="#top">Top</a> ]</div> </div> </div><br /> <div class="credit"> <hr /> Documentation generated on Thu, 26 Aug 2010 17:41:02 +0200 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a> </div> </td></tr></table> </td> </tr> </table> </body> </html>
HadoDokis/Pragtico
app/vendors/PHPExcel/Documentation/API/PHPExcel_Writer_Excel2007/PHPExcel_Writer_Excel2007_ContentTypes.html
HTML
mit
10,605
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 9986, 2015, 2005, 2465, 25718, 10288, 29109, 1035, 3213, 1035, 24970, 28332, 2581, 1035, 4180, 13874, 2015, 1026, 1013, 2516, 1028, 1026, 4957, 2128, 2140, 1027, 1000, 6782, 2103...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
export const PlusCircle = ` <svg viewBox="0 0 28 28"> <g fill="none" fill-rule="evenodd"> <path d="M8 14h12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/> <circle stroke="currentColor" cx="14" cy="14" r="13"/> <path d="M14 8v12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/> </g> </svg>`;
clair-design/clair
packages/icons/icons/PlusCircle.ts
TypeScript
mit
355
[ 30522, 9167, 9530, 3367, 4606, 6895, 21769, 1027, 1036, 1026, 17917, 2290, 3193, 8758, 1027, 1000, 1014, 1014, 2654, 2654, 1000, 1028, 1026, 1043, 6039, 1027, 1000, 3904, 1000, 6039, 1011, 3627, 1027, 1000, 2130, 7716, 2094, 1000, 1028, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// This program sends logging records directly to the server, rather // than going through the client logging daemon. #include "ace/SOCK_Connector.h" #include "ace/Log_Record.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_time.h" #include "ace/OS_NS_stdlib.h" #include "ace/OS_NS_unistd.h" #include "ace/CDR_Stream.h" static u_short LOGGER_PORT = ACE_DEFAULT_SERVER_PORT; static const ACE_TCHAR *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST; static const ACE_TCHAR *const DATA = ACE_TEXT ("hello world\n"); int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { u_short logger_port = argc > 1 ? ACE_OS::atoi (argv[1]) : LOGGER_PORT; const ACE_TCHAR *logger_host = argc > 2 ? argv[2] : LOGGER_HOST; ACE_SOCK_Stream logger; ACE_SOCK_Connector connector; ACE_INET_Addr addr (logger_port, logger_host); ACE_Log_Record log_record (LM_DEBUG, ACE_OS::time ((time_t *) 0), ACE_OS::getpid ()); if (connector.connect (logger, addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); log_record.msg_data (DATA); const size_t max_payload_size = 4 // type() + 8 // timestamp + 4 // process id + 4 // data length + ACE_Log_Record::MAXLOGMSGLEN // data + ACE_CDR::MAX_ALIGNMENT; // padding; // Insert contents of <log_record> into payload stream. ACE_OutputCDR payload (max_payload_size); payload << log_record; // Get the number of bytes used by the CDR stream. ACE_CDR::ULong length = payload.total_length (); // Send a header so the receiver can determine the byte order and // size of the incoming CDR stream. ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8); header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); // Store the size of the payload that follows header << ACE_CDR::ULong (length); // Use an iovec to send both buffer and payload simultaneously. iovec iov[2]; iov[0].iov_base = header.begin ()->rd_ptr (); iov[0].iov_len = 8; iov[1].iov_base = payload.begin ()->rd_ptr (); iov[1].iov_len = length; if (logger.sendv_n (iov, 2) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); else if (logger.close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); #if defined (ACE_WIN32) // !!Important, Winsock is broken in that if you don't close // down the connection before exiting main, you'll lose data. // More over, your server might get "Access Violation" from // within Winsock functions. // Here we close down the connection to Logger by redirecting // the logging destination back to stderr. ACE_LOG_MSG->open (0, ACE_Log_Msg::STDERR, 0); #endif /* ACE_WIN32 */ return 0; }
wfnex/openbras
src/ace/ACE_wrappers/netsvcs/clients/Logger/direct_logging.cpp
C++
bsd-3-clause
2,682
[ 30522, 1013, 1013, 2023, 2565, 10255, 15899, 2636, 3495, 2000, 1996, 8241, 1010, 2738, 1013, 1013, 2084, 2183, 2083, 1996, 7396, 15899, 12828, 1012, 1001, 2421, 1000, 9078, 1013, 28407, 1035, 19400, 1012, 1044, 1000, 1001, 2421, 1000, 9078,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2015, Simon Fuhrmann * TU Darmstadt - Graphics, Capture and Massively Parallel Computing * All rights reserved. * * This software may be modified and distributed under the terms * of the BSD 3-Clause license. See the LICENSE.txt file for details. */ #ifndef SFM_TRIANGULATE_HEADER #define SFM_TRIANGULATE_HEADER #include <vector> #include <ostream> #include "math/vector.h" #include "sfm/correspondence.h" #include "sfm/camera_pose.h" #include "sfm/defines.h" SFM_NAMESPACE_BEGIN /* ---------------- Low-level triangulation solver ---------------- */ /** * Given an image correspondence in two views and the corresponding poses, * this function triangulates the 3D point coordinate using the DLT algorithm. */ math::Vector<double, 3> triangulate_match (Correspondence2D2D const& match, CameraPose const& pose1, CameraPose const& pose2); /** * Given any number of 2D image positions and the corresponding camera poses, * this function triangulates the 3D point coordinate using the DLT algorithm. */ math::Vector<double, 3> triangulate_track (std::vector<math::Vec2f> const& pos, std::vector<CameraPose const*> const& poses); /** * Given a two-view pose configuration and a correspondence, this function * returns true if the triangulated point is in front of both cameras. */ bool is_consistent_pose (Correspondence2D2D const& match, CameraPose const& pose1, CameraPose const& pose2); /* --------------- Higher-level triangulation class --------------- */ /** * Triangulation routine that triangulates a track from camera poses and * 2D image positions while keeping triangulation statistics. In contrast * to the low-level functions, this implementation checks for triangulation * problems such as large reprojection error, tracks appearing behind the * camera, and unstable triangulation angles. */ class Triangulate { public: struct Options { Options (void); /** Threshold on reprojection error for outlier detection. */ double error_threshold; /** Threshold on the triangulation angle (in radians). */ double angle_threshold; /** Minimal number of views with small error (inliers). */ int min_num_views; }; struct Statistics { Statistics (void); /** The number of successfully triangulated tracks. */ int num_new_tracks; /** Number of tracks with too large reprojection error. */ int num_large_error; /** Number of tracks that appeared behind the camera. */ int num_behind_camera; /** Number of tracks with too small triangulation angle. */ int num_too_small_angle; }; public: explicit Triangulate (Options const& options); bool triangulate (std::vector<CameraPose const*> const& poses, std::vector<math::Vec2f> const& positions, math::Vec3d* track_pos, Statistics* stats = nullptr, std::vector<std::size_t>* outliers = nullptr) const; void print_statistics (Statistics const& stats, std::ostream& out) const; private: Options const opts; double const cos_angle_thres; }; /* ------------------------ Implementation ------------------------ */ inline Triangulate::Options::Options (void) : error_threshold(0.01) , angle_threshold(MATH_DEG2RAD(1.0)) , min_num_views(2) { } inline Triangulate::Statistics::Statistics (void) : num_new_tracks(0) , num_large_error(0) , num_behind_camera(0) , num_too_small_angle(0) { } inline Triangulate::Triangulate (Options const& options) : opts(options) , cos_angle_thres(std::cos(options.angle_threshold)) { } SFM_NAMESPACE_END #endif // SFM_TRIANGULATE_HEADER
AIBluefisher/SfM
DeepBlue/3D_reconstruction/ImageBasedModellingEdu/sfm/triangulate.h
C
gpl-3.0
3,705
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2325, 1010, 4079, 11865, 8093, 5804, 1008, 10722, 28381, 1011, 8389, 1010, 5425, 1998, 5294, 2135, 5903, 9798, 1008, 2035, 2916, 9235, 1012, 30524, 1035, 20346, 1001, 9375, 16420, 2213, 1035,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * @package Joomla.Administrator * @subpackage com_finder * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die; JLoader::register('FinderIndexer', __DIR__ . '/indexer.php'); /** * Result class for the Finder indexer package. * * This class uses magic __get() and __set() methods to prevent properties * being added that might confuse the system. All properties not explicitly * declared will be pushed into the elements array and can be accessed * explicitly using the getElement() method. * * @since 2.5 */ class FinderIndexerResult { /** * An array of extra result properties. * * @var array * @since 2.5 */ protected $elements = array(); /** * This array tells the indexer which properties should be indexed and what * weights to use for those properties. * * @var array * @since 2.5 */ protected $instructions = array( FinderIndexer::TITLE_CONTEXT => array('title', 'subtitle', 'id'), FinderIndexer::TEXT_CONTEXT => array('summary', 'body'), FinderIndexer::META_CONTEXT => array('meta', 'list_price', 'sale_price'), FinderIndexer::PATH_CONTEXT => array('path', 'alias'), FinderIndexer::MISC_CONTEXT => array('comments') ); /** * The indexer will use this data to create taxonomy mapping entries for * the item so that it can be filtered by type, label, category, * or whatever. * * @var array * @since 2.5 */ protected $taxonomy = array(); /** * The content URL. * * @var string * @since 2.5 */ public $url; /** * The content route. * * @var string * @since 2.5 */ public $route; /** * The content title. * * @var string * @since 2.5 */ public $title; /** * The content description. * * @var string * @since 2.5 */ public $description; /** * The published state of the result. * * @var integer * @since 2.5 */ public $published; /** * The content published state. * * @var integer * @since 2.5 */ public $state; /** * The content access level. * * @var integer * @since 2.5 */ public $access; /** * The content language. * * @var string * @since 2.5 */ public $language = '*'; /** * The publishing start date. * * @var string * @since 2.5 */ public $publish_start_date; /** * The publishing end date. * * @var string * @since 2.5 */ public $publish_end_date; /** * The generic start date. * * @var string * @since 2.5 */ public $start_date; /** * The generic end date. * * @var string * @since 2.5 */ public $end_date; /** * The item list price. * * @var mixed * @since 2.5 */ public $list_price; /** * The item sale price. * * @var mixed * @since 2.5 */ public $sale_price; /** * The content type id. This is set by the adapter. * * @var integer * @since 2.5 */ public $type_id; /** * The default language for content. * * @var string * @since 3.0.2 */ public $defaultLanguage; /** * Constructor * * @since 3.0.3 */ public function __construct() { $this->defaultLanguage = JComponentHelper::getParams('com_languages')->get('site', 'en-GB'); } /** * The magic set method is used to push additional values into the elements * array in order to preserve the cleanliness of the object. * * @param string $name The name of the element. * @param mixed $value The value of the element. * * @return void * * @since 2.5 */ public function __set($name, $value) { $this->setElement($name, $value); } /** * The magic get method is used to retrieve additional element values from the elements array. * * @param string $name The name of the element. * * @return mixed The value of the element if set, null otherwise. * * @since 2.5 */ public function __get($name) { return $this->getElement($name); } /** * The magic isset method is used to check the state of additional element values in the elements array. * * @param string $name The name of the element. * * @return boolean True if set, false otherwise. * * @since 2.5 */ public function __isset($name) { return isset($this->elements[$name]); } /** * The magic unset method is used to unset additional element values in the elements array. * * @param string $name The name of the element. * * @return void * * @since 2.5 */ public function __unset($name) { unset($this->elements[$name]); } /** * Method to retrieve additional element values from the elements array. * * @param string $name The name of the element. * * @return mixed The value of the element if set, null otherwise. * * @since 2.5 */ public function getElement($name) { // Get the element value if set. if (array_key_exists($name, $this->elements)) { return $this->elements[$name]; } return null; } /** * Method to set additional element values in the elements array. * * @param string $name The name of the element. * @param mixed $value The value of the element. * * @return void * * @since 2.5 */ public function setElement($name, $value) { $this->elements[$name] = $value; } /** * Method to get all processing instructions. * * @return array An array of processing instructions. * * @since 2.5 */ public function getInstructions() { return $this->instructions; } /** * Method to add a processing instruction for an item property. * * @param string $group The group to associate the property with. * @param string $property The property to process. * * @return void * * @since 2.5 */ public function addInstruction($group, $property) { // Check if the group exists. We can't add instructions for unknown groups. if (array_key_exists($group, $this->instructions)) { // Check if the property exists in the group. if (!in_array($property, $this->instructions[$group])) { // Add the property to the group. $this->instructions[$group][] = $property; } } } /** * Method to remove a processing instruction for an item property. * * @param string $group The group to associate the property with. * @param string $property The property to process. * * @return void * * @since 2.5 */ public function removeInstruction($group, $property) { // Check if the group exists. We can't remove instructions for unknown groups. if (array_key_exists($group, $this->instructions)) { // Search for the property in the group. $key = array_search($property, $this->instructions[$group]); // If the property was found, remove it. if ($key !== false) { unset($this->instructions[$group][$key]); } } } /** * Method to get the taxonomy maps for an item. * * @param string $branch The taxonomy branch to get. [optional] * * @return array An array of taxonomy maps. * * @since 2.5 */ public function getTaxonomy($branch = null) { // Get the taxonomy branch if available. if ($branch !== null && isset($this->taxonomy[$branch])) { // Filter the input. $branch = preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,_]+#mui', ' ', $branch); return $this->taxonomy[$branch]; } return $this->taxonomy; } /** * Method to add a taxonomy map for an item. * * @param string $branch The title of the taxonomy branch to add the node to. * @param string $title The title of the taxonomy node. * @param integer $state The published state of the taxonomy node. [optional] * @param integer $access The access level of the taxonomy node. [optional] * * @return void * * @since 2.5 */ public function addTaxonomy($branch, $title, $state = 1, $access = 1) { // Filter the input. $branch = preg_replace('#[^\pL\pM\pN\p{Pi}\p{Pf}\'+-.,_]+#mui', ' ', $branch); // Create the taxonomy node. $node = new JObject; $node->title = $title; $node->state = (int) $state; $node->access = (int) $access; // Add the node to the taxonomy branch. $this->taxonomy[$branch][$node->title] = $node; } /** * Method to set the item language * * @return void * * @since 3.0 */ public function setLanguage() { if ($this->language == '') { $this->language = $this->defaultLanguage; } } }
muhakh/joomla-cms
administrator/components/com_finder/helpers/indexer/result.php
PHP
gpl-2.0
8,566
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 1030, 7427, 28576, 19968, 2050, 1012, 8911, 1008, 1030, 4942, 23947, 4270, 4012, 1035, 2424, 2121, 1008, 1008, 1030, 9385, 9385, 1006, 1039, 1007, 2384, 1011, 2418, 2330, 3120, 5609, 1010, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2014 Gautier Hattenberger * * This file is part of paparazzi. * * paparazzi is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * paparazzi is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with paparazzi; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * */ /** @file modules/digital_cam/hackhd.h * @brief Digital video/photo recorder HackHD control * * Provides the control of the HackHD power, start and stop of recording. * If you are using firmware >= 1.1.5, it is also possible to take pictures * according to the parameter in the config.txt file (on HackHD SD card). * It is not possible to have both video and photo at the same time. * This driver starts the HackHD in standby mode and trigger the start/stop * of recording or take a picture. * Minimum time between two pictures is 2 seconds. * * It is mandatory to configure the control GPIO: * @verbatim * <configure name="HACKHD_GPIO" value="GPIOC,GPIO5"/> * @endverbatim * */ #ifndef HACKHD_H #define HACKHD_H #include "std.h" #include "math/pprz_geodetic_float.h" enum hackhd_status { HACKHD_NONE, HACKHD_POWER_ON, HACKHD_POWER_OFF, HACKHD_START_RECORD, HACKHD_STOP_RECORD, HACKHD_SHOOT, HACKHD_AUTOSHOOT_START }; struct HackHD { enum hackhd_status status; uint32_t timer; uint32_t photo_nr; uint32_t autoshoot; struct EnuCoor_f last_shot_pos; uint32_t log_delay; }; extern struct HackHD hackhd; extern void hackhd_init(void); extern void hackhd_periodic(void); extern void hackhd_autoshoot(void); extern void hackhd_autoshoot_start(void); extern void hackhd_command(enum hackhd_status cmd); // macro for setting handler #define hackhd_SendCmd(cmd) hackhd_command(cmd) #endif // HACKHD_H
transition-robotics/paparazzi
sw/airborne/modules/digital_cam/hackhd.h
C
gpl-2.0
2,251
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2297, 11721, 21823, 2121, 6045, 21806, 2121, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 13008, 20409, 5831, 1012, 1008, 1008, 13008, 20409, 5831, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
.mce-i-porto { background: url("../images/shortcodes.png") center center no-repeat !important; } /* Porto Visual Composer Elements */ [class*="porto_vc_"] { background: url(../images/vc_elements.png) !important; width: 32px; height: 32px; } .porto_vc_animation { background-position: 0 0 !important; } .porto_vc_block { background-position: 0 -32px !important; } .porto_vc_container { background-position: 0 -64px !important; } .porto_vc_content_box { background-position: 0 -96px !important; } .porto_vc_grid_container { background-position: 0 -128px !important; } .porto_vc_grid_item { background-position: 0 -160px !important; } .porto_vc_links_block { background-position: 0 -192px !important; } .porto_vc_links_item { background-position: 0 -224px !important; } .porto_vc_blog, .porto_vc_recent_posts { background-position: 0 -256px !important; } .porto_vc_faqs { background-position: 0 -288px !important; } .porto_vc_history { background-position: 0 -320px !important; } .porto_vc_recent_members { background-position: 0 -352px !important; } .porto_vc_members { background-position: 0 -352px !important; } .porto_vc_recent_portfolios { background-position: 0 -384px !important; } .porto_vc_portfolios { background-position: 0 -384px !important; } .porto_vc_testimonial { background-position: 0 -416px !important; } .porto_vc_woocommerce { background-position: 0 -448px !important; } .porto_vc_concept { background-position: 0 -480px !important; } .porto_vc_map_section { background-position: 0 -512px !important; }
PongPi/epaper
wp-content/themes/porto/inc/plugins/porto-shortcodes/assets/css/admin.css
CSS
gpl-2.0
1,650
[ 30522, 1012, 11338, 2063, 1011, 1045, 1011, 13809, 1063, 4281, 1024, 24471, 2140, 1006, 1000, 1012, 1012, 1013, 4871, 1013, 2460, 23237, 1012, 1052, 3070, 1000, 1007, 2415, 2415, 2053, 1011, 9377, 999, 2590, 1025, 1065, 1013, 1008, 13809, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright DataStax, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.datastax.dse.driver.internal.core.insights.schema; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_EMPTY) public class Insight<T> { @JsonProperty("metadata") private final InsightMetadata metadata; @JsonProperty("data") private final T insightData; @JsonCreator public Insight(@JsonProperty("metadata") InsightMetadata metadata, @JsonProperty("data") T data) { this.metadata = metadata; this.insightData = data; } public InsightMetadata getMetadata() { return metadata; } public T getInsightData() { return insightData; } @Override public String toString() { return "Insight{" + "metadata=" + metadata + ", insightData=" + insightData + '}'; } }
datastax/java-driver
core/src/main/java/com/datastax/dse/driver/internal/core/insights/schema/Insight.java
Java
apache-2.0
1,557
[ 30522, 1013, 1008, 1008, 9385, 2951, 9153, 2595, 1010, 4297, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# # BioPerl module for Bio::SeqFeature::Primer # # This is the original copyright statement. I have relied on Chad's module # extensively for this module. # # Copyright (c) 1997-2001 bioperl, Chad Matsalla. All Rights Reserved. # This module is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Copyright Chad Matsalla # # You may distribute this module under the same terms as perl itself # POD documentation - main docs before the code # # But I have modified lots of it, so I guess I should add: # # Copyright (c) 2003 bioperl, Rob Edwards. All Rights Reserved. # This module is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Copyright Rob Edwards # # You may distribute this module under the same terms as perl itself # POD documentation - main docs before the code =head1 NAME Bio::SeqFeature::Primer - Primer Generic SeqFeature =head1 SYNOPSIS # set up a single primer that can be used in a PCR reaction use Bio::SeqFeature::Primer; # initiate a primer with raw sequence my $primer=Bio::SeqFeature::Primer->new(-seq=>'CTTTTCATTCTGACTGCAACG'); # get the primery tag for the primer # should return Primer my $tag=$primer->primary_tag; # get or set the location that the primer binds to the target at $primer->location(500); my $location=$primer->location(500); # get or set the 5' end of the primer homology, as the primer doesn't # have to be the same as the target sequence $primer->start(2); my $start=$primer->start; # get or set the 3' end of the primer homology $primer->end(19); my $end = $primer->end; # get or set the strand of the primer. Strand should be 1, 0, or -1 $primer->strand(-1); my $strand=$primer->strand; # get or set the id of the primer $primer->display_id('test_id'); my $id=$primer->display_id; # get the tm of the primer. This is calculated for you by the software. # however, see the docs. my $tm = $primer->Tm; print "These are the details of the primer:\n\tTag:\t\t$tag\n\tLocation\t$location\n\tStart:\t\t$start\n"; print "\tEnd:\t\t$end\n\tStrand:\t\t$strand\n\tID:\t\t$id\n\tTm:\t\t$tm\n"; =head1 DESCRIPTION Handle primer sequences. This will allow you to generate a primer object required for a Bio::Seq::PrimedSeq object. This module is designed to integrate with Bio::Tools::Primer3 and Bio::Seq::PrimedSeq. In addition, you can calculate the melting temperature of the primer. This module is supposed to implement location and range, presumably through generic.pm, but does not do so yet. However, it does allow you to set primers, and use those objects as the basis for Bio::Seq::PrimedSeq objects. See also the POD for Bio::Seq::PrimedSeq and Bio::Tools::Nucleotide::Analysis::Primer3 =head1 FEEDBACK =head2 Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists =head2 Support Please direct usage questions or support issues to the mailing list: I<bioperl-l@bioperl.org> rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. =head2 Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ =head1 AUTHOR Rob Edwards, redwards@utmem.edu The original concept and much of the code was written by Chad Matsalla, bioinformatics1@dieselwurks.com =head1 APPENDIX The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ =cut # Let the code begin... package Bio::SeqFeature::Primer; use strict; use Bio::Seq; use Bio::Tools::SeqStats; use vars qw ($AUTOLOAD @RES %OK_FIELD $ID); BEGIN { @RES=qw(); # nothing here yet, not sure what we want! foreach my $attr (@RES) {$OK_FIELD{$attr}++} } use base qw(Bio::Root::Root Bio::SeqFeature::Generic); $ID = 'Bio::SeqFeature::Primer'; sub AUTOLOAD { my $self = shift; my $attr = $AUTOLOAD; $attr =~ s/.*:://; $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr}; $self->{$attr} = shift if @_; return $self->{$attr}; } =head2 new() Title : new() Usage : $primer = Bio::SeqFeature::Primer(-seq=>sequence_object); Function: Instantiate a new object Returns : A SeqPrimer object Args : You must pass either a sequence object (preferable) or a sequence. =cut sub new { # I have changed some of Chad's code. I hope he doesn't mind. Mine is more stupid than his, but my simple mind gets it. # I also removed from of the generic.pm things, but we can put them back.... my ($class, %args) = @_; my $self = $class->SUPER::new(%args); # i am going to keep an array of the things that have been passed # into the object on construction. this will aid retrieval of these # things later foreach my $argument (keys %args) { if ($argument eq "-SEQUENCE" || $argument eq "-sequence" || $argument eq "-seq") { if (ref($args{$argument}) eq "Bio::Seq") {$self->{seq} = $args{$argument}} else { unless ($args{-id}) {$args{-id}="SeqFeature Primer object"} $self->{seq} = Bio::Seq->new( -seq => $args{$argument}, -id => $args{-id}); } $self->{$argument} = $self->{seq}; push (@{$self->{arguments}}, "seq"); } else { $self->{$argument} = $args{$argument}; push (@{$self->{arguments}}, $argument); # note need to check the BioPerl way of doing this. } } # now error check and make sure that we at least got a sequence if (!$self->{seq}) {$self->throw("You must pass in a sequence to construct this object.")} # a bunch of things now need to be set for this SeqFeature # things like: # TARGET=513,26 # PRIMER_FIRST_BASE_INDEX=1 # PRIMER_LEFT=484,20 # these can be added in, and we won't demand them, but provide a mechanism to check that they exist $self->Tm(); return $self; } =head2 seq() Title : seq() Usage : $seq = $primer->seq(); Function: Return the sequence associated with this Primer. Returns : A Bio::Seq object Args : None. =cut sub seq { my $self = shift; return $self->{seq}; } sub primary_tag { return "Primer"; } =head2 source_tag() Title : source_tag() Usage : $tag = $feature->source_tag(); Function: Returns the source of this tag. Returns : A string. Args : If an argument is provided, the source of this SeqFeature is set to that argument. =cut sub source_tag { my ($self,$insource) = @_; if ($insource) { $self->{source} = $insource; } return $self->{source}; } =head2 location() Title : location() Usage : $tag = $primer->location(); Function: Gets or sets the location of the primer on the sequence Returns : If the location is set, returns that, if not returns 0. Note: At the moment I am using the primer3 notation of location (although you can set whatever you want). In this form, both primers are given from their 5' ends and a length. In this case, the left primer is given from the leftmost end, but the right primer is given from the rightmost end. You can use start() and end() to get the leftmost and rightmost base of each sequence. Args : If supplied will set a location =cut sub location { my ($self, $location) = @_; if ($location) {$self->{location}=$location} if ($self->{location}) {return $self->{location}} else {return 0} } =head2 start() Title : start() Usage : $start_position = $primer->start($new_position); Function: Return the start position of this Primer. This is the leftmost base, regardless of whether it is a left or right primer. Returns : The start position of this primer or 0 if not set. Args : If supplied will set a start position. =cut sub start { my ($self,$start) = @_; if ($start) {$self->{start_position} = $start} if ($self->{start_position}) {return $self->{start_position}} else {return 0} } =head2 end() Title : end() Usage : $end_position = $primer->end($new_position); Function: Return the end position of this primer. This is the rightmost base, regardless of whether it is a left or right primer. Returns : The end position of this primer. Args : If supplied will set an end position. =cut sub end { my ($self,$end) = @_; if ($end) {$self->{end_position} = $end} if ($self->{end_position}) {return $self->{end_position}} else {return 0} } =head2 strand() Title : strand() Usage : $strand=$primer->strand() Function: Get or set the strand. Returns : The strand that the primer binds to. Args : If an argument is supplied will set the strand, otherwise will return it. Should be 1, 0 (not set), or -1 =cut sub strand { my ($self, $strand) = @_; if ($strand) { unless ($strand == -1 || $strand == 0 ||$strand == 1) {$self->throw("Strand must be either 1, 0, or -1 not $strand")} $self->{strand}=$strand; } if ($self->{strand}) {return $self->{strand}} else {return 0} } =head2 display_id() Title : display_id() Usage : $id = $primer->display_id($new_id) Function: Returns the display ID for this Primer feature Returns : A scalar. Args : If an argument is provided, the display_id of this primer is set to that value. =cut sub display_id { my ($self,$newid) = @_; if ($newid) {$self->seq()->display_id($newid)} return $self->seq()->display_id(); } =head2 Tm() Title : Tm() Usage : $tm = $primer->Tm(-salt=>'0.05', -oligo=>'0.0000001') Function: Calculates and returns the Tm (melting temperature) of the primer Returns : A scalar containing the Tm. Args : -salt : set the Na+ concentration on which to base the calculation (default=0.05 molar). : -oligo : set the oligo concentration on which to base the calculation (default=0.00000025 molar). Notes : Calculation of Tm as per Allawi et. al Biochemistry 1997 36:10581-10594. Also see documentation at http://www.idtdna.com/Scitools/Scitools.aspx as they use this formula and have a couple nice help pages. These Tm values will be about are about 0.5-3 degrees off from those of the idtdna web tool. I don't know why. This was suggested by Barry Moore (thanks!). See the discussion on the bioperl-l with the subject "Bio::SeqFeature::Primer Calculating the PrimerTM" =cut sub Tm { my ($self, %args) = @_; my $salt_conc = 0.05; #salt concentration (molar units) my $oligo_conc = 0.00000025; #oligo concentration (molar units) if ($args{'-salt'}) {$salt_conc = $args{'-salt'}} #accept object defined salt concentration if ($args{'-oligo'}) {$oligo_conc = $args{'-oligo'}} #accept object defined oligo concentration my $seqobj = $self->seq(); my $length = $seqobj->length(); my $sequence = uc $seqobj->seq(); my @dinucleotides; my $enthalpy; my $entropy; #Break sequence string into an array of all possible dinucleotides while ($sequence =~ /(.)(?=(.))/g) { push @dinucleotides, $1.$2; } #Build a hash with the thermodynamic values my %thermo_values = ('AA' => {'enthalpy' => -7.9, 'entropy' => -22.2}, 'AC' => {'enthalpy' => -8.4, 'entropy' => -22.4}, 'AG' => {'enthalpy' => -7.8, 'entropy' => -21}, 'AT' => {'enthalpy' => -7.2, 'entropy' => -20.4}, 'CA' => {'enthalpy' => -8.5, 'entropy' => -22.7}, 'CC' => {'enthalpy' => -8, 'entropy' => -19.9}, 'CG' => {'enthalpy' => -10.6, 'entropy' => -27.2}, 'CT' => {'enthalpy' => -7.8, 'entropy' => -21}, 'GA' => {'enthalpy' => -8.2, 'entropy' => -22.2}, 'GC' => {'enthalpy' => -9.8, 'entropy' => -24.4}, 'GG' => {'enthalpy' => -8, 'entropy' => -19.9}, 'GT' => {'enthalpy' => -8.4, 'entropy' => -22.4}, 'TA' => {'enthalpy' => -7.2, 'entropy' => -21.3}, 'TC' => {'enthalpy' => -8.2, 'entropy' => -22.2}, 'TG' => {'enthalpy' => -8.5, 'entropy' => -22.7}, 'TT' => {'enthalpy' => -7.9, 'entropy' => -22.2}, 'A' => {'enthalpy' => 2.3, 'entropy' => 4.1}, 'C' => {'enthalpy' => 0.1, 'entropy' => -2.8}, 'G' => {'enthalpy' => 0.1, 'entropy' => -2.8}, 'T' => {'enthalpy' => 2.3, 'entropy' => 4.1} ); #Loop through dinucleotides and calculate cumulative enthalpy and entropy values for (@dinucleotides) { $enthalpy += $thermo_values{$_}{enthalpy}; $entropy += $thermo_values{$_}{entropy}; } #Account for initiation parameters $enthalpy += $thermo_values{substr($sequence, 0, 1)}{enthalpy}; $entropy += $thermo_values{substr($sequence, 0, 1)}{entropy}; $enthalpy += $thermo_values{substr($sequence, -1, 1)}{enthalpy}; $entropy += $thermo_values{substr($sequence, -1, 1)}{entropy}; #Symmetry correction $entropy -= 1.4; my $r = 1.987; #molar gas constant my $tm = ($enthalpy * 1000 / ($entropy + ($r * log($oligo_conc))) - 273.15 + (12* (log($salt_conc)/log(10)))); $self->{'Tm'}=$tm; return $tm; } =head2 Tm_estimate Title : Tm_estimate Usage : $tm = $primer->Tm_estimate(-salt=>'0.05') Function: Calculates and returns the Tm (melting temperature) of the primer Returns : A scalar containing the Tm. Args : -salt set the Na+ concentration on which to base the calculation. Notes : This is an estimate of the Tm that is kept in for comparative reasons. You should probably use Tm instead! This Tm calculations are taken from the Primer3 docs: They are based on Bolton and McCarthy, PNAS 84:1390 (1962) as presented in Sambrook, Fritsch and Maniatis, Molecular Cloning, p 11.46 (1989, CSHL Press). Tm = 81.5 + 16.6(log10([Na+])) + .41*(%GC) - 600/length where [Na+] is the molar sodium concentration, %GC is the %G+C of the sequence, and length is the length of the sequence. However.... I can never get this calculation to give me the same result as primer3 does. Don't ask why, I never figured it out. But I did want to include a Tm calculation here because I use these modules for other things besides reading primer3 output. The primer3 calculation is saved as 'PRIMER_LEFT_TM' or 'PRIMER_RIGHT_TM' and this calculation is saved as $primer->Tm so you can get both and average them! =cut sub Tm_estimate { # note I really think that this should be put into seqstats as it is more generic, but what the heck. my ($self, %args) = @_; my $salt=0.2; if ($args{'-salt'}) {$salt=$args{'-salt'}} my $seqobj=$self->seq(); my $length=$seqobj->length(); my $seqdata = Bio::Tools::SeqStats->count_monomers($seqobj); my $gc=$$seqdata{'G'} + $$seqdata{'C'}; my $percent_gc=($gc/$length)*100; my $tm= 81.5+(16.6*(log($salt)/log(10)))+(0.41*$percent_gc) - (600/$length); # and now error check compared to primer3 # note that this NEVER gives me the same values, so I am ignoring it # you can get these out separately anyway # if ($self->{'PRIMER_LEFT_TM'}) { # unless ($self->{'PRIMER_LEFT_TM'} == $tm) { # $self->warn("Calculated $tm for Left primer but received ".$self->{'PRIMER_LEFT_TM'}." from primer3\n"); # } # } # elsif ($self->{'PRIMER_RIGHT_TM'}) { # unless ($self->{'PRIMER_RIGHT_TM'} == $tm) { # $self->warn("Calculated $tm for Right primer but received ".$self->{'PRIMER_RIGHT_TM'}." from primer3\n"); # } # } $self->{'Tm'}=$tm; return $tm; } 1;
heqiaoliu/Viral-Dark-Matter
ivireons/server_ivireon_test/cgi-bin/Bioperl/Bio/SeqFeature/Primer.pm
Perl
gpl-2.0
17,181
[ 30522, 1001, 1001, 16012, 4842, 2140, 11336, 2005, 16012, 1024, 1024, 7367, 4160, 7959, 4017, 5397, 1024, 1024, 3539, 2099, 1001, 1001, 2023, 2003, 1996, 2434, 9385, 4861, 1012, 1045, 2031, 13538, 2006, 9796, 1005, 1055, 11336, 1001, 8077, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Pirigara globosa Span. SPECIES #### Status SYNONYM #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Magnoliopsida/Ericales/Lecythidaceae/Planchonia/Planchonia timorensis/ Syn. Pirigara globosa/README.md
Markdown
apache-2.0
179
[ 30522, 1001, 14255, 3089, 24864, 1043, 4135, 15853, 2050, 8487, 1012, 2427, 1001, 1001, 1001, 1001, 3570, 10675, 1001, 1001, 1001, 1001, 2429, 2000, 1996, 10161, 1997, 2166, 1010, 3822, 2254, 2249, 1001, 1001, 1001, 1001, 2405, 1999, 19701,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
public class Customers { public static string[] allCustomers = {"Peter Parker", "Klark Kent", "Bruce Vayne"}; }
jasarsoft/ipcs-primjeri
IPCS_02/Vjezba 2/company/customers/Customers.cs
C#
apache-2.0
112
[ 30522, 2270, 2465, 6304, 1063, 2270, 30524, 5982, 1000, 1010, 1000, 5503, 12436, 9654, 1000, 1065, 1025, 1065, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { AfterContentInit, ElementRef, QueryList } from '@angular/core'; import { MdChip } from './chip'; import { FocusKeyManager } from '../core/a11y/focus-key-manager'; /** * A material design chips component (named ChipList for it's similarity to the List component). * * Example: * * <md-chip-list> * <md-chip>Chip 1<md-chip> * <md-chip>Chip 2<md-chip> * </md-chip-list> */ export declare class MdChipList implements AfterContentInit { private _elementRef; /** Track which chips we're listening to for focus/destruction. */ private _subscribed; /** Whether or not the chip is selectable. */ protected _selectable: boolean; /** The FocusKeyManager which handles focus. */ _keyManager: FocusKeyManager; /** The chip components contained within this chip list. */ chips: QueryList<MdChip>; constructor(_elementRef: ElementRef); ngAfterContentInit(): void; /** * Whether or not this chip is selectable. When a chip is not selectable, * it's selected state is always ignored. */ selectable: boolean; /** * Programmatically focus the chip list. This in turn focuses the first * non-disabled chip in this chip list. */ focus(): void; /** Passes relevant key presses to our key manager. */ _keydown(event: KeyboardEvent): void; /** Toggles the selected state of the currently focused chip. */ protected _toggleSelectOnFocusedChip(): void; /** * Iterate through the list of chips and add them to our list of * subscribed chips. * * @param chips The list of chips to be subscribed. */ protected _subscribeChips(chips: QueryList<MdChip>): void; /** * Add a specific chip to our subscribed list. If the chip has * already been subscribed, this ensures it is only subscribed * once. * * @param chip The chip to be subscribed (or checked for existing * subscription). */ protected _addChip(chip: MdChip): void; /** * Utility to ensure all indexes are valid. * * @param index The index to be checked. * @returns True if the index is valid for our list of chips. */ private _isValidIndex(index); }
raymonddavis/Angular-SailsJs-SocketIo
web/node_modules/@angular/material/typings/chips/chip-list.d.ts
TypeScript
mit
2,231
[ 30522, 12324, 1063, 2044, 8663, 6528, 7629, 4183, 1010, 5783, 2890, 2546, 1010, 23032, 9863, 1065, 2013, 1005, 1030, 16108, 1013, 4563, 1005, 1025, 12324, 1063, 9108, 5428, 2361, 1065, 2013, 1005, 1012, 1013, 9090, 1005, 1025, 12324, 1063, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace PhpParser\Node\Scalar\MagicConst; use PhpParser\Node\Scalar\MagicConst; class Trait_ extends MagicConst { public function getName() { return '__TRAIT__'; } }
focuslife/v0.1
vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php
PHP
apache-2.0
203
[ 30522, 1026, 1029, 25718, 3415, 15327, 25718, 19362, 8043, 1032, 13045, 1032, 26743, 2099, 1032, 3894, 8663, 3367, 1025, 2224, 25718, 19362, 8043, 1032, 13045, 1032, 26743, 2099, 1032, 3894, 8663, 3367, 1025, 2465, 18275, 1035, 8908, 3894, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * @license * Copyright 2020 The FOAM Authors. All Rights Reserved. * http://www.apache.org/licenses/LICENSE-2.0 */ foam.CLASS({ package: 'foam.nanos.crunch.lite', name: 'MinMaxCapabilityRefinement', refines: 'foam.nanos.crunch.MinMaxCapability', implements: [ 'foam.nanos.crunch.lite.CapableCompatibleCapability' ], javaImports: [ 'foam.nanos.crunch.CapabilityJunctionPayload', 'foam.nanos.crunch.CrunchService', 'static foam.nanos.crunch.CapabilityJunctionStatus.*' ], methods: [ { name: 'getCapableChainedStatus', documentation: ` numberGrantedOrPending are the available CapablePayloads which are GRANTED or can eventually be turned into GRANTED from PENDING state. If MinMaxCapability.min is greater than the number of available payloads which are GRANTED or can eventually be turned into GRANTED, then it is impossible for the total amount of GRANTED payloads to be greater than the MIN, thereby fulfilling the minimum requirement. For example, let there be a min max capablity which has 10 prerequisites and a min of 2. If the user selected only 3 of those prereqs in the wizard, then the CapablePayload.status for those 3 will each be in PENDING state with approvals generated for each one. Note, there will only be these 3 CapablePayloads out of the 10 Prereqs avaliable on the Capable object since the user only selected 3. If 1 of those 3 CapablePayloads get rejected. Then there will be 2 numberGrantedOrPending which could still potentially satisfy the min requirement of 2 if those 2 CapablePayloads get set to GRANTED. If 2 of those 3 CapablePayloads get rejected. Then there will be 1 numberGrantedOrPending which would be impossible to satisfy the MinMaxCapability.min requirement of 2 even if that 1 CapablePayload is GRANTED. `, javaCode: ` CrunchService crunchService = (CrunchService) x.get("crunchService"); List<String> prereqCapIds = crunchService.getPrereqs(getId()); int numberGranted = 0; int numberPending = 0; int numberRejected = 0; for ( String capId : prereqCapIds ) { CapabilityJunctionPayload prereqPayload = (CapabilityJunctionPayload) capablePayloadDAO.find(capId); if ( prereqPayload == null ) { continue; } switch ( prereqPayload.getStatus() ) { case GRANTED: numberGranted++; continue; case PENDING: case APPROVED: numberPending++; continue; case REJECTED: numberRejected++; continue; } } int numberTotal = numberGranted + numberPending + numberRejected; int numberGrantedOrPending = numberGranted + numberPending; if ( numberTotal == 0 ){ return CapabilityJunctionStatus.ACTION_REQUIRED; } if ( getMin() > numberGrantedOrPending ){ return CapabilityJunctionStatus.REJECTED; } if ( numberGranted >= getMin() ) { return CapabilityJunctionStatus.GRANTED; } if ( numberTotal >= getMin() ) { return CapabilityJunctionStatus.PENDING; } return CapabilityJunctionStatus.ACTION_REQUIRED; ` } ] });
jacksonic/vjlofvhjfgm
src/foam/nanos/crunch/lite/MinMaxCapabilityRefinement.js
JavaScript
apache-2.0
3,413
[ 30522, 1013, 1008, 1008, 1008, 1030, 6105, 1008, 9385, 12609, 1996, 17952, 6048, 1012, 2035, 2916, 9235, 1012, 1008, 8299, 1024, 1013, 1013, 7479, 1012, 15895, 1012, 8917, 1013, 15943, 1013, 6105, 1011, 1016, 1012, 1014, 1008, 1013, 17952, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { Context } from '../../../src/context/Context'; describe('Context', () => { describe('Response', () => { it('should return the response object', () => { const res: any = 1; const context = new Context(undefined, res, undefined, undefined); expect(context.Response).toBe(1); }); }); describe('Request', () => { it('should return the request object', () => { const req: any = 1; const context = new Context(req, undefined, undefined, undefined); expect(context.Request).toBe(1); }); }); describe('Services', () => { it('should return the repositories object', () => { const services: any = 1; const context = new Context(undefined, undefined, undefined, services); expect(context.Services).toBe(1); }); }); describe('DataLoaders', () => { it('should return the dataLoaders object', () => { const dataLoaders: any = 1; const context = new Context(undefined, undefined, dataLoaders, undefined); expect(context.DataLoaders).toBe(1); }); }); describe('hasUserRoles', () => { it('should return the dataLoaders object', () => { const req: any = { acceptsLanguages: () => 'de' }; const context = new Context(req, undefined, undefined, undefined); expect(context.getLanguage()).toBe('de'); }); }); describe('hasUserRoles', () => { it('should return the request object', () => { const context = new Context(undefined, undefined, undefined, undefined); expect(context.hasUserRoles([])).toBeTruthy(); }); }); });
w3tecch/express-graphql-typescript-boilerplate
test/unit/context/context.spec.ts
TypeScript
mit
1,786
[ 30522, 12324, 1063, 6123, 1065, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 5034, 2278, 1013, 6123, 1013, 6123, 1005, 1025, 6235, 1006, 1005, 6123, 1005, 1010, 1006, 1007, 1027, 1028, 1063, 6235, 1006, 1005, 3433, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * JsNameAddrObjectFactory.h * * Created on: Jul 9, 2013 * Author: dcampbell */ #ifndef JSNAMEADDROBJECTFACTORY_H_ #define JSNAMEADDROBJECTFACTORY_H_ #include "JsObjectFactory.h" #include <resip/stack/SipMessage.hxx> #include "JsProxyBase.h" namespace jessip { class JsNameAddrObjectFactory : public jessip::JsObjectFactory { public: JsNameAddrObjectFactory(); virtual ~JsNameAddrObjectFactory(); virtual v8::Handle<v8::Value> createObjectInstance( const char* address); protected: virtual JsProxyBase* onCreateProxyObject(); virtual void onAddTemplateMethods(v8::Handle<v8::ObjectTemplate> temp); }; } /* namespace jessip */ #endif /* JSNAMEADDROBJECTFACTORY_H_ */
mustaphamond/jessip
src/JsNameAddrObjectFactory.h
C
gpl-3.0
708
[ 30522, 1013, 1008, 1008, 1046, 2015, 18442, 4215, 22196, 2497, 20614, 21450, 1012, 1044, 1008, 1008, 2580, 2006, 1024, 21650, 1023, 1010, 2286, 1008, 3166, 1024, 5887, 16613, 17327, 1008, 1013, 1001, 2065, 13629, 2546, 1046, 2015, 18442, 42...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.5.0_22) on Mon Dec 20 13:46:30 EST 2010 --> <TITLE> org.apache.tools.ant.taskdefs.optional.jsp.compilers (Apache Ant API) </TITLE> <META NAME="keywords" CONTENT="org.apache.tools.ant.taskdefs.optional.jsp.compilers package"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../../../stylesheet.css" TITLE="Style"> </HEAD> <BODY BGCOLOR="white"> <FONT size="+1" CLASS="FrameTitleFont"> <A HREF="../../../../../../../../org/apache/tools/ant/taskdefs/optional/jsp/compilers/package-summary.html" target="classFrame">org.apache.tools.ant.taskdefs.optional.jsp.compilers</A></FONT> <TABLE BORDER="0" WIDTH="100%" SUMMARY=""> <TR> <TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont"> Interfaces</FONT>&nbsp; <FONT CLASS="FrameItemFont"> <BR> <A HREF="JspCompilerAdapter.html" title="interface in org.apache.tools.ant.taskdefs.optional.jsp.compilers" target="classFrame"><I>JspCompilerAdapter</I></A></FONT></TD> </TR> </TABLE> <TABLE BORDER="0" WIDTH="100%" SUMMARY=""> <TR> <TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont"> Classes</FONT>&nbsp; <FONT CLASS="FrameItemFont"> <BR> <A HREF="DefaultJspCompilerAdapter.html" title="class in org.apache.tools.ant.taskdefs.optional.jsp.compilers" target="classFrame">DefaultJspCompilerAdapter</A> <BR> <A HREF="JasperC.html" title="class in org.apache.tools.ant.taskdefs.optional.jsp.compilers" target="classFrame">JasperC</A> <BR> <A HREF="JspCompilerAdapterFactory.html" title="class in org.apache.tools.ant.taskdefs.optional.jsp.compilers" target="classFrame">JspCompilerAdapterFactory</A></FONT></TD> </TR> </TABLE> </BODY> </HTML>
jeroendesloovere/PhotoSwipe
tools/apache-ant-1.8.2/docs/manual/api/org/apache/tools/ant/taskdefs/optional/jsp/compilers/package-frame.html
HTML
mit
1,765
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.jetbrains.plugins.scala package debugger.evaluation import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil /** * Nikolay.Tropin * 2014-09-28 */ object EvaluationException { def apply(message: String) = EvaluateExceptionUtil.createEvaluateException(message) def apply(thr: Throwable) = EvaluateExceptionUtil.createEvaluateException(thr) def apply(message: String, thr: Throwable) = EvaluateExceptionUtil.createEvaluateException(message, thr) }
triggerNZ/intellij-scala
src/org/jetbrains/plugins/scala/debugger/evaluation/EvaluationException.scala
Scala
apache-2.0
480
[ 30522, 7427, 8917, 1012, 6892, 10024, 7076, 1012, 13354, 7076, 1012, 26743, 7427, 2139, 8569, 13327, 1012, 9312, 12324, 4012, 1012, 13420, 3669, 3501, 1012, 2139, 8569, 13327, 1012, 3194, 1012, 9312, 1012, 16157, 10288, 24422, 21823, 2140, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
############################################################################## # # Copyright (C) 2013 Contributor # # 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. # ############################################################################## # # IPS::Package module # Author: Mark R. Bannister # # Routines for manipulating Solaris IPS package information. # ############################################################################## package IPS::Package; use strict; use warnings; use Carp; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(pkg_add_lookup pkg_lookup pkg_lookup_installed fmri_match); =head1 NAME IPS::Package - IPS package name support module =head1 SYNOPSIS use IPS; IPS::Package::pkg_add_lookup("pkg:/shell/bash"); @output = IPS::Package::pkg_lookup("bash"); @output = IPS::Package::pkg_lookup_re("^idr[0-9]"); print "match\n" if IPS::Package::fmri_match( "pkg:/shell/bash", "shell/bash"); =head1 DESCRIPTION Supporting routines used by B<pkgtree> to find packages based on partial and full FMRIs. This module handles the package name component of an FMRI. Use B<IPS::Version> for routines that work on the version number. =over 5 =item B<pkg_add_lookup>(I<pkg_fmri>, [I<installed>], [I<pkg_map>]) Adds full package name to lookup hash as well as its various shortened forms. The lookup hash is used by subsequent routines in this module. Note that the FMRI should not actually contain a version component. The I<installed> flag can be 1 to indicate that the package is installed, or 0 to indicate that it is not installed. This flag is used by B<pkg_lookup_installed>. If omitted, the default is 1. If I<pkg_map> is not provided then the module global hash B<IPS::pkg_map> will be used instead. =cut sub pkg_add_lookup { my ($pkg_fmri, $installed, $pkg_map) = @_; $pkg_map ||= \%IPS::pkg_map; (my $name = $pkg_fmri) =~ s=^pkg://[^/]*/==; # strip off publisher $pkg_map->{$name}->{$pkg_fmri} = $installed if ! $pkg_map->{$name}->{$pkg_fmri}; while ($name =~ /\//) { $name =~ s=^[^/]*/==; # strip off leading component $pkg_map->{$name}->{$pkg_fmri} = $installed if $name and ! $pkg_map->{$name}->{$pkg_fmri}; } } =item B<pkg_lookup>(I<pkg_fmri>, [I<pkg_map>]) Looks up full or partial package name in the package map, returning an array of full matching packages (if possible). If I<pkg_map> is not provided then the module global hash B<IPS::pkg_map> will be used instead. =cut sub pkg_lookup { my ($pkg_fmri, $pkg_map) = @_; $pkg_map ||= \%IPS::pkg_map; if (substr($pkg_fmri, 0, 6) eq 'pkg://') { # # This is already a full FMRI, as it has a publisher component # return $pkg_fmri; } # # Remove pkg:/ or single / prefix # (my $name = $pkg_fmri) =~ s=^(pkg:)?/==; my $pkg_hash = $pkg_map->{$name}; return "pkg:/$name" if ! $pkg_hash; return keys %$pkg_hash; } =item B<pkg_lookup_installed>(I<pkg_fmri>, [I<pkg_map>]) Same as B<pkg_lookup> except only works on packages marked as installed. Knowledge of whether a package is installed or not depends on the value of the I<installed> flag previously passed to B<pkg_add_lookup>. =cut sub pkg_lookup_installed { my ($pkg_fmri, $pkg_map) = @_; $pkg_map ||= \%IPS::pkg_map; # # Strip off publisher, remove pkg:/ or single / prefix # (my $name = $pkg_fmri) =~ s,^(pkg://[^/]*/|pkg:/|/),,; my $pkg_hash = $pkg_map->{$name}; return if ! $pkg_hash; my @pkg_list; for my $fmri (keys %$pkg_hash) { push @pkg_list, $fmri if $pkg_hash->{$fmri}; } return @pkg_list; } =item B<pkg_lookup_re>(I<pkg_re>, [I<pkg_map>]) Looks up package name with a regular expression in the package map, returning an array of full matching packages (if possible). If I<pkg_map> is not provided then the module global hash B<IPS::pkg_map> will be used instead. =cut sub pkg_lookup_re { my ($pkg_re, $pkg_map) = @_; $pkg_map ||= \%IPS::pkg_map; my @results; for my $name (keys %$pkg_map) { for my $fmri (keys %{$pkg_map->{$name}}) { push @results, $fmri if $fmri =~ $pkg_re or $name =~ $pkg_re; } } return @results; } =item B<pkg_lookup_installed_re>(I<pkg_re>, [I<pkg_map>]) Same as B<pkg_lookup_re> except only works on packages marked as installed. Knowledge of whether a package is installed or not depends on the value of the I<installed> flag previously passed to B<pkg_add_lookup>. =cut sub pkg_lookup_installed_re { my ($pkg_re, $pkg_map) = @_; $pkg_map ||= \%IPS::pkg_map; my @results; for my $name (keys %$pkg_map) { for my $fmri (keys %{$pkg_map->{$name}}) { push @results, $fmri if $pkg_map->{$name}->{$fmri} and \ ($fmri =~ $pkg_re or $name =~ $pkg_re); } } return @results; } =item B<fmri_match>(I<fmri1>, I<fmri2>) Checks two package names, and returns 1 if they match. Supports full and partial matching. =cut sub fmri_match { my ($fmri1, $fmri2) = @_; # # If both FMRIs have a publisher name, we can include the publisher # name in the comparison, otherwise we can't # if (!fmri_common(\$fmri1, \$fmri2, '^pkg://')) { # # FMRIs may optionally start with pkg:/ but we should ignore # leading pkg: or leading / in our comparisons if they are # not found in both FMRIs (unless publisher is included which # was tested for above) # fmri_common(\$fmri1, \$fmri2, '^pkg:'); fmri_common(\$fmri1, \$fmri2, '^/'); } my @fmri1 = split(/\//, $fmri1); my @fmri2 = split(/\//, $fmri2); my $i = @fmri1; my $j = @fmri2; while ($i > 0 and $j > 0) { $i--; $j--; return 0 if $fmri1[$i] ne $fmri2[$j]; } return 1; } ############################################################################## # fmri_common(<ref_fmri1>, <ref_fmri2>, <re_match>) # # Checks to see if regular expression <re_match> matches against # both FMRIs passed by reference. If only one of the two FMRIs # match the RE, then the text matching the RE is removed from # the string that had the match. # # Returns 1 if both FMRIs matched the RE. # # This is not a public interface. ############################################################################## sub fmri_common { my ($fmri1, $fmri2, $re) = @_; my $match1 = ($$fmri1 =~ $re); my $match2 = ($$fmri2 =~ $re); if ($match1 xor $match2) { $$fmri1 =~ s/$re// if $match1; $$fmri2 =~ s/$re// if $match2; } else { return $match1; } return 0; } =back =head1 SEE ALSO B<IPS>(3), B<IPS::Version>(3), B<pkg>(5), B<pkgtree>(1). =cut 1;
quattor/pkgtree
lib/perl5/IPS/Package.pm
Perl
apache-2.0
7,343
[ 30522, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Version details * * @package report * @subpackage progress * @copyright 2008 Sam Marshall * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2018112800; // Requires this Moodle version $plugin->component = 'report_progress'; // Full name of the plugin (used for diagnostics)
msoni11/moodle
report/progress/version.php
PHP
gpl-3.0
1,159
[ 30522, 1026, 1029, 25718, 1013, 1013, 2023, 5371, 2003, 2112, 1997, 6888, 2571, 1011, 8299, 1024, 1013, 1013, 6888, 2571, 1012, 8917, 1013, 1013, 1013, 1013, 1013, 6888, 2571, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 26...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
"use strict"; /* global describe it before */ const { assert } = require("chai"); const Database = require("./lib/database"); const testcases = (env) => { describe("Basic operations", () => { before(async () => { await Database.start(); }); it("should list zero objects", async () => { const list = await env.client.list("thing"); assert.isArray(list); assert.equal(list.length, 0); }); it("should create one object", async () => { const thing = await env.client.create("thing", { _id: "1", thingy: "Hello" }); assert.equal(thing.type, "scom.thing"); assert.equal(thing.thingy, "Hello"); }); it("should list one object", async () => { const list = await env.client.list("thing"); assert.isArray(list); assert.equal(list.length, 1); }); it("should update one object", async () => { const thing = await env.client.update("thing", "1", { thingy: "World" }); assert.equal(thing.type, "scom.thing"); assert.equal(thing.thingy, "World"); }); it("should delete one object", async () => { const thing = await env.client.remove("thing", "1"); assert.equal(thing.type, "scom.thing"); assert.equal(thing.thingy, "World"); }); it("should list zero objects", async () => { const list = await env.client.list("thing"); assert.isArray(list); assert.equal(list.length, 0); }); }); describe("Action operations", () => { before(async () => { await Database.start(); }); it("should create an object and tag it", async () => { await env.client.create("thing", { _id: "1", thingy: "Hello" }); const thing2 = await env.client.tag("thing", "1", { tag: [ "tag1", "tag2" ] }); assert.equal(thing2.type, "scom.thing"); assert.equal(thing2.thingy, "Hello"); assert.deepEqual(thing2.tags, [ "tag1", "tag2" ]); }); it("should get error with invalid action", async () => { try { await env.client.stuff("thing", "1", { 1: 0 }); assert(false, "Should have thrown"); } catch (error) { assert.equal(error.status, 400); } }); }); describe("Getter operations", () => { before(async () => { await Database.start(); }); it("should create an object and get something on it", async () => { await env.client.create("thing", { _id: "1", thingy: "Hello" }); const value = await env.client.thingy("thing", "1"); assert.equal(value, "Hello"); }); it("should get error with invalid getter", async () => { try { await env.client.stuff("thing", "1"); assert(false, "Should have thrown"); } catch (error) { assert.equal(error.status, 400); } }); }); }; module.exports = testcases;
Combitech/codefarm
src/lib/servicecom/test/testcases.js
JavaScript
mit
3,396
[ 30522, 1000, 2224, 9384, 1000, 1025, 1013, 1008, 3795, 6235, 2009, 2077, 1008, 1013, 9530, 3367, 1063, 20865, 1065, 1027, 5478, 1006, 1000, 15775, 2072, 1000, 1007, 1025, 9530, 3367, 7809, 1027, 5478, 1006, 1000, 1012, 1013, 5622, 2497, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Trait { fn dummy(&self) { } } struct Foo<T:Trait> { x: T, } static X: Foo<usize> = Foo { //~^ ERROR not implemented x: 1, }; fn main() { }
rprichard/rust
src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs
Rust
apache-2.0
628
[ 30522, 1013, 1013, 9385, 2297, 1996, 18399, 2622, 9797, 1012, 2156, 1996, 9385, 1013, 1013, 5371, 2012, 1996, 2327, 1011, 2504, 14176, 1997, 2023, 4353, 1998, 2012, 1013, 1013, 8299, 1024, 1013, 1013, 18399, 1011, 11374, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// -*- Mode: Go; indent-tabs-mode: t -*- /* * Copyright (C) 2017 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ package userd import ( "bytes" "fmt" "net/url" "os" "os/exec" "regexp" "syscall" "time" "github.com/godbus/dbus" "github.com/snapcore/snapd/i18n" "github.com/snapcore/snapd/logger" "github.com/snapcore/snapd/osutil" "github.com/snapcore/snapd/osutil/sys" "github.com/snapcore/snapd/release" "github.com/snapcore/snapd/strutil" "github.com/snapcore/snapd/usersession/userd/ui" ) const launcherIntrospectionXML = ` <interface name="org.freedesktop.DBus.Peer"> <method name='Ping'> </method> <method name='GetMachineId'> <arg type='s' name='machine_uuid' direction='out'/> </method> </interface> <interface name='io.snapcraft.Launcher'> <method name='OpenURL'> <arg type='s' name='url' direction='in'/> </method> <method name="OpenFile"> <arg type="s" name="parent_window" direction="in"/> <arg type="h" name="fd" direction="in"/> </method> </interface>` // allowedURLSchemes are those that can be passed to xdg-open so that it may // launch the handler for the url scheme on behalf of the snap (and therefore // outside of the calling snap's confinement). Historically we've been // conservative about adding url schemes but the thinking was refined in // https://github.com/snapcore/snapd/pull/7731#pullrequestreview-362900171 // // The current criteria for adding url schemes is: // * understanding and documenting the scheme in this file // * the scheme itself does not cause xdg-open to open files (eg, file:// or // matching '^[[:alpha:]+\.\-]+:' (from xdg-open source)) // * verifying that the recipient of the url (ie, what xdg-open calls) won't // process file paths/etc that can be leveraged to break out of the sandbox // (but understanding how the url can drive the recipient application is // important) // // This code uses golang's net/url.Parse() which will help ensure the url is // ok before passing to xdg-open. xdg-open itself properly quotes the url so // shell metacharacters are blocked. var ( allowedURLSchemes = []string{ // apt: the scheme allows specifying a package for xdg-open to pass to an // apt-handling application, like gnome-software, apturl, etc which are all // protected by policykit // - scheme: apt:<name of package> // - https://github.com/snapcore/snapd/pull/7731 "apt", // help: the scheme allows for specifying a help URL. This code ensures that // the url is parseable // - scheme: help://topic // - https://github.com/snapcore/snapd/pull/6493 "help", // http/https: the scheme allows specifying a web URL. This code ensures that // the url is parseable // - scheme: http(s)://example.com "http", "https", // mailto: the scheme allows for specifying an email address // - scheme: mailto:foo@example.com "mailto", // msteams: the scheme is a thin wrapper around https. // - scheme: msteams:... // - https://github.com/snapcore/snapd/pull/8761 "msteams", // TODO: document slack URL scheme. "slack", // snap: the scheme allows specifying a package for xdg-open to pass to a // snap-handling installer application, like snap-store, etc which are // protected by policykit/snap login // - https://github.com/snapcore/snapd/pull/5181 "snap", // zoommtg: the scheme is a modified web url scheme // - scheme: https://medium.com/zoom-developer-blog/zoom-url-schemes-748b95fd9205 // (eg, zoommtg://zoom.us/...) // - https://github.com/snapcore/snapd/pull/8304 "zoommtg", // zoomphonecall: another zoom URL scheme, for dialing phone numbers // - https://github.com/snapcore/snapd/pull/8910 "zoomphonecall", // zoomus: alternative name for zoommtg // - https://github.com/snapcore/snapd/pull/8910 "zoomus", } ) // Launcher implements the 'io.snapcraft.Launcher' DBus interface. type Launcher struct { conn *dbus.Conn } // Interface returns the name of the interface this object implements func (s *Launcher) Interface() string { return "io.snapcraft.Launcher" } // ObjectPath returns the path that the object is exported as func (s *Launcher) ObjectPath() dbus.ObjectPath { return "/io/snapcraft/Launcher" } // IntrospectionData gives the XML formatted introspection description // of the DBus service. func (s *Launcher) IntrospectionData() string { return launcherIntrospectionXML } func makeAccessDeniedError(err error) *dbus.Error { return &dbus.Error{ Name: "org.freedesktop.DBus.Error.AccessDenied", Body: []interface{}{err.Error()}, } } func checkOnClassic() *dbus.Error { if !release.OnClassic { return makeAccessDeniedError(fmt.Errorf("not supported on Ubuntu Core")) } return nil } // see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#file-naming var validDesktopFileName = regexp.MustCompile(`^[A-Za-z-_][A-Za-z0-9-_]*(\.[A-Za-z-_][A-Za-z0-9-_]*)*\.desktop$`) func schemeHasHandler(scheme string) (bool, error) { cmd := exec.Command("xdg-mime", "query", "default", "x-scheme-handler/"+scheme) // TODO: consider using Output() in case xdg-mime starts logging to // stderr out, err := cmd.CombinedOutput() if err != nil { return false, osutil.OutputErr(out, err) } out = bytes.TrimSpace(out) // if the output is a valid desktop file we have a handler for the given // scheme return validDesktopFileName.Match(out), nil } // OpenURL implements the 'OpenURL' method of the 'io.snapcraft.Launcher' // DBus interface. Before the provided url is passed to xdg-open the scheme is // validated against a list of allowed schemes. All other schemes are denied. func (s *Launcher) OpenURL(addr string, sender dbus.Sender) *dbus.Error { logger.Debugf("open url: %q", addr) if err := checkOnClassic(); err != nil { return err } u, err := url.Parse(addr) if err != nil { return &dbus.ErrMsgInvalidArg } if u.Scheme == "" { return makeAccessDeniedError(fmt.Errorf("cannot open URL without a scheme")) } isAllowed := strutil.ListContains(allowedURLSchemes, u.Scheme) if !isAllowed { // scheme is not listed in our allowed schemes list, perform // fallback and check whether the local system has a handler for // it isAllowed, err = schemeHasHandler(u.Scheme) if err != nil { logger.Noticef("cannot obtain scheme handler for %q: %v", u.Scheme, err) } } if !isAllowed { return makeAccessDeniedError(fmt.Errorf("Supplied URL scheme %q is not allowed", u.Scheme)) } if err := exec.Command("xdg-open", addr).Run(); err != nil { return dbus.MakeFailedError(fmt.Errorf("cannot open supplied URL")) } return nil } // fdToFilename determines the path associated with an open file descriptor. // // The file descriptor cannot be opened using O_PATH and must refer to // a regular file or to a directory. The symlink at /proc/self/fd/<fd> // is read to determine the filename. The descriptor is also fstat'ed // and the resulting device number and inode number are compared to // stat on the path determined earlier. The numbers must match. func fdToFilename(fd int) (string, error) { flags, err := sys.FcntlGetFl(fd) if err != nil { return "", err } // File descriptors opened with O_PATH do not imply access to // the file in question. if flags&sys.O_PATH != 0 { return "", fmt.Errorf("cannot use file descriptors opened using O_PATH") } // Determine the file name associated with the passed file descriptor. filename, err := os.Readlink(fmt.Sprintf("/proc/self/fd/%d", fd)) if err != nil { return "", err } var fileStat, fdStat syscall.Stat_t if err := syscall.Stat(filename, &fileStat); err != nil { return "", err } if err := syscall.Fstat(fd, &fdStat); err != nil { return "", err } // Sanity check to ensure we've got the right file if fdStat.Dev != fileStat.Dev || fdStat.Ino != fileStat.Ino { return "", fmt.Errorf("cannot determine file name") } fileType := fileStat.Mode & syscall.S_IFMT if fileType != syscall.S_IFREG && fileType != syscall.S_IFDIR { return "", fmt.Errorf("cannot open anything other than regular files or directories") } return filename, nil } func (s *Launcher) OpenFile(parentWindow string, clientFd dbus.UnixFD, sender dbus.Sender) *dbus.Error { // godbus transfers ownership of this file descriptor to us fd := int(clientFd) defer syscall.Close(fd) if err := checkOnClassic(); err != nil { return err } filename, err := fdToFilename(fd) if err != nil { return dbus.MakeFailedError(err) } snap, err := snapFromSender(s.conn, sender) if err != nil { return dbus.MakeFailedError(err) } dialog, err := ui.New() if err != nil { return dbus.MakeFailedError(err) } answeredYes := dialog.YesNo( i18n.G("Allow opening file?"), fmt.Sprintf(i18n.G("Allow snap %q to open file %q?"), snap, filename), &ui.DialogOptions{ Timeout: 5 * 60 * time.Second, Footer: i18n.G("This dialog will close automatically after 5 minutes of inactivity."), }, ) if !answeredYes { return dbus.MakeFailedError(fmt.Errorf("permission denied")) } if err = exec.Command("xdg-open", filename).Run(); err != nil { return dbus.MakeFailedError(fmt.Errorf("cannot open supplied URL")) } return nil }
sergiocazzolato/snapd
usersession/userd/launcher.go
GO
gpl-3.0
9,786
[ 30522, 1013, 1013, 1011, 1008, 1011, 5549, 1024, 2175, 1025, 27427, 4765, 1011, 21628, 2015, 1011, 5549, 1024, 1056, 1011, 1008, 1011, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2418, 18562, 5183, 1008, 1008, 2023, 2565, 2003, 2489, 4007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>{{ site.title }}{% if page.title %} - {{ page.title }}{% endif %}</title> <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}"> <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}"> <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" /> <link rel="shortcut icon" href="{{ '/assets/images/logo.png' | prepend: site.baseurl }}" /> <!-- Normalize.css --> <link rel="stylesheet" href="{{ "/assets/css/normalize.min.css" | prepend: site.baseurl }}"> <link rel="stylesheet" href="{{ "/assets/css/style.min.css" | prepend: site.baseurl }}"> <link rel="stylesheet" href="{{ "/assets/css/code.min.css" | prepend: site.baseurl }}"> <link rel="stylesheet" href="{{ "/assets/css/flexboxgrid.min.css" | prepend: site.baseurl }}"> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_CHTML"> </script> <script src="/assets/js/siema.min.js"></script> </head>
teslabs/teslabs.github.io
_includes/head.html
HTML
gpl-3.0
1,377
[ 30522, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 1060, 1011, 25423, 1011, 11892, 1000, 4180, 1027, 1000, 29464, 1027, 3341, 1000, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Copyright 2018 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, fields, models class ResPartner(models.Model): _inherit = "res.partner" _allowed_inactive_link_models = ["res.partner"] _inactive_cascade = True sta_mandate_ids = fields.One2many( comodel_name="sta.mandate", inverse_name="partner_id", string="State Mandates", domain=[("active", "=", True)], context={"force_recompute": True}, ) sta_mandate_inactive_ids = fields.One2many( comodel_name="sta.mandate", inverse_name="partner_id", string="State Mandates (Inactive)", domain=[("active", "=", False)], ) int_mandate_ids = fields.One2many( comodel_name="int.mandate", inverse_name="partner_id", string="Internal Mandates", domain=[("active", "=", True)], context={"force_recompute": True}, ) int_mandate_inactive_ids = fields.One2many( comodel_name="int.mandate", inverse_name="partner_id", string="Internal Mandates (Inactive)", domain=[("active", "=", False)], ) ext_mandate_ids = fields.One2many( comodel_name="ext.mandate", inverse_name="partner_id", string="External Mandates", domain=[("active", "=", True)], context={"force_recompute": True}, ) ext_mandate_inactive_ids = fields.One2many( comodel_name="ext.mandate", inverse_name="partner_id", string="External Mandates (Inactive)", domain=[("active", "=", False)], ) ext_mandate_count = fields.Integer( string="External Mandates Nbr", compute="_compute_mandate_assembly_count" ) ext_assembly_count = fields.Integer( string="External Assemblies", compute="_compute_mandate_assembly_count" ) def get_mandate_action(self): """ return an action for an ext.mandate contains into the domain a specific tuples to get concerned mandates """ self.ensure_one() res_ids = self._get_assemblies()._get_mandates().ids domain = [("id", "in", res_ids)] # get model's action to update its domain action = self.env["ir.actions.act_window"]._for_xml_id( "mozaik_mandate.ext_mandate_action" ) action["domain"] = domain return action def _get_assemblies(self): """ return the assemblies of the current partner """ self.ensure_one() assembly_model = "ext.assembly" if self.is_assembly: field = "partner_id" else: field = "ref_partner_id" domain = [(field, "=", self.id)] assembly_obj = self.env[assembly_model] assemblies = assembly_obj.search(domain) return assemblies def _compute_mandate_assembly_count(self): """ count the number of assemblies linked to the current partner count the number of mandates linked to the assemblies of the current partner """ for partner in self: assemblies = partner._get_assemblies() partner.ext_assembly_count = len(assemblies) partner.ext_mandate_count = len(assemblies._get_mandates()) def add_mandate_action(self): self.ensure_one() return { "type": "ir.actions.act_window", "name": _("Add a new mandate"), "res_model": self._context.get("mandate_model"), "context": {"default_partner_id": self.id}, "view_mode": "form", "target": "new", }
mozaik-association/mozaik
mozaik_mandate/models/res_partner.py
Python
agpl-3.0
3,660
[ 30522, 1001, 9385, 2760, 9353, 3385, 2063, 7842, 1013, 1050, 2615, 1001, 6105, 12943, 24759, 1011, 1017, 1012, 1014, 2030, 2101, 1006, 8299, 1024, 1013, 1013, 7479, 1012, 27004, 1012, 8917, 1013, 15943, 1013, 12943, 24759, 1007, 1012, 2013,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- title: Gatsby Lifecycle APIs --- Gatsby provides a rich set of lifecycle APIs to hook into Gatsby's bootstrap, build, and client runtime operations. Gatsby's design principles include: * Conventions > code but use low-level primitives to build conventions with code. * Extracting logic and configuration into [plugins](/docs/plugins/) should be trivial and encouraged. * Plugins are easy to open source and reuse. They're just NPM packages. See the links along the left under "REFERENCE" for the full API documentation.
danielfarrell/gatsby
docs/docs/gatsby-lifecycle-apis.md
Markdown
mit
532
[ 30522, 1011, 1011, 1011, 2516, 1024, 11721, 3215, 3762, 2166, 23490, 17928, 2015, 1011, 1011, 1011, 11721, 3215, 3762, 3640, 1037, 4138, 2275, 1997, 2166, 23490, 17928, 2015, 2000, 8103, 2046, 11721, 3215, 3762, 1005, 1055, 6879, 6494, 2361...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...