code
stringlengths 3
1.01M
| repo_name
stringlengths 5
116
| path
stringlengths 3
311
| language
stringclasses 30
values | license
stringclasses 15
values | size
int64 3
1.01M
|
|---|---|---|---|---|---|
# Batch L-BFGS
This document provides a walkthrough of the L-BFGS example. To run the
application, first install these dependencies.
- SciPy
- [TensorFlow](https://www.tensorflow.org/)
Then from the directory `ray/examples/lbfgs/` run the following.
```
source ../../setup-env.sh
python driver.py
```
Optimization is at the heart of many machine learning algorithms. Much of
machine learning involves specifying a loss function and finding the parameters
that minimize the loss. If we can compute the gradient of the loss function,
then we can apply a variety of gradient-based optimization algorithms. L-BFGS is
one such algorithm. It is a quasi-Newton method that uses gradient information
to approximate the inverse Hessian of the loss function in a computationally
efficient manner.
## The serial version
First we load the data in batches. Here, each element in `batches` is a tuple
whose first component is a batch of `100` images and whose second component is a
batch of the `100` corresponding labels. For simplicity, we use TensorFlow's
built in methods for loading the data.
```python
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
batch_size = 100
num_batches = mnist.train.num_examples / batch_size
batches = [mnist.train.next_batch(batch_size) for _ in range(num_batches)]
```
Now, suppose we have defined a function which takes a set of model parameters
`theta` and a batch of data (both images and labels) and computes the loss for
that choice of model parameters on that batch of data. Similarly, suppose we've
also defined a function that takes the same arguments and computes the gradient
of the loss for that choice of model parameters.
```python
def loss(theta, xs, ys):
# compute the loss on a batch of data
return loss
def grad(theta, xs, ys):
# compute the gradient on a batch of data
return grad
def full_loss(theta):
# compute the loss on the full data set
return sum([loss(theta, xs, ys) for (xs, ys) in batches])
def full_grad(theta):
# compute the gradient on the full data set
return sum([grad(theta, xs, ys) for (xs, ys) in batches])
```
Since we are working with a small dataset, we don't actually need to separate
these methods into the part that operates on a batch and the part that operates
on the full dataset, but doing so will make the distributed version clearer.
Now, if we wish to optimize the loss function using L-BFGS, we simply plug these
functions, along with an initial choice of model parameters, into
`scipy.optimize.fmin_l_bfgs_b`.
```python
theta_init = 1e-2 * np.random.normal(size=dim)
result = scipy.optimize.fmin_l_bfgs_b(full_loss, theta_init, fprime=full_grad)
```
## The distributed version
In this example, the computation of the gradient itself can be done in parallel
on a number of workers or machines.
First, let's turn the data into a collection of remote objects.
```python
batch_ids = [(ray.put(xs), ray.put(ys)) for (xs, ys) in batches]
```
We can load the data on the driver and distribute it this way because MNIST
easily fits on a single machine. However, for larger data sets, we will need to
use remote functions to distribute the loading of the data.
Now, lets turn `loss` and `grad` into remote functions.
```python
@ray.remote
def loss(theta, xs, ys):
# compute the loss
return loss
@ray.remote
def grad(theta, xs, ys):
# compute the gradient
return grad
```
The only difference is that we added the `@ray.remote` decorator.
Now, it is easy to speed up the computation of the full loss and the full
gradient.
```python
def full_loss(theta):
theta_id = ray.put(theta)
loss_ids = [loss.remote(theta_id, xs_id, ys_id) for (xs_id, ys_id) in batch_ids]
return sum(ray.get(loss_ids))
def full_grad(theta):
theta_id = ray.put(theta)
grad_ids = [grad.remote(theta_id, xs_id, ys_id) for (xs_id, ys_id) in batch_ids]
return sum(ray.get(grad_ids)).astype("float64") # This conversion is necessary for use with fmin_l_bfgs_b.
```
Note that we turn `theta` into a remote object with the line `theta_id =
ray.put(theta)` before passing it into the remote functions. If we had written
```python
[loss.remote(theta, xs_id, ys_id) for (xs_id, ys_id) in batch_ids]
```
instead of
```python
theta_id = ray.put(theta)
[loss.remote(theta_id, xs_id, ys_id) for (xs_id, ys_id) in batch_ids]
```
then each task that got sent to the scheduler (one for every element of
`batch_ids`) would have had a copy of `theta` serialized inside of it. Since
`theta` here consists of the parameters of a potentially large model, this is
inefficient. *Large objects should be passed by object ID to remote functions
and not by value*.
We use remote functions and remote objects internally in the implementation of
`full_loss` and `full_grad`, but the user-facing behavior of these methods is
identical to the behavior in the serial version.
We can now optimize the objective with the same function call as before.
```python
theta_init = 1e-2 * np.random.normal(size=dim)
result = scipy.optimize.fmin_l_bfgs_b(full_loss, theta_init, fprime=full_grad)
```
|
amplab/ray
|
examples/lbfgs/README.md
|
Markdown
|
bsd-3-clause
| 5,136
|
/*
* Copyright (c) Andrey Kuznetsov. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of imagero Andrey Kuznetsov nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.smartg.icc;
import com.smartg.icc.tag.Tag;
import com.smartg.icc.tag.Tag.ICurve;
import com.smartg.icc.tag.TagType;
public class Curve extends Tag implements ICurve {
int entryCount;
float[] values;
Curve inverse;
float gamma;
public Curve(float[] values) {
this(TagType.CURVE_TYPE, values);
}
public Curve(TagType tagType, float[] values) {
super(tagType);
this.values = values;
setValues(values);
}
protected void setValues(float[] values) {
if (values == null) {
entryCount = 0;
} else if (values.length == 1) {
gamma = values[0];
entryCount = 1;
} else {
entryCount = values.length;
}
}
boolean isIdentity() {
return entryCount == 0;
}
boolean isGamma() {
return entryCount == 1;
}
boolean isCurve() {
return entryCount > 1;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Curve: {");
sb.append("[entryCount=" + entryCount + "] ");
sb.append("[isIdentity=" + isIdentity() + "] ");
sb.append("[isGamma=" + isGamma() + "] ");
sb.append("[isCurve=" + isCurve() + "] ");
if (isGamma()) {
sb.append("[gamma=" + gamma + "]");
}
sb.append("}");
return sb.toString();
}
public float get(float a) {
if (isIdentity()) {
return a;
} else if (isGamma()) {
return (float) Math.pow(a, gamma);
} else {
if (a > 1.0f) {
return values[values.length - 1];
} else if (a < 0) {
return values[0];
}
int index = (int) (a * values.length);
if (index >= values.length) {
return values[values.length - 1];
}
if (index <= 0) {
return values[0];
}
int index2 = index + 1;
float length = values.length;
float smin = index / length;
float smax = index2 / length;
float dmin = values[index - 1];
float dmax = values[index2 - 1];
return interpolate(a, smin, smax, dmin, dmax);
}
}
protected final float interpolate(float x, float smin, float smax, float dmin, float dmax) {
float dHeight = dmax - dmin;
float sHeight = smax - smin;
return dmin + ((x - smin) * (dHeight / sHeight));
}
public ICurve inverse() {
if (inverse == null) {
if (entryCount > 1) {
float[] ivalues = new float[entryCount];
int prevIndex = 0;
for (int i = 0; i < entryCount; i++) {
float f = values[i];
int index = (int) (f * (entryCount - 1));
if (index < entryCount) {
for (int j = prevIndex + 1; j <= index; j++) {
ivalues[j] = i / (float) entryCount;
}
}
prevIndex = index;
}
inverse = new Curve(getTagType(), ivalues);
inverse.inverse = this;
} else if (entryCount == 1) {
float[] ivalues = new float[1];
float igamma = 1f / gamma;
ivalues[0] = igamma;
inverse = new Curve(getTagType(), ivalues);
inverse.inverse = this;
} else {
inverse = this;
}
}
return inverse;
}
public int getEntryCount() {
return entryCount;
}
public float getGamma() {
return gamma;
}
public float[] getValues() {
return values;
}
}
|
andronix3/ICC
|
com/smartg/icc/Curve.java
|
Java
|
bsd-3-clause
| 4,675
|
/* $NetBSD: iomd_io.c,v 1.1 2001/10/05 22:27:41 reinoud Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe.
* Copyright (c) 1997 Causality Limited.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Mark Brinicombe.
* 4. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* bus_space I/O functions for iomd
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
/* Proto types for all the bus_space structure functions */
bs_protos(iomd);
bs_protos(bs_notimpl);
/* Declare the iomd bus space tag */
struct bus_space iomd_bs_tag = {
/* cookie */
NULL,
/* mapping/unmapping */
iomd_bs_map,
iomd_bs_unmap,
iomd_bs_subregion,
/* allocation/deallocation */
iomd_bs_alloc,
iomd_bs_free,
/* get kernel virtual address */
0, /* there is no linear mapping */
/* mmap bus space for userland */
bs_notimpl_bs_mmap, /* XXX correct? XXX */
/* barrier */
iomd_bs_barrier,
/* read (single) */
iomd_bs_r_1,
iomd_bs_r_2,
iomd_bs_r_4,
bs_notimpl_bs_r_8,
/* read multiple */
bs_notimpl_bs_rm_1,
iomd_bs_rm_2,
bs_notimpl_bs_rm_4,
bs_notimpl_bs_rm_8,
/* read region */
bs_notimpl_bs_rr_1,
bs_notimpl_bs_rr_2,
bs_notimpl_bs_rr_4,
bs_notimpl_bs_rr_8,
/* write (single) */
iomd_bs_w_1,
iomd_bs_w_2,
iomd_bs_w_4,
bs_notimpl_bs_w_8,
/* write multiple */
bs_notimpl_bs_wm_1,
iomd_bs_wm_2,
bs_notimpl_bs_wm_4,
bs_notimpl_bs_wm_8,
/* write region */
bs_notimpl_bs_wr_1,
bs_notimpl_bs_wr_2,
bs_notimpl_bs_wr_4,
bs_notimpl_bs_wr_8,
/* set multiple */
bs_notimpl_bs_sm_1,
bs_notimpl_bs_sm_2,
bs_notimpl_bs_sm_4,
bs_notimpl_bs_sm_8,
/* set region */
bs_notimpl_bs_sr_1,
bs_notimpl_bs_sr_2,
bs_notimpl_bs_sr_4,
bs_notimpl_bs_sr_8,
/* copy */
bs_notimpl_bs_c_1,
bs_notimpl_bs_c_2,
bs_notimpl_bs_c_4,
bs_notimpl_bs_c_8,
};
/* bus space functions */
int
iomd_bs_map(t, bpa, size, cacheable, bshp)
void *t;
bus_addr_t bpa;
bus_size_t size;
int cacheable;
bus_space_handle_t *bshp;
{
/*
* Temporary implementation as all I/O is already mapped etc.
*
* Eventually this function will do the mapping check for multiple maps
*/
*bshp = bpa;
return(0);
}
int
iomd_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
bpap, bshp)
void *t;
bus_addr_t rstart, rend;
bus_size_t size, alignment, boundary;
int cacheable;
bus_addr_t *bpap;
bus_space_handle_t *bshp;
{
panic("iomd_alloc(): Help!\n");
}
void
iomd_bs_unmap(t, bsh, size)
void *t;
bus_space_handle_t bsh;
bus_size_t size;
{
/*
* Temporary implementation
*/
}
void
iomd_bs_free(t, bsh, size)
void *t;
bus_space_handle_t bsh;
bus_size_t size;
{
panic("iomd_free(): Help!\n");
/* iomd_unmap() does all that we need to do. */
/* iomd_unmap(t, bsh, size);*/
}
int
iomd_bs_subregion(t, bsh, offset, size, nbshp)
void *t;
bus_space_handle_t bsh;
bus_size_t offset, size;
bus_space_handle_t *nbshp;
{
*nbshp = bsh + (offset << 2);
return (0);
}
void
iomd_bs_barrier(t, bsh, offset, len, flags)
void *t;
bus_space_handle_t bsh;
bus_size_t offset, len;
int flags;
{
}
/* End of iomd_io.c */
|
MarginC/kame
|
netbsd/sys/arch/arm/iomd/iomd_io.c
|
C
|
bsd-3-clause
| 4,622
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE476_NULL_Pointer_Dereference__int_18.c
Label Definition File: CWE476_NULL_Pointer_Dereference.label.xml
Template File: sources-sinks-18.tmpl.c
*/
/*
* @description
* CWE: 476 NULL Pointer Dereference
* BadSource: Set data to NULL
* GoodSource: Initialize data
* Sinks:
* GoodSink: Check for NULL before attempting to print data
* BadSink : Print data
* Flow Variant: 18 Control flow: goto statements
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE476_NULL_Pointer_Dereference__int_18_bad()
{
int * data;
goto source;
source:
/* POTENTIAL FLAW: Set data to NULL */
data = NULL;
goto sink;
sink:
/* POTENTIAL FLAW: Attempt to use data, which may be NULL */
printIntLine(*data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G() - use badsource and goodsink by reversing the blocks on the second goto statement */
static void goodB2G()
{
int * data;
goto source;
source:
/* POTENTIAL FLAW: Set data to NULL */
data = NULL;
goto sink;
sink:
/* FIX: Check for NULL before attempting to print data */
if (data != NULL)
{
printIntLine(*data);
}
else
{
printLine("data is NULL");
}
}
/* goodG2B() - use goodsource and badsink by reversing the blocks on the first goto statement */
static void goodG2B()
{
int * data;
int tmpData = 5;
goto source;
source:
/* FIX: Initialize data */
{
data = &tmpData;
}
goto sink;
sink:
/* POTENTIAL FLAW: Attempt to use data, which may be NULL */
printIntLine(*data);
}
void CWE476_NULL_Pointer_Dereference__int_18_good()
{
goodB2G();
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE476_NULL_Pointer_Dereference__int_18_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE476_NULL_Pointer_Dereference__int_18_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
JianpingZeng/xcc
|
xcc/test/juliet/testcases/CWE476_NULL_Pointer_Dereference/CWE476_NULL_Pointer_Dereference__int_18.c
|
C
|
bsd-3-clause
| 2,606
|
<!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"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>HE_Mesh: wblut.geom.WB_AABBTree2D.EntryOrder Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">HE_Mesh
 <span id="projectnumber">6.0.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Packages</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="classes.html"><span>Class Index</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div><!-- 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('classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order.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="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">wblut.geom.WB_AABBTree2D.EntryOrder Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
<img id="dynsection-0-trigger" src="closed.png" alt="+"/> Inheritance diagram for wblut.geom.WB_AABBTree2D.EntryOrder:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center">
<img src="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order.png" usemap="#wblut.geom.WB_AABBTree2D.EntryOrder_map" alt=""/>
<map id="wblut.geom.WB_AABBTree2D.EntryOrder_map" name="wblut.geom.WB_AABBTree2D.EntryOrder_map">
</map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a9a6b7345119e3355a6135a777fb997bb"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order.html#a9a6b7345119e3355a6135a777fb997bb">compare</a> (final <a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry.html">Entry</a> arg0, final <a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry.html">Entry</a> arg1)</td></tr>
<tr class="separator:a9a6b7345119e3355a6135a777fb997bb"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a9a6b7345119e3355a6135a777fb997bb"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int wblut.geom.WB_AABBTree2D.EntryOrder.compare </td>
<td>(</td>
<td class="paramtype">final <a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry.html">Entry</a> </td>
<td class="paramname"><em>arg0</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">final <a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry.html">Entry</a> </td>
<td class="paramname"><em>arg1</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/geom/wblut/geom/<a class="el" href="_w_b___a_a_b_b_tree2_d_8java.html">WB_AABBTree2D.java</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="namespacewblut.html">wblut</a></li><li class="navelem"><a class="el" href="namespacewblut_1_1geom.html">geom</a></li><li class="navelem"><a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d.html">WB_AABBTree2D</a></li><li class="navelem"><a class="el" href="classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order.html">EntryOrder</a></li>
<li class="footer">Generated on Tue Dec 19 2017 21:20:17 for HE_Mesh by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li>
</ul>
</div>
</body>
</html>
|
DweebsUnited/CodeMonkey
|
resources/hemesh/ref/html/classwblut_1_1geom_1_1_w_b___a_a_b_b_tree2_d_1_1_entry_order.html
|
HTML
|
bsd-3-clause
| 8,115
|
package org.jadice.recordmapper.impl;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jadice.recordmapper.AfterUnmarshal;
import org.jadice.recordmapper.BeforeMarshal;
import org.jadice.recordmapper.Mapping;
import org.jadice.recordmapper.MappingException;
import org.jadice.recordmapper.SeeAlso;
public abstract class RecordMapping extends Mapping {
protected Map<Class<?>, RecordMapping> recordMappings;
protected List<FieldMapping> fieldMappings = new ArrayList<FieldMapping>();
protected Map<String, FieldMapping> fieldMappingsByName = new HashMap<String, FieldMapping>();
private final List<Method> beforeMarshal = new ArrayList<Method>(0);
private final List<Method> afterUnmarshal = new ArrayList<Method>(0);
private List<Class<?>> seeAlso;
protected Class<?> recordClass;
public Collection<? extends Class<?>> getReferencedClasses() {
final List<Class<?>> referencedClasses = new ArrayList<Class<?>>();
if (null != seeAlso)
referencedClasses.addAll(seeAlso);
for (final FieldMapping fm : fieldMappings)
referencedClasses.addAll(fm.getReferencedClasses());
return referencedClasses;
}
public void postInit(final Map<Class<?>, RecordMapping> mappings) throws MappingException {
recordMappings = mappings;
for (final FieldMapping fm : fieldMappings)
fm.postInit();
}
public void setRecordClass(final Class<?> c, final Annotation recordAnnotation) throws MappingException {
recordClass = c;
assertCompatibility(c, recordAnnotation);
final List<Field> fields = new ArrayList<Field>();
gatherFields(c, fields);
for (final Field f : fields) {
for (final Annotation a : f.getAnnotations()) {
// don't try to create field mappings for auxiliary annotations
if (null != a.annotationType().getAnnotation(Auxiliary.class))
continue;
final String implName = a.annotationType().getPackage().getName() + ".impl."
+ a.annotationType().getSimpleName() + "Impl";
try {
final Class<?> mapping = Class.forName(implName);
if (FieldMapping.class.isAssignableFrom(mapping)) {
final FieldMapping fm = (FieldMapping) mapping.newInstance();
if (fieldMappingsByName.containsKey(f.getName()))
throw new MappingException(this, "Already have a field mapping for " + f);
assertCompatibility(c, f, a, fm);
f.setAccessible(true);
fm.init(this, f, a);
fieldMappings.add(fm);
fieldMappingsByName.put(f.getName(), fm);
}
} catch (final Exception e) {
throw new MappingException(this, "Can't create mapping class", e);
}
}
}
// look for callbacks
for (final Method m : c.getDeclaredMethods()) {
if (m.getAnnotation(BeforeMarshal.class) != null) {
if (m.getParameterTypes().length != 0)
throw new MappingException(this, "@BeforeMarshal callback methods must not take parameters");
m.setAccessible(true);
beforeMarshal.add(m);
}
if (m.getAnnotation(AfterUnmarshal.class) != null) {
if (m.getParameterTypes().length != 0)
throw new MappingException(this, "@AfterUnmarshal callback methods must not take parameters");
m.setAccessible(true);
afterUnmarshal.add(m);
}
}
// look for @SeeAlso
final SeeAlso a = c.getAnnotation(SeeAlso.class);
if (null != a)
seeAlso = Arrays.asList(a.value());
}
private void gatherFields(final Class<?> c, final List<Field> fields) {
if (null != c.getSuperclass())
gatherFields(c.getSuperclass(), fields);
for (final Field f : c.getDeclaredFields())
fields.add(f);
}
protected abstract void assertCompatibility(Class<?> c, Field f, Annotation fieldAnnotation, FieldMapping mapping)
throws MappingException;
protected abstract void assertCompatibility(Class<?> c, Annotation recordAnnotation) throws MappingException;
public void marshal(final Object record, final MarshalContext mc) throws MappingException {
for (final Method m : beforeMarshal)
try {
m.invoke(record, (Object[]) null);
} catch (final Exception e) {
throw new MappingException(this, "Can't invoke @BeforeMarshal callback method", e);
}
for (final FieldMapping fm : fieldMappings)
fm.beforeMarshal(mc);
for (final FieldMapping fm : fieldMappings) {
final Object value = mc.getValue(fm.getField());
fm.marshal(mc, value);
}
}
public void unmarshal(final Object record, final UnmarshalContext mc) throws MappingException {
for (final FieldMapping fm : fieldMappings)
mc.setValue(fm.getField(), fm.unmarshal(mc));
for (final FieldMapping fm : fieldMappings)
fm.afterUnmarshal(mc);
for (final Method m : afterUnmarshal)
try {
m.invoke(record, (Object[]) null);
} catch (final Exception e) {
throw new MappingException(this, "Can't invoke @AfterUnmarshal callback method", e);
}
}
@Override
public int getSize(final MappingContext ctx) throws MappingException {
int size = 0;
for (final FieldMapping fm : fieldMappings)
size += fm.getSize(ctx);
return size;
}
public FieldMapping getFieldMapping(final String ref) {
return fieldMappingsByName.get(ref);
}
public RecordMapping getRecordMapping(final Class<?> cls) {
return recordMappings.get(cls);
}
public Class<?> getRecordClass() {
return recordClass;
}
@Override
public String toString() {
return recordClass.getName();
}
}
|
levigo/recordmapper
|
src/main/java/org/jadice/recordmapper/impl/RecordMapping.java
|
Java
|
bsd-3-clause
| 6,043
|
// <copyright file="HttpServiceConfigIPListenParam.cs" company="Salesforce.com">
//
// Copyright (c) 2014 Salesforce.com, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// </copyright>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace WindowsPhoneDriverServer.Internal
{
/// <summary>
/// Represents the struct used to configure IP listening through the HTTP service.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct HttpServiceConfigIPListenParam
{
/// <summary>
/// The address length of the IP address.
/// </summary>
public ushort AddrLength;
/// <summary>
/// The pointer to the IP address.
/// </summary>
public IntPtr Address;
}
}
|
forcedotcom/windowsphonedriver
|
src/WindowsPhoneDriverServer/Internal/HttpServiceConfigIPListenParam.cs
|
C#
|
bsd-3-clause
| 2,309
|
package sge.bounds;
import org.junit.Assert;
import org.junit.Test;
import sge.math.Vector2;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Test Axis Aligned Bounding Box.
*/
public class Circle_Test {
// Basic Circles
// 8 .......
// .... .....
// 7 D ... . C .
// .. .....
// 6 .......
// ... . ...
// 5 ........ .. ..
// .. . .. . .
// 4 . . . . .
// . . . . .
// 3 . A . . B . .
// . . . . .
// 2 . . . . .
// .. . .. . .
// 1 ........ ...
// ... ...
// 0 1 2 3 4 5 6 7 8
//
final Circle A = new Circle(new Vector2(3.0f, 3.0f), 1.0f);
final Circle B = new Circle(new Vector2(5.0f, 3.0f), 2.0f);
final Circle C = new Circle(new Vector2(7.0f, 7.0f), 0.5f);
final Circle D = new Circle(new Vector2(2.0f, 3.0f), 4.0f);
@Test
public void intersects () throws Exception {
assertTrue(A.intersects(B));
assertTrue(B.intersects(A));
assertTrue(B.intersects(D));
assertTrue(D.intersects(B));
assertTrue(B.intersects(A));
assertTrue(A.intersects(D));
assertFalse(A.intersects(C));
assertFalse(C.intersects(D));
}
@Test
public void containsPoint () throws Exception {
assertTrue(A.contains(new Vector2(2.0f, 3.0f)));
assertTrue(C.contains(new Vector2(6.8f, 7.0f)));
assertFalse(B.contains(new Vector2(2.0f, 6.0f)));
}
@Test
public void containsCircle () throws Exception {
assertTrue(D.contains(A));
assertFalse(D.contains(C));
assertFalse(D.contains(B));
assertFalse(A.contains(D));
}
final Rectangle R = new Rectangle(2.0f, 0.0f, 4.0f, 2.0f);
final Rectangle S = new Rectangle(4.0f, 3.0f, 5.0f, 8.0f);
@Test
public void containsRect () throws Exception {
assertTrue(A.intersects(R));
assertTrue(D.contains(R));
assertFalse(D.contains(S));
}
}
|
stuhacking/SGEngine
|
src/test/java/sge/bounds/Circle_Test.java
|
Java
|
bsd-3-clause
| 2,492
|
#############################################################################
# Makefile for building ../../../../../lib/libta_libc_csd.a
# Generated by tmake;
# Project: ta_libc/ta_libc
# Template: lib
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
CFLAGS = -pipe -fPIC -Wall -W -g -DTA_DEBUG -D_DEBUG -DTA_SINGLE_THREAD
CXXFLAGS= -pipe -fPIC -Wall -W -g -DTA_DEBUG -D_DEBUG -DTA_SINGLE_THREAD
INCPATH = -I../../../../../src/ta_common -I../../../../../include -I../../../../../src/ta_abstract -I../../../../../src/ta_abstract/tables -I../../../../../src/ta_abstract/frames -I$(QTDIR)/include
AR = ar cqs
RANLIB =
MOC = $(QTDIR)/bin/moc
UIC = $(QTDIR)/bin/uic
TAR = tar -cf
GZIP = gzip -9f
####### Support for 64-bit systems
ifeq ($(shell uname -m), x86_64)
CFLAGS += -march=x86-64 -m64 -D__64BIT__
CXXFLAGS += -march=x86-64 -m64 -D__64BIT__
endif
####### Apply additional overruling user flags, if any
CFLAGS += $(CUSERFLAGS)
CXXFLAGS += $(CUSERFLAGS)
####### Files
HEADERS =
SOURCES = ../../../../../src/ta_common/ta_global.c \
../../../../../src/ta_common/ta_retcode.c \
../../../../../src/ta_common/ta_version.c \
../../../../../src/ta_abstract/ta_abstract.c \
../../../../../src/ta_abstract/ta_def_ui.c \
../../../../../src/ta_abstract/ta_func_api.c \
../../../../../src/ta_abstract/ta_group_idx.c \
../../../../../src/ta_abstract/frames/ta_frame.c \
../../../../../src/ta_abstract/tables/table_a.c \
../../../../../src/ta_abstract/tables/table_b.c \
../../../../../src/ta_abstract/tables/table_c.c \
../../../../../src/ta_abstract/tables/table_d.c \
../../../../../src/ta_abstract/tables/table_e.c \
../../../../../src/ta_abstract/tables/table_f.c \
../../../../../src/ta_abstract/tables/table_g.c \
../../../../../src/ta_abstract/tables/table_h.c \
../../../../../src/ta_abstract/tables/table_i.c \
../../../../../src/ta_abstract/tables/table_j.c \
../../../../../src/ta_abstract/tables/table_k.c \
../../../../../src/ta_abstract/tables/table_l.c \
../../../../../src/ta_abstract/tables/table_m.c \
../../../../../src/ta_abstract/tables/table_n.c \
../../../../../src/ta_abstract/tables/table_o.c \
../../../../../src/ta_abstract/tables/table_p.c \
../../../../../src/ta_abstract/tables/table_q.c \
../../../../../src/ta_abstract/tables/table_r.c \
../../../../../src/ta_abstract/tables/table_s.c \
../../../../../src/ta_abstract/tables/table_t.c \
../../../../../src/ta_abstract/tables/table_u.c \
../../../../../src/ta_abstract/tables/table_v.c \
../../../../../src/ta_abstract/tables/table_w.c \
../../../../../src/ta_abstract/tables/table_x.c \
../../../../../src/ta_abstract/tables/table_y.c \
../../../../../src/ta_abstract/tables/table_z.c \
../../../../../src/ta_func/ta_utility.c \
../../../../../src/ta_func/ta_ACCBANDS.c \
../../../../../src/ta_func/ta_ACOS.c \
../../../../../src/ta_func/ta_AD.c \
../../../../../src/ta_func/ta_ADD.c \
../../../../../src/ta_func/ta_ADOSC.c \
../../../../../src/ta_func/ta_ADX.c \
../../../../../src/ta_func/ta_ADXR.c \
../../../../../src/ta_func/ta_APO.c \
../../../../../src/ta_func/ta_AROON.c \
../../../../../src/ta_func/ta_AROONOSC.c \
../../../../../src/ta_func/ta_ASIN.c \
../../../../../src/ta_func/ta_ATAN.c \
../../../../../src/ta_func/ta_ATR.c \
../../../../../src/ta_func/ta_AVGPRICE.c \
../../../../../src/ta_func/ta_BBANDS.c \
../../../../../src/ta_func/ta_BETA.c \
../../../../../src/ta_func/ta_BOP.c \
../../../../../src/ta_func/ta_CCI.c \
../../../../../src/ta_func/ta_CDL2CROWS.c \
../../../../../src/ta_func/ta_CDL3BLACKCROWS.c \
../../../../../src/ta_func/ta_CDL3INSIDE.c \
../../../../../src/ta_func/ta_CDL3LINESTRIKE.c \
../../../../../src/ta_func/ta_CDL3OUTSIDE.c \
../../../../../src/ta_func/ta_CDL3STARSINSOUTH.c \
../../../../../src/ta_func/ta_CDL3WHITESOLDIERS.c \
../../../../../src/ta_func/ta_CDLABANDONEDBABY.c \
../../../../../src/ta_func/ta_CDLADVANCEBLOCK.c \
../../../../../src/ta_func/ta_CDLBELTHOLD.c \
../../../../../src/ta_func/ta_CDLBREAKAWAY.c \
../../../../../src/ta_func/ta_CDLCLOSINGMARUBOZU.c \
../../../../../src/ta_func/ta_CDLCONCEALBABYSWALL.c \
../../../../../src/ta_func/ta_CDLCOUNTERATTACK.c \
../../../../../src/ta_func/ta_CDLDARKCLOUDCOVER.c \
../../../../../src/ta_func/ta_CDLDOJI.c \
../../../../../src/ta_func/ta_CDLDOJISTAR.c \
../../../../../src/ta_func/ta_CDLDRAGONFLYDOJI.c \
../../../../../src/ta_func/ta_CDLENGULFING.c \
../../../../../src/ta_func/ta_CDLEVENINGDOJISTAR.c \
../../../../../src/ta_func/ta_CDLEVENINGSTAR.c \
../../../../../src/ta_func/ta_CDLGAPSIDESIDEWHITE.c \
../../../../../src/ta_func/ta_CDLGRAVESTONEDOJI.c \
../../../../../src/ta_func/ta_CDLHAMMER.c \
../../../../../src/ta_func/ta_CDLHANGINGMAN.c \
../../../../../src/ta_func/ta_CDLHARAMI.c \
../../../../../src/ta_func/ta_CDLHARAMICROSS.c \
../../../../../src/ta_func/ta_CDLHIGHWAVE.c \
../../../../../src/ta_func/ta_CDLHIKKAKE.c \
../../../../../src/ta_func/ta_CDLHIKKAKEMOD.c \
../../../../../src/ta_func/ta_CDLHOMINGPIGEON.c \
../../../../../src/ta_func/ta_CDLIDENTICAL3CROWS.c \
../../../../../src/ta_func/ta_CDLINNECK.c \
../../../../../src/ta_func/ta_CDLINVERTEDHAMMER.c \
../../../../../src/ta_func/ta_CDLKICKING.c \
../../../../../src/ta_func/ta_CDLKICKINGBYLENGTH.c \
../../../../../src/ta_func/ta_CDLLADDERBOTTOM.c \
../../../../../src/ta_func/ta_CDLLONGLEGGEDDOJI.c \
../../../../../src/ta_func/ta_CDLLONGLINE.c \
../../../../../src/ta_func/ta_CDLMARUBOZU.c \
../../../../../src/ta_func/ta_CDLMATCHINGLOW.c \
../../../../../src/ta_func/ta_CDLMATHOLD.c \
../../../../../src/ta_func/ta_CDLMORNINGDOJISTAR.c \
../../../../../src/ta_func/ta_CDLMORNINGSTAR.c \
../../../../../src/ta_func/ta_CDLONNECK.c \
../../../../../src/ta_func/ta_CDLPIERCING.c \
../../../../../src/ta_func/ta_CDLRICKSHAWMAN.c \
../../../../../src/ta_func/ta_CDLRISEFALL3METHODS.c \
../../../../../src/ta_func/ta_CDLSEPARATINGLINES.c \
../../../../../src/ta_func/ta_CDLSHOOTINGSTAR.c \
../../../../../src/ta_func/ta_CDLSHORTLINE.c \
../../../../../src/ta_func/ta_CDLSPINNINGTOP.c \
../../../../../src/ta_func/ta_CDLSTALLEDPATTERN.c \
../../../../../src/ta_func/ta_CDLSTICKSANDWICH.c \
../../../../../src/ta_func/ta_CDLTAKURI.c \
../../../../../src/ta_func/ta_CDLTASUKIGAP.c \
../../../../../src/ta_func/ta_CDLTHRUSTING.c \
../../../../../src/ta_func/ta_CDLTRISTAR.c \
../../../../../src/ta_func/ta_CDLUNIQUE3RIVER.c \
../../../../../src/ta_func/ta_CDLUPSIDEGAP2CROWS.c \
../../../../../src/ta_func/ta_CDLXSIDEGAP3METHODS.c \
../../../../../src/ta_func/ta_CEIL.c \
../../../../../src/ta_func/ta_CMO.c \
../../../../../src/ta_func/ta_CORREL.c \
../../../../../src/ta_func/ta_COS.c \
../../../../../src/ta_func/ta_COSH.c \
../../../../../src/ta_func/ta_DEMA.c \
../../../../../src/ta_func/ta_DIV.c \
../../../../../src/ta_func/ta_DX.c \
../../../../../src/ta_func/ta_EMA.c \
../../../../../src/ta_func/ta_EXP.c \
../../../../../src/ta_func/ta_FLOOR.c \
../../../../../src/ta_func/ta_HT_DCPERIOD.c \
../../../../../src/ta_func/ta_HT_DCPHASE.c \
../../../../../src/ta_func/ta_HT_PHASOR.c \
../../../../../src/ta_func/ta_HT_SINE.c \
../../../../../src/ta_func/ta_HT_TRENDLINE.c \
../../../../../src/ta_func/ta_HT_TRENDMODE.c \
../../../../../src/ta_func/ta_KAMA.c \
../../../../../src/ta_func/ta_LINEARREG.c \
../../../../../src/ta_func/ta_LINEARREG_ANGLE.c \
../../../../../src/ta_func/ta_LINEARREG_INTERCEPT.c \
../../../../../src/ta_func/ta_LINEARREG_SLOPE.c \
../../../../../src/ta_func/ta_LN.c \
../../../../../src/ta_func/ta_LOG10.c \
../../../../../src/ta_func/ta_MA.c \
../../../../../src/ta_func/ta_MACD.c \
../../../../../src/ta_func/ta_MACDEXT.c \
../../../../../src/ta_func/ta_MACDFIX.c \
../../../../../src/ta_func/ta_MAMA.c \
../../../../../src/ta_func/ta_MAVP.c \
../../../../../src/ta_func/ta_MAX.c \
../../../../../src/ta_func/ta_MAXINDEX.c \
../../../../../src/ta_func/ta_MEDPRICE.c \
../../../../../src/ta_func/ta_MFI.c \
../../../../../src/ta_func/ta_MIDPOINT.c \
../../../../../src/ta_func/ta_MIDPRICE.c \
../../../../../src/ta_func/ta_MIN.c \
../../../../../src/ta_func/ta_MININDEX.c \
../../../../../src/ta_func/ta_MINMAX.c \
../../../../../src/ta_func/ta_MINMAXINDEX.c \
../../../../../src/ta_func/ta_MINUS_DI.c \
../../../../../src/ta_func/ta_MINUS_DM.c \
../../../../../src/ta_func/ta_MOM.c \
../../../../../src/ta_func/ta_MULT.c \
../../../../../src/ta_func/ta_NATR.c \
../../../../../src/ta_func/ta_OBV.c \
../../../../../src/ta_func/ta_PLUS_DI.c \
../../../../../src/ta_func/ta_PLUS_DM.c \
../../../../../src/ta_func/ta_PPO.c \
../../../../../src/ta_func/ta_ROC.c \
../../../../../src/ta_func/ta_ROCP.c \
../../../../../src/ta_func/ta_ROCR.c \
../../../../../src/ta_func/ta_ROCR100.c \
../../../../../src/ta_func/ta_RSI.c \
../../../../../src/ta_func/ta_SAR.c \
../../../../../src/ta_func/ta_SAREXT.c \
../../../../../src/ta_func/ta_SIN.c \
../../../../../src/ta_func/ta_SINH.c \
../../../../../src/ta_func/ta_SMA.c \
../../../../../src/ta_func/ta_SQRT.c \
../../../../../src/ta_func/ta_STDDEV.c \
../../../../../src/ta_func/ta_STOCH.c \
../../../../../src/ta_func/ta_STOCHF.c \
../../../../../src/ta_func/ta_STOCHRSI.c \
../../../../../src/ta_func/ta_SUB.c \
../../../../../src/ta_func/ta_SUM.c \
../../../../../src/ta_func/ta_T3.c \
../../../../../src/ta_func/ta_TAN.c \
../../../../../src/ta_func/ta_TANH.c \
../../../../../src/ta_func/ta_TEMA.c \
../../../../../src/ta_func/ta_TRANGE.c \
../../../../../src/ta_func/ta_TRIMA.c \
../../../../../src/ta_func/ta_TRIX.c \
../../../../../src/ta_func/ta_TSF.c \
../../../../../src/ta_func/ta_TYPPRICE.c \
../../../../../src/ta_func/ta_ULTOSC.c \
../../../../../src/ta_func/ta_VAR.c \
../../../../../src/ta_func/ta_WCLPRICE.c \
../../../../../src/ta_func/ta_WILLR.c \
../../../../../src/ta_func/ta_WMA.c
OBJECTS = ../../../../../temp/csd/ta_global.o \
../../../../../temp/csd/ta_retcode.o \
../../../../../temp/csd/ta_version.o \
../../../../../temp/csd/ta_abstract.o \
../../../../../temp/csd/ta_def_ui.o \
../../../../../temp/csd/ta_func_api.o \
../../../../../temp/csd/ta_group_idx.o \
../../../../../temp/csd/ta_frame.o \
../../../../../temp/csd/table_a.o \
../../../../../temp/csd/table_b.o \
../../../../../temp/csd/table_c.o \
../../../../../temp/csd/table_d.o \
../../../../../temp/csd/table_e.o \
../../../../../temp/csd/table_f.o \
../../../../../temp/csd/table_g.o \
../../../../../temp/csd/table_h.o \
../../../../../temp/csd/table_i.o \
../../../../../temp/csd/table_j.o \
../../../../../temp/csd/table_k.o \
../../../../../temp/csd/table_l.o \
../../../../../temp/csd/table_m.o \
../../../../../temp/csd/table_n.o \
../../../../../temp/csd/table_o.o \
../../../../../temp/csd/table_p.o \
../../../../../temp/csd/table_q.o \
../../../../../temp/csd/table_r.o \
../../../../../temp/csd/table_s.o \
../../../../../temp/csd/table_t.o \
../../../../../temp/csd/table_u.o \
../../../../../temp/csd/table_v.o \
../../../../../temp/csd/table_w.o \
../../../../../temp/csd/table_x.o \
../../../../../temp/csd/table_y.o \
../../../../../temp/csd/table_z.o \
../../../../../temp/csd/ta_utility.o \
../../../../../temp/csd/ta_ACCBANDS.o \
../../../../../temp/csd/ta_ACOS.o \
../../../../../temp/csd/ta_AD.o \
../../../../../temp/csd/ta_ADD.o \
../../../../../temp/csd/ta_ADOSC.o \
../../../../../temp/csd/ta_ADX.o \
../../../../../temp/csd/ta_ADXR.o \
../../../../../temp/csd/ta_APO.o \
../../../../../temp/csd/ta_AROON.o \
../../../../../temp/csd/ta_AROONOSC.o \
../../../../../temp/csd/ta_ASIN.o \
../../../../../temp/csd/ta_ATAN.o \
../../../../../temp/csd/ta_ATR.o \
../../../../../temp/csd/ta_AVGPRICE.o \
../../../../../temp/csd/ta_BBANDS.o \
../../../../../temp/csd/ta_BETA.o \
../../../../../temp/csd/ta_BOP.o \
../../../../../temp/csd/ta_CCI.o \
../../../../../temp/csd/ta_CDL2CROWS.o \
../../../../../temp/csd/ta_CDL3BLACKCROWS.o \
../../../../../temp/csd/ta_CDL3INSIDE.o \
../../../../../temp/csd/ta_CDL3LINESTRIKE.o \
../../../../../temp/csd/ta_CDL3OUTSIDE.o \
../../../../../temp/csd/ta_CDL3STARSINSOUTH.o \
../../../../../temp/csd/ta_CDL3WHITESOLDIERS.o \
../../../../../temp/csd/ta_CDLABANDONEDBABY.o \
../../../../../temp/csd/ta_CDLADVANCEBLOCK.o \
../../../../../temp/csd/ta_CDLBELTHOLD.o \
../../../../../temp/csd/ta_CDLBREAKAWAY.o \
../../../../../temp/csd/ta_CDLCLOSINGMARUBOZU.o \
../../../../../temp/csd/ta_CDLCONCEALBABYSWALL.o \
../../../../../temp/csd/ta_CDLCOUNTERATTACK.o \
../../../../../temp/csd/ta_CDLDARKCLOUDCOVER.o \
../../../../../temp/csd/ta_CDLDOJI.o \
../../../../../temp/csd/ta_CDLDOJISTAR.o \
../../../../../temp/csd/ta_CDLDRAGONFLYDOJI.o \
../../../../../temp/csd/ta_CDLENGULFING.o \
../../../../../temp/csd/ta_CDLEVENINGDOJISTAR.o \
../../../../../temp/csd/ta_CDLEVENINGSTAR.o \
../../../../../temp/csd/ta_CDLGAPSIDESIDEWHITE.o \
../../../../../temp/csd/ta_CDLGRAVESTONEDOJI.o \
../../../../../temp/csd/ta_CDLHAMMER.o \
../../../../../temp/csd/ta_CDLHANGINGMAN.o \
../../../../../temp/csd/ta_CDLHARAMI.o \
../../../../../temp/csd/ta_CDLHARAMICROSS.o \
../../../../../temp/csd/ta_CDLHIGHWAVE.o \
../../../../../temp/csd/ta_CDLHIKKAKE.o \
../../../../../temp/csd/ta_CDLHIKKAKEMOD.o \
../../../../../temp/csd/ta_CDLHOMINGPIGEON.o \
../../../../../temp/csd/ta_CDLIDENTICAL3CROWS.o \
../../../../../temp/csd/ta_CDLINNECK.o \
../../../../../temp/csd/ta_CDLINVERTEDHAMMER.o \
../../../../../temp/csd/ta_CDLKICKING.o \
../../../../../temp/csd/ta_CDLKICKINGBYLENGTH.o \
../../../../../temp/csd/ta_CDLLADDERBOTTOM.o \
../../../../../temp/csd/ta_CDLLONGLEGGEDDOJI.o \
../../../../../temp/csd/ta_CDLLONGLINE.o \
../../../../../temp/csd/ta_CDLMARUBOZU.o \
../../../../../temp/csd/ta_CDLMATCHINGLOW.o \
../../../../../temp/csd/ta_CDLMATHOLD.o \
../../../../../temp/csd/ta_CDLMORNINGDOJISTAR.o \
../../../../../temp/csd/ta_CDLMORNINGSTAR.o \
../../../../../temp/csd/ta_CDLONNECK.o \
../../../../../temp/csd/ta_CDLPIERCING.o \
../../../../../temp/csd/ta_CDLRICKSHAWMAN.o \
../../../../../temp/csd/ta_CDLRISEFALL3METHODS.o \
../../../../../temp/csd/ta_CDLSEPARATINGLINES.o \
../../../../../temp/csd/ta_CDLSHOOTINGSTAR.o \
../../../../../temp/csd/ta_CDLSHORTLINE.o \
../../../../../temp/csd/ta_CDLSPINNINGTOP.o \
../../../../../temp/csd/ta_CDLSTALLEDPATTERN.o \
../../../../../temp/csd/ta_CDLSTICKSANDWICH.o \
../../../../../temp/csd/ta_CDLTAKURI.o \
../../../../../temp/csd/ta_CDLTASUKIGAP.o \
../../../../../temp/csd/ta_CDLTHRUSTING.o \
../../../../../temp/csd/ta_CDLTRISTAR.o \
../../../../../temp/csd/ta_CDLUNIQUE3RIVER.o \
../../../../../temp/csd/ta_CDLUPSIDEGAP2CROWS.o \
../../../../../temp/csd/ta_CDLXSIDEGAP3METHODS.o \
../../../../../temp/csd/ta_CEIL.o \
../../../../../temp/csd/ta_CMO.o \
../../../../../temp/csd/ta_CORREL.o \
../../../../../temp/csd/ta_COS.o \
../../../../../temp/csd/ta_COSH.o \
../../../../../temp/csd/ta_DEMA.o \
../../../../../temp/csd/ta_DIV.o \
../../../../../temp/csd/ta_DX.o \
../../../../../temp/csd/ta_EMA.o \
../../../../../temp/csd/ta_EXP.o \
../../../../../temp/csd/ta_FLOOR.o \
../../../../../temp/csd/ta_HT_DCPERIOD.o \
../../../../../temp/csd/ta_HT_DCPHASE.o \
../../../../../temp/csd/ta_HT_PHASOR.o \
../../../../../temp/csd/ta_HT_SINE.o \
../../../../../temp/csd/ta_HT_TRENDLINE.o \
../../../../../temp/csd/ta_HT_TRENDMODE.o \
../../../../../temp/csd/ta_KAMA.o \
../../../../../temp/csd/ta_LINEARREG.o \
../../../../../temp/csd/ta_LINEARREG_ANGLE.o \
../../../../../temp/csd/ta_LINEARREG_INTERCEPT.o \
../../../../../temp/csd/ta_LINEARREG_SLOPE.o \
../../../../../temp/csd/ta_LN.o \
../../../../../temp/csd/ta_LOG10.o \
../../../../../temp/csd/ta_MA.o \
../../../../../temp/csd/ta_MACD.o \
../../../../../temp/csd/ta_MACDEXT.o \
../../../../../temp/csd/ta_MACDFIX.o \
../../../../../temp/csd/ta_MAMA.o \
../../../../../temp/csd/ta_MAVP.o \
../../../../../temp/csd/ta_MAX.o \
../../../../../temp/csd/ta_MAXINDEX.o \
../../../../../temp/csd/ta_MEDPRICE.o \
../../../../../temp/csd/ta_MFI.o \
../../../../../temp/csd/ta_MIDPOINT.o \
../../../../../temp/csd/ta_MIDPRICE.o \
../../../../../temp/csd/ta_MIN.o \
../../../../../temp/csd/ta_MININDEX.o \
../../../../../temp/csd/ta_MINMAX.o \
../../../../../temp/csd/ta_MINMAXINDEX.o \
../../../../../temp/csd/ta_MINUS_DI.o \
../../../../../temp/csd/ta_MINUS_DM.o \
../../../../../temp/csd/ta_MOM.o \
../../../../../temp/csd/ta_MULT.o \
../../../../../temp/csd/ta_NATR.o \
../../../../../temp/csd/ta_OBV.o \
../../../../../temp/csd/ta_PLUS_DI.o \
../../../../../temp/csd/ta_PLUS_DM.o \
../../../../../temp/csd/ta_PPO.o \
../../../../../temp/csd/ta_ROC.o \
../../../../../temp/csd/ta_ROCP.o \
../../../../../temp/csd/ta_ROCR.o \
../../../../../temp/csd/ta_ROCR100.o \
../../../../../temp/csd/ta_RSI.o \
../../../../../temp/csd/ta_SAR.o \
../../../../../temp/csd/ta_SAREXT.o \
../../../../../temp/csd/ta_SIN.o \
../../../../../temp/csd/ta_SINH.o \
../../../../../temp/csd/ta_SMA.o \
../../../../../temp/csd/ta_SQRT.o \
../../../../../temp/csd/ta_STDDEV.o \
../../../../../temp/csd/ta_STOCH.o \
../../../../../temp/csd/ta_STOCHF.o \
../../../../../temp/csd/ta_STOCHRSI.o \
../../../../../temp/csd/ta_SUB.o \
../../../../../temp/csd/ta_SUM.o \
../../../../../temp/csd/ta_T3.o \
../../../../../temp/csd/ta_TAN.o \
../../../../../temp/csd/ta_TANH.o \
../../../../../temp/csd/ta_TEMA.o \
../../../../../temp/csd/ta_TRANGE.o \
../../../../../temp/csd/ta_TRIMA.o \
../../../../../temp/csd/ta_TRIX.o \
../../../../../temp/csd/ta_TSF.o \
../../../../../temp/csd/ta_TYPPRICE.o \
../../../../../temp/csd/ta_ULTOSC.o \
../../../../../temp/csd/ta_VAR.o \
../../../../../temp/csd/ta_WCLPRICE.o \
../../../../../temp/csd/ta_WILLR.o \
../../../../../temp/csd/ta_WMA.o
INTERFACES =
UICDECLS =
UICIMPLS =
SRCMOC =
OBJMOC =
DIST =
TARGET = ../../../../../lib/libta_libc_csd.a
INTERFACE_DECL_PATH = .
####### Implicit rules
.SUFFIXES: .cpp .cxx .cc .C .c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
all: $(TARGET)
staticlib: $(TARGET)
$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
-rm -f $(TARGET)
$(AR) $(TARGET) $(OBJECTS) $(OBJMOC)
moc: $(SRCMOC)
clean:
-rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
-rm -f *~ core
####### Sub-libraries
###### Combined headers
####### Compile
../../../../../temp/csd/ta_global.o: ../../../../../src/ta_common/ta_global.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_global.o ../../../../../src/ta_common/ta_global.c
../../../../../temp/csd/ta_retcode.o: ../../../../../src/ta_common/ta_retcode.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_retcode.o ../../../../../src/ta_common/ta_retcode.c
../../../../../temp/csd/ta_version.o: ../../../../../src/ta_common/ta_version.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_version.o ../../../../../src/ta_common/ta_version.c
../../../../../temp/csd/ta_abstract.o: ../../../../../src/ta_abstract/ta_abstract.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_abstract.o ../../../../../src/ta_abstract/ta_abstract.c
../../../../../temp/csd/ta_def_ui.o: ../../../../../src/ta_abstract/ta_def_ui.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_def_ui.o ../../../../../src/ta_abstract/ta_def_ui.c
../../../../../temp/csd/ta_func_api.o: ../../../../../src/ta_abstract/ta_func_api.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_func_api.o ../../../../../src/ta_abstract/ta_func_api.c
../../../../../temp/csd/ta_group_idx.o: ../../../../../src/ta_abstract/ta_group_idx.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_group_idx.o ../../../../../src/ta_abstract/ta_group_idx.c
../../../../../temp/csd/ta_frame.o: ../../../../../src/ta_abstract/frames/ta_frame.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_frame.o ../../../../../src/ta_abstract/frames/ta_frame.c
../../../../../temp/csd/table_a.o: ../../../../../src/ta_abstract/tables/table_a.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_a.o ../../../../../src/ta_abstract/tables/table_a.c
../../../../../temp/csd/table_b.o: ../../../../../src/ta_abstract/tables/table_b.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_b.o ../../../../../src/ta_abstract/tables/table_b.c
../../../../../temp/csd/table_c.o: ../../../../../src/ta_abstract/tables/table_c.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_c.o ../../../../../src/ta_abstract/tables/table_c.c
../../../../../temp/csd/table_d.o: ../../../../../src/ta_abstract/tables/table_d.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_d.o ../../../../../src/ta_abstract/tables/table_d.c
../../../../../temp/csd/table_e.o: ../../../../../src/ta_abstract/tables/table_e.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_e.o ../../../../../src/ta_abstract/tables/table_e.c
../../../../../temp/csd/table_f.o: ../../../../../src/ta_abstract/tables/table_f.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_f.o ../../../../../src/ta_abstract/tables/table_f.c
../../../../../temp/csd/table_g.o: ../../../../../src/ta_abstract/tables/table_g.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_g.o ../../../../../src/ta_abstract/tables/table_g.c
../../../../../temp/csd/table_h.o: ../../../../../src/ta_abstract/tables/table_h.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_h.o ../../../../../src/ta_abstract/tables/table_h.c
../../../../../temp/csd/table_i.o: ../../../../../src/ta_abstract/tables/table_i.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_i.o ../../../../../src/ta_abstract/tables/table_i.c
../../../../../temp/csd/table_j.o: ../../../../../src/ta_abstract/tables/table_j.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_j.o ../../../../../src/ta_abstract/tables/table_j.c
../../../../../temp/csd/table_k.o: ../../../../../src/ta_abstract/tables/table_k.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_k.o ../../../../../src/ta_abstract/tables/table_k.c
../../../../../temp/csd/table_l.o: ../../../../../src/ta_abstract/tables/table_l.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_l.o ../../../../../src/ta_abstract/tables/table_l.c
../../../../../temp/csd/table_m.o: ../../../../../src/ta_abstract/tables/table_m.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_m.o ../../../../../src/ta_abstract/tables/table_m.c
../../../../../temp/csd/table_n.o: ../../../../../src/ta_abstract/tables/table_n.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_n.o ../../../../../src/ta_abstract/tables/table_n.c
../../../../../temp/csd/table_o.o: ../../../../../src/ta_abstract/tables/table_o.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_o.o ../../../../../src/ta_abstract/tables/table_o.c
../../../../../temp/csd/table_p.o: ../../../../../src/ta_abstract/tables/table_p.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_p.o ../../../../../src/ta_abstract/tables/table_p.c
../../../../../temp/csd/table_q.o: ../../../../../src/ta_abstract/tables/table_q.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_q.o ../../../../../src/ta_abstract/tables/table_q.c
../../../../../temp/csd/table_r.o: ../../../../../src/ta_abstract/tables/table_r.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_r.o ../../../../../src/ta_abstract/tables/table_r.c
../../../../../temp/csd/table_s.o: ../../../../../src/ta_abstract/tables/table_s.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_s.o ../../../../../src/ta_abstract/tables/table_s.c
../../../../../temp/csd/table_t.o: ../../../../../src/ta_abstract/tables/table_t.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_t.o ../../../../../src/ta_abstract/tables/table_t.c
../../../../../temp/csd/table_u.o: ../../../../../src/ta_abstract/tables/table_u.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_u.o ../../../../../src/ta_abstract/tables/table_u.c
../../../../../temp/csd/table_v.o: ../../../../../src/ta_abstract/tables/table_v.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_v.o ../../../../../src/ta_abstract/tables/table_v.c
../../../../../temp/csd/table_w.o: ../../../../../src/ta_abstract/tables/table_w.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_w.o ../../../../../src/ta_abstract/tables/table_w.c
../../../../../temp/csd/table_x.o: ../../../../../src/ta_abstract/tables/table_x.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_x.o ../../../../../src/ta_abstract/tables/table_x.c
../../../../../temp/csd/table_y.o: ../../../../../src/ta_abstract/tables/table_y.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_y.o ../../../../../src/ta_abstract/tables/table_y.c
../../../../../temp/csd/table_z.o: ../../../../../src/ta_abstract/tables/table_z.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/table_z.o ../../../../../src/ta_abstract/tables/table_z.c
../../../../../temp/csd/ta_utility.o: ../../../../../src/ta_func/ta_utility.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_utility.o ../../../../../src/ta_func/ta_utility.c
../../../../../temp/csd/ta_ACCBANDS.o: ../../../../../src/ta_func/ta_ACCBANDS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ACCBANDS.o ../../../../../src/ta_func/ta_ACCBANDS.c
../../../../../temp/csd/ta_ACOS.o: ../../../../../src/ta_func/ta_ACOS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ACOS.o ../../../../../src/ta_func/ta_ACOS.c
../../../../../temp/csd/ta_AD.o: ../../../../../src/ta_func/ta_AD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_AD.o ../../../../../src/ta_func/ta_AD.c
../../../../../temp/csd/ta_ADD.o: ../../../../../src/ta_func/ta_ADD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ADD.o ../../../../../src/ta_func/ta_ADD.c
../../../../../temp/csd/ta_ADOSC.o: ../../../../../src/ta_func/ta_ADOSC.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ADOSC.o ../../../../../src/ta_func/ta_ADOSC.c
../../../../../temp/csd/ta_ADX.o: ../../../../../src/ta_func/ta_ADX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ADX.o ../../../../../src/ta_func/ta_ADX.c
../../../../../temp/csd/ta_ADXR.o: ../../../../../src/ta_func/ta_ADXR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ADXR.o ../../../../../src/ta_func/ta_ADXR.c
../../../../../temp/csd/ta_APO.o: ../../../../../src/ta_func/ta_APO.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_APO.o ../../../../../src/ta_func/ta_APO.c
../../../../../temp/csd/ta_AROON.o: ../../../../../src/ta_func/ta_AROON.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_AROON.o ../../../../../src/ta_func/ta_AROON.c
../../../../../temp/csd/ta_AROONOSC.o: ../../../../../src/ta_func/ta_AROONOSC.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_AROONOSC.o ../../../../../src/ta_func/ta_AROONOSC.c
../../../../../temp/csd/ta_ASIN.o: ../../../../../src/ta_func/ta_ASIN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ASIN.o ../../../../../src/ta_func/ta_ASIN.c
../../../../../temp/csd/ta_ATAN.o: ../../../../../src/ta_func/ta_ATAN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ATAN.o ../../../../../src/ta_func/ta_ATAN.c
../../../../../temp/csd/ta_ATR.o: ../../../../../src/ta_func/ta_ATR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ATR.o ../../../../../src/ta_func/ta_ATR.c
../../../../../temp/csd/ta_AVGPRICE.o: ../../../../../src/ta_func/ta_AVGPRICE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_AVGPRICE.o ../../../../../src/ta_func/ta_AVGPRICE.c
../../../../../temp/csd/ta_BBANDS.o: ../../../../../src/ta_func/ta_BBANDS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_BBANDS.o ../../../../../src/ta_func/ta_BBANDS.c
../../../../../temp/csd/ta_BETA.o: ../../../../../src/ta_func/ta_BETA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_BETA.o ../../../../../src/ta_func/ta_BETA.c
../../../../../temp/csd/ta_BOP.o: ../../../../../src/ta_func/ta_BOP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_BOP.o ../../../../../src/ta_func/ta_BOP.c
../../../../../temp/csd/ta_CCI.o: ../../../../../src/ta_func/ta_CCI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CCI.o ../../../../../src/ta_func/ta_CCI.c
../../../../../temp/csd/ta_CDL2CROWS.o: ../../../../../src/ta_func/ta_CDL2CROWS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL2CROWS.o ../../../../../src/ta_func/ta_CDL2CROWS.c
../../../../../temp/csd/ta_CDL3BLACKCROWS.o: ../../../../../src/ta_func/ta_CDL3BLACKCROWS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3BLACKCROWS.o ../../../../../src/ta_func/ta_CDL3BLACKCROWS.c
../../../../../temp/csd/ta_CDL3INSIDE.o: ../../../../../src/ta_func/ta_CDL3INSIDE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3INSIDE.o ../../../../../src/ta_func/ta_CDL3INSIDE.c
../../../../../temp/csd/ta_CDL3LINESTRIKE.o: ../../../../../src/ta_func/ta_CDL3LINESTRIKE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3LINESTRIKE.o ../../../../../src/ta_func/ta_CDL3LINESTRIKE.c
../../../../../temp/csd/ta_CDL3OUTSIDE.o: ../../../../../src/ta_func/ta_CDL3OUTSIDE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3OUTSIDE.o ../../../../../src/ta_func/ta_CDL3OUTSIDE.c
../../../../../temp/csd/ta_CDL3STARSINSOUTH.o: ../../../../../src/ta_func/ta_CDL3STARSINSOUTH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3STARSINSOUTH.o ../../../../../src/ta_func/ta_CDL3STARSINSOUTH.c
../../../../../temp/csd/ta_CDL3WHITESOLDIERS.o: ../../../../../src/ta_func/ta_CDL3WHITESOLDIERS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDL3WHITESOLDIERS.o ../../../../../src/ta_func/ta_CDL3WHITESOLDIERS.c
../../../../../temp/csd/ta_CDLABANDONEDBABY.o: ../../../../../src/ta_func/ta_CDLABANDONEDBABY.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLABANDONEDBABY.o ../../../../../src/ta_func/ta_CDLABANDONEDBABY.c
../../../../../temp/csd/ta_CDLADVANCEBLOCK.o: ../../../../../src/ta_func/ta_CDLADVANCEBLOCK.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLADVANCEBLOCK.o ../../../../../src/ta_func/ta_CDLADVANCEBLOCK.c
../../../../../temp/csd/ta_CDLBELTHOLD.o: ../../../../../src/ta_func/ta_CDLBELTHOLD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLBELTHOLD.o ../../../../../src/ta_func/ta_CDLBELTHOLD.c
../../../../../temp/csd/ta_CDLBREAKAWAY.o: ../../../../../src/ta_func/ta_CDLBREAKAWAY.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLBREAKAWAY.o ../../../../../src/ta_func/ta_CDLBREAKAWAY.c
../../../../../temp/csd/ta_CDLCLOSINGMARUBOZU.o: ../../../../../src/ta_func/ta_CDLCLOSINGMARUBOZU.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLCLOSINGMARUBOZU.o ../../../../../src/ta_func/ta_CDLCLOSINGMARUBOZU.c
../../../../../temp/csd/ta_CDLCONCEALBABYSWALL.o: ../../../../../src/ta_func/ta_CDLCONCEALBABYSWALL.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLCONCEALBABYSWALL.o ../../../../../src/ta_func/ta_CDLCONCEALBABYSWALL.c
../../../../../temp/csd/ta_CDLCOUNTERATTACK.o: ../../../../../src/ta_func/ta_CDLCOUNTERATTACK.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLCOUNTERATTACK.o ../../../../../src/ta_func/ta_CDLCOUNTERATTACK.c
../../../../../temp/csd/ta_CDLDARKCLOUDCOVER.o: ../../../../../src/ta_func/ta_CDLDARKCLOUDCOVER.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLDARKCLOUDCOVER.o ../../../../../src/ta_func/ta_CDLDARKCLOUDCOVER.c
../../../../../temp/csd/ta_CDLDOJI.o: ../../../../../src/ta_func/ta_CDLDOJI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLDOJI.o ../../../../../src/ta_func/ta_CDLDOJI.c
../../../../../temp/csd/ta_CDLDOJISTAR.o: ../../../../../src/ta_func/ta_CDLDOJISTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLDOJISTAR.o ../../../../../src/ta_func/ta_CDLDOJISTAR.c
../../../../../temp/csd/ta_CDLDRAGONFLYDOJI.o: ../../../../../src/ta_func/ta_CDLDRAGONFLYDOJI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLDRAGONFLYDOJI.o ../../../../../src/ta_func/ta_CDLDRAGONFLYDOJI.c
../../../../../temp/csd/ta_CDLENGULFING.o: ../../../../../src/ta_func/ta_CDLENGULFING.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLENGULFING.o ../../../../../src/ta_func/ta_CDLENGULFING.c
../../../../../temp/csd/ta_CDLEVENINGDOJISTAR.o: ../../../../../src/ta_func/ta_CDLEVENINGDOJISTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLEVENINGDOJISTAR.o ../../../../../src/ta_func/ta_CDLEVENINGDOJISTAR.c
../../../../../temp/csd/ta_CDLEVENINGSTAR.o: ../../../../../src/ta_func/ta_CDLEVENINGSTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLEVENINGSTAR.o ../../../../../src/ta_func/ta_CDLEVENINGSTAR.c
../../../../../temp/csd/ta_CDLGAPSIDESIDEWHITE.o: ../../../../../src/ta_func/ta_CDLGAPSIDESIDEWHITE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLGAPSIDESIDEWHITE.o ../../../../../src/ta_func/ta_CDLGAPSIDESIDEWHITE.c
../../../../../temp/csd/ta_CDLGRAVESTONEDOJI.o: ../../../../../src/ta_func/ta_CDLGRAVESTONEDOJI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLGRAVESTONEDOJI.o ../../../../../src/ta_func/ta_CDLGRAVESTONEDOJI.c
../../../../../temp/csd/ta_CDLHAMMER.o: ../../../../../src/ta_func/ta_CDLHAMMER.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHAMMER.o ../../../../../src/ta_func/ta_CDLHAMMER.c
../../../../../temp/csd/ta_CDLHANGINGMAN.o: ../../../../../src/ta_func/ta_CDLHANGINGMAN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHANGINGMAN.o ../../../../../src/ta_func/ta_CDLHANGINGMAN.c
../../../../../temp/csd/ta_CDLHARAMI.o: ../../../../../src/ta_func/ta_CDLHARAMI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHARAMI.o ../../../../../src/ta_func/ta_CDLHARAMI.c
../../../../../temp/csd/ta_CDLHARAMICROSS.o: ../../../../../src/ta_func/ta_CDLHARAMICROSS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHARAMICROSS.o ../../../../../src/ta_func/ta_CDLHARAMICROSS.c
../../../../../temp/csd/ta_CDLHIGHWAVE.o: ../../../../../src/ta_func/ta_CDLHIGHWAVE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHIGHWAVE.o ../../../../../src/ta_func/ta_CDLHIGHWAVE.c
../../../../../temp/csd/ta_CDLHIKKAKE.o: ../../../../../src/ta_func/ta_CDLHIKKAKE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHIKKAKE.o ../../../../../src/ta_func/ta_CDLHIKKAKE.c
../../../../../temp/csd/ta_CDLHIKKAKEMOD.o: ../../../../../src/ta_func/ta_CDLHIKKAKEMOD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHIKKAKEMOD.o ../../../../../src/ta_func/ta_CDLHIKKAKEMOD.c
../../../../../temp/csd/ta_CDLHOMINGPIGEON.o: ../../../../../src/ta_func/ta_CDLHOMINGPIGEON.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLHOMINGPIGEON.o ../../../../../src/ta_func/ta_CDLHOMINGPIGEON.c
../../../../../temp/csd/ta_CDLIDENTICAL3CROWS.o: ../../../../../src/ta_func/ta_CDLIDENTICAL3CROWS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLIDENTICAL3CROWS.o ../../../../../src/ta_func/ta_CDLIDENTICAL3CROWS.c
../../../../../temp/csd/ta_CDLINNECK.o: ../../../../../src/ta_func/ta_CDLINNECK.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLINNECK.o ../../../../../src/ta_func/ta_CDLINNECK.c
../../../../../temp/csd/ta_CDLINVERTEDHAMMER.o: ../../../../../src/ta_func/ta_CDLINVERTEDHAMMER.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLINVERTEDHAMMER.o ../../../../../src/ta_func/ta_CDLINVERTEDHAMMER.c
../../../../../temp/csd/ta_CDLKICKING.o: ../../../../../src/ta_func/ta_CDLKICKING.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLKICKING.o ../../../../../src/ta_func/ta_CDLKICKING.c
../../../../../temp/csd/ta_CDLKICKINGBYLENGTH.o: ../../../../../src/ta_func/ta_CDLKICKINGBYLENGTH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLKICKINGBYLENGTH.o ../../../../../src/ta_func/ta_CDLKICKINGBYLENGTH.c
../../../../../temp/csd/ta_CDLLADDERBOTTOM.o: ../../../../../src/ta_func/ta_CDLLADDERBOTTOM.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLLADDERBOTTOM.o ../../../../../src/ta_func/ta_CDLLADDERBOTTOM.c
../../../../../temp/csd/ta_CDLLONGLEGGEDDOJI.o: ../../../../../src/ta_func/ta_CDLLONGLEGGEDDOJI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLLONGLEGGEDDOJI.o ../../../../../src/ta_func/ta_CDLLONGLEGGEDDOJI.c
../../../../../temp/csd/ta_CDLLONGLINE.o: ../../../../../src/ta_func/ta_CDLLONGLINE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLLONGLINE.o ../../../../../src/ta_func/ta_CDLLONGLINE.c
../../../../../temp/csd/ta_CDLMARUBOZU.o: ../../../../../src/ta_func/ta_CDLMARUBOZU.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLMARUBOZU.o ../../../../../src/ta_func/ta_CDLMARUBOZU.c
../../../../../temp/csd/ta_CDLMATCHINGLOW.o: ../../../../../src/ta_func/ta_CDLMATCHINGLOW.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLMATCHINGLOW.o ../../../../../src/ta_func/ta_CDLMATCHINGLOW.c
../../../../../temp/csd/ta_CDLMATHOLD.o: ../../../../../src/ta_func/ta_CDLMATHOLD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLMATHOLD.o ../../../../../src/ta_func/ta_CDLMATHOLD.c
../../../../../temp/csd/ta_CDLMORNINGDOJISTAR.o: ../../../../../src/ta_func/ta_CDLMORNINGDOJISTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLMORNINGDOJISTAR.o ../../../../../src/ta_func/ta_CDLMORNINGDOJISTAR.c
../../../../../temp/csd/ta_CDLMORNINGSTAR.o: ../../../../../src/ta_func/ta_CDLMORNINGSTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLMORNINGSTAR.o ../../../../../src/ta_func/ta_CDLMORNINGSTAR.c
../../../../../temp/csd/ta_CDLONNECK.o: ../../../../../src/ta_func/ta_CDLONNECK.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLONNECK.o ../../../../../src/ta_func/ta_CDLONNECK.c
../../../../../temp/csd/ta_CDLPIERCING.o: ../../../../../src/ta_func/ta_CDLPIERCING.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLPIERCING.o ../../../../../src/ta_func/ta_CDLPIERCING.c
../../../../../temp/csd/ta_CDLRICKSHAWMAN.o: ../../../../../src/ta_func/ta_CDLRICKSHAWMAN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLRICKSHAWMAN.o ../../../../../src/ta_func/ta_CDLRICKSHAWMAN.c
../../../../../temp/csd/ta_CDLRISEFALL3METHODS.o: ../../../../../src/ta_func/ta_CDLRISEFALL3METHODS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLRISEFALL3METHODS.o ../../../../../src/ta_func/ta_CDLRISEFALL3METHODS.c
../../../../../temp/csd/ta_CDLSEPARATINGLINES.o: ../../../../../src/ta_func/ta_CDLSEPARATINGLINES.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSEPARATINGLINES.o ../../../../../src/ta_func/ta_CDLSEPARATINGLINES.c
../../../../../temp/csd/ta_CDLSHOOTINGSTAR.o: ../../../../../src/ta_func/ta_CDLSHOOTINGSTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSHOOTINGSTAR.o ../../../../../src/ta_func/ta_CDLSHOOTINGSTAR.c
../../../../../temp/csd/ta_CDLSHORTLINE.o: ../../../../../src/ta_func/ta_CDLSHORTLINE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSHORTLINE.o ../../../../../src/ta_func/ta_CDLSHORTLINE.c
../../../../../temp/csd/ta_CDLSPINNINGTOP.o: ../../../../../src/ta_func/ta_CDLSPINNINGTOP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSPINNINGTOP.o ../../../../../src/ta_func/ta_CDLSPINNINGTOP.c
../../../../../temp/csd/ta_CDLSTALLEDPATTERN.o: ../../../../../src/ta_func/ta_CDLSTALLEDPATTERN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSTALLEDPATTERN.o ../../../../../src/ta_func/ta_CDLSTALLEDPATTERN.c
../../../../../temp/csd/ta_CDLSTICKSANDWICH.o: ../../../../../src/ta_func/ta_CDLSTICKSANDWICH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLSTICKSANDWICH.o ../../../../../src/ta_func/ta_CDLSTICKSANDWICH.c
../../../../../temp/csd/ta_CDLTAKURI.o: ../../../../../src/ta_func/ta_CDLTAKURI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLTAKURI.o ../../../../../src/ta_func/ta_CDLTAKURI.c
../../../../../temp/csd/ta_CDLTASUKIGAP.o: ../../../../../src/ta_func/ta_CDLTASUKIGAP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLTASUKIGAP.o ../../../../../src/ta_func/ta_CDLTASUKIGAP.c
../../../../../temp/csd/ta_CDLTHRUSTING.o: ../../../../../src/ta_func/ta_CDLTHRUSTING.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLTHRUSTING.o ../../../../../src/ta_func/ta_CDLTHRUSTING.c
../../../../../temp/csd/ta_CDLTRISTAR.o: ../../../../../src/ta_func/ta_CDLTRISTAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLTRISTAR.o ../../../../../src/ta_func/ta_CDLTRISTAR.c
../../../../../temp/csd/ta_CDLUNIQUE3RIVER.o: ../../../../../src/ta_func/ta_CDLUNIQUE3RIVER.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLUNIQUE3RIVER.o ../../../../../src/ta_func/ta_CDLUNIQUE3RIVER.c
../../../../../temp/csd/ta_CDLUPSIDEGAP2CROWS.o: ../../../../../src/ta_func/ta_CDLUPSIDEGAP2CROWS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLUPSIDEGAP2CROWS.o ../../../../../src/ta_func/ta_CDLUPSIDEGAP2CROWS.c
../../../../../temp/csd/ta_CDLXSIDEGAP3METHODS.o: ../../../../../src/ta_func/ta_CDLXSIDEGAP3METHODS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CDLXSIDEGAP3METHODS.o ../../../../../src/ta_func/ta_CDLXSIDEGAP3METHODS.c
../../../../../temp/csd/ta_CEIL.o: ../../../../../src/ta_func/ta_CEIL.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CEIL.o ../../../../../src/ta_func/ta_CEIL.c
../../../../../temp/csd/ta_CMO.o: ../../../../../src/ta_func/ta_CMO.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CMO.o ../../../../../src/ta_func/ta_CMO.c
../../../../../temp/csd/ta_CORREL.o: ../../../../../src/ta_func/ta_CORREL.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_CORREL.o ../../../../../src/ta_func/ta_CORREL.c
../../../../../temp/csd/ta_COS.o: ../../../../../src/ta_func/ta_COS.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_COS.o ../../../../../src/ta_func/ta_COS.c
../../../../../temp/csd/ta_COSH.o: ../../../../../src/ta_func/ta_COSH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_COSH.o ../../../../../src/ta_func/ta_COSH.c
../../../../../temp/csd/ta_DEMA.o: ../../../../../src/ta_func/ta_DEMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_DEMA.o ../../../../../src/ta_func/ta_DEMA.c
../../../../../temp/csd/ta_DIV.o: ../../../../../src/ta_func/ta_DIV.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_DIV.o ../../../../../src/ta_func/ta_DIV.c
../../../../../temp/csd/ta_DX.o: ../../../../../src/ta_func/ta_DX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_DX.o ../../../../../src/ta_func/ta_DX.c
../../../../../temp/csd/ta_EMA.o: ../../../../../src/ta_func/ta_EMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_EMA.o ../../../../../src/ta_func/ta_EMA.c
../../../../../temp/csd/ta_EXP.o: ../../../../../src/ta_func/ta_EXP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_EXP.o ../../../../../src/ta_func/ta_EXP.c
../../../../../temp/csd/ta_FLOOR.o: ../../../../../src/ta_func/ta_FLOOR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_FLOOR.o ../../../../../src/ta_func/ta_FLOOR.c
../../../../../temp/csd/ta_HT_DCPERIOD.o: ../../../../../src/ta_func/ta_HT_DCPERIOD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_DCPERIOD.o ../../../../../src/ta_func/ta_HT_DCPERIOD.c
../../../../../temp/csd/ta_HT_DCPHASE.o: ../../../../../src/ta_func/ta_HT_DCPHASE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_DCPHASE.o ../../../../../src/ta_func/ta_HT_DCPHASE.c
../../../../../temp/csd/ta_HT_PHASOR.o: ../../../../../src/ta_func/ta_HT_PHASOR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_PHASOR.o ../../../../../src/ta_func/ta_HT_PHASOR.c
../../../../../temp/csd/ta_HT_SINE.o: ../../../../../src/ta_func/ta_HT_SINE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_SINE.o ../../../../../src/ta_func/ta_HT_SINE.c
../../../../../temp/csd/ta_HT_TRENDLINE.o: ../../../../../src/ta_func/ta_HT_TRENDLINE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_TRENDLINE.o ../../../../../src/ta_func/ta_HT_TRENDLINE.c
../../../../../temp/csd/ta_HT_TRENDMODE.o: ../../../../../src/ta_func/ta_HT_TRENDMODE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_HT_TRENDMODE.o ../../../../../src/ta_func/ta_HT_TRENDMODE.c
../../../../../temp/csd/ta_KAMA.o: ../../../../../src/ta_func/ta_KAMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_KAMA.o ../../../../../src/ta_func/ta_KAMA.c
../../../../../temp/csd/ta_LINEARREG.o: ../../../../../src/ta_func/ta_LINEARREG.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LINEARREG.o ../../../../../src/ta_func/ta_LINEARREG.c
../../../../../temp/csd/ta_LINEARREG_ANGLE.o: ../../../../../src/ta_func/ta_LINEARREG_ANGLE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LINEARREG_ANGLE.o ../../../../../src/ta_func/ta_LINEARREG_ANGLE.c
../../../../../temp/csd/ta_LINEARREG_INTERCEPT.o: ../../../../../src/ta_func/ta_LINEARREG_INTERCEPT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LINEARREG_INTERCEPT.o ../../../../../src/ta_func/ta_LINEARREG_INTERCEPT.c
../../../../../temp/csd/ta_LINEARREG_SLOPE.o: ../../../../../src/ta_func/ta_LINEARREG_SLOPE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LINEARREG_SLOPE.o ../../../../../src/ta_func/ta_LINEARREG_SLOPE.c
../../../../../temp/csd/ta_LN.o: ../../../../../src/ta_func/ta_LN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LN.o ../../../../../src/ta_func/ta_LN.c
../../../../../temp/csd/ta_LOG10.o: ../../../../../src/ta_func/ta_LOG10.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_LOG10.o ../../../../../src/ta_func/ta_LOG10.c
../../../../../temp/csd/ta_MA.o: ../../../../../src/ta_func/ta_MA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MA.o ../../../../../src/ta_func/ta_MA.c
../../../../../temp/csd/ta_MACD.o: ../../../../../src/ta_func/ta_MACD.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MACD.o ../../../../../src/ta_func/ta_MACD.c
../../../../../temp/csd/ta_MACDEXT.o: ../../../../../src/ta_func/ta_MACDEXT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MACDEXT.o ../../../../../src/ta_func/ta_MACDEXT.c
../../../../../temp/csd/ta_MACDFIX.o: ../../../../../src/ta_func/ta_MACDFIX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MACDFIX.o ../../../../../src/ta_func/ta_MACDFIX.c
../../../../../temp/csd/ta_MAMA.o: ../../../../../src/ta_func/ta_MAMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MAMA.o ../../../../../src/ta_func/ta_MAMA.c
../../../../../temp/csd/ta_MAVP.o: ../../../../../src/ta_func/ta_MAVP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MAVP.o ../../../../../src/ta_func/ta_MAVP.c
../../../../../temp/csd/ta_MAX.o: ../../../../../src/ta_func/ta_MAX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MAX.o ../../../../../src/ta_func/ta_MAX.c
../../../../../temp/csd/ta_MAXINDEX.o: ../../../../../src/ta_func/ta_MAXINDEX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MAXINDEX.o ../../../../../src/ta_func/ta_MAXINDEX.c
../../../../../temp/csd/ta_MEDPRICE.o: ../../../../../src/ta_func/ta_MEDPRICE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MEDPRICE.o ../../../../../src/ta_func/ta_MEDPRICE.c
../../../../../temp/csd/ta_MFI.o: ../../../../../src/ta_func/ta_MFI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MFI.o ../../../../../src/ta_func/ta_MFI.c
../../../../../temp/csd/ta_MIDPOINT.o: ../../../../../src/ta_func/ta_MIDPOINT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MIDPOINT.o ../../../../../src/ta_func/ta_MIDPOINT.c
../../../../../temp/csd/ta_MIDPRICE.o: ../../../../../src/ta_func/ta_MIDPRICE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MIDPRICE.o ../../../../../src/ta_func/ta_MIDPRICE.c
../../../../../temp/csd/ta_MIN.o: ../../../../../src/ta_func/ta_MIN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MIN.o ../../../../../src/ta_func/ta_MIN.c
../../../../../temp/csd/ta_MININDEX.o: ../../../../../src/ta_func/ta_MININDEX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MININDEX.o ../../../../../src/ta_func/ta_MININDEX.c
../../../../../temp/csd/ta_MINMAX.o: ../../../../../src/ta_func/ta_MINMAX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MINMAX.o ../../../../../src/ta_func/ta_MINMAX.c
../../../../../temp/csd/ta_MINMAXINDEX.o: ../../../../../src/ta_func/ta_MINMAXINDEX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MINMAXINDEX.o ../../../../../src/ta_func/ta_MINMAXINDEX.c
../../../../../temp/csd/ta_MINUS_DI.o: ../../../../../src/ta_func/ta_MINUS_DI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MINUS_DI.o ../../../../../src/ta_func/ta_MINUS_DI.c
../../../../../temp/csd/ta_MINUS_DM.o: ../../../../../src/ta_func/ta_MINUS_DM.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MINUS_DM.o ../../../../../src/ta_func/ta_MINUS_DM.c
../../../../../temp/csd/ta_MOM.o: ../../../../../src/ta_func/ta_MOM.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MOM.o ../../../../../src/ta_func/ta_MOM.c
../../../../../temp/csd/ta_MULT.o: ../../../../../src/ta_func/ta_MULT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_MULT.o ../../../../../src/ta_func/ta_MULT.c
../../../../../temp/csd/ta_NATR.o: ../../../../../src/ta_func/ta_NATR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_NATR.o ../../../../../src/ta_func/ta_NATR.c
../../../../../temp/csd/ta_OBV.o: ../../../../../src/ta_func/ta_OBV.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_OBV.o ../../../../../src/ta_func/ta_OBV.c
../../../../../temp/csd/ta_PLUS_DI.o: ../../../../../src/ta_func/ta_PLUS_DI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_PLUS_DI.o ../../../../../src/ta_func/ta_PLUS_DI.c
../../../../../temp/csd/ta_PLUS_DM.o: ../../../../../src/ta_func/ta_PLUS_DM.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_PLUS_DM.o ../../../../../src/ta_func/ta_PLUS_DM.c
../../../../../temp/csd/ta_PPO.o: ../../../../../src/ta_func/ta_PPO.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_PPO.o ../../../../../src/ta_func/ta_PPO.c
../../../../../temp/csd/ta_ROC.o: ../../../../../src/ta_func/ta_ROC.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ROC.o ../../../../../src/ta_func/ta_ROC.c
../../../../../temp/csd/ta_ROCP.o: ../../../../../src/ta_func/ta_ROCP.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ROCP.o ../../../../../src/ta_func/ta_ROCP.c
../../../../../temp/csd/ta_ROCR.o: ../../../../../src/ta_func/ta_ROCR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ROCR.o ../../../../../src/ta_func/ta_ROCR.c
../../../../../temp/csd/ta_ROCR100.o: ../../../../../src/ta_func/ta_ROCR100.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ROCR100.o ../../../../../src/ta_func/ta_ROCR100.c
../../../../../temp/csd/ta_RSI.o: ../../../../../src/ta_func/ta_RSI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_RSI.o ../../../../../src/ta_func/ta_RSI.c
../../../../../temp/csd/ta_SAR.o: ../../../../../src/ta_func/ta_SAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SAR.o ../../../../../src/ta_func/ta_SAR.c
../../../../../temp/csd/ta_SAREXT.o: ../../../../../src/ta_func/ta_SAREXT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SAREXT.o ../../../../../src/ta_func/ta_SAREXT.c
../../../../../temp/csd/ta_SIN.o: ../../../../../src/ta_func/ta_SIN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SIN.o ../../../../../src/ta_func/ta_SIN.c
../../../../../temp/csd/ta_SINH.o: ../../../../../src/ta_func/ta_SINH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SINH.o ../../../../../src/ta_func/ta_SINH.c
../../../../../temp/csd/ta_SMA.o: ../../../../../src/ta_func/ta_SMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SMA.o ../../../../../src/ta_func/ta_SMA.c
../../../../../temp/csd/ta_SQRT.o: ../../../../../src/ta_func/ta_SQRT.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SQRT.o ../../../../../src/ta_func/ta_SQRT.c
../../../../../temp/csd/ta_STDDEV.o: ../../../../../src/ta_func/ta_STDDEV.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_STDDEV.o ../../../../../src/ta_func/ta_STDDEV.c
../../../../../temp/csd/ta_STOCH.o: ../../../../../src/ta_func/ta_STOCH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_STOCH.o ../../../../../src/ta_func/ta_STOCH.c
../../../../../temp/csd/ta_STOCHF.o: ../../../../../src/ta_func/ta_STOCHF.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_STOCHF.o ../../../../../src/ta_func/ta_STOCHF.c
../../../../../temp/csd/ta_STOCHRSI.o: ../../../../../src/ta_func/ta_STOCHRSI.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_STOCHRSI.o ../../../../../src/ta_func/ta_STOCHRSI.c
../../../../../temp/csd/ta_SUB.o: ../../../../../src/ta_func/ta_SUB.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SUB.o ../../../../../src/ta_func/ta_SUB.c
../../../../../temp/csd/ta_SUM.o: ../../../../../src/ta_func/ta_SUM.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_SUM.o ../../../../../src/ta_func/ta_SUM.c
../../../../../temp/csd/ta_T3.o: ../../../../../src/ta_func/ta_T3.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_T3.o ../../../../../src/ta_func/ta_T3.c
../../../../../temp/csd/ta_TAN.o: ../../../../../src/ta_func/ta_TAN.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TAN.o ../../../../../src/ta_func/ta_TAN.c
../../../../../temp/csd/ta_TANH.o: ../../../../../src/ta_func/ta_TANH.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TANH.o ../../../../../src/ta_func/ta_TANH.c
../../../../../temp/csd/ta_TEMA.o: ../../../../../src/ta_func/ta_TEMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TEMA.o ../../../../../src/ta_func/ta_TEMA.c
../../../../../temp/csd/ta_TRANGE.o: ../../../../../src/ta_func/ta_TRANGE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TRANGE.o ../../../../../src/ta_func/ta_TRANGE.c
../../../../../temp/csd/ta_TRIMA.o: ../../../../../src/ta_func/ta_TRIMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TRIMA.o ../../../../../src/ta_func/ta_TRIMA.c
../../../../../temp/csd/ta_TRIX.o: ../../../../../src/ta_func/ta_TRIX.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TRIX.o ../../../../../src/ta_func/ta_TRIX.c
../../../../../temp/csd/ta_TSF.o: ../../../../../src/ta_func/ta_TSF.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TSF.o ../../../../../src/ta_func/ta_TSF.c
../../../../../temp/csd/ta_TYPPRICE.o: ../../../../../src/ta_func/ta_TYPPRICE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_TYPPRICE.o ../../../../../src/ta_func/ta_TYPPRICE.c
../../../../../temp/csd/ta_ULTOSC.o: ../../../../../src/ta_func/ta_ULTOSC.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_ULTOSC.o ../../../../../src/ta_func/ta_ULTOSC.c
../../../../../temp/csd/ta_VAR.o: ../../../../../src/ta_func/ta_VAR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_VAR.o ../../../../../src/ta_func/ta_VAR.c
../../../../../temp/csd/ta_WCLPRICE.o: ../../../../../src/ta_func/ta_WCLPRICE.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_WCLPRICE.o ../../../../../src/ta_func/ta_WCLPRICE.c
../../../../../temp/csd/ta_WILLR.o: ../../../../../src/ta_func/ta_WILLR.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_WILLR.o ../../../../../src/ta_func/ta_WILLR.c
../../../../../temp/csd/ta_WMA.o: ../../../../../src/ta_func/ta_WMA.c
$(CC) -c $(CFLAGS) $(INCPATH) -o ../../../../../temp/csd/ta_WMA.o ../../../../../src/ta_func/ta_WMA.c
|
d-s-x/ta-lib
|
c/make/csd/linux/g++/ta_libc/Makefile
|
Makefile
|
bsd-3-clause
| 58,360
|
---
tags: epidemiologi
title: Fattiga och rika
author: Karl Pettersson
lang: sv
---
Nu i veckan rapporterades att det dör fler människor av cancer än av
cirkulationssjukdom "bland medelålders människor i höginkomstländer"
[@Larsson190903]. Det bygger på en artikel som publicerats i Lancet
inom ramen för studien PURE [@Dagenais2019]. I studien har 162\ 534
personer från 21 olika länder (däribland Sverige) följts under peroden
2005–2016. De 21 länderna har sedan, i enlighet med Världsbankens
klassifikation, delats in i låginkomstländer (Bangladesh, Indien,
Pakistan och Zimbabwe), medelinkomstländer
(bl.a.\ Filippinerna, Iran, Kina och Polen) och höginkomstländer
(Förenade Arabemiraten, Kanada, Saudiarabien och Sverige). Vid
rekryteringen var personerna 35–70 år gamla med en medelålder på 51
år. Under uppföljningen dog 11\ 307 personer: bland dessa var
cirkulationssjukdom vanligare dödsorsak än cancer globalt och i de
båda lägre inkomstgrupperna, men cancer var vanligare dödsorsak i
höginkomstländerna. Ålders- och könsstandardiserade dödstal i
cirkulationssjukdom var mycket högre i låginkomstländerna (4,1/1000
personår) och medelinkomstländerna (2,1) än i höginkomstländerna
(0,6). För incidensen i dessa sjukdomar var mönstret likartat, fast
inte lika utpräglat (7,1, 6,8 och 4,3 i låg-, mellan- och
höginkomstländer).
Några uppgifter om åldersfördelningen av dödsfall har jag inte kunnat
hitta, men givet den initiala åldersfördelningen och uppföljningstiden
måste de allra flesta dödsfall ha inträffat före 75 års ålder.
Det är inte någon större nyhet att cancer är en vanligare dödsorsak
än cirkulationssjukdom i dessa åldersgrupper i rika länder, framför
allt bland kvinnor. @Fig:secirctum5116_4574 visar kvot mellan antalet
dödsfall i cirkulationsorgan och tumörer (enligt de definioner som
används i [Mortalitetsdiagram](https://mortchart.klpn.se/mortchartdoc.html))
i Sverige i åldersgrupperna 45–64 och 65–74 år. Det bygger på data
tillgängliga via @whomort, och kan, om
[Mortchartgen.jl](https://github.com/klpn/Mortchartgen.jl)
installerats och datafiler lästs in, återskapas genom att
klona [bloggförrådet](https://github.com/klpn/static-dust.git) och köra
`./cts.jl` i underkatalogen `postdata/2019-09-08-fattig`.^[Använder
denna gång också @pgfplotsx för att generera diagrammet.]
{#fig:secirctum5116_4574 width=100%}
Bland svenska kvinnor i åldersgruppen 45–64 år ägde alltså en sådan
övergång rum redan på 1950-talet, även om den bland männen inträffade
först efter millennieskiftet, genom nedgången av kranskärlssjukdom. Om
något verkar trenden med sjunkande kvot ha stabiliserats de senaste
10–15 åren, vilket är i linje med vad jag skrev [den 3 december
2016](2016-12-03-seliv.html). Men samtidigt är dessa dödsfall före 75
års ålder inte representativa för dödligheten som helhet i Sverige och
andra höginkomstländer, där medellivslängden numera är över 80 år. I
veckan offentliggjordes också svensk dödsorsaksstatistik för 2018
[@sosdorstat2018]. Av denna framgår att tumörer (ICD-10 C00-D48) stod
för 23,9/27,1 procent av alla dödsfall bland kvinnor/män detta år.
Cirkulationssjukdom (ICD-10 I00–I99+F01) var vanligare, med
34,77/34,18 procent av dödsfallen. Men dessa dödsfall har i allt
större utsträckning koncentrerats till de högsta åldersgrupperna, som
alltså inte kunnat studeras i PURE. Bland svenskarna som dog av
cirkulationssjukdom 2018 var 43,32 procent av kvinnorna och 21,91
procent av männen till och med över 90 år.
Forskaren Annika Rosengren, som lett den svenska delen av PURE,
intervjuas av @Larsson190903. Hon säger att cirkulationssjukdomar är
"mer likartade sjukdomar", att de till "åtminstone två tredjedelar"
kan "förklaras av riskfaktorer", som vi vet hur de skall åtgärdas,
till skillnad från cancer, där riskfaktorer inte kunnat identifieras på
samma sätt. Ett sådant resonemang finns också i den publicerade
artikeln. En systerartikel från PURE, som också publicerats nyligen,
handlar om samband mellan olika riskfaktorer, cirkulationssjukdom och
total dödlighet inom de olika befolkningarna [@Yusuf2019]. Artikeln
täcker in både metabola faktorer (som högt blodtryck, höga nivåer
av icke HDL-kolesterol och hög midjevidd/höftvidd), beteendemässiga faktorer
(som rökning och kost) och även faktorer som låg utbildning
och luftföroreningar. Den andel (PAF) av cirkulationssjukdom
(definierat som död i cirkulationssjukdom, eller insjuknande i
hjärtinfarkt, slaganfall eller hjärtsvikt) som kunde tillskrivas dessa
riskfaktorer i kombination var 71 procent.
En intressant sak är dock att variation i dessa riskfaktorer inte
kunde förklara variationen i sjuklighet och dödlighet i
cirkulationssjukdom mellan de olika grupperna av befolkningar.
Befolkningarna i höginkomstländerna hade, jämfört med
låginkomstländerna, högre genomsnittligt blodtryck, BMI och
kolesterol, även om det var färre som rökte (men fler som rökt
tidigare), och nästa inga som hade luftföroreningar inomhus. I mitt
inlägg här [den 18 juni](2019-06-18-tvar.html) gjorde jag en liknande
observation: att de riskfaktorer som ingår i GBD 2017 inte verkar
förklara mycket av variationen i dödstal i kranskärlssjukdom i
medelåldern på befolkningsnivå. En faktor som PURE-artiklarna lyfter
fram som förklaring till att höginkomstländerna har lägre dödstal,
trots mer ogynnsamma nivåer av flera riskfaktorer, är bättre tillgång
till modern sjukvård. Men även incidensen i cirkulationssjukdom var
som sagt lägre i höginkomstländerna. Andra faktorer, som belastning av
infektioner (där låg- och medelinkomstländerna också hade mycket högre
dödstal) kan också spela in, på samma sätt som de kan vara en viktig
faktor för nedgången av cirkulationssjukdom över tid inom befolkningar,
som jag skrev om senast [den 28 juli](2019-07-28-renare.html).
Det finns också en spänning mellan synen på cirkulationssjukdomarna som
en homogen grupp och det Rosengren själv sade i en annan SR-intervju i
somras, som jag skrev om [den 18 juli](2019-07-18-tungt.html). Hon
påtalade att hjärtvården i Sverige måste anpassas till ett förändrat
sjukdomsmönster med mindre hjärtinfarkter och mer av kardiomyopati
och hjärtsvikt. [Den 12 augusti](2019-08-12-nedgang.html) visade jag
också på en sådan utveckling i Sverige. En följd av detta blir att
faktorer som i hög grad är specifika för hjärtinfarkt (som icke
HDL-kolesterol i PURE) får mindre betydelse för cirkulationsgruppen som
helhet.
@Dagenais2019 hävdar också att vi kan vänta oss en framtida minskning
av cirkulationssjukdom i låg- och medelinkomstländer, att cancer då
kommer att få ökad relativ betydelse som dödsorsak (åtminstone i
medelåldern), och att detta i viss mån hänt i medelinkomstländer. Ett
land som inte ingår i PURE, men som kan exemplifiera en sådan
utveckling i takt med ökat välstånd på senare tid, är Estland. Nyligen
läste jag @Rausing2014, där författaren skildrar hur hon vistats i en
estnisk kolchos 1993–1994, som del av antropologiskt fältarbete. Just
under denna period var landet som mest fattigt och rörigt, efter
frigörelsen från Sovjetunionen, vilket skildras målande. Sedan har
landet genomgått en snabb utveckling och räknas numera som ett
höginkomstland av Världsbanken. Det speglas också i en sådan
transition som beskrivs i PURE-studierna. Enligt uppskattningar
tillgängliga via @gbdresults stod 1994 cirkulationssjukdom för
50,02/47,83 procent av dödsfallen bland kvinnor/män i Estland i
åldersgruppen 50–69 år och tumörer för 28,2/24,15 procent. Men 2017
hade andelen för cirkulation minskat till 31,46/38,69 procent, och för
tumörer ökat till 42,79/31,5 procent. Alltså hade rankningen blivit
omvänd bland kvinnorna, på samma sätt som i Sverige för ungefär ett
halvsekel sedan. Sett till alla åldersgrupper var minskningen av
cirkulationssjukdom inte så stor: från 63,28/46,64 procent 1994
till 56,03/44,37 procent 2017.
## Referenser
|
klpn/static-dust
|
posts/2019-09-08-fattig.md
|
Markdown
|
bsd-3-clause
| 8,272
|
#!/bin/bash
set -e
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
npm run clean
npm run build
npm test
|
jupyter/jupyter-js-phosphide
|
scripts/travis_script.sh
|
Shell
|
bsd-3-clause
| 107
|
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#pragma once
#include <kernel_headers/gradient.hpp>
#include <program.hpp>
#include <traits.hpp>
#include <string>
#include <mutex>
#include <map>
#include <dispatch.hpp>
#include <Param.hpp>
#include <debug_opencl.hpp>
#include <type_util.hpp>
#include <math.hpp>
#include "config.hpp"
using cl::Buffer;
using cl::Program;
using cl::Kernel;
using cl::KernelFunctor;
using cl::EnqueueArgs;
using cl::NDRange;
using std::string;
namespace opencl
{
namespace kernel
{
// Kernel Launch Config Values
static const int TX = 32;
static const int TY = 8;
template<typename T>
void gradient(Param grad0, Param grad1, const Param in)
{
static std::once_flag compileFlags[DeviceManager::MAX_DEVICES];
static std::map<int, Program*> gradProgs;
static std::map<int, Kernel*> gradKernels;
int device = getActiveDeviceId();
std::call_once( compileFlags[device], [device] () {
ToNumStr<T> toNumStr;
std::ostringstream options;
options << " -D T=" << dtype_traits<T>::getName()
<< " -D TX=" << TX
<< " -D TY=" << TY
<< " -D ZERO=" << toNumStr(scalar<T>(0));
if((af_dtype) dtype_traits<T>::af_type == c32 ||
(af_dtype) dtype_traits<T>::af_type == c64) {
options << " -D CPLX=1";
} else {
options << " -D CPLX=0";
}
if (std::is_same<T, double>::value ||
std::is_same<T, cdouble>::value) {
options << " -D USE_DOUBLE";
}
Program prog;
buildProgram(prog, gradient_cl, gradient_cl_len, options.str());
gradProgs[device] = new Program(prog);
gradKernels[device] = new Kernel(*gradProgs[device], "gradient_kernel");
});
auto gradOp = KernelFunctor<Buffer, const KParam, Buffer, const KParam,
const Buffer, const KParam, const int, const int>
(*gradKernels[device]);
NDRange local(TX, TY, 1);
int blocksPerMatX = divup(in.info.dims[0], TX);
int blocksPerMatY = divup(in.info.dims[1], TY);
NDRange global(local[0] * blocksPerMatX * in.info.dims[2],
local[1] * blocksPerMatY * in.info.dims[3],
1);
gradOp(EnqueueArgs(getQueue(), global, local),
*grad0.data, grad0.info, *grad1.data, grad1.info,
*in.data, in.info, blocksPerMatX, blocksPerMatY);
CL_DEBUG_FINISH(getQueue());
}
}
}
|
shehzan10/arrayfire
|
src/backend/opencl/kernel/gradient.hpp
|
C++
|
bsd-3-clause
| 3,153
|
<!--===- documentation/ParserCombinators.md
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
See https://llvm.org/LICENSE.txt for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-->
## Concept
The Fortran language recognizer here can be classified as an LL recursive
descent parser. It is composed from a *parser combinator* library that
defines a few fundamental parsers and a few ways to compose them into more
powerful parsers.
For our purposes here, a *parser* is any object that attempts to recognize
an instance of some syntax from an input stream. It may succeed or fail.
On success, it may return some semantic value to its caller.
In C++ terms, a parser is any instance of a class that
1. has a `constexpr` default constructor,
1. defines a type named `resultType`, and
1. provides a function (`const` member or `static`) that accepts a reference to a
`ParseState` as its argument and returns a `std::optional<resultType>` as a
result, with the presence or absence of a value in the `std::optional<>`
signifying success or failure, respectively.
```
std::optional<resultType> Parse(ParseState &) const;
```
The `resultType` of a parser is typically the class type of some particular
node type in the parse tree.
`ParseState` is a class that encapsulates a position in the source stream,
collects messages, and holds a few state flags that determine tokenization
(e.g., are we in a character literal?). Instances of `ParseState` are
independent and complete -- they are cheap to duplicate whenever necessary to
implement backtracking.
The `constexpr` default constructor of a parser is important. The functions
(below) that operate on instances of parsers are themselves all `constexpr`.
This use of compile-time expressions allows the entirety of a recursive
descent parser for a language to be constructed at compilation time through
the use of templates.
### Fundamental Predefined Parsers
These objects and functions are (or return) the fundamental parsers:
* `ok` is a trivial parser that always succeeds without advancing.
* `pure(x)` returns a trivial parser that always succeeds without advancing,
returning some value `x`.
* `fail<T>(msg)` denotes a trivial parser that always fails, emitting the
given message as a side effect. The template parameter is the type of
the value that the parser never returns.
* `cut` is a trivial parser that always fails silently.
* `nextCh` consumes the next character and returns its location,
and fails at EOF.
* `"xyz"_ch` succeeds if the next character consumed matches any of those
in the string and returns its location. Be advised that the source
will have been normalized to lower case (miniscule) letters outside
character and Hollerith literals and edit descriptors before parsing.
### Combinators
These functions and operators combine existing parsers to generate new parsers.
They are `constexpr`, so they should be viewed as type-safe macros.
* `!p` succeeds if p fails, and fails if p succeeds.
* `p >> q` fails if p does, otherwise running q and returning its value when
it succeeds.
* `p / q` fails if p does, otherwise running q and returning p's value
if q succeeds.
* `p || q` succeeds if p does, otherwise running q. The two parsers must
have the same type, and the value returned by the first succeeding parser
is the value of the combination.
* `first(p1, p2, ...)` returns the value of the first parser that succeeds.
All of the parsers in the list must return the same type.
It is essentially the same as `p1 || p2 || ...` but has a slightly
faster implementation and may be easier to format in your code.
* `lookAhead(p)` succeeds if p does, but doesn't modify any state.
* `attempt(p)` succeeds if p does, safely preserving state on failure.
* `many(p)` recognizes a greedy sequence of zero or more nonempty successes
of p, and returns `std::list<>` of their values. It always succeeds.
* `some(p)` recognized a greedy sequence of one or more successes of p.
It fails if p immediately fails.
* `skipMany(p)` is the same as `many(p)`, but it discards the results.
* `maybe(p)` tries to match p, returning an `std::optional<T>` value.
It always succeeds.
* `defaulted(p)` matches p, and when p fails it returns a
default-constructed instance of p's resultType. It always succeeds.
* `nonemptySeparated(p, q)` repeatedly matches "p q p q p q ... p",
returning a `std::list<>` of only the values of the p's. It fails if
p immediately fails.
* `extension(p)` parses p if strict standard compliance is disabled,
or with a warning if nonstandard usage warnings are enabled.
* `deprecated(p)` parses p if strict standard compliance is disabled,
with a warning if deprecated usage warnings are enabled.
* `inContext(msg, p)` runs p within an error message context; any
message that `p` generates will be tagged with `msg` as its
context. Contexts may nest.
* `withMessage(msg, p)` succeeds if `p` does, and if it does not,
it discards the messages from `p` and fails with the specified message.
* `recovery(p, q)` is equivalent to `p || q`, except that error messages
generated from the first parser are retained, and a flag is set in
the ParseState to remember that error recovery was necessary.
* `localRecovery(msg, p, q)` is equivalent to `recovery(withMessage(msg, p), defaulted(cut >> p) >> q)`. It is useful for targeted error recovery situations
within statements.
Note that
```
a >> b >> c / d / e
```
matches a sequence of five parsers, but returns only the result that was
obtained by matching `c`.
### Applicatives
The following *applicative* combinators combine parsers and modify or
collect the values that they return.
* `construct<T>(p1, p2, ...)` matches zero or more parsers in succession,
collecting their results and then passing them with move semantics to a
constructor for the type T if they all succeed.
If there is a single parser as the argument and it returns no usable
value but only success or failure (_e.g.,_ `"IF"_tok`), the default
nullary constructor of the type `T` is called.
* `sourced(p)` matches p, and fills in its `source` data member with the
locations of the cooked character stream that it consumed
* `applyFunction(f, p1, p2, ...)` matches one or more parsers in succession,
collecting their results and passing them as rvalue reference arguments to
some function, returning its result.
* `applyLambda([](&&x){}, p1, p2, ...)` is the same thing, but for lambdas
and other function objects.
* `applyMem(mf, p1, p2, ...)` is the same thing, but invokes a member
function of the result of the first parser for updates in place.
### Token Parsers
Last, we have these basic parsers on which the actual grammar of the Fortran
is built. All of the following parsers consume characters acquired from
`nextCh`.
* `space` always succeeds after consuming any spaces
* `spaceCheck` always succeeds after consuming any spaces, and can emit
a warning if there was no space in free form code before a character
that could continue a name or keyword
* `digit` matches one cooked decimal digit (0-9)
* `letter` matches one cooked letter (A-Z)
* `"..."_tok` match the content of the string, skipping spaces before and
after. Internal spaces are optional matches. The `_tok` suffix is
optional when the parser appears before the combinator `>>` or after
the combinator `/`.
* `"..."_sptok` is a string match in which the spaces are required in
free form source.
* `"..."_id` is a string match for a complete identifier (not a prefix of
a longer identifier or keyword).
* `parenthesized(p)` is shorthand for `"(" >> p / ")"`.
* `bracketed(p)` is shorthand for `"[" >> p / "]"`.
* `nonEmptyList(p)` matches a comma-separated list of one or more
instances of p.
* `nonEmptyList(errorMessage, p)` is equivalent to
`withMessage(errorMessage, nonemptyList(p))`, which allows one to supply
a meaningful error message in the event of an empty list.
* `optionalList(p)` is the same thing, but can be empty, and always succeeds.
### Debugging Parser
Last, a string literal `"..."_debug` denotes a parser that emits the string to
`llvm::errs` and succeeds. It is useful for tracing while debugging a parser but should
obviously not be committed for production code.
|
endlessm/chromium-browser
|
third_party/llvm/flang/documentation/ParserCombinators.md
|
Markdown
|
bsd-3-clause
| 8,353
|
/* BFD back-end for OpenRISC 1000 COFF binaries.
Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Ivan Guzvinec <ivang@opencores.org>
This file is part of BFD, the Binary File Descriptor library.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define OR32 1
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/or32.h"
#include "coff/internal.h"
#include "libcoff.h"
static long get_symbol_value
PARAMS ((asymbol *));
static bfd_reloc_status_type or32_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_boolean coff_or32_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
struct internal_reloc *, struct internal_syment *, asection **));
static bfd_boolean coff_or32_adjust_symndx
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
struct internal_reloc *, bfd_boolean *));
static void reloc_processing
PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
#define INSERT_HWORD(WORD,HWORD) \
(((WORD) & 0xffff0000) | ((HWORD)& 0x0000ffff))
#define EXTRACT_HWORD(WORD) \
((WORD) & 0x0000ffff)
#define SIGN_EXTEND_HWORD(HWORD) \
((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD))
#define INSERT_JUMPTARG(WORD,JT) \
(((WORD) & 0xfc000000) | ((JT)& 0x03ffffff))
#define EXTRACT_JUMPTARG(WORD) \
((WORD) & 0x03ffffff)
#define SIGN_EXTEND_JUMPTARG(JT) \
((JT) & 0x04000000 ? (JT)|(~0x03ffffffL) : (JT))
/* Provided the symbol, returns the value reffed. */
static long
get_symbol_value (symbol)
asymbol *symbol;
{
long relocation = 0;
if (bfd_is_com_section (symbol->section))
relocation = 0;
else
relocation = symbol->value +
symbol->section->output_section->vma +
symbol->section->output_offset;
return relocation;
}
/* This function is in charge of performing all the or32 relocations. */
static bfd_reloc_status_type
or32_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
error_message)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol_in;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message;
{
/* The consth relocation comes in two parts, we have to remember
the state between calls, in these variables. */
static bfd_boolean part1_consth_active = FALSE;
static unsigned long part1_consth_value;
unsigned long insn;
unsigned long sym_value;
unsigned long unsigned_value;
unsigned short r_type;
long signed_value;
unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
bfd_byte *hit_data =addr + (bfd_byte *)(data);
r_type = reloc_entry->howto->type;
if (output_bfd)
{
/* Partial linking - do nothing. */
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (symbol_in != NULL
&& bfd_is_und_section (symbol_in->section))
{
/* Keep the state machine happy in case we're called again. */
if (r_type == R_IHIHALF)
{
part1_consth_active = TRUE;
part1_consth_value = 0;
}
return bfd_reloc_undefined;
}
if ((part1_consth_active) && (r_type != R_IHCONST))
{
part1_consth_active = FALSE;
*error_message = (char *) "Missing IHCONST";
return bfd_reloc_dangerous;
}
sym_value = get_symbol_value (symbol_in);
switch (r_type)
{
case R_IREL:
insn = bfd_get_32(abfd, hit_data);
/* Take the value in the field and sign extend it. */
signed_value = EXTRACT_JUMPTARG (insn);
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
signed_value <<= 2;
/* See the note on the R_IREL reloc in coff_or32_relocate_section. */
if (signed_value == - (long) reloc_entry->address)
signed_value = 0;
signed_value += sym_value + reloc_entry->addend;
/* Relative jmp/call, so subtract from the value the
address of the place we're coming from. */
signed_value -= (reloc_entry->address
+ input_section->output_section->vma
+ input_section->output_offset);
if (signed_value > 0x7ffffff || signed_value < -0x8000000)
return bfd_reloc_overflow;
signed_value >>= 2;
insn = INSERT_JUMPTARG (insn, signed_value);
bfd_put_32 (abfd, insn, hit_data);
break;
case R_ILOHALF:
insn = bfd_get_32 (abfd, hit_data);
unsigned_value = EXTRACT_HWORD (insn);
unsigned_value += sym_value + reloc_entry->addend;
insn = INSERT_HWORD (insn, unsigned_value);
bfd_put_32 (abfd, insn, hit_data);
break;
case R_IHIHALF:
insn = bfd_get_32 (abfd, hit_data);
/* consth, part 1
Just get the symbol value that is referenced. */
part1_consth_active = TRUE;
part1_consth_value = sym_value + reloc_entry->addend;
/* Don't modify insn until R_IHCONST. */
break;
case R_IHCONST:
insn = bfd_get_32 (abfd, hit_data);
/* consth, part 2
Now relocate the reference. */
if (! part1_consth_active)
{
*error_message = (char *) "Missing IHIHALF";
return bfd_reloc_dangerous;
}
/* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */
unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/
unsigned_value += reloc_entry->addend; /* r_symndx */
unsigned_value += part1_consth_value;
unsigned_value = unsigned_value >> 16;
insn = INSERT_HWORD (insn, unsigned_value);
part1_consth_active = FALSE;
bfd_put_32 (abfd, insn, hit_data);
break;
case R_BYTE:
insn = bfd_get_8 (abfd, hit_data);
unsigned_value = insn + sym_value + reloc_entry->addend;
if (unsigned_value & 0xffffff00)
return bfd_reloc_overflow;
bfd_put_8 (abfd, unsigned_value, hit_data);
break;
case R_HWORD:
insn = bfd_get_16 (abfd, hit_data);
unsigned_value = insn + sym_value + reloc_entry->addend;
if (unsigned_value & 0xffff0000)
return bfd_reloc_overflow;
bfd_put_16 (abfd, insn, hit_data);
break;
case R_WORD:
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
bfd_put_32 (abfd, insn, hit_data);
break;
default:
*error_message = _("Unrecognized reloc");
return bfd_reloc_dangerous;
}
return bfd_reloc_ok;
}
/* type rightshift
size
bitsize
pc-relative
bitpos
absolute
complain_on_overflow
special_function
relocation name
partial_inplace
src_mask
*/
/* FIXME: I'm not real sure about this table. */
static reloc_howto_type howto_table[] =
{
{ R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "ABS", TRUE, 0xffffffff,0xffffffff, FALSE },
EMPTY_HOWTO (1),
EMPTY_HOWTO (2),
EMPTY_HOWTO (3),
EMPTY_HOWTO (4),
EMPTY_HOWTO (5),
EMPTY_HOWTO (6),
EMPTY_HOWTO (7),
EMPTY_HOWTO (8),
EMPTY_HOWTO (9),
EMPTY_HOWTO (10),
EMPTY_HOWTO (11),
EMPTY_HOWTO (12),
EMPTY_HOWTO (13),
EMPTY_HOWTO (14),
EMPTY_HOWTO (15),
EMPTY_HOWTO (16),
EMPTY_HOWTO (17),
EMPTY_HOWTO (18),
EMPTY_HOWTO (19),
EMPTY_HOWTO (20),
EMPTY_HOWTO (21),
EMPTY_HOWTO (22),
EMPTY_HOWTO (23),
{ R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed, or32_reloc, "IREL", TRUE, 0xffffffff,0xffffffff, FALSE },
{ R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "IABS", TRUE, 0xffffffff,0xffffffff, FALSE },
{ R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE },
{ R_IHIHALF, 0, 3, 16, TRUE, 16,complain_overflow_signed, or32_reloc, "IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE },
{ R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE },
{ R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, or32_reloc, "BYTE", TRUE, 0x000000ff,0x000000ff, FALSE },
{ R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, or32_reloc, "HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE },
{ R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "WORD", TRUE, 0xffffffff,0xffffffff, FALSE },
};
#define BADMAG(x) OR32BADMAG (x)
#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \
reloc_processing (relent, reloc, symbols, abfd, section)
static void
reloc_processing (relent,reloc, symbols, abfd, section)
arelent *relent;
struct internal_reloc *reloc;
asymbol **symbols;
bfd *abfd;
asection *section;
{
static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
relent->address = reloc->r_vaddr;
relent->howto = howto_table + reloc->r_type;
if (reloc->r_type == R_IHCONST)
{
/* The address of an R_IHCONST should always be the address of
the immediately preceding R_IHIHALF. relocs generated by gas
are correct, but relocs generated by High C are different (I
can't figure out what the address means for High C). We can
handle both gas and High C by ignoring the address here, and
simply reusing the address saved for R_IHIHALF. */
if (ihihalf_vaddr == (bfd_vma) -1)
abort ();
relent->address = ihihalf_vaddr;
ihihalf_vaddr = (bfd_vma) -1;
relent->addend = reloc->r_symndx;
relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr;
}
else
{
asymbol *ptr;
relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
ptr = *(relent->sym_ptr_ptr);
relent->addend = 0;
relent->address-= section->vma;
if (reloc->r_type == R_IHIHALF)
ihihalf_vaddr = relent->address;
else if (ihihalf_vaddr != (bfd_vma) -1)
abort ();
}
}
/* The reloc processing routine for the optimized COFF linker. */
static bfd_boolean
coff_or32_relocate_section (output_bfd, info, input_bfd, input_section,
contents, relocs, syms, sections)
bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
bfd *input_bfd;
asection *input_section;
bfd_byte *contents;
struct internal_reloc *relocs;
struct internal_syment *syms;
asection **sections;
{
struct internal_reloc *rel;
struct internal_reloc *relend;
bfd_boolean hihalf;
bfd_vma hihalf_val;
/* If we are performing a relocatable link, we don't need to do a
thing. The caller will take care of adjusting the reloc
addresses and symbol indices. */
if (info->relocatable)
return TRUE;
hihalf = FALSE;
hihalf_val = 0;
rel = relocs;
relend = rel + input_section->reloc_count;
for (; rel < relend; rel++)
{
long symndx;
bfd_byte *loc;
struct coff_link_hash_entry *h;
struct internal_syment *sym;
asection *sec;
bfd_vma val;
bfd_boolean overflow;
unsigned long insn;
long signed_value;
unsigned long unsigned_value;
bfd_reloc_status_type rstat;
symndx = rel->r_symndx;
loc = contents + rel->r_vaddr - input_section->vma;
if (symndx == -1 || rel->r_type == R_IHCONST)
h = NULL;
else
h = obj_coff_sym_hashes (input_bfd)[symndx];
sym = NULL;
sec = NULL;
val = 0;
/* An R_IHCONST reloc does not have a symbol. Instead, the
symbol index is an addend. R_IHCONST is always used in
conjunction with R_IHHALF. */
if (rel->r_type != R_IHCONST)
{
if (h == NULL)
{
if (symndx == -1)
sec = bfd_abs_section_ptr;
else
{
sym = syms + symndx;
sec = sections[symndx];
val = (sec->output_section->vma
+ sec->output_offset
+ sym->n_value
- sec->vma);
}
}
else
{
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
{
sec = h->root.u.def.section;
val = (h->root.u.def.value
+ sec->output_section->vma
+ sec->output_offset);
}
else
{
if (! ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd, input_section,
rel->r_vaddr - input_section->vma, TRUE)))
return FALSE;
}
}
if (hihalf)
{
if (! ((*info->callbacks->reloc_dangerous)
(info, "missing IHCONST reloc", input_bfd,
input_section, rel->r_vaddr - input_section->vma)))
return FALSE;
hihalf = FALSE;
}
}
overflow = FALSE;
switch (rel->r_type)
{
default:
bfd_set_error (bfd_error_bad_value);
return FALSE;
case R_IREL:
insn = bfd_get_32 (input_bfd, loc);
/* Extract the addend. */
signed_value = EXTRACT_JUMPTARG (insn);
signed_value = SIGN_EXTEND_JUMPTARG (signed_value);
signed_value <<= 2;
/* Determine the destination of the jump. */
signed_value += val;
/* Make the destination PC relative. */
signed_value -= (input_section->output_section->vma
+ input_section->output_offset
+ (rel->r_vaddr - input_section->vma));
if (signed_value > 0x7ffffff || signed_value < - 0x8000000)
{
overflow = TRUE;
signed_value = 0;
}
/* Put the adjusted value back into the instruction. */
signed_value >>= 2;
insn = INSERT_JUMPTARG(insn, signed_value);
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
break;
case R_ILOHALF:
insn = bfd_get_32 (input_bfd, loc);
unsigned_value = EXTRACT_HWORD (insn);
unsigned_value += val;
insn = INSERT_HWORD (insn, unsigned_value);
bfd_put_32 (input_bfd, insn, loc);
break;
case R_IHIHALF:
/* Save the value for the R_IHCONST reloc. */
hihalf = TRUE;
hihalf_val = val;
break;
case R_IHCONST:
if (! hihalf)
{
if (! ((*info->callbacks->reloc_dangerous)
(info, "missing IHIHALF reloc", input_bfd,
input_section, rel->r_vaddr - input_section->vma)))
return FALSE;
hihalf_val = 0;
}
insn = bfd_get_32 (input_bfd, loc);
unsigned_value = rel->r_symndx + hihalf_val;
unsigned_value >>= 16;
insn = INSERT_HWORD (insn, unsigned_value);
bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
hihalf = FALSE;
break;
case R_BYTE:
case R_HWORD:
case R_WORD:
rstat = _bfd_relocate_contents (howto_table + rel->r_type,
input_bfd, val, loc);
if (rstat == bfd_reloc_overflow)
overflow = TRUE;
else if (rstat != bfd_reloc_ok)
abort ();
break;
}
if (overflow)
{
const char *name;
char buf[SYMNMLEN + 1];
if (symndx == -1)
name = "*ABS*";
else if (h != NULL)
name = NULL;
else if (sym == NULL)
name = "*unknown*";
else if (sym->_n._n_n._n_zeroes == 0
&& sym->_n._n_n._n_offset != 0)
name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
else
{
strncpy (buf, sym->_n._n_name, SYMNMLEN);
buf[SYMNMLEN] = '\0';
name = buf;
}
if (! ((*info->callbacks->reloc_overflow)
(info, (h ? &h->root : NULL), name,
howto_table[rel->r_type].name, (bfd_vma) 0, input_bfd,
input_section, rel->r_vaddr - input_section->vma)))
return FALSE;
}
}
return TRUE;
}
#define coff_relocate_section coff_or32_relocate_section
/* We don't want to change the symndx of a R_IHCONST reloc, since it
is actually an addend, not a symbol index at all. */
static bfd_boolean
coff_or32_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
bfd *obfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
bfd *ibfd ATTRIBUTE_UNUSED;
asection *sec ATTRIBUTE_UNUSED;
struct internal_reloc *irel;
bfd_boolean *adjustedp;
{
if (irel->r_type == R_IHCONST)
*adjustedp = TRUE;
else
*adjustedp = FALSE;
return TRUE;
}
#define coff_adjust_symndx coff_or32_adjust_symndx
#include "coffcode.h"
const bfd_target or32coff_big_vec =
{
"coff-or32-big", /* Name. */
bfd_target_coff_flavour,
BFD_ENDIAN_BIG, /* Data byte order is big. */
BFD_ENDIAN_BIG, /* Header byte order is big. */
(HAS_RELOC | EXEC_P | /* Object flags. */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | WP_TEXT),
(SEC_HAS_CONTENTS | SEC_ALLOC | /* Section flags. */
SEC_LOAD | SEC_RELOC |
SEC_READONLY ),
'_', /* Leading underscore. */
'/', /* ar_pad_char. */
15, /* ar_max_namelen. */
/* Data. */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
/* Headers. */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
{
_bfd_dummy_target,
coff_object_p,
bfd_generic_archive_p,
_bfd_dummy_target
},
{
bfd_false,
coff_mkobject,
_bfd_generic_mkarchive,
bfd_false
},
{
bfd_false,
coff_write_object_contents,
_bfd_write_archive_contents,
bfd_false
},
BFD_JUMP_TABLE_GENERIC (coff),
BFD_JUMP_TABLE_COPY (coff),
BFD_JUMP_TABLE_CORE (_bfd_nocore),
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
BFD_JUMP_TABLE_SYMBOLS (coff),
BFD_JUMP_TABLE_RELOCS (coff),
BFD_JUMP_TABLE_WRITE (coff),
BFD_JUMP_TABLE_LINK (coff),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
/* Alternative_target. */
#ifdef TARGET_LITTLE_SYM
& TARGET_LITTLE_SYM,
#else
NULL,
#endif
COFF_SWAP_TABLE
};
|
shaotuanchen/sunflower_exp
|
tools/source/binutils-2.16.1/bfd/coff-or32.c
|
C
|
bsd-3-clause
| 19,490
|
/*
Copyright (c) 2011, Heath Borders
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Heath Borders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "HBCollection.h"
@interface NSSet(HBCollections)<HBCollection>
@end
|
hborders/HBCollections
|
Source/NSSet+HBCollections.h
|
C
|
bsd-3-clause
| 1,603
|
<?php
/**
* Created by PhpStorm.
* User: Marcos
* Date: 07/09/2015
* Time: 19:50
*/
namespace CodeOrders\V1\Rest\Users;
use Zend\Db\ResultSet\HydratingResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Stdlib\Hydrator\ClassMethods;
class UsersRepositoryFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$dbAdapter = $serviceLocator->get('DbAdapter');
$userMapper = new UsersMapper();
$hydrator = new HydratingResultSet($userMapper, new UsersEntity());
//$hydrator = new HydratingResultSet(new ClassMethods(), new UsersEntity());
$tableGateway = new TableGateway('oauth_users', $dbAdapter, null, $hydrator);
$usersRepository = new UsersRepository($tableGateway);
return $usersRepository;
}
}
|
marcoscg/CodeOrder
|
module/CodeOrders/src/CodeOrders/V1/Rest/Users/UsersRepositoryFactory.php
|
PHP
|
bsd-3-clause
| 934
|
/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <memory>
#include <utility>
#include "webrtc/modules/congestion_controller/probing_interval_estimator.h"
#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_aimd_rate_control.h"
#include "webrtc/test/gmock.h"
#include "webrtc/test/gtest.h"
using ::testing::Return;
namespace webrtc {
namespace {
constexpr int kMinIntervalMs = 2000;
constexpr int kMaxIntervalMs = 50000;
constexpr int kDefaultIntervalMs = 3000;
struct ProbingIntervalEstimatorStates {
std::unique_ptr<ProbingIntervalEstimator> probing_interval_estimator;
std::unique_ptr<MockAimdRateControl> aimd_rate_control;
};
ProbingIntervalEstimatorStates CreateProbingIntervalEstimatorStates() {
ProbingIntervalEstimatorStates states;
states.aimd_rate_control.reset(new MockAimdRateControl());
states.probing_interval_estimator.reset(new ProbingIntervalEstimator(
kMinIntervalMs, kMaxIntervalMs, kDefaultIntervalMs,
states.aimd_rate_control.get()));
return states;
}
} // namespace
TEST(ProbingIntervalEstimatorTest, DefaultIntervalUntillWeHaveDrop) {
auto states = CreateProbingIntervalEstimatorStates();
EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
.WillOnce(Return(rtc::Optional<int>()))
.WillOnce(Return(rtc::Optional<int>(5000)));
EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
.WillOnce(Return(4000))
.WillOnce(Return(4000));
EXPECT_EQ(kDefaultIntervalMs,
states.probing_interval_estimator->GetIntervalMs());
EXPECT_NE(kDefaultIntervalMs,
states.probing_interval_estimator->GetIntervalMs());
}
TEST(ProbingIntervalEstimatorTest, CalcInterval) {
auto states = CreateProbingIntervalEstimatorStates();
EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
.WillOnce(Return(rtc::Optional<int>(20000)));
EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
.WillOnce(Return(5000));
EXPECT_EQ(4000, states.probing_interval_estimator->GetIntervalMs());
}
TEST(ProbingIntervalEstimatorTest, IntervalDoesNotExceedMin) {
auto states = CreateProbingIntervalEstimatorStates();
EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
.WillOnce(Return(rtc::Optional<int>(1000)));
EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
.WillOnce(Return(5000));
EXPECT_EQ(kMinIntervalMs, states.probing_interval_estimator->GetIntervalMs());
}
TEST(ProbingIntervalEstimatorTest, IntervalDoesNotExceedMax) {
auto states = CreateProbingIntervalEstimatorStates();
EXPECT_CALL(*states.aimd_rate_control, GetLastBitrateDecreaseBps())
.WillOnce(Return(rtc::Optional<int>(50000)));
EXPECT_CALL(*states.aimd_rate_control, GetNearMaxIncreaseRateBps())
.WillOnce(Return(100));
EXPECT_EQ(kMaxIntervalMs, states.probing_interval_estimator->GetIntervalMs());
}
} // namespace webrtc
|
Alkalyne/webrtctrunk
|
modules/congestion_controller/probing_interval_estimator_unittest.cc
|
C++
|
bsd-3-clause
| 3,310
|
(function($) {
$.extend({
tablesorterPager: new function() {
function updatePageDisplay(c) {
var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);
}
function setPageSize(table,size) {
var c = table.config;
c.size = size;
c.totalPages = Math.ceil(c.totalRows / c.size);
c.pagerPositionSet = false;
moveToPage(table);
fixPosition(table);
}
function fixPosition(table) {
var c = table.config;
if(!c.pagerPositionSet && c.positionFixed) {
var c = table.config, o = $(table);
if(o.offset) {
c.container.css({
top: o.offset().top + o.height() + 'px',
position: 'absolute'
});
}
c.pagerPositionSet = true;
}
}
function moveToFirstPage(table) {
var c = table.config;
c.page = 0;
moveToPage(table);
}
function moveToLastPage(table) {
var c = table.config;
c.page = (c.totalPages-1);
moveToPage(table);
}
function moveToNextPage(table) {
var c = table.config;
if (c.page < (c.totalPages-1)) {
c.page += 1;
moveToPage(table);
}
}
function moveToPrevPage(table) {
var c = table.config;
if (c.page > 0) {
c.page -= 1;
moveToPage(table);
}
}
function moveToPage(table) {
var c = table.config;
if(c.page < 0 || c.page > (c.totalPages-1)) {
c.page = 0;
}
renderTable(table,c.rowsCopy);
renderPagination(table);
}
function renderTable(table,rows) {
var c = table.config;
var l = rows.length;
var s = (c.page * c.size);
var e = (s + c.size);
if(e > rows.length ) {
e = rows.length;
}
var tableBody = $(table.tBodies[0]);
// clear the table body
$.tablesorter.clearTableBody(table);
for(var i = s; i < e; i++) {
//tableBody.append(rows[i]);
var o = rows[i];
var l = o.length;
for(var j=0; j < l; j++) {
tableBody[0].appendChild(o[j]);
}
}
fixPosition(table,tableBody);
$(table).trigger("applyWidgets");
if( c.page >= c.totalPages ) {
moveToLastPage(table);
}
updatePageDisplay(c);
}
function renderPagination(table) {
/*
* Creates numbered pagination links
* and appends to config.cssPaginationDisplay
*/
var config = table.config;
var pager = config.container;
var paginationNode = $(pager).find(config.cssPaginationDisplay);
paginationNode.children('span.page').remove();
if (config.totalPages) {
for (var x=0; x < config.totalPages; x+=1) {
$('<span class="page">' + (x+1) + '</span>').appendTo(paginationNode);
}
}
var pages = paginationNode.children('span.page');
if (config.totalPages > 1) {
pages.bind('click', function() {
config.page = parseInt($(this).text()) - 1;
moveToPage(table);
});
}
$(pages[config.page]).addClass('active');
}
this.appender = function(table,rows) {
var c = table.config;
c.rowsCopy = rows;
c.totalRows = rows.length;
c.totalPages = Math.ceil(c.totalRows / c.size);
renderTable(table,rows);
};
this.defaults = {
size: 10,
offset: 0,
page: 0,
totalRows: 0,
totalPages: 0,
container: null,
cssNext: '.next',
cssPrev: '.prev',
cssFirst: '.first',
cssLast: '.last',
cssPaginationDisplay: '.pagination',
cssPageDisplay: '.pagedisplay',
cssPageSize: '.pagesize',
seperator: "/",
positionFixed: true,
appender: this.appender
};
this.construct = function(settings) {
return this.each(function() {
config = $.extend(this.config, $.tablesorterPager.defaults, settings);
var table = this, pager = config.container;
$(this).trigger("appendCache");
$(config.cssFirst,pager).click(function() {
moveToFirstPage(table);
return false;
});
$(config.cssNext,pager).click(function() {
moveToNextPage(table);
return false;
});
$(config.cssPrev,pager).click(function() {
moveToPrevPage(table);
return false;
});
$(config.cssLast,pager).click(function() {
moveToLastPage(table);
return false;
});
$(config.cssPageSize,pager).change(function() {
setPageSize(table,parseInt($(this).val()));
return false;
});
renderPagination(table);
});
};
}
});
// extend plugin scope
$.fn.extend({
tablesorterPager: $.tablesorterPager.construct
});
})(jQuery);
|
lincolnloop/django-mineral
|
mineral/static/mineral/js/plugins/jquery.tablesorter.pager.js
|
JavaScript
|
bsd-3-clause
| 4,953
|
201705231015
## Distributed Tracing: How We Got Here and Where We're Going
Ben Sigelman
Monitoring must tell stories
the story must say why things are happening
Open Tracing
|
kayiwa/monitorama17
|
day_two/201705231015sigelman/notes.md
|
Markdown
|
bsd-3-clause
| 179
|
/*
* Copyright (c) 2008, intarsys consulting GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of intarsys nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package de.intarsys.cwt.font.truetype;
import java.util.logging.Logger;
import de.intarsys.tools.logging.LogTools;
import de.intarsys.tools.message.MessageBundle;
import de.intarsys.tools.message.MessageBundleTools;
public class PACKAGE {
public final static MessageBundle Messages = MessageBundleTools
.getMessageBundle(PACKAGE.class);
public final static Logger Log = LogTools.getLogger(PACKAGE.class);
}
|
maximumspatium/iscwt
|
src/main/java/de/intarsys/cwt/font/truetype/PACKAGE.java
|
Java
|
bsd-3-clause
| 1,969
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/ppapi_command_buffer_proxy.h"
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/api_id.h"
#include "ppapi/shared_impl/host_resource.h"
#include "ppapi/shared_impl/proxy_lock.h"
namespace ppapi {
namespace proxy {
PpapiCommandBufferProxy::PpapiCommandBufferProxy(
const ppapi::HostResource& resource,
PluginDispatcher* dispatcher,
const gpu::Capabilities& capabilities,
const SerializedHandle& shared_state,
gpu::CommandBufferId command_buffer_id)
: command_buffer_id_(command_buffer_id),
capabilities_(capabilities),
resource_(resource),
dispatcher_(dispatcher),
next_fence_sync_release_(1),
pending_fence_sync_release_(0),
flushed_fence_sync_release_(0),
validated_fence_sync_release_(0) {
shared_state_shm_.reset(
new base::SharedMemory(shared_state.shmem(), false));
shared_state_shm_->Map(shared_state.size());
InstanceData* data = dispatcher->GetInstanceData(resource.instance());
flush_info_ = &data->flush_info_;
}
PpapiCommandBufferProxy::~PpapiCommandBufferProxy() {
// gpu::Buffers are no longer referenced, allowing shared memory objects to be
// deleted, closing the handle in this process.
}
bool PpapiCommandBufferProxy::Initialize() {
return true;
}
gpu::CommandBuffer::State PpapiCommandBufferProxy::GetLastState() {
ppapi::ProxyLock::AssertAcquiredDebugOnly();
return last_state_;
}
int32_t PpapiCommandBufferProxy::GetLastToken() {
ppapi::ProxyLock::AssertAcquiredDebugOnly();
TryUpdateState();
return last_state_.token;
}
void PpapiCommandBufferProxy::Flush(int32_t put_offset) {
if (last_state_.error != gpu::error::kNoError)
return;
OrderingBarrier(put_offset);
FlushInternal();
}
void PpapiCommandBufferProxy::OrderingBarrier(int32_t put_offset) {
if (last_state_.error != gpu::error::kNoError)
return;
if (flush_info_->flush_pending && flush_info_->resource != resource_) {
FlushInternal();
}
flush_info_->flush_pending = true;
flush_info_->resource = resource_;
flush_info_->put_offset = put_offset;
pending_fence_sync_release_ = next_fence_sync_release_ - 1;
}
void PpapiCommandBufferProxy::WaitForTokenInRange(int32_t start, int32_t end) {
TryUpdateState();
if (!InRange(start, end, last_state_.token) &&
last_state_.error == gpu::error::kNoError) {
bool success = false;
gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange(
ppapi::API_ID_PPB_GRAPHICS_3D,
resource_,
start,
end,
&state,
&success)))
UpdateState(state, success);
}
DCHECK(InRange(start, end, last_state_.token) ||
last_state_.error != gpu::error::kNoError);
}
void PpapiCommandBufferProxy::WaitForGetOffsetInRange(int32_t start,
int32_t end) {
TryUpdateState();
if (!InRange(start, end, last_state_.get_offset) &&
last_state_.error == gpu::error::kNoError) {
bool success = false;
gpu::CommandBuffer::State state;
if (Send(new PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange(
ppapi::API_ID_PPB_GRAPHICS_3D,
resource_,
start,
end,
&state,
&success)))
UpdateState(state, success);
}
DCHECK(InRange(start, end, last_state_.get_offset) ||
last_state_.error != gpu::error::kNoError);
}
void PpapiCommandBufferProxy::SetGetBuffer(int32_t transfer_buffer_id) {
if (last_state_.error == gpu::error::kNoError) {
Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer(
ppapi::API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id));
}
}
scoped_refptr<gpu::Buffer> PpapiCommandBufferProxy::CreateTransferBuffer(
size_t size,
int32_t* id) {
*id = -1;
if (last_state_.error != gpu::error::kNoError)
return NULL;
// Assuming we are in the renderer process, the service is responsible for
// duplicating the handle. This might not be true for NaCl.
ppapi::proxy::SerializedHandle handle(
ppapi::proxy::SerializedHandle::SHARED_MEMORY);
if (!Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer(
ppapi::API_ID_PPB_GRAPHICS_3D, resource_,
base::checked_cast<uint32_t>(size), id, &handle))) {
if (last_state_.error == gpu::error::kNoError)
last_state_.error = gpu::error::kLostContext;
return NULL;
}
if (*id <= 0 || !handle.is_shmem()) {
if (last_state_.error == gpu::error::kNoError)
last_state_.error = gpu::error::kOutOfBounds;
return NULL;
}
std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(handle.shmem(), false));
// Map the shared memory on demand.
if (!shared_memory->memory()) {
if (!shared_memory->Map(handle.size())) {
if (last_state_.error == gpu::error::kNoError)
last_state_.error = gpu::error::kOutOfBounds;
*id = -1;
return NULL;
}
}
return gpu::MakeBufferFromSharedMemory(std::move(shared_memory),
handle.size());
}
void PpapiCommandBufferProxy::DestroyTransferBuffer(int32_t id) {
if (last_state_.error != gpu::error::kNoError)
return;
Send(new PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer(
ppapi::API_ID_PPB_GRAPHICS_3D, resource_, id));
}
void PpapiCommandBufferProxy::SetLock(base::Lock*) {
NOTIMPLEMENTED();
}
bool PpapiCommandBufferProxy::IsGpuChannelLost() {
NOTIMPLEMENTED();
return false;
}
void PpapiCommandBufferProxy::EnsureWorkVisible() {
DCHECK_GE(flushed_fence_sync_release_, validated_fence_sync_release_);
Send(new PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible(
ppapi::API_ID_PPB_GRAPHICS_3D, resource_));
validated_fence_sync_release_ = flushed_fence_sync_release_;
}
gpu::CommandBufferNamespace PpapiCommandBufferProxy::GetNamespaceID() const {
return gpu::CommandBufferNamespace::GPU_IO;
}
gpu::CommandBufferId PpapiCommandBufferProxy::GetCommandBufferID() const {
return command_buffer_id_;
}
uint64_t PpapiCommandBufferProxy::GenerateFenceSyncRelease() {
return next_fence_sync_release_++;
}
bool PpapiCommandBufferProxy::IsFenceSyncRelease(uint64_t release) {
return release != 0 && release < next_fence_sync_release_;
}
bool PpapiCommandBufferProxy::IsFenceSyncFlushed(uint64_t release) {
return release <= flushed_fence_sync_release_;
}
bool PpapiCommandBufferProxy::IsFenceSyncFlushReceived(uint64_t release) {
if (!IsFenceSyncFlushed(release))
return false;
if (release <= validated_fence_sync_release_)
return true;
EnsureWorkVisible();
return release <= validated_fence_sync_release_;
}
void PpapiCommandBufferProxy::SignalSyncToken(const gpu::SyncToken& sync_token,
const base::Closure& callback) {
NOTIMPLEMENTED();
}
bool PpapiCommandBufferProxy::CanWaitUnverifiedSyncToken(
const gpu::SyncToken* sync_token) {
return false;
}
int32_t PpapiCommandBufferProxy::GetExtraCommandBufferData() const {
return 0;
}
void PpapiCommandBufferProxy::SignalQuery(uint32_t query,
const base::Closure& callback) {
NOTREACHED();
}
gpu::Capabilities PpapiCommandBufferProxy::GetCapabilities() {
return capabilities_;
}
int32_t PpapiCommandBufferProxy::CreateImage(ClientBuffer buffer,
size_t width,
size_t height,
unsigned internalformat) {
NOTREACHED();
return -1;
}
void PpapiCommandBufferProxy::DestroyImage(int32_t id) {
NOTREACHED();
}
int32_t PpapiCommandBufferProxy::CreateGpuMemoryBufferImage(
size_t width,
size_t height,
unsigned internalformat,
unsigned usage) {
NOTREACHED();
return -1;
}
bool PpapiCommandBufferProxy::Send(IPC::Message* msg) {
DCHECK(last_state_.error == gpu::error::kNoError);
// We need to hold the Pepper proxy lock for sync IPC, because the GPU command
// buffer may use a sync IPC with another lock held which could lead to lock
// and deadlock if we dropped the proxy lock here.
// http://crbug.com/418651
if (dispatcher_->SendAndStayLocked(msg))
return true;
last_state_.error = gpu::error::kLostContext;
return false;
}
void PpapiCommandBufferProxy::UpdateState(
const gpu::CommandBuffer::State& state,
bool success) {
// Handle wraparound. It works as long as we don't have more than 2B state
// updates in flight across which reordering occurs.
if (success) {
if (state.generation - last_state_.generation < 0x80000000U) {
last_state_ = state;
}
} else {
last_state_.error = gpu::error::kLostContext;
++last_state_.generation;
}
}
void PpapiCommandBufferProxy::TryUpdateState() {
if (last_state_.error == gpu::error::kNoError)
shared_state()->Read(&last_state_);
}
gpu::CommandBufferSharedState* PpapiCommandBufferProxy::shared_state() const {
return reinterpret_cast<gpu::CommandBufferSharedState*>(
shared_state_shm_->memory());
}
void PpapiCommandBufferProxy::FlushInternal() {
DCHECK(last_state_.error == gpu::error::kNoError);
DCHECK(flush_info_->flush_pending);
DCHECK_GE(pending_fence_sync_release_, flushed_fence_sync_release_);
IPC::Message* message = new PpapiHostMsg_PPBGraphics3D_AsyncFlush(
ppapi::API_ID_PPB_GRAPHICS_3D, flush_info_->resource,
flush_info_->put_offset);
// Do not let a synchronous flush hold up this message. If this handler is
// deferred until after the synchronous flush completes, it will overwrite the
// cached last_state_ with out-of-date data.
message->set_unblock(true);
Send(message);
flush_info_->flush_pending = false;
flush_info_->resource.SetHostResource(0, 0);
flushed_fence_sync_release_ = pending_fence_sync_release_;
}
} // namespace proxy
} // namespace ppapi
|
was4444/chromium.src
|
ppapi/proxy/ppapi_command_buffer_proxy.cc
|
C++
|
bsd-3-clause
| 10,204
|
from django.http import HttpResponse
from django.template import Template
def admin_required_view(request):
if request.user.is_staff:
return HttpResponse(Template('You are an admin').render({}))
return HttpResponse(Template('Access denied').render({}))
|
bfirsh/pytest_django
|
tests/views.py
|
Python
|
bsd-3-clause
| 270
|
/*
* Copyright (c) 2004-07 Applied Micro Circuits Corporation.
* Copyright (c) 2004-05 Vinod Kashyap.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: releng/9.3/sys/dev/twa/tw_osl_ioctl.h 169400 2007-05-09 04:16:32Z scottl $
*/
/*
* AMCC'S 3ware driver for 9000 series storage controllers.
*
* Author: Vinod Kashyap
* Modifications by: Adam Radford
*/
#ifndef TW_OSL_IOCTL_H
#define TW_OSL_IOCTL_H
/*
* Macros and structures for OS Layer/Common Layer handled ioctls.
*/
#include <dev/twa/tw_cl_fwif.h>
#include <dev/twa/tw_cl_ioctl.h>
#pragma pack(1)
/*
* We need the structure below to ensure that the first byte of
* data_buf is not overwritten by the kernel, after we return
* from the ioctl call. Note that cmd_pkt has been reduced
* to an array of 1024 bytes even though it's actually 2048 bytes
* in size. This is because, we don't expect requests from user
* land requiring 2048 (273 sg elements) byte cmd pkts.
*/
typedef struct tw_osli_ioctl_no_data_buf {
struct tw_cl_driver_packet driver_pkt;
TW_VOID *pdata; /* points to data_buf */
TW_INT8 padding[488 - sizeof(TW_VOID *)];
struct tw_cl_command_packet cmd_pkt;
} TW_OSLI_IOCTL_NO_DATA_BUF;
#pragma pack()
/* ioctl cmds handled by the OS Layer */
#define TW_OSL_IOCTL_SCAN_BUS \
_IO('T', 200)
#define TW_OSL_IOCTL_FIRMWARE_PASS_THROUGH \
_IOWR('T', 202, TW_OSLI_IOCTL_NO_DATA_BUF)
#include <sys/ioccom.h>
#pragma pack(1)
typedef struct tw_osli_ioctl_with_payload {
struct tw_cl_driver_packet driver_pkt;
TW_INT8 padding[488];
struct tw_cl_command_packet cmd_pkt;
union {
struct tw_cl_event_packet event_pkt;
struct tw_cl_lock_packet lock_pkt;
struct tw_cl_compatibility_packet compat_pkt;
TW_INT8 data_buf[1];
} payload;
} TW_OSLI_IOCTL_WITH_PAYLOAD;
#pragma pack()
/* ioctl cmds handled by the Common Layer */
#define TW_CL_IOCTL_GET_FIRST_EVENT \
_IOWR('T', 203, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_GET_LAST_EVENT \
_IOWR('T', 204, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_GET_NEXT_EVENT \
_IOWR('T', 205, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_GET_PREVIOUS_EVENT \
_IOWR('T', 206, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_GET_LOCK \
_IOWR('T', 207, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_RELEASE_LOCK \
_IOWR('T', 208, TW_OSLI_IOCTL_WITH_PAYLOAD)
#define TW_CL_IOCTL_GET_COMPATIBILITY_INFO \
_IOWR('T', 209, TW_OSLI_IOCTL_WITH_PAYLOAD)
#endif /* TW_OSL_IOCTL_H */
|
dcui/FreeBSD-9.3_kernel
|
sys/dev/twa/tw_osl_ioctl.h
|
C
|
bsd-3-clause
| 3,754
|
/***************************************************************************
*
* Copyright (c) 2014 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file loiter.h
*
* Helper class to loiter
*
* @author Julian Oes <julian@oes.ch>
*/
#ifndef NAVIGATOR_LOITER_H
#define NAVIGATOR_LOITER_H
#include "navigator_mode.h"
#include "mission_block.h"
class Loiter final : public MissionBlock
{
public:
Loiter(Navigator *navigator, const char *name);
~Loiter() = default;
void on_inactive() override;
void on_activation() override;
void on_active() override;
// TODO: share this with mission
enum mission_yaw_mode {
MISSION_YAWMODE_NONE = 0,
MISSION_YAWMODE_FRONT_TO_WAYPOINT = 1,
MISSION_YAWMODE_FRONT_TO_HOME = 2,
MISSION_YAWMODE_BACK_TO_HOME = 3,
MISSION_YAWMODE_MAX = 4
};
private:
/**
* Use the stored reposition location of the navigator
* to move to a new location.
*/
void reposition();
/**
* Set the position to hold based on the current local position
*/
void set_loiter_position();
control::BlockParamInt _param_yawmode;
bool _loiter_pos_set{false};
};
#endif
|
jlecoeur/Firmware
|
src/modules/navigator/loiter.h
|
C
|
bsd-3-clause
| 2,699
|
using System;
using NServiceKit.DataAnnotations;
using NServiceKit.OrmLite.Firebird.DbSchema;
namespace NServiceKit.OrmLite.Firebird
{
/// <summary>A procedure.</summary>
public class Procedure : IProcedure
{
/// <summary>
/// Initializes a new instance of the NServiceKit.OrmLite.Firebird.Procedure class.
/// </summary>
public Procedure()
{
}
/// <summary>Gets or sets the name.</summary>
/// <value>The name.</value>
[Alias("NAME")]
public string Name { get; set; }
/// <summary>Gets or sets the owner.</summary>
/// <value>The owner.</value>
[Alias("OWNER")]
public string Owner { get; set; }
/// <summary>Gets or sets the inputs.</summary>
/// <value>The inputs.</value>
[Alias("INPUTS")]
public Int16 Inputs { get; set; }
/// <summary>Gets or sets the outputs.</summary>
/// <value>The outputs.</value>
[Alias("OUTPUTS")]
public Int16 Outputs { get; set; }
/// <summary>Gets the type.</summary>
/// <value>The type.</value>
[Ignore]
public ProcedureType Type
{
get
{
return Outputs == 0 ? ProcedureType.Executable : ProcedureType.Selectable;
}
}
}
}
|
NServiceKit/NServiceKit.OrmLite
|
src/NServiceKit.OrmLite.Firebird/FbSchema/Procedure.cs
|
C#
|
bsd-3-clause
| 1,217
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE78_OS_Command_Injection__wchar_t_file_system_11.c
Label Definition File: CWE78_OS_Command_Injection.one_string.label.xml
Template File: sources-sink-11.tmpl.c
*/
/*
* @description
* CWE: 78 OS Command Injection
* BadSource: file Read input from a file
* GoodSource: Fixed string
* Sink: system
* BadSink : Execute command in data using system()
* Flow Variant: 11 Control flow: if(globalReturnsTrue()) and if(globalReturnsFalse())
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define FULL_COMMAND L"dir "
#else
#include <unistd.h>
#define FULL_COMMAND L"ls "
#endif
#ifdef _WIN32
#define FILENAME "C:\\temp\\file.txt"
#else
#define FILENAME "/tmp/file.txt"
#endif
#ifdef _WIN32
#define SYSTEM _wsystem
#else /* NOT _WIN32 */
#define SYSTEM system
#endif
#ifndef OMITBAD
void CWE78_OS_Command_Injection__wchar_t_file_system_11_bad()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
if(globalReturnsTrue())
{
{
/* Read input from a file */
size_t dataLen = wcslen(data);
FILE * pFile;
/* if there is room in data, attempt to read the input from a file */
if (100-dataLen > 1)
{
pFile = fopen(FILENAME, "r");
if (pFile != NULL)
{
/* POTENTIAL FLAW: Read data from a file */
if (fgetws(data+dataLen, (int)(100-dataLen), pFile) == NULL)
{
printLine("fgetws() failed");
/* Restore NUL terminator if fgetws fails */
data[dataLen] = L'\0';
}
fclose(pFile);
}
}
}
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) != 0)
{
printLine("command execution failed!");
exit(1);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the globalReturnsTrue() to globalReturnsFalse() */
static void goodG2B1()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
if(globalReturnsFalse())
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) != 0)
{
printLine("command execution failed!");
exit(1);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
wchar_t * data;
wchar_t data_buf[100] = FULL_COMMAND;
data = data_buf;
if(globalReturnsTrue())
{
/* FIX: Append a fixed string to data (not user / external input) */
wcscat(data, L"*.*");
}
/* POTENTIAL FLAW: Execute command in data possibly leading to command injection */
if (SYSTEM(data) != 0)
{
printLine("command execution failed!");
exit(1);
}
}
void CWE78_OS_Command_Injection__wchar_t_file_system_11_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE78_OS_Command_Injection__wchar_t_file_system_11_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE78_OS_Command_Injection__wchar_t_file_system_11_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
JianpingZeng/xcc
|
xcc/test/juliet/testcases/CWE78_OS_Command_Injection/s07/CWE78_OS_Command_Injection__wchar_t_file_system_11.c
|
C
|
bsd-3-clause
| 4,354
|
/* /////////////////////////////////////////////////////////////////////////
* File: test/unit/test.unit.bec.COMErrorObject/implicit_link.cpp
*
* Purpose: Implicit link file for the test.unit.bec.COMErrorObject project.
*
* Created: 2nd August 2009
* Updated: 10th January 2011
*
* Status: Wizard-generated
*
* License: (Licensed under the Synesis Software Open License)
*
* Copyright (c) 2009-2011, Synesis Software Pty Ltd.
* All rights reserved.
*
* www: http://www.synesis.com.au/software
*
* ////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////
* Includes
*/
/* Pantheios Header Files */
#include <pantheios/implicit_link/util.h>
#include <pantheios/implicit_link/bec.COMErrorObject.h>
/* xTests Header Files */
#include <xtests/implicit_link.h>
/* shwild Header Files */
#include <shwild/implicit_link.h>
/* ///////////////////////////// end of file //////////////////////////// */
|
zvelo/pantheios
|
test/unit/test.unit.bec.COMErrorObject/implicit_link.cpp
|
C++
|
bsd-3-clause
| 1,120
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<title>Flights Over TO</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
<script type="text/javascript">
var Toronto = new google.maps.LatLng(43.6568774, -79.32085);
google.maps.event.addDomListener(window, 'load', function () {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: Toronto,
mapTypeId: google.maps.MapTypeId.HYBRID
});
// ##### SSE
var flightMarkers = {};
var flightEventsUrl = '/sse'; // Can also be full address
var flightEvents = new EventSource(flightEventsUrl, { withCredentials: true });
// ...
flightEvents.onopen = function () {
console.log('connection opened');
}
flightEvents.onerror = function (e) {
console.log(e);
console.error('connection error');
}
flightEvents.addEventListener('set', function(e) {
var flightId = ('' + e.lastEventId);
var flightData = JSON.parse(e.data);
console.log('[set]', flightData.icaco, '=>', JSON.stringify(flightData));
// ...
if (!flightData) {
console.error('No data');
return;
}
if (flightData.lat === undefined) return;
if (flightData.lon === undefined) return;
var flightPosition = new google.maps.LatLng(flightData.lat, flightData.lon);
// ...
if (flightData.icaco in flightMarkers) {
flightMarkers[flightData.icaco].setPosition(flightPosition);
return;
}
var infowindow = new google.maps.InfoWindow({
content: 'icaco: ' + flightData.icaco
});
var marker = new google.maps.Marker({
map: map,
position: flightPosition
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
flightMarkers[flightData.icaco] = marker;
});
flightEvents.addEventListener('del', function(e) {
var flightId = ('' + e.lastEventId);
var flightData = JSON.parse(e.data);
console.log('[del]', flightData.icaco, '=>', JSON.stringify(flightData));
// ...
if ((flightData.icaco in flightMarkers) === false) return;
flightMarkers[flightData.icaco].setMap(null); // TODO: sometimes the marker does not exist, find out why
delete flightMarkers[flightData.icaco];
});
});
</script>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 95%; /* Leave some room to open debug console */
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
|
eddiecorrigall/flight-relayd
|
sse-demo2/index.html
|
HTML
|
bsd-3-clause
| 2,680
|
/*
* Copyright (c) 1997 - 2015
* Actelion Pharmaceuticals Ltd.
* Gewerbestrasse 16
* CH-4123 Allschwil, Switzerland
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package com.actelion.research.chem;
public class IsotopeHelper {
private static final Isotope[][] sIsotope = {
null,
{ new Isotope(0, 1.007825032, 100.0000), // 1
new Isotope(1, 2.014101778, 0.0150),
new Isotope(2, 3.016049268, 0),
new Isotope(3, 4.027834627, 0),
new Isotope(4, 5.039542911, 0),
new Isotope(5, 6.044942608, 0) },
{ new Isotope(1, 3.016029310, 0.0001), // 2
new Isotope(2, 4.002603250, 100.0000),
new Isotope(3, 5.012223628, 0),
new Isotope(4, 6.018888072, 0),
new Isotope(5, 7.028030527, 0),
new Isotope(6, 8.033921838, 0),
new Isotope(7, 9.043820323, 0),
new Isotope(8, 10.052399713, 0) },
{ new Isotope(1, 4.027182329, 0), // 3
new Isotope(2, 5.012537796, 0),
new Isotope(3, 6.015122281, 8.1081),
new Isotope(4, 7.016004049, 100.0000),
new Isotope(5, 8.022486670, 0),
new Isotope(6, 9.026789122, 0),
new Isotope(7, 10.035480884, 0),
new Isotope(8, 11.043796166, 0),
new Isotope(9, 12.053780, 0) },
{ new Isotope(1, 5.040790, 0), // 4
new Isotope(2, 6.019725804, 0),
new Isotope(3, 7.016929246, 0),
new Isotope(4, 8.005305094, 0),
new Isotope(5, 9.012182135, 100.0000),
new Isotope(6, 10.013533720, 0),
new Isotope(7, 11.021657653, 0),
new Isotope(8, 12.026920631, 0),
new Isotope(9, 13.036133834, 0),
new Isotope(10, 14.042815522, 0) },
{ new Isotope(2, 7.029917389, 0), // 5
new Isotope(3, 8.024606713, 0),
new Isotope(4, 9.013328806, 0),
new Isotope(5, 10.012937027, 24.8439),
new Isotope(6, 11.009305466, 100.0000),
new Isotope(7, 12.014352109, 0),
new Isotope(8, 13.017780267, 0),
new Isotope(9, 14.025404064, 0),
new Isotope(10, 15.031097291, 0),
new Isotope(11, 16.039808836, 0),
new Isotope(12, 17.046931399, 0),
new Isotope(13, 18.056170, 0),
new Isotope(14, 19.063730, 0) },
{ new Isotope(2, 8.037675026, 0), // 6
new Isotope(3, 9.031040087, 0),
new Isotope(4, 10.016853110, 0),
new Isotope(5, 11.011433818, 0),
new Isotope(6, 12.0000000, 100.0000),
new Isotope(7, 13.003354838, 1.1122),
new Isotope(8, 14.003241988, 0),
new Isotope(9, 15.010599258, 0),
new Isotope(10, 16.014701243, 0),
new Isotope(11, 17.022583712, 0),
new Isotope(12, 18.026757058, 0),
new Isotope(13, 19.035248094, 0),
new Isotope(14, 20.040322395, 0),
new Isotope(15, 21.049340, 0),
new Isotope(16, 22.056450, 0) },
{ new Isotope(3, 10.042618, 0), // 7
new Isotope(4, 11.026796226, 0),
new Isotope(5, 12.018613202, 0),
new Isotope(6, 13.005738584, 0),
new Isotope(7, 14.003074005, 100.0000),
new Isotope(8, 15.000108898, 0.3673),
new Isotope(9, 16.006101417, 0),
new Isotope(10, 17.008449673, 0),
new Isotope(11, 18.014081827, 0),
new Isotope(12, 19.017026896, 0),
new Isotope(13, 20.023367295, 0),
new Isotope(14, 21.027087574, 0),
new Isotope(15, 22.034440259, 0),
new Isotope(16, 23.040510, 0),
new Isotope(17, 24.050500, 0) },
{ new Isotope(4, 12.034404776, 0), // 8
new Isotope(5, 13.024810400, 0),
new Isotope(6, 14.008595285, 0),
new Isotope(7, 15.003065386, 0),
new Isotope(8, 15.994914622, 100.0000),
new Isotope(9, 16.999131501, 0.0381),
new Isotope(10, 17.999160419, 0.2005),
new Isotope(11, 19.003578730, 0),
new Isotope(12, 20.004076150, 0),
new Isotope(13, 21.008654631, 0),
new Isotope(14, 22.009967157, 0),
new Isotope(15, 23.015691325, 0),
new Isotope(16, 24.020369922, 0),
new Isotope(17, 25.029140, 0),
new Isotope(18, 26.037750, 0) },
{ new Isotope(5, 14.036080, 0), // 9
new Isotope(6, 15.018010856, 0),
new Isotope(7, 16.011465730, 0),
new Isotope(8, 17.002095238, 0),
new Isotope(9, 18.000937667, 0),
new Isotope(10, 18.998403205, 100.0000),
new Isotope(11, 19.999981324, 0),
new Isotope(12, 20.999948921, 0),
new Isotope(13, 22.002999250, 0),
new Isotope(14, 23.003574385, 0),
new Isotope(15, 24.008099371, 0),
new Isotope(16, 25.012094963, 0),
new Isotope(17, 26.019633157, 0),
new Isotope(18, 27.026892316, 0),
new Isotope(19, 28.035670, 0),
new Isotope(20, 29.043260, 0) },
{ new Isotope(6, 16.025756907, 0), // 10
new Isotope(7, 17.017697565, 0),
new Isotope(8, 18.005697066, 0),
new Isotope(9, 19.001879839, 0),
new Isotope(10, 19.992440176, 100.0000),
new Isotope(11, 20.993846744, 0.2983),
new Isotope(12, 21.991385510, 10.1867),
new Isotope(13, 22.994467337, 0),
new Isotope(14, 23.993615074, 0),
new Isotope(15, 24.997789899, 0),
new Isotope(16, 26.000461498, 0),
new Isotope(17, 27.007615200, 0),
new Isotope(18, 28.012108072, 0),
new Isotope(19, 29.019345902, 0),
new Isotope(20, 30.023872000, 0),
new Isotope(21, 31.033110, 0),
new Isotope(22, 32.039910, 0) },
{ new Isotope(7, 18.027180, 0), // 11
new Isotope(8, 19.013879450, 0),
new Isotope(9, 20.007348260, 0),
new Isotope(10, 20.997655099, 0),
new Isotope(11, 21.994436782, 0),
new Isotope(12, 22.989769675, 100.0000),
new Isotope(13, 23.990963332, 0),
new Isotope(14, 24.989954352, 0),
new Isotope(15, 25.992589898, 0),
new Isotope(16, 26.994008702, 0),
new Isotope(17, 27.998890410, 0),
new Isotope(18, 29.002811301, 0),
new Isotope(19, 30.009226487, 0),
new Isotope(20, 31.013595108, 0),
new Isotope(21, 32.019649792, 0),
new Isotope(22, 33.027386000, 0),
new Isotope(23, 34.034900, 0),
new Isotope(24, 35.044180, 0) },
{ new Isotope(8, 20.018862744, 0), // 12
new Isotope(9, 21.011714174, 0),
new Isotope(10, 21.999574055, 0),
new Isotope(11, 22.994124850, 0),
new Isotope(12, 23.985041898, 100.0000),
new Isotope(13, 24.985837023, 12.6598),
new Isotope(14, 25.982593040, 13.9380),
new Isotope(15, 26.984340742, 0),
new Isotope(16, 27.983876703, 0),
new Isotope(17, 28.988554743, 0),
new Isotope(18, 29.990464529, 0),
new Isotope(19, 30.996548459, 0),
new Isotope(20, 31.999145889, 0),
new Isotope(21, 33.005586975, 0),
new Isotope(22, 34.009072440, 0),
new Isotope(23, 35.018669000, 0),
new Isotope(24, 36.022450, 0),
new Isotope(25, 37.031240, 0) },
{ new Isotope(8, 21.028040, 0), // 13
new Isotope(9, 22.019520, 0),
new Isotope(10, 23.007264900, 0),
new Isotope(11, 23.999940911, 0),
new Isotope(12, 24.990428555, 0),
new Isotope(13, 25.986891659, 0),
new Isotope(14, 26.981538441, 100.0000),
new Isotope(15, 27.981910184, 0),
new Isotope(16, 28.980444848, 0),
new Isotope(17, 29.982960304, 0),
new Isotope(18, 30.983946023, 0),
new Isotope(19, 31.988124379, 0),
new Isotope(20, 32.990869587, 0),
new Isotope(21, 33.996927255, 0),
new Isotope(22, 34.999937650, 0),
new Isotope(23, 36.006351501, 0),
new Isotope(24, 37.010310000, 0),
new Isotope(25, 38.016900, 0),
new Isotope(26, 39.021900, 0) },
{ new Isotope(8, 22.034530, 0), // 14
new Isotope(9, 23.025520, 0),
new Isotope(10, 24.011545711, 0),
new Isotope(11, 25.004106640, 0),
new Isotope(12, 25.992329935, 0),
new Isotope(13, 26.986704764, 0),
new Isotope(14, 27.976926533, 100.0000),
new Isotope(15, 28.976494719, 5.0634),
new Isotope(16, 29.973770218, 3.3612),
new Isotope(17, 30.975363275, 0),
new Isotope(18, 31.974148129, 0),
new Isotope(19, 32.978000520, 0),
new Isotope(20, 33.978575745, 0),
new Isotope(21, 34.984584158, 0),
new Isotope(22, 35.986687363, 0),
new Isotope(23, 36.992995990, 0),
new Isotope(24, 37.995980000, 0),
new Isotope(25, 39.002300, 0),
new Isotope(26, 40.005800, 0),
new Isotope(27, 41.012700, 0),
new Isotope(28, 42.016100, 0) },
{ new Isotope(9, 24.034350, 0), // 15
new Isotope(10, 25.020260, 0),
new Isotope(11, 26.011780, 0),
new Isotope(12, 26.999191645, 0),
new Isotope(13, 27.992312330, 0),
new Isotope(14, 28.981801376, 0),
new Isotope(15, 29.978313807, 0),
new Isotope(16, 30.973761512, 100.0000),
new Isotope(17, 31.973907163, 0),
new Isotope(18, 32.971725281, 0),
new Isotope(19, 33.973636381, 0),
new Isotope(20, 34.973314249, 0),
new Isotope(21, 35.978259824, 0),
new Isotope(22, 36.979608338, 0),
new Isotope(23, 37.984470000, 0),
new Isotope(24, 38.986420000, 0),
new Isotope(25, 39.991050000, 0),
new Isotope(26, 40.994800000, 0),
new Isotope(27, 42.000090, 0),
new Isotope(28, 43.003310, 0),
new Isotope(29, 44.009880, 0),
new Isotope(30, 45.015140, 0),
new Isotope(31, 46.023830, 0) },
{ new Isotope(10, 26.027880, 0), // 16
new Isotope(11, 27.018795, 0),
new Isotope(12, 28.004372661, 0),
new Isotope(13, 28.996608805, 0),
new Isotope(14, 29.984902954, 0),
new Isotope(15, 30.979554421, 0),
new Isotope(16, 31.972070690, 100.0000),
new Isotope(17, 32.971458497, 0.7893),
new Isotope(18, 33.967866831, 4.4306),
new Isotope(19, 34.969032140, 0),
new Isotope(20, 35.967080880, 0.0220),
new Isotope(21, 36.971125716, 0),
new Isotope(22, 37.971163443, 0),
new Isotope(23, 38.975135275, 0),
new Isotope(24, 39.975470000, 0),
new Isotope(25, 40.980030000, 0),
new Isotope(26, 41.981490000, 0),
new Isotope(27, 42.986600000, 0),
new Isotope(28, 43.988320, 0),
new Isotope(29, 44.994820, 0),
new Isotope(30, 45.999570, 0),
new Isotope(31, 47.007620, 0),
new Isotope(32, 48.012990, 0),
new Isotope(33, 49.022010, 0) },
{ new Isotope(11, 28.028510, 0), // 17
new Isotope(12, 29.014110, 0),
new Isotope(13, 30.004770, 0),
new Isotope(14, 30.992416014, 0),
new Isotope(15, 31.985688908, 0),
new Isotope(16, 32.977451798, 0),
new Isotope(17, 33.973761967, 0),
new Isotope(18, 34.968852707, 100.0000),
new Isotope(19, 35.968306945, 0),
new Isotope(20, 36.965902600, 31.9780),
new Isotope(21, 37.968010550, 0),
new Isotope(22, 38.968007677, 0),
new Isotope(23, 39.970415555, 0),
new Isotope(24, 40.970650212, 0),
new Isotope(25, 41.973174994, 0),
new Isotope(26, 42.974203385, 0),
new Isotope(27, 43.978538712, 0),
new Isotope(28, 44.979700000, 0),
new Isotope(29, 45.984120, 0),
new Isotope(30, 46.987950, 0),
new Isotope(31, 47.994850, 0),
new Isotope(32, 48.999890, 0),
new Isotope(33, 50.007730, 0),
new Isotope(34, 51.013530, 0) },
{ new Isotope(12, 30.021560, 0), // 18
new Isotope(13, 31.012126, 0),
new Isotope(14, 31.997660660, 0),
new Isotope(15, 32.989928719, 0),
new Isotope(16, 33.980270118, 0),
new Isotope(17, 34.975256726, 0),
new Isotope(18, 35.967546282, 0.3380),
new Isotope(19, 36.966775912, 0),
new Isotope(20, 37.962732161, 0.0630),
new Isotope(21, 38.964313413, 0),
new Isotope(22, 39.962383123, 100.0000),
new Isotope(23, 40.964500828, 0),
new Isotope(24, 41.963046386, 0),
new Isotope(25, 42.965670701, 0),
new Isotope(26, 43.965365269, 0),
new Isotope(27, 44.968094979, 0),
new Isotope(28, 45.968093467, 0),
new Isotope(29, 46.972186238, 0),
new Isotope(30, 47.975070, 0),
new Isotope(31, 48.982180, 0),
new Isotope(32, 49.985940, 0),
new Isotope(33, 50.993240, 0),
new Isotope(34, 51.998170, 0),
new Isotope(35, 53.006227, 0) },
{ new Isotope(13, 32.021920, 0), // 19
new Isotope(14, 33.007260, 0),
new Isotope(15, 33.998410, 0),
new Isotope(16, 34.988011615, 0),
new Isotope(17, 35.981293405, 0),
new Isotope(18, 36.973376915, 0),
new Isotope(19, 37.969080107, 0),
new Isotope(20, 38.963706861, 100.0000),
new Isotope(21, 39.963998672, 0.0130),
new Isotope(22, 40.961825972, 7.2170),
new Isotope(23, 41.962403059, 0),
new Isotope(24, 42.960715746, 0),
new Isotope(25, 43.961556146, 0),
new Isotope(26, 44.960699658, 0),
new Isotope(27, 45.961976203, 0),
new Isotope(28, 46.961677807, 0),
new Isotope(29, 47.965512946, 0),
new Isotope(30, 48.967450084, 0),
new Isotope(31, 49.972782832, 0),
new Isotope(32, 50.976380, 0),
new Isotope(33, 51.982610, 0),
new Isotope(34, 52.987120, 0),
new Isotope(35, 53.993990, 0),
new Isotope(36, 54.999388, 0) },
{ new Isotope(14, 34.014120, 0), // 20
new Isotope(15, 35.004765, 0),
new Isotope(16, 35.993087234, 0),
new Isotope(17, 36.985871505, 0),
new Isotope(18, 37.976318637, 0),
new Isotope(19, 38.970717729, 0),
new Isotope(20, 39.962591155, 100.0000),
new Isotope(21, 40.962278349, 0),
new Isotope(22, 41.958618337, 0.6674),
new Isotope(23, 42.958766833, 0.1393),
new Isotope(24, 43.955481094, 2.1518),
new Isotope(25, 44.956185938, 0),
new Isotope(26, 45.953692759, 0.0041),
new Isotope(27, 46.954546459, 0),
new Isotope(28, 47.952533512, 0.1929),
new Isotope(29, 48.955673302, 0),
new Isotope(30, 49.957518286, 0),
new Isotope(31, 50.961474238, 0),
new Isotope(32, 51.965100000, 0),
new Isotope(33, 52.970050, 0),
new Isotope(34, 53.974680, 0),
new Isotope(35, 54.980550, 0),
new Isotope(36, 55.985790, 0),
new Isotope(37, 56.992356, 0) },
{ new Isotope(15, 36.014920, 0), // 21
new Isotope(16, 37.003050, 0),
new Isotope(17, 37.994700, 0),
new Isotope(18, 38.984790009, 0),
new Isotope(19, 39.977964014, 0),
new Isotope(20, 40.969251316, 0),
new Isotope(21, 41.965516761, 0),
new Isotope(22, 42.961150980, 0),
new Isotope(23, 43.959403048, 0),
new Isotope(24, 44.955910243, 100.0000),
new Isotope(25, 45.955170250, 0),
new Isotope(26, 46.952408027, 0),
new Isotope(27, 47.952234991, 0),
new Isotope(28, 48.950024065, 0),
new Isotope(29, 49.952187008, 0),
new Isotope(30, 50.953602700, 0),
new Isotope(31, 51.956650000, 0),
new Isotope(32, 52.958170000, 0),
new Isotope(33, 53.963000000, 0),
new Isotope(34, 54.969400000, 0),
new Isotope(35, 55.972660, 0),
new Isotope(36, 56.977040, 0),
new Isotope(37, 57.983070, 0),
new Isotope(38, 58.988041, 0) },
{ new Isotope(16, 38.009770, 0), // 22
new Isotope(17, 39.001323, 0),
new Isotope(18, 39.990498907, 0),
new Isotope(19, 40.983131, 0),
new Isotope(20, 41.973031622, 0),
new Isotope(21, 42.968523342, 0),
new Isotope(22, 43.959690235, 0),
new Isotope(23, 44.958124349, 0),
new Isotope(24, 45.952629491, 10.8401),
new Isotope(25, 46.951763792, 9.8916),
new Isotope(26, 47.947947053, 100.0000),
new Isotope(27, 48.947870789, 7.4526),
new Isotope(28, 49.944792069, 7.3171),
new Isotope(29, 50.946616017, 0),
new Isotope(30, 51.946898175, 0),
new Isotope(31, 52.949731709, 0),
new Isotope(32, 53.950870000, 0),
new Isotope(33, 54.955120000, 0),
new Isotope(34, 55.957990000, 0),
new Isotope(35, 56.964300000, 0),
new Isotope(36, 57.966110, 0),
new Isotope(37, 58.971960, 0),
new Isotope(38, 59.975640, 0),
new Isotope(39, 60.982018, 0) },
{ new Isotope(17, 40.011090, 0), // 23
new Isotope(18, 40.999740, 0),
new Isotope(19, 41.991230, 0),
new Isotope(20, 42.980650, 0),
new Isotope(21, 43.974400, 0),
new Isotope(22, 44.965782286, 0),
new Isotope(23, 45.960199491, 0),
new Isotope(24, 46.954906918, 0),
new Isotope(25, 47.952254480, 0),
new Isotope(26, 48.948516914, 0),
new Isotope(27, 49.947162792, 0.2510),
new Isotope(28, 50.943963675, 100.0000),
new Isotope(29, 51.944779658, 0),
new Isotope(30, 52.944342517, 0),
new Isotope(31, 53.946444381, 0),
new Isotope(32, 54.947238194, 0),
new Isotope(33, 55.950360000, 0),
new Isotope(34, 56.952360000, 0),
new Isotope(35, 57.956650000, 0),
new Isotope(36, 58.959300000, 0),
new Isotope(37, 59.964500000, 0),
new Isotope(38, 60.967410, 0),
new Isotope(39, 61.973140, 0),
new Isotope(40, 62.976750, 0) },
{ new Isotope(18, 42.006430, 0), // 24
new Isotope(19, 42.997707, 0),
new Isotope(20, 43.985470, 0),
new Isotope(21, 44.979160, 0),
new Isotope(22, 45.968361649, 0),
new Isotope(23, 46.962906512, 0),
new Isotope(24, 47.954035861, 0),
new Isotope(25, 48.951341135, 0),
new Isotope(26, 49.946049607, 5.1915),
new Isotope(27, 50.944771767, 0),
new Isotope(28, 51.940511904, 100.0000),
new Isotope(29, 52.940653781, 11.3379),
new Isotope(30, 53.938884921, 2.8166),
new Isotope(31, 54.940844164, 0),
new Isotope(32, 55.940645238, 0),
new Isotope(33, 56.943753800, 0),
new Isotope(34, 57.944250000, 0),
new Isotope(35, 58.948630000, 0),
new Isotope(36, 59.949730000, 0),
new Isotope(37, 60.954090000, 0),
new Isotope(38, 61.955800000, 0),
new Isotope(39, 62.961860, 0),
new Isotope(40, 63.964200, 0),
new Isotope(41, 64.970370, 0) },
{ new Isotope(19, 44.006870, 0), // 25
new Isotope(20, 44.994510, 0),
new Isotope(21, 45.986720, 0),
new Isotope(22, 46.976100, 0),
new Isotope(23, 47.968870, 0),
new Isotope(24, 48.959623415, 0),
new Isotope(25, 49.954243960, 0),
new Isotope(26, 50.948215487, 0),
new Isotope(27, 51.945570079, 0),
new Isotope(28, 52.941294702, 0),
new Isotope(29, 53.940363247, 0),
new Isotope(30, 54.938049636, 100.0000),
new Isotope(31, 55.938909366, 0),
new Isotope(32, 56.938287458, 0),
new Isotope(33, 57.939986451, 0),
new Isotope(34, 58.940447166, 0),
new Isotope(35, 59.943193998, 0),
new Isotope(36, 60.944460000, 0),
new Isotope(37, 61.947970000, 0),
new Isotope(38, 62.949810000, 0),
new Isotope(39, 63.953730000, 0),
new Isotope(40, 64.956100000, 0),
new Isotope(41, 65.960820, 0),
new Isotope(42, 66.963820, 0) },
{ new Isotope(19, 45.014560, 0), // 26
new Isotope(20, 46.000810, 0),
new Isotope(21, 46.992890, 0),
new Isotope(22, 47.980560, 0),
new Isotope(23, 48.973610, 0),
new Isotope(24, 49.962993316, 0),
new Isotope(25, 50.956824936, 0),
new Isotope(26, 51.948116526, 0),
new Isotope(27, 52.945312282, 0),
new Isotope(28, 53.939614836, 6.3236),
new Isotope(29, 54.938298029, 0),
new Isotope(30, 55.934942133, 100.0000),
new Isotope(31, 56.935398707, 2.3986),
new Isotope(32, 57.933280458, 0.3053),
new Isotope(33, 58.934880493, 0),
new Isotope(34, 59.934076943, 0),
new Isotope(35, 60.936749461, 0),
new Isotope(36, 61.936770495, 0),
new Isotope(37, 62.940118442, 0),
new Isotope(38, 63.940870000, 0),
new Isotope(39, 64.944940000, 0),
new Isotope(40, 65.945980000, 0),
new Isotope(41, 66.950000000, 0),
new Isotope(42, 67.952510, 0),
new Isotope(43, 68.957700, 0) },
{ new Isotope(21, 48.001760, 0), // 27
new Isotope(22, 48.989720, 0),
new Isotope(23, 49.981540, 0),
new Isotope(24, 50.970720, 0),
new Isotope(25, 51.963590, 0),
new Isotope(26, 52.954224985, 0),
new Isotope(27, 53.948464147, 0),
new Isotope(28, 54.942003149, 0),
new Isotope(29, 55.939843937, 0),
new Isotope(30, 56.936296235, 0),
new Isotope(31, 57.935757571, 0),
new Isotope(32, 58.933200194, 100.0000),
new Isotope(33, 59.933822196, 0),
new Isotope(34, 60.932479381, 0),
new Isotope(35, 61.934054212, 0),
new Isotope(36, 62.933615218, 0),
new Isotope(37, 63.935813523, 0),
new Isotope(38, 64.936484581, 0),
new Isotope(39, 65.939825412, 0),
new Isotope(40, 66.940610000, 0),
new Isotope(41, 67.944360000, 0),
new Isotope(42, 68.945200000, 0),
new Isotope(43, 69.949810, 0),
new Isotope(44, 70.951730, 0),
new Isotope(45, 71.956410, 0) },
{ new Isotope(22, 49.995930, 0), // 28
new Isotope(23, 50.987720, 0),
new Isotope(24, 51.975680, 0),
new Isotope(25, 52.968460, 0),
new Isotope(26, 53.957910508, 0),
new Isotope(27, 54.951336329, 0),
new Isotope(28, 55.942136339, 0),
new Isotope(29, 56.939800489, 0),
new Isotope(30, 57.935347922, 100.0000),
new Isotope(31, 58.934351553, 0),
new Isotope(32, 59.930790633, 38.2305),
new Isotope(33, 60.931060442, 1.6552),
new Isotope(34, 61.928348763, 5.2585),
new Isotope(35, 62.929672948, 0),
new Isotope(36, 63.927969574, 1.3329),
new Isotope(37, 64.930088013, 0),
new Isotope(38, 65.929115232, 0),
new Isotope(39, 66.931569638, 0),
new Isotope(40, 67.931844932, 0),
new Isotope(41, 68.935181837, 0),
new Isotope(42, 69.936140000, 0),
new Isotope(43, 70.940000000, 0),
new Isotope(44, 71.941300000, 0),
new Isotope(45, 72.946080, 0),
new Isotope(46, 73.947910, 0),
new Isotope(47, 74.952970, 0),
new Isotope(48, 75.955330, 0),
new Isotope(49, 76.960830, 0),
new Isotope(50, 77.963800, 0) },
{ new Isotope(23, 51.997180, 0), // 29
new Isotope(24, 52.985550, 0),
new Isotope(25, 53.976710, 0),
new Isotope(26, 54.966050, 0),
new Isotope(27, 55.958560, 0),
new Isotope(28, 56.949215695, 0),
new Isotope(29, 57.944540734, 0),
new Isotope(30, 58.939504114, 0),
new Isotope(31, 59.937368123, 0),
new Isotope(32, 60.933462181, 0),
new Isotope(33, 61.932587299, 0),
new Isotope(34, 62.929601079, 100.0000),
new Isotope(35, 63.929767865, 0),
new Isotope(36, 64.927793707, 44.5710),
new Isotope(37, 65.928873041, 0),
new Isotope(38, 66.927750294, 0),
new Isotope(39, 67.929637875, 0),
new Isotope(40, 68.929425281, 0),
new Isotope(41, 69.932409287, 0),
new Isotope(42, 70.932619818, 0),
new Isotope(43, 71.935520, 0),
new Isotope(44, 72.936490, 0),
new Isotope(45, 73.940200, 0),
new Isotope(46, 74.941700, 0),
new Isotope(47, 75.945990, 0),
new Isotope(48, 76.947950, 0),
new Isotope(49, 77.952810, 0),
new Isotope(50, 78.955280, 0),
new Isotope(51, 79.961890, 0) },
{ new Isotope(24, 53.992950, 0), // 30
new Isotope(25, 54.983980, 0),
new Isotope(26, 55.972380, 0),
new Isotope(27, 56.964910, 0),
new Isotope(28, 57.954596465, 0),
new Isotope(29, 58.949267074, 0),
new Isotope(30, 59.941832031, 0),
new Isotope(31, 60.939513907, 0),
new Isotope(32, 61.934334132, 0),
new Isotope(33, 62.933215563, 0),
new Isotope(34, 63.929146578, 100.0000),
new Isotope(35, 64.929245079, 0),
new Isotope(36, 65.926036763, 57.4074),
new Isotope(37, 66.927130859, 8.4362),
new Isotope(38, 67.924847566, 38.6831),
new Isotope(39, 68.926553538, 0),
new Isotope(40, 69.925324870, 1.2346),
new Isotope(41, 70.927727195, 0),
new Isotope(42, 71.926861122, 0),
new Isotope(43, 72.929779469, 0),
new Isotope(44, 73.929458261, 0),
new Isotope(45, 74.932937379, 0),
new Isotope(46, 75.933394207, 0),
new Isotope(47, 76.937085857, 0),
new Isotope(48, 77.938569576, 0),
new Isotope(49, 78.942095175, 0),
new Isotope(50, 79.944414722, 0),
new Isotope(51, 80.950480, 0),
new Isotope(52, 81.954840, 0) },
{ new Isotope(25, 55.994910, 0), // 31
new Isotope(26, 56.982930, 0),
new Isotope(27, 57.974250, 0),
new Isotope(28, 58.963370, 0),
new Isotope(29, 59.957060, 0),
new Isotope(30, 60.949170, 0),
new Isotope(31, 61.944179608, 0),
new Isotope(32, 62.939141527, 0),
new Isotope(33, 63.936838307, 0),
new Isotope(34, 64.932739322, 0),
new Isotope(35, 65.931592355, 0),
new Isotope(36, 66.928204915, 0),
new Isotope(37, 67.927983497, 0),
new Isotope(38, 68.925580912, 100.0000),
new Isotope(39, 69.926027741, 0),
new Isotope(40, 70.924705010, 66.3890),
new Isotope(41, 71.926369350, 0),
new Isotope(42, 72.925169832, 0),
new Isotope(43, 73.926940999, 0),
new Isotope(44, 74.926500645, 0),
new Isotope(45, 75.928928262, 0),
new Isotope(46, 76.929281189, 0),
new Isotope(47, 77.931655950, 0),
new Isotope(48, 78.932916371, 0),
new Isotope(49, 79.936588154, 0),
new Isotope(50, 80.937752955, 0),
new Isotope(51, 81.943160, 0),
new Isotope(52, 82.946870, 0),
new Isotope(53, 83.952340, 0) },
{ new Isotope(26, 57.991010, 0), // 32
new Isotope(27, 58.981750, 0),
new Isotope(28, 59.970190, 0),
new Isotope(29, 60.963790, 0),
new Isotope(30, 61.954650, 0),
new Isotope(31, 62.949640, 0),
new Isotope(32, 63.941572638, 0),
new Isotope(33, 64.939440762, 0),
new Isotope(34, 65.933846798, 0),
new Isotope(35, 66.932738415, 0),
new Isotope(36, 67.928097266, 0),
new Isotope(37, 68.927972002, 0),
new Isotope(38, 69.924250365, 56.1644),
new Isotope(39, 70.924953991, 0),
new Isotope(40, 71.922076184, 75.0685),
new Isotope(41, 72.923459361, 21.3698),
new Isotope(42, 73.921178213, 100.0000),
new Isotope(43, 74.922859494, 21.3698),
new Isotope(44, 75.921402716, 0),
new Isotope(45, 76.923548462, 0),
new Isotope(46, 77.922852886, 0),
new Isotope(47, 78.925401560, 0),
new Isotope(48, 79.925444764, 0),
new Isotope(49, 80.928821065, 0),
new Isotope(50, 81.929550326, 0),
new Isotope(51, 82.934510, 0),
new Isotope(52, 83.937310, 0),
new Isotope(53, 84.942690, 0),
new Isotope(54, 85.946270, 0) },
{ new Isotope(27, 59.993130, 0), // 33
new Isotope(28, 60.980620, 0),
new Isotope(29, 61.973200, 0),
new Isotope(30, 62.963690, 0),
new Isotope(31, 63.957572, 0),
new Isotope(32, 64.949484, 0),
new Isotope(33, 65.944099147, 0),
new Isotope(34, 66.939190417, 0),
new Isotope(35, 67.936792976, 0),
new Isotope(36, 68.932280154, 0),
new Isotope(37, 69.930927811, 0),
new Isotope(38, 70.927114724, 0),
new Isotope(39, 71.926752647, 0),
new Isotope(40, 72.923825288, 0),
new Isotope(41, 73.923929076, 0),
new Isotope(42, 74.921596417, 100.0000),
new Isotope(43, 75.922393933, 0),
new Isotope(44, 76.920647703, 0),
new Isotope(45, 77.921828577, 0),
new Isotope(46, 78.920948498, 0),
new Isotope(47, 79.922578162, 0),
new Isotope(48, 80.922132884, 0),
new Isotope(49, 81.924504668, 0),
new Isotope(50, 82.924980625, 0),
new Isotope(51, 83.929060, 0),
new Isotope(52, 84.931810, 0),
new Isotope(53, 85.936230, 0),
new Isotope(54, 86.939580, 0),
new Isotope(55, 87.944560, 0),
new Isotope(56, 88.949230, 0) },
{ new Isotope(31, 64.964660, 0), // 34
new Isotope(32, 65.955210, 0),
new Isotope(33, 66.950090, 0),
new Isotope(34, 67.941870, 0),
new Isotope(35, 68.939562155, 0),
new Isotope(36, 69.933504, 0),
new Isotope(37, 70.931868378, 0),
new Isotope(38, 71.927112313, 0),
new Isotope(39, 72.926766800, 0),
new Isotope(40, 73.922476561, 1.8145),
new Isotope(41, 74.922523571, 0),
new Isotope(42, 75.919214107, 18.1451),
new Isotope(43, 76.919914610, 15.3226),
new Isotope(44, 77.917309522, 47.3790),
new Isotope(45, 78.918499802, 0),
new Isotope(46, 79.916521828, 100.0000),
new Isotope(47, 80.917992931, 0),
new Isotope(48, 81.916700000, 18.9516),
new Isotope(49, 82.919119072, 0),
new Isotope(50, 83.918464523, 0),
new Isotope(51, 84.922244678, 0),
new Isotope(52, 85.924271165, 0),
new Isotope(53, 86.928520749, 0),
new Isotope(54, 87.931423982, 0),
new Isotope(55, 88.936020, 0),
new Isotope(56, 89.939420, 0),
new Isotope(57, 90.945370, 0),
new Isotope(58, 91.949330, 0) },
{ new Isotope(32, 66.964790, 0), // 35
new Isotope(33, 67.958248, 0),
new Isotope(34, 68.950178, 0),
new Isotope(35, 69.944208, 0),
new Isotope(36, 70.939246, 0),
new Isotope(37, 71.936496876, 0),
new Isotope(38, 72.931794889, 0),
new Isotope(39, 73.929891152, 0),
new Isotope(40, 74.925776410, 0),
new Isotope(41, 75.924541974, 0),
new Isotope(42, 76.921380123, 0),
new Isotope(43, 77.921146130, 0),
new Isotope(44, 78.918337647, 100.0000),
new Isotope(45, 79.918529952, 0),
new Isotope(46, 80.916291060, 97.2776),
new Isotope(47, 81.916804666, 0),
new Isotope(48, 82.915180219, 0),
new Isotope(49, 83.916503685, 0),
new Isotope(50, 84.915608027, 0),
new Isotope(51, 85.918797162, 0),
new Isotope(52, 86.920710713, 0),
new Isotope(53, 87.924065908, 0),
new Isotope(54, 88.926387260, 0),
new Isotope(55, 89.930634988, 0),
new Isotope(56, 90.933965300, 0),
new Isotope(57, 91.939255258, 0),
new Isotope(58, 92.943100, 0),
new Isotope(59, 93.948680, 0) },
{ new Isotope(33, 68.965320, 0), // 36
new Isotope(34, 69.956010, 0),
new Isotope(35, 70.950510, 0),
new Isotope(36, 71.941907540, 0),
new Isotope(37, 72.938931115, 0),
new Isotope(38, 73.933258225, 0),
new Isotope(39, 74.931033794, 0),
new Isotope(40, 75.925948304, 0),
new Isotope(41, 76.924667880, 0),
new Isotope(42, 77.920386271, 85.9106140),
new Isotope(43, 78.920082992, 0),
new Isotope(44, 79.916378040, 0.6140),
new Isotope(45, 80.916592419, 0),
new Isotope(46, 81.913484601, 3.9474),
new Isotope(47, 82.914135952, 20.3509),
new Isotope(48, 83.911506627, 100.0000),
new Isotope(49, 84.912526954, 0),
new Isotope(50, 85.910610313, 30.3509),
new Isotope(51, 86.913354251, 0),
new Isotope(52, 87.914446951, 0),
new Isotope(53, 88.917632505, 0),
new Isotope(54, 89.919523803, 0),
new Isotope(55, 90.923442418, 0),
new Isotope(56, 91.926152752, 0),
new Isotope(57, 92.931265246, 0),
new Isotope(58, 93.934362, 0),
new Isotope(59, 94.939840, 0),
new Isotope(60, 95.943070, 0),
new Isotope(61, 96.948560, 0) },
{ new Isotope(34, 70.965320, 0), // 37
new Isotope(35, 71.959080, 0),
new Isotope(36, 72.950366, 0),
new Isotope(37, 73.944470376, 0),
new Isotope(38, 74.938569199, 0),
new Isotope(39, 75.935071448, 0),
new Isotope(40, 76.930406599, 0),
new Isotope(41, 77.928141485, 0),
new Isotope(42, 78.923996719, 0),
new Isotope(43, 79.922519322, 0),
new Isotope(44, 80.918994165, 0),
new Isotope(45, 81.918207691, 0),
new Isotope(46, 82.915111951, 0),
new Isotope(47, 83.914384676, 0),
new Isotope(48, 84.911789341, 100.0000),
new Isotope(49, 85.911167080, 0),
new Isotope(50, 86.909183465, 38.5710),
new Isotope(51, 87.911318556, 0),
new Isotope(52, 88.912279939, 0),
new Isotope(53, 89.914808941, 0),
new Isotope(54, 90.916534160, 0),
new Isotope(55, 91.919725442, 0),
new Isotope(56, 92.922032765, 0),
new Isotope(57, 93.926407326, 0),
new Isotope(58, 94.929319260, 0),
new Isotope(59, 95.934283962, 0),
new Isotope(60, 96.937342863, 0),
new Isotope(61, 97.941703557, 0),
new Isotope(62, 98.945420616, 0),
new Isotope(63, 99.949870, 0),
new Isotope(64, 100.953195994, 0),
new Isotope(65, 101.959210, 0) },
{ new Isotope(35, 72.965970, 0), // 38
new Isotope(36, 73.956310, 0),
new Isotope(37, 74.949920, 0),
new Isotope(38, 75.941610, 0),
new Isotope(39, 76.937761511, 0),
new Isotope(40, 77.932179362, 0),
new Isotope(41, 78.929707076, 0),
new Isotope(42, 79.924524588, 0),
new Isotope(43, 80.923213095, 0),
new Isotope(44, 81.918401258, 0),
new Isotope(45, 82.917555029, 0),
new Isotope(46, 83.913424778, 0.6781),
new Isotope(47, 84.912932689, 0),
new Isotope(48, 85.909262351, 11.9399),
new Isotope(49, 86.908879316, 8.4766),
new Isotope(50, 87.905614339, 100.0000),
new Isotope(51, 88.907452906, 0),
new Isotope(52, 89.907737596, 0),
new Isotope(53, 90.910209845, 0),
new Isotope(54, 91.911029895, 0),
new Isotope(55, 92.914022410, 0),
new Isotope(56, 93.915359856, 0),
new Isotope(57, 94.919358213, 0),
new Isotope(58, 95.921680473, 0),
new Isotope(59, 96.926148757, 0),
new Isotope(60, 97.928471177, 0),
new Isotope(61, 98.933315038, 0),
new Isotope(62, 99.935351729, 0),
new Isotope(63, 100.940517434, 0),
new Isotope(64, 101.943018795, 0),
new Isotope(65, 102.948950, 0),
new Isotope(66, 103.952330, 0) },
{ new Isotope(38, 76.949620, 0), // 39
new Isotope(39, 77.943500, 0),
new Isotope(40, 78.937350712, 0),
new Isotope(41, 79.931982402, 0),
new Isotope(42, 80.929128719, 0),
new Isotope(43, 81.926792071, 0),
new Isotope(44, 82.922352572, 0),
new Isotope(45, 83.920387768, 0),
new Isotope(46, 84.916427076, 0),
new Isotope(47, 85.914887724, 0),
new Isotope(48, 86.910877833, 0),
new Isotope(49, 87.909503361, 0),
new Isotope(50, 88.905847902, 100.0000),
new Isotope(51, 89.907151443, 0),
new Isotope(52, 90.907303415, 0),
new Isotope(53, 91.908946832, 0),
new Isotope(54, 92.909581582, 0),
new Isotope(55, 93.911594008, 0),
new Isotope(56, 94.912823709, 0),
new Isotope(57, 95.915897787, 0),
new Isotope(58, 96.918131017, 0),
new Isotope(59, 97.922219525, 0),
new Isotope(60, 98.924634736, 0),
new Isotope(61, 99.927756402, 0),
new Isotope(62, 100.930313395, 0),
new Isotope(63, 101.933555501, 0),
new Isotope(64, 102.936940, 0),
new Isotope(65, 103.941450, 0),
new Isotope(66, 104.945090, 0),
new Isotope(67, 105.950220, 0) },
{ new Isotope(39, 78.949160, 0), // 40
new Isotope(40, 79.940550, 0),
new Isotope(41, 80.936815296, 0),
new Isotope(42, 81.931086249, 0),
new Isotope(43, 82.928652130, 0),
new Isotope(44, 83.923250, 0),
new Isotope(45, 84.921465220, 0),
new Isotope(46, 85.916472851, 0),
new Isotope(47, 86.914816578, 0),
new Isotope(48, 87.910226179, 0),
new Isotope(49, 88.908888916, 0),
new Isotope(50, 89.904703679, 100.0000),
new Isotope(51, 90.905644968, 21.9048),
new Isotope(52, 91.905040106, 33.3822),
new Isotope(53, 92.906475627, 0),
new Isotope(54, 93.906315765, 33.6832),
new Isotope(55, 94.908042739, 0),
new Isotope(56, 95.908275675, 5.4033),
new Isotope(57, 96.910950716, 0),
new Isotope(58, 97.912746366, 0),
new Isotope(59, 98.916511084, 0),
new Isotope(60, 99.917761704, 0),
new Isotope(61, 100.921139958, 0),
new Isotope(62, 101.922981089, 0),
new Isotope(63, 102.926597062, 0),
new Isotope(64, 103.928780, 0),
new Isotope(65, 104.933050, 0),
new Isotope(66, 105.935910, 0),
new Isotope(67, 106.940860, 0),
new Isotope(68, 107.944280, 0) },
{ new Isotope(40, 80.949050, 0), // 41
new Isotope(41, 81.943130, 0),
new Isotope(42, 82.936703713, 0),
new Isotope(43, 83.933570, 0),
new Isotope(44, 84.927906486, 0),
new Isotope(45, 85.925037588, 0),
new Isotope(46, 86.920361435, 0),
new Isotope(47, 87.918331440, 0),
new Isotope(48, 88.913495503, 0),
new Isotope(49, 89.911264109, 0),
new Isotope(50, 90.906990538, 0),
new Isotope(51, 91.907193214, 0),
new Isotope(52, 92.906377543, 100.0000),
new Isotope(53, 93.907283457, 0),
new Isotope(54, 94.906835178, 0),
new Isotope(55, 95.908100076, 0),
new Isotope(56, 96.908097144, 0),
new Isotope(57, 97.910330690, 0),
new Isotope(58, 98.911617864, 0),
new Isotope(59, 99.914181434, 0),
new Isotope(60, 100.915251567, 0),
new Isotope(61, 101.918037417, 0),
new Isotope(62, 102.919141297, 0),
new Isotope(63, 103.922459464, 0),
new Isotope(64, 104.923934023, 0),
new Isotope(65, 105.928190, 0),
new Isotope(66, 106.930310, 0),
new Isotope(67, 107.935010, 0),
new Isotope(68, 108.937630, 0),
new Isotope(69, 109.942680, 0) },
{ new Isotope(41, 82.948740, 0), // 42
new Isotope(42, 83.940090, 0),
new Isotope(43, 84.936590, 0),
new Isotope(44, 85.930695167, 0),
new Isotope(45, 86.927326830, 0),
new Isotope(46, 87.921952728, 0),
new Isotope(47, 88.919480562, 0),
new Isotope(48, 89.913936161, 0),
new Isotope(49, 90.911750754, 0),
new Isotope(50, 91.906810480, 61.5002),
new Isotope(51, 92.906812213, 0),
new Isotope(52, 93.905087578, 38.3340),
new Isotope(53, 94.905841487, 65.9760),
new Isotope(54, 95.904678904, 69.1256),
new Isotope(55, 96.906021033, 39.5773),
new Isotope(56, 97.905407846, 100.0000),
new Isotope(57, 98.907711598, 0),
new Isotope(58, 99.907477149, 39.9088),
new Isotope(59, 100.910346543, 0),
new Isotope(60, 101.910297162, 0),
new Isotope(61, 102.913204596, 0),
new Isotope(62, 103.913758387, 0),
new Isotope(63, 104.916972087, 0),
new Isotope(64, 105.918134284, 0),
new Isotope(65, 106.921694724, 0),
new Isotope(66, 107.923973837, 0),
new Isotope(67, 108.927810, 0),
new Isotope(68, 109.929730, 0),
new Isotope(69, 110.934510, 0),
new Isotope(70, 111.936840, 0),
new Isotope(71, 112.942030, 0) },
{ new Isotope(42, 84.948940, 0), // 43
new Isotope(43, 85.942880, 0),
new Isotope(44, 86.936530, 0),
new Isotope(45, 87.932830, 0),
new Isotope(46, 88.927542880, 0),
new Isotope(47, 89.923555830, 0),
new Isotope(48, 90.918428200, 0),
new Isotope(49, 91.915259655, 0),
new Isotope(50, 92.910248473, 0),
new Isotope(51, 93.909656309, 0),
new Isotope(52, 94.907656454, 0),
new Isotope(53, 95.907870803, 0),
new Isotope(54, 96.906364843, 0),
new Isotope(55, 97.907215692, 0),
new Isotope(56, 98.906254554, 0),
new Isotope(57, 99.907657594, 0),
new Isotope(58, 100.907314380, 0),
new Isotope(59, 101.909212938, 0),
new Isotope(60, 102.909178805, 0),
new Isotope(61, 103.911444898, 0),
new Isotope(62, 104.911658043, 0),
new Isotope(63, 105.914355408, 0),
new Isotope(64, 106.915081691, 0),
new Isotope(65, 107.918479973, 0),
new Isotope(66, 108.919980998, 0),
new Isotope(67, 109.923390, 0),
new Isotope(68, 110.925050, 0),
new Isotope(69, 111.929240, 0),
new Isotope(70, 112.931330, 0),
new Isotope(71, 113.935880, 0),
new Isotope(72, 114.938280, 0) },
{ new Isotope(43, 86.949180, 0), // 44
new Isotope(44, 87.940420, 0),
new Isotope(45, 88.936110, 0),
new Isotope(46, 89.929780, 0),
new Isotope(47, 90.926377434, 0),
new Isotope(48, 91.920120, 0),
new Isotope(49, 92.917051523, 0),
new Isotope(50, 93.911359569, 0),
new Isotope(51, 94.910412729, 0),
new Isotope(52, 95.907597681, 17.4684),
new Isotope(53, 96.907554546, 0),
new Isotope(54, 97.905287111, 5.9494),
new Isotope(55, 98.905939307, 40.1899),
new Isotope(56, 99.904219664, 39.8734),
new Isotope(57, 100.905582219, 53.7975),
new Isotope(58, 101.904349503, 100.0000),
new Isotope(59, 102.906323677, 0),
new Isotope(60, 103.905430145, 59.1772),
new Isotope(61, 104.907750341, 0),
new Isotope(62, 105.907326913, 0),
new Isotope(63, 106.909907207, 0),
new Isotope(64, 107.910192211, 0),
new Isotope(65, 108.913201565, 0),
new Isotope(66, 109.913966185, 0),
new Isotope(67, 110.917560, 0),
new Isotope(68, 111.918821673, 0),
new Isotope(69, 112.922540, 0),
new Isotope(70, 113.923891981, 0),
new Isotope(71, 114.928310, 0),
new Isotope(72, 115.930160, 0),
new Isotope(73, 116.934790, 0),
new Isotope(74, 117.937030, 0) },
{ new Isotope(44, 88.949380, 0), // 45
new Isotope(45, 89.942870, 0),
new Isotope(46, 90.936550, 0),
new Isotope(47, 91.931980, 0),
new Isotope(48, 92.925740, 0),
new Isotope(49, 93.921698, 0),
new Isotope(50, 94.915898541, 0),
new Isotope(51, 95.914518212, 0),
new Isotope(52, 96.911336643, 0),
new Isotope(53, 97.910716431, 0),
new Isotope(54, 98.908132101, 0),
new Isotope(55, 99.908116630, 0),
new Isotope(56, 100.906163526, 0),
new Isotope(57, 101.906842845, 0),
new Isotope(58, 102.905504182, 100.0000),
new Isotope(59, 103.906655315, 0),
new Isotope(60, 104.905692444, 0),
new Isotope(61, 105.907284615, 0),
new Isotope(62, 106.906750540, 0),
new Isotope(63, 107.908730768, 0),
new Isotope(64, 108.908735621, 0),
new Isotope(65, 109.910949525, 0),
new Isotope(66, 110.911660, 0),
new Isotope(67, 111.913969253, 0),
new Isotope(68, 112.915420, 0),
new Isotope(69, 113.917343360, 0),
new Isotope(70, 114.920124676, 0),
new Isotope(71, 115.922746643, 0),
new Isotope(72, 116.925350, 0),
new Isotope(73, 117.929430, 0),
new Isotope(74, 118.931360, 0),
new Isotope(75, 119.935780, 0),
new Isotope(76, 120.938080, 0) },
{ new Isotope(45, 90.949480, 0), // 46
new Isotope(46, 91.940420, 0),
new Isotope(47, 92.935910, 0),
new Isotope(48, 93.928770, 0),
new Isotope(49, 94.924690, 0),
new Isotope(50, 95.918221940, 0),
new Isotope(51, 96.916478921, 0),
new Isotope(52, 97.912720751, 0),
new Isotope(53, 98.911767757, 0),
new Isotope(54, 99.908504596, 0),
new Isotope(55, 100.908289144, 0),
new Isotope(56, 101.905607716, 3.7322),
new Isotope(57, 102.906087204, 0),
new Isotope(58, 103.904034912, 40.7611),
new Isotope(59, 104.905084046, 81.7051),
new Isotope(60, 105.903483087, 100.0000),
new Isotope(61, 106.905128453, 0),
new Isotope(62, 107.903894451, 96.8167),
new Isotope(63, 108.905953535, 0),
new Isotope(64, 109.905152385, 42.8833),
new Isotope(65, 110.907643952, 0),
new Isotope(66, 111.907313277, 0),
new Isotope(67, 112.910151346, 0),
new Isotope(68, 113.910365322, 0),
new Isotope(69, 114.913683410, 0),
new Isotope(70, 115.914158288, 0),
new Isotope(71, 116.917840, 0),
new Isotope(72, 117.918983915, 0),
new Isotope(73, 118.922680, 0),
new Isotope(74, 119.924030, 0),
new Isotope(75, 120.928180, 0),
new Isotope(76, 121.929800, 0),
new Isotope(77, 122.934260, 0) },
{ new Isotope(47, 93.942780, 0), // 47
new Isotope(48, 94.935480, 0),
new Isotope(49, 95.930680, 0),
new Isotope(50, 96.924000, 0),
new Isotope(51, 97.921759995, 0),
new Isotope(52, 98.917597103, 0),
new Isotope(53, 99.916069387, 0),
new Isotope(54, 100.912802135, 0),
new Isotope(55, 101.911999996, 0),
new Isotope(56, 102.908972453, 0),
new Isotope(57, 103.908628228, 0),
new Isotope(58, 104.906528234, 0),
new Isotope(59, 105.906666431, 0),
new Isotope(60, 106.905093020, 100.0000),
new Isotope(61, 107.905953705, 0),
new Isotope(62, 108.904755514, 92.9050),
new Isotope(63, 109.906110460, 0),
new Isotope(64, 110.905294679, 0),
new Isotope(65, 111.907004132, 0),
new Isotope(66, 112.906565708, 0),
new Isotope(67, 113.908807907, 0),
new Isotope(68, 114.908762282, 0),
new Isotope(69, 115.911359558, 0),
new Isotope(70, 116.911684187, 0),
new Isotope(71, 117.914582383, 0),
new Isotope(72, 118.915666045, 0),
new Isotope(73, 119.918788609, 0),
new Isotope(74, 120.919851074, 0),
new Isotope(75, 121.923320, 0),
new Isotope(76, 122.924900, 0),
new Isotope(77, 123.928530, 0),
new Isotope(78, 124.930540, 0),
new Isotope(79, 125.934500, 0),
new Isotope(80, 126.936880, 0) },
{ new Isotope(48, 95.939770, 0), // 48
new Isotope(49, 96.934940, 0),
new Isotope(50, 97.927579, 0),
new Isotope(51, 98.925010, 0),
new Isotope(52, 99.920230232, 0),
new Isotope(53, 100.918681442, 0),
new Isotope(54, 101.914777255, 0),
new Isotope(55, 102.913418952, 0),
new Isotope(56, 103.909848091, 0),
new Isotope(57, 104.909467818, 0),
new Isotope(58, 105.906458007, 4.3508),
new Isotope(59, 106.906614232, 0),
new Isotope(60, 107.904183403, 3.0978),
new Isotope(61, 108.904985569, 0),
new Isotope(62, 109.903005578, 43.4737),
new Isotope(63, 110.904181628, 44.5527),
new Isotope(64, 111.902757226, 83.9888),
new Isotope(65, 112.904400947, 42.5339),
new Isotope(66, 113.903358121, 100.0000),
new Isotope(67, 114.905430553, 0),
new Isotope(68, 115.904755434, 26.0703),
new Isotope(69, 116.907218242, 0),
new Isotope(70, 117.906914144, 0),
new Isotope(71, 118.909922582, 0),
new Isotope(72, 119.909851352, 0),
new Isotope(73, 120.912980390, 0),
new Isotope(74, 121.913500, 0),
new Isotope(75, 122.917003675, 0),
new Isotope(76, 123.917648302, 0),
new Isotope(77, 124.921247170, 0),
new Isotope(78, 125.922353996, 0),
new Isotope(79, 126.926434822, 0),
new Isotope(80, 127.927760617, 0),
new Isotope(81, 128.932260, 0),
new Isotope(82, 129.933980, 0) },
{ new Isotope(49, 97.942240, 0), // 49
new Isotope(50, 98.934610, 0),
new Isotope(51, 99.931149033, 0),
new Isotope(52, 100.926560, 0),
new Isotope(53, 101.924707541, 0),
new Isotope(54, 102.919913896, 0),
new Isotope(55, 103.918338416, 0),
new Isotope(56, 104.914673434, 0),
new Isotope(57, 105.913461134, 0),
new Isotope(58, 106.910292195, 0),
new Isotope(59, 107.909719683, 0),
new Isotope(60, 108.907154078, 0),
new Isotope(61, 109.907168783, 0),
new Isotope(62, 110.905110677, 0),
new Isotope(63, 111.905533338, 0),
new Isotope(64, 112.904061223, 4.4932),
new Isotope(65, 113.904916758, 0),
new Isotope(66, 114.903878328, 100.0000),
new Isotope(67, 115.905259995, 0),
new Isotope(68, 116.904515731, 0),
new Isotope(69, 117.906354623, 0),
new Isotope(70, 118.905846334, 0),
new Isotope(71, 119.907961505, 0),
new Isotope(72, 120.907848847, 0),
new Isotope(73, 121.910277103, 0),
new Isotope(74, 122.910438951, 0),
new Isotope(75, 123.913175916, 0),
new Isotope(76, 124.913601387, 0),
new Isotope(77, 125.916464532, 0),
new Isotope(78, 126.917344048, 0),
new Isotope(79, 127.920170658, 0),
new Isotope(80, 128.921657958, 0),
new Isotope(81, 129.924854941, 0),
new Isotope(82, 130.926767408, 0),
new Isotope(83, 131.932919005, 0),
new Isotope(84, 132.938340, 0),
new Isotope(85, 133.944660, 0) },
{ new Isotope(50, 99.938954, 0), // 50
new Isotope(51, 100.936060, 0),
new Isotope(52, 101.930490, 0),
new Isotope(53, 102.928130, 0),
new Isotope(54, 103.923185469, 0),
new Isotope(55, 104.921390409, 0),
new Isotope(56, 105.916880472, 0),
new Isotope(57, 106.915666702, 0),
new Isotope(58, 107.911965339, 0),
new Isotope(59, 108.911286879, 0),
new Isotope(60, 109.907852688, 0),
new Isotope(61, 110.907735404, 0),
new Isotope(62, 111.904820810, 3.0864),
new Isotope(63, 112.905173373, 0),
new Isotope(64, 113.902781816, 2.1605),
new Isotope(65, 114.903345973, 1.2346),
new Isotope(66, 115.901744149, 45.3704),
new Isotope(67, 116.902953765, 23.7654),
new Isotope(68, 117.901606328, 75.0000),
new Isotope(69, 118.903308880, 26.5432),
new Isotope(70, 119.902196571, 100.0000),
new Isotope(71, 120.904236867, 0),
new Isotope(72, 121.903440138, 14.1975),
new Isotope(73, 122.905721901, 0),
new Isotope(74, 123.905274630, 17.2840),
new Isotope(75, 124.907784924, 0),
new Isotope(76, 125.907653953, 0),
new Isotope(77, 126.910350980, 0),
new Isotope(78, 127.910534953, 0),
new Isotope(79, 128.913439976, 0),
new Isotope(80, 129.913852185, 0),
new Isotope(81, 130.916919144, 0),
new Isotope(82, 131.917744455, 0),
new Isotope(83, 132.923814085, 0),
new Isotope(84, 133.928463576, 0),
new Isotope(85, 134.934730, 0),
new Isotope(86, 135.939340, 0),
new Isotope(87, 136.945790, 0) },
{ new Isotope(52, 102.940120, 0), // 51
new Isotope(53, 103.936287, 0),
new Isotope(54, 104.931528593, 0),
new Isotope(55, 105.928183134, 0),
new Isotope(56, 106.924150, 0),
new Isotope(57, 107.922160, 0),
new Isotope(58, 108.918136092, 0),
new Isotope(59, 109.917533911, 0),
new Isotope(60, 110.912534147, 0),
new Isotope(61, 111.912394640, 0),
new Isotope(62, 112.909377941, 0),
new Isotope(63, 113.909095876, 0),
new Isotope(64, 114.906598812, 0),
new Isotope(65, 115.906797235, 0),
new Isotope(66, 116.904839590, 0),
new Isotope(67, 117.905531885, 0),
new Isotope(68, 118.903946460, 0),
new Isotope(69, 119.905074315, 0),
new Isotope(70, 120.903818044, 100.0000),
new Isotope(71, 121.905175415, 0),
new Isotope(72, 122.904215696, 74.5201),
new Isotope(73, 123.905937525, 0),
new Isotope(74, 124.905247804, 0),
new Isotope(75, 125.907248153, 0),
new Isotope(76, 126.906914564, 0),
new Isotope(77, 127.909167330, 0),
new Isotope(78, 128.909150092, 0),
new Isotope(79, 129.911546459, 0),
new Isotope(80, 130.911946487, 0),
new Isotope(81, 131.914413247, 0),
new Isotope(82, 132.915236466, 0),
new Isotope(83, 133.920551554, 0),
new Isotope(84, 134.925167962, 0),
new Isotope(85, 135.930660, 0),
new Isotope(86, 136.935310, 0),
new Isotope(87, 137.940960, 0),
new Isotope(88, 138.945710, 0) },
{ new Isotope(54, 105.937702, 0), // 52
new Isotope(55, 106.935036, 0),
new Isotope(56, 107.929486838, 0),
new Isotope(57, 108.927456483, 0),
new Isotope(58, 109.922407164, 0),
new Isotope(59, 110.921120589, 0),
new Isotope(60, 111.917061617, 0),
new Isotope(61, 112.915452551, 0),
new Isotope(62, 113.912498025, 0),
new Isotope(63, 114.911578627, 0),
new Isotope(64, 115.908420253, 0),
new Isotope(65, 116.908634180, 0),
new Isotope(66, 117.905825187, 0),
new Isotope(67, 118.906408110, 0),
new Isotope(68, 119.904019891, 0.2840),
new Isotope(69, 120.904929815, 0),
new Isotope(70, 121.903047064, 7.6923),
new Isotope(71, 122.904272951, 2.6864),
new Isotope(72, 123.902819466, 14.2485),
new Isotope(73, 124.904424718, 21.1243),
new Isotope(74, 125.903305543, 56.0651),
new Isotope(75, 126.905217290, 0),
new Isotope(76, 127.904461383, 93.7574),
new Isotope(77, 128.906595593, 0),
new Isotope(78, 129.906222753, 100.0000),
new Isotope(79, 130.908521880, 0),
new Isotope(80, 131.908523782, 0),
new Isotope(81, 132.910939068, 0),
new Isotope(82, 133.911540546, 0),
new Isotope(83, 134.916450782, 0),
new Isotope(84, 135.920103155, 0),
new Isotope(85, 136.925324769, 0),
new Isotope(86, 137.929220, 0),
new Isotope(87, 138.934730, 0),
new Isotope(88, 139.938700, 0),
new Isotope(89, 140.944390, 0),
new Isotope(90, 141.948500, 0) },
{ new Isotope(55, 107.943291, 0), // 53
new Isotope(56, 108.938191658, 0),
new Isotope(57, 109.934634181, 0),
new Isotope(58, 110.930276, 0),
new Isotope(59, 111.927970, 0),
new Isotope(60, 112.923644245, 0),
new Isotope(61, 113.921850, 0),
new Isotope(62, 114.918272, 0),
new Isotope(63, 115.916735014, 0),
new Isotope(64, 116.913647692, 0),
new Isotope(65, 117.913375230, 0),
new Isotope(66, 118.910180837, 0),
new Isotope(67, 119.910047843, 0),
new Isotope(68, 120.907366063, 0),
new Isotope(69, 121.907592451, 0),
new Isotope(70, 122.905597944, 0),
new Isotope(71, 123.906211423, 0),
new Isotope(72, 124.904624150, 0),
new Isotope(73, 125.905619387, 0),
new Isotope(74, 126.904468420, 100.0000),
new Isotope(75, 127.905805254, 0),
new Isotope(76, 128.904987487, 0),
new Isotope(77, 129.906674018, 0),
new Isotope(78, 130.906124168, 0),
new Isotope(79, 131.907994525, 0),
new Isotope(80, 132.907806465, 0),
new Isotope(81, 133.909876552, 0),
new Isotope(82, 134.910050310, 0),
new Isotope(83, 135.914655105, 0),
new Isotope(84, 136.917872653, 0),
new Isotope(85, 137.922383666, 0),
new Isotope(86, 138.926093402, 0),
new Isotope(87, 139.931210, 0),
new Isotope(88, 140.934830, 0),
new Isotope(89, 141.940180, 0),
new Isotope(90, 142.944070, 0),
new Isotope(91, 143.949610, 0) },
{ new Isotope(56, 109.944476, 0), // 54
new Isotope(57, 110.941632, 0),
new Isotope(58, 111.935665350, 0),
new Isotope(59, 112.933382836, 0),
new Isotope(60, 113.928145, 0),
new Isotope(61, 114.926979032, 0),
new Isotope(62, 115.921394197, 0),
new Isotope(63, 116.920564355, 0),
new Isotope(64, 117.916570920, 0),
new Isotope(65, 118.915554295, 0),
new Isotope(66, 119.912151990, 0),
new Isotope(67, 120.911386497, 0),
new Isotope(68, 121.908548396, 0),
new Isotope(69, 122.908470748, 0),
new Isotope(70, 123.905895774, 0.3717),
new Isotope(71, 124.906398236, 0),
new Isotope(72, 125.904268868, 0.3346),
new Isotope(73, 126.905179581, 0),
new Isotope(74, 127.903530436, 7.1004),
new Isotope(75, 128.904779458, 98.1413),
new Isotope(76, 129.903507903, 15.2416),
new Isotope(77, 130.905081920, 78.8104),
new Isotope(78, 131.904154457, 100.0000),
new Isotope(79, 132.905905660, 0),
new Isotope(80, 133.905394504, 38.6617),
new Isotope(81, 134.907207499, 0),
new Isotope(82, 135.907219526, 33.0855),
new Isotope(83, 136.911562939, 0),
new Isotope(84, 137.913988549, 0),
new Isotope(85, 138.918786859, 0),
new Isotope(86, 139.921635665, 0),
new Isotope(87, 140.926646282, 0),
new Isotope(88, 141.929702981, 0),
new Isotope(89, 142.934890, 0),
new Isotope(90, 143.938230, 0),
new Isotope(91, 144.943670, 0),
new Isotope(92, 145.947300, 0),
new Isotope(93, 146.953010, 0) },
{ new Isotope(57, 111.950331, 0), // 55
new Isotope(58, 112.944535512, 0),
new Isotope(59, 113.940841319, 0),
new Isotope(60, 114.935939, 0),
new Isotope(61, 115.932914152, 0),
new Isotope(62, 116.928639484, 0),
new Isotope(63, 117.926554883, 0),
new Isotope(64, 118.922370879, 0),
new Isotope(65, 119.920678219, 0),
new Isotope(66, 120.917183637, 0),
new Isotope(67, 121.916121946, 0),
new Isotope(68, 122.912990168, 0),
new Isotope(69, 123.912245731, 0),
new Isotope(70, 124.909724871, 0),
new Isotope(71, 125.909447953, 0),
new Isotope(72, 126.907417600, 0),
new Isotope(73, 127.907747919, 0),
new Isotope(74, 128.906063369, 0),
new Isotope(75, 129.906706163, 0),
new Isotope(76, 130.905460232, 0),
new Isotope(77, 131.906429799, 0),
new Isotope(78, 132.905446870, 100.0000),
new Isotope(79, 133.906713419, 0),
new Isotope(80, 134.905971903, 0),
new Isotope(81, 135.907305741, 0),
new Isotope(82, 136.907083505, 0),
new Isotope(83, 137.911010537, 0),
new Isotope(84, 138.913357921, 0),
new Isotope(85, 139.917277075, 0),
new Isotope(86, 140.920043984, 0),
new Isotope(87, 141.924292317, 0),
new Isotope(88, 142.927330292, 0),
new Isotope(89, 143.932027373, 0),
new Isotope(90, 144.935388226, 0),
new Isotope(91, 145.940162028, 0),
new Isotope(92, 146.943864435, 0),
new Isotope(93, 147.948899539, 0),
new Isotope(94, 148.952720, 0),
new Isotope(95, 149.957970, 0),
new Isotope(96, 150.962000, 0) },
{ new Isotope(58, 113.950941, 0), // 56
new Isotope(59, 114.947710, 0),
new Isotope(60, 115.941680, 0),
new Isotope(61, 116.937700229, 0),
new Isotope(62, 117.933440, 0),
new Isotope(63, 118.931051927, 0),
new Isotope(64, 119.926045941, 0),
new Isotope(65, 120.924485908, 0),
new Isotope(66, 121.920260, 0),
new Isotope(67, 122.918850, 0),
new Isotope(68, 123.915088437, 0),
new Isotope(69, 124.914620234, 0),
new Isotope(70, 125.911244146, 0),
new Isotope(71, 126.911121328, 0),
new Isotope(72, 127.908308870, 0),
new Isotope(73, 128.908673749, 0),
new Isotope(74, 129.906310478, 0.1478),
new Isotope(75, 130.906930798, 0),
new Isotope(76, 131.905056152, 0.1409),
new Isotope(77, 132.906002368, 0),
new Isotope(78, 133.904503347, 3.3710),
new Isotope(79, 134.905682749, 9.1939),
new Isotope(80, 135.904570109, 10.9540),
new Isotope(81, 136.905821414, 15.6625),
new Isotope(82, 137.905241273, 100.0000),
new Isotope(83, 138.908835384, 0),
new Isotope(84, 139.910599485, 0),
new Isotope(85, 140.914406439, 0),
new Isotope(86, 141.916448175, 0),
new Isotope(87, 142.920617184, 0),
new Isotope(88, 143.922940468, 0),
new Isotope(89, 144.926923807, 0),
new Isotope(90, 145.930106645, 0),
new Isotope(91, 146.933992519, 0),
new Isotope(92, 147.937682377, 0),
new Isotope(93, 148.942460, 0),
new Isotope(94, 149.945620, 0),
new Isotope(95, 150.950700, 0),
new Isotope(96, 151.954160, 0),
new Isotope(97, 152.959610, 0) },
{ new Isotope(60, 116.950010, 0), // 57
new Isotope(61, 117.946570, 0),
new Isotope(62, 118.940990, 0),
new Isotope(63, 119.938070, 0),
new Isotope(64, 120.933010, 0),
new Isotope(65, 121.930710, 0),
new Isotope(66, 122.926240, 0),
new Isotope(67, 123.924530, 0),
new Isotope(68, 124.920670, 0),
new Isotope(69, 125.919370, 0),
new Isotope(70, 126.916160, 0),
new Isotope(71, 127.915447940, 0),
new Isotope(72, 128.912667334, 0),
new Isotope(73, 129.912320, 0),
new Isotope(74, 130.910108489, 0),
new Isotope(75, 131.910110399, 0),
new Isotope(76, 132.908396372, 0),
new Isotope(77, 133.908489607, 0),
new Isotope(78, 134.906971003, 0),
new Isotope(79, 135.907651181, 0),
new Isotope(80, 136.906465656, 0),
new Isotope(81, 137.907106826, 0.0901),
new Isotope(82, 138.906348160, 100.0000),
new Isotope(83, 139.909472552, 0),
new Isotope(84, 140.910957016, 0),
new Isotope(85, 141.914074489, 0),
new Isotope(86, 142.916058646, 0),
new Isotope(87, 143.919591666, 0),
new Isotope(88, 144.921638370, 0),
new Isotope(89, 145.925700146, 0),
new Isotope(90, 146.927819639, 0),
new Isotope(91, 147.932191197, 0),
new Isotope(92, 148.934370, 0),
new Isotope(93, 149.938570, 0),
new Isotope(94, 150.941560, 0),
new Isotope(95, 151.946110, 0),
new Isotope(96, 152.949450, 0),
new Isotope(97, 153.954400, 0),
new Isotope(98, 154.958130, 0) },
{ new Isotope(61, 118.952760, 0), // 58
new Isotope(62, 119.946640, 0),
new Isotope(63, 120.943670, 0),
new Isotope(64, 121.938010, 0),
new Isotope(65, 122.935510, 0),
new Isotope(66, 123.930520, 0),
new Isotope(67, 124.928540, 0),
new Isotope(68, 125.924100, 0),
new Isotope(69, 126.922750, 0),
new Isotope(70, 127.918870, 0),
new Isotope(71, 128.918679183, 0),
new Isotope(72, 129.914339361, 0),
new Isotope(73, 130.914424137, 0),
new Isotope(74, 131.911490, 0),
new Isotope(75, 132.911550, 0),
new Isotope(76, 133.909026379, 0),
new Isotope(77, 134.909145555, 0),
new Isotope(78, 135.907143574, 0.2147),
new Isotope(79, 136.907777634, 0),
new Isotope(80, 137.905985574, 0.2825),
new Isotope(81, 138.906646605, 0),
new Isotope(82, 139.905434035, 100.0000),
new Isotope(83, 140.908271103, 0),
new Isotope(84, 141.909239733, 12.5226),
new Isotope(85, 142.912381158, 0),
new Isotope(86, 143.913642686, 0),
new Isotope(87, 144.917227871, 0),
new Isotope(88, 145.918689722, 0),
new Isotope(89, 146.922510962, 0),
new Isotope(90, 147.924394738, 0),
new Isotope(91, 148.928289207, 0),
new Isotope(92, 149.930226399, 0),
new Isotope(93, 150.934040, 0),
new Isotope(94, 151.936380, 0),
new Isotope(95, 152.940580, 0),
new Isotope(96, 153.943320, 0),
new Isotope(97, 154.948040, 0),
new Isotope(98, 155.951260, 0),
new Isotope(99, 156.956340, 0) },
{ new Isotope(62, 120.955364, 0), // 59
new Isotope(63, 121.951650, 0),
new Isotope(64, 122.945960, 0),
new Isotope(65, 123.942960, 0),
new Isotope(66, 124.937830, 0),
new Isotope(67, 125.935310, 0),
new Isotope(68, 126.930830, 0),
new Isotope(69, 127.928800, 0),
new Isotope(70, 128.924860, 0),
new Isotope(71, 129.923380, 0),
new Isotope(72, 130.920060245, 0),
new Isotope(73, 131.919120, 0),
new Isotope(74, 132.916200, 0),
new Isotope(75, 133.915672, 0),
new Isotope(76, 134.913139140, 0),
new Isotope(77, 135.912646935, 0),
new Isotope(78, 136.910678351, 0),
new Isotope(79, 137.910748891, 0),
new Isotope(80, 138.908932181, 0),
new Isotope(81, 139.909071204, 0),
new Isotope(82, 140.907647726, 100.0000),
new Isotope(83, 141.910039865, 0),
new Isotope(84, 142.910812233, 0),
new Isotope(85, 143.913300595, 0),
new Isotope(86, 144.914506897, 0),
new Isotope(87, 145.917588016, 0),
new Isotope(88, 146.918979001, 0),
new Isotope(89, 147.922183237, 0),
new Isotope(90, 148.923791056, 0),
new Isotope(91, 149.926995031, 0),
new Isotope(92, 150.928227869, 0),
new Isotope(93, 151.931600, 0),
new Isotope(94, 152.933650, 0),
new Isotope(95, 153.937390, 0),
new Isotope(96, 154.939990, 0),
new Isotope(97, 155.944120, 0),
new Isotope(98, 156.947170, 0),
new Isotope(99, 157.951780, 0),
new Isotope(100, 158.955230, 0) },
{ new Isotope(66, 125.943070, 0), // 60
new Isotope(67, 126.940500, 0),
new Isotope(68, 127.935390, 0),
new Isotope(69, 128.932385, 0),
new Isotope(70, 129.928780, 0),
new Isotope(71, 130.927102697, 0),
new Isotope(72, 131.923120, 0),
new Isotope(73, 132.922210, 0),
new Isotope(74, 133.918645, 0),
new Isotope(75, 134.918240, 0),
new Isotope(76, 135.915020542, 0),
new Isotope(77, 136.914639730, 0),
new Isotope(78, 137.912917450, 0),
new Isotope(79, 138.911924150, 0),
new Isotope(80, 139.909309824, 0),
new Isotope(81, 140.909604800, 0),
new Isotope(82, 141.907718643, 100.0000),
new Isotope(83, 142.909809626, 44.8949),
new Isotope(84, 143.910082629, 87.7258),
new Isotope(85, 144.912568847, 30.5934),
new Isotope(86, 145.913112139, 63.3616),
new Isotope(87, 146.916095794, 0),
new Isotope(88, 147.916888516, 21.2311),
new Isotope(89, 148.920144190, 0),
new Isotope(90, 149.920886563, 20.7888),
new Isotope(91, 150.923824739, 0),
new Isotope(92, 151.924682428, 0),
new Isotope(93, 152.927694534, 0),
new Isotope(94, 153.929483295, 0),
new Isotope(95, 154.932629551, 0),
new Isotope(96, 155.935200, 0),
new Isotope(97, 156.939270, 0),
new Isotope(98, 157.941870, 0),
new Isotope(99, 158.946390, 0),
new Isotope(100, 159.949390, 0),
new Isotope(101, 160.954330, 0) },
{ new Isotope(67, 127.948260, 0), // 61
new Isotope(68, 128.943160, 0),
new Isotope(69, 129.940450, 0),
new Isotope(70, 130.935800, 0),
new Isotope(71, 131.933750, 0),
new Isotope(72, 132.929720, 0),
new Isotope(73, 133.928490, 0),
new Isotope(74, 134.924617, 0),
new Isotope(75, 135.923447865, 0),
new Isotope(76, 136.920713, 0),
new Isotope(77, 137.920432261, 0),
new Isotope(78, 138.916759814, 0),
new Isotope(79, 139.915801649, 0),
new Isotope(80, 140.913606636, 0),
new Isotope(81, 141.912950738, 0),
new Isotope(82, 142.910927571, 0),
new Isotope(83, 143.912585768, 0),
new Isotope(84, 144.912743879, 0),
new Isotope(85, 145.914692165, 0),
new Isotope(86, 146.915133898, 0),
new Isotope(87, 147.917467786, 0),
new Isotope(88, 148.918329195, 0),
new Isotope(89, 149.920979477, 0),
new Isotope(90, 150.921202693, 0),
new Isotope(91, 151.923490557, 0),
new Isotope(92, 152.924113189, 0),
new Isotope(93, 153.926547019, 0),
new Isotope(94, 154.928097047, 0),
new Isotope(95, 155.931060357, 0),
new Isotope(96, 156.933200, 0),
new Isotope(97, 157.936690, 0),
new Isotope(98, 158.939130, 0),
new Isotope(99, 159.942990, 0),
new Isotope(100, 160.945860, 0),
new Isotope(101, 161.950290, 0),
new Isotope(102, 162.953520, 0) },
{ new Isotope(68, 129.948630, 0), // 62
new Isotope(69, 130.945890, 0),
new Isotope(70, 131.940820, 0),
new Isotope(71, 132.938730, 0),
new Isotope(72, 133.934020, 0),
new Isotope(73, 134.932350, 0),
new Isotope(74, 135.928300, 0),
new Isotope(75, 136.927046709, 0),
new Isotope(76, 137.923540, 0),
new Isotope(77, 138.922302000, 0),
new Isotope(78, 139.918991000, 0),
new Isotope(79, 140.918468512, 0),
new Isotope(80, 141.915193274, 0),
new Isotope(81, 142.914623555, 0),
new Isotope(82, 143.911994730, 11.6540),
new Isotope(83, 144.913405611, 0),
new Isotope(84, 145.913036760, 0),
new Isotope(85, 146.914893275, 56.7670),
new Isotope(86, 147.914817914, 42.4810),
new Isotope(87, 148.917179521, 52.2560),
new Isotope(88, 149.917271454, 27.8200),
new Isotope(89, 150.919928351, 0),
new Isotope(90, 151.919728244, 100.0000),
new Isotope(91, 152.922093907, 0),
new Isotope(92, 153.922205303, 84.9620),
new Isotope(93, 154.924635940, 0),
new Isotope(94, 155.925526236, 0),
new Isotope(95, 156.928354506, 0),
new Isotope(96, 157.929987938, 0),
new Isotope(97, 158.933200, 0),
new Isotope(98, 159.935140, 0),
new Isotope(99, 160.938830, 0),
new Isotope(100, 161.941220, 0),
new Isotope(101, 162.945360, 0),
new Isotope(102, 163.948280, 0),
new Isotope(103, 164.952980, 0) },
{ new Isotope(69, 131.954160, 0), // 63
new Isotope(70, 132.948900, 0),
new Isotope(71, 133.946320, 0),
new Isotope(72, 134.941720, 0),
new Isotope(73, 135.939500, 0),
new Isotope(74, 136.935210, 0),
new Isotope(75, 137.933450, 0),
new Isotope(76, 138.928829150, 0),
new Isotope(77, 139.928083921, 0),
new Isotope(78, 140.924885867, 0),
new Isotope(79, 141.923400033, 0),
new Isotope(80, 142.920286634, 0),
new Isotope(81, 143.918774116, 0),
new Isotope(82, 144.916261285, 0),
new Isotope(83, 145.917199714, 0),
new Isotope(84, 146.916741206, 0),
new Isotope(85, 147.918153775, 0),
new Isotope(86, 148.917925922, 0),
new Isotope(87, 149.919698294, 0),
new Isotope(88, 150.919846022, 91.5709),
new Isotope(89, 151.921740399, 0),
new Isotope(90, 152.921226219, 100.0000),
new Isotope(91, 153.922975386, 0),
new Isotope(92, 154.922889429, 0),
new Isotope(93, 155.924750855, 0),
new Isotope(94, 156.925419435, 0),
new Isotope(95, 157.927841923, 0),
new Isotope(96, 158.929084500, 0),
new Isotope(97, 159.931460406, 0),
new Isotope(98, 160.933680, 0),
new Isotope(99, 161.937040, 0),
new Isotope(100, 162.939210, 0),
new Isotope(101, 163.942990, 0),
new Isotope(102, 164.945720, 0),
new Isotope(103, 165.949970, 0),
new Isotope(104, 166.953050, 0) },
{ new Isotope(72, 135.947070, 0), // 64
new Isotope(73, 136.944650, 0),
new Isotope(74, 137.939970, 0),
new Isotope(75, 138.938080, 0),
new Isotope(76, 139.933236934, 0),
new Isotope(77, 140.932210, 0),
new Isotope(78, 141.927908919, 0),
new Isotope(79, 142.926738636, 0),
new Isotope(80, 143.923390357, 0),
new Isotope(81, 144.921687498, 0),
new Isotope(82, 145.918305344, 0),
new Isotope(83, 146.919089446, 0),
new Isotope(84, 147.918109771, 0),
new Isotope(85, 148.919336427, 0),
new Isotope(86, 149.918655455, 0),
new Isotope(87, 150.920344273, 0),
new Isotope(88, 151.919787882, 0.8052),
new Isotope(89, 152.921746283, 0),
new Isotope(90, 153.920862271, 8.7762),
new Isotope(91, 154.922618801, 59.5813),
new Isotope(92, 155.922119552, 82.4074),
new Isotope(93, 156.923956686, 63.0032),
new Isotope(94, 157.924100533, 100.0000),
new Isotope(95, 158.926385075, 0),
new Isotope(96, 159.927050616, 88.0032),
new Isotope(97, 160.929665688, 0),
new Isotope(98, 161.930981211, 0),
new Isotope(99, 162.933990, 0),
new Isotope(100, 163.935860, 0),
new Isotope(101, 164.939380, 0),
new Isotope(102, 165.941600, 0),
new Isotope(103, 166.945570, 0),
new Isotope(104, 167.948360, 0),
new Isotope(105, 168.952870, 0) },
{ new Isotope(73, 137.952870, 0), // 65
new Isotope(74, 138.948030, 0),
new Isotope(75, 139.945367985, 0),
new Isotope(76, 140.941160, 0),
new Isotope(77, 141.939073781, 0),
new Isotope(78, 142.934750, 0),
new Isotope(79, 143.932530, 0),
new Isotope(80, 144.928880, 0),
new Isotope(81, 145.927180629, 0),
new Isotope(82, 146.924037176, 0),
new Isotope(83, 147.924298636, 0),
new Isotope(84, 148.923241630, 0),
new Isotope(85, 149.923654158, 0),
new Isotope(86, 150.923098169, 0),
new Isotope(87, 151.924071324, 0),
new Isotope(88, 152.923430858, 0),
new Isotope(89, 153.924686236, 0),
new Isotope(90, 154.923500411, 0),
new Isotope(91, 155.924743749, 0),
new Isotope(92, 156.924021155, 0),
new Isotope(93, 157.925410260, 0),
new Isotope(94, 158.925343135, 100.0000),
new Isotope(95, 159.927164021, 0),
new Isotope(96, 160.927566289, 0),
new Isotope(97, 161.929484803, 0),
new Isotope(98, 162.930643942, 0),
new Isotope(99, 163.933347253, 0),
new Isotope(100, 164.934880, 0),
new Isotope(101, 165.938050, 0),
new Isotope(102, 166.940050, 0),
new Isotope(103, 167.943640, 0),
new Isotope(104, 168.946220, 0),
new Isotope(105, 169.950250, 0),
new Isotope(106, 170.953300, 0) },
{ new Isotope(74, 139.953790, 0), // 66
new Isotope(75, 140.951190, 0),
new Isotope(76, 141.946695946, 0),
new Isotope(77, 142.943830, 0),
new Isotope(78, 143.939070, 0),
new Isotope(79, 144.936717, 0),
new Isotope(80, 145.932720118, 0),
new Isotope(81, 146.930878496, 0),
new Isotope(82, 147.927177882, 0),
new Isotope(83, 148.927333981, 0),
new Isotope(84, 149.925579728, 0),
new Isotope(85, 150.926179630, 0),
new Isotope(86, 151.924713874, 0),
new Isotope(87, 152.925760865, 0),
new Isotope(88, 153.924422046, 0),
new Isotope(89, 154.925748950, 0),
new Isotope(90, 155.924278273, 0.2128),
new Isotope(91, 156.925461256, 0),
new Isotope(92, 157.924404637, 0.3546),
new Isotope(93, 158.925735660, 0),
new Isotope(94, 159.925193718, 8.2979),
new Isotope(95, 160.926929595, 67.0212),
new Isotope(96, 161.926794731, 90.4255),
new Isotope(97, 162.928727532, 88.2978),
new Isotope(98, 163.929171165, 100.0000),
new Isotope(99, 164.931699828, 0),
new Isotope(100, 165.932803241, 0),
new Isotope(101, 166.935649025, 0),
new Isotope(102, 167.937230, 0),
new Isotope(103, 168.940303648, 0),
new Isotope(104, 169.942670, 0),
new Isotope(105, 170.946480, 0),
new Isotope(106, 171.949110, 0),
new Isotope(107, 172.953440, 0) },
{ new Isotope(75, 141.959860, 0), // 67
new Isotope(76, 142.954690, 0),
new Isotope(77, 143.951640, 0),
new Isotope(78, 144.946880, 0),
new Isotope(79, 145.944100, 0),
new Isotope(80, 146.939840, 0),
new Isotope(81, 147.937269, 0),
new Isotope(82, 148.933789944, 0),
new Isotope(83, 149.932760914, 0),
new Isotope(84, 150.931680791, 0),
new Isotope(85, 151.931740598, 0),
new Isotope(86, 152.930194506, 0),
new Isotope(87, 153.930596268, 0),
new Isotope(88, 154.929079084, 0),
new Isotope(89, 155.929001869, 0),
new Isotope(90, 156.928188059, 0),
new Isotope(91, 157.928945730, 0),
new Isotope(92, 158.927708537, 0),
new Isotope(93, 159.928725679, 0),
new Isotope(94, 160.927851662, 0),
new Isotope(95, 161.929092420, 0),
new Isotope(96, 162.928730286, 0),
new Isotope(97, 163.930230577, 0),
new Isotope(98, 164.930319169, 100.0000),
new Isotope(99, 165.932281267, 0),
new Isotope(100, 166.933126195, 0),
new Isotope(101, 167.935496424, 0),
new Isotope(102, 168.936868306, 0),
new Isotope(103, 169.939614951, 0),
new Isotope(104, 170.941461227, 0),
new Isotope(105, 171.944820, 0),
new Isotope(106, 172.947290, 0),
new Isotope(107, 173.951150, 0),
new Isotope(108, 174.954050, 0) },
{ new Isotope(76, 143.960590, 0), // 68
new Isotope(77, 144.957460, 0),
new Isotope(78, 145.952120, 0),
new Isotope(79, 146.949310, 0),
new Isotope(80, 147.944440, 0),
new Isotope(81, 148.942780527, 0),
new Isotope(82, 149.937171034, 0),
new Isotope(83, 150.937460, 0),
new Isotope(84, 151.935078452, 0),
new Isotope(85, 152.935093125, 0),
new Isotope(86, 153.932777294, 0),
new Isotope(87, 154.933204273, 0),
new Isotope(88, 155.931015001, 0),
new Isotope(89, 156.931945517, 0),
new Isotope(90, 157.929912, 0),
new Isotope(91, 158.930680718, 0),
new Isotope(92, 159.929078924, 0),
new Isotope(93, 160.930001348, 0),
new Isotope(94, 161.928774923, 0.4167),
new Isotope(95, 162.930029273, 0),
new Isotope(96, 163.929196996, 4.7917),
new Isotope(97, 164.930722800, 0),
new Isotope(98, 165.930289970, 100.0000),
new Isotope(99, 166.932045448, 68.3036),
new Isotope(100, 167.932367781, 79.7619),
new Isotope(101, 168.934588082, 0),
new Isotope(102, 169.935460334, 44.3452),
new Isotope(103, 170.938025885, 0),
new Isotope(104, 171.939352149, 0),
new Isotope(105, 172.942400, 0),
new Isotope(106, 173.944340, 0),
new Isotope(107, 174.947930, 0),
new Isotope(108, 175.950290, 0),
new Isotope(109, 176.954370, 0) },
{ new Isotope(77, 145.966495, 0), // 69
new Isotope(78, 146.961081, 0),
new Isotope(79, 147.957550, 0),
new Isotope(80, 148.952650, 0),
new Isotope(81, 149.949670, 0),
new Isotope(82, 150.944842, 0),
new Isotope(83, 151.944300, 0),
new Isotope(84, 152.942027631, 0),
new Isotope(85, 153.940832325, 0),
new Isotope(86, 154.939191562, 0),
new Isotope(87, 155.939006895, 0),
new Isotope(88, 156.936756069, 0),
new Isotope(89, 157.936996, 0),
new Isotope(90, 158.934808966, 0),
new Isotope(91, 159.935090772, 0),
new Isotope(92, 160.933398042, 0),
new Isotope(93, 161.933970147, 0),
new Isotope(94, 162.932647648, 0),
new Isotope(95, 163.933450972, 0),
new Isotope(96, 164.932432463, 0),
new Isotope(97, 165.933553133, 0),
new Isotope(98, 166.932848844, 0),
new Isotope(99, 167.934170375, 0),
new Isotope(100, 168.934211117, 100.0000),
new Isotope(101, 169.935797877, 0),
new Isotope(102, 170.936425817, 0),
new Isotope(103, 171.938396118, 0),
new Isotope(104, 172.939600336, 0),
new Isotope(105, 173.942164618, 0),
new Isotope(106, 174.943832897, 0),
new Isotope(107, 175.946991412, 0),
new Isotope(108, 176.949040, 0),
new Isotope(109, 177.952640, 0),
new Isotope(110, 178.955340, 0) },
{ new Isotope(78, 147.966760, 0), // 70
new Isotope(79, 148.963480, 0),
new Isotope(80, 149.957990, 0),
new Isotope(81, 150.954657965, 0),
new Isotope(82, 151.950167, 0),
new Isotope(83, 152.949210, 0),
new Isotope(84, 153.945651145, 0),
new Isotope(85, 154.945792, 0),
new Isotope(86, 155.942847109, 0),
new Isotope(87, 156.942658650, 0),
new Isotope(88, 157.939857897, 0),
new Isotope(89, 158.940153735, 0),
new Isotope(90, 159.937560, 0),
new Isotope(91, 160.937357719, 0),
new Isotope(92, 161.935750, 0),
new Isotope(93, 162.936265492, 0),
new Isotope(94, 163.934520, 0),
new Isotope(95, 164.935397592, 0),
new Isotope(96, 165.933879623, 0),
new Isotope(97, 166.934946862, 0),
new Isotope(98, 167.933894465, 0.4088),
new Isotope(99, 168.935187120, 0),
new Isotope(100, 169.934758652, 9.5912),
new Isotope(101, 170.936322297, 44.9686),
new Isotope(102, 171.936377696, 68.8679),
new Isotope(103, 172.938206756, 50.6918),
new Isotope(104, 173.938858101, 100.0000),
new Isotope(105, 174.941272494, 0),
new Isotope(106, 175.942568409, 39.9371),
new Isotope(107, 176.945257126, 0),
new Isotope(108, 177.946643396, 0),
new Isotope(109, 178.950170, 0),
new Isotope(110, 179.952330, 0),
new Isotope(111, 180.956150, 0) },
{ new Isotope(79, 149.972668, 0), // 71
new Isotope(80, 150.967147, 0),
new Isotope(81, 151.963610, 0),
new Isotope(82, 152.958690, 0),
new Isotope(83, 153.957100, 0),
new Isotope(84, 154.953641324, 0),
new Isotope(85, 155.952907, 0),
new Isotope(86, 156.950101536, 0),
new Isotope(87, 157.948577981, 0),
new Isotope(88, 158.946615113, 0),
new Isotope(89, 159.945383, 0),
new Isotope(90, 160.943047504, 0),
new Isotope(91, 161.943222, 0),
new Isotope(92, 162.941203796, 0),
new Isotope(93, 163.941215, 0),
new Isotope(94, 164.939605886, 0),
new Isotope(95, 165.939762646, 0),
new Isotope(96, 166.938307056, 0),
new Isotope(97, 167.938698576, 0),
new Isotope(98, 168.937648757, 0),
new Isotope(99, 169.938472190, 0),
new Isotope(100, 170.937909903, 0),
new Isotope(101, 171.939082239, 0),
new Isotope(102, 172.938926901, 0),
new Isotope(103, 173.940333522, 0),
new Isotope(104, 174.940767904, 100.0000),
new Isotope(105, 175.942682399, 2.6694),
new Isotope(106, 176.943754987, 0),
new Isotope(107, 177.945951366, 0),
new Isotope(108, 178.947324216, 0),
new Isotope(109, 179.949879968, 0),
new Isotope(110, 180.951970, 0),
new Isotope(111, 181.955210, 0),
new Isotope(112, 182.957570, 0),
new Isotope(113, 183.961170, 0) },
{ new Isotope(82, 153.964250, 0), // 72
new Isotope(83, 154.962760, 0),
new Isotope(84, 155.959247, 0),
new Isotope(85, 156.958127, 0),
new Isotope(86, 157.954055280, 0),
new Isotope(87, 158.954003, 0),
new Isotope(88, 159.950713588, 0),
new Isotope(89, 160.950330852, 0),
new Isotope(90, 161.947202977, 0),
new Isotope(91, 162.947057, 0),
new Isotope(92, 163.944422, 0),
new Isotope(93, 164.944540, 0),
new Isotope(94, 165.942250, 0),
new Isotope(95, 166.942600, 0),
new Isotope(96, 167.940630, 0),
new Isotope(97, 168.941158567, 0),
new Isotope(98, 169.939650, 0),
new Isotope(99, 170.940490, 0),
new Isotope(100, 171.939457980, 0),
new Isotope(101, 172.940650, 0),
new Isotope(102, 173.940040159, 0.4545),
new Isotope(103, 174.941502991, 0),
new Isotope(104, 175.941401828, 14.7727),
new Isotope(105, 176.943220013, 52.8409),
new Isotope(106, 177.943697732, 76.9886),
new Isotope(107, 178.945815073, 39.0341),
new Isotope(108, 179.946548760, 100.0000),
new Isotope(109, 180.949099124, 0),
new Isotope(110, 181.950552893, 0),
new Isotope(111, 182.953531012, 0),
new Isotope(112, 183.955447880, 0),
new Isotope(113, 184.958780, 0),
new Isotope(114, 185.960920, 0) },
{ new Isotope(83, 155.971689, 0), // 73
new Isotope(84, 156.968145, 0),
new Isotope(85, 157.966368, 0),
new Isotope(86, 158.962323090, 0),
new Isotope(87, 159.961358, 0),
new Isotope(88, 160.958372992, 0),
new Isotope(89, 161.956556553, 0),
new Isotope(90, 162.954316650, 0),
new Isotope(91, 163.953570, 0),
new Isotope(92, 164.950817, 0),
new Isotope(93, 165.950470, 0),
new Isotope(94, 166.948639, 0),
new Isotope(95, 167.947787, 0),
new Isotope(96, 168.945920, 0),
new Isotope(97, 169.946090, 0),
new Isotope(98, 170.944460, 0),
new Isotope(99, 171.944739818, 0),
new Isotope(100, 172.944590, 0),
new Isotope(101, 173.944167937, 0),
new Isotope(102, 174.943650, 0),
new Isotope(103, 175.944740551, 0),
new Isotope(104, 176.944471766, 0),
new Isotope(105, 177.945750349, 0),
new Isotope(106, 178.945934113, 0),
new Isotope(107, 179.947465655, 0.0120),
new Isotope(108, 180.947996346, 100.0000),
new Isotope(109, 181.950152414, 0),
new Isotope(110, 182.951373188, 0),
new Isotope(111, 183.954009331, 0),
new Isotope(112, 184.955559086, 0),
new Isotope(113, 185.958550100, 0),
new Isotope(114, 186.960410, 0),
new Isotope(115, 187.963710, 0) },
{ new Isotope(84, 157.973939, 0), // 74
new Isotope(85, 158.972280, 0),
new Isotope(86, 159.968369, 0),
new Isotope(87, 160.967089, 0),
new Isotope(88, 161.962750303, 0),
new Isotope(89, 162.962532, 0),
new Isotope(90, 163.958983810, 0),
new Isotope(91, 164.958335962, 0),
new Isotope(92, 165.955019896, 0),
new Isotope(93, 166.954672, 0),
new Isotope(94, 167.951863, 0),
new Isotope(95, 168.951759, 0),
new Isotope(96, 169.948473988, 0),
new Isotope(97, 170.949460, 0),
new Isotope(98, 171.948228837, 0),
new Isotope(99, 172.948884, 0),
new Isotope(100, 173.946160, 0),
new Isotope(101, 174.946770, 0),
new Isotope(102, 175.945590, 0),
new Isotope(103, 176.946620, 0),
new Isotope(104, 177.945848364, 0),
new Isotope(105, 178.947071733, 0),
new Isotope(106, 179.946705734, 0.4239),
new Isotope(107, 180.948198054, 0),
new Isotope(108, 181.948205519, 85.7515),
new Isotope(109, 182.950224458, 46.6254),
new Isotope(110, 183.950932553, 100.0000),
new Isotope(111, 184.953420586, 0),
new Isotope(112, 185.954362204, 93.2507),
new Isotope(113, 186.957158365, 0),
new Isotope(114, 187.958486954, 0),
new Isotope(115, 188.961912220, 0),
new Isotope(116, 189.963179541, 0) },
{ new Isotope(85, 159.981485, 0), // 75
new Isotope(86, 160.977661, 0),
new Isotope(87, 161.975707, 0),
new Isotope(88, 162.971375872, 0),
new Isotope(89, 163.970319, 0),
new Isotope(90, 164.967050268, 0),
new Isotope(91, 165.965211372, 0),
new Isotope(92, 166.962564, 0),
new Isotope(93, 167.961609, 0),
new Isotope(94, 168.958830, 0),
new Isotope(95, 169.958163, 0),
new Isotope(96, 170.955547, 0),
new Isotope(97, 171.955285, 0),
new Isotope(98, 172.953062, 0),
new Isotope(99, 173.952114, 0),
new Isotope(100, 174.951393, 0),
new Isotope(101, 175.951570, 0),
new Isotope(102, 176.950270, 0),
new Isotope(103, 177.950851081, 0),
new Isotope(104, 178.949981038, 0),
new Isotope(105, 179.950787680, 0),
new Isotope(106, 180.950064596, 0),
new Isotope(107, 181.951211444, 0),
new Isotope(108, 182.950821349, 0),
new Isotope(109, 183.952524289, 0),
new Isotope(110, 184.952955747, 59.7444),
new Isotope(111, 185.954986529, 0),
new Isotope(112, 186.955750787, 100.0000),
new Isotope(113, 187.958112287, 0),
new Isotope(114, 188.959228359, 0),
new Isotope(115, 189.961816139, 0),
new Isotope(116, 190.963123592, 0),
new Isotope(117, 191.965960, 0) },
{ new Isotope(86, 161.983819, 0), // 76
new Isotope(87, 162.982048, 0),
new Isotope(88, 163.977927, 0),
new Isotope(89, 164.976475, 0),
new Isotope(90, 165.971934911, 0),
new Isotope(91, 166.971554, 0),
new Isotope(92, 167.967832911, 0),
new Isotope(93, 168.967076205, 0),
new Isotope(94, 169.963569716, 0),
new Isotope(95, 170.963040, 0),
new Isotope(96, 171.960078, 0),
new Isotope(97, 172.959791, 0),
new Isotope(98, 173.956307704, 0),
new Isotope(99, 174.957080, 0),
new Isotope(100, 175.953757941, 0),
new Isotope(101, 176.955045, 0),
new Isotope(102, 177.953348225, 0),
new Isotope(103, 178.953951, 0),
new Isotope(104, 179.952308241, 0),
new Isotope(105, 180.953274494, 0),
new Isotope(106, 181.952186222, 0),
new Isotope(107, 182.953110, 0),
new Isotope(108, 183.952490808, 0.488),
new Isotope(109, 184.954043023, 0),
new Isotope(110, 185.953838355, 3.8537),
new Isotope(111, 186.955747928, 3.9024),
new Isotope(112, 187.955835993, 32.4390),
new Isotope(113, 188.958144866, 39.2683),
new Isotope(114, 189.958445210, 64.3902),
new Isotope(115, 190.960927951, 0),
new Isotope(116, 191.961479047, 100.0000),
new Isotope(117, 192.964148083, 0),
new Isotope(118, 193.965179314, 0),
new Isotope(119, 194.968123889, 0),
new Isotope(120, 195.969622550, 0) },
{ new Isotope(88, 164.987580, 0), // 77
new Isotope(89, 165.985506, 0),
new Isotope(90, 166.980951577, 0),
new Isotope(91, 167.979966, 0),
new Isotope(92, 168.976390868, 0),
new Isotope(93, 169.974441697, 0),
new Isotope(94, 170.971779, 0),
new Isotope(95, 171.970643, 0),
new Isotope(96, 172.967707, 0),
new Isotope(97, 173.966804, 0),
new Isotope(98, 174.964279, 0),
new Isotope(99, 175.963511, 0),
new Isotope(100, 176.961170, 0),
new Isotope(101, 177.960084944, 0),
new Isotope(102, 178.959150, 0),
new Isotope(103, 179.958555615, 0),
new Isotope(104, 180.957642156, 0),
new Isotope(105, 181.958127689, 0),
new Isotope(106, 182.956814, 0),
new Isotope(107, 183.957388318, 0),
new Isotope(108, 184.956590, 0),
new Isotope(109, 185.957951104, 0),
new Isotope(110, 186.957360830, 0),
new Isotope(111, 187.958851962, 0),
new Isotope(112, 188.958716473, 0),
new Isotope(113, 189.960592299, 0),
new Isotope(114, 190.960591191, 59.4896),
new Isotope(115, 191.962602198, 0),
new Isotope(116, 192.962923700, 100.0000),
new Isotope(117, 193.965075610, 0),
new Isotope(118, 194.965976800, 0),
new Isotope(119, 195.968379906, 0),
new Isotope(120, 196.969636496, 0),
new Isotope(121, 197.972280, 0),
new Isotope(122, 198.973787159, 0) },
{ new Isotope(90, 167.988035, 0), // 78
new Isotope(91, 168.986421, 0),
new Isotope(92, 169.981734918, 0),
new Isotope(93, 170.981251, 0),
new Isotope(94, 171.977376138, 0),
new Isotope(95, 172.976499642, 0),
new Isotope(96, 173.972811276, 0),
new Isotope(97, 174.972276, 0),
new Isotope(98, 175.969000, 0),
new Isotope(99, 176.968453, 0),
new Isotope(100, 177.964894223, 0),
new Isotope(101, 178.965475, 0),
new Isotope(102, 179.962023729, 0),
new Isotope(103, 180.963177, 0),
new Isotope(104, 181.961267637, 0),
new Isotope(105, 182.961729, 0),
new Isotope(106, 183.959851685, 0),
new Isotope(107, 184.960753782, 0),
new Isotope(108, 185.959432346, 0),
new Isotope(109, 186.960697, 0),
new Isotope(110, 187.959395697, 0),
new Isotope(111, 188.960831900, 0),
new Isotope(112, 189.959930073, 0.0296),
new Isotope(113, 190.961684653, 0),
new Isotope(114, 191.961035158, 2.3373),
new Isotope(115, 192.962984504, 0),
new Isotope(116, 193.962663581, 97.3373),
new Isotope(117, 194.964774449, 100.0000),
new Isotope(118, 195.964934884, 74.8521),
new Isotope(119, 196.967323401, 0),
new Isotope(120, 197.967876009, 21.3018),
new Isotope(121, 198.970576213, 0),
new Isotope(122, 199.971423885, 0),
new Isotope(123, 200.974496467, 0),
new Isotope(124, 201.975740, 0) },
{ new Isotope(92, 170.991183, 0), // 79
new Isotope(93, 171.990109, 0),
new Isotope(94, 172.986398138, 0),
new Isotope(95, 173.984325861, 0),
new Isotope(96, 174.981552, 0),
new Isotope(97, 175.980269, 0),
new Isotope(98, 176.977215, 0),
new Isotope(99, 177.975975, 0),
new Isotope(100, 178.973412, 0),
new Isotope(101, 179.972396, 0),
new Isotope(102, 180.969948, 0),
new Isotope(103, 181.968621416, 0),
new Isotope(104, 182.967620, 0),
new Isotope(105, 183.966776046, 0),
new Isotope(106, 184.965806956, 0),
new Isotope(107, 185.965997671, 0),
new Isotope(108, 186.964562, 0),
new Isotope(109, 187.965321662, 0),
new Isotope(110, 188.964224300, 0),
new Isotope(111, 189.964698757, 0),
new Isotope(112, 190.963649239, 0),
new Isotope(113, 191.964810107, 0),
new Isotope(114, 192.964131745, 0),
new Isotope(115, 193.965338890, 0),
new Isotope(116, 194.965017928, 0),
new Isotope(117, 195.966551315, 0),
new Isotope(118, 196.966551609, 100.0000),
new Isotope(119, 197.968225244, 0),
new Isotope(120, 198.968748016, 0),
new Isotope(121, 199.970717886, 0),
new Isotope(122, 200.971640839, 0),
new Isotope(123, 201.973788431, 0),
new Isotope(124, 202.975137256, 0),
new Isotope(125, 203.977705, 0),
new Isotope(126, 204.979610, 0) },
{ new Isotope(95, 174.991411, 0), // 80
new Isotope(96, 175.987413248, 0),
new Isotope(97, 176.986336874, 0),
new Isotope(98, 177.982476325, 0),
new Isotope(99, 178.981783, 0),
new Isotope(100, 179.978322, 0),
new Isotope(101, 180.977806, 0),
new Isotope(102, 181.973935460, 0),
new Isotope(103, 182.974561, 0),
new Isotope(104, 183.970705219, 0),
new Isotope(105, 184.971983, 0),
new Isotope(106, 185.969460021, 0),
new Isotope(107, 186.969785, 0),
new Isotope(108, 187.967511693, 0),
new Isotope(109, 188.968733187, 0),
new Isotope(110, 189.966958568, 0),
new Isotope(111, 190.967063110, 0),
new Isotope(112, 191.965921572, 0),
new Isotope(113, 192.966644169, 0),
new Isotope(114, 193.965381832, 0),
new Isotope(115, 194.966638981, 0),
new Isotope(116, 195.965814846, 0.5059),
new Isotope(117, 196.967195333, 0),
new Isotope(118, 197.966751830, 34.0641),
new Isotope(119, 198.968262489, 57.3356),
new Isotope(120, 199.968308726, 77.9089),
new Isotope(121, 200.970285275, 44.5194),
new Isotope(122, 201.970625604, 100.0000),
new Isotope(123, 202.972857096, 0),
new Isotope(124, 203.973475640, 22.9342),
new Isotope(125, 204.976056104, 0),
new Isotope(126, 205.977498672, 0),
new Isotope(127, 206.982577025, 0),
new Isotope(128, 207.985940, 0) },
{ new Isotope(96, 176.996881, 0), // 81
new Isotope(97, 177.994637, 0),
new Isotope(98, 178.991466, 0),
new Isotope(99, 179.990194, 0),
new Isotope(100, 180.986904, 0),
new Isotope(101, 181.985610, 0),
new Isotope(102, 182.982697, 0),
new Isotope(103, 183.981760, 0),
new Isotope(104, 184.979100, 0),
new Isotope(105, 185.977549881, 0),
new Isotope(106, 186.976170, 0),
new Isotope(107, 187.975920, 0),
new Isotope(108, 188.974290451, 0),
new Isotope(109, 189.974473379, 0),
new Isotope(110, 190.972261952, 0),
new Isotope(111, 191.972770785, 0),
new Isotope(112, 192.970548, 0),
new Isotope(113, 193.971053, 0),
new Isotope(114, 194.969650, 0),
new Isotope(115, 195.970515, 0),
new Isotope(116, 196.969536200, 0),
new Isotope(117, 197.970466294, 0),
new Isotope(118, 198.969813837, 0),
new Isotope(119, 199.970945394, 0),
new Isotope(120, 200.970803770, 0),
new Isotope(121, 201.972090569, 0),
new Isotope(122, 202.972329088, 41.8922),
new Isotope(123, 203.973848646, 0),
new Isotope(124, 204.974412270, 100.0000),
new Isotope(125, 205.976095321, 0),
new Isotope(126, 206.977407908, 0),
new Isotope(127, 207.982004653, 0),
new Isotope(128, 208.985349125, 0),
new Isotope(129, 209.990065574, 0) },
{ new Isotope(99, 180.996714, 0), // 82
new Isotope(100, 181.992676101, 0),
new Isotope(101, 182.991930, 0),
new Isotope(102, 183.988198, 0),
new Isotope(103, 184.987580, 0),
new Isotope(104, 185.983485388, 0),
new Isotope(105, 186.984030, 0),
new Isotope(106, 187.979869108, 0),
new Isotope(107, 188.980880, 0),
new Isotope(108, 189.978180008, 0),
new Isotope(109, 190.978200, 0),
new Isotope(110, 191.975719811, 0),
new Isotope(111, 192.976080, 0),
new Isotope(112, 193.974648056, 0),
new Isotope(113, 194.975920279, 0),
new Isotope(114, 195.972710, 0),
new Isotope(115, 196.973380, 0),
new Isotope(116, 197.971980, 0),
new Isotope(117, 198.972909384, 0),
new Isotope(118, 199.971815560, 0),
new Isotope(119, 200.972846589, 0),
new Isotope(120, 201.972143786, 0),
new Isotope(121, 202.973375491, 0),
new Isotope(122, 203.973028761, 2.6718),
new Isotope(123, 204.974467112, 0),
new Isotope(124, 205.974449002, 45.9923),
new Isotope(125, 206.975880605, 42.1756),
new Isotope(126, 207.976635850, 100.0000),
new Isotope(127, 208.981074801, 0),
new Isotope(128, 209.984173129, 0),
new Isotope(129, 210.988731474, 0),
new Isotope(130, 211.991887495, 0),
new Isotope(131, 212.996500, 0),
new Isotope(132, 213.999798147, 0) },
{ new Isotope(102, 184.997708, 0), // 83
new Isotope(103, 185.996480, 0),
new Isotope(104, 186.993458, 0),
new Isotope(105, 187.992173, 0),
new Isotope(106, 188.989505, 0),
new Isotope(107, 189.987520007, 0),
new Isotope(108, 190.986053, 0),
new Isotope(109, 191.985368, 0),
new Isotope(110, 192.983662229, 0),
new Isotope(111, 193.983430186, 0),
new Isotope(112, 194.981126970, 0),
new Isotope(113, 195.981236107, 0),
new Isotope(114, 196.978934287, 0),
new Isotope(115, 197.979024396, 0),
new Isotope(116, 198.977576953, 0),
new Isotope(117, 199.978141983, 0),
new Isotope(118, 200.976970721, 0),
new Isotope(119, 201.977674504, 0),
new Isotope(120, 202.976868118, 0),
new Isotope(121, 203.977805161, 0),
new Isotope(122, 204.977374688, 0),
new Isotope(123, 205.978482854, 0),
new Isotope(124, 206.978455217, 0),
new Isotope(125, 207.979726699, 0),
new Isotope(126, 208.980383241, 100.0000),
new Isotope(127, 209.984104944, 0),
new Isotope(128, 210.987258139, 0),
new Isotope(129, 211.991271542, 0),
new Isotope(130, 212.994374836, 0),
new Isotope(131, 213.998698664, 0),
new Isotope(132, 215.001832349, 0),
new Isotope(133, 216.006199, 0) },
{ new Isotope(106, 189.994293888, 0), // 84
new Isotope(107, 190.994653, 0),
new Isotope(108, 191.990330390, 0),
new Isotope(109, 192.991102, 0),
new Isotope(110, 193.988284107, 0),
new Isotope(111, 194.988045, 0),
new Isotope(112, 195.985469432, 0),
new Isotope(113, 196.985567, 0),
new Isotope(114, 197.984024384, 0),
new Isotope(115, 198.985044507, 0),
new Isotope(116, 199.981735, 0),
new Isotope(117, 200.982209, 0),
new Isotope(118, 201.980704, 0),
new Isotope(119, 202.981412863, 0),
new Isotope(120, 203.980307113, 0),
new Isotope(121, 204.981165396, 0),
new Isotope(122, 205.980465241, 0),
new Isotope(123, 206.981578228, 0),
new Isotope(124, 207.981231059, 0),
new Isotope(125, 208.982415788, 0),
new Isotope(126, 209.982857396, 0),
new Isotope(127, 210.986636869, 0),
new Isotope(128, 211.988851755, 0),
new Isotope(129, 212.992842522, 0),
new Isotope(130, 213.995185949, 0),
new Isotope(131, 214.999414609, 0),
new Isotope(132, 216.001905198, 0),
new Isotope(133, 217.006253, 0),
new Isotope(134, 218.008965773, 0) },
{ new Isotope(108, 193.000188, 0), // 85
new Isotope(109, 193.997973, 0),
new Isotope(110, 194.996554, 0),
new Isotope(111, 195.995702, 0),
new Isotope(112, 196.993891293, 0),
new Isotope(113, 197.993433680, 0),
new Isotope(114, 198.991008569, 0),
new Isotope(115, 199.990920883, 0),
new Isotope(116, 200.988486908, 0),
new Isotope(117, 201.988448629, 0),
new Isotope(118, 202.986847216, 0),
new Isotope(119, 203.987261559, 0),
new Isotope(120, 204.986036352, 0),
new Isotope(121, 205.986599242, 0),
new Isotope(122, 206.985775861, 0),
new Isotope(123, 207.986582508, 0),
new Isotope(124, 208.986158678, 0),
new Isotope(125, 209.987131308, 0),
new Isotope(126, 210.987480806, 0),
new Isotope(127, 211.990734657, 0),
new Isotope(128, 212.992921150, 0),
new Isotope(129, 213.996356412, 0),
new Isotope(130, 214.998641245, 0),
new Isotope(131, 216.002408839, 0),
new Isotope(132, 217.004709619, 0),
new Isotope(133, 218.008681458, 0),
new Isotope(134, 219.011296478, 0),
new Isotope(135, 220.015301, 0),
new Isotope(136, 221.018140, 0),
new Isotope(137, 222.022330, 0),
new Isotope(138, 223.025340, 0) },
{ new Isotope(110, 196.001117268, 0), // 86
new Isotope(111, 197.001661, 0),
new Isotope(112, 197.998779978, 0),
new Isotope(113, 198.998309, 0),
new Isotope(114, 199.995634148, 0),
new Isotope(115, 200.995535, 0),
new Isotope(116, 201.993899382, 0),
new Isotope(117, 202.994765192, 0),
new Isotope(118, 203.991365, 0),
new Isotope(119, 204.991668, 0),
new Isotope(120, 205.990160, 0),
new Isotope(121, 206.990726826, 0),
new Isotope(122, 207.989631237, 0),
new Isotope(123, 208.990376634, 0),
new Isotope(124, 209.989679862, 0),
new Isotope(125, 210.990585410, 0),
new Isotope(126, 211.990688899, 0),
new Isotope(127, 212.993868354, 0),
new Isotope(128, 213.995346275, 0),
new Isotope(129, 214.998729195, 0),
new Isotope(130, 216.000258153, 0),
new Isotope(131, 217.003914555, 0),
new Isotope(132, 218.005586315, 0),
new Isotope(133, 219.009474831, 0),
new Isotope(134, 220.011384149, 0),
new Isotope(135, 221.015455, 0),
new Isotope(136, 222.017570472, 0),
new Isotope(137, 223.021790, 0),
new Isotope(138, 224.024090, 0),
new Isotope(139, 225.028440, 0),
new Isotope(140, 226.030890, 0),
new Isotope(141, 227.035407, 0),
new Isotope(142, 228.038084, 0) },
{ new Isotope(113, 200.006499, 0), // 87
new Isotope(114, 201.004586920, 0),
new Isotope(115, 202.003968850, 0),
new Isotope(116, 203.001423829, 0),
new Isotope(117, 204.001221209, 0),
new Isotope(118, 204.998663961, 0),
new Isotope(119, 205.998486886, 0),
new Isotope(120, 206.996859385, 0),
new Isotope(121, 207.997133849, 0),
new Isotope(122, 208.995915421, 0),
new Isotope(123, 209.996398327, 0),
new Isotope(124, 210.995529332, 0),
new Isotope(125, 211.996194988, 0),
new Isotope(126, 212.996174845, 0),
new Isotope(127, 213.998954740, 0),
new Isotope(128, 215.000326029, 0),
new Isotope(129, 216.003187873, 0),
new Isotope(130, 217.004616452, 0),
new Isotope(131, 218.007563326, 0),
new Isotope(132, 219.009240843, 0),
new Isotope(133, 220.012312978, 0),
new Isotope(134, 221.014245654, 0),
new Isotope(135, 222.017543957, 0),
new Isotope(136, 223.019730712, 0),
new Isotope(137, 224.023235513, 0),
new Isotope(138, 225.025606914, 0),
new Isotope(139, 226.029343423, 0),
new Isotope(140, 227.031833167, 0),
new Isotope(141, 228.034776087, 0),
new Isotope(142, 229.038426, 0),
new Isotope(143, 230.042510, 0),
new Isotope(144, 231.045407, 0),
new Isotope(145, 232.049654, 0) },
{ new Isotope(115, 203.009210, 0), // 88
new Isotope(116, 204.006434513, 0),
new Isotope(117, 205.006187, 0),
new Isotope(118, 206.004463814, 0),
new Isotope(119, 207.005176607, 0),
new Isotope(120, 208.001776, 0),
new Isotope(121, 209.001944, 0),
new Isotope(122, 210.000446, 0),
new Isotope(123, 211.000893996, 0),
new Isotope(124, 211.999783492, 0),
new Isotope(125, 213.000345847, 0),
new Isotope(126, 214.000091141, 0),
new Isotope(127, 215.002704195, 0),
new Isotope(128, 216.003518402, 0),
new Isotope(129, 217.006306010, 0),
new Isotope(130, 218.007123948, 0),
new Isotope(131, 219.010068787, 0),
new Isotope(132, 220.011014669, 0),
new Isotope(133, 221.013907762, 0),
new Isotope(134, 222.015361820, 0),
new Isotope(135, 223.018497140, 0),
new Isotope(136, 224.020202004, 0),
new Isotope(137, 225.023604463, 0),
new Isotope(138, 226.025402555, 0),
new Isotope(139, 227.029170677, 0),
new Isotope(140, 228.031064101, 0),
new Isotope(141, 229.034820309, 0),
new Isotope(142, 230.037084774, 0),
new Isotope(143, 231.041220, 0),
new Isotope(144, 232.043693, 0),
new Isotope(145, 233.047995, 0),
new Isotope(146, 234.050547, 0) },
{ new Isotope(118, 207.012469754, 0), // 89
new Isotope(119, 208.012112949, 0),
new Isotope(120, 209.009568736, 0),
new Isotope(121, 210.009256802, 0),
new Isotope(122, 211.007648196, 0),
new Isotope(123, 212.007811441, 0),
new Isotope(124, 213.006573689, 0),
new Isotope(125, 214.006893072, 0),
new Isotope(126, 215.006450832, 0),
new Isotope(127, 216.008721268, 0),
new Isotope(128, 217.009332676, 0),
new Isotope(129, 218.011625045, 0),
new Isotope(130, 219.012404918, 0),
new Isotope(131, 220.014752105, 0),
new Isotope(132, 221.015575746, 0),
new Isotope(133, 222.017828852, 0),
new Isotope(134, 223.019126030, 0),
new Isotope(135, 224.021708435, 0),
new Isotope(136, 225.023220576, 0),
new Isotope(137, 226.026089848, 0),
new Isotope(138, 227.027746979, 0),
new Isotope(139, 228.031014825, 0),
new Isotope(140, 229.032930871, 0),
new Isotope(141, 230.036025144, 0),
new Isotope(142, 231.038551503, 0),
new Isotope(143, 232.042022474, 0),
new Isotope(144, 233.044550, 0),
new Isotope(145, 234.048420, 0),
new Isotope(146, 235.051102, 0),
new Isotope(147, 236.055178, 0) },
{ new Isotope(120, 210.015711883, 0), // 90
new Isotope(121, 211.016306912, 0),
new Isotope(122, 212.012916, 0),
new Isotope(123, 213.012962, 0),
new Isotope(124, 214.011451, 0),
new Isotope(125, 215.011726597, 0),
new Isotope(126, 216.011050963, 0),
new Isotope(127, 217.013066169, 0),
new Isotope(128, 218.013267744, 0),
new Isotope(129, 219.015521253, 0),
new Isotope(130, 220.015733126, 0),
new Isotope(131, 221.018171499, 0),
new Isotope(132, 222.018454131, 0),
new Isotope(133, 223.020795153, 0),
new Isotope(134, 224.021459250, 0),
new Isotope(135, 225.023941441, 0),
new Isotope(136, 226.024890681, 0),
new Isotope(137, 227.027698859, 0),
new Isotope(138, 228.028731348, 0),
new Isotope(139, 229.031755340, 0),
new Isotope(140, 230.033126574, 0),
new Isotope(141, 231.036297060, 0),
new Isotope(142, 232.038050360, 100.0000),
new Isotope(143, 233.041576923, 0),
new Isotope(144, 234.043595497, 0),
new Isotope(145, 235.047504420, 0),
new Isotope(146, 236.049710, 0),
new Isotope(147, 237.053894, 0),
new Isotope(148, 238.056243, 0) },
{ new Isotope(122, 213.021183209, 0), // 91
new Isotope(123, 214.020739230, 0),
new Isotope(124, 215.019097612, 0),
new Isotope(125, 216.019109649, 0),
new Isotope(126, 217.018288571, 0),
new Isotope(127, 218.020007906, 0),
new Isotope(128, 219.019880348, 0),
new Isotope(129, 220.021876493, 0),
new Isotope(130, 221.021863742, 0),
new Isotope(131, 222.023726, 0),
new Isotope(132, 223.023963748, 0),
new Isotope(133, 224.025614854, 0),
new Isotope(134, 225.026115172, 0),
new Isotope(135, 226.027932750, 0),
new Isotope(136, 227.028793151, 0),
new Isotope(137, 228.031036942, 0),
new Isotope(138, 229.032088601, 0),
new Isotope(139, 230.034532562, 0),
new Isotope(140, 231.035878898, 0),
new Isotope(141, 232.038581720, 0),
new Isotope(142, 233.040240235, 0),
new Isotope(143, 234.043302325, 0),
new Isotope(144, 235.045436759, 0),
new Isotope(145, 236.048675176, 0),
new Isotope(146, 237.051139430, 0),
new Isotope(147, 238.054497046, 0),
new Isotope(148, 239.057130, 0),
new Isotope(149, 240.060980, 0) },
{ new Isotope(126, 218.023487, 0), // 92
new Isotope(127, 219.024915423, 0),
new Isotope(128, 220.024712, 0),
new Isotope(129, 221.026351, 0),
new Isotope(130, 222.026070, 0),
new Isotope(131, 223.027722956, 0),
new Isotope(132, 224.027590139, 0),
new Isotope(133, 225.029384369, 0),
new Isotope(134, 226.029339750, 0),
new Isotope(135, 227.031140069, 0),
new Isotope(136, 228.031366357, 0),
new Isotope(137, 229.033496137, 0),
new Isotope(138, 230.033927392, 0),
new Isotope(139, 231.036289158, 0),
new Isotope(140, 232.037146280, 0),
new Isotope(141, 233.039628196, 0),
new Isotope(142, 234.040945606, 0.0055),
new Isotope(143, 235.043923062, 0.7253),
new Isotope(144, 236.045561897, 0),
new Isotope(145, 237.048723955, 0),
new Isotope(146, 238.050782583, 100.0000),
new Isotope(147, 239.054287777, 0),
new Isotope(148, 240.056585734, 0),
new Isotope(149, 241.060330, 0),
new Isotope(150, 242.062925, 0) },
{ new Isotope(132, 225.033899689, 0), // 93
new Isotope(133, 226.035129, 0),
new Isotope(134, 227.034958261, 0),
new Isotope(135, 228.036180, 0),
new Isotope(136, 229.036246866, 0),
new Isotope(137, 230.037812591, 0),
new Isotope(138, 231.038233161, 0),
new Isotope(139, 232.040099, 0),
new Isotope(140, 233.040732350, 0),
new Isotope(141, 234.042888556, 0),
new Isotope(142, 235.044055876, 0),
new Isotope(143, 236.046559724, 0),
new Isotope(144, 237.048167253, 0),
new Isotope(145, 238.050940464, 0),
new Isotope(146, 239.052931399, 0),
new Isotope(147, 240.056168828, 0),
new Isotope(148, 241.058246266, 0),
new Isotope(149, 242.061635, 0),
new Isotope(150, 243.064273, 0),
new Isotope(151, 244.067850, 0) },
{ new Isotope(134, 228.038727686, 0), // 94
new Isotope(135, 229.040138934, 0),
new Isotope(136, 230.039645603, 0),
new Isotope(137, 231.041258, 0),
new Isotope(138, 232.041179445, 0),
new Isotope(139, 233.042987570, 0),
new Isotope(140, 234.043304681, 0),
new Isotope(141, 235.045281500, 0),
new Isotope(142, 236.046048088, 0),
new Isotope(143, 237.048403774, 0),
new Isotope(144, 238.049553400, 0),
new Isotope(145, 239.052156519, 0),
new Isotope(146, 240.053807460, 0),
new Isotope(147, 241.056845291, 0),
new Isotope(148, 242.058736847, 0),
new Isotope(149, 243.061997013, 0),
new Isotope(150, 244.064197650, 0),
new Isotope(151, 245.067738657, 0),
new Isotope(152, 246.070198429, 0),
new Isotope(153, 247.074070, 0) },
{ new Isotope(136, 231.045560, 0), // 95
new Isotope(137, 232.046590, 0),
new Isotope(138, 233.046472, 0),
new Isotope(139, 234.047794, 0),
new Isotope(140, 235.048029, 0),
new Isotope(141, 236.049569, 0),
new Isotope(142, 237.049970748, 0),
new Isotope(143, 238.051977839, 0),
new Isotope(144, 239.053018481, 0),
new Isotope(145, 240.055287826, 0),
new Isotope(146, 241.056822944, 0),
new Isotope(147, 242.059543039, 0),
new Isotope(148, 243.061372686, 0),
new Isotope(149, 244.064279429, 0),
new Isotope(150, 245.066445398, 0),
new Isotope(151, 246.069768438, 0),
new Isotope(152, 247.072086, 0),
new Isotope(153, 248.075745, 0),
new Isotope(154, 249.078480, 0) },
{ new Isotope(137, 233.050800, 0), // 96
new Isotope(138, 234.050240, 0),
new Isotope(139, 235.051591, 0),
new Isotope(140, 236.051405, 0),
new Isotope(141, 237.052891, 0),
new Isotope(142, 238.053016298, 0),
new Isotope(143, 239.054951, 0),
new Isotope(144, 240.055519046, 0),
new Isotope(145, 241.057646736, 0),
new Isotope(146, 242.058829326, 0),
new Isotope(147, 243.061382249, 0),
new Isotope(148, 244.062746349, 0),
new Isotope(149, 245.065485586, 0),
new Isotope(150, 246.067217551, 0),
new Isotope(151, 247.070346811, 0),
new Isotope(152, 248.072342247, 0),
new Isotope(153, 249.075947062, 0),
new Isotope(154, 250.078350687, 0),
new Isotope(155, 251.082277873, 0),
new Isotope(156, 252.084870, 0) },
{ new Isotope(138, 235.056580, 0), // 97
new Isotope(139, 236.057330, 0),
new Isotope(140, 237.057127, 0),
new Isotope(141, 238.058266, 0),
new Isotope(142, 239.058362, 0),
new Isotope(143, 240.059749, 0),
new Isotope(144, 241.060223, 0),
new Isotope(145, 242.062050, 0),
new Isotope(146, 243.063001570, 0),
new Isotope(147, 244.065167882, 0),
new Isotope(148, 245.066355386, 0),
new Isotope(149, 246.068666836, 0),
new Isotope(150, 247.070298533, 0),
new Isotope(151, 248.073080, 0),
new Isotope(152, 249.074979937, 0),
new Isotope(153, 250.078310529, 0),
new Isotope(154, 251.080753440, 0),
new Isotope(155, 252.084303, 0),
new Isotope(156, 253.086880, 0),
new Isotope(157, 254.090600, 0) },
{ new Isotope(139, 237.062070, 0), // 98
new Isotope(140, 238.061410, 0),
new Isotope(141, 239.062579, 0),
new Isotope(142, 240.062295, 0),
new Isotope(143, 241.063716, 0),
new Isotope(144, 242.063688713, 0),
new Isotope(145, 243.065421, 0),
new Isotope(146, 244.065990390, 0),
new Isotope(147, 245.068039, 0),
new Isotope(148, 246.068798807, 0),
new Isotope(149, 247.070992043, 0),
new Isotope(150, 248.072178080, 0),
new Isotope(151, 249.074846818, 0),
new Isotope(152, 250.076399951, 0),
new Isotope(153, 251.079580056, 0),
new Isotope(154, 252.081619582, 0),
new Isotope(155, 253.085126791, 0),
new Isotope(156, 254.087316198, 0),
new Isotope(157, 255.091039, 0),
new Isotope(158, 256.093440, 0) },
{ new Isotope(141, 240.068920, 0), // 99
new Isotope(142, 241.068662, 0),
new Isotope(143, 242.069699, 0),
new Isotope(144, 243.069631, 0),
new Isotope(145, 244.070969, 0),
new Isotope(146, 245.071317, 0),
new Isotope(147, 246.072965, 0),
new Isotope(148, 247.073650, 0),
new Isotope(149, 248.075458, 0),
new Isotope(150, 249.076405, 0),
new Isotope(151, 250.078654, 0),
new Isotope(152, 251.079983592, 0),
new Isotope(153, 252.082972247, 0),
new Isotope(154, 253.084817974, 0),
new Isotope(155, 254.088016026, 0),
new Isotope(156, 255.090266386, 0),
new Isotope(157, 256.093592, 0),
new Isotope(158, 257.095979, 0) },
{ new Isotope(142, 242.073430, 0), // 100
new Isotope(143, 243.074510, 0),
new Isotope(144, 244.074077, 0),
new Isotope(145, 245.075375, 0),
new Isotope(146, 246.075281634, 0),
new Isotope(147, 247.076819, 0),
new Isotope(148, 248.077184411, 0),
new Isotope(149, 249.079024, 0),
new Isotope(150, 250.079514759, 0),
new Isotope(151, 251.081566467, 0),
new Isotope(152, 252.082460071, 0),
new Isotope(153, 253.085176259, 0),
new Isotope(154, 254.086847795, 0),
new Isotope(155, 255.089955466, 0),
new Isotope(156, 256.091766522, 0),
new Isotope(157, 257.095098635, 0),
new Isotope(158, 258.097069, 0),
new Isotope(159, 259.100588, 0) },
{ new Isotope(144, 245.081017, 0), // 101
new Isotope(145, 246.081933, 0),
new Isotope(146, 247.081804, 0),
new Isotope(147, 248.082909, 0),
new Isotope(148, 249.083002, 0),
new Isotope(149, 250.084488, 0),
new Isotope(150, 251.084919, 0),
new Isotope(151, 252.086630, 0),
new Isotope(152, 253.087280, 0),
new Isotope(153, 254.089725, 0),
new Isotope(154, 255.091075196, 0),
new Isotope(155, 256.094052757, 0),
new Isotope(156, 257.095534643, 0),
new Isotope(157, 258.098425321, 0),
new Isotope(158, 259.100503, 0),
new Isotope(159, 260.103645, 0) },
{ new Isotope(147, 249.087823, 0), // 102
new Isotope(148, 250.087493, 0),
new Isotope(149, 251.088960, 0),
new Isotope(150, 252.088965909, 0),
new Isotope(151, 253.090649, 0),
new Isotope(152, 254.090948746, 0),
new Isotope(153, 255.093232449, 0),
new Isotope(154, 256.094275879, 0),
new Isotope(155, 257.096852778, 0),
new Isotope(156, 258.098200, 0),
new Isotope(157, 259.101024, 0),
new Isotope(158, 260.102636, 0),
new Isotope(159, 261.105743, 0),
new Isotope(160, 262.107520, 0) },
{ new Isotope(148, 251.094360, 0), // 103
new Isotope(149, 252.095330, 0),
new Isotope(150, 253.095258, 0),
new Isotope(151, 254.096587, 0),
new Isotope(152, 255.096769, 0),
new Isotope(153, 256.098763, 0),
new Isotope(154, 257.099606, 0),
new Isotope(155, 258.101883, 0),
new Isotope(156, 259.102990, 0),
new Isotope(157, 260.105572, 0),
new Isotope(158, 261.106941, 0),
new Isotope(159, 262.109692, 0),
new Isotope(160, 263.111394, 0) },
{ new Isotope(149, 253.100679, 0), // 104
new Isotope(150, 254.100166, 0),
new Isotope(151, 255.101492, 0),
new Isotope(152, 256.101179573, 0),
new Isotope(153, 257.103072, 0),
new Isotope(154, 258.103568, 0),
new Isotope(155, 259.105628, 0),
new Isotope(156, 260.106434, 0),
new Isotope(157, 261.108752, 0),
new Isotope(158, 262.109918, 0),
new Isotope(159, 263.112540, 0),
new Isotope(160, 264.113978, 0) },
{ new Isotope(150, 255.107398, 0), // 105
new Isotope(151, 256.108110, 0),
new Isotope(152, 257.107858, 0),
new Isotope(153, 258.109438, 0),
new Isotope(154, 259.109721, 0),
new Isotope(155, 260.111427, 0),
new Isotope(156, 261.112106, 0),
new Isotope(157, 262.114153, 0),
new Isotope(158, 263.115078, 0),
new Isotope(159, 264.117473, 0),
new Isotope(160, 265.118659, 0) },
{ new Isotope(152, 258.113151, 0), // 106
new Isotope(153, 259.114652, 0),
new Isotope(154, 260.114435447, 0),
new Isotope(155, 261.116199, 0),
new Isotope(156, 262.116477, 0),
new Isotope(157, 263.118313, 0),
new Isotope(158, 264.118924, 0),
new Isotope(159, 265.121066, 0),
new Isotope(160, 266.121928, 0) },
{ new Isotope(153, 260.121803, 0), // 107
new Isotope(154, 261.121800, 0),
new Isotope(155, 262.123009, 0),
new Isotope(156, 263.123146, 0),
new Isotope(157, 264.124730, 0),
new Isotope(158, 265.125198, 0),
new Isotope(159, 266.127009, 0),
new Isotope(160, 267.127740, 0) },
{ new Isotope(155, 263.128710, 0), // 108
new Isotope(156, 264.128408258, 0),
new Isotope(157, 265.130001, 0),
new Isotope(158, 266.130042, 0),
new Isotope(159, 267.131774, 0),
new Isotope(160, 268.132156, 0),
new Isotope(161, 269.134114, 0) },
{ new Isotope(156, 265.136567, 0), // 109
new Isotope(157, 266.137940, 0),
new Isotope(158, 267.137526, 0),
new Isotope(159, 268.138816, 0),
new Isotope(160, 269.139106, 0),
new Isotope(161, 270.140723, 0),
new Isotope(162, 271.141229, 0) } };
public static int[] getIsotopeList(int atomicNo) {
int[] isotopeList = new int[sIsotope[atomicNo].length];
for (int i=0; i<sIsotope[atomicNo].length; i++)
isotopeList[i] = atomicNo + sIsotope[atomicNo][i].neutrones;
return isotopeList;
}
public static double getAbsoluteMass(int atomicNo, int mass) {
int neutrones = mass - atomicNo;
for (int i=0; i<sIsotope[atomicNo].length; i++)
if (sIsotope[atomicNo][i].neutrones == neutrones)
return sIsotope[atomicNo][i].absoluteMass;
return Double.NaN;
}
public static double getNaturalPercentage(int atomicNo, int mass) {
int neutrones = mass - atomicNo;
for (int i=0; i<sIsotope[atomicNo].length; i++)
if (sIsotope[atomicNo][i].neutrones == neutrones)
return sIsotope[atomicNo][i].percentage;
return Double.NaN;
}
}
class Isotope {
protected int neutrones;
protected double absoluteMass;
protected double percentage;
protected Isotope(int neutrones, double absoluteMass, double percentage) {
this.neutrones = neutrones;
this.absoluteMass = absoluteMass;
this.percentage = percentage;
}
}
|
egonw/openchemlib
|
src/com/actelion/research/chem/IsotopeHelper.java
|
Java
|
bsd-3-clause
| 113,708
|
from django.db import models
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from press_links.enums import STATUS_CHOICES, LIVE_STATUS, DRAFT_STATUS
from django.utils import timezone
from parler.models import TranslatableModel, TranslatedFields
from parler.managers import TranslatableQuerySet
class EntryManager(models.Manager):
def get_queryset(self):
return EntryQuerySet(self.model)
def live(self):
"""
Returns a list of all published entries.
:rtype: django.db.models.QuerySet
"""
return self.filter(pub_date__lte=timezone.now(), status=LIVE_STATUS) \
.filter(site=Site.objects.get_current())
class EntryQuerySet(TranslatableQuerySet):
pass
class Entry(TranslatableModel):
author = models.ForeignKey(User, verbose_name=_('author'),
related_name='%(app_label)s_%(class)s_related')
slug = models.SlugField(max_length=255, unique_for_date='pub_date',
verbose_name='slug')
pub_date = models.DateTimeField(default=timezone.now,
verbose_name=_('publication date'))
status = models.IntegerField(choices=STATUS_CHOICES, default=DRAFT_STATUS,
verbose_name=_('status'))
site = models.ManyToManyField(Site,
verbose_name=_('Sites where the entry is published'),
related_name='%(app_label)s_%(class)s_related')
objects = EntryManager()
translations = TranslatedFields(
title=models.CharField(max_length=255, verbose_name=_('title')),
source=models.CharField(max_length=255, blank=True,
verbose_name=_('the source for the entry')),
excerpt=models.TextField(blank=True, verbose_name=_(u'Excerpt'))
)
@models.permalink
def get_absolute_url(self):
return ('press_links_entry_detail', (), {'slug': self.slug})
class Meta:
get_latest_by = 'pub_date'
ordering = ['-pub_date']
verbose_name = _('Press Entry')
verbose_name_plural = _('Press Entries')
def __unicode__(self):
return self.title
class Link(TranslatableModel):
link_new_page = models.BooleanField(default=False, verbose_name=_('open link in new page'))
entry = models.ForeignKey(Entry, verbose_name=_('Entry'))
translations = TranslatedFields(
link=models.CharField(max_length=255,
verbose_name=_('link address (add http:// for external link)')),
link_text=models.CharField(max_length=255,
verbose_name=_('text for link'))
)
class Meta:
verbose_name = _('Press Link')
verbose_name_plural = _('Press Links')
|
iberben/django-press-links
|
press_links/models.py
|
Python
|
bsd-3-clause
| 2,904
|
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
),
),
'translator' => array(
'locale' => 'ru_RU',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
|
crossdev/avantpack
|
module/Application/config/module.config.php
|
PHP
|
bsd-3-clause
| 3,538
|
var app = angular.module('questionnaireApp', [])
.controller('newQuestionController', ['$scope', function ($scope) {
$scope.options = window.options || {};
var questionOptions = window.questionOptions;
$scope.knowOptions = 'custom';
var clickCustomCount = 0;
$scope.answerType = window.answerType || "";
$scope.isAnswerTypeIsMultiChoice = function(){
return $scope.answerType == 'MultipleResponse' || $scope.answerType == 'MultiChoice';
};
$scope.addOption = function() {
$scope.existingQuestionOptions.push({});
};
$scope.removeOption = function(index) {
if($scope.existingQuestionOptions.length > 1) {
$scope.existingQuestionOptions.splice(index, 1);
} else {
$scope.existingQuestionOptions[0].text = "";
}
};
$scope.answerTypeIsMultiChoice = $scope.answerType && $scope.isAnswerTypeIsMultiChoice();
if (typeof window.answerSubType !== 'undefined'){
$scope.answerSubType = { text: window.answerSubType, value: window.answerSubType };
}
$scope.existingQuestionOptions = window.questionOptions || [];
var answerTypes = Object.keys(window.options);
var options = answerTypes.map(function (key) {
return { ansType: key, subTypes: $scope.options[key].map(function (subType) {
return { 'text': subType, 'value': subType };
})};
});
var createOptions = function(strOptions) {
var options = strOptions.split(",");
return options.map(function(option) {
return {text: option};
});
};
$scope.$watch('knowOptions', function(knownOption) {
if (knownOption === 'custom') {
if(clickCustomCount === 0) {
$scope.existingQuestionOptions = window.questionOptions
.filter(function(o) { return o != "" && o != null; })
.map(function(o) { return {text: o}; });
} else {
$scope.existingQuestionOptions = [];
}
if($scope.existingQuestionOptions.length === 0) {
$scope.addOption();
}
clickCustomCount ++;
} else {
$scope.existingQuestionOptions = createOptions(knownOption);
}
});
$scope.$watch('answerType', function (answerType) {
var answerTypeToShow = options.filter(function (option) {
return option.ansType == answerType;
})[0];
$scope.allOptions = answerTypeToShow && answerTypeToShow.subTypes;
});
}]);
|
eJRF/ejrf
|
questionnaire/static/js/ng-client/new-question.js
|
JavaScript
|
bsd-3-clause
| 2,809
|
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// VertexArrayVk.cpp:
// Implements the class methods for VertexArrayVk.
//
#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
#include "common/debug.h"
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/BufferVk.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/trace.h"
namespace rx
{
namespace
{
constexpr size_t kDynamicVertexDataSize = 1024 * 1024;
constexpr size_t kDynamicIndexDataSize = 1024 * 8;
constexpr size_t kDynamicIndirectDataSize = sizeof(VkDrawIndexedIndirectCommand) * 8;
ANGLE_INLINE bool BindingIsAligned(const gl::VertexBinding &binding,
const angle::Format &angleFormat,
unsigned int attribSize,
GLuint relativeOffset)
{
GLintptr totalOffset = binding.getOffset() + relativeOffset;
GLuint mask = angleFormat.componentAlignmentMask;
if (mask != std::numeric_limits<GLuint>::max())
{
return ((totalOffset & mask) == 0 && (binding.getStride() & mask) == 0);
}
else
{
// To perform the GPU conversion for formats with components that aren't byte-aligned
// (for example, A2BGR10 or RGB10A2), one element has to be placed in 4 bytes to perform
// the compute shader. So, binding offset and stride has to be aligned to formatSize.
unsigned int formatSize = angleFormat.pixelBytes;
return (totalOffset % formatSize == 0) && (binding.getStride() % formatSize == 0);
}
}
angle::Result StreamVertexData(ContextVk *contextVk,
vk::DynamicBuffer *dynamicBuffer,
const uint8_t *sourceData,
size_t bytesToAllocate,
size_t destOffset,
size_t vertexCount,
size_t sourceStride,
size_t destStride,
VertexCopyFunction vertexLoadFunction,
vk::BufferHelper **bufferOut,
VkDeviceSize *bufferOffsetOut,
uint32_t replicateCount)
{
uint8_t *dst = nullptr;
ANGLE_TRY(dynamicBuffer->allocate(contextVk, bytesToAllocate, &dst, nullptr, bufferOffsetOut,
nullptr));
*bufferOut = dynamicBuffer->getCurrentBuffer();
dst += destOffset;
if (replicateCount == 1)
{
vertexLoadFunction(sourceData, sourceStride, vertexCount, dst);
}
else
{
ASSERT(replicateCount > 1);
uint32_t sourceRemainingCount = replicateCount - 1;
for (size_t dataCopied = 0; dataCopied < bytesToAllocate;
dataCopied += destStride, dst += destStride, sourceRemainingCount--)
{
vertexLoadFunction(sourceData, sourceStride, 1, dst);
if (sourceRemainingCount == 0)
{
sourceData += sourceStride;
sourceRemainingCount = replicateCount;
}
}
}
ANGLE_TRY(dynamicBuffer->flush(contextVk));
return angle::Result::Continue;
}
size_t GetVertexCount(BufferVk *srcBuffer, const gl::VertexBinding &binding, uint32_t srcFormatSize)
{
// Bytes usable for vertex data.
GLint64 bytes = srcBuffer->getSize() - binding.getOffset();
if (bytes < srcFormatSize)
return 0;
// Count the last vertex. It may occupy less than a full stride.
size_t numVertices = 1;
bytes -= srcFormatSize;
// Count how many strides fit remaining space.
if (bytes > 0)
numVertices += static_cast<size_t>(bytes) / binding.getStride();
return numVertices;
}
} // anonymous namespace
VertexArrayVk::VertexArrayVk(ContextVk *contextVk, const gl::VertexArrayState &state)
: VertexArrayImpl(state),
mCurrentArrayBufferHandles{},
mCurrentArrayBufferOffsets{},
mCurrentArrayBufferRelativeOffsets{},
mCurrentArrayBuffers{},
mCurrentElementArrayBufferOffset(0),
mCurrentElementArrayBuffer(nullptr),
mLineLoopHelper(contextVk->getRenderer()),
mDirtyLineLoopTranslation(true)
{
RendererVk *renderer = contextVk->getRenderer();
VkBufferCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
createInfo.size = 16;
createInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
(void)mTheNullBuffer.init(contextVk, createInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
mCurrentArrayBufferHandles.fill(mTheNullBuffer.getBuffer().getHandle());
mCurrentArrayBufferOffsets.fill(0);
mCurrentArrayBufferRelativeOffsets.fill(0);
mCurrentArrayBuffers.fill(&mTheNullBuffer);
mDynamicVertexData.init(renderer, vk::kVertexBufferUsageFlags, vk::kVertexBufferAlignment,
kDynamicVertexDataSize, true);
// We use an alignment of four for index data. This ensures that compute shaders can read index
// elements from "uint" aligned addresses.
mDynamicIndexData.init(renderer, vk::kIndexBufferUsageFlags, vk::kIndexBufferAlignment,
kDynamicIndexDataSize, true);
mTranslatedByteIndexData.init(renderer, vk::kIndexBufferUsageFlags, vk::kIndexBufferAlignment,
kDynamicIndexDataSize, true);
mTranslatedByteIndirectData.init(renderer, vk::kIndirectBufferUsageFlags,
vk::kIndirectBufferAlignment, kDynamicIndirectDataSize, true);
}
VertexArrayVk::~VertexArrayVk() {}
void VertexArrayVk::destroy(const gl::Context *context)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
mTheNullBuffer.release(renderer);
mDynamicVertexData.release(renderer);
mDynamicIndexData.release(renderer);
mTranslatedByteIndexData.release(renderer);
mTranslatedByteIndirectData.release(renderer);
mLineLoopHelper.release(contextVk);
}
angle::Result VertexArrayVk::convertIndexBufferGPU(ContextVk *contextVk,
BufferVk *bufferVk,
const void *indices)
{
intptr_t offsetIntoSrcData = reinterpret_cast<intptr_t>(indices);
size_t srcDataSize = static_cast<size_t>(bufferVk->getSize()) - offsetIntoSrcData;
mTranslatedByteIndexData.releaseInFlightBuffers(contextVk);
ANGLE_TRY(mTranslatedByteIndexData.allocate(contextVk, sizeof(GLushort) * srcDataSize, nullptr,
nullptr, &mCurrentElementArrayBufferOffset,
nullptr));
mCurrentElementArrayBuffer = mTranslatedByteIndexData.getCurrentBuffer();
vk::BufferHelper *dest = mTranslatedByteIndexData.getCurrentBuffer();
vk::BufferHelper *src = &bufferVk->getBuffer();
// Copy relevant section of the source into destination at allocated offset. Note that the
// offset returned by allocate() above is in bytes. As is the indices offset pointer.
UtilsVk::ConvertIndexParameters params = {};
params.srcOffset = static_cast<uint32_t>(offsetIntoSrcData);
params.dstOffset = static_cast<uint32_t>(mCurrentElementArrayBufferOffset);
params.maxIndex = static_cast<uint32_t>(bufferVk->getSize());
return contextVk->getUtils().convertIndexBuffer(contextVk, dest, src, params);
}
angle::Result VertexArrayVk::convertIndexBufferIndirectGPU(ContextVk *contextVk,
vk::BufferHelper *srcIndirectBuf,
VkDeviceSize srcIndirectBufOffset,
vk::BufferHelper **indirectBufferVkOut,
VkDeviceSize *indirectBufferVkOffsetOut)
{
size_t srcDataSize = static_cast<size_t>(mCurrentElementArrayBuffer->getSize());
ASSERT(mCurrentElementArrayBuffer ==
&vk::GetImpl(getState().getElementArrayBuffer())->getBuffer());
mTranslatedByteIndexData.releaseInFlightBuffers(contextVk);
mTranslatedByteIndirectData.releaseInFlightBuffers(contextVk);
vk::BufferHelper *srcIndexBuf = mCurrentElementArrayBuffer;
VkDeviceSize dstIndirectBufOffset;
VkDeviceSize dstIndexBufOffset;
ANGLE_TRY(mTranslatedByteIndexData.allocate(contextVk, sizeof(GLushort) * srcDataSize, nullptr,
nullptr, &dstIndexBufOffset, nullptr));
vk::BufferHelper *dstIndexBuf = mTranslatedByteIndexData.getCurrentBuffer();
ANGLE_TRY(mTranslatedByteIndirectData.allocate(contextVk, sizeof(VkDrawIndexedIndirectCommand),
nullptr, nullptr, &dstIndirectBufOffset,
nullptr));
vk::BufferHelper *dstIndirectBuf = mTranslatedByteIndirectData.getCurrentBuffer();
// Save new element array buffer
mCurrentElementArrayBuffer = dstIndexBuf;
mCurrentElementArrayBufferOffset = dstIndexBufOffset;
// Tell caller what new indirect buffer is
*indirectBufferVkOut = dstIndirectBuf;
*indirectBufferVkOffsetOut = dstIndirectBufOffset;
// Copy relevant section of the source into destination at allocated offset. Note that the
// offset returned by allocate() above is in bytes. As is the indices offset pointer.
UtilsVk::ConvertIndexIndirectParameters params = {};
params.srcIndirectBufOffset = static_cast<uint32_t>(srcIndirectBufOffset);
params.dstIndexBufOffset = static_cast<uint32_t>(dstIndexBufOffset);
params.maxIndex = static_cast<uint32_t>(srcDataSize);
params.dstIndirectBufOffset = static_cast<uint32_t>(dstIndirectBufOffset);
return contextVk->getUtils().convertIndexIndirectBuffer(contextVk, srcIndirectBuf, srcIndexBuf,
dstIndirectBuf, dstIndexBuf, params);
}
angle::Result VertexArrayVk::handleLineLoopIndexIndirect(ContextVk *contextVk,
gl::DrawElementsType glIndexType,
vk::BufferHelper *srcIndirectBuf,
VkDeviceSize indirectBufferOffset,
vk::BufferHelper **indirectBufferOut,
VkDeviceSize *indirectBufferOffsetOut)
{
ANGLE_TRY(mLineLoopHelper.streamIndicesIndirect(
contextVk, glIndexType, mCurrentElementArrayBuffer, srcIndirectBuf, indirectBufferOffset,
&mCurrentElementArrayBuffer, &mCurrentElementArrayBufferOffset, indirectBufferOut,
indirectBufferOffsetOut));
return angle::Result::Continue;
}
angle::Result VertexArrayVk::handleLineLoopIndirectDraw(const gl::Context *context,
vk::BufferHelper *indirectBufferVk,
VkDeviceSize indirectBufferOffset,
vk::BufferHelper **indirectBufferOut,
VkDeviceSize *indirectBufferOffsetOut)
{
size_t maxVertexCount = 0;
ContextVk *contextVk = vk::GetImpl(context);
const gl::AttributesMask activeAttribs =
context->getStateCache().getActiveBufferedAttribsMask();
const auto &attribs = mState.getVertexAttributes();
const auto &bindings = mState.getVertexBindings();
for (size_t attribIndex : activeAttribs)
{
const gl::VertexAttribute &attrib = attribs[attribIndex];
ASSERT(attrib.enabled);
VkDeviceSize bufSize = this->getCurrentArrayBuffers()[attribIndex]->getSize();
const gl::VertexBinding &binding = bindings[attrib.bindingIndex];
size_t stride = binding.getStride();
size_t vertexCount = static_cast<size_t>(bufSize / stride);
if (vertexCount > maxVertexCount)
{
maxVertexCount = vertexCount;
}
}
ANGLE_TRY(mLineLoopHelper.streamArrayIndirect(contextVk, maxVertexCount + 1, indirectBufferVk,
indirectBufferOffset, &mCurrentElementArrayBuffer,
&mCurrentElementArrayBufferOffset,
indirectBufferOut, indirectBufferOffsetOut));
return angle::Result::Continue;
}
angle::Result VertexArrayVk::convertIndexBufferCPU(ContextVk *contextVk,
gl::DrawElementsType indexType,
size_t indexCount,
const void *sourcePointer)
{
ASSERT(!mState.getElementArrayBuffer() || indexType == gl::DrawElementsType::UnsignedByte);
mDynamicIndexData.releaseInFlightBuffers(contextVk);
size_t elementSize = contextVk->getVkIndexTypeSize(indexType);
const size_t amount = elementSize * indexCount;
GLubyte *dst = nullptr;
ANGLE_TRY(mDynamicIndexData.allocate(contextVk, amount, &dst, nullptr,
&mCurrentElementArrayBufferOffset, nullptr));
mCurrentElementArrayBuffer = mDynamicIndexData.getCurrentBuffer();
if (contextVk->shouldConvertUint8VkIndexType(indexType))
{
// Unsigned bytes don't have direct support in Vulkan so we have to expand the
// memory to a GLushort.
const GLubyte *in = static_cast<const GLubyte *>(sourcePointer);
GLushort *expandedDst = reinterpret_cast<GLushort *>(dst);
bool primitiveRestart = contextVk->getState().isPrimitiveRestartEnabled();
constexpr GLubyte kUnsignedByteRestartValue = 0xFF;
constexpr GLushort kUnsignedShortRestartValue = 0xFFFF;
if (primitiveRestart)
{
for (size_t index = 0; index < indexCount; index++)
{
GLushort value = static_cast<GLushort>(in[index]);
if (in[index] == kUnsignedByteRestartValue)
{
// Convert from 8-bit restart value to 16-bit restart value
value = kUnsignedShortRestartValue;
}
expandedDst[index] = value;
}
}
else
{
// Fast path for common case.
for (size_t index = 0; index < indexCount; index++)
{
expandedDst[index] = static_cast<GLushort>(in[index]);
}
}
}
else
{
// The primitive restart value is the same for OpenGL and Vulkan,
// so there's no need to perform any conversion.
memcpy(dst, sourcePointer, amount);
}
return mDynamicIndexData.flush(contextVk);
}
// We assume the buffer is completely full of the same kind of data and convert
// and/or align it as we copy it to a DynamicBuffer. The assumption could be wrong
// but the alternative of copying it piecemeal on each draw would have a lot more
// overhead.
angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk,
BufferVk *srcBuffer,
const gl::VertexBinding &binding,
size_t attribIndex,
const vk::Format &vertexFormat,
ConversionBuffer *conversion,
GLuint relativeOffset)
{
const angle::Format &srcFormat = vertexFormat.intendedFormat();
const angle::Format &destFormat = vertexFormat.actualBufferFormat();
ASSERT(binding.getStride() % (srcFormat.pixelBytes / srcFormat.channelCount) == 0);
unsigned srcFormatSize = srcFormat.pixelBytes;
unsigned destFormatSize = destFormat.pixelBytes;
size_t numVertices = GetVertexCount(srcBuffer, binding, srcFormatSize);
if (numVertices == 0)
{
return angle::Result::Continue;
}
ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment);
// Allocate buffer for results
conversion->data.releaseInFlightBuffers(contextVk);
ANGLE_TRY(conversion->data.allocate(contextVk, numVertices * destFormatSize, nullptr, nullptr,
&conversion->lastAllocationOffset, nullptr));
ASSERT(conversion->dirty);
conversion->dirty = false;
UtilsVk::ConvertVertexParameters params;
params.vertexCount = numVertices;
params.srcFormat = &srcFormat;
params.destFormat = &destFormat;
params.srcStride = binding.getStride();
params.srcOffset = binding.getOffset() + relativeOffset;
params.destOffset = static_cast<size_t>(conversion->lastAllocationOffset);
ANGLE_TRY(contextVk->getUtils().convertVertexBuffer(
contextVk, conversion->data.getCurrentBuffer(), &srcBuffer->getBuffer(), params));
return angle::Result::Continue;
}
angle::Result VertexArrayVk::convertVertexBufferCPU(ContextVk *contextVk,
BufferVk *srcBuffer,
const gl::VertexBinding &binding,
size_t attribIndex,
const vk::Format &vertexFormat,
ConversionBuffer *conversion,
GLuint relativeOffset)
{
ANGLE_TRACE_EVENT0("gpu.angle", "VertexArrayVk::convertVertexBufferCpu");
unsigned srcFormatSize = vertexFormat.intendedFormat().pixelBytes;
unsigned dstFormatSize = vertexFormat.actualBufferFormat().pixelBytes;
conversion->data.releaseInFlightBuffers(contextVk);
size_t numVertices = GetVertexCount(srcBuffer, binding, srcFormatSize);
if (numVertices == 0)
{
return angle::Result::Continue;
}
void *src = nullptr;
ANGLE_TRY(srcBuffer->mapImpl(contextVk, &src));
const uint8_t *srcBytes = reinterpret_cast<const uint8_t *>(src);
srcBytes += binding.getOffset() + relativeOffset;
ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment);
ANGLE_TRY(StreamVertexData(contextVk, &conversion->data, srcBytes, numVertices * dstFormatSize,
0, numVertices, binding.getStride(), srcFormatSize,
vertexFormat.vertexLoadFunction, &mCurrentArrayBuffers[attribIndex],
&conversion->lastAllocationOffset, 1));
ANGLE_TRY(srcBuffer->unmapImpl(contextVk));
ASSERT(conversion->dirty);
conversion->dirty = false;
return angle::Result::Continue;
}
angle::Result VertexArrayVk::syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
gl::VertexArray::DirtyAttribBitsArray *attribBits,
gl::VertexArray::DirtyBindingBitsArray *bindingBits)
{
ASSERT(dirtyBits.any());
ContextVk *contextVk = vk::GetImpl(context);
const std::vector<gl::VertexAttribute> &attribs = mState.getVertexAttributes();
const std::vector<gl::VertexBinding> &bindings = mState.getVertexBindings();
for (size_t dirtyBit : dirtyBits)
{
switch (dirtyBit)
{
case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER:
{
gl::Buffer *bufferGL = mState.getElementArrayBuffer();
if (bufferGL)
{
BufferVk *bufferVk = vk::GetImpl(bufferGL);
mCurrentElementArrayBuffer = &bufferVk->getBuffer();
}
else
{
mCurrentElementArrayBuffer = nullptr;
}
mLineLoopBufferFirstIndex.reset();
mLineLoopBufferLastIndex.reset();
contextVk->setIndexBufferDirty();
mDirtyLineLoopTranslation = true;
break;
}
case gl::VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA:
mLineLoopBufferFirstIndex.reset();
mLineLoopBufferLastIndex.reset();
contextVk->setIndexBufferDirty();
mDirtyLineLoopTranslation = true;
break;
#define ANGLE_VERTEX_DIRTY_ATTRIB_FUNC(INDEX) \
case gl::VertexArray::DIRTY_BIT_ATTRIB_0 + INDEX: \
{ \
const bool bufferOnly = \
(*attribBits)[INDEX].to_ulong() == \
angle::Bit<unsigned long>(gl::VertexArray::DIRTY_ATTRIB_POINTER_BUFFER); \
ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[INDEX], \
bindings[attribs[INDEX].bindingIndex], INDEX, bufferOnly)); \
(*attribBits)[INDEX].reset(); \
break; \
}
ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_ATTRIB_FUNC)
#define ANGLE_VERTEX_DIRTY_BINDING_FUNC(INDEX) \
case gl::VertexArray::DIRTY_BIT_BINDING_0 + INDEX: \
for (size_t attribIndex : bindings[INDEX].getBoundAttributesMask()) \
{ \
ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[attribIndex], bindings[INDEX], \
attribIndex, false)); \
} \
(*bindingBits)[INDEX].reset(); \
break;
ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_BINDING_FUNC)
#define ANGLE_VERTEX_DIRTY_BUFFER_DATA_FUNC(INDEX) \
case gl::VertexArray::DIRTY_BIT_BUFFER_DATA_0 + INDEX: \
ANGLE_TRY(syncDirtyAttrib(contextVk, attribs[INDEX], \
bindings[attribs[INDEX].bindingIndex], INDEX, false)); \
break;
ANGLE_VERTEX_INDEX_CASES(ANGLE_VERTEX_DIRTY_BUFFER_DATA_FUNC)
default:
UNREACHABLE();
break;
}
}
return angle::Result::Continue;
}
#undef ANGLE_VERTEX_DIRTY_ATTRIB_FUNC
#undef ANGLE_VERTEX_DIRTY_BINDING_FUNC
#undef ANGLE_VERTEX_DIRTY_BUFFER_DATA_FUNC
ANGLE_INLINE void VertexArrayVk::setDefaultPackedInput(ContextVk *contextVk, size_t attribIndex)
{
const gl::State &glState = contextVk->getState();
const gl::VertexAttribCurrentValueData &defaultValue =
glState.getVertexAttribCurrentValues()[attribIndex];
angle::FormatID format = GetCurrentValueFormatID(defaultValue.Type);
contextVk->onVertexAttributeChange(attribIndex, 0, 0, format, 0);
}
void VertexArrayVk::updateActiveAttribInfo(ContextVk *contextVk)
{
const std::vector<gl::VertexAttribute> &attribs = mState.getVertexAttributes();
const std::vector<gl::VertexBinding> &bindings = mState.getVertexBindings();
// Update pipeline cache with current active attribute info
for (size_t attribIndex : mState.getEnabledAttributesMask())
{
const gl::VertexAttribute &attrib = attribs[attribIndex];
const gl::VertexBinding &binding = bindings[attribs[attribIndex].bindingIndex];
contextVk->onVertexAttributeChange(attribIndex, mCurrentArrayBufferStrides[attribIndex],
binding.getDivisor(), attrib.format->id,
mCurrentArrayBufferRelativeOffsets[attribIndex]);
}
}
angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t attribIndex,
bool bufferOnly)
{
if (attrib.enabled)
{
RendererVk *renderer = contextVk->getRenderer();
const vk::Format &vertexFormat = renderer->getFormat(attrib.format->id);
GLuint stride;
// Init attribute offset to the front-end value
mCurrentArrayBufferRelativeOffsets[attribIndex] = attrib.relativeOffset;
bool anyVertexBufferConvertedOnGpu = false;
gl::Buffer *bufferGL = binding.getBuffer().get();
// Emulated and/or client-side attribs will be streamed
bool isStreamingVertexAttrib =
(binding.getDivisor() > renderer->getMaxVertexAttribDivisor()) || (bufferGL == nullptr);
mStreamingVertexAttribsMask.set(attribIndex, isStreamingVertexAttrib);
if (!isStreamingVertexAttrib)
{
BufferVk *bufferVk = vk::GetImpl(bufferGL);
const angle::Format &intendedFormat = vertexFormat.intendedFormat();
bool bindingIsAligned = BindingIsAligned(
binding, intendedFormat, intendedFormat.channelCount, attrib.relativeOffset);
if (vertexFormat.vertexLoadRequiresConversion || !bindingIsAligned)
{
ConversionBuffer *conversion = bufferVk->getVertexConversionBuffer(
renderer, intendedFormat.id, binding.getStride(),
binding.getOffset() + attrib.relativeOffset, !bindingIsAligned);
if (conversion->dirty)
{
if (bindingIsAligned)
{
ANGLE_TRY(convertVertexBufferGPU(contextVk, bufferVk, binding, attribIndex,
vertexFormat, conversion,
attrib.relativeOffset));
anyVertexBufferConvertedOnGpu = true;
}
else
{
ANGLE_TRY(convertVertexBufferCPU(contextVk, bufferVk, binding, attribIndex,
vertexFormat, conversion,
attrib.relativeOffset));
}
// If conversion happens, the destination buffer stride may be changed,
// therefore an attribute change needs to be called. Note that it may trigger
// unnecessary vulkan PSO update when the destination buffer stride does not
// change, but for simplity just make it conservative
bufferOnly = false;
}
vk::BufferHelper *bufferHelper = conversion->data.getCurrentBuffer();
mCurrentArrayBuffers[attribIndex] = bufferHelper;
mCurrentArrayBufferHandles[attribIndex] = bufferHelper->getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = conversion->lastAllocationOffset;
// Converted attribs are packed in their own VK buffer so offset is zero
mCurrentArrayBufferRelativeOffsets[attribIndex] = 0;
// Converted buffer is tightly packed
stride = vertexFormat.actualBufferFormat().pixelBytes;
}
else
{
if (bufferVk->getSize() == 0)
{
mCurrentArrayBuffers[attribIndex] = &mTheNullBuffer;
mCurrentArrayBufferHandles[attribIndex] =
mTheNullBuffer.getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = 0;
stride = 0;
}
else
{
vk::BufferHelper &bufferHelper = bufferVk->getBuffer();
mCurrentArrayBuffers[attribIndex] = &bufferHelper;
mCurrentArrayBufferHandles[attribIndex] = bufferHelper.getBuffer().getHandle();
// Vulkan requires the offset is within the buffer. We use robust access
// behaviour to reset the offset if it starts outside the buffer.
mCurrentArrayBufferOffsets[attribIndex] =
binding.getOffset() < bufferVk->getSize() ? binding.getOffset() : 0;
stride = binding.getStride();
}
}
}
else
{
mCurrentArrayBuffers[attribIndex] = &mTheNullBuffer;
mCurrentArrayBufferHandles[attribIndex] = mTheNullBuffer.getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = 0;
// Client side buffer will be transfered to a tightly packed buffer later
stride = vertexFormat.actualBufferFormat().pixelBytes;
}
if (bufferOnly)
{
contextVk->invalidateVertexBuffers();
}
else
{
contextVk->onVertexAttributeChange(attribIndex, stride, binding.getDivisor(),
attrib.format->id,
mCurrentArrayBufferRelativeOffsets[attribIndex]);
// Cache the stride of the attribute
mCurrentArrayBufferStrides[attribIndex] = stride;
}
if (anyVertexBufferConvertedOnGpu &&
renderer->getFeatures().flushAfterVertexConversion.enabled)
{
ANGLE_TRY(contextVk->flushImpl(nullptr));
}
}
else
{
contextVk->invalidateDefaultAttribute(attribIndex);
// These will be filled out by the ContextVk.
mCurrentArrayBuffers[attribIndex] = &mTheNullBuffer;
mCurrentArrayBufferHandles[attribIndex] = mTheNullBuffer.getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = 0;
mCurrentArrayBufferStrides[attribIndex] = 0;
mCurrentArrayBufferRelativeOffsets[attribIndex] = 0;
setDefaultPackedInput(contextVk, attribIndex);
}
return angle::Result::Continue;
}
// Handle copying client attribs and/or expanding attrib buffer in case where attribute
// divisor value has to be emulated.
angle::Result VertexArrayVk::updateStreamedAttribs(const gl::Context *context,
GLint firstVertex,
GLsizei vertexOrIndexCount,
GLsizei instanceCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices)
{
ContextVk *contextVk = vk::GetImpl(context);
const gl::AttributesMask activeAttribs =
context->getStateCache().getActiveClientAttribsMask() |
context->getStateCache().getActiveBufferedAttribsMask();
const gl::AttributesMask activeStreamedAttribs = mStreamingVertexAttribsMask & activeAttribs;
// Early return for corner case where emulated buffered attribs are not active
if (!activeStreamedAttribs.any())
return angle::Result::Continue;
GLint startVertex;
size_t vertexCount;
ANGLE_TRY(GetVertexRangeInfo(context, firstVertex, vertexOrIndexCount, indexTypeOrInvalid,
indices, 0, &startVertex, &vertexCount));
RendererVk *renderer = contextVk->getRenderer();
mDynamicVertexData.releaseInFlightBuffers(contextVk);
const auto &attribs = mState.getVertexAttributes();
const auto &bindings = mState.getVertexBindings();
// TODO: When we have a bunch of interleaved attributes, they end up
// un-interleaved, wasting space and copying time. Consider improving on that.
for (size_t attribIndex : activeStreamedAttribs)
{
const gl::VertexAttribute &attrib = attribs[attribIndex];
ASSERT(attrib.enabled);
const gl::VertexBinding &binding = bindings[attrib.bindingIndex];
const vk::Format &vertexFormat = renderer->getFormat(attrib.format->id);
GLuint stride = vertexFormat.actualBufferFormat().pixelBytes;
ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment);
const uint8_t *src = static_cast<const uint8_t *>(attrib.pointer);
const uint32_t divisor = binding.getDivisor();
if (divisor > 0)
{
// Instanced attrib
if (divisor > renderer->getMaxVertexAttribDivisor())
{
// Emulated attrib
BufferVk *bufferVk = nullptr;
if (binding.getBuffer().get() != nullptr)
{
// Map buffer to expand attribs for divisor emulation
bufferVk = vk::GetImpl(binding.getBuffer().get());
void *buffSrc = nullptr;
ANGLE_TRY(bufferVk->mapImpl(contextVk, &buffSrc));
src = reinterpret_cast<const uint8_t *>(buffSrc) + binding.getOffset();
}
// Divisor will be set to 1 & so update buffer to have 1 attrib per instance
size_t bytesToAllocate = instanceCount * stride;
ANGLE_TRY(StreamVertexData(contextVk, &mDynamicVertexData, src, bytesToAllocate, 0,
instanceCount, binding.getStride(), stride,
vertexFormat.vertexLoadFunction,
&mCurrentArrayBuffers[attribIndex],
&mCurrentArrayBufferOffsets[attribIndex], divisor));
if (bufferVk)
{
ANGLE_TRY(bufferVk->unmapImpl(contextVk));
}
}
else
{
ASSERT(binding.getBuffer().get() == nullptr);
size_t count = UnsignedCeilDivide(instanceCount, divisor);
size_t bytesToAllocate = count * stride;
ANGLE_TRY(StreamVertexData(contextVk, &mDynamicVertexData, src, bytesToAllocate, 0,
count, binding.getStride(), stride,
vertexFormat.vertexLoadFunction,
&mCurrentArrayBuffers[attribIndex],
&mCurrentArrayBufferOffsets[attribIndex], 1));
}
}
else
{
ASSERT(binding.getBuffer().get() == nullptr);
// Allocate space for startVertex + vertexCount so indexing will work. If we don't
// start at zero all the indices will be off.
// Only vertexCount vertices will be used by the upcoming draw so that is all we copy.
size_t bytesToAllocate = (startVertex + vertexCount) * stride;
src += startVertex * binding.getStride();
size_t destOffset = startVertex * stride;
ANGLE_TRY(StreamVertexData(
contextVk, &mDynamicVertexData, src, bytesToAllocate, destOffset, vertexCount,
binding.getStride(), stride, vertexFormat.vertexLoadFunction,
&mCurrentArrayBuffers[attribIndex], &mCurrentArrayBufferOffsets[attribIndex], 1));
}
mCurrentArrayBufferHandles[attribIndex] =
mCurrentArrayBuffers[attribIndex]->getBuffer().getHandle();
}
return angle::Result::Continue;
}
angle::Result VertexArrayVk::handleLineLoop(ContextVk *contextVk,
GLint firstVertex,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
uint32_t *indexCountOut)
{
if (indexTypeOrInvalid != gl::DrawElementsType::InvalidEnum)
{
// Handle GL_LINE_LOOP drawElements.
if (mDirtyLineLoopTranslation)
{
gl::Buffer *elementArrayBuffer = mState.getElementArrayBuffer();
if (!elementArrayBuffer)
{
ANGLE_TRY(mLineLoopHelper.streamIndices(
contextVk, indexTypeOrInvalid, vertexOrIndexCount,
reinterpret_cast<const uint8_t *>(indices), &mCurrentElementArrayBuffer,
&mCurrentElementArrayBufferOffset, indexCountOut));
}
else
{
// When using an element array buffer, 'indices' is an offset to the first element.
intptr_t offset = reinterpret_cast<intptr_t>(indices);
BufferVk *elementArrayBufferVk = vk::GetImpl(elementArrayBuffer);
ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer(
contextVk, elementArrayBufferVk, indexTypeOrInvalid, vertexOrIndexCount, offset,
&mCurrentElementArrayBuffer, &mCurrentElementArrayBufferOffset, indexCountOut));
}
}
// If we've had a drawArrays call with a line loop before, we want to make sure this is
// invalidated the next time drawArrays is called since we use the same index buffer for
// both calls.
mLineLoopBufferFirstIndex.reset();
mLineLoopBufferLastIndex.reset();
return angle::Result::Continue;
}
// Note: Vertex indexes can be arbitrarily large.
uint32_t clampedVertexCount = gl::clampCast<uint32_t>(vertexOrIndexCount);
// Handle GL_LINE_LOOP drawArrays.
size_t lastVertex = static_cast<size_t>(firstVertex + clampedVertexCount);
if (!mLineLoopBufferFirstIndex.valid() || !mLineLoopBufferLastIndex.valid() ||
mLineLoopBufferFirstIndex != firstVertex || mLineLoopBufferLastIndex != lastVertex)
{
ANGLE_TRY(mLineLoopHelper.getIndexBufferForDrawArrays(
contextVk, clampedVertexCount, firstVertex, &mCurrentElementArrayBuffer,
&mCurrentElementArrayBufferOffset));
mLineLoopBufferFirstIndex = firstVertex;
mLineLoopBufferLastIndex = lastVertex;
}
*indexCountOut = vertexOrIndexCount + 1;
return angle::Result::Continue;
}
void VertexArrayVk::updateDefaultAttrib(ContextVk *contextVk,
size_t attribIndex,
VkBuffer bufferHandle,
vk::BufferHelper *buffer,
uint32_t offset)
{
if (!mState.getEnabledAttributesMask().test(attribIndex))
{
mCurrentArrayBufferHandles[attribIndex] = bufferHandle;
mCurrentArrayBufferOffsets[attribIndex] = offset;
mCurrentArrayBuffers[attribIndex] = buffer;
setDefaultPackedInput(contextVk, attribIndex);
}
}
} // namespace rx
|
endlessm/chromium-browser
|
third_party/angle/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
|
C++
|
bsd-3-clause
| 40,492
|
{-# LANGUAGE ViewPatterns #-}
module Plunge.Analytics.C2CPP
( lineAssociations
) where
import Data.List
import Plunge.Types.PreprocessorOutput
-- Fill in any gaps left by making associations out of CPP spans.
lineAssociations :: [Section] -> [LineAssociation]
lineAssociations ss = concat $ snd $ mapAccumL fillGap 1 assocs
where
fillGap :: LineNumber -> LineAssociation -> (LineNumber, [LineAssociation])
fillGap n (LineAssociation Nothing Nothing) = (n, [])
fillGap n a@(LineAssociation Nothing (Just _)) = (n, [a])
fillGap _ a@(LineAssociation (Just clr) Nothing) = (toLine clr, [a])
fillGap n a@(LineAssociation (Just clr) (Just _)) | n < cFrom = (cTo, [gap, a])
| n == cFrom = (cTo, [a])
| otherwise = (n, []) -- n > cFrom
where cTo = toLine clr
cFrom = fromLine clr
gap = LineAssociation (Just $ LineRange n cFrom) Nothing
assocs = sectionLineAssociations ss
sectionLineAssociations :: [Section] -> [LineAssociation]
sectionLineAssociations ss = map lineAssoc ss
where
lineAssoc (Block bls sl lr) =
LineAssociation { cppRange = Just lr
, cRange = Just $ LineRange sl (sl + (length bls))
}
lineAssoc (MiscDirective _ lr) =
LineAssociation { cppRange = Just lr
, cRange = Nothing
}
lineAssoc (Expansion _ (CppDirective stop _ _) n _ lr) =
LineAssociation { cppRange = Just lr
, cRange = Just $ LineRange n stop
}
|
sw17ch/plunge
|
src/Plunge/Analytics/C2CPP.hs
|
Haskell
|
bsd-3-clause
| 1,653
|
# Copyright (c) 2011-2014 Berkeley Model United Nations. All rights reserved.
# Use of this source code is governed by a BSD License (see LICENSE).
import json
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.client import Client
from huxley.accounts.models import User
from huxley.api.tests import (CreateAPITestCase, DestroyAPITestCase,
ListAPITestCase, PartialUpdateAPITestCase,
RetrieveAPITestCase)
from huxley.utils.test import TestSchools, TestUsers
class UserDetailGetTestCase(RetrieveAPITestCase):
url_name = 'api:user_detail'
def test_anonymous_user(self):
'''It should reject request from an anonymous user.'''
user = TestUsers.new_user()
response = self.get_response(user.id)
self.assertNotAuthenticated(response)
def test_other_user(self):
'''It should reject request from another user.'''
user1 = TestUsers.new_user(username='user1')
user2 = TestUsers.new_user(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(user1.id)
self.assertPermissionDenied(response)
def test_superuser(self):
'''It should return the correct fields for a superuser.'''
user1 = TestUsers.new_user(username='user1')
user2 = TestUsers.new_superuser(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(user1.id)
self.assertEqual(response.data, {
'id': user1.id,
'username': user1.username,
'first_name': user1.first_name,
'last_name': user1.last_name,
'user_type': user1.user_type,
'school': user1.school_id,
'committee': user1.committee_id})
def test_self(self):
'''It should return the correct fields for a single user.'''
school = TestSchools.new_school()
user = school.advisor
self.client.login(username=user.username, password='test')
response = self.get_response(user.id)
self.assertEqual(response.data, {
'id': user.id,
'username': user.username,
'first_name': user.first_name,
'last_name': user.last_name,
'user_type': user.user_type,
'school': {
'id': school.id,
'registered': school.registered.isoformat(),
'name': school.name,
'address': school.address,
'city': school.city,
'state': school.state,
'zip_code': school.zip_code,
'country': school.country,
'primary_name': school.primary_name,
'primary_gender': school.primary_gender,
'primary_email': school.primary_email,
'primary_phone': school.primary_phone,
'primary_type': school.primary_type,
'secondary_name': school.secondary_name,
'secondary_gender': school.secondary_gender,
'secondary_email': school.secondary_email,
'secondary_phone': school.secondary_phone,
'secondary_type': school.secondary_type,
'program_type': school.program_type,
'times_attended': school.times_attended,
'international': school.international,
'waitlist': school.waitlist,
'beginner_delegates': school.beginner_delegates,
'intermediate_delegates': school.intermediate_delegates,
'advanced_delegates': school.advanced_delegates,
'spanish_speaking_delegates': school.spanish_speaking_delegates,
'country_preferences': school.country_preference_ids,
'prefers_bilingual': school.prefers_bilingual,
'prefers_specialized_regional':
school.prefers_specialized_regional,
'prefers_crisis': school.prefers_crisis,
'prefers_alternative': school.prefers_alternative,
'prefers_press_corps': school.prefers_press_corps,
'registration_comments': school.registration_comments,
'fees_owed': float(school.fees_owed),
'fees_paid': float(school.fees_paid),
},
'committee': user.committee_id})
def test_chair(self):
'''It should have the correct fields for chairs.'''
user = TestUsers.new_user(user_type=User.TYPE_CHAIR,
committee_id=4)
self.client.login(username='testuser', password='test')
response = self.get_response(user.id)
self.assertEqual(response.data, {
'id': user.id,
'username': user.username,
'first_name': user.first_name,
'last_name': user.last_name,
'user_type': user.user_type,
'school': user.school_id,
'committee': user.committee_id})
class UserDetailDeleteTestCase(DestroyAPITestCase):
url_name = 'api:user_detail'
def setUp(self):
self.user = TestUsers.new_user(username='user1', password='user1')
def test_anonymous_user(self):
'''It should reject the request from an anonymous user.'''
response = self.get_response(self.user.id)
self.assertNotAuthenticated(response)
self.assertTrue(User.objects.filter(id=self.user.id).exists())
def test_other_user(self):
'''It should reject the request from another user.'''
TestUsers.new_user(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(self.user.id)
self.assertPermissionDenied(response)
self.assertTrue(User.objects.filter(id=self.user.id).exists())
def test_self(self):
'''It should allow a user to delete themself.'''
self.client.login(username='user1', password='user1')
response = self.get_response(self.user.id)
self.assertEqual(response.status_code, 204)
self.assertFalse(User.objects.filter(id=self.user.id).exists())
def test_superuser(self):
'''It should allow a superuser to delete a user.'''
TestUsers.new_superuser(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(self.user.id)
self.assertEqual(response.status_code, 204)
self.assertFalse(User.objects.filter(id=self.user.id).exists())
class UserDetailPatchTestCase(PartialUpdateAPITestCase):
url_name = 'api:user_detail'
params = {'first_name': 'first',
'last_name': 'last'}
def setUp(self):
self.user = TestUsers.new_user(username='user1', password='user1')
def test_anonymous_user(self):
'''An anonymous user should not be able to change information.'''
response = self.get_response(self.user.id, params=self.params)
self.assertNotAuthenticated(response)
user = User.objects.get(id=self.user.id)
self.assertEqual(user.first_name, 'Test')
self.assertEqual(user.last_name, 'User')
def test_other_user(self):
'''Another user should not be able to change information about any other user.'''
TestUsers.new_user(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(self.user.id, params=self.params)
self.assertPermissionDenied(response)
user = User.objects.get(id=self.user.id)
self.assertEqual(user.first_name, 'Test')
self.assertEqual(user.last_name, 'User')
def test_self(self):
'''A User should be allowed to change information about himself.'''
self.client.login(username='user1', password='user1')
response = self.get_response(self.user.id, params=self.params)
user = User.objects.get(id=self.user.id)
self.assertEqual(response.data['first_name'], user.first_name)
self.assertEqual(response.data['last_name'], user.last_name)
def test_superuser(self):
'''A superuser should be allowed to change information about a user.'''
TestUsers.new_superuser(username='user2', password='user2')
self.client.login(username='user2', password='user2')
response = self.get_response(self.user.id, params=self.params)
user = User.objects.get(id=self.user.id)
self.assertEqual(response.data['first_name'], user.first_name)
self.assertEqual(response.data['last_name'], user.last_name)
class UserListGetTestCase(ListAPITestCase):
url_name = 'api:user_list'
def test_anonymous_user(self):
'''It should reject the request from an anonymous user.'''
TestUsers.new_user(username='user1')
TestUsers.new_user(username='user2')
response = self.get_response()
self.assertNotAuthenticated(response)
def test_user(self):
'''It should reject the request from a regular user.'''
TestUsers.new_user(username='user1', password='user1')
TestUsers.new_user(username='user2')
self.client.login(username='user1', password='user1')
response = self.get_response()
self.assertPermissionDenied(response)
def test_superuser(self):
'''It should allow a superuser to list all users.'''
user1 = TestUsers.new_superuser(username='user1', password='user1')
user2 = TestUsers.new_user(username='user2')
self.client.login(username='user1', password='user1')
response = self.get_response()
self.assertEqual(response.data, [
{'id': user1.id,
'username': user1.username,
'first_name': user1.first_name,
'last_name': user1.last_name,
'user_type': user1.user_type,
'school': user1.school_id,
'committee': user1.committee_id},
{'id': user2.id,
'username': user2.username,
'first_name': user2.first_name,
'last_name': user2.last_name,
'user_type': user2.user_type,
'school': user2.school_id,
'committee': user2.committee_id}])
class UserListPostTestCase(CreateAPITestCase):
url_name = 'api:user_list'
params = {'username': 'Kunal',
'password': 'password',
'first_name': 'Kunal',
'last_name': 'Mehta'}
def test_valid(self):
params = self.get_params()
response = self.get_response(params)
user_query = User.objects.filter(id=response.data['id'])
self.assertTrue(user_query.exists())
user = User.objects.get(id=response.data['id'])
self.assertEqual(response.data, {
'id': user.id,
'username': user.username,
'first_name': user.first_name,
'last_name': user.last_name,
'user_type': User.TYPE_ADVISOR,
'school': user.school_id,
'email': user.email})
def test_empty_username(self):
response = self.get_response(params=self.get_params(username=''))
self.assertEqual(response.data, {
'username': ['This field is required.']})
def test_taken_username(self):
TestUsers.new_user(username='_Kunal', password='pass')
response = self.get_response(params=self.get_params(username='_Kunal'))
self.assertEqual(response.data, {
'username': ['This username is already taken.']})
def test_invalid_username(self):
response = self.get_response(params=self.get_params(username='>Kunal'))
self.assertEqual(response.data, {
'username': ['Usernames may contain alphanumerics, underscores, '
'and/or hyphens only.']})
def test_empty_password(self):
response = self.get_response(params=self.get_params(password=''))
self.assertEqual(response.data, {
'password': ['This field is required.']})
def test_invalid_password(self):
response = self.get_response(params=self.get_params(password='>pass'))
self.assertEqual(response.data, {
'password': ['Password contains invalid characters.']})
def test_empty_first_name(self):
response = self.get_response(params=self.get_params(first_name=''))
self.assertEqual(response.data, {
'first_name': ['This field is required.']})
def test_empty_last_name(self):
response = self.get_response(params=self.get_params(last_name=''))
self.assertEqual(response.data, {
'last_name': ['This field is required.']})
def test_username_length(self):
response = self.get_response(params=self.get_params(username='user'))
self.assertEqual(response.data, {
'username': ['Username must be at least 5 characters.']})
def test_password_length(self):
response = self.get_response(params=self.get_params(password='pass'))
self.assertEqual(response.data, {
'password': ['Password must be at least 6 characters.']})
class CurrentUserTestCase(TestCase):
def setUp(self):
self.client = Client()
self.url = reverse('api:current_user')
def get_data(self, url):
return json.loads(self.client.get(url).content)
def test_login(self):
user = TestUsers.new_user(username='lol', password='lol')
user2 = TestUsers.new_user(username='bunny', password='bunny')
credentials = {'username': 'lol', 'password': 'lol'}
response = self.client.post(self.url,
data=json.dumps(credentials),
content_type='application/json')
self.assertEqual(response.status_code, 201)
self.assertEqual(self.client.session['_auth_user_id'], user.id)
credentials = {'username': 'bunny', 'password': 'bunny'}
response = self.client.post(self.url,
data=json.dumps(credentials),
content_type='application/json')
self.assertEqual(self.client.session['_auth_user_id'], user.id)
data = json.loads(response.content)
self.assertEqual(data['detail'],
'Another user is currently logged in.')
def test_logout(self):
user = TestUsers.new_user(username='lol', password='lol')
self.client.login(username='lol', password='lol')
self.assertEqual(self.client.session['_auth_user_id'], user.id)
response = self.client.delete(self.url)
self.assertEqual(response.status_code, 204)
self.assertTrue('_auth_user_id' not in self.client.session)
def test_get(self):
data = self.get_data(self.url)
self.assertEqual(len(data.keys()), 1)
self.assertEqual(data['detail'], 'Not found')
school = TestSchools.new_school()
user = school.advisor
self.client.login(username=user.username, password='test')
data = self.get_data(self.url)
self.assertEqual(len(data.keys()), 7)
self.assertEqual(data['id'], user.id)
self.assertEqual(data['username'], user.username)
self.assertEqual(data['first_name'], user.first_name)
self.assertEqual(data['last_name'], user.last_name)
self.assertEqual(data['user_type'], User.TYPE_ADVISOR)
self.assertEqual(data['school'], {
'id': school.id,
'registered': school.registered.isoformat(),
'name': school.name,
'address': school.address,
'city': school.city,
'state': school.state,
'zip_code': school.zip_code,
'country': school.country,
'primary_name': school.primary_name,
'primary_gender': school.primary_gender,
'primary_email': school.primary_email,
'primary_phone': school.primary_phone,
'primary_type': school.primary_type,
'secondary_name': school.secondary_name,
'secondary_gender': school.secondary_gender,
'secondary_email': school.secondary_email,
'secondary_phone': school.secondary_phone,
'secondary_type': school.secondary_type,
'program_type': school.program_type,
'times_attended': school.times_attended,
'international': school.international,
'waitlist': school.waitlist,
'beginner_delegates': school.beginner_delegates,
'intermediate_delegates': school.intermediate_delegates,
'advanced_delegates': school.advanced_delegates,
'spanish_speaking_delegates': school.spanish_speaking_delegates,
'country_preferences': school.country_preference_ids,
'prefers_bilingual': school.prefers_bilingual,
'prefers_specialized_regional': school.prefers_specialized_regional,
'prefers_crisis': school.prefers_crisis,
'prefers_alternative': school.prefers_alternative,
'prefers_press_corps': school.prefers_press_corps,
'registration_comments': school.registration_comments,
'fees_owed': float(school.fees_owed),
'fees_paid': float(school.fees_paid),
})
|
jmosky12/huxley
|
huxley/api/tests/test_user.py
|
Python
|
bsd-3-clause
| 17,518
|
<?php
namespace frontend\controllers;
use common\models\Order;
use common\models\OrderItem;
use common\models\Product;
use yz\shoppingcart\ShoppingCart;
use yii\web\Controller;
class CartController extends Controller
{
public function actionAdd($id)
{
$product = Product::findOne($id);
if ($product) {
\Yii::$app->cart->put($product);
return $this->goBack();
}
}
public function actionList()
{
/* @var $cart ShoppingCart */
$cart = \Yii::$app->cart;
$products = $cart->getPositions();
$total = $cart->getCost();
return $this->render('list', [
'products' => $products,
'total' => $total,
]);
}
public function actionRemove($id)
{
$product = Product::findOne($id);
if ($product) {
\Yii::$app->cart->remove($product);
$this->redirect(['cart/list']);
}
}
public function actionUpdate($id, $quantity)
{
$product = Product::findOne($id);
if ($product) {
\Yii::$app->cart->update($product, $quantity);
$this->redirect(['cart/list']);
}
}
public function actionOrder()
{
$order = new Order();
/* @var $cart ShoppingCart */
$cart = \Yii::$app->cart;
/* @var $products Product[] */
$products = $cart->getPositions();
$total = $cart->getCost();
if ($order->load(\Yii::$app->request->post()) && $order->validate()) {
$transaction = $order->getDb()->beginTransaction();
$order->save(false);
foreach($products as $product) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->title = $product->title;
$orderItem->price = $product->getPrice();
$orderItem->product_id = $product->id;
$orderItem->quantity = $product->getQuantity();
if (!$orderItem->save(false)) {
$transaction->rollBack();
\Yii::$app->session->addFlash('error', 'Cannot place your order. Please contact us.');
return $this->redirect('catalog/list');
}
}
$transaction->commit();
\Yii::$app->cart->removeAll();
\Yii::$app->session->addFlash('success', 'Thanks for your order. We\'ll contact you soon.');
$order->sendEmail();
return $this->redirect('catalog/list');
}
return $this->render('order', [
'order' => $order,
'products' => $products,
'total' => $total,
]);
}
}
|
kantjessica/tryyii
|
frontend/controllers/CartController.php
|
PHP
|
bsd-3-clause
| 2,748
|
from django.db import models
class Entry(models.Model):
title = models.CharField(max_length=200)
date = models.DateTimeField()
class Meta:
ordering = ('date',)
def __unicode__(self):
return self.title
def get_absolute_url(self):
return "/blog/%s/" % self.pk
class Article(models.Model):
title = models.CharField(max_length=200)
entry = models.ForeignKey(Entry)
def __unicode__(self):
return self.title
|
bfirsh/syndication-view
|
syndication/tests/models.py
|
Python
|
bsd-3-clause
| 486
|
"use strict";
var fluid = require("infusion");
var gpii = fluid.registerNamespace("gpii");
fluid.registerNamespace("gpii.oauth2");
fluid.defaults("gpii.oauth2.userService", {
gradeNames: ["fluid.eventedComponent", "autoInit"],
components: {
dataStore: {
type: "gpii.oauth2.dataStore"
}
},
invokers: {
authenticateUser: {
funcName: "gpii.oauth2.userService.authenticateUser",
args: ["{dataStore}", "{arguments}.0", "{arguments}.1"]
// username, password
},
getUserById: {
func: "{dataStore}.findUserById"
}
}
});
gpii.oauth2.userService.authenticateUser = function (dataStore, username, password) {
var user = dataStore.findUserByUsername(username);
// TODO store passwords securely
if (user && user.password === password) {
return user;
}
return false;
};
|
simonbates/gpii-oauth2
|
gpii-oauth2-authorization-server/src/UserService.js
|
JavaScript
|
bsd-3-clause
| 935
|
from holoviews.element import (
ElementConversion, Points as HvPoints, Polygons as HvPolygons,
Path as HvPath
)
from .geo import (_Element, Feature, Tiles, is_geographic, # noqa (API import)
WMTS, Points, Image, Text, LineContours, RGB,
FilledContours, Path, Polygons, Shape, Dataset,
Contours, TriMesh, Graph, Nodes, EdgePaths, QuadMesh,
VectorField, Labels, HexTiles, Rectangles, Segments)
class GeoConversion(ElementConversion):
"""
GeoConversion is a very simple container object which can
be given an existing Dataset and provides methods to convert
the Dataset into most other Element types. If the requested
key dimensions correspond to geographical coordinates the
conversion interface will automatically use a geographical
Element type while all other plot will use regular HoloViews
Elements.
"""
def __init__(self, cube):
self._element = cube
def __call__(self, *args, **kwargs):
group_type = args[0]
if 'crs' not in kwargs and issubclass(group_type, _Element):
kwargs['crs'] = self._element.crs
is_gpd = self._element.interface.datatype == 'geodataframe'
if is_gpd:
kdims = args[1] if len(args) > 1 else kwargs.get('kdims', None)
if len(args) > 1:
args = (Dataset, [])+args[2:]
else:
args = (Dataset,)
kwargs['kdims'] = []
converted = super(GeoConversion, self).__call__(*args, **kwargs)
if is_gpd:
if kdims is None: kdims = group_type.kdims
converted = converted.map(lambda x: x.clone(kdims=kdims, new_type=group_type), Dataset)
return converted
def linecontours(self, kdims=None, vdims=None, mdims=None, **kwargs):
return self(LineContours, kdims, vdims, mdims, **kwargs)
def filledcontours(self, kdims=None, vdims=None, mdims=None, **kwargs):
return self(FilledContours, kdims, vdims, mdims, **kwargs)
def image(self, kdims=None, vdims=None, mdims=None, **kwargs):
return self(Image, kdims, vdims, mdims, **kwargs)
def points(self, kdims=None, vdims=None, mdims=None, **kwargs):
if kdims is None: kdims = self._element.kdims
el_type = Points if is_geographic(self._element, kdims) else HvPoints
return self(el_type, kdims, vdims, mdims, **kwargs)
def polygons(self, kdims=None, vdims=None, mdims=None, **kwargs):
if kdims is None: kdims = self._element.kdims
el_type = Polygons if is_geographic(self._element, kdims) else HvPolygons
return self(el_type, kdims, vdims, mdims, **kwargs)
def path(self, kdims=None, vdims=None, mdims=None, **kwargs):
if kdims is None: kdims = self._element.kdims
el_type = Path if is_geographic(self._element, kdims) else HvPath
return self(el_type, kdims, vdims, mdims, **kwargs)
Dataset._conversion_interface = GeoConversion
|
ioam/geoviews
|
geoviews/element/__init__.py
|
Python
|
bsd-3-clause
| 3,017
|
<?php
namespace W3C\Validation;
/**
* Class, which represents a validation result.
*
* @author Michel Hunziker <info@michelhunziker.com>
* @copyright Copyright (c) 2014 Michel Hunziker <info@michelhunziker.com>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD-3-Clause License
*/
class Result
{
/**
* @var bool
*/
protected $isValid;
/**
* @var Violation[]
*/
protected $errors = array();
/**
* @var int
*/
protected $errorCount = 0;
/**
* @var Violation[]
*/
protected $warnings = array();
/**
* @var int
*/
protected $warningCount = 0;
/**
* @param Violation $error
* @return Result
*/
public function addError(Violation $error)
{
$this->errors[] = $error;
$this->errorCount++;
return $this;
}
/**
* @return Violation[]
*/
public function getErrors()
{
return $this->errors;
}
/**
* @return int
*/
public function getErrorCount()
{
return $this->errorCount;
}
/**
* @param bool $isValid
* @return Result
*/
public function setIsValid($isValid)
{
$this->isValid = (bool) $isValid;
return $this;
}
/**
* @return bool
*/
public function isValid()
{
return $this->isValid;
}
/**
* @param Violation $warning
* @return Result
*/
public function addWarning(Violation $warning)
{
$this->warnings[] = $warning;
$this->warningCount++;
return $this;
}
/**
* @return Violation[]
*/
public function getWarnings()
{
return $this->warnings;
}
/**
* @return int
*/
public function getWarningCount()
{
return $this->warningCount;
}
}
|
micheh/w3c-validator
|
src/W3C/Validation/Result.php
|
PHP
|
bsd-3-clause
| 1,878
|
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using OpenMetaverse;
using log4net;
using Nini.Config;
using System.Reflection;
using OpenSim.Services.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Data;
using OpenSim.Framework;
namespace OpenSim.Services.InventoryService
{
public class XInventoryService : ServiceBase, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
protected IXInventoryData m_Database;
protected bool m_AllowDelete = true;
public XInventoryService(IConfigSource config) : base(config)
{
string dllName = String.Empty;
string connString = String.Empty;
//string realm = "Inventory"; // OSG version doesn't use this
//
// Try reading the [InventoryService] section first, if it exists
//
IConfig authConfig = config.Configs["InventoryService"];
if (authConfig != null)
{
dllName = authConfig.GetString("StorageProvider", dllName);
connString = authConfig.GetString("ConnectionString", connString);
m_AllowDelete = authConfig.GetBoolean("AllowDelete", true);
// realm = authConfig.GetString("Realm", realm);
}
//
// Try reading the [DatabaseService] section, if it exists
//
IConfig dbConfig = config.Configs["DatabaseService"];
if (dbConfig != null)
{
if (dllName == String.Empty)
dllName = dbConfig.GetString("StorageProvider", String.Empty);
if (connString == String.Empty)
connString = dbConfig.GetString("ConnectionString", String.Empty);
}
//
// We tried, but this doesn't exist. We can't proceed.
//
if (dllName == String.Empty)
throw new Exception("No StorageProvider configured");
m_Database = LoadPlugin<IXInventoryData>(dllName,
new Object[] {connString, String.Empty});
if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module");
}
public virtual bool CreateUserInventory(UUID principalID)
{
// This is braindeaad. We can't ever communicate that we fixed
// an existing inventory. Well, just return root folder status,
// but check sanity anyway.
//
bool result = false;
InventoryFolderBase rootFolder = GetRootFolder(principalID);
if (rootFolder == null)
{
rootFolder = ConvertToOpenSim(CreateFolder(principalID, UUID.Zero, (int)AssetType.RootFolder, "My Inventory"));
result = true;
}
XInventoryFolder[] sysFolders = GetSystemFolders(principalID);
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Animation, "Animations");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Bodypart, "Body Parts");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.CallingCard, "Calling Cards");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Clothing, "Clothing");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Gesture, "Gestures");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Landmark, "Landmarks");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.LostAndFoundFolder, "Lost And Found");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Notecard, "Notecards");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Object, "Objects");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.SnapshotFolder, "Photo Album");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.LSLText, "Scripts");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Sound, "Sounds");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.Texture, "Textures");
if (!Array.Exists(sysFolders, delegate (XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; }))
CreateFolder(principalID, rootFolder.ID, (int)AssetType.TrashFolder, "Trash");
return result;
}
protected XInventoryFolder CreateFolder(UUID principalID, UUID parentID, int type, string name)
{
XInventoryFolder newFolder = new XInventoryFolder();
newFolder.folderName = name;
newFolder.type = type;
newFolder.version = 1;
newFolder.folderID = UUID.Random();
newFolder.agentID = principalID;
newFolder.parentFolderID = parentID;
m_Database.StoreFolder(newFolder);
return newFolder;
}
protected virtual XInventoryFolder[] GetSystemFolders(UUID principalID)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting system folders for {0}", principalID);
XInventoryFolder[] allFolders = m_Database.GetFolders(
new string[] { "agentID" },
new string[] { principalID.ToString() });
XInventoryFolder[] sysFolders = Array.FindAll(
allFolders,
delegate (XInventoryFolder f)
{
if (f.type > 0)
return true;
return false;
});
// m_log.DebugFormat(
// "[XINVENTORY SERVICE]: Found {0} system folders for {1}", sysFolders.Length, principalID);
return sysFolders;
}
public virtual List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
{
XInventoryFolder[] allFolders = m_Database.GetFolders(
new string[] { "agentID" },
new string[] { principalID.ToString() });
if (allFolders.Length == 0)
return null;
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
foreach (XInventoryFolder x in allFolders)
{
//m_log.DebugFormat("[XINVENTORY SERVICE]: Adding folder {0} to skeleton", x.folderName);
folders.Add(ConvertToOpenSim(x));
}
return folders;
}
public virtual InventoryFolderBase GetRootFolder(UUID principalID)
{
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "parentFolderID"},
new string[] { principalID.ToString(), UUID.Zero.ToString() });
if (folders.Length == 0)
return null;
XInventoryFolder root = null;
foreach (XInventoryFolder folder in folders)
if (folder.folderName == "My Inventory")
root = folder;
if (folders == null) // oops
root = folders[0];
return ConvertToOpenSim(root);
}
public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "type"},
new string[] { principalID.ToString(), ((int)type).ToString() });
if (folders.Length == 0)
{
// m_log.WarnFormat("[XINVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
return null;
}
// m_log.DebugFormat(
// "[XINVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}",
// folders[0].folderName, folders[0].folderID, type, principalID);
return ConvertToOpenSim(folders[0]);
}
public virtual InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
{
// This method doesn't receive a valud principal id from the
// connector. So we disregard the principal and look
// by ID.
//
//m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString());
InventoryCollection inventory = new InventoryCollection();
inventory.UserID = principalID;
inventory.Folders = new List<InventoryFolderBase>();
inventory.Items = new List<InventoryItemBase>();
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "parentFolderID"},
new string[] { folderID.ToString() });
foreach (XInventoryFolder x in folders)
{
//m_log.DebugFormat("[XINVENTORY]: Adding folder {0} to response", x.folderName);
inventory.Folders.Add(ConvertToOpenSim(x));
}
XInventoryItem[] items = m_Database.GetItems(
new string[] { "parentFolderID"},
new string[] { folderID.ToString() });
foreach (XInventoryItem i in items)
{
//m_log.DebugFormat("[XINVENTORY]: Adding item {0} to response", i.inventoryName);
inventory.Items.Add(ConvertToOpenSim(i));
}
return inventory;
}
public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
{
// m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID);
// Since we probably don't get a valid principal here, either ...
//
List<InventoryItemBase> invItems = new List<InventoryItemBase>();
XInventoryItem[] items = m_Database.GetItems(
new string[] { "parentFolderID" },
new string[] { folderID.ToString() });
foreach (XInventoryItem i in items)
invItems.Add(ConvertToOpenSim(i));
return invItems;
}
public virtual bool AddFolder(InventoryFolderBase folder)
{
InventoryFolderBase check = GetFolder(folder);
if (check != null)
return false;
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
return m_Database.StoreFolder(xFolder);
}
public virtual bool UpdateFolder(InventoryFolderBase folder)
{
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
InventoryFolderBase check = GetFolder(folder);
if (check == null)
return AddFolder(folder);
if (check.Type != -1 || xFolder.type != -1)
{
if (xFolder.version > check.Version)
return false;
check.Version = (ushort)xFolder.version;
xFolder = ConvertFromOpenSim(check);
return m_Database.StoreFolder(xFolder);
}
if (xFolder.version < check.Version)
xFolder.version = check.Version;
xFolder.folderID = check.ID;
return m_Database.StoreFolder(xFolder);
}
public virtual bool MoveFolder(InventoryFolderBase folder)
{
XInventoryFolder[] x = m_Database.GetFolders(
new string[] { "folderID" },
new string[] { folder.ID.ToString() });
if (x.Length == 0)
return false;
x[0].parentFolderID = folder.ParentID;
return m_Database.StoreFolder(x[0]);
}
// We don't check the principal's ID here
//
public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
{
if (!m_AllowDelete)
return false;
// Ignore principal ID, it's bogus at connector level
//
foreach (UUID id in folderIDs)
{
if (!ParentIsTrash(id))
continue;
InventoryFolderBase f = new InventoryFolderBase();
f.ID = id;
PurgeFolder(f);
m_Database.DeleteFolders("folderID", id.ToString());
}
return true;
}
public virtual bool PurgeFolder(InventoryFolderBase folder)
{
if (!m_AllowDelete)
return false;
if (!ParentIsTrash(folder.ID))
return false;
XInventoryFolder[] subFolders = m_Database.GetFolders(
new string[] { "parentFolderID" },
new string[] { folder.ID.ToString() });
foreach (XInventoryFolder x in subFolders)
{
PurgeFolder(ConvertToOpenSim(x));
m_Database.DeleteFolders("folderID", x.folderID.ToString());
}
m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
return true;
}
public virtual bool AddItem(InventoryItemBase item)
{
// m_log.DebugFormat(
// "[XINVENTORY SERVICE]: Adding item {0} to folder {1} for {2}", item.ID, item.Folder, item.Owner);
return m_Database.StoreItem(ConvertFromOpenSim(item));
}
public virtual bool UpdateItem(InventoryItemBase item)
{
return m_Database.StoreItem(ConvertFromOpenSim(item));
}
public virtual bool MoveItems(UUID principalID, List<InventoryItemBase> items)
{
// Principal is b0rked. *sigh*
//
foreach (InventoryItemBase i in items)
{
m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
}
return true;
}
public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs)
{
if (!m_AllowDelete)
return false;
// Just use the ID... *facepalms*
//
foreach (UUID id in itemIDs)
m_Database.DeleteItems("inventoryID", id.ToString());
return true;
}
public virtual InventoryItemBase GetItem(InventoryItemBase item)
{
XInventoryItem[] items = m_Database.GetItems(
new string[] { "inventoryID" },
new string[] { item.ID.ToString() });
if (items.Length == 0)
return null;
return ConvertToOpenSim(items[0]);
}
public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder)
{
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "folderID"},
new string[] { folder.ID.ToString() });
if (folders.Length == 0)
return null;
return ConvertToOpenSim(folders[0]);
}
public virtual List<InventoryItemBase> GetActiveGestures(UUID principalID)
{
XInventoryItem[] items = m_Database.GetActiveGestures(principalID);
if (items.Length == 0)
return new List<InventoryItemBase>();
List<InventoryItemBase> ret = new List<InventoryItemBase>();
foreach (XInventoryItem x in items)
ret.Add(ConvertToOpenSim(x));
return ret;
}
public virtual int GetAssetPermissions(UUID principalID, UUID assetID)
{
return m_Database.GetAssetPermissions(principalID, assetID);
}
// CM never needed those. Left unimplemented.
// Obsolete in core
//
public InventoryCollection GetUserInventory(UUID userID)
{
return null;
}
public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
{
}
// Unused.
//
public bool HasInventoryForUser(UUID userID)
{
return false;
}
// CM Helpers
//
protected InventoryFolderBase ConvertToOpenSim(XInventoryFolder folder)
{
InventoryFolderBase newFolder = new InventoryFolderBase();
newFolder.ParentID = folder.parentFolderID;
newFolder.Type = (short)folder.type;
newFolder.Version = (ushort)folder.version;
newFolder.Name = folder.folderName;
newFolder.Owner = folder.agentID;
newFolder.ID = folder.folderID;
return newFolder;
}
protected XInventoryFolder ConvertFromOpenSim(InventoryFolderBase folder)
{
XInventoryFolder newFolder = new XInventoryFolder();
newFolder.parentFolderID = folder.ParentID;
newFolder.type = (int)folder.Type;
newFolder.version = (int)folder.Version;
newFolder.folderName = folder.Name;
newFolder.agentID = folder.Owner;
newFolder.folderID = folder.ID;
return newFolder;
}
protected InventoryItemBase ConvertToOpenSim(XInventoryItem item)
{
InventoryItemBase newItem = new InventoryItemBase();
newItem.AssetID = item.assetID;
newItem.AssetType = item.assetType;
newItem.Name = item.inventoryName;
newItem.Owner = item.avatarID;
newItem.ID = item.inventoryID;
newItem.InvType = item.invType;
newItem.Folder = item.parentFolderID;
newItem.CreatorIdentification = item.creatorID;
newItem.Description = item.inventoryDescription;
newItem.NextPermissions = (uint)item.inventoryNextPermissions;
newItem.CurrentPermissions = (uint)item.inventoryCurrentPermissions;
newItem.BasePermissions = (uint)item.inventoryBasePermissions;
newItem.EveryOnePermissions = (uint)item.inventoryEveryOnePermissions;
newItem.GroupPermissions = (uint)item.inventoryGroupPermissions;
newItem.GroupID = item.groupID;
if (item.groupOwned == 0)
newItem.GroupOwned = false;
else
newItem.GroupOwned = true;
newItem.SalePrice = item.salePrice;
newItem.SaleType = (byte)item.saleType;
newItem.Flags = (uint)item.flags;
newItem.CreationDate = item.creationDate;
return newItem;
}
protected XInventoryItem ConvertFromOpenSim(InventoryItemBase item)
{
XInventoryItem newItem = new XInventoryItem();
newItem.assetID = item.AssetID;
newItem.assetType = item.AssetType;
newItem.inventoryName = item.Name;
newItem.avatarID = item.Owner;
newItem.inventoryID = item.ID;
newItem.invType = item.InvType;
newItem.parentFolderID = item.Folder;
newItem.creatorID = item.CreatorIdentification;
newItem.inventoryDescription = item.Description;
newItem.inventoryNextPermissions = (int)item.NextPermissions;
newItem.inventoryCurrentPermissions = (int)item.CurrentPermissions;
newItem.inventoryBasePermissions = (int)item.BasePermissions;
newItem.inventoryEveryOnePermissions = (int)item.EveryOnePermissions;
newItem.inventoryGroupPermissions = (int)item.GroupPermissions;
newItem.groupID = item.GroupID;
if (item.GroupOwned)
newItem.groupOwned = 1;
else
newItem.groupOwned = 0;
newItem.salePrice = item.SalePrice;
newItem.saleType = (int)item.SaleType;
newItem.flags = (int)item.Flags;
newItem.creationDate = item.CreationDate;
return newItem;
}
private bool ParentIsTrash(UUID folderID)
{
XInventoryFolder[] folder = m_Database.GetFolders(new string[] {"folderID"}, new string[] {folderID.ToString()});
if (folder.Length < 1)
return false;
if (folder[0].type == (int)AssetType.TrashFolder)
return true;
UUID parentFolder = folder[0].parentFolderID;
while (parentFolder != UUID.Zero)
{
XInventoryFolder[] parent = m_Database.GetFolders(new string[] {"folderID"}, new string[] {parentFolder.ToString()});
if (parent.Length < 1)
return false;
if (parent[0].type == (int)AssetType.TrashFolder)
return true;
if (parent[0].type == (int)AssetType.RootFolder)
return false;
parentFolder = parent[0].parentFolderID;
}
return false;
}
}
}
|
allquixotic/opensim-autobackup
|
OpenSim/Services/InventoryService/XInventoryService.cs
|
C#
|
bsd-3-clause
| 24,805
|
/*L
Copyright SAIC
Distributed under the OSI-approved BSD 3-Clause License.
See http://ncip.github.com/cabio/LICENSE.txt for details.
L*/
create index AR_SWISSPROT_GENECHIP_A on AR_SWISSPROT(GENECHIP_ARRAY) PARALLEL NOLOGGING tablespace CABIO_MAP_FUT;
create index AR_SWISSPROT_SWISSPROT_ on AR_SWISSPROT(SWISSPROT_ID) PARALLEL NOLOGGING tablespace CABIO_MAP_FUT;
create index AR_SWISSPROT_PROBE_SET_ on AR_SWISSPROT(PROBE_SET_ID) PARALLEL NOLOGGING tablespace CABIO_MAP_FUT;
--EXIT;
|
NCIP/cabio
|
software/cabio-database/scripts/sql_loader/no_longer_used/indexes/ar_swissprot.cols.sql
|
SQL
|
bsd-3-clause
| 508
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_apitest.h"
#include <stddef.h>
#include <utility>
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/switches.h"
#include "extensions/test/result_catcher.h"
#include "net/base/escape.h"
#include "net/base/filename_util.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
namespace extensions {
namespace {
const char kTestCustomArg[] = "customArg";
const char kTestDataDirectory[] = "testDataDirectory";
const char kTestWebSocketPort[] = "testWebSocketPort";
const char kFtpServerPort[] = "ftpServer.port";
const char kEmbeddedTestServerPort[] = "testServer.port";
} // namespace
ExtensionApiTest::ExtensionApiTest() {
net::test_server::RegisterDefaultHandlers(embedded_test_server());
}
ExtensionApiTest::~ExtensionApiTest() = default;
void ExtensionApiTest::SetUpOnMainThread() {
ExtensionBrowserTest::SetUpOnMainThread();
DCHECK(!test_config_.get()) << "Previous test did not clear config state.";
test_config_.reset(new base::DictionaryValue());
test_config_->SetString(kTestDataDirectory,
net::FilePathToFileURL(test_data_dir_).spec());
if (embedded_test_server()->Started()) {
// InitializeEmbeddedTestServer was called before |test_config_| was set.
// Set the missing port key.
test_config_->SetInteger(kEmbeddedTestServerPort,
embedded_test_server()->port());
}
TestGetConfigFunction::set_test_config_state(test_config_.get());
}
void ExtensionApiTest::TearDownOnMainThread() {
ExtensionBrowserTest::TearDownOnMainThread();
TestGetConfigFunction::set_test_config_state(NULL);
test_config_.reset(NULL);
}
bool ExtensionApiTest::RunExtensionTest(const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
kFlagEnableFileAccess, kFlagNone);
}
bool ExtensionApiTest::RunExtensionTestWithFlags(
const std::string& extension_name,
int browser_test_flags,
int api_test_flags) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
browser_test_flags, api_test_flags);
}
bool ExtensionApiTest::RunExtensionTestWithArg(
const std::string& extension_name,
const char* custom_arg) {
return RunExtensionTestImpl(extension_name, std::string(), custom_arg,
kFlagEnableFileAccess, kFlagNone);
}
bool ExtensionApiTest::RunExtensionTestWithFlagsAndArg(
const std::string& extension_name,
const char* custom_arg,
int browser_test_flags,
int api_test_flags) {
return RunExtensionTestImpl(extension_name, std::string(), custom_arg,
browser_test_flags, api_test_flags);
}
bool ExtensionApiTest::RunExtensionTestIncognito(
const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
kFlagEnableIncognito | kFlagEnableFileAccess,
kFlagNone);
}
bool ExtensionApiTest::RunExtensionTestIgnoreManifestWarnings(
const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
kFlagIgnoreManifestWarnings, kFlagNone);
}
bool ExtensionApiTest::RunExtensionTestAllowOldManifestVersion(
const std::string& extension_name) {
return RunExtensionTestImpl(
extension_name, std::string(), nullptr,
kFlagEnableFileAccess | kFlagAllowOldManifestVersions, kFlagNone);
}
bool ExtensionApiTest::RunComponentExtensionTest(
const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
kFlagEnableFileAccess, kFlagLoadAsComponent);
}
bool ExtensionApiTest::RunComponentExtensionTestWithArg(
const std::string& extension_name,
const char* custom_arg) {
return RunExtensionTestImpl(extension_name, std::string(), custom_arg,
kFlagEnableFileAccess, kFlagLoadAsComponent);
}
bool ExtensionApiTest::RunExtensionTestNoFileAccess(
const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr, kFlagNone,
kFlagNone);
}
bool ExtensionApiTest::RunExtensionTestIncognitoNoFileAccess(
const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
kFlagEnableIncognito, kFlagNone);
}
bool ExtensionApiTest::RunExtensionSubtest(const std::string& extension_name,
const std::string& page_url) {
return RunExtensionSubtestWithArgAndFlags(extension_name, page_url, nullptr,
kFlagEnableFileAccess, kFlagNone);
}
bool ExtensionApiTest::RunExtensionSubtest(const std::string& extension_name,
const std::string& page_url,
int browser_test_flags,
int api_test_flags) {
return RunExtensionSubtestWithArgAndFlags(extension_name, page_url, nullptr,
browser_test_flags, api_test_flags);
}
bool ExtensionApiTest::RunExtensionSubtestWithArg(
const std::string& extension_name,
const std::string& page_url,
const char* custom_arg) {
return RunExtensionSubtestWithArgAndFlags(
extension_name, page_url, custom_arg, kFlagEnableFileAccess, kFlagNone);
}
bool ExtensionApiTest::RunExtensionSubtestWithArgAndFlags(
const std::string& extension_name,
const std::string& page_url,
const char* custom_arg,
int browser_test_flags,
int api_test_flags) {
DCHECK(!page_url.empty()) << "Argument page_url is required.";
return RunExtensionTestImpl(extension_name, page_url, custom_arg,
browser_test_flags, api_test_flags);
}
bool ExtensionApiTest::RunPageTest(const std::string& page_url) {
return RunExtensionSubtest(std::string(), page_url);
}
bool ExtensionApiTest::RunPageTest(const std::string& page_url,
int browser_test_flags,
int api_test_flags) {
return RunExtensionSubtest(std::string(), page_url, browser_test_flags,
api_test_flags);
}
bool ExtensionApiTest::RunPlatformAppTest(const std::string& extension_name) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr, kFlagNone,
kFlagLaunchPlatformApp);
}
bool ExtensionApiTest::RunPlatformAppTestWithArg(
const std::string& extension_name, const char* custom_arg) {
return RunPlatformAppTestWithFlags(extension_name, custom_arg, kFlagNone,
kFlagNone);
}
bool ExtensionApiTest::RunPlatformAppTestWithFlags(
const std::string& extension_name,
int browser_test_flags,
int api_test_flags) {
return RunExtensionTestImpl(extension_name, std::string(), nullptr,
browser_test_flags,
api_test_flags | kFlagLaunchPlatformApp);
}
bool ExtensionApiTest::RunPlatformAppTestWithFlags(
const std::string& extension_name,
const char* custom_arg,
int browser_test_flags,
int api_test_flags) {
return RunExtensionTestImpl(extension_name, std::string(), custom_arg,
browser_test_flags,
api_test_flags | kFlagLaunchPlatformApp);
}
bool ExtensionApiTest::RunExtensionTestImpl(const std::string& extension_name,
const std::string& page_url,
const char* custom_arg,
int browser_test_flags,
int api_test_flags) {
static_assert(static_cast<int>(ExtensionBrowserTest::kFlagNone) ==
static_cast<int>(ExtensionApiTest::kFlagNone),
"ExtensionApiTest::kFlagNone has an incorrect value");
// The value of "api_test_flags" should not have any of the flags from the
// ExtensionBrowserTest::Flags range. "kFlagNextValue - 1" is all of the
// bits from that range.
CHECK_EQ(0, api_test_flags & (kFlagNextValue - 1));
bool load_as_component =
api_test_flags & ExtensionApiTest::kFlagLoadAsComponent;
bool launch_platform_app =
api_test_flags & ExtensionApiTest::kFlagLaunchPlatformApp;
bool use_incognito = api_test_flags & kFlagUseIncognito;
bool use_root_extensions_dir =
api_test_flags & ExtensionApiTest::kFlagUseRootExtensionsDir;
if (custom_arg && custom_arg[0])
SetCustomArg(custom_arg);
ResultCatcher catcher;
DCHECK(!extension_name.empty() || !page_url.empty()) <<
"extension_name and page_url cannot both be empty";
const Extension* extension = NULL;
if (!extension_name.empty()) {
const base::FilePath& root_path =
use_root_extensions_dir ? shared_test_data_dir_ : test_data_dir_;
base::FilePath extension_path = root_path.AppendASCII(extension_name);
if (load_as_component) {
extension = LoadExtensionAsComponent(extension_path);
} else {
extension = LoadExtensionWithFlags(extension_path, browser_test_flags);
}
if (!extension) {
message_ = "Failed to load extension.";
return false;
}
}
// If there is a page_url to load, navigate it.
if (!page_url.empty()) {
GURL url = GURL(page_url);
// Note: We use is_valid() here in the expectation that the provided url
// may lack a scheme & host and thus be a relative url within the loaded
// extension.
if (!url.is_valid()) {
DCHECK(!extension_name.empty()) <<
"Relative page_url given with no extension_name";
url = extension->GetResourceURL(page_url);
}
if (use_incognito)
OpenURLOffTheRecord(browser()->profile(), url);
else
ui_test_utils::NavigateToURL(browser(), url);
} else if (launch_platform_app) {
apps::AppLaunchParams params(
extension->id(), LaunchContainer::kLaunchContainerNone,
WindowOpenDisposition::NEW_WINDOW, AppLaunchSource::kSourceTest);
params.command_line = *base::CommandLine::ForCurrentProcess();
apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->BrowserAppLauncher()
.LaunchAppWithParams(params);
}
if (!catcher.GetNextResult()) {
message_ = catcher.message();
return false;
}
return true;
}
// Test that exactly one extension is loaded, and return it.
const Extension* ExtensionApiTest::GetSingleLoadedExtension() {
ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
const Extension* result = NULL;
for (const scoped_refptr<const Extension>& extension :
registry->enabled_extensions()) {
// Ignore any component extensions. They are automatically loaded into all
// profiles and aren't the extension we're looking for here.
if (extension->location() == Manifest::COMPONENT)
continue;
if (result != NULL) {
// TODO(yoz): this is misleading; it counts component extensions.
message_ = base::StringPrintf(
"Expected only one extension to be present. Found %u.",
static_cast<unsigned>(registry->enabled_extensions().size()));
return NULL;
}
result = extension.get();
}
if (!result) {
message_ = "extension pointer is NULL.";
return NULL;
}
return result;
}
bool ExtensionApiTest::StartEmbeddedTestServer() {
if (!InitializeEmbeddedTestServer())
return false;
EmbeddedTestServerAcceptConnections();
return true;
}
bool ExtensionApiTest::InitializeEmbeddedTestServer() {
if (!embedded_test_server()->InitializeAndListen())
return false;
// Build a dictionary of values that tests can use to build URLs that
// access the test server and local file system. Tests can see these values
// using the extension API function chrome.test.getConfig().
if (test_config_) {
test_config_->SetInteger(kEmbeddedTestServerPort,
embedded_test_server()->port());
}
// else SetUpOnMainThread has not been called yet. Possibly because the
// caller needs a valid port in an overridden SetUpCommandLine method.
return true;
}
void ExtensionApiTest::EmbeddedTestServerAcceptConnections() {
embedded_test_server()->StartAcceptingConnections();
}
bool ExtensionApiTest::StartWebSocketServer(
const base::FilePath& root_directory,
bool enable_basic_auth) {
websocket_server_.reset(new net::SpawnedTestServer(
net::SpawnedTestServer::TYPE_WS, root_directory));
websocket_server_->set_websocket_basic_auth(enable_basic_auth);
if (!websocket_server_->Start())
return false;
test_config_->SetInteger(kTestWebSocketPort,
websocket_server_->host_port_pair().port());
return true;
}
bool ExtensionApiTest::StartFTPServer(const base::FilePath& root_directory) {
ftp_server_.reset(new net::SpawnedTestServer(net::SpawnedTestServer::TYPE_FTP,
root_directory));
if (!ftp_server_->Start())
return false;
test_config_->SetInteger(kFtpServerPort,
ftp_server_->host_port_pair().port());
return true;
}
void ExtensionApiTest::SetCustomArg(base::StringPiece custom_arg) {
test_config_->SetKey(kTestCustomArg, base::Value(custom_arg));
}
void ExtensionApiTest::SetUpCommandLine(base::CommandLine* command_line) {
ExtensionBrowserTest::SetUpCommandLine(command_line);
test_data_dir_ = test_data_dir_.AppendASCII("api_test");
RegisterPathProvider();
base::PathService::Get(DIR_TEST_DATA, &shared_test_data_dir_);
shared_test_data_dir_ = shared_test_data_dir_.AppendASCII("api_test");
// Backgrounded renderer processes run at a lower priority, causing the
// tests to take more time to complete. Disable backgrounding so that the
// tests don't time out.
command_line->AppendSwitch(::switches::kDisableRendererBackgrounding);
}
} // namespace extensions
|
endlessm/chromium-browser
|
chrome/browser/extensions/extension_apitest.cc
|
C++
|
bsd-3-clause
| 15,857
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cerrno>
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/indexed_db/indexed_db_backing_store.h"
#include "content/browser/indexed_db/leveldb/leveldb_database.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/leveldatabase/env_chromium.h"
using base::StringPiece;
using content::IndexedDBBackingStore;
using content::LevelDBComparator;
using content::LevelDBDatabase;
using content::LevelDBFactory;
using content::LevelDBSnapshot;
namespace base {
class TaskRunner;
}
namespace content {
class IndexedDBFactory;
}
namespace net {
class URLRequestContext;
}
namespace {
class BustedLevelDBDatabase : public LevelDBDatabase {
public:
BustedLevelDBDatabase() {}
static scoped_ptr<LevelDBDatabase> Open(
const base::FilePath& file_name,
const LevelDBComparator* /*comparator*/) {
return scoped_ptr<LevelDBDatabase>(new BustedLevelDBDatabase);
}
virtual leveldb::Status Get(const base::StringPiece& key,
std::string* value,
bool* found,
const LevelDBSnapshot* = 0) OVERRIDE {
return leveldb::Status::IOError("It's busted!");
}
private:
DISALLOW_COPY_AND_ASSIGN(BustedLevelDBDatabase);
};
class MockLevelDBFactory : public LevelDBFactory {
public:
MockLevelDBFactory() : destroy_called_(false) {}
virtual leveldb::Status OpenLevelDB(
const base::FilePath& file_name,
const LevelDBComparator* comparator,
scoped_ptr<LevelDBDatabase>* db,
bool* is_disk_full = 0) OVERRIDE {
*db = BustedLevelDBDatabase::Open(file_name, comparator);
return leveldb::Status::OK();
}
virtual leveldb::Status DestroyLevelDB(const base::FilePath& file_name)
OVERRIDE {
EXPECT_FALSE(destroy_called_);
destroy_called_ = true;
return leveldb::Status::IOError("error");
}
virtual ~MockLevelDBFactory() { EXPECT_TRUE(destroy_called_); }
private:
bool destroy_called_;
private:
DISALLOW_COPY_AND_ASSIGN(MockLevelDBFactory);
};
TEST(IndexedDBIOErrorTest, CleanUpTest) {
content::IndexedDBFactory* factory = NULL;
const GURL origin("http://localhost:81");
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
const base::FilePath path = temp_directory.path();
net::URLRequestContext* request_context = NULL;
MockLevelDBFactory mock_leveldb_factory;
blink::WebIDBDataLoss data_loss =
blink::WebIDBDataLossNone;
std::string data_loss_message;
bool disk_full = false;
base::TaskRunner* task_runner = NULL;
bool clean_journal = false;
leveldb::Status s;
scoped_refptr<IndexedDBBackingStore> backing_store =
IndexedDBBackingStore::Open(factory,
origin,
path,
request_context,
&data_loss,
&data_loss_message,
&disk_full,
&mock_leveldb_factory,
task_runner,
clean_journal,
&s);
}
// TODO(dgrogan): Remove expect_destroy if we end up not using it again. It is
// currently set to false in all 4 calls below.
template <class T>
class MockErrorLevelDBFactory : public LevelDBFactory {
public:
MockErrorLevelDBFactory(T error, bool expect_destroy)
: error_(error),
expect_destroy_(expect_destroy),
destroy_called_(false) {}
virtual leveldb::Status OpenLevelDB(
const base::FilePath& file_name,
const LevelDBComparator* comparator,
scoped_ptr<LevelDBDatabase>* db,
bool* is_disk_full = 0) OVERRIDE {
return MakeIOError(
"some filename", "some message", leveldb_env::kNewLogger, error_);
}
virtual leveldb::Status DestroyLevelDB(const base::FilePath& file_name)
OVERRIDE {
EXPECT_FALSE(destroy_called_);
destroy_called_ = true;
return leveldb::Status::IOError("error");
}
virtual ~MockErrorLevelDBFactory() {
EXPECT_EQ(expect_destroy_, destroy_called_);
}
private:
T error_;
bool expect_destroy_;
bool destroy_called_;
DISALLOW_COPY_AND_ASSIGN(MockErrorLevelDBFactory);
};
TEST(IndexedDBNonRecoverableIOErrorTest, NuancedCleanupTest) {
content::IndexedDBFactory* factory = NULL;
const GURL origin("http://localhost:81");
net::URLRequestContext* request_context = NULL;
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
const base::FilePath path = temp_directory.path();
blink::WebIDBDataLoss data_loss =
blink::WebIDBDataLossNone;
std::string data_loss_reason;
bool disk_full = false;
base::TaskRunner* task_runner = NULL;
bool clean_journal = false;
leveldb::Status s;
MockErrorLevelDBFactory<int> mock_leveldb_factory(ENOSPC, false);
scoped_refptr<IndexedDBBackingStore> backing_store =
IndexedDBBackingStore::Open(factory,
origin,
path,
request_context,
&data_loss,
&data_loss_reason,
&disk_full,
&mock_leveldb_factory,
task_runner,
clean_journal,
&s);
ASSERT_TRUE(s.IsIOError());
MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory2(
base::File::FILE_ERROR_NO_MEMORY, false);
scoped_refptr<IndexedDBBackingStore> backing_store2 =
IndexedDBBackingStore::Open(factory,
origin,
path,
request_context,
&data_loss,
&data_loss_reason,
&disk_full,
&mock_leveldb_factory2,
task_runner,
clean_journal,
&s);
ASSERT_TRUE(s.IsIOError());
MockErrorLevelDBFactory<int> mock_leveldb_factory3(EIO, false);
scoped_refptr<IndexedDBBackingStore> backing_store3 =
IndexedDBBackingStore::Open(factory,
origin,
path,
request_context,
&data_loss,
&data_loss_reason,
&disk_full,
&mock_leveldb_factory3,
task_runner,
clean_journal,
&s);
ASSERT_TRUE(s.IsIOError());
MockErrorLevelDBFactory<base::File::Error> mock_leveldb_factory4(
base::File::FILE_ERROR_FAILED, false);
scoped_refptr<IndexedDBBackingStore> backing_store4 =
IndexedDBBackingStore::Open(factory,
origin,
path,
request_context,
&data_loss,
&data_loss_reason,
&disk_full,
&mock_leveldb_factory4,
task_runner,
clean_journal,
&s);
ASSERT_TRUE(s.IsIOError());
}
} // namespace
|
chromium2014/src
|
content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc
|
C++
|
bsd-3-clause
| 7,962
|
#!/usr/bin/env python
'''
Copyright (C) 2020, WAFW00F Developers.
See the LICENSE file for copying permission.
'''
NAME = 'Edgecast (Verizon Digital Media)'
def is_waf(self):
schemes = [
self.matchHeader(('Server', r'^ECD(.+)?')),
self.matchHeader(('Server', r'^ECS(.*)?'))
]
if any(i for i in schemes):
return True
return False
|
EnableSecurity/wafw00f
|
wafw00f/plugins/edgecast.py
|
Python
|
bsd-3-clause
| 371
|
using System;
using Microsoft.AspNetCore.Authentication;
namespace WopiHost.Core.Security.Authentication
{
/// <summary>
/// WOPI-related extensions for <see cref="AuthenticationBuilder"/>.
/// </summary>
public static class AuthenticationBuilderExtensions
{
/// <summary>
/// Adds <see cref="AccessTokenHandler"/> to the <see cref="AuthenticationBuilder"/>.
/// </summary>
/// <param name="builder">An instance of <see cref="AuthenticationBuilder"/></param>
/// <param name="authenticationScheme">Schema name</param>
/// <param name="displayName">Schema display name</param>
/// <param name="configureOptions">A delegate for configuring <see cref="AccessTokenAuthenticationOptions"/></param>
/// <returns></returns>
public static AuthenticationBuilder AddTokenAuthentication(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action<AccessTokenAuthenticationOptions> configureOptions)
{
return builder.AddScheme<AccessTokenAuthenticationOptions, AccessTokenHandler>(authenticationScheme, displayName, configureOptions);
}
}
}
|
petrsvihlik/WopiHost
|
WopiHost.Core/Security/Authentication/AuthenticationBuilderExtensions.cs
|
C#
|
bsd-3-clause
| 1,111
|
#
# Define HPSS for 6.2 and above systems
#
LOCAL_ROOT = /opt/hpss
ROOT_SUBPATH = .
include $(LOCAL_ROOT)/Makefile.macros
COMPFLAGS = -O0 -g -Wall -Werror
INCLUDE_PATH = -I. -I$(LOCAL_INCLUDE) -I$(DB_INSTALL_PATH)/include
CFLAGS = $(INCLUDE_PATH) $(COMPFLAGS) $(MACHINE_FLAGS)
.c.o:; @echo "Compiling $<"...
@$(CC) $(CFLAGS) -c $<
LIBS = -L$(BUILD_LIB) \
-lhpss -lhpsscs -levent
POSIXLIB = -L/opt/hpss/tools/unsupported/lib/ \
-lhpssposix
LDFLAGS = $(COMPFLAGS) $(RUNFLAGS)
OBJ = util.o utf8.o hpss_mkdir.o hpss_chmod.o hpss_rm.o hpss_ls.o \
hpss_put_from_proxy.o hpss_get_to_proxy.o hpss_link.o hpss_stat.o \
hpss_rename.o hpss_set_uda.o hpss_get_storage_info.o hpss_chown.o\
hpss_get_udas.o hpss_del_uda.o hpss_stage.o hpss_purge.o\
hpss_get_to_client.o hpss_purge_lock.o
PROG = hpss-http_proxy
all: $(PROG)
clean:; /bin/rm -f *.o $(PROG)
hpss-http_proxy: hpss-http_proxy.o $(OBJ)
@echo "Linking $@"...
@$(CC) $@.o -o $@ $(CFLAGS) $(LDFLAGS) $(OBJ) $(LIBS)
|
chanke/hpss-utils
|
hpss-http_proxy/src/src/Makefile
|
Makefile
|
bsd-3-clause
| 1,120
|
{-# LANGUAGE GADTs, TypeOperators #-}
module Compiler.InstantiateLambdas (instantiate, dump) where
import Compiler.Generics
import Compiler.Expression
import Control.Applicative
import Control.Arrow hiding (app)
import Control.Monad.Reader
import Data.List (intercalate)
import qualified Lang.Value as V
instantiate :: Arrow (~>) => V.Val l i ~> Expression
instantiate = arr (flip runReader 0 . tr)
where
tr :: V.Val l i -> Reader Integer Expression
tr (V.App f a ) = app <$> tr f <*> tr a
tr (V.Con c ) = pure (con c)
tr (V.Lam f ) = local (+1) (ask >>= \r -> let v = 'v':show r in lam [v] <$> tr (f (V.Var v)))
tr (V.Name n e ) = name n <$> tr e
tr (V.Prim s vs) = pure (prim s vs)
tr (V.Var v ) = pure (var v)
dump :: Arrow (~>) => Expression ~> String
dump = arr rec
where
tr (App f e ) = rec f ++ "(\n" ++ indent (rec e) ++ ")"
tr (Con c ) = c
tr (Lam as e) = "(function (" ++ intercalate ", " as ++ ")" ++ "\n{\n" ++ indent ("return " ++ rec e ++ ";") ++ "\n})"
tr (Name n e ) = "/* " ++ n ++ "*/ " ++ rec e
tr (Prim s vs) = s vs ++ " /* free: " ++ intercalate ", " vs ++ " */"
tr (Var v ) = v
rec = tr . unId . out
indent = unlines . map (" "++) . lines
|
tomlokhorst/AwesomePrelude
|
src/Compiler/InstantiateLambdas.hs
|
Haskell
|
bsd-3-clause
| 1,251
|
% COMMAND-WRAPPER-EXEC(1) Command Wrapper 0.1.0 | Command Wrapper
% Peter Trsko
% 17th April 2020
# NAME
`command-wrapper-exec` - Execute predefined command with a user specified
environment.
# USAGE
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec \[\--notify] [\--] *COMMAND*
\[*COMMAND\_ARGUMENTS*]
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec {\--list|\--ls|-l|\--tree|-t}
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec \--expression=*EXPRESSION* \[\--notify]
[\--] \[*COMMAND\_ARGUMENTS*]
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec \--print [\--] *COMMAND*
\[*COMMAND\_ARGUMENTS*]
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec \--print-completion \--index=*NUM*
\--shell=*SHELL* *COMMAND* [\--] \[*COMMAND\_ARGUMENTS*]
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] exec {\--help|-h}
TOOLSET\_COMMAND \[GLOBAL\_OPTIONS] help exec
# DESCRIPTION
Purpose of this subcommand is to build "porcelain" actions, a set high-level
easy to use commands. They should have simpler API, completion, and
hierarchical structure (dot-separated, e.g. `docker.purne`). If something is
too complex to be implemented using exec then it should go into a script, or it
should be implemented as a separate subcommand.
What we mean by hierarchical is for example following:
```
psql.development.cart
psql.development.products
psql.production.cart
psql.production.products
```
In the above example the structure implies certain command line options and/or
environment variables passed to the underlying command. Specifically, which
environment (production or development) to use, and what database to connect to
(cart or products). To make understanding and organising commands easier `exec`
provides `--tree` option to list its commands in tree structure. Above example
would look something like:
```
├── psql
│ ├── development
│ │ ├── cart
│ │ └── products
│ └── production
│ ├── cart
│ └── products
└── ...
```
This functionality is probably the closest thing to common pattern of putting a
`Makefile` into project root directory just to have few phony targets. If we
look at it from different perspective then we can see that `exec` command
provides similar functionality to some shell features, especially aliases.
Exec's configuration defines list of commands (in form of a Dhall function)
associated with a symbolic name. For each command we can specify a working
directory, environment variables, arguments, completion, and working directory.
The ability to specify working directory is very interesting for big projects
that consist of multiple separate applications. Just one example of subcommand
names to illustrate its usefulness:
```
yarn.eshop.cart
yarn.eshop.orders
yarn.eshop.product-view
yarn.eshop.search
```
Most of exec's features, as well as restriction, come from using Dhall for
configuration. Biggest advantage is probably that it's possible to share
command definitions in the form of Dhall files. Those we can safely import
even from an URL. All of this can be done without dropping into general
purpose scripting language like Bash.
# OPTIONS
\--list, \--ls, -l
: List available *COMMAND*s.
\--tree, \-t
: List available *COMMAND*s in tree-like form treating dots (`.`) as
separators.
Let's say that we have following commands reported by `--list`:
```
build.back-end
build.back-end.locally
build.back-end.remotely
build.front-end
build.back-end.locally
build.back-end.remotely
debug
echo
```
These would be displayed as a following tree:
```
├── build
│ ├── back-end
│ │ ├── locally
│ │ └── remotely
│ └── front-end
│ ├── locally
│ └── remotely
├── debug
└── echo
```
\--expression=*EXPRESSION*
: Execute Dhall *EXPRESSION*. The *EXPRESSION* can have one of the following
types:
1. `CommandWrapper.ExecCommand.Type` constructor function:
```Dhall
∀(verbosity : CommandWrapper.Verbosity.Type)
→ ∀(colour : CommandWrapper.ColourOutput.Type)
→ ∀(arguments : List Text)
→ CommandWrapper.ExecCommand.Type
```
For example:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in λ(verbosity : CommandWrapper.Verbosity.Type)
→ λ(colourOutput : CommandWrapper.ColourOutput.Type)
→ λ(arguments : List Text)
→ CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = arguments
, environment = [] : List CommandWrapper.EnvironmentVariable.Type
, searchPath = True
, workingDirectory = None Text
}
```
2. `CommandWrapper.ExecCommand.Type`, for example:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = [] : List Text
, environment = [] : List CommandWrapper.EnvironmentVariable.Type
, searchPath = True
, workingDirectory = None Text
}
```
Expression of type `CommandWrapper.ExecCommand.Type` is what is created
with `--print` option.
In this case user-provided arguments will be appended to the value
supplied in `arguments` field.
3. `CommandWrapper.Command.Type`, for example:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in CommandWrapper.Command::{
, command = "echo"
, arguments = [] : List Text
}
```
In this case user-provided arguments will be appended to the value
supplied in `arguments` field.
4. `CommandWrapper.ExecNamedCommand.Type`, for example:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in CommandWrapper.ExecNamedCommand::{
, name = "echo"
, command =
λ(verbosity : CommandWrapper.Verbosity.Type)
→ λ(colourOutput : CommandWrapper.ColourOutput.Type)
→ λ(arguments : List Text)
→ CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = arguments
}
}
```
This one is probably the best one for designing new `exec` commands
that can be immediately plugged into its configuration file.
This feature (`--expression=`*EXPRESSION*`) is very useful when designing
new commands.
\--notify
: Send desktop notification when the command is done.
\--print
: Print command as it will be executed in Dhall format. Can be used as
dry-run functionality, for debugging, and for creating template when adding
new command. Any *COMMAND_ARGUMENTS* are passed to the Dhall
function before it being evaluated.
Let's say that configuration contains following command definition:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in CommandWrapper.ExecConfig::{
, commands =
[ CommandWrapper.ExecNamedCommand::{
, name = "echo"
, description = Some "Call echo command (not the shell builtin)."
, command =
λ(_ : CommandWrapper.Verbosity.Type)
→ λ(_ : CommandWrapper.ColourOutput.Type)
→ λ(arguments : List Text)
→ CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = arguments
}
}
]
}
```
If we call following:
```
TOOLSET_COMMAND exec --print echo foo bar
```
Then we'll get output like this one:
```Dhall
{ command = "echo"
, arguments = [ "foo", "bar" ]
, environment = [] : List { name : Text, value : Text }
, searchPath = True
, workingDirectory = None Text
}
```
See also *CONFIGURATION FILE* section for more information.
\--print-completion
: Similar to `--print`, but prints command that would be used to do command
line completion if it was invoked. Additional options `--index=`*NUM*, and
`--shell=`*SHELL* are passed to the command line completion command.
\--help, -h
: Display help information and exit. Same as `TOOLSET_COMMAND help exec`.
*COMMAND*
: `COMMAND` is a symbolic command name as it is specified in configuration
file. If available then it is executed. Any *COMMAND_ARGUMENTS* are
passed to it. See *CONFIGURATION FILE* section for more details.
*COMMAND_ARGUMENTS*
: Extra arguments that are passed to the command referenced by *COMMAND*. See
*CONFIGURATION FILE* section for more details.
# EXIT STATUS
For documentation of generic *EXIT STATUS* codes see `command-wrapper(1)`
manual page section *EXIT STATUS*. Any *EXIT STATUS* codes specific to this
subcommand will be listed below.
# FILES
`${XDG_CONFIG_HOME:-$HOME/.config}/${toolset}/command-wrapper-exec.dhall`
: Configuration file specifies *COMMAND*s that can be invoked. Command
configuration is actually a function with a name associated with it.
See also `XDG_CONFIG_HOME` in *ENVIRONMENT VARIABLES* section for more
information on how Command Wrapper figures out where to look for this
configuration file.
# ENVIRONMENT VARIABLES
See also `command-wrapper(1)` *ENVIRONMENT VARIABLES* section. Everything
mentioned there applies to this subcommand as well.
`XDG_CONFIG_HOME`
: Overrides where this subcommand expects its configuration file. It follows
this simple logic:
* If `XDG_CONFIG_HOME` environment variable is set then the configuration
file has path:
```
${XDG_CONFIG_HOME}/${toolset}/command-wrapper-exec.dhall
```
* If `XDG_CONFIG_HOME` environment variable is not set then default value
is used instead:
```
${HOME}/.config/${toolset}/command-wrapper-exec.dhall
```
See [XDG Base Directory Specification
](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
for more information on rationale behind this.
# CONFIGURATION FILE
See *FILES* section for documentation on where `exec`'s configuration file is
located.
Following example shows `exec` configuration file with one subcommand named
`echo` (for more see *EXAMPLES* section):
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
in CommandWrapper.ExecConfig::{
, commands =
[ CommandWrapper.ExecNamedCommand::{
, name = "echo"
, description = Some "Call echo command (not the shell builtin)."
, command =
λ(_ : CommandWrapper.Verbosity.Type)
→ λ(_ : CommandWrapper.ColourOutput.Type)
→ λ(arguments : List Text)
→ CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = arguments
}
}
]
}
```
If we expand `CommandWrapper.ExecNamedCommand.Type` type we get:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
-- Note that adding a hash will allow Dhall to cache the import.
-- See also `dhall hash --help`.
in -- List of commands that `exec` subcommand can execute.
{ commands :
List
-- Symbolic name for this command (`COMMAND`)
-- that can be used to invoke it via:
--
-- TOOLSET_COMMAND exec COMMAND
--
-- See `COMMAND` description for more details.
{ name : Text
-- Description of `COMMAND` which is printed when `exec`
-- is invoked with `--list` option.
, description : Optional Text
-- Function that constructs command description
-- that we can execute.
, command :
-- Verbosity is taken from following
-- environment variable:
--
-- COMMAND_WRAPPER_VERBOSITY
--
-- See `command-wrapper-subcommand-protocol(7)`
-- for more details on its purpose.
∀(verbosity : CommandWrapper.Verbosity.Type)
-- Colour output preferences are taken from
-- following environment variable:
--
-- COMMAND_WRAPPER_COLOUR
--
-- See `command-wrapper-subcommand-protocol(7)`
-- for more details on its purpose.
→ ∀(colourOutput : CommandWrapper.ColourOutput.Type)
-- Extra arguments passed on command line.
-- See `EXTRA_COMMAND_ARGUMENTS` for more
-- details.
→ ∀(arguments : List Text)
-- Either command name of fill file path
-- to an executable. We search for it in
-- `$PATH` only if `searchPath = True`
→ { command : Text
-- Arguments as they are passed to `command`
-- when executed. Usually we want to append
-- `EXTRA_COMMAND_ARGUMENTS`, but not always.
, arguments : List Text
-- Look for `command` in `$PATH`?
--
-- * True - Yes, search `$PATH` for `command`.
-- * False - No, ignore `$PATH` and execute
-- `command` as it is. Usually requires
-- `command` to be a full path.
, searchPath : Bool
-- Additional environment variables to
-- pass to the `command` when executed.
-- They may override existing environment
-- variables.
, environment : List CommandWrapper.EnvironmentVariable.Type
-- Change working directory before executing
-- `command`, if specified. Otherwise keep
-- working directory unchanged.
, workingDirectory : Optional Text
}
-- Alternative command to invoke when performing
-- command line completion.
, completion :
Optional
( ∀(shell : CommandWrapper.Shell.Type)
→ ∀(index : Natural)
→ ∀(arguments : List Text)
→ CommandWrapper.ExecCommand.Type
)
, notifyWhen : Optional CommandWrapper.NotifyWhen.Type
}
}
```
See also following (*EXAMPLES*) section.
# EXAMPLES
Lets say
`${XDG_CONFIG_HOME:-$HOME/.config}/command-wrapper/command-wrapper-exec.dhall`
contains the following:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
-- Note that adding a hash will allow Dhall to cache the import.
-- See also `dhall hash --help`.
in CommandWrapper.ExecConfig::{
, commands =
-- Use smart constructor to create named commands to avoid upgrade
-- issues any time there is a change in definition of
-- `CommandWrapper.ExecNamedCommand.Type`.
[ CommandWrapper.ExecNamedCommand::{
-- Name of the command we are defining, this will be what needs to
-- be passed to `exec` to invoke it:
-- ```
-- TOOLSET_COMMAND [GLOBAL_OPTIONS] exec [EXEC_OPTIONS] echo [ARGUMENTS]
-- ```
, name = "echo"
, description = Some "Call echo command (not the shell builtin)."
-- We are ignoring `verbosity` and `colourOutput`, both of those
-- are passed down from toolset configuration and GLOBAL_OPTIONS.
-- Therefore, we can construct a command that respects those
-- options as well.
, command =
( λ(verbosity : CommandWrapper.Verbosity.Type)
→ λ(colourOutput : CommandWrapper.ColourOutput.Type)
→ λ(arguments : List Text)
→ CommandWrapper.ExecCommand::{
, command = "echo"
, arguments = arguments
-- Following default values can be omitted:
, environment = CommandWrapper.Environment.empty
, searchPath = True
, workingDirectory = None Text
}
)
}
]
}
```
Then we can run it as:
```
user@machine ~ $ TOOLSET_COMMAND exec echo hello world
hello world
```
We can simplify that if we modify `TOOLSET_COMMAND` configuration to provide an
alias for it. Following is a function that if applied to toolset configuration
will add an alias named `hello.world`:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
-- Note that adding a hash will allow Dhall to cache the import.
-- See also `dhall hash --help`.
in λ(cfg : CommandWrapper.ToolsetConfig.Type)
→ cfg
// { aliases =
cfg.aliases
# [ { alias = "hello.world"
, description = None Text
, command = "exec"
, arguments = ["echo", "hello", "world"] : List Text
}
]
}
```
After that we can run:
```
user@machine ~ $ TOOLSET_COMMAND hello.world
hello world
user@machine ~ $ TOOLSET_COMMAND hello.world again
hello world again
```
Following Dhall expression will create aliases for all exec commands:
```Dhall
let CommandWrapper =
https://raw.githubusercontent.com/trskop/command-wrapper/master/command-wrapper/dhall/CommandWrapper/package.dhall
let execConfig = ../command-wrapper-exec.dhall
in CommandWrapper.ExecNamedCommand.namedCommandsToAliases execConfig.commands
```
It is ment to be put into
`${XDG_CONFIG_HOME:-$HOME/.config}/command-wrapper/default/exec-aliases.dhall`
and included in
`${XDG_CONFIG_HOME:-$HOME/.config}/command-wrapper/default.dhall`.
# SEE ALSO
command-wrapper(1)
* [XDG Base Directory Specification
](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
# BUGS
<https://github.com/trskop/command-wrapper/issues>
|
trskop/command-wrapper
|
command-wrapper/man/command-wrapper-exec.1.md
|
Markdown
|
bsd-3-clause
| 19,142
|
/*
Copyright (c) 2000-2021, Board of Trustees of Leland Stanford Jr. University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.lockss.plugin;
import org.lockss.test.*;
/**
* <p>
* Unit tests of {@link HttpHttpsUrlHelper}.
* </p>
*
* @author Thib Guicherd-Callin
* @since 1.75.4
* @see HttpHttpsUrlHelper
*/
public class TestHttpHttpsUrlHelper extends LockssTestCase {
/**
* <p>
* Tests a typical {@link HttpHttpsUrlHelper}.
* </p>
*
* @throws Exception
* if an error occurs.
* @since 1.75.4
*/
public void testHttpHttpsUrlHelper() throws Exception {
MockArchivalUnit au = new MockArchivalUnit();
au.setConfiguration(ConfigurationUtil.fromArgs("foo_url", "http://foo.example.com/",
"bar_url", "https://bar.example.com/"));
HttpHttpsUrlHelper helper = new HttpHttpsUrlHelper(au, "foo_url", "bar_url");
// URLs from foo.example.com should all be normalized to http://
assertEquals("http://foo.example.com/some/path.html",
helper.normalize("http://foo.example.com/some/path.html"));
assertEquals("http://foo.example.com/some/path.html",
helper.normalize("https://foo.example.com/some/path.html"));
// URLs from bar.example.com should all be normalized to https://
assertEquals("https://bar.example.com/some/path.html",
helper.normalize("http://bar.example.com/some/path.html"));
assertEquals("https://bar.example.com/some/path.html",
helper.normalize("https://bar.example.com/some/path.html"));
// URLs from other hosts (e.g. www.example.com) should be unchanged
assertEquals("http://www.example.com/some/path.html",
helper.normalize("http://www.example.com/some/path.html"));
assertEquals("https://www.example.com/some/path.html",
helper.normalize("https://www.example.com/some/path.html"));
}
/**
* <p>
* Tests the default constructor
* {@link HttpHttpsUrlHelper#HttpHttpsUrlHelper(ArchivalUnit)}, which implies
* {@code base_url} only.
* </p>
*
* @throws Exception
* if an error occurs.
* @since 1.75.4
*/
public void testDefault() throws Exception {
MockArchivalUnit au = new MockArchivalUnit();
au.setConfiguration(ConfigurationUtil.fromArgs("base_url", "http://foo.example.com/",
"bar_url", "https://bar.example.com/"));
HttpHttpsUrlHelper helper = new HttpHttpsUrlHelper(au); // default implies just "base_url"
// URLs from foo.example.com should all be normalized to http://
assertEquals("http://foo.example.com/some/path.html",
helper.normalize("http://foo.example.com/some/path.html"));
assertEquals("http://foo.example.com/some/path.html",
helper.normalize("https://foo.example.com/some/path.html"));
// URLs from bar.example.com should be unchanged
assertEquals("http://bar.example.com/some/path.html",
helper.normalize("http://bar.example.com/some/path.html"));
assertEquals("https://bar.example.com/some/path.html",
helper.normalize("https://bar.example.com/some/path.html"));
// URLs from other hosts (e.g. www.example.com) should be unchanged
assertEquals("http://www.example.com/some/path.html",
helper.normalize("http://www.example.com/some/path.html"));
assertEquals("https://www.example.com/some/path.html",
helper.normalize("https://www.example.com/some/path.html"));
}
}
|
lockss/lockss-daemon
|
test/src/org/lockss/plugin/TestHttpHttpsUrlHelper.java
|
Java
|
bsd-3-clause
| 5,017
|
#include "mantra_character.h"
CMCharacter::CMCharacter(){
char_init();
}
CMCharacter::~CMCharacter(){
DEL(m_class);
DEL(health);
DEL(mana);
DEL(intel);
DEL(str);
DEL(spi);
DEL(agi);
}
void CMCharacter::char_init(void){
m_class=new CMClass;
health=new CMStat;
mana=new CMStat;
intel=new CMStat;
str=new CMStat;
spi=new CMStat;
agi=new CMStat;
}
|
sethcoder/ember
|
src/mantra_character.cpp
|
C++
|
bsd-3-clause
| 407
|
/**
** @file tcOptionsView2.h
*/
/*
** Copyright (c) 2014, GCBLUE PROJECT
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
**
** 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
**
** 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
**
** 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from
** this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
** NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
** IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _OPTIONSVIEW2_H_
#define _OPTIONSVIEW2_H_
#if _MSC_VER > 1000
#pragma once
#endif
#include "wx/wx.h"
#include <boost/shared_ptr.hpp>
#include "tcOptions.h"
#include "tcXmlWindow.h"
#include "tcTabbedWindow.h"
class tcTexture2D;
class tcOptions;
class tcSound;
/// View and GUI for user options data
class tcOptionsView2 : public tcXmlWindow, public tcTabbedWindow
{
// placement info for GUI buttons, text, etc.
struct tsButtonInfo
{
int buttonX;
int buttonY;
int textX;
int textY;
int optionIdx;
int valueIdx;
bool isSlider; ///< a hack to add sliders
tcRect thumbRect; ///< rect of slider "thumb"
};
public:
void Init();
void Draw();
void DrawButton(int x, int y, int abOn);
void DrawSlider(int x, int y, tcRect thumbRect, float value, bool interacting);
void OnLButtonDown(wxMouseEvent& event);
void OnLButtonUp(wxMouseEvent& event);
void OnLeaveWindow(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
bool OnLButtonDownSlider(const wxPoint& pos);
void OnSize(wxSizeEvent& event);
virtual void SetActive(bool abActive);
bool ButtonContainingPoint(wxPoint point, int& rnOption, int& rnValue);
tcOptionsView2(wxWindow* parent,
const wxPoint& pos, const wxSize& size,
const wxString& name = "OptionsView");
tcOptionsView2(tc3DWindow2* parent,
const wxPoint& pos, const wxSize& size,
const wxString& name);
virtual ~tcOptionsView2();
private:
tcOptions *mpOptions;
struct ControlGroup
{
std::string groupName;
std::vector<tc3DWindow2*> controls;
std::vector<tc3DWindow2*> labels;
};
std::vector<ControlGroup> controlGroups;
boost::shared_ptr<tcTexture2D> mpiButtonOn;
boost::shared_ptr<tcTexture2D> mpiButtonOff;
float fontSize; ///< font size of options choice text
int mnButtonWidth;
int mnButtonHeight;
std::vector<tsButtonInfo> buttonInfo;
int mnXStart;
int mnYStart;
std::string lastTab;
// section to support dragging slider bar
const float sliderBarWidth;
bool sliderDragActive;
size_t sliderIdx; ///< index in buttonInfo of slider being dragged
wxPoint buttonDownPoint;
float sliderDragValue;
std::string buttonDownTab; ///< to detect if tab has been changed in middle of drag
void OnControlUpdate(wxCommandEvent& event);
void CloseAllLists();
void UpdateButtonInfo();
DECLARE_EVENT_TABLE()
};
#endif // _OPTIONSVIEW_H_
|
gcblue/gcblue
|
include/graphics/tcOptionsView2.h
|
C
|
bsd-3-clause
| 4,075
|
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-08 22:45
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('topics', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='articletopicrank',
options={'ordering': ('rank',)},
),
migrations.AlterModelOptions(
name='wordtopicrank',
options={'ordering': ('rank',)},
),
]
|
GeorgiaTechDHLab/TOME
|
topics/migrations/0002_auto_20170308_2245.py
|
Python
|
bsd-3-clause
| 537
|
#ifndef COG_H
#define COG_H
#include <wheel.h>
namespace cog
{
class CoreEngine
{
private:
bool setup_paths(const char* pname);
protected:
wcl::ModuleLibrary modulelibrary;
wheel::interface::Video* window;
wheel::interface::Audio* audio;
wheel::Library library;
struct
{
wheel::string save;
wheel::string content;
wheel::string module;
} paths;
public:
wheel::EventList eventlist;
wheel::interface::Video* video_ptr() { return window; }
wheel::interface::Audio* audio_ptr() { return audio; }
virtual bool run();
bool running();
CoreEngine(const char* name, int argc, char* argv[]);
virtual ~CoreEngine() { wcl::terminate(); }
};
}
#endif
|
ronchaine/wheel-extras
|
include/cog.h
|
C
|
bsd-3-clause
| 971
|
package com.madgnome.jira.plugins.jirachievements.utils.initializers;
import com.madgnome.jira.plugins.jirachievements.data.services.IProjectVersionStatisticDaoService;
public class ProjectVersionStatisticInitializer extends ClearTableInitializer<IProjectVersionStatisticDaoService>
{
public ProjectVersionStatisticInitializer(IProjectVersionStatisticDaoService daoService)
{
super(daoService);
}
}
|
madgnome/jirachievements
|
src/main/java/com/madgnome/jira/plugins/jirachievements/utils/initializers/ProjectVersionStatisticInitializer.java
|
Java
|
bsd-3-clause
| 412
|
<?php
/**
* This file is the main Package Manager.
*
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2021 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.1 RC4
*/
if (!defined('SMF'))
die('No direct access...');
/**
* This is the notoriously defunct package manager..... :/.
*/
function Packages()
{
global $txt, $sourcedir, $context;
// @todo Remove this!
if (isset($_GET['get']) || isset($_GET['pgdownload']))
{
require_once($sourcedir . '/PackageGet.php');
return PackageGet();
}
isAllowedTo('admin_forum');
// Load all the basic stuff.
require_once($sourcedir . '/Subs-Package.php');
loadLanguage('Packages');
loadTemplate('Packages', 'admin');
$context['page_title'] = $txt['package'];
// Delegation makes the world... that is, the package manager go 'round.
$subActions = array(
'browse' => 'PackageBrowse',
'remove' => 'PackageRemove',
'list' => 'PackageList',
'ftptest' => 'PackageFTPTest',
'install' => 'PackageInstallTest',
'install2' => 'PackageInstall',
'uninstall' => 'PackageInstallTest',
'uninstall2' => 'PackageInstall',
'options' => 'PackageOptions',
'perms' => 'PackagePermissions',
'flush' => 'FlushInstall',
'examine' => 'ExamineFile',
'showoperations' => 'ViewOperations',
);
// Work out exactly who it is we are calling.
if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
$context['sub_action'] = $_REQUEST['sa'];
else
$context['sub_action'] = 'browse';
// Set up some tabs...
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['package_manager'],
// @todo 'help' => 'registrations',
'description' => $txt['package_manager_desc'],
'tabs' => array(
'browse' => array(
),
'packageget' => array(
'description' => $txt['download_packages_desc'],
),
'perms' => array(
'description' => $txt['package_file_perms_desc'],
),
'options' => array(
'description' => $txt['package_install_options_desc'],
),
),
);
if ($context['sub_action'] == 'browse')
loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
call_integration_hook('integrate_manage_packages', array(&$subActions));
// Call the function we're handing control to.
call_helper($subActions[$context['sub_action']]);
}
/**
* Test install a package.
*/
function PackageInstallTest()
{
global $boarddir, $txt, $context, $scripturl, $sourcedir, $packagesdir, $modSettings, $smcFunc, $settings;
// You have to specify a file!!
if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '')
redirectexit('action=admin;area=packages');
$context['filename'] = preg_replace('~[\.]+~', '.', $_REQUEST['package']);
// Do we have an existing id, for uninstalls and the like.
$context['install_id'] = isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : 0;
require_once($sourcedir . '/Subs-Package.php');
// Load up the package FTP information?
create_chmod_control();
// Make sure temp directory exists and is empty.
if (file_exists($packagesdir . '/temp'))
deltree($packagesdir . '/temp', false);
if (!mktree($packagesdir . '/temp', 0755))
{
deltree($packagesdir . '/temp', false);
if (!mktree($packagesdir . '/temp', 0777))
{
deltree($packagesdir . '/temp', false);
create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'], 'crash_on_error' => true));
deltree($packagesdir . '/temp', false);
if (!mktree($packagesdir . '/temp', 0777))
fatal_lang_error('package_cant_download', false);
}
}
$context['uninstalling'] = $_REQUEST['sa'] == 'uninstall';
// Change our last link tree item for more information on this Packages area.
$context['linktree'][count($context['linktree']) - 1] = array(
'url' => $scripturl . '?action=admin;area=packages;sa=browse',
'name' => $context['uninstalling'] ? $txt['package_uninstall_actions'] : $txt['install_actions']
);
$context['page_title'] .= ' - ' . ($context['uninstalling'] ? $txt['package_uninstall_actions'] : $txt['install_actions']);
$context['sub_template'] = 'view_package';
if (!file_exists($packagesdir . '/' . $context['filename']))
{
deltree($packagesdir . '/temp');
fatal_lang_error('package_no_file', false);
}
// Extract the files so we can get things like the readme, etc.
if (is_file($packagesdir . '/' . $context['filename']))
{
$context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml'))
foreach ($context['extracted_files'] as $file)
if (basename($file['filename']) == 'package-info.xml')
{
$context['base_path'] = dirname($file['filename']) . '/';
break;
}
if (!isset($context['base_path']))
$context['base_path'] = '';
}
elseif (is_dir($packagesdir . '/' . $context['filename']))
{
copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
$context['extracted_files'] = listtree($packagesdir . '/temp');
$context['base_path'] = '';
}
else
fatal_lang_error('no_access', false);
// Load up any custom themes we may want to install into...
$request = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE (id_theme = {int:default_theme} OR id_theme IN ({array_int:known_theme_list}))
AND variable IN ({string:name}, {string:theme_dir})',
array(
'known_theme_list' => explode(',', $modSettings['knownThemes']),
'default_theme' => 1,
'name' => 'name',
'theme_dir' => 'theme_dir',
)
);
$theme_paths = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
$smcFunc['db_free_result']($request);
// Get the package info...
$packageInfo = getPackageInfo($context['filename']);
if (!is_array($packageInfo))
fatal_lang_error($packageInfo);
$packageInfo['filename'] = $context['filename'];
$context['package_name'] = isset($packageInfo['name']) ? $packageInfo['name'] : $context['filename'];
// Set the type of extraction...
$context['extract_type'] = isset($packageInfo['type']) ? $packageInfo['type'] : 'modification';
// Get our validation info.
$context['validation_tests'] = package_validate_installtest(array(
'file_name' => $packagesdir . '/' . $context['filename'],
'custom_id' => !empty($packageInfo['id']) ? $packageInfo['id'] : '',
'custom_type' => $context['extract_type']
));
// The mod isn't installed.... unless proven otherwise.
$context['is_installed'] = false;
// See if it is installed?
$request = $smcFunc['db_query']('', '
SELECT version, themes_installed, db_changes
FROM {db_prefix}log_packages
WHERE package_id = {string:current_package}
AND install_state != {int:not_installed}
ORDER BY time_installed DESC
LIMIT 1',
array(
'not_installed' => 0,
'current_package' => $packageInfo['id'],
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$old_themes = explode(',', $row['themes_installed']);
$old_version = $row['version'];
$db_changes = empty($row['db_changes']) ? array() : $smcFunc['json_decode']($row['db_changes'], true);
}
$smcFunc['db_free_result']($request);
$context['database_changes'] = array();
if (isset($packageInfo['uninstall']['database']))
$context['database_changes'][] = sprintf($txt['package_db_code'], $packageInfo['uninstall']['database']);
if (!empty($db_changes))
{
foreach ($db_changes as $change)
{
if (isset($change[2]) && isset($txt['package_db_' . $change[0]]))
$context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]);
elseif (isset($txt['package_db_' . $change[0]]))
$context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]);
else
$context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : '');
}
}
// Uninstalling?
if ($context['uninstalling'])
{
// Wait, it's not installed yet!
if (!isset($old_version) && $context['uninstalling'])
{
deltree($packagesdir . '/temp');
fatal_lang_error('package_cant_uninstall', false);
}
$actions = parsePackageInfo($packageInfo['xml'], true, 'uninstall');
// Gadzooks! There's no uninstaller at all!?
if (empty($actions))
{
deltree($packagesdir . '/temp');
fatal_lang_error('package_uninstall_cannot', false);
}
// Can't edit the custom themes it's edited if you're uninstalling, they must be removed.
$context['themes_locked'] = true;
// Only let them uninstall themes it was installed into.
foreach ($theme_paths as $id => $data)
if ($id != 1 && !in_array($id, $old_themes))
unset($theme_paths[$id]);
}
elseif (isset($old_version) && $old_version != $packageInfo['version'])
{
// Look for an upgrade...
$actions = parsePackageInfo($packageInfo['xml'], true, 'upgrade', $old_version);
// There was no upgrade....
if (empty($actions))
$context['is_installed'] = true;
else
{
// Otherwise they can only upgrade themes from the first time around.
foreach ($theme_paths as $id => $data)
if ($id != 1 && !in_array($id, $old_themes))
unset($theme_paths[$id]);
}
}
elseif (isset($old_version) && $old_version == $packageInfo['version'])
$context['is_installed'] = true;
if (!isset($old_version) || $context['is_installed'])
$actions = parsePackageInfo($packageInfo['xml'], true, 'install');
$context['actions'] = array();
$context['ftp_needed'] = false;
$context['has_failure'] = false;
$chmod_files = array();
// no actions found, return so we can display an error
if (empty($actions))
return;
// This will hold data about anything that can be installed in other themes.
$themeFinds = array(
'candidates' => array(),
'other_themes' => array(),
);
// Now prepare things for the template.
foreach ($actions as $action)
{
// Not failed until proven otherwise.
$failed = false;
$thisAction = array();
if ($action['type'] == 'chmod')
{
$chmod_files[] = $action['filename'];
continue;
}
elseif ($action['type'] == 'readme' || $action['type'] == 'license')
{
$type = 'package_' . $action['type'];
if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename']))
$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r"));
elseif (file_exists($action['filename']))
$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r"));
if (!empty($action['parse_bbc']))
{
require_once($sourcedir . '/Subs-Post.php');
$context[$type] = preg_replace('~\[[/]?html\]~i', '', $context[$type]);
preparsecode($context[$type]);
$context[$type] = parse_bbc($context[$type]);
}
else
$context[$type] = nl2br($context[$type]);
continue;
}
// Don't show redirects.
elseif ($action['type'] == 'redirect')
continue;
elseif ($action['type'] == 'error')
{
$context['has_failure'] = true;
if (isset($action['error_msg']) && isset($action['error_var']))
$context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']);
elseif (isset($action['error_msg']))
$context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg'];
}
elseif ($action['type'] == 'modification')
{
if (!file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename']))
{
$context['has_failure'] = true;
$context['actions'][] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_missing'],
'failed' => true,
);
}
else
{
if ($action['boardmod'])
$mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
else
$mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths);
if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-')
$mod_actions[0]['filename'] = $action['filename'];
foreach ($mod_actions as $key => $mod_action)
{
// Lets get the last section of the file name.
if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
else
$actual_filename = $key;
if ($mod_action['type'] == 'opened')
$failed = false;
elseif ($mod_action['type'] == 'failure')
{
if (empty($mod_action['is_custom']))
$context['has_failure'] = true;
$failed = true;
}
elseif ($mod_action['type'] == 'chmod')
{
$chmod_files[] = $mod_action['filename'];
}
elseif ($mod_action['type'] == 'saved')
{
if (!empty($mod_action['is_custom']))
{
if (!isset($context['theme_actions'][$mod_action['is_custom']]))
$context['theme_actions'][$mod_action['is_custom']] = array(
'name' => $theme_paths[$mod_action['is_custom']]['name'],
'actions' => array(),
'has_failure' => $failed,
);
else
$context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed;
$context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'],
'failed' => $failed,
);
}
elseif (!isset($context['actions'][$actual_filename]))
{
$context['actions'][$actual_filename] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'],
'failed' => $failed,
);
}
else
{
$context['actions'][$actual_filename]['failed'] |= $failed;
$context['actions'][$actual_filename]['description'] = $context['actions'][$actual_filename]['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'];
}
}
elseif ($mod_action['type'] == 'skipping')
{
$context['actions'][$actual_filename] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_skipping']
);
}
elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom']))
{
$context['has_failure'] = true;
$context['actions'][$actual_filename] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_missing'],
'failed' => true,
);
}
elseif ($mod_action['type'] == 'error')
$context['actions'][$actual_filename] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $txt['package_action_error'],
'failed' => true,
);
}
// We need to loop again just to get the operations down correctly.
foreach ($mod_actions as $operation_key => $mod_action)
{
// Lets get the last section of the file name.
if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php')
$actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']);
elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches))
$actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']);
else
$actual_filename = $key;
// We just need it for actual parse changes.
if (!in_array($mod_action['type'], array('error', 'result', 'opened', 'saved', 'end', 'missing', 'skipping', 'chmod')))
{
if (empty($mod_action['is_custom']))
$context['actions'][$actual_filename]['operations'][] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'],
'position' => $mod_action['position'],
'operation_key' => $operation_key,
'filename' => $action['filename'],
'is_boardmod' => $action['boardmod'],
'failed' => $mod_action['failed'],
'ignore_failure' => !empty($mod_action['ignore_failure']),
);
// Themes are under the saved type.
if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']]))
$context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array(
'type' => $txt['execute_modification'],
'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))),
'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'],
'position' => $mod_action['position'],
'operation_key' => $operation_key,
'filename' => $action['filename'],
'is_boardmod' => $action['boardmod'],
'failed' => $mod_action['failed'],
'ignore_failure' => !empty($mod_action['ignore_failure']),
);
}
}
}
}
elseif ($action['type'] == 'code')
{
$thisAction = array(
'type' => $txt['execute_code'],
'action' => $smcFunc['htmlspecialchars']($action['filename']),
);
}
elseif ($action['type'] == 'database' && !$context['uninstalling'])
{
$thisAction = array(
'type' => $txt['execute_database_changes'],
'action' => $smcFunc['htmlspecialchars']($action['filename']),
);
}
elseif (in_array($action['type'], array('create-dir', 'create-file')))
{
$thisAction = array(
'type' => $txt['package_create'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.')))
);
}
elseif ($action['type'] == 'hook')
{
$action['description'] = !isset($action['hook'], $action['function']) ? $txt['package_action_failure'] : $txt['package_action_success'];
if (!isset($action['hook'], $action['function']))
$context['has_failure'] = true;
$thisAction = array(
'type' => $action['reverse'] ? $txt['execute_hook_remove'] : $txt['execute_hook_add'],
'action' => sprintf($txt['execute_hook_action' . ($action['reverse'] ? '_inverse' : '')], $smcFunc['htmlspecialchars']($action['hook'])),
);
}
elseif ($action['type'] == 'credits')
{
$thisAction = array(
'type' => $txt['execute_credits_add'],
'action' => sprintf($txt['execute_credits_action'], $smcFunc['htmlspecialchars']($action['title'])),
);
}
elseif ($action['type'] == 'requires')
{
$installed = false;
$version = true;
// package missing required values?
if (!isset($action['id']))
$context['has_failure'] = true;
else
{
// See if this dependancy is installed
$request = $smcFunc['db_query']('', '
SELECT version
FROM {db_prefix}log_packages
WHERE package_id = {string:current_package}
AND install_state != {int:not_installed}
ORDER BY time_installed DESC
LIMIT 1',
array(
'not_installed' => 0,
'current_package' => $action['id'],
)
);
$installed = ($smcFunc['db_num_rows']($request) !== 0);
if ($installed)
list ($version) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// do a version level check (if requested) in the most basic way
$version = (isset($action['version']) ? $version == $action['version'] : true);
}
// Set success or failure information
$action['description'] = ($installed && $version) ? $txt['package_action_success'] : $txt['package_action_failure'];
$context['has_failure'] = !($installed && $version);
$thisAction = array(
'type' => $txt['package_requires'],
'action' => $txt['package_check_for'] . ' ' . $action['id'] . (isset($action['version']) ? (' / ' . ($version ? $action['version'] : '<span class="error">' . $action['version'] . '</span>')) : ''),
);
}
elseif (in_array($action['type'], array('require-dir', 'require-file')))
{
// Do this one...
$thisAction = array(
'type' => $txt['package_extract'] . ' ' . ($action['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.')))
);
// Could this be theme related?
if (!empty($action['unparsed_destination']) && preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir|themes_dir)~i', $action['unparsed_destination'], $matches))
{
// Is the action already stated?
$theme_action = !empty($action['theme_action']) && in_array($action['theme_action'], array('no', 'yes', 'auto')) ? $action['theme_action'] : 'auto';
// If it's not auto do we think we have something we can act upon?
if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir')))
$theme_action = '';
// ... or if it's auto do we even want to do anything?
elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir')
$theme_action = '';
// So, we still want to do something?
if ($theme_action != '')
$themeFinds['candidates'][] = $action;
// Otherwise is this is going into another theme record it.
elseif ($matches[1] == 'themes_dir')
$themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename']));
}
}
elseif (in_array($action['type'], array('move-dir', 'move-file')))
$thisAction = array(
'type' => $txt['package_move'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => $smcFunc['htmlspecialchars'](strtr($action['source'], array($boarddir => '.'))) . ' => ' . $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.')))
);
elseif (in_array($action['type'], array('remove-dir', 'remove-file')))
{
$thisAction = array(
'type' => $txt['package_delete'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => $smcFunc['htmlspecialchars'](strtr($action['filename'], array($boarddir => '.')))
);
// Could this be theme related?
if (!empty($action['unparsed_filename']) && preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir|themes_dir)~i', $action['unparsed_filename'], $matches))
{
// Is the action already stated?
$theme_action = !empty($action['theme_action']) && in_array($action['theme_action'], array('no', 'yes', 'auto')) ? $action['theme_action'] : 'auto';
$action['unparsed_destination'] = $action['unparsed_filename'];
// If it's not auto do we think we have something we can act upon?
if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir')))
$theme_action = '';
// ... or if it's auto do we even want to do anything?
elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir')
$theme_action = '';
// So, we still want to do something?
if ($theme_action != '')
$themeFinds['candidates'][] = $action;
// Otherwise is this is going into another theme record it.
elseif ($matches[1] == 'themes_dir')
$themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename']));
}
}
if (empty($thisAction))
continue;
if (!in_array($action['type'], array('hook', 'credits')))
{
if ($context['uninstalling'])
$file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename'];
else
$file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename'];
}
// Don't fail if a file/directory we're trying to create doesn't exist...
if (isset($action['filename']) && !file_exists($file) && !in_array($action['type'], array('create-dir', 'create-file')))
{
$context['has_failure'] = true;
$thisAction += array(
'description' => $txt['package_action_missing'],
'failed' => true,
);
}
// @todo None given?
if (empty($thisAction['description']))
$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
$context['actions'][] = $thisAction;
}
// Have we got some things which we might want to do "multi-theme"?
if (!empty($themeFinds['candidates']))
{
foreach ($themeFinds['candidates'] as $action_data)
{
// Get the part of the file we'll be dealing with.
preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir)(\\|/)*(.+)*~i', $action_data['unparsed_destination'], $matches);
if ($matches[1] == 'imagesdir')
$path = '/' . basename($settings['default_images_url']);
elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir')
$path = '/languages';
else
$path = '';
if (!empty($matches[3]))
$path .= $matches[3];
if (!$context['uninstalling'])
$path .= '/' . basename($action_data['filename']);
// Loop through each custom theme to note it's candidacy!
foreach ($theme_paths as $id => $theme_data)
{
if (isset($theme_data['theme_dir']) && $id != 1)
{
$real_path = $theme_data['theme_dir'] . $path;
// Confirm that we don't already have this dealt with by another entry.
if (!in_array(strtolower(strtr($real_path, array('\\' => '/'))), $themeFinds['other_themes']))
{
// Check if we will need to chmod this.
if (!mktree(dirname($real_path), false))
{
$temp = dirname($real_path);
while (!file_exists($temp) && strlen($temp) > 1)
$temp = dirname($temp);
$chmod_files[] = $temp;
}
if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path))))
$chmod_files[] = $real_path;
if (!isset($context['theme_actions'][$id]))
$context['theme_actions'][$id] = array(
'name' => $theme_data['name'],
'actions' => array(),
);
if ($context['uninstalling'])
$context['theme_actions'][$id]['actions'][] = array(
'type' => $txt['package_delete'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')),
'description' => '',
'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['filename'], 'future' => $real_path, 'id' => $id))),
'not_mod' => true,
);
else
$context['theme_actions'][$id]['actions'][] = array(
'type' => $txt['package_extract'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']),
'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')),
'description' => '',
'value' => base64_encode($smcFunc['json_encode'](array('type' => $action_data['type'], 'orig' => $action_data['destination'], 'future' => $real_path, 'id' => $id))),
'not_mod' => true,
);
}
}
}
}
}
// Trash the cache... which will also check permissions for us!
package_flush_cache(true);
if (file_exists($packagesdir . '/temp'))
deltree($packagesdir . '/temp');
if (!empty($chmod_files))
{
$ftp_status = create_chmod_control($chmod_files);
$context['ftp_needed'] = !empty($ftp_status['files']['notwritable']) && !empty($context['package_ftp']);
}
$context['post_url'] = $scripturl . '?action=admin;area=packages;sa=' . ($context['uninstalling'] ? 'uninstall' : 'install') . ($context['ftp_needed'] ? '' : '2') . ';package=' . $context['filename'] . ';pid=' . $context['install_id'];
checkSubmitOnce('register');
}
/**
* Apply another type of (avatar, language, etc.) package.
*/
function PackageInstall()
{
global $txt, $context, $boardurl, $scripturl, $sourcedir, $packagesdir, $modSettings;
global $user_info, $smcFunc;
// Make sure we don't install this mod twice.
checkSubmitOnce('check');
checkSession();
// If there's no file, what are we installing?
if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '')
redirectexit('action=admin;area=packages');
$context['filename'] = $_REQUEST['package'];
// If this is an uninstall, we'll have an id.
$context['install_id'] = isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : 0;
require_once($sourcedir . '/Subs-Package.php');
// @todo Perhaps do it in steps, if necessary?
$context['uninstalling'] = $_REQUEST['sa'] == 'uninstall2';
// Set up the linktree for other.
$context['linktree'][count($context['linktree']) - 1] = array(
'url' => $scripturl . '?action=admin;area=packages;sa=browse',
'name' => $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']
);
$context['page_title'] .= ' - ' . ($context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']);
$context['sub_template'] = 'extract_package';
if (!file_exists($packagesdir . '/' . $context['filename']))
fatal_lang_error('package_no_file', false);
// Load up the package FTP information?
create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package']));
// Make sure temp directory exists and is empty!
if (file_exists($packagesdir . '/temp'))
deltree($packagesdir . '/temp', false);
else
mktree($packagesdir . '/temp', 0777);
// Let the unpacker do the work.
if (is_file($packagesdir . '/' . $context['filename']))
{
$context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
if (!file_exists($packagesdir . '/temp/package-info.xml'))
foreach ($context['extracted_files'] as $file)
if (basename($file['filename']) == 'package-info.xml')
{
$context['base_path'] = dirname($file['filename']) . '/';
break;
}
if (!isset($context['base_path']))
$context['base_path'] = '';
}
elseif (is_dir($packagesdir . '/' . $context['filename']))
{
copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
$context['extracted_files'] = listtree($packagesdir . '/temp');
$context['base_path'] = '';
}
else
fatal_lang_error('no_access', false);
// Are we installing this into any custom themes?
$custom_themes = array(1);
$known_themes = explode(',', $modSettings['knownThemes']);
if (!empty($_POST['custom_theme']))
{
foreach ($_POST['custom_theme'] as $tid)
if (in_array($tid, $known_themes))
$custom_themes[] = (int) $tid;
}
// Now load up the paths of the themes that we need to know about.
$request = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE id_theme IN ({array_int:custom_themes})
AND variable IN ({string:name}, {string:theme_dir})',
array(
'custom_themes' => $custom_themes,
'name' => 'name',
'theme_dir' => 'theme_dir',
)
);
$theme_paths = array();
$themes_installed = array(1);
while ($row = $smcFunc['db_fetch_assoc']($request))
$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
$smcFunc['db_free_result']($request);
// Are there any theme copying that we want to take place?
$context['theme_copies'] = array(
'require-file' => array(),
'require-dir' => array(),
);
if (!empty($_POST['theme_changes']))
{
foreach ($_POST['theme_changes'] as $change)
{
if (empty($change))
continue;
$theme_data = $smcFunc['json_decode'](base64_decode($change), true);
if (empty($theme_data['type']))
continue;
$themes_installed[] = $theme_data['id'];
$context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future'];
}
}
// Get the package info...
$packageInfo = getPackageInfo($context['filename']);
if (!is_array($packageInfo))
fatal_lang_error($packageInfo);
if (is_dir($packagesdir . '/' . $context['filename']))
$context['package_sha256_hash'] = '';
else
$context['package_sha256_hash'] = hash_file('sha256', $packagesdir . '/' . $context['filename']);
$packageInfo['filename'] = $context['filename'];
// Set the type of extraction...
$context['extract_type'] = isset($packageInfo['type']) ? $packageInfo['type'] : 'modification';
// Create a backup file to roll back to! (but if they do this more than once, don't run it a zillion times.)
if (!empty($modSettings['package_make_full_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['filename'] . ($context['uninstalling'] ? '$$' : '$')))
{
$_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$');
$result = package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.'));
if (!$result)
fatal_lang_error('could_not_package_backup', false);
}
// The mod isn't installed.... unless proven otherwise.
$context['is_installed'] = false;
// Is it actually installed?
$request = $smcFunc['db_query']('', '
SELECT version, themes_installed, db_changes
FROM {db_prefix}log_packages
WHERE package_id = {string:current_package}
AND install_state != {int:not_installed}
ORDER BY time_installed DESC
LIMIT 1',
array(
'not_installed' => 0,
'current_package' => $packageInfo['id'],
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$old_themes = explode(',', $row['themes_installed']);
$old_version = $row['version'];
$db_changes = empty($row['db_changes']) ? array() : $smcFunc['json_decode']($row['db_changes'], true);
}
$smcFunc['db_free_result']($request);
// Wait, it's not installed yet!
// @todo Replace with a better error message!
if (!isset($old_version) && $context['uninstalling'])
{
deltree($packagesdir . '/temp');
fatal_error('Hacker?', false);
}
// Uninstalling?
elseif ($context['uninstalling'])
{
$install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall');
// Gadzooks! There's no uninstaller at all!?
if (empty($install_log))
fatal_lang_error('package_uninstall_cannot', false);
// They can only uninstall from what it was originally installed into.
foreach ($theme_paths as $id => $data)
if ($id != 1 && !in_array($id, $old_themes))
unset($theme_paths[$id]);
$context['keep_url'] = $scripturl . '?action=admin;area=packages;sa=browse;' . $context['session_var'] . '=' . $context['session_id'];
$context['remove_url'] = $scripturl . '?action=admin;area=packages;sa=remove;package=' . $context['filename'] . ';' . $context['session_var'] . '=' . $context['session_id'];
}
elseif (isset($old_version) && $old_version != $packageInfo['version'])
{
// Look for an upgrade...
$install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $old_version);
// There was no upgrade....
if (empty($install_log))
$context['is_installed'] = true;
else
{
// Upgrade previous themes only!
foreach ($theme_paths as $id => $data)
if ($id != 1 && !in_array($id, $old_themes))
unset($theme_paths[$id]);
}
}
elseif (isset($old_version) && $old_version == $packageInfo['version'])
$context['is_installed'] = true;
if (!isset($old_version) || $context['is_installed'])
$install_log = parsePackageInfo($packageInfo['xml'], false, 'install');
$context['install_finished'] = false;
// @todo Make a log of any errors that occurred and output them?
if (!empty($install_log))
{
$failed_steps = array();
$failed_count = 0;
foreach ($install_log as $action)
{
$failed_count++;
if ($action['type'] == 'modification' && !empty($action['filename']))
{
if ($action['boardmod'])
$mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths);
else
$mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths);
// Any errors worth noting?
foreach ($mod_actions as $key => $modAction)
{
if ($modAction['type'] == 'failure')
$failed_steps[] = array(
'file' => $modAction['filename'],
'large_step' => $failed_count,
'sub_step' => $key,
'theme' => 1,
);
// Gather the themes we installed into.
if (!empty($modAction['is_custom']))
$themes_installed[] = $modAction['is_custom'];
}
}
elseif ($action['type'] == 'code' && !empty($action['filename']))
{
// This is just here as reference for what is available.
global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $smcFunc;
// Now include the file and be done with it ;).
if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename']))
require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']);
}
elseif ($action['type'] == 'credits')
{
// Time to build the billboard
$credits_tag = array(
'url' => $action['url'],
'license' => $action['license'],
'licenseurl' => $action['licenseurl'],
'copyright' => $action['copyright'],
'title' => $action['title'],
);
}
elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function']))
{
// Set the system to ignore hooks, but only if it wasn't changed before.
if (!isset($context['ignore_hook_errors']))
$context['ignore_hook_errors'] = true;
if ($action['reverse'])
remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']);
else
add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']);
}
// Only do the database changes on uninstall if requested.
elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes'])))
{
// These can also be there for database changes.
global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $smcFunc;
global $db_package_log;
// We'll likely want the package specific database functionality!
db_extend('packages');
// Let the file work its magic ;)
if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename']))
require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']);
}
// Handle a redirect...
elseif ($action['type'] == 'redirect' && !empty($action['redirect_url']))
{
$context['redirect_url'] = $action['redirect_url'];
$context['redirect_text'] = !empty($action['filename']) && file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename']) ? $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']);
$context['redirect_timeout'] = empty($action['redirect_timeout']) ? 5 : (int) ceil($action['redirect_timeout'] / 1000);
if (!empty($action['parse_bbc']))
{
require_once($sourcedir . '/Subs-Post.php');
$context['redirect_text'] = preg_replace('~\[[/]?html\]~i', '', $context['redirect_text']);
preparsecode($context['redirect_text']);
$context['redirect_text'] = parse_bbc($context['redirect_text']);
}
// Parse out a couple of common urls.
$urls = array(
'$boardurl' => $boardurl,
'$scripturl' => $scripturl,
'$session_var' => $context['session_var'],
'$session_id' => $context['session_id'],
);
$context['redirect_url'] = strtr($context['redirect_url'], $urls);
}
}
package_flush_cache();
// See if this is already installed, and change it's state as required.
$request = $smcFunc['db_query']('', '
SELECT package_id, install_state, db_changes
FROM {db_prefix}log_packages
WHERE install_state != {int:not_installed}
AND package_id = {string:current_package}
' . ($context['install_id'] ? ' AND id_install = {int:install_id} ' : '') . '
ORDER BY time_installed DESC
LIMIT 1',
array(
'not_installed' => 0,
'install_id' => $context['install_id'],
'current_package' => $packageInfo['id'],
)
);
$is_upgrade = false;
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// Uninstalling?
if ($context['uninstalling'])
{
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_packages
SET install_state = {int:not_installed}, member_removed = {string:member_name},
id_member_removed = {int:current_member}, time_removed = {int:current_time}, sha256_hash = {string:package_hash}
WHERE package_id = {string:package_id}
AND id_install = {int:install_id}',
array(
'current_member' => $user_info['id'],
'not_installed' => 0,
'current_time' => time(),
'package_id' => $row['package_id'],
'member_name' => $user_info['name'],
'install_id' => $context['install_id'],
'package_hash' => $context['package_sha256_hash'],
)
);
}
// Otherwise must be an upgrade.
else
{
$is_upgrade = true;
$old_db_changes = empty($row['db_changes']) ? array() : $smcFunc['json_decode']($row['db_changes'], true);
// Mark the old version as uninstalled
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_packages
SET install_state = {int:not_installed}, member_removed = {string:member_name},
id_member_removed = {int:current_member}, time_removed = {int:current_time}, sha256_hash = {string:package_hash}
WHERE package_id = {string:package_id}
AND version = {string:old_version}',
array(
'current_member' => $user_info['id'],
'not_installed' => 0,
'current_time' => time(),
'package_id' => $row['package_id'],
'member_name' => $user_info['name'],
'old_version' => $old_version,
'package_hash' => $context['package_sha256_hash'],
)
);
}
}
// Assuming we're not uninstalling, add the entry.
if (!$context['uninstalling'])
{
// Reload the settings table for mods that have altered them upon installation
reloadSettings();
// Any db changes from older version?
if (!empty($old_db_changes))
$db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log);
// If there are some database changes we might want to remove then filter them out.
if (!empty($db_package_log))
{
// We're really just checking for entries which are create table AND add columns (etc).
$tables = array();
usort($db_package_log, function($a, $b)
{
if ($a[0] == $b[0])
return 0;
return $a[0] == 'remove_table' ? -1 : 1;
});
foreach ($db_package_log as $k => $log)
{
if ($log[0] == 'remove_table')
$tables[] = $log[1];
elseif (in_array($log[1], $tables))
unset($db_package_log[$k]);
}
$db_changes = $smcFunc['json_encode']($db_package_log);
}
else
$db_changes = '';
// What themes did we actually install?
$themes_installed = array_unique($themes_installed);
$themes_installed = implode(',', $themes_installed);
// What failed steps?
$failed_step_insert = $smcFunc['json_encode']($failed_steps);
// Un-sanitize things before we insert them...
$keys = array('filename', 'name', 'id', 'version');
foreach ($keys as $key)
{
// Yay for variable variables...
${"package_$key"} = un_htmlspecialchars($packageInfo[$key]);
}
// Credits tag?
$credits_tag = (empty($credits_tag)) ? '' : $smcFunc['json_encode']($credits_tag);
$smcFunc['db_insert']('',
'{db_prefix}log_packages',
array(
'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string',
'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int',
'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string',
'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string',
'sha256_hash' => 'string',
),
array(
$package_filename, $package_name, $package_id, $package_version,
$user_info['id'], $user_info['name'], time(),
$is_upgrade ? 2 : 1, $failed_step_insert, $themes_installed,
0, $db_changes, $credits_tag, $context['package_sha256_hash']
),
array('id_install')
);
}
$smcFunc['db_free_result']($request);
$context['install_finished'] = true;
}
// If there's database changes - and they want them removed - let's do it last!
if (!empty($db_changes) && !empty($_POST['do_db_changes']))
{
// We're gonna be needing the package db functions!
db_extend('packages');
foreach ($db_changes as $change)
{
if ($change[0] == 'remove_table' && isset($change[1]))
$smcFunc['db_drop_table']($change[1]);
elseif ($change[0] == 'remove_column' && isset($change[2]))
$smcFunc['db_remove_column']($change[1], $change[2]);
elseif ($change[0] == 'remove_index' && isset($change[2]))
$smcFunc['db_remove_index']($change[1], $change[2]);
}
}
// Clean house... get rid of the evidence ;).
if (file_exists($packagesdir . '/temp'))
deltree($packagesdir . '/temp');
// Log what we just did.
logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin');
// Just in case, let's clear the whole cache and any minimized CSS and JS to avoid anything going up the swanny.
clean_cache();
deleteAllMinified();
foreach (array('css_files', 'javascript_files') as $file_type)
{
foreach ($context[$file_type] as $id => $file)
{
if (isset($file['filePath']) && !file_exists($file['filePath']))
unset($context[$file_type][$id]);
}
}
// Restore file permissions?
create_chmod_control(array(), array(), true);
}
/**
* List the files in a package.
*/
function PackageList()
{
global $txt, $scripturl, $context, $sourcedir, $packagesdir;
require_once($sourcedir . '/Subs-Package.php');
// No package? Show him or her the door.
if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '')
redirectexit('action=admin;area=packages');
$context['linktree'][] = array(
'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $_REQUEST['package'],
'name' => $txt['list_file']
);
$context['page_title'] .= ' - ' . $txt['list_file'];
$context['sub_template'] = 'list';
// The filename...
$context['filename'] = $_REQUEST['package'];
// Let the unpacker do the work.
if (is_file($packagesdir . '/' . $context['filename']))
$context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null);
elseif (is_dir($packagesdir . '/' . $context['filename']))
$context['files'] = listtree($packagesdir . '/' . $context['filename']);
}
/**
* Display one of the files in a package.
*/
function ExamineFile()
{
global $txt, $scripturl, $context, $sourcedir, $packagesdir, $smcFunc;
require_once($sourcedir . '/Subs-Package.php');
// No package? Show him or her the door.
if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '')
redirectexit('action=admin;area=packages');
// No file? Show him or her the door.
if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '')
redirectexit('action=admin;area=packages');
$_REQUEST['package'] = preg_replace('~[\.]+~', '.', strtr($_REQUEST['package'], array('/' => '_', '\\' => '_')));
$_REQUEST['file'] = preg_replace('~[\.]+~', '.', $_REQUEST['file']);
if (isset($_REQUEST['raw']))
{
if (is_file($packagesdir . '/' . $_REQUEST['package']))
echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true);
elseif (is_dir($packagesdir . '/' . $_REQUEST['package']))
echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']);
obExit(false);
}
$context['linktree'][count($context['linktree']) - 1] = array(
'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $_REQUEST['package'],
'name' => $txt['package_examine_file']
);
$context['page_title'] .= ' - ' . $txt['package_examine_file'];
$context['sub_template'] = 'examine';
// The filename...
$context['package'] = $_REQUEST['package'];
$context['filename'] = $_REQUEST['file'];
// Let the unpacker do the work.... but make sure we handle images properly.
if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png')))
$context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">';
else
{
if (is_file($packagesdir . '/' . $_REQUEST['package']))
$context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true));
elseif (is_dir($packagesdir . '/' . $_REQUEST['package']))
$context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']));
if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php')
$context['filedata'] = highlight_php_code($context['filedata']);
}
}
/**
* Delete a package.
*/
function PackageRemove()
{
global $scripturl, $packagesdir;
// Check it.
checkSession('get');
// Ack, don't allow deletion of arbitrary files here, could become a security hole somehow!
if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups')
redirectexit('action=admin;area=packages;sa=browse');
$_GET['package'] = preg_replace('~[\.]+~', '.', strtr($_GET['package'], array('/' => '_', '\\' => '_')));
// Can't delete what's not there.
if (file_exists($packagesdir . '/' . $_GET['package']) && (substr($_GET['package'], -4) == '.zip' || substr($_GET['package'], -4) == '.tgz' || substr($_GET['package'], -7) == '.tar.gz' || is_dir($packagesdir . '/' . $_GET['package'])) && $_GET['package'] != 'backups' && substr($_GET['package'], 0, 1) != '.')
{
create_chmod_control(array($packagesdir . '/' . $_GET['package']), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=remove;package=' . $_GET['package'], 'crash_on_error' => true));
if (is_dir($packagesdir . '/' . $_GET['package']))
deltree($packagesdir . '/' . $_GET['package']);
else
{
smf_chmod($packagesdir . '/' . $_GET['package'], 0777);
unlink($packagesdir . '/' . $_GET['package']);
}
}
redirectexit('action=admin;area=packages;sa=browse');
}
/**
* Browse a list of installed packages.
*/
function PackageBrowse()
{
global $txt, $scripturl, $context, $sourcedir, $smcFunc;
$context['page_title'] .= ' - ' . $txt['browse_packages'];
$context['forum_version'] = SMF_FULL_VERSION;
$context['available_packages'] = 0;
$context['modification_types'] = array('modification', 'avatar', 'language', 'unknown');
call_integration_hook('integrate_modification_types');
require_once($sourcedir . '/Subs-List.php');
foreach ($context['modification_types'] as $type)
{
// Use the standard templates for showing this.
$listOptions = array(
'id' => 'packages_lists_' . $type,
'title' => $txt[$type . '_package'],
'no_items_label' => $txt['no_packages'],
'get_items' => array(
'function' => 'list_getPackages',
'params' => array($type),
),
'base_href' => $scripturl . '?action=admin;area=packages;sa=browse;type=' . $type,
'default_sort_col' => 'id' . $type,
'columns' => array(
'id' . $type => array(
'header' => array(
'value' => $txt['package_id'],
'style' => 'width: 52px;',
),
'data' => array(
'db' => 'sort_id',
),
'sort' => array(
'default' => 'sort_id',
'reverse' => 'sort_id'
),
),
'mod_name' . $type => array(
'header' => array(
'value' => $txt['mod_name'],
'style' => 'width: 25%;',
),
'data' => array(
'db' => 'name',
),
'sort' => array(
'default' => 'name',
'reverse' => 'name',
),
),
'version' . $type => array(
'header' => array(
'value' => $txt['mod_version'],
),
'data' => array(
'db' => 'version',
),
'sort' => array(
'default' => 'version',
'reverse' => 'version',
),
),
'time_installed' . $type => array(
'header' => array(
'value' => $txt['mod_installed_time'],
),
'data' => array(
'function' => function($package) use ($txt)
{
return !empty($package['time_installed'])
? timeformat($package['time_installed'])
: $txt['not_applicable'];
},
'class' => 'smalltext',
),
'sort' => array(
'default' => 'time_installed',
'reverse' => 'time_installed',
),
),
'operations' . $type => array(
'header' => array(
'value' => '',
),
'data' => array(
'function' => function($package) use ($context, $scripturl, $txt, $type)
{
$return = '';
if ($package['can_uninstall'])
$return = '
<a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button floatnone">' . $txt['uninstall'] . '</a>';
elseif ($package['can_emulate_uninstall'])
$return = '
<a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;ve=' . $package['can_emulate_uninstall'] . ';package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button floatnone">' . $txt['package_emulate_uninstall'] . ' ' . $package['can_emulate_uninstall'] . '</a>';
elseif ($package['can_upgrade'])
$return = '
<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button" floatnone>' . $txt['package_upgrade'] . '</a>';
elseif ($package['can_install'])
$return = '
<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button floatnone">' . $txt['install_' . $type] . '</a>';
elseif ($package['can_emulate_install'])
$return = '
<a href="' . $scripturl . '?action=admin;area=packages;sa=install;ve=' . $package['can_emulate_install'] . ';package=' . $package['filename'] . '" class="button floatnone">' . $txt['package_emulate_install'] . ' ' . $package['can_emulate_install'] . '</a>';
return $return . '
<a href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $package['filename'] . '" class="button floatnone">' . $txt['list_files'] . '</a>
<a href="' . $scripturl . '?action=admin;area=packages;sa=remove;package=' . $package['filename'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"' . ($package['is_installed'] && $package['is_current'] ? ' data-confirm="' . $txt['package_delete_bad'] . '"' : '') . ' class="button' . ($package['is_installed'] && $package['is_current'] ? ' you_sure' : '') . ' floatnone">' . $txt['package_delete'] . '</a>';
},
'class' => 'righttext',
),
),
),
);
createList($listOptions);
}
$context['sub_template'] = 'browse';
$context['default_list'] = 'packages_lists';
$get_versions = $smcFunc['db_query']('', '
SELECT data FROM {db_prefix}admin_info_files WHERE filename={string:versionsfile} AND path={string:smf}',
array(
'versionsfile' => 'latest-versions.txt',
'smf' => '/smf/',
)
);
$data = $smcFunc['db_fetch_assoc']($get_versions);
$smcFunc['db_free_result']($get_versions);
// Decode the data.
$items = $smcFunc['json_decode']($data['data'], true);
$context['emulation_versions'] = preg_replace('~^SMF ~', '', $items);
// Current SMF version, which is selected by default
$context['default_version'] = SMF_VERSION;
if (!in_array($context['default_version'], $context['emulation_versions']))
{
$context['emulation_versions'][] = $context['default_version'];
}
// Version we're currently emulating, if any
$context['selected_version'] = preg_replace('~^SMF ~', '', $context['forum_version']);
}
/**
* Get a listing of all the packages
*
* Determines if the package is a mod, avatar, or language package and
* groups it accordingly. If a package is not recognised as one of the
* above, it is then put into a special group, "unknown".
*
* Determines whether the package has been installed or not by
* checking it against {@link loadInstalledPackages()}.
*
* @param int $start The item to start with (not used here)
* @param int $items_per_page The number of items to show per page (not used here)
* @param string $sort A string indicating how to sort the results
* @param string $params Type of packages
* @return array An array of information about the packages
*/
function list_getPackages($start, $items_per_page, $sort, $params)
{
global $scripturl, $packagesdir, $context;
static $installed_mods;
$packages = array();
$column = array();
// We need the packages directory to be writable for this.
if (!@is_writable($packagesdir))
create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true));
$the_version = SMF_VERSION;
// Here we have a little code to help those who class themselves as something of gods, version emulation ;)
if (isset($_GET['version_emulate']) && strtr($_GET['version_emulate'], array('SMF ' => '')) == $the_version)
{
unset($_SESSION['version_emulate']);
}
elseif (isset($_GET['version_emulate']))
{
if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === SMF_FULL_VERSION) && isset($_SESSION['version_emulate']))
unset($_SESSION['version_emulate']);
elseif ($_GET['version_emulate'] !== 0)
$_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => ''));
}
if (!empty($_SESSION['version_emulate']))
{
$context['forum_version'] = 'SMF ' . $_SESSION['version_emulate'];
$the_version = $_SESSION['version_emulate'];
}
if (isset($_SESSION['single_version_emulate']))
unset($_SESSION['single_version_emulate']);
if (empty($installed_mods))
{
$instmods = loadInstalledPackages();
$installed_mods = array();
// Look through the list of installed mods...
foreach ($instmods as $installed_mod)
$installed_mods[$installed_mod['package_id']] = array(
'id' => $installed_mod['id'],
'version' => $installed_mod['version'],
'time_installed' => $installed_mod['time_installed'],
);
// Get a list of all the ids installed, so the latest packages won't include already installed ones.
$context['installed_mods'] = array_keys($installed_mods);
}
if ($dir = @opendir($packagesdir))
{
$dirs = array();
$sort_id = array(
'modification' => 1,
'avatar' => 1,
'language' => 1,
'unknown' => 1,
);
call_integration_hook('integrate_packages_sort_id', array(&$sort_id, &$packages));
while ($package = readdir($dir))
{
if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip'))
continue;
// Skip directories or files that are named the same.
if (is_dir($packagesdir . '/' . $package))
{
if (in_array($package, $dirs))
continue;
$dirs[] = $package;
}
elseif (substr(strtolower($package), -7) == '.tar.gz')
{
if (in_array(substr($package, 0, -7), $dirs))
continue;
$dirs[] = substr($package, 0, -7);
}
elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz')
{
if (in_array(substr($package, 0, -4), $dirs))
continue;
$dirs[] = substr($package, 0, -4);
}
$packageInfo = getPackageInfo($package);
if (!is_array($packageInfo))
continue;
if (!empty($packageInfo))
{
if (!isset($sort_id[$packageInfo['type']]))
$packageInfo['sort_id'] = $sort_id['unknown'];
else
$packageInfo['sort_id'] = $sort_id[$packageInfo['type']];
$packageInfo['time_installed'] = 0;
$packageInfo['is_installed'] = isset($installed_mods[$packageInfo['id']]);
if ($packageInfo['is_installed'])
{
$packageInfo['is_current'] = $installed_mods[$packageInfo['id']]['version'] == $packageInfo['version'];
$packageInfo['is_newer'] = $installed_mods[$packageInfo['id']]['version'] > $packageInfo['version'];
$packageInfo['installed_id'] = $installed_mods[$packageInfo['id']]['id'];
if ($packageInfo['is_current'])
$packageInfo['time_installed'] = $installed_mods[$packageInfo['id']]['time_installed'];
}
$packageInfo['can_install'] = false;
$packageInfo['can_uninstall'] = false;
$packageInfo['can_upgrade'] = false;
$packageInfo['can_emulate_install'] = false;
$packageInfo['can_emulate_uninstall'] = false;
// This package is currently NOT installed. Check if it can be.
if (!$packageInfo['is_installed'] && $packageInfo['xml']->exists('install'))
{
// Check if there's an install for *THIS* version of SMF.
$installs = $packageInfo['xml']->set('install');
foreach ($installs as $install)
{
if (!$install->exists('@for') || matchPackageVersion($the_version, $install->fetch('@for')))
{
// Okay, this one is good to go.
$packageInfo['can_install'] = true;
break;
}
}
// no install found for this version, lets see if one exists for another
if ($packageInfo['can_install'] === false && $install->exists('@for') && empty($_SESSION['version_emulate']))
{
$reset = true;
// Get the highest install version that is available from the package
foreach ($installs as $install)
{
$packageInfo['can_emulate_install'] = matchHighestPackageVersion($install->fetch('@for'), $reset, $the_version);
$reset = false;
}
}
}
// An already installed, but old, package. Can we upgrade it?
elseif ($packageInfo['is_installed'] && !$packageInfo['is_current'] && $packageInfo['xml']->exists('upgrade'))
{
$upgrades = $packageInfo['xml']->set('upgrade');
// First go through, and check against the current version of SMF.
foreach ($upgrades as $upgrade)
{
// Even if it is for this SMF, is it for the installed version of the mod?
if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for')))
if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from')))
{
$packageInfo['can_upgrade'] = true;
break;
}
}
}
// Note that it has to be the current version to be uninstallable. Shucks.
elseif ($packageInfo['is_installed'] && $packageInfo['is_current'] && $packageInfo['xml']->exists('uninstall'))
{
$uninstalls = $packageInfo['xml']->set('uninstall');
// Can we find any uninstallation methods that work for this SMF version?
foreach ($uninstalls as $uninstall)
{
if (!$uninstall->exists('@for') || matchPackageVersion($the_version, $uninstall->fetch('@for')))
{
$packageInfo['can_uninstall'] = true;
break;
}
}
// no uninstall found for this version, lets see if one exists for another
if ($packageInfo['can_uninstall'] === false && $uninstall->exists('@for') && empty($_SESSION['version_emulate']))
{
$reset = true;
// Get the highest install version that is available from the package
foreach ($uninstalls as $uninstall)
{
$packageInfo['can_emulate_uninstall'] = matchHighestPackageVersion($uninstall->fetch('@for'), $reset, $the_version);
$reset = false;
}
}
}
// Save some memory by not passing the xmlArray object into context.
unset($packageInfo['xml']);
if (isset($sort_id[$packageInfo['type']]) && $params == $packageInfo['type'])
{
$column[] = $packageInfo[$sort];
$sort_id[$packageInfo['type']]++;
$packages[] = $packageInfo;
}
elseif (!isset($sort_id[$packageInfo['type']]) && $params == 'unknown')
{
$column[] = $packageInfo[$sort];
$packageInfo['sort_id'] = $sort_id['unknown'];
$sort_id['unknown']++;
$packages[] = $packageInfo;
}
}
}
closedir($dir);
}
$context['available_packages'] += count($packages);
array_multisort(
$column,
isset($_GET['desc']) ? SORT_DESC : SORT_ASC,
$packages
);
return $packages;
}
/**
* Used when a temp FTP access is needed to package functions
*/
function PackageOptions()
{
global $txt, $context, $modSettings, $smcFunc;
if (isset($_POST['save']))
{
checkSession();
updateSettings(array(
'package_server' => trim($smcFunc['htmlspecialchars']($_POST['pack_server'])),
'package_port' => trim($smcFunc['htmlspecialchars']($_POST['pack_port'])),
'package_username' => trim($smcFunc['htmlspecialchars']($_POST['pack_user'])),
'package_make_backups' => !empty($_POST['package_make_backups']),
'package_make_full_backups' => !empty($_POST['package_make_full_backups'])
));
$_SESSION['adm-save'] = true;
redirectexit('action=admin;area=packages;sa=options');
}
if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match))
$default_username = $match[1];
else
$default_username = '';
$context['page_title'] = $txt['package_settings'];
$context['sub_template'] = 'install_options';
$context['package_ftp_server'] = isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost';
$context['package_ftp_port'] = isset($modSettings['package_port']) ? $modSettings['package_port'] : '21';
$context['package_ftp_username'] = isset($modSettings['package_username']) ? $modSettings['package_username'] : $default_username;
$context['package_make_backups'] = !empty($modSettings['package_make_backups']);
$context['package_make_full_backups'] = !empty($modSettings['package_make_full_backups']);
if (!empty($_SESSION['adm-save']))
{
$context['saved_successful'] = true;
unset ($_SESSION['adm-save']);
}
}
/**
* List operations
*/
function ViewOperations()
{
global $context, $txt, $sourcedir, $packagesdir, $smcFunc, $modSettings, $settings;
// Can't be in here buddy.
isAllowedTo('admin_forum');
// We need to know the operation key for the search and replace, mod file looking at, is it a board mod?
if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key']))
fatal_lang_error('operation_invalid', 'general');
// Load the required file.
require_once($sourcedir . '/Subs-Package.php');
// Uninstalling the mod?
$reverse = isset($_REQUEST['reverse']) ? true : false;
// Get the base name.
$context['filename'] = preg_replace('~[\.]+~', '.', $_REQUEST['package']);
// We need to extract this again.
if (is_file($packagesdir . '/' . $context['filename']))
{
$context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml'))
foreach ($context['extracted_files'] as $file)
if (basename($file['filename']) == 'package-info.xml')
{
$context['base_path'] = dirname($file['filename']) . '/';
break;
}
if (!isset($context['base_path']))
$context['base_path'] = '';
}
elseif (is_dir($packagesdir . '/' . $context['filename']))
{
copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp');
$context['extracted_files'] = listtree($packagesdir . '/temp');
$context['base_path'] = '';
}
// Load up any custom themes we may want to install into...
$request = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE (id_theme = {int:default_theme} OR id_theme IN ({array_int:known_theme_list}))
AND variable IN ({string:name}, {string:theme_dir})',
array(
'known_theme_list' => explode(',', $modSettings['knownThemes']),
'default_theme' => 1,
'name' => 'name',
'theme_dir' => 'theme_dir',
)
);
$theme_paths = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
$smcFunc['db_free_result']($request);
// If we're viewing uninstall operations, only consider themes that
// the package is actually installed into.
if (isset($_REQUEST['reverse']) && !empty($_REQUEST['install_id']))
{
$install_id = (int) $_REQUEST['install_id'];
if ($install_id > 0)
{
$old_themes = array();
$request = $smcFunc['db_query']('', '
SELECT themes_installed
FROM {db_prefix}log_packages
WHERE id_install = {int:install_id}',
array(
'install_id' => $install_id,
)
);
if ($smcFunc['db_num_rows']($request) == 1)
{
list ($old_themes) = $smcFunc['db_fetch_row']($request);
$old_themes = explode(',', $old_themes);
foreach ($theme_paths as $id => $data)
if ($id != 1 && !in_array($id, $old_themes))
unset($theme_paths[$id]);
}
$smcFunc['db_free_result']($request);
}
}
// Boardmod?
if (isset($_REQUEST['boardmod']))
$mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths);
else
$mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths);
// Ok lets get the content of the file.
$context['operations'] = array(
'search' => strtr($smcFunc['htmlspecialchars']($mod_actions[$_REQUEST['operation_key']]['search_original']), array('[' => '[', ']' => ']')),
'replace' => strtr($smcFunc['htmlspecialchars']($mod_actions[$_REQUEST['operation_key']]['replace_original']), array('[' => '[', ']' => ']')),
'position' => $mod_actions[$_REQUEST['operation_key']]['position'],
);
// Let's do some formatting...
$operation_text = $context['operations']['position'] == 'replace' ? 'operation_replace' : ($context['operations']['position'] == 'before' ? 'operation_after' : 'operation_before');
$context['operations']['search'] = parse_bbc('[code=' . $txt['operation_find'] . ']' . ($context['operations']['position'] == 'end' ? '?>' : $context['operations']['search']) . '[/code]');
$context['operations']['replace'] = parse_bbc('[code=' . $txt[$operation_text] . ']' . $context['operations']['replace'] . '[/code]');
// No layers
$context['template_layers'] = array();
$context['sub_template'] = 'view_operations';
// We only want to load these three JavaScript files.
$context['javascript_files'] = array_intersect_key(
$context['javascript_files'],
[
'smf_script_js' => true,
'smf_jquery_js' => true
]
);
// Since the alerts code is loaded very late in the process, it must be disabled seperately.
$settings['disable_files'] = ['smf_alerts'];
}
/**
* Allow the admin to reset permissions on files.
*/
function PackagePermissions()
{
global $context, $txt, $modSettings, $boarddir, $sourcedir, $cachedir, $smcFunc, $package_ftp;
// Let's try and be good, yes?
checkSession('get');
// If we're restoring permissions this is just a pass through really.
if (isset($_GET['restore']))
{
create_chmod_control(array(), array(), true);
fatal_lang_error('no_access', false);
}
// This is a memory eat.
setMemoryLimit('128M');
@set_time_limit(600);
// Load up some FTP stuff.
create_chmod_control();
if (empty($package_ftp) && !isset($_POST['skip_ftp']))
{
require_once($sourcedir . '/Class-Package.php');
$ftp = new ftp_connection(null);
list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
$context['package_ftp'] = array(
'server' => isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost',
'port' => isset($modSettings['package_port']) ? $modSettings['package_port'] : '21',
'username' => empty($username) ? (isset($modSettings['package_username']) ? $modSettings['package_username'] : '') : $username,
'path' => $detect_path,
'form_elements_only' => true,
);
}
else
$context['ftp_connected'] = true;
// Define the template.
$context['page_title'] = $txt['package_file_perms'];
$context['sub_template'] = 'file_permissions';
// Define what files we're interested in, as a tree.
$context['file_tree'] = array(
strtr($boarddir, array('\\' => '/')) => array(
'type' => 'dir',
'contents' => array(
'agreement.txt' => array(
'type' => 'file',
'writable_on' => 'standard',
),
'Settings.php' => array(
'type' => 'file',
'writable_on' => 'restrictive',
),
'Settings_bak.php' => array(
'type' => 'file',
'writable_on' => 'restrictive',
),
'attachments' => array(
'type' => 'dir',
'writable_on' => 'restrictive',
),
'avatars' => array(
'type' => 'dir',
'writable_on' => 'standard',
),
'cache' => array(
'type' => 'dir',
'writable_on' => 'restrictive',
),
'custom_avatar_dir' => array(
'type' => 'dir',
'writable_on' => 'restrictive',
),
'Smileys' => array(
'type' => 'dir_recursive',
'writable_on' => 'standard',
),
'Sources' => array(
'type' => 'dir_recursive',
'list_contents' => true,
'writable_on' => 'standard',
'contents' => array(
'tasks' => array(
'type' => 'dir',
'list_contents' => true,
),
),
),
'Themes' => array(
'type' => 'dir_recursive',
'writable_on' => 'standard',
'contents' => array(
'default' => array(
'type' => 'dir_recursive',
'list_contents' => true,
'contents' => array(
'languages' => array(
'type' => 'dir',
'list_contents' => true,
),
),
),
),
),
'Packages' => array(
'type' => 'dir',
'writable_on' => 'standard',
'contents' => array(
'temp' => array(
'type' => 'dir',
),
'backup' => array(
'type' => 'dir',
),
),
),
),
),
);
// Directories that can move.
if (substr($sourcedir, 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Sources']);
$context['file_tree'][strtr($sourcedir, array('\\' => '/'))] = array(
'type' => 'dir',
'list_contents' => true,
'writable_on' => 'standard',
);
}
// Moved the cache?
if (substr($cachedir, 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['cache']);
$context['file_tree'][strtr($cachedir, array('\\' => '/'))] = array(
'type' => 'dir',
'list_contents' => false,
'writable_on' => 'restrictive',
);
}
// Are we using multiple attachment directories?
if (!empty($modSettings['currentAttachmentUploadDir']))
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
if (!is_array($modSettings['attachmentUploadDir']))
$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
// @todo Should we suggest non-current directories be read only?
foreach ($modSettings['attachmentUploadDir'] as $dir)
$context['file_tree'][strtr($dir, array('\\' => '/'))] = array(
'type' => 'dir',
'writable_on' => 'restrictive',
);
}
elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
$context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array(
'type' => 'dir',
'writable_on' => 'restrictive',
);
}
if (substr($modSettings['smileys_dir'], 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Smileys']);
$context['file_tree'][strtr($modSettings['smileys_dir'], array('\\' => '/'))] = array(
'type' => 'dir_recursive',
'writable_on' => 'standard',
);
}
if (substr($modSettings['avatar_directory'], 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['avatars']);
$context['file_tree'][strtr($modSettings['avatar_directory'], array('\\' => '/'))] = array(
'type' => 'dir',
'writable_on' => 'standard',
);
}
if (isset($modSettings['custom_avatar_dir']) && substr($modSettings['custom_avatar_dir'], 0, strlen($boarddir)) != $boarddir)
{
unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['custom_avatar_dir']);
$context['file_tree'][strtr($modSettings['custom_avatar_dir'], array('\\' => '/'))] = array(
'type' => 'dir',
'writable_on' => 'restrictive',
);
}
// Load up any custom themes.
$request = $smcFunc['db_query']('', '
SELECT value
FROM {db_prefix}themes
WHERE id_theme > {int:default_theme_id}
AND id_member = {int:guest_id}
AND variable = {string:theme_dir}
ORDER BY value ASC',
array(
'default_theme_id' => 1,
'guest_id' => 0,
'theme_dir' => 'theme_dir',
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes'))
$context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array(
'type' => 'dir_recursive',
'list_contents' => true,
'contents' => array(
'languages' => array(
'type' => 'dir',
'list_contents' => true,
),
),
);
else
{
$context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array(
'type' => 'dir_recursive',
'list_contents' => true,
'contents' => array(
'languages' => array(
'type' => 'dir',
'list_contents' => true,
),
),
);
}
}
$smcFunc['db_free_result']($request);
// If we're submitting then let's move on to another function to keep things cleaner..
if (isset($_POST['action_changes']))
return PackagePermissionsAction();
$context['look_for'] = array();
// Are we looking for a particular tree - normally an expansion?
if (!empty($_REQUEST['find']))
$context['look_for'][] = base64_decode($_REQUEST['find']);
// Only that tree?
$context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : '';
if ($context['only_find'])
$context['look_for'][] = $context['only_find'];
// Have we got a load of back-catalogue trees to expand from a submit etc?
if (!empty($_GET['back_look']))
{
$potententialTrees = $smcFunc['json_decode'](base64_decode($_GET['back_look']), true);
foreach ($potententialTrees as $tree)
$context['look_for'][] = $tree;
}
// ... maybe posted?
if (!empty($_POST['back_look']))
$context['only_find'] = array_merge($context['only_find'], $_POST['back_look']);
$context['back_look_data'] = base64_encode($smcFunc['json_encode'](array_slice($context['look_for'], 0, 15)));
// Are we finding more files than first thought?
$context['file_offset'] = !empty($_REQUEST['fileoffset']) ? (int) $_REQUEST['fileoffset'] : 0;
// Don't list more than this many files in a directory.
$context['file_limit'] = 150;
// How many levels shall we show?
$context['default_level'] = empty($context['only_find']) ? 2 : 25;
// This will be used if we end up catching XML data.
$context['xml_data'] = array(
'roots' => array(
'identifier' => 'root',
'children' => array(
array(
'value' => preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $context['only_find']),
),
),
),
'folders' => array(
'identifier' => 'folder',
'children' => array(),
),
);
foreach ($context['file_tree'] as $path => $data)
{
// Run this directory.
if (file_exists($path) && (empty($context['only_find']) || substr($context['only_find'], 0, strlen($path)) == $path))
{
// Get the first level down only.
fetchPerms__recursive($path, $context['file_tree'][$path], 1);
$context['file_tree'][$path]['perms'] = array(
'chmod' => @is_writable($path),
'perms' => @fileperms($path),
);
}
else
unset($context['file_tree'][$path]);
}
// Is this actually xml?
if (isset($_GET['xml']))
{
loadTemplate('Xml');
$context['sub_template'] = 'generic_xml';
$context['template_layers'] = array();
}
}
/**
* Checkes the permissions of all the areas that will be affected by the package
*
* @param string $path The path to the directiory to check permissions for
* @param array $data An array of data about the directory
* @param int $level How far deep to go
*/
function fetchPerms__recursive($path, &$data, $level)
{
global $context;
$isLikelyPath = false;
foreach ($context['look_for'] as $possiblePath)
if (substr($possiblePath, 0, strlen($path)) == $path)
$isLikelyPath = true;
// Is this where we stop?
if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath)
return;
elseif ($level > $context['default_level'] && !$isLikelyPath)
return;
// Are we actually interested in saving this data?
$save_data = empty($context['only_find']) || $context['only_find'] == $path;
// @todo Shouldn't happen - but better error message?
if (!is_dir($path))
fatal_lang_error('no_access', false);
// This is where we put stuff we've found for sorting.
$foundData = array(
'files' => array(),
'folders' => array(),
);
$dh = opendir($path);
while ($entry = readdir($dh))
{
// Some kind of file?
if (is_file($path . '/' . $entry))
{
// Are we listing PHP files in this directory?
if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php')
$foundData['files'][$entry] = true;
// A file we were looking for.
elseif ($save_data && isset($data['contents'][$entry]))
$foundData['files'][$entry] = true;
}
// It's a directory - we're interested one way or another, probably...
elseif ($entry != '.' && $entry != '..')
{
// Going further?
if ((!empty($data['type']) && $data['type'] == 'dir_recursive') || (isset($data['contents'][$entry]) && (!empty($data['contents'][$entry]['list_contents']) || (!empty($data['contents'][$entry]['type']) && $data['contents'][$entry]['type'] == 'dir_recursive'))))
{
if (!isset($data['contents'][$entry]))
$foundData['folders'][$entry] = 'dir_recursive';
else
$foundData['folders'][$entry] = true;
// If this wasn't expected inherit the recusiveness...
if (!isset($data['contents'][$entry]))
// We need to do this as we will be going all recursive.
$data['contents'][$entry] = array(
'type' => 'dir_recursive',
);
// Actually do the recursive stuff...
fetchPerms__recursive($path . '/' . $entry, $data['contents'][$entry], $level + 1);
}
// Maybe it is a folder we are not descending into.
elseif (isset($data['contents'][$entry]))
$foundData['folders'][$entry] = true;
// Otherwise we stop here.
}
}
closedir($dh);
// Nothing to see here?
if (!$save_data)
return;
// Now actually add the data, starting with the folders.
ksort($foundData['folders']);
foreach ($foundData['folders'] as $folder => $type)
{
$additional_data = array(
'perms' => array(
'chmod' => @is_writable($path . '/' . $folder),
'perms' => @fileperms($path . '/' . $folder),
),
);
if ($type !== true)
$additional_data['type'] = $type;
// If there's an offset ignore any folders in XML mode.
if (isset($_GET['xml']) && $context['file_offset'] == 0)
{
$context['xml_data']['folders']['children'][] = array(
'attributes' => array(
'writable' => $additional_data['perms']['chmod'] ? 1 : 0,
'permissions' => substr(sprintf('%o', $additional_data['perms']['perms']), -4),
'folder' => 1,
'path' => $context['only_find'],
'level' => $level,
'more' => 0,
'offset' => $context['file_offset'],
'my_ident' => preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $context['only_find'] . '/' . $folder),
'ident' => preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $context['only_find']),
),
'value' => $folder,
);
}
elseif (!isset($_GET['xml']))
{
if (isset($data['contents'][$folder]))
$data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data);
else
$data['contents'][$folder] = $additional_data;
}
}
// Now we want to do a similar thing with files.
ksort($foundData['files']);
$counter = -1;
foreach ($foundData['files'] as $file => $dummy)
{
$counter++;
// Have we reached our offset?
if ($context['file_offset'] > $counter)
continue;
// Gone too far?
if ($counter > ($context['file_offset'] + $context['file_limit']))
continue;
$additional_data = array(
'perms' => array(
'chmod' => @is_writable($path . '/' . $file),
'perms' => @fileperms($path . '/' . $file),
),
);
// XML?
if (isset($_GET['xml']))
{
$context['xml_data']['folders']['children'][] = array(
'attributes' => array(
'writable' => $additional_data['perms']['chmod'] ? 1 : 0,
'permissions' => substr(sprintf('%o', $additional_data['perms']['perms']), -4),
'folder' => 0,
'path' => $context['only_find'],
'level' => $level,
'more' => $counter == ($context['file_offset'] + $context['file_limit']) ? 1 : 0,
'offset' => $context['file_offset'],
'my_ident' => preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $context['only_find'] . '/' . $file),
'ident' => preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $context['only_find']),
),
'value' => $file,
);
}
elseif ($counter != ($context['file_offset'] + $context['file_limit']))
{
if (isset($data['contents'][$file]))
$data['contents'][$file] = array_merge($data['contents'][$file], $additional_data);
else
$data['contents'][$file] = $additional_data;
}
}
}
/**
* Actually action the permission changes they want.
*/
function PackagePermissionsAction()
{
global $smcFunc, $context, $txt, $package_ftp;
umask(0);
$timeout_limit = 5;
$context['method'] = $_POST['method'] == 'individual' ? 'individual' : 'predefined';
$context['sub_template'] = 'action_permissions';
$context['page_title'] = $txt['package_file_perms_applying'];
$context['back_look_data'] = isset($_POST['back_look']) ? $_POST['back_look'] : array();
// Skipping use of FTP?
if (empty($package_ftp))
$context['skip_ftp'] = true;
// We'll start off in a good place, security. Make sure that if we're dealing with individual files that they seem in the right place.
if ($context['method'] == 'individual')
{
// Only these path roots are legal.
$legal_roots = array_keys($context['file_tree']);
$context['custom_value'] = (int) $_POST['custom_value'];
// Continuing?
if (isset($_POST['toProcess']))
$_POST['permStatus'] = $smcFunc['json_decode'](base64_decode($_POST['toProcess']), true);
if (isset($_POST['permStatus']))
{
$context['to_process'] = array();
$validate_custom = false;
foreach ($_POST['permStatus'] as $path => $status)
{
// Nothing to see here?
if ($status == 'no_change')
continue;
$legal = false;
foreach ($legal_roots as $root)
if (substr($path, 0, strlen($root)) == $root)
$legal = true;
if (!$legal)
continue;
// Check it exists.
if (!file_exists($path))
continue;
if ($status == 'custom')
$validate_custom = true;
// Now add it.
$context['to_process'][$path] = $status;
}
$context['total_items'] = isset($_POST['totalItems']) ? (int) $_POST['totalItems'] : count($context['to_process']);
// Make sure the chmod status is valid?
if ($validate_custom)
{
if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false)
fatal_error($txt['chmod_value_invalid']);
}
// Nothing to do?
if (empty($context['to_process']))
redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']);
}
// Should never get here,
else
fatal_lang_error('no_access', false);
// Setup the custom value.
$custom_value = octdec('0' . $context['custom_value']);
// Start processing items.
foreach ($context['to_process'] as $path => $status)
{
if (in_array($status, array('execute', 'writable', 'read')))
package_chmod($path, $status);
elseif ($status == 'custom' && !empty($custom_value))
{
// Use FTP if we have it.
if (!empty($package_ftp) && !empty($_SESSION['pack_ftp']))
{
$ftp_file = strtr($path, array($_SESSION['pack_ftp']['root'] => ''));
$package_ftp->chmod($ftp_file, $custom_value);
}
else
smf_chmod($path, $custom_value);
}
// This fish is fried...
unset($context['to_process'][$path]);
// See if we're out of time?
if ((time() - TIME_START) > $timeout_limit)
{
// Prepare template usage for to_process.
$context['to_process_encode'] = base64_encode($smcFunc['json_encode']($context['to_process']));
return false;
}
}
// Prepare template usage for to_process.
$context['to_process_encode'] = base64_encode($smcFunc['json_encode']($context['to_process']));
}
// If predefined this is a little different.
else
{
$context['predefined_type'] = isset($_POST['predefined']) ? $_POST['predefined'] : 'restricted';
$context['total_items'] = isset($_POST['totalItems']) ? (int) $_POST['totalItems'] : 0;
$context['directory_list'] = isset($_POST['dirList']) ? $smcFunc['json_decode'](base64_decode($_POST['dirList']), true) : array();
$context['file_offset'] = isset($_POST['fileOffset']) ? (int) $_POST['fileOffset'] : 0;
// Haven't counted the items yet?
if (empty($context['total_items']))
{
/**
* Counts all the directories under a given path
*
* @param string $dir
* @return integer
*/
function count_directories__recursive($dir)
{
global $context;
$count = 0;
$dh = @opendir($dir);
while ($entry = readdir($dh))
{
if ($entry != '.' && $entry != '..' && is_dir($dir . '/' . $entry))
{
$context['directory_list'][$dir . '/' . $entry] = 1;
$count++;
$count += count_directories__recursive($dir . '/' . $entry);
}
}
closedir($dh);
return $count;
}
foreach ($context['file_tree'] as $path => $data)
{
if (is_dir($path))
{
$context['directory_list'][$path] = 1;
$context['total_items'] += count_directories__recursive($path);
$context['total_items']++;
}
}
}
// Have we built up our list of special files?
if (!isset($_POST['specialFiles']) && $context['predefined_type'] != 'free')
{
$context['special_files'] = array();
/**
* Builds a list of special files recursively for a given path
*
* @param string $path
* @param array $data
*/
function build_special_files__recursive($path, &$data)
{
global $context;
if (!empty($data['writable_on']))
if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive')
$context['special_files'][$path] = 1;
if (!empty($data['contents']))
foreach ($data['contents'] as $name => $contents)
build_special_files__recursive($path . '/' . $name, $contents);
}
foreach ($context['file_tree'] as $path => $data)
build_special_files__recursive($path, $data);
}
// Free doesn't need special files.
elseif ($context['predefined_type'] == 'free')
$context['special_files'] = array();
else
$context['special_files'] = $smcFunc['json_decode'](base64_decode($_POST['specialFiles']), true);
// Now we definitely know where we are, we need to go through again doing the chmod!
foreach ($context['directory_list'] as $path => $dummy)
{
// Do the contents of the directory first.
$dh = @opendir($path);
$file_count = 0;
$dont_chmod = false;
while ($entry = readdir($dh))
{
$file_count++;
// Actually process this file?
if (!$dont_chmod && !is_dir($path . '/' . $entry) && (empty($context['file_offset']) || $context['file_offset'] < $file_count))
{
$status = $context['predefined_type'] == 'free' || isset($context['special_files'][$path . '/' . $entry]) ? 'writable' : 'execute';
package_chmod($path . '/' . $entry, $status);
}
// See if we're out of time?
if (!$dont_chmod && (time() - TIME_START) > $timeout_limit)
{
$dont_chmod = true;
// Don't do this again.
$context['file_offset'] = $file_count;
}
}
closedir($dh);
// If this is set it means we timed out half way through.
if ($dont_chmod)
{
$context['total_files'] = $file_count;
$context['directory_list_encode'] = base64_encode($smcFunc['json_encode']($context['directory_list']));
$context['special_files_encode'] = base64_encode($smcFunc['json_encode']($context['special_files']));
return false;
}
// Do the actual directory.
$status = $context['predefined_type'] == 'free' || isset($context['special_files'][$path]) ? 'writable' : 'execute';
package_chmod($path, $status);
// We've finished the directory so no file offset, and no record.
$context['file_offset'] = 0;
unset($context['directory_list'][$path]);
// See if we're out of time?
if ((time() - TIME_START) > $timeout_limit)
{
// Prepare this for usage on templates.
$context['directory_list_encode'] = base64_encode($smcFunc['json_encode']($context['directory_list']));
$context['special_files_encode'] = base64_encode($smcFunc['json_encode']($context['special_files']));
return false;
}
}
// Prepare this for usage on templates.
$context['directory_list_encode'] = base64_encode($smcFunc['json_encode']($context['directory_list']));
$context['special_files_encode'] = base64_encode($smcFunc['json_encode']($context['special_files']));
}
// If we're here we are done!
redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode($smcFunc['json_encode']($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']);
}
/**
* Test an FTP connection.
*/
function PackageFTPTest()
{
global $context, $txt, $package_ftp;
checkSession('get');
// Try to make the FTP connection.
create_chmod_control(array(), array('force_find_error' => true));
// Deal with the template stuff.
loadTemplate('Xml');
$context['sub_template'] = 'generic_xml';
$context['template_layers'] = array();
// Define the return data, this is simple.
$context['xml_data'] = array(
'results' => array(
'identifier' => 'result',
'children' => array(
array(
'attributes' => array(
'success' => !empty($package_ftp) ? 1 : 0,
),
'value' => !empty($package_ftp) ? $txt['package_ftp_test_success'] : (isset($context['package_ftp'], $context['package_ftp']['error']) ? $context['package_ftp']['error'] : $txt['package_ftp_test_failed']),
),
),
),
);
}
?>
|
StealthWombat/SMF2.1-more-forkery
|
Sources/Packages.php
|
PHP
|
bsd-3-clause
| 97,648
|
<?php
namespace frontend\modules\postad\models;
use Yii;
/**
* This is the model class for table "post_ad_attributes".
*
* @property integer $id
* @property integer $post_id
* @property string $attribute_property
* @property string $attribute_value
*/
class PostAdAttributes extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'post_ad_attributes';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['post_id'], 'integer'],
[['attribute_property', 'attribute_value'], 'string', 'max' => 45],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'post_id' => 'Post ID',
'attribute_property' => 'Attribute Property',
'attribute_value' => 'Attribute Value',
];
}
}
|
sadiyaalkurn/verkopen
|
frontend/modules/postad/models/PostAdAttributes.php
|
PHP
|
bsd-3-clause
| 949
|
<?php
namespace app\models;
use Yii;
use yii\web\UploadedFile;
use yii\imagine\Image;
use Imagine\Gd;
use Imagine\Image\Box;
use Imagine\Image\BoxInterface;
/**
* This is the model class for table "merchant_menu".
*
* @property integer $id
* @property string $title
* @property integer $price
* @property integer $weight
* @property string $description
* @property integer $merchant_id
* @property integer $created_date
* @property integer $kitchen_id
*/
class MerchantMenu extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
const CATEGORY_KITCHEN = 2;
const CATEGORY_MENU = 32;
const CATEGORY_WEIGHT_TYPE = 44;
const MAX_COUNT_PHOTOS = 7;
const MAX_UPLOAD_SIZE = 5242880;
public $contacts;
public $imageFiles;
public $mainImageFile;
private $path = '/var/www/img.inreserve.kz/uploads/menu/';
public static function tableName()
{
return 'merchant_menu';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['title', 'price', 'weight', 'merchant_id', 'weight_type'], 'required'],
[['price', 'merchant_id', 'created_date', 'kitchen_id', 'category_id'], 'integer'],
[['weight'], 'double'],
[['description'], 'string'],
[['title'], 'string', 'max' => 255],
[['imageFiles'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg', 'maxFiles' => 4, 'maxSize' => self::MAX_UPLOAD_SIZE, 'tooBig' => 'Размер файла превышает 5мб'],
[['mainImageFile'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg', 'maxSize' => self::MAX_UPLOAD_SIZE, 'tooBig' => 'Размер файла превышает 5мб'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'price' => 'Цена за порцию',
'weight' => 'Вес',
'description' => 'Описание',
'merchant_id' => 'Merchant ID',
'created_date' => 'Created Date',
'kitchen_id' => 'Тип кухни',
'category_id' => 'Категория',
'weight_type' => 'Единица измерения'
];
}
public function getKitchens(){
$array = [];
$categories = Category::find()->where(['parent_id'=>$this::CATEGORY_KITCHEN,'lang'=>Yii::$app->params['defaultLang']])->orderBy("title ASC")->all();
foreach ($categories as $category) {
$array[$category->id] = $category->title;
}
return $array;
}
public function getWeightType(){
return $this->hasOne(Category::className(), ['id' => 'weight_type']);
}
public function getCategories(){
$array = [];
$categories = Category::find()->where(['parent_id'=>$this::CATEGORY_MENU,'lang'=>Yii::$app->params['defaultLang']])->orderBy("position asc")->all();
foreach ($categories as $category) {
$childs = Category::find()->where(['parent_id'=>$category->id,'lang'=>Yii::$app->params['defaultLang']])->orderBy("position asc")->all();
if ($childs):
$child_array = [];
foreach ($childs as $child):
$child_array[$child->id] = $child->title;
endforeach;
$array[$category->title] = $child_array;
else:
$array[$category->id] = $category->title;
endif;
}
return $array;
}
public function getWeightTypes(){
$array = [];
$categories = Category::find()->where(['parent_id'=>$this::CATEGORY_WEIGHT_TYPE,'lang'=>Yii::$app->params['defaultLang']])->orderBy("position asc")->all();
foreach ($categories as $category) {
$array[$category->id] = $category->title;
}
return $array;
}
public function beforeValidate()
{
$this->weight = str_replace(',','.',$this->weight);
return parent::beforeValidate();
}
public function beforeSave($insert)
{
if ($this->isNewRecord):
$this->created_date = time();
endif;
return parent::beforeSave($insert);
}
public function upload()
{
if ($this->validate()) {
foreach ($this->imageFiles as $file) {
$count_images = MerchantMenuPhotos::find()->where(['menu_id'=>$this->id])->count();
if ($count_images <= self::MAX_COUNT_PHOTOS){
$filename = md5($file->baseName.time().date("YmdHsi")) . '.' . $file->extension;
if ($file->saveAs($this->path . $filename)):
Image::getImagine()->open($this->path.$filename)->thumbnail(new Box(200, 200))->save($this->path.'thumb_'.$filename , ['quality' => 90]);
Image::getImagine()->open($this->path.$filename)->thumbnail(new Box(1200, 768))->save($this->path.$filename , ['quality' => 90]);
$image = new MerchantMenuPhotos();
$image->file = $filename;
$image->menu_id = $this->id;
$image->is_main = 0;
$image->creation_date = time();
$image->save();
endif;
}
}
} else {
return false;
}
}
public function retUnitCase( $value, $unit1, $unit2, $unit3 ){
$value = abs( $value % 100 );
if (11 > $value || $value > 19) {
switch( $value % 10 ) {
case 1: return $unit1;
case 2: case 3: case 4: return $unit2;
}
}
return $unit3;
}
}
|
elorian/cabinet.inreserve.kz
|
models/MerchantMenu.php
|
PHP
|
bsd-3-clause
| 6,009
|
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
package net.tinyos.script.tree;
import java.io.*;
import net.tinyos.script.*;
public class ForUnconditionalStatement extends Statement {
private SingleReference variableSet;
private Expression initialValue;
private ConstantExpression endValue;
private ConstantExpression step;
private StatementList statements;
private SingleAccess variableGet;
private int constantValue;
public ForUnconditionalStatement(int lineNumber, SingleReference variableSet, Expression initialValue, ConstantExpression endValue, ConstantExpression step, StatementList statements, SingleAccess variableGet) {
super(lineNumber);
this.variableSet = variableSet;
this.initialValue = initialValue;
this.endValue = endValue;
this.step = step;
this.statements = statements;
this.variableGet = variableGet;
}
public void checkStatement(SymbolTable table) throws SemanticException {
if (!variableSet.toString().equals(variableGet.toString())) {
throw new SemanticException("Loop value and increment value must be same variable: " + variableSet + "(" + variableSet.symbol() + ") and " + variableGet + "(" + variableGet.symbol() + ")", lineNumber());
}
variableSet.checkStatement(table);
initialValue.checkStatement(table);
endValue.checkStatement(table);
statements.checkStatement(table);
variableGet.checkStatement(table);
}
public void generateCode(SymbolTable table, CodeWriter writer) throws IOException {
writer.writeComment("Beginning of unconditional loop");
initialValue.generateCode(table, writer);
variableSet.generateCode(table, writer);
String label = "label" + table.getBranchSym();
writer.writeLabel(label);
statements.generateCode(table, writer);
variableGet.generateCode(table, writer);
if (step.value() != 0) {
step.generateCode(table, writer);
writer.writeInstr("add");
writer.writeInstr("copy");
variableSet.generateCode(table, writer);
}
endValue.generateCode(table, writer);
writer.writeInstr("lt");
writer.writeInstr("2jumps10 " + label);
writer.writeComment("End of unconditional loop");
}
}
|
fresskarma/tinyos-1.x
|
tools/java/net/tinyos/script/tree/ForUnconditionalStatement.java
|
Java
|
bsd-3-clause
| 3,614
|
import org.tolweb.treegrow.page.InternetLink;
import junit.framework.TestCase;
/*
* Created on Jul 4, 2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
/**
* @author dmandel
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class InternetLinkTest extends TestCase {
public void testEquals() {
InternetLink link1 = new InternetLink();
InternetLink link2 = new InternetLink();
assertFalse(link1.equals(link2));
link1.setLinkId(new Long(1));
assertFalse(link1.equals(link2));
link2.setLinkId(new Long(2));
assertFalse(link1.equals(link2));
link2.setLinkId(new Long(1));
assertTrue(link1.equals(link2));
assertTrue(link1.equals(link1));
assertTrue(link2.equals(link2));
}
}
|
tolweb/tolweb-app
|
TreeGrow/tests/org/tolweb/treegrow/page/InternetLinkTest.java
|
Java
|
bsd-3-clause
| 891
|
<?php
/**
* Created by PhpStorm.
* Author: npbtrac@yahoo.com
* Date time: 9/10/17 11:13 PM
*/
namespace enpii\enpiiCms\libs\override\db;
use yii\db\ActiveQuery;
use enpii\enpiiCms\libs\override\db\NpActiveRecord as ActiveRecord;
/**
* Class NpActiveQuery
* @package enpii\enpiiCms\libs\override\db
* For overriding Yii methods
*/
class NpActiveQuery extends ActiveQuery
{
/**
* Determine a record is active or not
* A working record means is_deleted = 0 and is_enabled = 1
* @return $this
*/
public function isWorking()
{
return $this->andWhere(['status' > ActiveRecord::_STATUS_DISABLED]);
}
/**
* @return $this
*/
public function notDeleted()
{
return $this->andFilterWhere(['is_deleted' => 0]);
}
}
|
npbtrac/yii2-enpii-cms
|
libs/override/db/NpActiveQuery.php
|
PHP
|
bsd-3-clause
| 792
|
<?php
namespace Jazzee\Entity;
/**
* AuditLog
* AuditLog entries record critical user actions against applicants
* Like editing or deleting answers
*
* @Entity
* @Table(name="audit_log")
* @SuppressWarnings(PHPMD.ShortVariable)
* @author Jon Johnson <jon.johnson@ucsf.edu>
* @license http://jazzee.org/license BSD-3-Clause
*/
class AuditLog
{
/**
* @Id
* @Column(type="bigint")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/** @Column(type="datetime") */
protected $createdAt;
/** @Column(type="text") */
private $text;
/**
* @ManyToOne(targetEntity="User",inversedBy="auditLogs")
* @JoinColumn(onDelete="CASCADE")
*/
protected $user;
/**
* @ManyToOne(targetEntity="Applicant",inversedBy="auditLogs")
* @JoinColumn(onDelete="CASCADE")
*/
protected $applicant;
/**
* Constructor
* Everythign is specified here and can't be set any other way
* @param User $user
* @param Applicant $applicant
* @param strig $text
*/
public function __construct(User $user, Applicant $applicant, $text)
{
$this->createdAt = new \DateTime('now');
$this->user = $user;
$this->applicant = $applicant;
$this->text = $text;
}
/**
* Get id
*
* @return bigint $id
*/
public function getId()
{
return $this->id;
}
/**
* Get createdAt
*
* @return \DateTime $createdAt
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Get user
*
* @return Entity\User $user
*/
public function getUser()
{
return $this->user;
}
/**
* Get applicant
*
* @return Applicant $applicant
*/
public function getApplicant()
{
return $this->applicant;
}
/**
* Get text
*
* @return string $text
*/
public function getText()
{
return $this->text;
}
}
|
Jazzee/Jazzee
|
src/Jazzee/Entity/AuditLog.php
|
PHP
|
bsd-3-clause
| 1,853
|
package ildl
package benchmark
package hamming
import collection.mutable.Queue
object BigIntAsLong extends TransformationDescription {
def toRepr(high: BigInt): Long @high = {
assert(high.isValidLong)
high.longValue()
}
def toHigh(repr: Long @high): BigInt = BigInt(repr)
def extension_*(recv: Long @high, other: Long @high): Long @high =
recv * other
}
object HammingNumbers {
adrt(BigIntAsLong) {
class HammingADRT {
def x(n: BigInt*) = 1
val n = BigInt(1)
x(n * 2)
}
}
def main(args: Array[String]): Unit = {
new HammingADRT()
}
}
|
miniboxing/ildl-plugin
|
tests/correctness/resources/tests/hamming-issue.scala
|
Scala
|
bsd-3-clause
| 598
|
/*
* libjingle
* Copyright 2012, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This file contains mock implementations of observers used in PeerConnection.
#ifndef TALK_APP_WEBRTC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
#define TALK_APP_WEBRTC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
#include <string>
#include "talk/app/webrtc/datachannelinterface.h"
namespace webrtc {
class MockCreateSessionDescriptionObserver
: public webrtc::CreateSessionDescriptionObserver {
public:
MockCreateSessionDescriptionObserver()
: called_(false),
result_(false) {}
virtual ~MockCreateSessionDescriptionObserver() {}
virtual void OnSuccess(SessionDescriptionInterface* desc) {
called_ = true;
result_ = true;
desc_.reset(desc);
}
virtual void OnFailure(const std::string& error) {
called_ = true;
result_ = false;
}
bool called() const { return called_; }
bool result() const { return result_; }
SessionDescriptionInterface* release_desc() {
return desc_.release();
}
private:
bool called_;
bool result_;
rtc::scoped_ptr<SessionDescriptionInterface> desc_;
};
class MockSetSessionDescriptionObserver
: public webrtc::SetSessionDescriptionObserver {
public:
MockSetSessionDescriptionObserver()
: called_(false),
result_(false) {}
virtual ~MockSetSessionDescriptionObserver() {}
virtual void OnSuccess() {
called_ = true;
result_ = true;
}
virtual void OnFailure(const std::string& error) {
called_ = true;
result_ = false;
}
bool called() const { return called_; }
bool result() const { return result_; }
private:
bool called_;
bool result_;
};
class MockDataChannelObserver : public webrtc::DataChannelObserver {
public:
explicit MockDataChannelObserver(webrtc::DataChannelInterface* channel)
: channel_(channel), received_message_count_(0) {
channel_->RegisterObserver(this);
state_ = channel_->state();
}
virtual ~MockDataChannelObserver() {
channel_->UnregisterObserver();
}
virtual void OnStateChange() { state_ = channel_->state(); }
virtual void OnMessage(const DataBuffer& buffer) {
last_message_.assign(buffer.data.data(), buffer.data.length());
++received_message_count_;
}
bool IsOpen() const { return state_ == DataChannelInterface::kOpen; }
const std::string& last_message() const { return last_message_; }
size_t received_message_count() const { return received_message_count_; }
private:
rtc::scoped_refptr<webrtc::DataChannelInterface> channel_;
DataChannelInterface::DataState state_;
std::string last_message_;
size_t received_message_count_;
};
class MockStatsObserver : public webrtc::StatsObserver {
public:
MockStatsObserver()
: called_(false) {}
virtual ~MockStatsObserver() {}
virtual void OnComplete(const StatsReports& reports) {
called_ = true;
reports_.clear();
reports_.reserve(reports.size());
StatsReports::const_iterator it;
for (it = reports.begin(); it != reports.end(); ++it)
reports_.push_back(StatsReportCopyable(*(*it)));
}
bool called() const { return called_; }
size_t number_of_reports() const { return reports_.size(); }
int AudioOutputLevel() {
return GetSsrcStatsValue(
webrtc::StatsReport::kStatsValueNameAudioOutputLevel);
}
int AudioInputLevel() {
return GetSsrcStatsValue(
webrtc::StatsReport::kStatsValueNameAudioInputLevel);
}
int BytesReceived() {
return GetSsrcStatsValue(
webrtc::StatsReport::kStatsValueNameBytesReceived);
}
int BytesSent() {
return GetSsrcStatsValue(webrtc::StatsReport::kStatsValueNameBytesSent);
}
private:
int GetSsrcStatsValue(StatsReport::StatsValueName name) {
if (reports_.empty()) {
return 0;
}
for (size_t i = 0; i < reports_.size(); ++i) {
if (reports_[i].type != StatsReport::kStatsReportTypeSsrc)
continue;
webrtc::StatsReport::Values::const_iterator it =
reports_[i].values.begin();
for (; it != reports_[i].values.end(); ++it) {
if (it->name == name) {
return rtc::FromString<int>(it->value);
}
}
}
return 0;
}
bool called_;
std::vector<StatsReportCopyable> reports_;
};
} // namespace webrtc
#endif // TALK_APP_WEBRTC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_
|
xin3liang/platform_external_chromium_org_third_party_libjingle_source_talk
|
app/webrtc/test/mockpeerconnectionobservers.h
|
C
|
bsd-3-clause
| 5,709
|
<?php
/**
* @author James Baster <james@jarofgreen.co.uk>
* @copyright City of Edinburgh Council & James Baster
* @license Open Source under the 3-clause BSD License
* @url https://github.com/City-Outdoors/City-Outdoors-Web
*/
include dirname(__FILE__).'/../src/global.php';
include dirname(__FILE__).'/importFunctions.php';
$config = json_decode(file_get_contents($argv[1]));
if (!is_object($config)) die("Config failed to load\n");
$import = new ImportJADU($config->source->website, $config->source->apiKEY);
$user = User::loadByEmail($config->destination->userEmail);
if (!$user) die("No User found\n");
foreach($config->data as $data) {
$block = CMSContent::loadBlockBySlug($data->blockName);
if (!$block) $block = CMSContent::createBlock ($data->blockName, $user);
$import->importDocumentFromIDToCMSContent($data->documentID, $data->documentPageID, $block, $user);
}
print "Done\n";
|
City-Outdoors/City-Outdoors-Web
|
includes/tasks/importJaduPages.php
|
PHP
|
bsd-3-clause
| 921
|
/* Creates a new interaction class */
function iClazz(SuperClass, methods) {
var subClass = function () {
this.config.apply(this, arguments);
};
subClass.prototype = Object.create(SuperClass.prototype);
subClass.prototype.constructor = subClass;
subClass.prototype.parent = SuperClass.prototype;
subClass.prototype = $.extend(subClass.prototype, methods);
return subClass;
}
var SocialInteraction = iClazz(Object, {
config: function(options) {},
init: function() {}
});
var ToggleSocialInteraction = iClazz(SocialInteraction, {
config: function(options) {
this.options = {
selector: '.toggle_social_relationship',
eventType: 'click',
container: $('body')
};
if (typeof options == 'object') $.extend(this.options, options);
this.init();
},
init: function() {
var container = this.options.container,
$class = this;
if (container && (typeof container == 'object' && container[0] instanceof Element)) {
container.delegate(this.options.selector, this.options.eventType, function(e) {
e.preventDefault();
var $this = $(this),
url = $this.attr('href') || $this.data('url'),
pk = $this.data('pk');
if (typeof pk !== 'undefined' && typeof url !== 'undefined') {
$.ajax(url, {
type: 'POST',
data: {
"pk": pk
},
context: this,
success: function(response, status, xhr) {
$class.success(response, status, xhr, this);
},
error: function(response, status, xhr) {
$class.error(response, status, xhr, this);
},
dataType: "json"
});
} else {
throw new Error('Error: the values of (url and pk) must be specified.');
}
});
} else {
throw new Error('Error: this.options.container expects an HTML Element.');
}
},
success: function(response, status, xhr, context) {
if (status == "success" && response['result']) {
$(context).addClass((response['toggle_status']) ? 'on' : 'off');
}
},
error: function(response, status, xhr, context) {}
});
var FormSocialInteraction = iClazz(SocialInteraction, {
config: function(options) {
this.options = {
selector: '',
eventType: ''
};
if (typeof options == 'object') $.extend(this.options, options);
this.init();
},
init: function() {
var eventTrigger = $(this.options.selector).first(),
$class = this;
eventTrigger.on(this.options.eventType, function() {
$class.eventImpl(eventTrigger);
})
},
eventImpl: function(eventTrigger) {}
});
|
dgvicente/django-social-network
|
social_network/static/social_network/js/interactions.js
|
JavaScript
|
bsd-3-clause
| 3,125
|
# Haskell-Invaders
Tested on Ubuntu 15.10 with SDL 2.0.4
To install without static links:
1) Clone the repository.
2) Install SDL 2.0.4 (https://www.libsdl.org/download-2.0.php)
3) Install Haskell Stack 1.0.4 (http://docs.haskellstack.org/en/stable/GUIDE.html)
4) From the local Haskell-Invaders workspace, type "stack build", "stack exec space-invaders-exe"
I based my implementation off of a friend's CS2500 assignment and as a result, the invaders do not move. (http://www.ccs.neu.edu/course/cs2500f13-seattle/assignments/assignment7.html)
Also, you've got to hit an invader's corner in order to hit them, and the ship is not hit unless it's an upper left corner -- This was a learning project and I'd rather be working on the next project than hammering out a box-detection algorithm for a project that I consider unlikely for others to pull and install. If you're disappointed with this implementation, by all means play the actual game here: www.freeinvaders.org
|
KenseiMaedhros/Haskell-Invaders
|
README.md
|
Markdown
|
bsd-3-clause
| 972
|
from operator import attrgetter
from plyj.model.source_element import Expression
from plyj.utility import assert_type
class Name(Expression):
simple = property(attrgetter("_simple"))
value = property(attrgetter("_value"))
def __init__(self, value):
"""
Represents a name.
:param value: The name.
"""
super(Name, self).__init__()
self._fields = ['value']
self._value = None
self._simple = False
self.value = value
@value.setter
def value(self, value):
self._value = assert_type(value, str)
self._simple = "." not in value
def append_name(self, name):
self._simple = False
if isinstance(name, Name):
self._value = self._value + '.' + name._value
else:
self._value = self._value + '.' + name
@staticmethod
def ensure(se, simple):
if isinstance(se, str):
return Name(se)
if not isinstance(se, Name):
raise TypeError("Required Name, got \"{}\"".format(str(type(se))))
if simple and not se.simple:
raise TypeError("Required simple Name, got complex Name")
return se
def serialize(self):
return self.value
|
Craxic/plyj
|
plyj/model/name.py
|
Python
|
bsd-3-clause
| 1,255
|
package org.motechproject.scheduler.it;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.motechproject.event.MotechEvent;
import org.motechproject.scheduler.contract.CronSchedulableJob;
import org.motechproject.scheduler.contract.RepeatingSchedulableJob;
import org.motechproject.scheduler.contract.RunOnceSchedulableJob;
import org.motechproject.scheduler.service.MotechSchedulerService;
import org.motechproject.scheduler.service.SchedulerChannelProvider;
import org.motechproject.tasks.domain.EventParameter;
import org.motechproject.tasks.domain.TaskTriggerInformation;
import org.motechproject.tasks.domain.TriggerEvent;
import org.motechproject.testing.osgi.BasePaxIT;
import org.motechproject.testing.osgi.container.MotechNativeTestContainerFactory;
import org.ops4j.pax.exam.ExamFactory;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerSuite;
import org.osgi.framework.BundleContext;
import org.quartz.SchedulerException;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerSuite.class)
@ExamFactory(MotechNativeTestContainerFactory.class)
public class SchedulerChannelProviderBundleIT extends BasePaxIT {
private static final String TEST_EVENT = "test-event";
@Inject
private BundleContext bundleContext;
@Inject
private MotechSchedulerService schedulerService;
private SchedulerChannelProvider channelProvider;
@Before
public void setUp() {
if (channelProvider == null) {
channelProvider = (SchedulerChannelProvider) bundleContext.getService(
bundleContext.getServiceReference("org.motechproject.tasks.domain.DynamicChannelProvider")
);
}
Map<String, Object> params = new HashMap<>();
params.put(MotechSchedulerService.JOB_ID_KEY, "job_id");
schedulerService.scheduleJob(
new CronSchedulableJob(
new MotechEvent(TEST_EVENT, params),
"0 0 12 * * ?"
)
);
schedulerService.scheduleRunOnceJob(
new RunOnceSchedulableJob(
new MotechEvent(TEST_EVENT, params),
DateTime.now().plusDays(1)
)
);
schedulerService.scheduleRepeatingJob(
new RepeatingSchedulableJob(
new MotechEvent(TEST_EVENT, params),
DateTimeConstants.SECONDS_PER_DAY,
DateTime.now().plusHours(1),
DateTime.now().plusHours(3),
false
)
);
}
@Test
public void shouldGetTriggers() throws SchedulerException {
List<TriggerEvent> triggers = channelProvider.getTriggers(1, 20);
assertTrue(triggers.containsAll(getExpectedTriggers()));
}
@Test
public void shouldGetTrigger() {
TaskTriggerInformation information = new TaskTriggerInformation(
"Job: test-event-job_id",
"Channel name",
"Module name",
"Module version",
"test-event-job_id",
TEST_EVENT
);
TriggerEvent trigger = channelProvider.getTrigger(information);
assertEquals(getExpectedTrigger(), trigger);
}
@Test
public void shouldCountTrigger() {
assertTrue(channelProvider.countTriggers() >= 3);
}
private TriggerEvent getExpectedTrigger() {
List<EventParameter> parameters = new ArrayList<>();
parameters.add(new EventParameter("scheduler.jobId", "JobID"));
return new TriggerEvent(
"Job: test-event-job_id",
"test-event-job_id",
null,
parameters,
TEST_EVENT
);
}
private List<TriggerEvent> getExpectedTriggers() {
List<TriggerEvent> triggers = new ArrayList<>();
List<EventParameter> parameters = new ArrayList<>();
parameters.add(new EventParameter("scheduler.jobId", "JobID"));
triggers.add(new TriggerEvent(
"Job: test-event-job_id",
"test-event-job_id",
null,
parameters,
TEST_EVENT
));
triggers.add(new TriggerEvent(
"Job: test-event-job_id-repeat",
"test-event-job_id-repeat",
null,
parameters,
TEST_EVENT
));
triggers.add(new TriggerEvent(
"Job: test-event-job_id-runonce",
"test-event-job_id-runonce",
null,
parameters,
TEST_EVENT
));
return triggers;
}
@After
public void tearDown() throws SchedulerException {
schedulerService.unscheduleAllJobs(TEST_EVENT);
}
}
|
justin-hayes/motech
|
modules/scheduler/scheduler/src/test/java/org/motechproject/scheduler/it/SchedulerChannelProviderBundleIT.java
|
Java
|
bsd-3-clause
| 5,309
|
// Copyright 2019 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 COMPONENTS_EXO_WAYLAND_WL_DATA_DEVICE_MANAGER_H_
#define COMPONENTS_EXO_WAYLAND_WL_DATA_DEVICE_MANAGER_H_
#include <stdint.h>
#include "base/macros.h"
struct wl_client;
namespace exo {
class Display;
namespace wayland {
class SerialTracker;
constexpr uint32_t kWlDataDeviceManagerVersion = 3;
struct WaylandDataDeviceManager {
WaylandDataDeviceManager(Display* display, SerialTracker* serial_tracker)
: display(display), serial_tracker(serial_tracker) {}
WaylandDataDeviceManager(const WaylandDataDeviceManager&) = delete;
WaylandDataDeviceManager& operator=(const WaylandDataDeviceManager&) = delete;
// Owned by WaylandServerController, which always outlives
// wl_data_device_manager.
Display* const display;
// Owned by Server, which always outlives wl_data_device_manager.
SerialTracker* const serial_tracker;
};
void bind_data_device_manager(wl_client* client,
void* data,
uint32_t version,
uint32_t id);
} // namespace wayland
} // namespace exo
#endif // COMPONENTS_EXO_WAYLAND_WL_DATA_DEVICE_MANAGER_H_
|
nwjs/chromium.src
|
components/exo/wayland/wl_data_device_manager.h
|
C
|
bsd-3-clause
| 1,314
|
/* ====================================================================
* Copyright 2005-2006 JRemoting Committers
* Portions copyright 2001 - 2004 Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.codehaus.jremoting.responses;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* Class BadServerSideEvent
*
* @author Paul Hammant
*
*/
public class BadServerSideEvent extends Response {
private String message;
private static final long serialVersionUID = -2483879009323117727L;
public BadServerSideEvent(String message) {
this.message = message;
}
// for Externalisation
public BadServerSideEvent() {
}
public String getMessage() {
return message;
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(message);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
message = (String) in.readObject();
}
}
|
paul-hammant/JRemoting
|
api/src/java/org/codehaus/jremoting/responses/BadServerSideEvent.java
|
Java
|
bsd-3-clause
| 1,562
|
{% extends "layout.html" %}
{% block content %}
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<h1>Welcome to This is a foo bar project</h1>
<p>This is a starter Flask template. It includes Bootstrap 3, jQuery 2, Flask-SQLAlchemy, WTForms, and various testing utilities out of the box.</p>
<p><a href="https://github.com/sloria/cookiecutter-flask" class="btn btn-primary btn-large">Learn more »</a></p>
</div><!-- /.jumbotron -->
<div class="body-content">
<div class="row">
<div class="col-lg-4">
<h2><i class="fa fa-code"></i> Bootstrap 3</h2>
<p>Sleek, intuitive, and powerful mobile-first front-end framework for faster and easier web development.</p>
<p><a class="btn btn-default" href="http://getbootstrap.com/">Official website »</a></p>
</div>
<div class="col-lg-4">
<h2><i class="fa fa-flask"></i> SQLAlchemy</h2>
<p>SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.</p>
<p><a href="http://www.sqlalchemy.org/" class="btn btn-default" href="#">Official website »</a></p>
</div>
<div class="col-lg-4">
<h2><i class="fa fa-edit"></i> WTForms</h2>
<p>WTForms is a flexible forms validation and rendering library for python web development.</p>
<p><a href="http://wtforms.simplecodes.com/" class="btn btn-default" href="#">Official website »</a></p>
</div>
</div><!-- /.row -->
</div>
{% endblock %}
|
ghofranehr/foobar
|
foobar/templates/public/home.html
|
HTML
|
bsd-3-clause
| 1,561
|
/*
* Copyright 2014, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package io.grpc;
import java.io.InputStream;
/**
* A typed abstraction over message parsing and serialization.
*
* <p>Stub implementations will define implementations of this interface for each of the request and
* response messages provided by a service.
*
* @param <T> type of serializable message
*/
public interface Marshaller<T> {
/**
* Given a message, produce an {@link InputStream} for it so that it can be written to the wire.
*
* @param value to serialize.
* @return serialized value as stream of bytes.
*/
public InputStream stream(T value);
/**
* Given an {@link InputStream} parse it into an instance of the declared type so that it can be
* passed to application code.
*
* @param stream of bytes for serialized value
* @return parsed value
*/
public T parse(InputStream stream);
}
|
meghana0507/grpc-java-poll
|
core/src/main/java/io/grpc/Marshaller.java
|
Java
|
bsd-3-clause
| 2,470
|
BeCool-ElkArte
==============
Created closely with @meetdilip with huge thanks to him!
|
CrimeS/BeCool-ElkArte
|
README.md
|
Markdown
|
bsd-3-clause
| 89
|
from .variables import *
def Cell(node):
# cells must stand on own line
if node.parent.cls not in ("Assign", "Assigns"):
node.auxiliary("cell")
return "{", ",", "}"
def Assign(node):
if node.name == 'varargin':
out = "%(0)s = va_arg(varargin, " + node[0].type + ") ;"
else:
out = "%(0)s.clear() ;"
# append to cell, one by one
for elem in node[1]:
out = out + "\n%(0)s.push_back(" + str(elem) + ") ;"
return out
|
jonathf/matlab2cpp
|
src/matlab2cpp/rules/_cell.py
|
Python
|
bsd-3-clause
| 495
|
#!/bin/bash
# Assumes this script is in a directory one level below the repo's root dir.
TEST_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
GSUTIL_DIR="$TEST_DIR/.."
find "$GSUTIL_DIR" \
-path "$GSUTIL_DIR/gslib/third_party" -prune -o \
-path "$GSUTIL_DIR/gslib/vendored" -prune -o \
-path "$GSUTIL_DIR/third_party" -prune -o \
-name "*.py" -print \
| xargs python -m pylint --rcfile="$TEST_DIR/.pylintrc_limited"
|
endlessm/chromium-browser
|
third_party/catapult/third_party/gsutil/test/run_pylint.sh
|
Shell
|
bsd-3-clause
| 460
|
# -*-coding:Utf-8 -*
# Copyright (c) 2010 LE GOFF Vincent
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# raise of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this raise of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
"""Fichier contenant le paramètre 'border' de la commande 'voile'."""
from primaires.interpreteur.masque.parametre import Parametre
class PrmBorder(Parametre):
"""Commande 'voile border'.
"""
def __init__(self):
"""Constructeur du paramètre"""
Parametre.__init__(self, "border", "haul")
self.schema = "<nombre>"
self.aide_courte = "borde la voile présente"
self.aide_longue = \
"Cette commande permet de border la voile dans la salle où " \
"vous vous trouvez. Plus la voile est bordée, plus elle " \
"est parallèle à l'âxe du navire. La voile doit être plus " \
"ou moins bordée selon l'allure du navire. Si vous voulez " \
"changer d'amure, utilisez la commande %voile% %voile:empanner%."
def ajouter(self):
"""Méthode appelée lors de l'ajout de la commande à l'interpréteur"""
nombre = self.noeud.get_masque("nombre")
nombre.proprietes["limite_sup"] = "90"
def interpreter(self, personnage, dic_masques):
"""Interprétation du paramètre"""
salle = personnage.salle
if not hasattr(salle, "voiles"):
personnage << "|err|Vous n'êtes pas sur un navire.|ff|"
return
voiles = salle.voiles
if not voiles:
personnage << "|err|Vous ne voyez aucune voile ici.|ff|"
return
voile = voiles[0]
if not voile.hissee:
personnage << "|err|Cette voile n'est pas hissée.|ff|"
else:
nombre = dic_masques["nombre"].nombre
if voile.orientation < 0:
voile.orientation += nombre
if voile.orientation > -5:
voile.orientation = -5
personnage << "Vous bordez {}.".format(voile.nom)
personnage.salle.envoyer("{{}} borde {}.".format(
voile.nom), personnage)
elif voile.orientation > 0:
voile.orientation -= nombre
if voile.orientation < 5:
voile.orientation = 5
personnage << "Vous bordez {}.".format(voile.nom)
personnage.salle.envoyer("{{}} borde {}.".format(
voile.nom), personnage)
else:
personnage << "|err|Cette voile ne peut être bordée " \
"davantage.|ff|"
|
stormi/tsunami
|
src/secondaires/navigation/commandes/voile/border.py
|
Python
|
bsd-3-clause
| 4,041
|
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('ReactDOMProduction', () => {
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
var React;
var ReactDOM;
var ReactDOMServer;
var oldProcess;
beforeEach(() => {
__DEV__ = false;
// Mutating process.env.NODE_ENV would cause our babel plugins to do the
// wrong thing. If you change this, make sure to test with jest --no-cache.
oldProcess = process;
global.process = {
...process,
env: {...process.env, NODE_ENV: 'production'},
};
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
ReactDOMServer = require('react-dom/server');
});
afterEach(() => {
__DEV__ = true;
global.process = oldProcess;
});
it('should use prod fbjs', () => {
var warning = require('fbjs/lib/warning');
spyOn(console, 'error');
warning(false, 'Do cows go moo?');
expectDev(console.error.calls.count()).toBe(0);
});
it('should use prod React', () => {
spyOn(console, 'error');
// no key warning
void <div>{[<span />]}</div>;
expectDev(console.error.calls.count()).toBe(0);
});
it('should handle a simple flow', () => {
class Component extends React.Component {
render() {
return <span>{this.props.children}</span>;
}
}
var container = document.createElement('div');
var inst = ReactDOM.render(
<div className="blue" style={{fontFamily: 'Helvetica'}}>
<Component key={1}>A</Component>
<Component key={2}>B</Component>
<Component key={3}>C</Component>
</div>,
container,
);
expect(container.firstChild).toBe(inst);
expect(inst.className).toBe('blue');
expect(inst.style.fontFamily).toBe('Helvetica');
expect(inst.textContent).toBe('ABC');
ReactDOM.render(
<div className="red" style={{fontFamily: 'Comic Sans MS'}}>
<Component key={2}>B</Component>
<Component key={1}>A</Component>
<Component key={3}>C</Component>
</div>,
container,
);
expect(inst.className).toBe('red');
expect(inst.style.fontFamily).toBe('Comic Sans MS');
expect(inst.textContent).toBe('BAC');
ReactDOM.unmountComponentAtNode(container);
expect(container.childNodes.length).toBe(0);
});
it('should handle a simple flow (ssr)', () => {
class Component extends React.Component {
render() {
return <span>{this.props.children}</span>;
}
}
var container = document.createElement('div');
var markup = ReactDOMServer.renderToString(
<div className="blue" style={{fontFamily: 'Helvetica'}}>
<Component key={1}>A</Component>
<Component key={2}>B</Component>
<Component key={3}>C</Component>
</div>,
container,
);
container.innerHTML = markup;
var inst = container.firstChild;
expect(inst.className).toBe('blue');
expect(inst.style.fontFamily).toBe('Helvetica');
expect(inst.textContent).toBe('ABC');
});
it('should call lifecycle methods', () => {
var log = [];
class Component extends React.Component {
state = {y: 1};
shouldComponentUpdate(nextProps, nextState) {
log.push(['shouldComponentUpdate', nextProps, nextState]);
return nextProps.x !== this.props.x || nextState.y !== this.state.y;
}
componentWillMount() {
log.push(['componentWillMount']);
}
componentDidMount() {
log.push(['componentDidMount']);
}
componentWillReceiveProps(nextProps) {
log.push(['componentWillReceiveProps', nextProps]);
}
componentWillUpdate(nextProps, nextState) {
log.push(['componentWillUpdate', nextProps, nextState]);
}
componentDidUpdate(prevProps, prevState) {
log.push(['componentDidUpdate', prevProps, prevState]);
}
componentWillUnmount() {
log.push(['componentWillUnmount']);
}
render() {
log.push(['render']);
return null;
}
}
var container = document.createElement('div');
var inst = ReactDOM.render(<Component x={1} />, container);
expect(log).toEqual([
['componentWillMount'],
['render'],
['componentDidMount'],
]);
log = [];
inst.setState({y: 2});
expect(log).toEqual([
['shouldComponentUpdate', {x: 1}, {y: 2}],
['componentWillUpdate', {x: 1}, {y: 2}],
['render'],
['componentDidUpdate', {x: 1}, {y: 1}],
]);
log = [];
inst.setState({y: 2});
expect(log).toEqual([['shouldComponentUpdate', {x: 1}, {y: 2}]]);
log = [];
ReactDOM.render(<Component x={2} />, container);
expect(log).toEqual([
['componentWillReceiveProps', {x: 2}],
['shouldComponentUpdate', {x: 2}, {y: 2}],
['componentWillUpdate', {x: 2}, {y: 2}],
['render'],
['componentDidUpdate', {x: 1}, {y: 2}],
]);
log = [];
ReactDOM.render(<Component x={2} />, container);
expect(log).toEqual([
['componentWillReceiveProps', {x: 2}],
['shouldComponentUpdate', {x: 2}, {y: 2}],
]);
log = [];
ReactDOM.unmountComponentAtNode(container);
expect(log).toEqual([['componentWillUnmount']]);
});
it('should throw with an error code in production', () => {
expect(function() {
class Component extends React.Component {
render() {
return undefined;
}
}
var container = document.createElement('div');
ReactDOM.render(<Component />, container);
}).toThrowError(
'Minified React error #109; visit ' +
'http://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Component' +
' for the full message or use the non-minified dev environment' +
' for full errors and additional helpful warnings.',
);
});
it('should not crash with devtools installed', () => {
try {
global.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
inject: function() {},
onCommitFiberRoot: function() {},
onCommitFiberUnmount: function() {},
supportsFiber: true,
};
jest.resetModules();
React = require('react');
ReactDOM = require('react-dom');
class Component extends React.Component {
render() {
return <div />;
}
}
ReactDOM.render(<Component />, document.createElement('container'));
} finally {
global.__REACT_DEVTOOLS_GLOBAL_HOOK__ = undefined;
}
});
if (ReactDOMFeatureFlags.useFiber) {
// This test is originally from ReactDOMFiber-test but we replicate it here
// to avoid production-only regressions because of host context differences
// in dev and prod.
it('should keep track of namespace across portals in production', () => {
var svgEls, htmlEls;
var expectSVG = {ref: el => svgEls.push(el)};
var expectHTML = {ref: el => htmlEls.push(el)};
var usePortal = function(tree) {
return ReactDOM.unstable_createPortal(
tree,
document.createElement('div'),
);
};
var assertNamespacesMatch = function(tree) {
var container = document.createElement('div');
svgEls = [];
htmlEls = [];
ReactDOM.render(tree, container);
svgEls.forEach(el => {
expect(el.namespaceURI).toBe('http://www.w3.org/2000/svg');
});
htmlEls.forEach(el => {
expect(el.namespaceURI).toBe('http://www.w3.org/1999/xhtml');
});
ReactDOM.unmountComponentAtNode(container);
expect(container.innerHTML).toBe('');
};
assertNamespacesMatch(
<div {...expectHTML}>
<svg {...expectSVG}>
<foreignObject {...expectSVG}>
<p {...expectHTML} />
{usePortal(
<svg {...expectSVG}>
<image {...expectSVG} />
<svg {...expectSVG}>
<image {...expectSVG} />
<foreignObject {...expectSVG}>
<p {...expectHTML} />
</foreignObject>
{usePortal(<p {...expectHTML} />)}
</svg>
<image {...expectSVG} />
</svg>,
)}
<p {...expectHTML} />
</foreignObject>
<image {...expectSVG} />
</svg>
<p {...expectHTML} />
</div>,
);
});
}
});
|
leexiaosi/react
|
src/renderers/dom/__tests__/ReactDOMProduction-test.js
|
JavaScript
|
bsd-3-clause
| 8,787
|
{% ckan_extends %}
{% block page_primary_action %}
{% if h.check_access('package_create') %}
<div class="page_primary_action">
{% link_for _('Add Dataset'), controller='ckanext.customdataset.controllers.datasettypes:DatasetTypesController',
action='select_dataset_types', class_='btn btn-primary', icon='plus-sign-alt' %}
{# {% link_for _('Add Dataset Original'), controller='package', action='new', class_='btn btn-primary', icon='plus-sign-alt' %} #}
</div>
{% endif %}
{% endblock %}
|
CI-WATER/portal
|
src/ckanext-customdataset/ckanext/customdataset/templates/package/search.html
|
HTML
|
bsd-3-clause
| 539
|
#include "stack.h"
#include <stdlib.h>
#include <stdio.h>
void kw_stack_init(stack *s) {
s->stack = malloc(STACK_DEFAULT_SIZE * sizeof(void*));
s->pos = 0;
s->mlen = STACK_DEFAULT_SIZE;
}
void kw_stack_free(stack *s) {
if(!s) return;
if(!s->stack) return;
free(s->stack);
}
void *kw_stack_grow(stack *s) {
void *junk; // So we don't whack s->stack on failure
s->mlen *= 2; // Double it
junk = realloc(s->stack, sizeof(void *) * s->mlen);
return junk;
}
int kw_push(stack *s, void *item) {
if(!s) {
fprintf(stderr, "Bad stack passed to kw_kw_kw_pop()\n");
return -1;
}
if(!item) return -1;
if(s->pos >= s->mlen && !kw_stack_grow(s)) {
fprintf(stderr, "Realloc failed\n");
return -1;
}
s->stack[s->pos] = item;
return ++s->pos;
}
void *kw_pop(stack *s) {
if(!s) {
fprintf(stderr, "Bad stack passed to kw_pop()\n");
return NULL;
}
if(s->pos > s->mlen) return NULL;
if(s->pos - 1 < 0) return NULL;
return s->stack[--s->pos];
}
void *kw_peek(stack *s, int back) {
if(!s) {
fprintf(stderr, "Bad stack passed to kw_peek()\n");
return NULL;
}
int pos = s->pos - back - 1;
if(pos < 0) {
return NULL;
}
return s->stack[pos];
}
|
thomasluce/YAPWTP
|
src/stack.c
|
C
|
bsd-3-clause
| 1,210
|
/** @file
Support for Graphics output spliter.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "ConSplitter.h"
CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
/**
Returns information for an available graphics mode that the graphics device
and the set of active video output devices supports.
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
@param ModeNumber The mode number to return information on.
@param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.
@param Info A pointer to callee allocated buffer that returns information about ModeNumber.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
@retval EFI_OUT_OF_RESOURCES No resource available.
**/
EFI_STATUS
EFIAPI
ConSplitterGraphicsOutputQueryMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber,
OUT UINTN *SizeOfInfo,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
)
{
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_STATUS Status;
UINTN Index;
if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {
return EFI_INVALID_PARAMETER;
}
//
// retrieve private data
//
Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
GraphicsOutput = NULL;
if (Private->CurrentNumberOfGraphicsOutput == 1) {
//
// Find the only one GraphicsOutput.
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
break;
}
}
}
if (GraphicsOutput != NULL) {
//
// If only one physical GOP device exist, return its information.
//
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) ModeNumber, SizeOfInfo, Info);
return Status;
} else {
//
// If 2 more phyiscal GOP device exist or GOP protocol does not exist,
// return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().
//
*Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (*Info == NULL) {
return EFI_OUT_OF_RESOURCES;
}
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
CopyMem (*Info, &Private->GraphicsOutputModeBuffer[ModeNumber], *SizeOfInfo);
}
return EFI_SUCCESS;
}
/**
Set the video device into the specified mode and clears the visible portions of
the output display to black.
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
@param ModeNumber Abstraction that defines the current video mode.
@retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
@retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
@retval EFI_OUT_OF_RESOURCES No resource available.
**/
EFI_STATUS
EFIAPI
ConSplitterGraphicsOutputSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
IN UINT32 ModeNumber
)
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_GRAPHICS_OUTPUT_PROTOCOL *PhysicalGraphicsOutput;
UINTN NumberIndex;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];
ReturnStatus = EFI_SUCCESS;
GraphicsOutput = NULL;
PhysicalGraphicsOutput = NULL;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
PhysicalGraphicsOutput = GraphicsOutput;
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {
FreePool (Info);
break;
}
FreePool (Info);
}
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
UgaDraw,
Mode->HorizontalResolution,
Mode->VerticalResolution,
32,
60
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
}
This->Mode->Mode = ModeNumber;
if ((Private->CurrentNumberOfGraphicsOutput == 1) && (PhysicalGraphicsOutput != NULL)) {
//
// If only one physical GOP device exist, copy physical information to consplitter.
//
CopyMem (This->Mode->Info, PhysicalGraphicsOutput->Mode->Info, PhysicalGraphicsOutput->Mode->SizeOfInfo);
This->Mode->SizeOfInfo = PhysicalGraphicsOutput->Mode->SizeOfInfo;
This->Mode->FrameBufferBase = PhysicalGraphicsOutput->Mode->FrameBufferBase;
This->Mode->FrameBufferSize = PhysicalGraphicsOutput->Mode->FrameBufferSize;
} else {
//
// If 2 more phyiscal GOP device exist or GOP protocol does not exist,
// return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().
//
CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo);
}
return ReturnStatus;
}
/**
The following table defines actions for BltOperations.
EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiBltVideoToBltBuffer - Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiBltBufferToVideo - Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiBltVideoToVideo - Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
@param This Protocol instance pointer.
@param BltBuffer Buffer containing data to blit into video buffer.
This buffer has a size of
Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
@param BltOperation Operation to perform on BlitBuffer and video
memory
@param SourceX X coordinate of source for the BltBuffer.
@param SourceY Y coordinate of source for the BltBuffer.
@param DestinationX X coordinate of destination for the BltBuffer.
@param DestinationY Y coordinate of destination for the BltBuffer.
@param Width Width of rectangle in BltBuffer in pixels.
@param Height Hight of rectangle in BltBuffer in pixels.
@param Delta OPTIONAL.
@retval EFI_SUCCESS The Blt operation completed.
@retval EFI_INVALID_PARAMETER BltOperation is not valid.
@retval EFI_DEVICE_ERROR A hardware error occured writting to the video
buffer.
**/
EFI_STATUS
EFIAPI
ConSplitterGraphicsOutputBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
{
EFI_STATUS Status;
EFI_STATUS ReturnStatus;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {
return EFI_INVALID_PARAMETER;
}
Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
ReturnStatus = EFI_SUCCESS;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
GraphicsOutput,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiBltVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = UgaDraw->Blt (
UgaDraw,
(EFI_UGA_PIXEL *) BltBuffer,
(EFI_UGA_BLT_OPERATION) BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiBltVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
}
return ReturnStatus;
}
/**
Return the current video mode information.
@param This The EFI_UGA_DRAW_PROTOCOL instance.
@param HorizontalResolution The size of video screen in pixels in the X dimension.
@param VerticalResolution The size of video screen in pixels in the Y dimension.
@param ColorDepth Number of bits per pixel, currently defined to be 32.
@param RefreshRate The refresh rate of the monitor in Hertz.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_INVALID_PARAMETER One of the input args was NULL.
**/
EFI_STATUS
EFIAPI
ConSplitterUgaDrawGetMode (
IN EFI_UGA_DRAW_PROTOCOL *This,
OUT UINT32 *HorizontalResolution,
OUT UINT32 *VerticalResolution,
OUT UINT32 *ColorDepth,
OUT UINT32 *RefreshRate
)
{
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
if ((HorizontalResolution == NULL) ||
(VerticalResolution == NULL) ||
(RefreshRate == NULL) ||
(ColorDepth == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// retrieve private data
//
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
*HorizontalResolution = Private->UgaHorizontalResolution;
*VerticalResolution = Private->UgaVerticalResolution;
*ColorDepth = Private->UgaColorDepth;
*RefreshRate = Private->UgaRefreshRate;
return EFI_SUCCESS;
}
/**
Set the current video mode information.
@param This The EFI_UGA_DRAW_PROTOCOL instance.
@param HorizontalResolution The size of video screen in pixels in the X dimension.
@param VerticalResolution The size of video screen in pixels in the Y dimension.
@param ColorDepth Number of bits per pixel, currently defined to be 32.
@param RefreshRate The refresh rate of the monitor in Hertz.
@retval EFI_SUCCESS Mode information returned.
@retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
@retval EFI_OUT_OF_RESOURCES Out of resources.
**/
EFI_STATUS
EFIAPI
ConSplitterUgaDrawSetMode (
IN EFI_UGA_DRAW_PROTOCOL *This,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
)
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
UINTN NumberIndex;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
EFI_UGA_DRAW_PROTOCOL *UgaDraw;
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
ReturnStatus = EFI_SUCCESS;
//
// Update the Mode data
//
Private->UgaHorizontalResolution = HorizontalResolution;
Private->UgaVerticalResolution = VerticalResolution;
Private->UgaColorDepth = ColorDepth;
Private->UgaRefreshRate = RefreshRate;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
//
// Find corresponding ModeNumber of this GraphicsOutput instance
//
for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {
Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);
if (EFI_ERROR (Status)) {
return Status;
}
if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
FreePool (Info);
break;
}
FreePool (Info);
}
Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)){
UgaDraw = Private->TextOutList[Index].UgaDraw;
if (UgaDraw != NULL) {
Status = UgaDraw->SetMode (
UgaDraw,
HorizontalResolution,
VerticalResolution,
ColorDepth,
RefreshRate
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
}
}
}
return ReturnStatus;
}
/**
Blt a rectangle of pixels on the graphics screen.
The following table defines actions for BltOperations.
EfiUgaVideoFill:
Write data from the BltBuffer pixel (SourceX, SourceY)
directly to every pixel of the video display rectangle
(DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
Only one pixel will be used from the BltBuffer. Delta is NOT used.
EfiUgaVideoToBltBuffer:
Read data from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
the BltBuffer rectangle (DestinationX, DestinationY )
(DestinationX + Width, DestinationY + Height). If DestinationX or
DestinationY is not zero then Delta must be set to the length in bytes
of a row in the BltBuffer.
EfiUgaBltBufferToVideo:
Write data from the BltBuffer rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
not zero then Delta must be set to the length in bytes of a row in the
BltBuffer.
EfiUgaVideoToVideo:
Copy from the video display rectangle
(SourceX, SourceY) (SourceX + Width, SourceY + Height) .
to the video display rectangle (DestinationX, DestinationY)
(DestinationX + Width, DestinationY + Height).
The BltBuffer and Delta are not used in this mode.
@param This Protocol instance pointer.
@param BltBuffer Buffer containing data to blit into video buffer. This
buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
@param BltOperation Operation to perform on BlitBuffer and video memory
@param SourceX X coordinate of source for the BltBuffer.
@param SourceY Y coordinate of source for the BltBuffer.
@param DestinationX X coordinate of destination for the BltBuffer.
@param DestinationY Y coordinate of destination for the BltBuffer.
@param Width Width of rectangle in BltBuffer in pixels.
@param Height Hight of rectangle in BltBuffer in pixels.
@param Delta OPTIONAL
@retval EFI_SUCCESS The Blt operation completed.
@retval EFI_INVALID_PARAMETER BltOperation is not valid.
@retval EFI_DEVICE_ERROR A hardware error occured writting to the video buffer.
**/
EFI_STATUS
EFIAPI
ConSplitterUgaDrawBlt (
IN EFI_UGA_DRAW_PROTOCOL *This,
IN EFI_UGA_PIXEL *BltBuffer, OPTIONAL
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
{
EFI_STATUS Status;
TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS ReturnStatus;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
ReturnStatus = EFI_SUCCESS;
//
// return the worst status met
//
for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
GraphicsOutput,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltBuffer,
(EFI_GRAPHICS_OUTPUT_BLT_OPERATION) BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiUgaVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
if (Private->TextOutList[Index].UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = Private->TextOutList[Index].UgaDraw->Blt (
Private->TextOutList[Index].UgaDraw,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
if (EFI_ERROR (Status)) {
ReturnStatus = Status;
} else if (BltOperation == EfiUgaVideoToBltBuffer) {
//
// Only need to read the data into buffer one time
//
return EFI_SUCCESS;
}
}
}
return ReturnStatus;
}
/**
Sets the output device(s) to a specified mode.
@param Private Text Out Splitter pointer.
@param ModeNumber The mode number to set.
**/
VOID
TextOutSetMode (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
IN UINTN ModeNumber
)
{
//
// No need to do extra check here as whether (Column, Row) is valid has
// been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
// always be supported.
//
Private->TextOutMode.Mode = (INT32) ModeNumber;
Private->TextOutMode.CursorColumn = 0;
Private->TextOutMode.CursorRow = 0;
Private->TextOutMode.CursorVisible = TRUE;
return;
}
|
intel/ipmctl
|
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c
|
C
|
bsd-3-clause
| 23,928
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link href="https://fonts.gstatic.com/" rel="preconnect" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700|Roboto:300,400,400i,700&display=fallback" rel="stylesheet">
<style>
body,
input {
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif
}
code,
kbd,
pre {
font-family: "Roboto Mono", "Courier New", Courier, monospace
}
</style>
<link rel="stylesheet" href="../_static/stylesheets/application.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-palette.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-fixes.css"/>
<link rel="stylesheet" href="../_static/fonts/material-icons.css"/>
<meta name="theme-color" content="#3f51b5">
<script src="../_static/javascripts/modernizr.js"></script>
<title>statsmodels.tsa.holtwinters.HoltWintersResults.slope — statsmodels</title>
<link rel="icon" type="image/png" sizes="32x32" href="../_static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../_static/icons/favicon-16x16.png">
<link rel="manifest" href="../_static/icons/site.webmanifest">
<link rel="mask-icon" href="../_static/icons/safari-pinned-tab.svg" color="#919191">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="../_static/icons/browserconfig.xml">
<link rel="stylesheet" href="../_static/stylesheets/examples.css">
<link rel="stylesheet" href="../_static/stylesheets/deprecation.css">
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/material.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="statsmodels.tsa.holtwinters.HoltWintersResults.sse" href="statsmodels.tsa.holtwinters.HoltWintersResults.sse.html" />
<link rel="prev" title="statsmodels.tsa.holtwinters.HoltWintersResults.season" href="statsmodels.tsa.holtwinters.HoltWintersResults.season.html" />
</head>
<body dir=ltr
data-md-color-primary=indigo data-md-color-accent=blue>
<svg class="md-svg">
<defs data-children-count="0">
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#generated/statsmodels.tsa.holtwinters.HoltWintersResults.slope" tabindex="1" class="md-skip"> Skip to content </a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex navheader">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../index.html" title="statsmodels"
class="md-header-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" height="26"
alt="statsmodels logo">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">statsmodels v0.12.2</span>
<span class="md-header-nav__topic"> statsmodels.tsa.holtwinters.HoltWintersResults.slope </span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" action="../search.html" method="GET" name="search">
<input type="text" class="md-search__input" name="q" placeholder="Search"
autocapitalize="off" autocomplete="off" spellcheck="false"
data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">

</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
</div>
<script src="../_static/javascripts/version_dropdown.js"></script>
<script>
var json_loc = "../_static/versions.json",
target_loc = "../../",
text = "Versions";
$( document ).ready( add_version_dropdown(json_loc, target_loc, text));
</script>
</div>
</nav>
</header>
<div class="md-container">
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item"><a href="../user-guide.html" class="md-tabs__link">User Guide</a></li>
<li class="md-tabs__item"><a href="../tsa.html" class="md-tabs__link">Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a></li>
<li class="md-tabs__item"><a href="statsmodels.tsa.holtwinters.HoltWintersResults.html" class="md-tabs__link">statsmodels.tsa.holtwinters.HoltWintersResults</a></li>
</ul>
</div>
</nav>
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="../index.html" title="statsmodels" class="md-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" alt=" logo" width="48" height="48">
</a>
<a href="../index.html"
title="statsmodels">statsmodels v0.12.2</a>
</label>
<div class="md-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../install.html" class="md-nav__link">Installing statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../gettingstarted.html" class="md-nav__link">Getting started</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html" class="md-nav__link">User Guide</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../user-guide.html#background" class="md-nav__link">Background</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#regression-and-linear-models" class="md-nav__link">Regression and Linear Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#time-series-analysis" class="md-nav__link">Time Series Analysis</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../tsa.html" class="md-nav__link">Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a>
</li>
<li class="md-nav__item">
<a href="../statespace.html" class="md-nav__link">Time Series Analysis by State Space Methods <code class="xref py py-mod docutils literal notranslate"><span class="pre">statespace</span></code></a>
</li>
<li class="md-nav__item">
<a href="../vector_ar.html" class="md-nav__link">Vector Autoregressions <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa.vector_ar</span></code></a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#other-models" class="md-nav__link">Other Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#statistics-and-tools" class="md-nav__link">Statistics and Tools</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#data-sets" class="md-nav__link">Data Sets</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#sandbox" class="md-nav__link">Sandbox</a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../examples/index.html" class="md-nav__link">Examples</a>
</li>
<li class="md-nav__item">
<a href="../api.html" class="md-nav__link">API Reference</a>
</li>
<li class="md-nav__item">
<a href="../about.html" class="md-nav__link">About statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../dev/index.html" class="md-nav__link">Developer Page</a>
</li>
<li class="md-nav__item">
<a href="../release/index.html" class="md-nav__link">Release Notes</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item"><a class="md-nav__extra_link" href="../_sources/generated/statsmodels.tsa.holtwinters.HoltWintersResults.slope.rst.txt">Show Source</a> </li>
<li id="searchbox" class="md-nav__item"></li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset" role="main">
<h1 id="generated-statsmodels-tsa-holtwinters-holtwintersresults-slope--page-root">statsmodels.tsa.holtwinters.HoltWintersResults.slope<a class="headerlink" href="#generated-statsmodels-tsa-holtwinters-holtwintersresults-slope--page-root" title="Permalink to this headline">¶</a></h1>
<dl class="py method">
<dt id="statsmodels.tsa.holtwinters.HoltWintersResults.slope">
<em class="property">property </em><code class="sig-prename descclassname">HoltWintersResults.</code><code class="sig-name descname">slope</code><a class="headerlink" href="#statsmodels.tsa.holtwinters.HoltWintersResults.slope" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of the slope values that make up the fitted values.</p>
<div class="deprecated">
<p><span class="versionmodified deprecated">Deprecated since version 0.12: </span>Use the trend property instead.</p>
</div>
</dd></dl>
</article>
</div>
</div>
</main>
</div>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="statsmodels.tsa.holtwinters.HoltWintersResults.season.html" title="statsmodels.tsa.holtwinters.HoltWintersResults.season"
class="md-flex md-footer-nav__link md-footer-nav__link--prev"
rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span
class="md-footer-nav__direction"> Previous </span> statsmodels.tsa.holtwinters.HoltWintersResults.season </span>
</div>
</a>
<a href="statsmodels.tsa.holtwinters.HoltWintersResults.sse.html" title="statsmodels.tsa.holtwinters.HoltWintersResults.sse"
class="md-flex md-footer-nav__link md-footer-nav__link--next"
rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"><span
class="md-flex__ellipsis"> <span
class="md-footer-nav__direction"> Next </span> statsmodels.tsa.holtwinters.HoltWintersResults.sse </span>
</div>
<div class="md-flex__cell md-flex__cell--shrink"><i
class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
© Copyright 2009-2019, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers.
</div>
Last updated on
Feb 02, 2021.
<br/>
Created using
<a href="http://www.sphinx-doc.org/">Sphinx</a> 3.4.3.
and
<a href="https://github.com/bashtage/sphinx-material/">Material for
Sphinx</a>
</div>
</div>
</div>
</footer>
<script src="../_static/javascripts/application.js"></script>
<script>app.initialize({version: "1.0.4", url: {base: ".."}})</script>
</body>
</html>
|
statsmodels/statsmodels.github.io
|
v0.12.2/generated/statsmodels.tsa.holtwinters.HoltWintersResults.slope.html
|
HTML
|
bsd-3-clause
| 17,862
|
package Bio::WGS2NCBI::MrnaFeature;
use Bio::WGS2NCBI::Logger;
use Bio::WGS2NCBI::StrandedFeature;
use base 'Bio::WGS2NCBI::StrandedFeature';
=head1 NAME
Bio::WGS2NCBI::MrnaFeature - mRNA feature
=head1 DESCRIPTION
Objects of this class represent an mRNA feature for a gene.
=head1 SEE ALSO
L<Bio::WGS2NCBI::StrandedFeature>
=head1 METHODS
=over
=item new()
Returns a new mRNA feature. Requires the arguments 'product', 'protein_id' and
'transcript_id', for example:
my $mrna = Bio::WGS2NCBI::MrnaFeature->new(
product => $product,
protein_id => $protein_id,
transcript_id => $transcript_id,
);
=cut
sub new {
my $class = shift;
my %args = @_;
if ( not $args{'product'} or not $args{'protein_id'} or not $args{'transcript_id'} ) {
DEBUG "need product, protein_id and transcript_id, product_id";
}
$class->SUPER::new(%args);
}
=item qualifiers()
Returns the feature qualifiers for mRNA features, i.e. 'product', 'protein_id' and
'transcript_id'
=cut
sub qualifiers { qw(product protein_id transcript_id) }
sub product {
my $self = shift;
$self->{'product'} = shift if @_;
return $self->{'product'};
}
sub protein_id {
my $self = shift;
$self->{'protein_id'} = shift if @_;
return $self->{'protein_id'};
}
sub transcript_id {
my $self = shift;
$self->{'transcript_id'} = shift if @_;
return $self->{'transcript_id'};
}
=back
=cut
1;
|
naturalis/wgs2ncbi
|
lib/Bio/WGS2NCBI/MrnaFeature.pm
|
Perl
|
bsd-3-clause
| 1,414
|
<?php
use yii\db\Migration;
class m161012_160910_tweet_date extends Migration
{
public function safeUp()
{
$this->addColumn('{{%tweets}}', 'create_at', $this->timestamp());
}
public function safeDown()
{
$this->dropColumn('{{%tweets}}', 'create_at');
}
}
|
lutersergei/YII2
|
console/migrations/m161012_160910_tweet_date.php
|
PHP
|
bsd-3-clause
| 298
|
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_FEATURES_IMPL_FEATURE_H_
#define PCL_FEATURES_IMPL_FEATURE_H_
#include <pcl/search/pcl_search.h>
//////////////////////////////////////////////////////////////////////////////////////////////
inline void
pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
const Eigen::Vector4f &point,
Eigen::Vector4f &plane_parameters, float &curvature)
{
solvePlaneParameters (covariance_matrix, plane_parameters [0], plane_parameters [1], plane_parameters [2], curvature);
plane_parameters[3] = 0;
// Hessian form (D = nc . p_plane (centroid here) + p)
plane_parameters[3] = -1 * plane_parameters.dot (point);
}
//////////////////////////////////////////////////////////////////////////////////////////////
inline void
pcl::solvePlaneParameters (const Eigen::Matrix3f &covariance_matrix,
float &nx, float &ny, float &nz, float &curvature)
{
// Avoid getting hung on Eigen's optimizers
// for (int i = 0; i < 9; ++i)
// if (!std::isfinite (covariance_matrix.coeff (i)))
// {
// //PCL_WARN ("[pcl::solvePlaneParameteres] Covariance matrix has NaN/Inf values!\n");
// nx = ny = nz = curvature = std::numeric_limits<float>::quiet_NaN ();
// return;
// }
// Extract the smallest eigenvalue and its eigenvector
EIGEN_ALIGN16 Eigen::Vector3f::Scalar eigen_value;
EIGEN_ALIGN16 Eigen::Vector3f eigen_vector;
pcl::eigen33 (covariance_matrix, eigen_value, eigen_vector);
nx = eigen_vector [0];
ny = eigen_vector [1];
nz = eigen_vector [2];
// Compute the curvature surface change
float eig_sum = covariance_matrix.coeff (0) + covariance_matrix.coeff (4) + covariance_matrix.coeff (8);
if (eig_sum != 0)
curvature = fabsf (eigen_value / eig_sum);
else
curvature = 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointOutT> bool
pcl::Feature<PointInT, PointOutT>::initCompute ()
{
if (!PCLBase<PointInT>::initCompute ())
{
PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
return (false);
}
// If the dataset is empty, just return
if (input_->points.empty ())
{
PCL_ERROR ("[pcl::%s::compute] input_ is empty!\n", getClassName ().c_str ());
// Cleanup
deinitCompute ();
return (false);
}
// If no search surface has been defined, use the input dataset as the search surface itself
if (!surface_)
{
fake_surface_ = true;
surface_ = input_;
}
// Check if a space search locator was given
if (!tree_)
{
if (surface_->isOrganized () && input_->isOrganized ())
tree_.reset (new pcl::search::OrganizedNeighbor<PointInT> ());
else
tree_.reset (new pcl::search::KdTree<PointInT> (false));
}
if (tree_->getInputCloud () != surface_) // Make sure the tree searches the surface
tree_->setInputCloud (surface_);
// Do a fast check to see if the search parameters are well defined
if (search_radius_ != 0.0)
{
if (k_ != 0)
{
PCL_ERROR ("[pcl::%s::compute] ", getClassName ().c_str ());
PCL_ERROR ("Both radius (%f) and K (%d) defined! ", search_radius_, k_);
PCL_ERROR ("Set one of them to zero first and then re-run compute ().\n");
// Cleanup
deinitCompute ();
return (false);
}
else // Use the radiusSearch () function
{
search_parameter_ = search_radius_;
// Declare the search locator definition
search_method_surface_ = [this] (const PointCloudIn &cloud, int index, double radius,
std::vector<int> &k_indices, std::vector<float> &k_distances)
{
return tree_->radiusSearch (cloud, index, radius, k_indices, k_distances, 0);
};
}
}
else
{
if (k_ != 0) // Use the nearestKSearch () function
{
search_parameter_ = k_;
// Declare the search locator definition
search_method_surface_ = [this] (const PointCloudIn &cloud, int index, int k, std::vector<int> &k_indices,
std::vector<float> &k_distances)
{
return tree_->nearestKSearch (cloud, index, k, k_indices, k_distances);
};
}
else
{
PCL_ERROR ("[pcl::%s::compute] Neither radius nor K defined! ", getClassName ().c_str ());
PCL_ERROR ("Set one of them to a positive number first and then re-run compute ().\n");
// Cleanup
deinitCompute ();
return (false);
}
}
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointOutT> bool
pcl::Feature<PointInT, PointOutT>::deinitCompute ()
{
// Reset the surface
if (fake_surface_)
{
surface_.reset ();
fake_surface_ = false;
}
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointOutT> void
pcl::Feature<PointInT, PointOutT>::compute (PointCloudOut &output)
{
if (!initCompute ())
{
output.width = output.height = 0;
output.points.clear ();
return;
}
// Copy the header
output.header = input_->header;
// Resize the output dataset
if (output.points.size () != indices_->size ())
output.points.resize (indices_->size ());
// Check if the output will be computed for all points or only a subset
// If the input width or height are not set, set output width as size
if (indices_->size () != input_->points.size () || input_->width * input_->height == 0)
{
output.width = static_cast<uint32_t> (indices_->size ());
output.height = 1;
}
else
{
output.width = input_->width;
output.height = input_->height;
}
output.is_dense = input_->is_dense;
// Perform the actual feature computation
computeFeature (output);
deinitCompute ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointNT, typename PointOutT> bool
pcl::FeatureFromNormals<PointInT, PointNT, PointOutT>::initCompute ()
{
if (!Feature<PointInT, PointOutT>::initCompute ())
{
PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
return (false);
}
// Check if input normals are set
if (!normals_)
{
PCL_ERROR ("[pcl::%s::initCompute] No input dataset containing normals was given!\n", getClassName ().c_str ());
Feature<PointInT, PointOutT>::deinitCompute ();
return (false);
}
// Check if the size of normals is the same as the size of the surface
if (normals_->points.size () != surface_->points.size ())
{
PCL_ERROR ("[pcl::%s::initCompute] ", getClassName ().c_str ());
PCL_ERROR ("The number of points in the input dataset (%u) differs from ", surface_->points.size ());
PCL_ERROR ("the number of points in the dataset containing the normals (%u)!\n", normals_->points.size ());
Feature<PointInT, PointOutT>::deinitCompute ();
return (false);
}
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointLT, typename PointOutT> bool
pcl::FeatureFromLabels<PointInT, PointLT, PointOutT>::initCompute ()
{
if (!Feature<PointInT, PointOutT>::initCompute ())
{
PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ());
return (false);
}
// Check if input normals are set
if (!labels_)
{
PCL_ERROR ("[pcl::%s::initCompute] No input dataset containing labels was given!\n", getClassName ().c_str ());
Feature<PointInT, PointOutT>::deinitCompute ();
return (false);
}
// Check if the size of normals is the same as the size of the surface
if (labels_->points.size () != surface_->points.size ())
{
PCL_ERROR ("[pcl::%s::initCompute] The number of points in the input dataset differs from the number of points in the dataset containing the labels!\n", getClassName ().c_str ());
Feature<PointInT, PointOutT>::deinitCompute ();
return (false);
}
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointInT, typename PointRFT> bool
pcl::FeatureWithLocalReferenceFrames<PointInT, PointRFT>::initLocalReferenceFrames (const size_t& indices_size,
const LRFEstimationPtr& lrf_estimation)
{
if (frames_never_defined_)
frames_.reset ();
// Check if input frames are set
if (!frames_)
{
if (!lrf_estimation)
{
PCL_ERROR ("[initLocalReferenceFrames] No input dataset containing reference frames was given!\n");
return (false);
} else
{
//PCL_WARN ("[initLocalReferenceFrames] No input dataset containing reference frames was given! Proceed using default\n");
PointCloudLRFPtr default_frames (new PointCloudLRF());
lrf_estimation->compute (*default_frames);
frames_ = default_frames;
}
}
// Check if the size of frames is the same as the size of the input cloud
if (frames_->points.size () != indices_size)
{
if (!lrf_estimation)
{
PCL_ERROR ("[initLocalReferenceFrames] The number of points in the input dataset differs from the number of points in the dataset containing the reference frames!\n");
return (false);
} else
{
//PCL_WARN ("[initLocalReferenceFrames] The number of points in the input dataset differs from the number of points in the dataset containing the reference frames! Proceed using default\n");
PointCloudLRFPtr default_frames (new PointCloudLRF());
lrf_estimation->compute (*default_frames);
frames_ = default_frames;
}
}
return (true);
}
#endif //#ifndef PCL_FEATURES_IMPL_FEATURE_H_
|
drmateo/pcl
|
features/include/pcl/features/impl/feature.hpp
|
C++
|
bsd-3-clause
| 12,501
|
from corehq.apps.reports.models import HQToggle
from corehq.apps.reports.fields import ReportField
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_noop
class SubmitToggle(HQToggle):
def __init__(self, type, show, name, doc_type):
super(SubmitToggle, self).__init__(type, show, name)
self.doc_type = doc_type
class SubmissionErrorType(object):
# This is largely modeled off how the user filter works
SUCCESS = 0
PARTIAL_SUCCESS = 1
DUPLICATE = 2
OVERWRITTEN = 3
UNKNOWN_ERROR = 4
ARCHIVED = 5
doc_types = ["XFormInstance", "XFormError", "XFormDuplicate", "XFormDeprecated", "SubmissionErrorLog", "XFormArchived"]
human_readable = [ugettext_noop("Normal Form"),
ugettext_noop("Form with Errors"),
ugettext_noop("Duplicate Form"),
ugettext_noop("Overwritten Form"),
ugettext_noop("Generic Error"),
ugettext_noop("Archived Form")]
error_defaults = [False, True, False, False, True, False]
success_defaults = [True, False, False, False, False, False]
@classmethod
def display_name_by_doc_type(cls, doc_type):
return cls.display_name_by_index(cls.doc_types.index(doc_type))
@classmethod
def display_name_by_index(cls, index):
return cls.human_readable[index]
@classmethod
def doc_type_by_index(cls, index):
return cls.doc_types[index]
@classmethod
def use_error_defaults(cls):
return [SubmitToggle(i, cls.error_defaults[i], name, cls.doc_types[i]) for i, name in enumerate(cls.human_readable)]
@classmethod
def use_success_defaults(cls):
return [SubmitToggle(i, cls.success_defaults[i], name, cls.doc_types[i]) for i, name in enumerate(cls.human_readable)]
@classmethod
def use_filter(cls, filter):
return [SubmitToggle(i, unicode(i) in filter, name, cls.doc_types[i]) for i, name in enumerate(cls.human_readable)]
class SubmissionTypeField(ReportField):
slug = "submitfilter"
template = "reports/fields/submit_error_types.html"
def update_context(self):
self.context['submission_types'] = self.get_filter_toggle(self.request)
@classmethod
def get_filter_toggle(cls, request):
filter = None
try:
if request.GET.get(cls.slug, ''):
filter = request.GET.getlist(cls.slug)
except KeyError:
pass
if filter:
return SubmissionErrorType.use_filter(filter)
else:
return SubmissionErrorType.use_error_defaults()
|
gmimano/commcaretest
|
corehq/apps/receiverwrapper/fields.py
|
Python
|
bsd-3-clause
| 2,703
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin="">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono:400,500,700&display=fallback">
<style>
body,
input {
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif
}
code,
kbd,
pre {
font-family: "Roboto Mono", "Courier New", Courier, monospace
}
</style>
<link rel="stylesheet" href="../_static/stylesheets/application.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-palette.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-fixes.css"/>
<link rel="stylesheet" href="../_static/fonts/material-icons.css"/>
<meta name="theme-color" content="#3f51b5">
<script src="../_static/javascripts/modernizr.js"></script>
<title>statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix — statsmodels</title>
<link rel="icon" type="image/png" sizes="32x32" href="../_static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../_static/icons/favicon-16x16.png">
<link rel="manifest" href="../_static/icons/site.webmanifest">
<link rel="mask-icon" href="../_static/icons/safari-pinned-tab.svg" color="#919191">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="../_static/icons/browserconfig.xml">
<link rel="stylesheet" href="../_static/stylesheets/examples.css">
<link rel="stylesheet" href="../_static/material.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/language_data.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="statsmodels.tsa.statespace.varmax.VARMAX.predict" href="statsmodels.tsa.statespace.varmax.VARMAX.predict.html" />
<link rel="prev" title="statsmodels.tsa.statespace.varmax.VARMAX.observed_information_matrix" href="statsmodels.tsa.statespace.varmax.VARMAX.observed_information_matrix.html" />
<script src="../_static/javascripts/version_dropdown.js"></script>
<script>
var json_loc = "../_static/versions.json",
target_loc = "../../",
text = "Versions";
$( document ).ready( add_version_dropdown(json_loc, target_loc, text));
</script>
</head>
<body dir=ltr
data-md-color-primary=indigo data-md-color-accent=blue>
<svg class="md-svg">
<defs data-children-count="0">
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#generated/statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix" tabindex="1" class="md-skip"> Skip to content </a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex navheader">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../index.html" title="statsmodels"
class="md-header-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" height="26"
alt="statsmodels logo">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">statsmodels 0.11.0</span>
<span class="md-header-nav__topic"> statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix </span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" action="../search.html" method="GET" name="search">
<input type="text" class="md-search__input" name="q" placeholder="Search"
autocapitalize="off" autocomplete="off" spellcheck="false"
data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">

</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item"><a href="../user-guide.html" class="md-tabs__link">User Guide</a></li>
<li class="md-tabs__item"><a href="../statespace.html" class="md-tabs__link">Time Series Analysis by State Space Methods <code class="xref py py-mod docutils literal notranslate"><span class="pre">statespace</span></code></a></li>
<li class="md-tabs__item"><a href="statsmodels.tsa.statespace.varmax.VARMAX.html" class="md-tabs__link">statsmodels.tsa.statespace.varmax.VARMAX</a></li>
</ul>
</div>
</nav>
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="../index.html" title="statsmodels" class="md-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" alt=" logo" width="48" height="48">
</a>
<a href="../index.html"
title="statsmodels">statsmodels 0.11.0</a>
</label>
<div class="md-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../install.html" class="md-nav__link">Installing statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../gettingstarted.html" class="md-nav__link">Getting started</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html" class="md-nav__link">User Guide</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../user-guide.html#background" class="md-nav__link">Background</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#regression-and-linear-models" class="md-nav__link">Regression and Linear Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#time-series-analysis" class="md-nav__link">Time Series Analysis</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../tsa.html" class="md-nav__link">Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a>
</li>
<li class="md-nav__item">
<a href="../statespace.html" class="md-nav__link">Time Series Analysis by State Space Methods <code class="xref py py-mod docutils literal notranslate"><span class="pre">statespace</span></code></a>
</li>
<li class="md-nav__item">
<a href="../vector_ar.html" class="md-nav__link">Vector Autoregressions <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa.vector_ar</span></code></a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#other-models" class="md-nav__link">Other Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#statistics-and-tools" class="md-nav__link">Statistics and Tools</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#data-sets" class="md-nav__link">Data Sets</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#sandbox" class="md-nav__link">Sandbox</a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../examples/index.html" class="md-nav__link">Examples</a>
</li>
<li class="md-nav__item">
<a href="../api.html" class="md-nav__link">API Reference</a>
</li>
<li class="md-nav__item">
<a href="../about.html" class="md-nav__link">About statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../dev/index.html" class="md-nav__link">Developer Page</a>
</li>
<li class="md-nav__item">
<a href="../release/index.html" class="md-nav__link">Release Notes</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item"><a class="md-nav__extra_link" href="../_sources/generated/statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix.rst.txt">Show Source</a> </li>
<li id="searchbox" class="md-nav__item"></li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset" role="main">
<h1 id="generated-statsmodels-tsa-statespace-varmax-varmax-opg-information-matrix--page-root">statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix<a class="headerlink" href="#generated-statsmodels-tsa-statespace-varmax-varmax-opg-information-matrix--page-root" title="Permalink to this headline">¶</a></h1>
<dl class="method">
<dt id="statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix">
<code class="sig-prename descclassname">VARMAX.</code><code class="sig-name descname">opg_information_matrix</code><span class="sig-paren">(</span><em class="sig-param">params</em>, <em class="sig-param">transformed=True</em>, <em class="sig-param">includes_fixed=False</em>, <em class="sig-param">approx_complex_step=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Outer product of gradients information matrix</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>params</strong><span class="classifier"><a class="reference external" href="https://docs.scipy.org/doc/numpy/glossary.html#term-array-like" title="(in NumPy v1.17)"><span>array_like</span></a>, <code class="xref py py-obj docutils literal notranslate"><span class="pre">optional</span></code></span></dt><dd><p>Array of parameters at which to evaluate the loglikelihood
function.</p>
</dd>
<dt><strong>**kwargs</strong></dt><dd><p>Additional arguments to the <cite>loglikeobs</cite> method.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">References</p>
<p>Berndt, Ernst R., Bronwyn Hall, Robert Hall, and Jerry Hausman. 1974.
Estimation and Inference in Nonlinear Structural Models.
NBER Chapters. National Bureau of Economic Research, Inc.</p>
</dd></dl>
</article>
</div>
</div>
</main>
</div>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="statsmodels.tsa.statespace.varmax.VARMAX.observed_information_matrix.html" title="Material"
class="md-flex md-footer-nav__link md-footer-nav__link--prev"
rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span
class="md-footer-nav__direction"> Previous </span> statsmodels.tsa.statespace.varmax.VARMAX.observed_information_matrix </span>
</div>
</a>
<a href="statsmodels.tsa.statespace.varmax.VARMAX.predict.html" title="Admonition"
class="md-flex md-footer-nav__link md-footer-nav__link--next"
rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"><span
class="md-flex__ellipsis"> <span
class="md-footer-nav__direction"> Next </span> statsmodels.tsa.statespace.varmax.VARMAX.predict </span>
</div>
<div class="md-flex__cell md-flex__cell--shrink"><i
class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
© Copyright 2009-2019, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers.
</div>
Last updated on
Jan 22, 2020.
<br/>
Created using
<a href="http://sphinx-doc.org/">Sphinx</a> 2.3.1.
and
<a href="https://github.com/bashtage/sphinx-material/">Material for
Sphinx</a>
</div>
</div>
</div>
</footer>
<script src="../_static/javascripts/application.js"></script>
<script>app.initialize({version: "1.0.4", url: {base: ".."}})</script>
</body>
</html>
|
statsmodels/statsmodels.github.io
|
v0.11.0/generated/statsmodels.tsa.statespace.varmax.VARMAX.opg_information_matrix.html
|
HTML
|
bsd-3-clause
| 18,807
|
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model app\models\PopulacMapuser */
$this->title = Yii::t('app', '新增账号');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', '账号管理'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->registerJs("$('#populacmapuser-mapuser').on('keyup', function() {
if($(this).val()) {
$('#populacmapuser-nickname').val($(this).val());
}
});");
?>
<div class="populac-mapuser-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
|
tqsq2005/learnYii2
|
views/mapuser/create.php
|
PHP
|
bsd-3-clause
| 631
|
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blis.h"
#define FUNCPTR_T axpyv_fp
typedef void (*FUNCPTR_T)(
conj_t conjx,
dim_t n,
void* alpha,
void* x, inc_t incx,
void* y, inc_t incy
);
// If some mixed datatype functions will not be compiled, we initialize
// the corresponding elements of the function array to NULL.
#ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
static FUNCPTR_T GENARRAY3_ALL(ftypes,axpyv_kernel_void);
#else
#ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
static FUNCPTR_T GENARRAY3_EXT(ftypes,axpyv_kernel_void);
#else
static FUNCPTR_T GENARRAY3_MIN(ftypes,axpyv_kernel_void);
#endif
#endif
void bli_axpyv_kernel( obj_t* alpha,
obj_t* x,
obj_t* y )
{
num_t dt_x = bli_obj_datatype( *x );
num_t dt_y = bli_obj_datatype( *y );
conj_t conjx = bli_obj_conj_status( *x );
dim_t n = bli_obj_vector_dim( *x );
inc_t inc_x = bli_obj_vector_inc( *x );
void* buf_x = bli_obj_buffer_at_off( *x );
inc_t inc_y = bli_obj_vector_inc( *y );
void* buf_y = bli_obj_buffer_at_off( *y );
num_t dt_alpha;
void* buf_alpha;
FUNCPTR_T f;
// If alpha is a scalar constant, use dt_x to extract the address of the
// corresponding constant value; otherwise, use the datatype encoded
// within the alpha object and extract the buffer at the alpha offset.
bli_set_scalar_dt_buffer( alpha, dt_x, dt_alpha, buf_alpha );
// Index into the type combination array to extract the correct
// function pointer.
f = ftypes[dt_alpha][dt_x][dt_y];
// Invoke the function.
f( conjx,
n,
buf_alpha,
buf_x, inc_x,
buf_y, inc_y );
}
#undef GENTFUNC3
#define GENTFUNC3( ctype_a, ctype_x, ctype_y, cha, chx, chy, varname, kername ) \
\
void PASTEMAC3(cha,chx,chy,varname)( \
conj_t conjx, \
dim_t n, \
void* alpha, \
void* x, inc_t incx, \
void* y, inc_t incy \
) \
{ \
PASTEMAC3(cha,chx,chy,kername)( conjx, \
n, \
alpha, \
x, incx, \
y, incy ); \
}
// Define the basic set of functions unconditionally, and then also some
// mixed datatype functions if requested.
INSERT_GENTFUNC3_BASIC( axpyv_kernel_void, AXPYV_KERNEL )
#ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
INSERT_GENTFUNC3_MIX_D( axpyv_kernel_void, AXPYV_KERNEL )
#endif
#ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
INSERT_GENTFUNC3_MIX_P( axpyv_kernel_void, AXPYV_KERNEL )
#endif
|
tkelman/blis
|
frame/1/axpyv/bli_axpyv_kernel.c
|
C
|
bsd-3-clause
| 4,535
|
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\DeliverySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Deliveries';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="delivery-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Create Delivery', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'_id',
'uid',
'reg_id',
'lat',
'lng',
// 'created',
// 'gmt',
// 'position',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
|
vanguardpro/delivery-server
|
backend/views/delivery/index.php
|
PHP
|
bsd-3-clause
| 957
|
/***********************************************************************
* fileio_dev.c *
***********************************************************************
Purpose: Machine dependent FORTRAN to C interface for BSL file I/O
Authors: G.R.Mant
Returns: Nil
Updates: 01/11/89 Initial implementation
04/07/97 Memory mapping added
*/
#include <stdio.h>
#ifdef TITAN
# define rframe RFRAME
# define wframe WFRAME
# define opnfil OPNFIL
# define opnnew OPNNEW
# define fcls FCLOSE
# define outfil OUTFIL
# define timer TIMER
# define rdhdr RDHDR
#else
# if defined (AIX) || defined (__hpux)
# define rframe rframe
# define wframe wframe
# define opnfil opnfil
# define opnnew opnnew
# define fcls fcls
# define outfil outfil
# define timer timer
# define rdhdr rdhdr
# else /* SOLARIS , CONVEX , IRIX , LINUX */
# define rframe rframe_
# define wframe wframe_
# define opnfil opnfil_
# define opnnew opnnew_
# define fcls fclose_
# define outfil outfil_
# define timer timer_
# define rdhdr rdhdr_
# endif
#endif
#ifdef TITAN
typedef struct {
char *addr;
int len;
} Str_Desc;
#else
#define Str_Desc char
#endif
#include <sys/types.h>
#ifdef __hpux
# include <time.h>
#else
# include <sys/time.h>
#endif
void timer (void);
void rframe (int *, int *, int *, int *, long int *, int *);
void wframe (int *, int *, int *, int *, void *, int *);
void opnfil (int *, Str_Desc *, int *, int *, int *, int *, int *, int *, int *, int *);
void opnnew (int *, int *, int *, int *, Str_Desc *, int *, Str_Desc *, Str_Desc *, int *);
void outfil (int *, int *, Str_Desc *, Str_Desc *, Str_Desc *, int *);
void rdhdr (Str_Desc*, Str_Desc*, int *, int *, int *, int *, int *, int *, int *);
void fcls (int *);
int rframe_c (int, int, int, int, void **);
int wframe_c (int, int, int, int, void *);
int opnfil_c (char *, int, int, int *, int *, int *);
int opnnew_c (int, int, int, char *, char *, char *);
int outfil_c (char *, char *, char *);
int rdhdr_c (char *, char *, int, int, int *, int *, int *);
static int hdrgen (int, int, int, char *, char *, char *);
void timer (void)
{
time_t *tloc = '\0';
printf ("time in seconds since midnight is %d\n", time (tloc));
return;
}
void rframe (int *fd, int *frame, int *npix, int *nrast, long int *pointer, int *irc)
{
void *buff;
*irc = rframe_c (*fd, *frame, *npix, *nrast, &buff);
*pointer = (long int) buff;
return;
}
void wframe (int *fd, int *frame, int *npix, int *nrast, void *buff, int *irc)
{
*irc = wframe_c (*fd, *frame, *npix, *nrast, buff);
return;
}
void opnfil (int *fd, Str_Desc *filename, int *ispec, int *filenum, int *iffr,
int *ilfr, int *npix, int *nrast, int *nframe, int *irc)
{
#ifdef TITAN
char *fnam = filename->addr;
#else
char *fnam = filename;
#endif
*(fnam + 10) = '\0';
if ((*fd = opnfil_c (fnam, *ispec, *filenum, npix, nrast, nframe)) == -1)
*irc = 1;
else
*irc = 0;
return;
}
void opnnew (int *fd, int *npix, int *nrast, int *nframe, Str_Desc *filename,
int *filenum, Str_Desc *title1, Str_Desc *title2, int *irc)
{
#ifdef TITAN
char *fnam = filename->addr;
char *titl1 = title1->addr;
char *titl2 = title2->addr;
#else
char *fnam = filename;
char *titl1 = title1;
char *titl2 = title2;
#endif
*(titl1 + 79) = '\0';
*(titl2 + 79) = '\0';
*(fnam + 10) = '\0';
if ((*fd = opnnew_c (*npix, *nrast, *nframe, fnam, titl1, titl2)) == -1)
*irc = 1;
else
*irc = 0;
return;
}
void rdhdr (Str_Desc *filename, Str_Desc *binary, int *ispec, int *filenum,
int *iunit, int *npix, int *nrast, int *nframe, int *irc)
{
#ifdef TITAN
char *fnam = filename->addr;
char *biny = binary->addr;
#else
char *fnam = filename;
char *biny = binary;
#endif
*(biny + 10) = '\0';
*(fnam + 10) = '\0';
if (rdhdr_c (fnam, biny, *ispec, *filenum, npix, nrast, nframe))
*irc = 0;
else
*irc = 1;
return;
}
void fcls (int *fd)
{
close (*fd);
*fd = -1;
return;
}
void outfil (int *iterm, int *iprint, Str_Desc *filename,
Str_Desc *title1, Str_Desc *title2, int *irc)
{
#ifdef TITAN
char *fnam = filename->addr;
char *titl1 = title1->addr;
char *titl2 = title2->addr;
#else
char *fnam = filename;
char *titl1 = title1;
char *titl2 = title2;
#endif
if ((outfil_c (fnam, titl1, titl2)) == -1)
*irc = 1;
else
*irc = 0;
return;
}
/***********************************************************************
* rframe.c *
***********************************************************************
Purpose: Read a frame of image data
Author: G.R.Mant
Returns: TRUE or FALSE
Updates: Initial C implementation 24/07/91
18/08/94 RCD: Modified to use memory mapping for reading binary input
*/
#if defined(__hpux) || defined(IRIX) || defined(TITAN) || defined (AIX) || defined (LINUX)
# include <fcntl.h>
# include <ctype.h>
#else
# ifdef ULTRIX
# include <sys/file.h>
# else
# ifdef SOLARIS
# include <sys/fcntl.h>
# else
# include <sys/fcntlcom.h>
# endif
# endif
#endif
#include <unistd.h>
#include <sys/mman.h>
#ifdef __hpux
# define _SC_PAGESIZE _SC_PAGE_SIZE
#endif
#define OK 0
#define ERROR -1
#define FALSE 0
#define TRUE !FALSE
#define PMODE 0664
int rframe_c (int fd, int frame, int npix, int nrast, void **buff)
{
int nbytes = npix*nrast*sizeof (float); /* Nos of bytes to read */
long offset = (frame - 1) * nbytes; /* Offset from start */
int c; /* Actual bytes read */
#ifdef MMAP
int psize = sysconf (_SC_PAGESIZE); /* System page size */
char *tmp;
off_t off;
off = (off_t) (offset - offset % psize);
nbytes += offset - off;
if ((tmp = (char *) mmap ((void *) 0, (size_t) nbytes, PROT_READ, MAP_SHARED,
fd, off)) == (caddr_t) -1)
{
perror ("mmap");
return (ERROR);
}
*buff = (void *) (tmp + offset - off);
#else
if ((lseek (fd, offset, SEEK_SET)) == ERROR)
{
errmsg ("Error: Unable to access specified frame number");
return (ERROR);
}
if (!(*buff = (void *) malloc (nbytes)))
{
errmsg ("Error: Unable to allocate sufficient memory");
return (ERROR);
}
if ((c = read (fd, *buff, nbytes)) != nbytes)
{
errmsg ("Error: Reading frame of binary data");
return (ERROR);
}
#endif
return (OK);
}
/***********************************************************************
* wframe.c *
***********************************************************************
Purpose: Write sequential frames of image data.
Author: G.R.Mant
Returns: TRUE or FALSE
Updates: Initial C implementation 24/07/91
*/
int wframe_c (int fd, int frame, int npix, int nrast, void *buff)
{
int nbytes = npix*nrast*sizeof (float); /* No of bytes to write */
int c; /* Actual bytes written */
#ifdef MMAP
char *cbuf = (char *) buff;
char *tmp;
int i;
if ((tmp = (char *) mmap ((void *) 0, (size_t) nbytes, PROT_WRITE, MAP_SHARED,
fd, (off_t) 0)) == (caddr_t) -1)
{
perror ("mmap");
return (ERROR);
}
for (i=0; i<nbytes; i++)
{
*tmp++ = *cbuf++;
}
if ((c = munmap ((void *) tmp, (size_t) nbytes)) == -1)
{
perror ("munmap");
return (ERROR);
}
#else
if ((c = write (fd, buff, nbytes)) != nbytes)
{
errmsg ("Error: Writing frame of binary data");
return (ERROR);
}
#endif
return (OK);
}
/***********************************************************************
* opnfil.c *
***********************************************************************
Purpose: Open a binary dataset
Author: G.R.Mant
Returns: file descriptor number else -1
Updates: Initial C implementation 24/07/91
*/
int opnfil_c (char *filename, int ispec, int filenum, int *npix, int *nrast, int *nframe)
{
char binary[80];
int fd;
if (!(rdhdr_c (filename, binary, ispec, filenum, npix, nrast, nframe)))
{
errmsg ("Error: Header file not found");
return (ERROR);
}
if ((fd = open (binary, O_RDONLY)) == ERROR)
{
errmsg ("Error: Unable to open binary file");
return (ERROR);
}
return (fd);
}
/***********************************************************************
* opnnew.c *
***********************************************************************
Purpose: Open a binary dataset for output
Author: G.R.Mant
Returns: file descriptor number else -1
Updates: Initial C implementation 24/07/91
*/
int opnnew_c (int npix, int nrast, int nframe, char *filename,
char *title1, char *title2)
{
int fd;
char *cptr;
cptr = filename;
while (*cptr != '\0')
{
if (islower(*cptr))
*cptr = toupper(*cptr);
cptr++;
}
if (!(hdrgen (npix, nrast, nframe, filename, title1, title2)))
return (ERROR);
if ((fd = creat (filename, PMODE)) == ERROR)
{
errmsg ("Error: Unable to create output binary file");
return (ERROR);
}
return (fd);
}
/***********************************************************************
* hdrgen.c *
***********************************************************************
Purpose: Output header file.
Author: G.Mant
Returns: TRUE for successful, else FALSE
Updates: Initial C implementation 27/11/89
*/
static int hdrgen (int npix, int nrast, int nframe, char *filename,
char *title1, char *title2)
{
int indice[10], i;
FILE *fp, *fpopen ();
for (i=0; i<10; i++)
indice[i]=0;
if ((fp = fopen (filename, "w")) == NULL)
{
errmsg ("Error: Unable to open header dataset");
return (FALSE);
}
else
{
fprintf (fp, "%s\n", title1);
fprintf (fp, "%s\n", title2);
indice[0] = npix;
indice[1] = nrast;
indice[2] = nframe;
for (i=0; i<10; i++)
fprintf (fp, "%8d", indice[i]);
*(filename + 5) = '1';
fprintf (fp, "\n%s\n", filename);
fclose (fp);
return (TRUE);
}
}
/***********************************************************************
* rdhdr.c *
***********************************************************************
Purpose: Read the header file for the associated binary file,
corresponding to the file number.
Author : G.R.Mant
Returns: TRUE or FALSE;
Updates:
24/07/91 GRM Initial C implementation
*/
#define MAXLIN 120
int rdhdr_c (char *filename, char *binary, int ispec, int filenum,
int *npix, int *nrast, int *nframe)
{
char buff[MAXLIN+1], *cptr;
register int i = 0;
FILE *fp, *fopen ();
if (ispec > 0)
{
cptr = filename;
*++cptr = (ispec / 10000) + '0';
*++cptr = ((ispec % 10000) / 1000) + '0';
}
if ((fp = fopen (filename, "r")) == NULL)
return (FALSE);
else
{
if ((fgets (buff, MAXLIN, fp)) == NULL)
return (FALSE);
else if ((fgets (buff, MAXLIN, fp)) == NULL)
return (FALSE);
else
{
do {
if ((fgets (buff, MAXLIN, fp)) == NULL)
return (FALSE);
else if (sscanf (buff, "%8d%8d%8d", npix, nrast, nframe) != 3)
return (FALSE);
else if ((fgets (binary, MAXLIN, fp)) == NULL)
return (FALSE);
}
while (++i < filenum);
}
*(binary+10) = '\0'; /* Remove new line character */
fclose (fp);
return (TRUE);
}
}
/***********************************************************************
* outfil.c *
***********************************************************************
Purpose: Get header filename and title records from terminal.
Author: G.R.Mant
Returns: TRUE or FALSE
Updates: Initial C implementation 24/07/91
*/
int outfil_c (char *filename, char *title1, char *title2)
{
int len;
do {
printf ("Enter output filename [Xnn000.xxx]: ");
fflush (stdout);
if (fgets (filename, 80, stdin) == NULL || feof (stdin))
{
fflush (stdin);
clearerr (stdin);
printf ("\n");
fflush (stdout);
return (ERROR);
}
len = strlen (filename);
*(filename + --len) = '\0'; /* Remove new line character */
if (strcmp (filename, "^D") == 0)
{
fflush (stdin);
clearerr (stdin);
printf ("\n");
fflush (stdout);
return (ERROR);
}
if (len != 10)
errmsg ("Error: Invalid header filename");
else
{
#ifdef VMS
*(filename+len) = ';';
*(filename+len+1) = '1';
*(filename+len+2) = '\0';
#endif
if (isalpha (*filename) && isdigit(*(filename+1)) &&
isdigit (*(filename+2)) && *(filename+3) == '0' &&
*(filename+4) == '0' && *(filename+5) == '0' &&
*(filename+6) == '.')
break;
else
errmsg ("Error: Invalid header filename");
}
}
while (1);
printf ("Enter first header: ");
fflush (stdout);
if (fgets (title1, 80, stdin) == NULL)
{
fflush (stdin);
clearerr (stdin);
printf ("\n");
fflush (stdout);
return (ERROR);
}
len = strlen (title1);
*(title1 + --len) = '\0'; /* Remove new line character */
printf ("Enter second header: ");
fflush (stdout);
if (fgets (title2, 80, stdin) == NULL)
{
fflush (stdin);
clearerr (stdin);
printf ("\n");
fflush (stdout);
return (ERROR);
}
len = strlen (title2);
*(title2 + --len) = '\0'; /* Remove new line character */
fflush (stdin);
fflush (stdout);
clearerr (stdin);
return (OK);
}
|
scattering-central/CCP13
|
software/libs/bsl/fileio_dev.c
|
C
|
bsd-3-clause
| 13,878
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0004_auto_20150428_2142'),
]
operations = [
migrations.AddField(
model_name='parentrelation',
name='signature',
field=models.CharField(max_length=255, null=True, verbose_name='sig', blank=True),
preserve_default=True,
),
]
|
oskarm91/sis
|
apps/users/migrations/0005_parentrelation_signature.py
|
Python
|
bsd-3-clause
| 488
|
<?php
namespace Ddl\Form;
/**
* CreateTableForm [CreateTableForm]
*
* @copyright (c) year, Claudio Coelho
*/
class CreateTableForm extends \Zend\Form\Form {
public function __construct($serviceLocator, $name = null, $options = array()) {
parent::__construct('CreateTableForm', $options);
//Não se esqueça de setar o inputFilter
$this->setInputFilter(new TableFilter($serviceLocator));
//############################################ informações da coluna title ##############################################:
$this->add(
array(
'type' => 'text',
'name' => 'tabela',
'options' => array(
'label' => 'FILD_TABELA_LABEL',
),
'attributes' => array(
'id' => 'tabela',
'title' => 'FILD_TABELA_DESC',
'class' => 'form-control input-sm',
'placeholder' => 'FILD_TABELA_PLACEHOLDER',
'data-access' => '3',
'data-position' => 'geral',
),
)
);
$this->add(array(
'name' => 'save',
'attributes' => array(
'type' => 'submit',
'value' => 'BTN_SAVE_LABEL',
'title' => 'BTN_SAVE_DESC',
'class' => 'btn btn-green submitbutton',
'id' => 'save',
),
));
}
public function getTabelas($serviceLocator) {
$table = $serviceLocator->get('Table');
$tableNames[''] = '--Selecione--';
if ($table->getTablenames()):
foreach ($table->getTablenames() as $value):
$tableNames[$value] = $value;
endforeach;
endif;
return $tableNames;
}
}
|
callcocam/zf2-puro
|
module/Ddl/src/Ddl/Form/CreateTableForm.php
|
PHP
|
bsd-3-clause
| 1,911
|
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
return *(int *)a>*(int *)b;
}
int main()
{
int p,i=0;
int a[20];
while(scanf("%d",&p),p+1)
{
if(p)
{
a[i++]=p;
continue;
}
else
{
i--;
int cn=0;
qsort(a,i,sizeof(a[0]),cmp);
for(int j=1;j<i;j++)
{
for(int k=0;k<j;k++)
{
if(2*a[k]==a[j])
{
cn++;
break;
}
}
}
printf("%d\n",cn);
i=0;
}
}
return 0;
}
|
lulyon/poj-archive
|
emperorlu/1552/2968967_WA.cc
|
C++
|
bsd-3-clause
| 503
|
# BridgeDB by Nick Mathewson.
# Copyright (c) 2007-2009, The Tor Project, Inc.
# See LICENSE for licensing information
from __future__ import print_function
import doctest
import os
import random
import sqlite3
import tempfile
import unittest
import warnings
import time
from datetime import datetime
import bridgedb.Bridges
import bridgedb.Main
import bridgedb.Dist
import bridgedb.Time
import bridgedb.Storage
import re
import ipaddr
from bridgedb.Filters import filterBridgesByIP4
from bridgedb.Filters import filterBridgesByIP6
from bridgedb.Filters import filterBridgesByOnlyIP4
from bridgedb.Filters import filterBridgesByOnlyIP6
from bridgedb.Filters import filterBridgesByTransport
from bridgedb.Filters import filterBridgesByNotBlockedIn
from bridgedb.Stability import BridgeHistory
from bridgedb.parse import addr
from bridgedb.parse import networkstatus
from math import log
def suppressWarnings():
warnings.filterwarnings('ignore', '.*tmpnam.*')
def randomIP():
if random.choice(xrange(2)):
return randomIP4()
return randomIP6()
def randomIP4():
return ipaddr.IPv4Address(random.getrandbits(32))
def randomIP4String():
return randomIP4().compressed
def randomIP6():
return ipaddr.IPv6Address(random.getrandbits(128))
def randomIP6String():
return bracketIP6(randomIP6().compressed)
def randomIPString():
if random.choice(xrange(2)):
return randomIP4String()
return randomIP6String()
def bracketIP6(ip):
"""Put brackets around an IPv6 address, just as tor does."""
return "[%s]" % ip
def random16IP():
upper = "123.123." # same 16
lower = ".".join([str(random.randrange(1,256)) for _ in xrange(2)])
return upper+lower
def randomPort():
return random.randint(1,65535)
def randomPortSpec():
"""
returns a random list of ports
"""
ports = []
for i in range(0,24):
ports.append(random.randint(1,65535))
ports.sort(reverse=True)
portspec = ""
for i in range(0,16):
portspec += "%d," % random.choice(ports)
portspec = portspec.rstrip(',') #remove trailing ,
return portspec
def randomCountry():
countries = ['us', 'nl', 'de', 'cz', 'sk', 'as', 'si', 'it']
#XXX: load from geoip
return random.choice(countries)
def randomCountrySpec():
countries = ['us', 'nl', 'de', 'cz', 'sk', 'as', 'si', 'it']
#XXX: load from geoip
spec = ""
choices = []
for i in xrange(10):
choices.append(random.choice(countries))
choices = set(choices) #dedupe
choices = list(choices)
spec += ",".join(choices)
return spec
def fakeBridge(orport=8080, running=True, stable=True, or_addresses=False,
transports=False):
nn = "bridge-%s"%random.randrange(0,1000000)
ip = ipaddr.IPAddress(randomIP4())
fp = "".join([random.choice("0123456789ABCDEF") for _ in xrange(40)])
b = bridgedb.Bridges.Bridge(nn,ip,orport,fingerprint=fp)
b.setStatus(running, stable)
oraddrs = []
if or_addresses:
for i in xrange(8):
# Only add or_addresses if they are valid. Otherwise, the test
# will randomly fail if an invalid address is chosen:
address = randomIP4String()
portlist = addr.PortList(randomPortSpec())
if addr.isValidIP(address):
oraddrs.append((address, portlist,))
for address, portlist in oraddrs:
networkstatus.parseALine("{0}:{1}".format(address, portlist))
try:
portlist.add(b.or_addresses[address])
except KeyError:
pass
finally:
b.or_addresses[address] = portlist
if transports:
for i in xrange(0,8):
b.transports.append(bridgedb.Bridges.PluggableTransport(b,
random.choice(["obfs", "obfs2", "pt1"]),
randomIP(), randomPort()))
return b
def fakeBridge6(orport=8080, running=True, stable=True, or_addresses=False,
transports=False):
nn = "bridge-%s"%random.randrange(0,1000000)
ip = ipaddr.IPAddress(randomIP6())
fp = "".join([random.choice("0123456789ABCDEF") for _ in xrange(40)])
b = bridgedb.Bridges.Bridge(nn,ip,orport,fingerprint=fp)
b.setStatus(running, stable)
oraddrs = []
if or_addresses:
for i in xrange(8):
# Only add or_addresses if they are valid. Otherwise, the test
# will randomly fail if an invalid address is chosen:
address = randomIP6()
portlist = addr.PortList(randomPortSpec())
if addr.isValidIP(address):
address = bracketIP6(address)
oraddrs.append((address, portlist,))
for address, portlist in oraddrs:
networkstatus.parseALine("{0}:{1}".format(address, portlist))
try:
portlist.add(b.or_addresses[address])
except KeyError:
pass
finally:
b.or_addresses[address] = portlist
try:
portlist.add(b.or_addresses[address])
except KeyError:
pass
finally:
b.or_addresses[address] = portlist
if transports:
for i in xrange(0,8):
b.transports.append(bridgedb.Bridges.PluggableTransport(b,
random.choice(["obfs", "obfs2", "pt1"]),
randomIP(), randomPort()))
return b
def fake16Bridge(orport=8080, running=True, stable=True):
nn = "bridge-%s"%random.randrange(0,1000000)
ip = random16IP()
fp = "".join([random.choice("0123456789ABCDEF") for _ in xrange(40)])
b = bridgedb.Bridges.Bridge(nn,ip,orport,fingerprint=fp)
b.setStatus(running, stable)
return b
simpleDesc = "router Unnamed %s %s 0 9030\n"\
"opt fingerprint DEAD BEEF F00F DEAD BEEF F00F DEAD BEEF F00F DEAD\n"\
"opt @purpose bridge\n"
orAddress = "or-address %s:%s\n"
def gettimestamp():
ts = time.strftime("%Y-%m-%d %H:%M:%S")
return "opt published %s\n" % ts
class RhymesWith255Category:
def contains(self, ip):
return ip.endswith(".255")
class EmailBridgeDistTests(unittest.TestCase):
def setUp(self):
self.fd, self.fname = tempfile.mkstemp()
self.db = bridgedb.Storage.Database(self.fname)
bridgedb.Storage.setGlobalDB(self.db)
self.cur = self.db._conn.cursor()
def tearDown(self):
self.db.close()
os.close(self.fd)
os.unlink(self.fname)
def testEmailRateLimit(self):
db = self.db
EMAIL_DOMAIN_MAP = {'example.com':'example.com'}
d = bridgedb.Dist.EmailBasedDistributor(
"Foo",
{'example.com': 'example.com',
'dkim.example.com': 'dkim.example.com'},
{'example.com': [], 'dkim.example.com': ['dkim']})
for _ in xrange(256):
d.insert(fakeBridge())
d.getBridgesForEmail('abc@example.com', 1, 3)
self.assertRaises(bridgedb.Dist.TooSoonEmail,
d.getBridgesForEmail, 'abc@example.com', 1, 3)
self.assertRaises(bridgedb.Dist.IgnoreEmail,
d.getBridgesForEmail, 'abc@example.com', 1, 3)
def testUnsupportedDomain(self):
db = self.db
self.assertRaises(bridgedb.Dist.UnsupportedDomain,
bridgedb.Dist.normalizeEmail, 'bad@email.com',
{'example.com':'example.com'},
{'example.com':[]})
class IPBridgeDistTests(unittest.TestCase):
def dumbAreaMapper(self, ip):
return ip
def testBasicDist(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(256):
d.insert(fakeBridge())
n = d.getBridgesForIP("1.2.3.4", "x", 2)
n2 = d.getBridgesForIP("1.2.3.4", "x", 2)
self.assertEquals(n, n2)
def testDistWithCategories(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo",
[RhymesWith255Category()])
assert len(d.categories) == 1
for _ in xrange(256):
d.insert(fakeBridge())
for _ in xrange(256):
# Make sure that the categories do not overlap
f = lambda: ".".join([str(random.randrange(1,255)) for _ in xrange(4)])
g = lambda: ".".join([str(random.randrange(1,255)) for _ in xrange(3)] + ['255'])
n = d.getBridgesForIP(g(), "x", 10)
n2 = d.getBridgesForIP(f(), "x", 10)
assert(len(n) > 0)
assert(len(n2) > 0)
for b in n:
assert (b not in n2)
for b in n2:
assert (b not in n)
#XXX: #6175 breaks this test!
#def testDistWithPortRestrictions(self):
# param = bridgedb.Bridges.BridgeRingParameters(needPorts=[(443, 1)])
# d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Baz",
# answerParameters=param)
# for _ in xrange(32):
# d.insert(fakeBridge(443))
# for _ in range(256):
# d.insert(fakeBridge())
# for _ in xrange(32):
# i = randomIP()
# n = d.getBridgesForIP(i, "x", 5)
# count = 0
# fps = {}
# for b in n:
# fps[b.getID()] = 1
# if b.orport == 443:
# count += 1
# self.assertEquals(len(fps), len(n))
# self.assertEquals(len(fps), 5)
# self.assertTrue(count >= 1)
#def testDistWithFilter16(self):
# d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
# for _ in xrange(256):
# d.insert(fake16Bridge())
# n = d.getBridgesForIP("1.2.3.4", "x", 10)
# slash16s = dict()
# for bridge in n:
# m = re.match(r'(\d+\.\d+)\.\d+\.\d+', bridge.ip)
# upper16 = m.group(1)
# self.assertTrue(upper16 not in slash16s)
# slash16s[upper16] = True
def testDistWithFilterIP6(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True))
d.insert(fakeBridge(or_addresses=True))
for i in xrange(500):
bridges = d.getBridgesForIP(randomIP4String(),
"faketimestamp",
bridgeFilterRules=[filterBridgesByIP6])
bridge = random.choice(bridges)
bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv6Address)
address, portlist = networkstatus.parseALine(bridge_line)
assert type(address) is ipaddr.IPv6Address
assert filterBridgesByIP6(random.choice(bridges))
def testDistWithFilterIP4(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True))
d.insert(fakeBridge(or_addresses=True))
for i in xrange(500):
bridges = d.getBridgesForIP(randomIP4String(),
"faketimestamp",
bridgeFilterRules=[filterBridgesByIP4])
bridge = random.choice(bridges)
bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv4Address)
address, portlist = networkstatus.parseALine(bridge_line)
assert type(address) is ipaddr.IPv4Address
assert filterBridgesByIP4(random.choice(bridges))
def testDistWithFilterBoth(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True))
d.insert(fakeBridge(or_addresses=True))
for i in xrange(50):
bridges = d.getBridgesForIP(randomIP4String(),
"faketimestamp", 1,
bridgeFilterRules=[
filterBridgesByIP4,
filterBridgesByIP6])
if bridges:
t = bridges.pop()
assert filterBridgesByIP4(t)
assert filterBridgesByIP6(t)
address, portlist = networkstatus.parseALine(
t.getConfigLine(addressClass=ipaddr.IPv4Address))
assert type(address) is ipaddr.IPv4Address
address, portlist = networkstatus.parseALine(
t.getConfigLine(addressClass=ipaddr.IPv6Address))
assert type(address) is ipaddr.IPv6Address
def testDistWithFilterAll(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True))
d.insert(fakeBridge(or_addresses=True))
for i in xrange(5):
b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[
filterBridgesByOnlyIP4, filterBridgesByOnlyIP6])
assert len(b) == 0
def testDistWithFilterBlockedCountries(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True))
d.insert(fakeBridge(or_addresses=True))
for b in d.splitter.bridges:
# china blocks all :-(
for pt in b.transports:
key = "%s:%s" % (pt.address, pt.port)
b.blockingCountries[key] = set(['cn'])
for address, portlist in b.or_addresses.items():
for port in portlist:
key = "%s:%s" % (address, port)
b.blockingCountries[key] = set(['cn'])
key = "%s:%s" % (b.ip, b.orport)
b.blockingCountries[key] = set(['cn'])
for i in xrange(5):
b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[
filterBridgesByNotBlockedIn("cn")])
assert len(b) == 0
b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[
filterBridgesByNotBlockedIn("us")])
assert len(b) > 0
def testDistWithFilterBlockedCountriesAdvanced(self):
d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo")
for _ in xrange(250):
d.insert(fakeBridge6(or_addresses=True, transports=True))
d.insert(fakeBridge(or_addresses=True, transports=True))
for b in d.splitter.bridges:
# china blocks some transports
for pt in b.transports:
if random.choice(xrange(2)) > 0:
key = "%s:%s" % (pt.address, pt.port)
b.blockingCountries[key] = set(['cn'])
for address, portlist in b.or_addresses.items():
# china blocks some transports
for port in portlist:
if random.choice(xrange(2)) > 0:
key = "%s:%s" % (address, port)
b.blockingCountries[key] = set(['cn'])
key = "%s:%s" % (b.ip, b.orport)
b.blockingCountries[key] = set(['cn'])
# we probably will get at least one bridge back!
# it's pretty unlikely to lose a coin flip 250 times in a row
for i in xrange(5):
b = d.getBridgesForIP(randomIPString(), "x", 1,
bridgeFilterRules=[
filterBridgesByNotBlockedIn("cn", methodname='obfs2'),
filterBridgesByTransport('obfs2'),
])
try: assert len(b) > 0
except AssertionError:
print("epic fail")
b = d.getBridgesForIP(randomIPString(), "x", 1, bridgeFilterRules=[
filterBridgesByNotBlockedIn("us")])
assert len(b) > 0
class DictStorageTests(unittest.TestCase):
def setUp(self):
self.fd, self.fname = tempfile.mkstemp()
self.conn = sqlite3.Connection(self.fname)
def tearDown(self):
self.conn.close()
os.close(self.fd)
os.unlink(self.fname)
def testSimpleDict(self):
self.conn.execute("CREATE TABLE A ( X PRIMARY KEY, Y )")
d = bridgedb.Storage.SqliteDict(self.conn, self.conn.cursor(),
"A", (), (), "X", "Y")
self.basictests(d)
def testComplexDict(self):
self.conn.execute("CREATE TABLE B ( X, Y, Z, "
"CONSTRAINT B_PK PRIMARY KEY (X,Y) )")
d = bridgedb.Storage.SqliteDict(self.conn, self.conn.cursor(),
"B", ("X",), ("x1",), "Y", "Z")
d2 = bridgedb.Storage.SqliteDict(self.conn, self.conn.cursor(),
"B", ("X",), ("x2",), "Y", "Z")
self.basictests(d)
self.basictests(d2)
def basictests(self, d):
d["hello"] = "goodbye"
d["hola"] = "adios"
self.assertEquals(d["hola"], "adios")
d["hola"] = "hasta luego"
self.assertEquals(d["hola"], "hasta luego")
self.assertEquals(sorted(d.keys()), [u"hello", u"hola"])
self.assertRaises(KeyError, d.__getitem__, "buongiorno")
self.assertEquals(d.get("buongiorno", "ciao"), "ciao")
self.conn.commit()
d["buongiorno"] = "ciao"
del d['hola']
self.assertRaises(KeyError, d.__getitem__, "hola")
self.conn.rollback()
self.assertEquals(d["hola"], "hasta luego")
self.assertEquals(d.setdefault("hola","bye"), "hasta luego")
self.assertEquals(d.setdefault("yo","bye"), "bye")
self.assertEquals(d['yo'], "bye")
class SQLStorageTests(unittest.TestCase):
def setUp(self):
self.fd, self.fname = tempfile.mkstemp()
self.db = bridgedb.Storage.Database(self.fname)
self.cur = self.db._conn.cursor()
def tearDown(self):
self.db.close()
os.close(self.fd)
os.unlink(self.fname)
def assertCloseTo(self, a, b, delta=60):
self.assertTrue(abs(a-b) <= delta)
def testBridgeStorage(self):
db = self.db
B = bridgedb.Bridges.Bridge
t = time.time()
cur = self.cur
k1 = "aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb"
k2 = "abababababababababababababababababababab"
k3 = "cccccccccccccccccccccccccccccccccccccccc"
b1 = B("serv1", "1.2.3.4", 999, fingerprint=k1)
b1_v2 = B("serv1", "1.2.3.5", 9099, fingerprint=k1)
b2 = B("serv2", "2.3.4.5", 9990, fingerprint=k2)
b3 = B("serv3", "2.3.4.6", 9008, fingerprint=k3)
validRings = ["ring1", "ring2", "ring3"]
r = db.insertBridgeAndGetRing(b1, "ring1", t, validRings)
self.assertEquals(r, "ring1")
r = db.insertBridgeAndGetRing(b1, "ring10", t+500, validRings)
self.assertEquals(r, "ring1")
cur.execute("SELECT distributor, address, or_port, first_seen, "
"last_seen FROM Bridges WHERE hex_key = ?", (k1,))
v = cur.fetchone()
self.assertEquals(v,
("ring1", "1.2.3.4", 999,
bridgedb.Storage.timeToStr(t),
bridgedb.Storage.timeToStr(t+500)))
r = db.insertBridgeAndGetRing(b1_v2, "ring99", t+800, validRings)
self.assertEquals(r, "ring1")
cur.execute("SELECT distributor, address, or_port, first_seen, "
"last_seen FROM Bridges WHERE hex_key = ?", (k1,))
v = cur.fetchone()
self.assertEquals(v,
("ring1", "1.2.3.5", 9099,
bridgedb.Storage.timeToStr(t),
bridgedb.Storage.timeToStr(t+800)))
db.insertBridgeAndGetRing(b2, "ring2", t, validRings)
db.insertBridgeAndGetRing(b3, "ring3", t, validRings)
cur.execute("SELECT COUNT(distributor) FROM Bridges")
v = cur.fetchone()
self.assertEquals(v, (3,))
r = db.getEmailTime("abc@example.com")
self.assertEquals(r, None)
db.setEmailTime("abc@example.com", t)
db.setEmailTime("def@example.com", t+1000)
r = db.getEmailTime("abc@example.com")
self.assertCloseTo(r, t)
r = db.getEmailTime("def@example.com")
self.assertCloseTo(r, t+1000)
r = db.getEmailTime("ghi@example.com")
self.assertEquals(r, None)
db.cleanEmailedBridges(t+200)
db.setEmailTime("def@example.com", t+5000)
r = db.getEmailTime("abc@example.com")
self.assertEquals(r, None)
r = db.getEmailTime("def@example.com")
self.assertCloseTo(r, t+5000)
cur.execute("SELECT * FROM EmailedBridges")
self.assertEquals(len(cur.fetchall()), 1)
db.addBridgeBlock(b2.fingerprint, 'us')
self.assertEquals(db.isBlocked(b2.fingerprint, 'us'), True)
db.delBridgeBlock(b2.fingerprint, 'us')
self.assertEquals(db.isBlocked(b2.fingerprint, 'us'), False)
db.addBridgeBlock(b2.fingerprint, 'uk')
db.addBridgeBlock(b3.fingerprint, 'uk')
self.assertEquals(set([b2.fingerprint, b3.fingerprint]),
set(db.getBlockedBridges('uk')))
db.addBridgeBlock(b2.fingerprint, 'cn')
db.addBridgeBlock(b2.fingerprint, 'de')
db.addBridgeBlock(b2.fingerprint, 'jp')
db.addBridgeBlock(b2.fingerprint, 'se')
db.addBridgeBlock(b2.fingerprint, 'kr')
self.assertEquals(set(db.getBlockingCountries(b2.fingerprint)),
set(['uk', 'cn', 'de', 'jp', 'se', 'kr']))
self.assertEquals(db.getWarnedEmail("def@example.com"), False)
db.setWarnedEmail("def@example.com")
self.assertEquals(db.getWarnedEmail("def@example.com"), True)
db.setWarnedEmail("def@example.com", False)
self.assertEquals(db.getWarnedEmail("def@example.com"), False)
db.setWarnedEmail("def@example.com")
self.assertEquals(db.getWarnedEmail("def@example.com"), True)
db.cleanWarnedEmails(t+200)
self.assertEquals(db.getWarnedEmail("def@example.com"), False)
class ParseDescFileTests(unittest.TestCase):
def testSimpleDesc(self):
test = ""
for i in range(100):
test+= "".join(simpleDesc % (randomIP(), randomPort()))
test+=gettimestamp()
test+="router-signature\n"
bs = [b for b in bridgedb.Bridges.parseDescFile(test.split('\n'))]
self.assertEquals(len(bs), 100)
for b in bs:
b.assertOK()
def testSingleOrAddress(self):
test = ""
for i in range(100):
test+= simpleDesc % (randomIP(), randomPort())
test+= orAddress % (randomIP(),randomPort())
test+=gettimestamp()
test+= "router-signature\n"
bs = [b for b in bridgedb.Bridges.parseDescFile(test.split('\n'))]
self.assertEquals(len(bs), 100)
for b in bs:
b.assertOK()
def testMultipleOrAddress(self):
test = ""
for i in range(100):
test+= simpleDesc % (randomIPString(), randomPort())
for i in xrange(8):
test+= orAddress % (randomIPString(),randomPortSpec())
test+=gettimestamp()
test+= "router-signature\n"
bs = [b for b in bridgedb.Bridges.parseDescFile(test.split('\n'))]
self.assertEquals(len(bs), 100)
for b in bs:
b.assertOK()
def testConvolutedOrAddress(self):
test = ""
for i in range(100):
test+= simpleDesc % (randomIPString(), randomPort())
for i in xrange(8):
test+= orAddress % (randomIPString(),randomPortSpec())
test+=gettimestamp()
test+= "router-signature\n"
bs = [b for b in bridgedb.Bridges.parseDescFile(test.split('\n'))]
self.assertEquals(len(bs), 100)
for b in bs:
b.assertOK()
def testParseCountryBlockFile(self):
simpleBlock = "%s:%s %s\n"
countries = ['us', 'nl', 'de', 'cz', 'sk', 'as', 'si', 'it']
test = str()
for i in range(100):
test += simpleBlock % (randomIPString(), randomPort(),
randomCountrySpec())
test+=gettimestamp()
for a,p,c in bridgedb.Bridges.parseCountryBlockFile(test.split('\n')):
assert type(a) in (ipaddr.IPv6Address, ipaddr.IPv4Address)
assert isinstance(p, addr.PortList)
assert isinstance(c, list)
assert len(c) > 0
for y in c:
assert y in countries
#print "address: %s" % a
#print "portlist: %s" % p
#print "countries: %s" % c
class BridgeStabilityTests(unittest.TestCase):
def setUp(self):
self.fd, self.fname = tempfile.mkstemp()
self.db = bridgedb.Storage.Database(self.fname)
bridgedb.Storage.setGlobalDB(self.db)
self.cur = self.db._conn.cursor()
def tearDown(self):
self.db.close()
os.close(self.fd)
os.unlink(self.fname)
def testAddOrUpdateSingleBridgeHistory(self):
db = self.db
b = fakeBridge()
timestamp = time.time()
bhe = bridgedb.Stability.addOrUpdateBridgeHistory(b, timestamp)
assert isinstance(bhe, BridgeHistory)
assert isinstance(db.getBridgeHistory(b.fingerprint), BridgeHistory)
assert len([y for y in db.getAllBridgeHistory()]) == 1
def testDeletingSingleBridgeHistory(self):
db = self.db
b = fakeBridge()
timestamp = time.time()
bhe = bridgedb.Stability.addOrUpdateBridgeHistory(b, timestamp)
assert isinstance(bhe, BridgeHistory)
assert isinstance(db.getBridgeHistory(b.fingerprint), BridgeHistory)
db.delBridgeHistory(b.fingerprint)
assert db.getBridgeHistory(b.fingerprint) is None
assert len([y for y in db.getAllBridgeHistory()]) == 0
def testTOSA(self):
db = self.db
b = random.choice([fakeBridge,fakeBridge6])()
def timestampSeries(x):
for i in xrange(61):
yield (i+1)*60*30 + x # 30 minute intervals
now = time.time()
time_on_address = long(60*30*60) # 30 hours
downtime = 60*60*random.randint(0,4) # random hours of downtime
for t in timestampSeries(now):
bridgedb.Stability.addOrUpdateBridgeHistory(b,t)
assert db.getBridgeHistory(b.fingerprint).tosa == time_on_address
b.orport += 1
for t in timestampSeries(now + time_on_address + downtime):
bhe = bridgedb.Stability.addOrUpdateBridgeHistory(b,t)
assert db.getBridgeHistory(b.fingerprint).tosa == time_on_address + downtime
def testLastSeenWithDifferentAddressAndPort(self):
db = self.db
for i in xrange(10):
num_desc = 30
time_start = time.time()
ts = [ 60*30*(i+1) + time_start for i in xrange(num_desc) ]
b = random.choice([fakeBridge(), fakeBridge6()])
[ bridgedb.Stability.addOrUpdateBridgeHistory(b, t) for t in ts ]
# change the port
b.orport = b.orport+1
last_seen = ts[-1]
ts = [ 60*30*(i+1) + last_seen for i in xrange(num_desc) ]
[ bridgedb.Stability.addOrUpdateBridgeHistory(b, t) for t in ts ]
b = db.getBridgeHistory(b.fingerprint)
assert b.tosa == ts[-1] - last_seen
assert (long(last_seen*1000) == b.lastSeenWithDifferentAddressAndPort)
assert (long(ts[-1]*1000) == b.lastSeenWithThisAddressAndPort)
def testFamiliar(self):
# create some bridges
# XXX: slow
num_bridges = 10
num_desc = 4*48 # 30m intervals, 48 per day
time_start = time.time()
bridges = [ fakeBridge() for x in xrange(num_bridges) ]
t = time.time()
ts = [ (i+1)*60*30+t for i in xrange(num_bridges) ]
for b in bridges:
time_series = [ 60*30*(i+1) + time_start for i in xrange(num_desc) ]
[ bridgedb.Stability.addOrUpdateBridgeHistory(b, i) for i in time_series ]
assert None not in bridges
# +1 to avoid rounding errors
assert bridges[-(num_bridges/8 + 1)].familiar == True
def testDiscountAndPruneBridgeHistory(self):
""" Test pruning of old Bridge History """
if os.environ.get('TRAVIS'):
self.skipTest("Hangs on Travis-CI.")
db = self.db
# make a bunch of bridges
num_bridges = 20
time_start = time.time()
bridges = [random.choice([fakeBridge, fakeBridge6])()
for i in xrange(num_bridges)]
# run some of the bridges for the full time series
running = bridges[:num_bridges/2]
# and some that are not
expired = bridges[num_bridges/2:]
for b in running: assert b not in expired
# Solving:
# 1 discount event per 12 hours, 24 descriptors 30m apart
num_successful = random.randint(2,60)
# figure out how many intervals it will take for weightedUptime to
# decay to < 1
num_desc = int(30*log(1/float(num_successful*30*60))/(-0.05))
timeseries = [ 60*30*(i+1) + time_start for i in xrange(num_desc) ]
for i in timeseries:
for b in running:
bridgedb.Stability.addOrUpdateBridgeHistory(b, i)
if num_successful > 0:
for b in expired:
bridgedb.Stability.addOrUpdateBridgeHistory(b, i)
num_successful -= 1
# now we expect to see the bridge has been removed from history
for bridge in expired:
b = db.getBridgeHistory(bridge.fingerprint)
assert b is None
# and make sure none of the others have
for bridge in running:
b = db.getBridgeHistory(bridge.fingerprint)
assert b is not None
def testSuite():
suite = unittest.TestSuite()
loader = unittest.TestLoader()
for klass in [ IPBridgeDistTests, DictStorageTests, SQLStorageTests,
EmailBridgeDistTests, ParseDescFileTests, BridgeStabilityTests ]:
suite.addTest(loader.loadTestsFromTestCase(klass))
for module in [ bridgedb.Bridges,
bridgedb.Main,
bridgedb.Dist,
bridgedb.Time ]:
suite.addTest(doctest.DocTestSuite(module))
return suite
def main():
suppressWarnings()
unittest.TextTestRunner(verbosity=1).run(testSuite())
|
wfn/bridgedb
|
lib/bridgedb/Tests.py
|
Python
|
bsd-3-clause
| 30,756
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrTestBatch_DEFINED
#define GrTestBatch_DEFINED
#include "GrBatch.h"
#include "GrVertexBuffer.h"
/*
* A simple batch only for testing purposes which actually doesn't batch at all, but can fit into
* the batch pipeline and generate arbitrary geometry
*/
class GrTestBatch : public GrBatch {
public:
struct Geometry {
GrColor fColor;
};
virtual const char* name() const override = 0;
void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
// When this is called on a batch, there is only one geometry bundle
out->setKnownFourComponents(this->geoData(0)->fColor);
}
void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
out->setUnknownSingleComponent();
}
void initBatchTracker(const GrPipelineInfo& init) override {
// Handle any color overrides
if (!init.readsColor()) {
this->geoData(0)->fColor = GrColor_ILLEGAL;
}
init.getOverrideColorIfSet(&this->geoData(0)->fColor);
// setup batch properties
fBatch.fColorIgnored = !init.readsColor();
fBatch.fColor = this->geoData(0)->fColor;
fBatch.fUsesLocalCoords = init.readsLocalCoords();
fBatch.fCoverageIgnored = !init.readsCoverage();
}
void generateGeometry(GrBatchTarget* batchTarget) override {
batchTarget->initDraw(fGeometryProcessor, this->pipeline());
this->onGenerateGeometry(batchTarget);
}
protected:
GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) {
fGeometryProcessor.reset(SkRef(gp));
this->setBounds(bounds);
}
const GrGeometryProcessor* geometryProcessor() const { return fGeometryProcessor; }
private:
virtual Geometry* geoData(int index) = 0;
virtual const Geometry* geoData(int index) const = 0;
bool onCombineIfPossible(GrBatch* t) override {
return false;
}
virtual void onGenerateGeometry(GrBatchTarget* batchTarget) = 0;
struct BatchTracker {
GrColor fColor;
bool fUsesLocalCoords;
bool fColorIgnored;
bool fCoverageIgnored;
};
SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
BatchTracker fBatch;
};
#endif
|
todotodoo/skia
|
src/gpu/GrTestBatch.h
|
C
|
bsd-3-clause
| 2,401
|
from __future__ import absolute_import, unicode_literals
from six import add_metaclass, text_type
from .event_encoder import Parameter, EventEncoder
@add_metaclass(EventEncoder)
class Event(object):
hit = Parameter('t', text_type, required=True)
category = Parameter('ec', text_type, required=True)
action = Parameter('ea', text_type, required=True)
label = Parameter('el', text_type)
value = Parameter('ev', int)
def __init__(self, **kwargs):
self.hit = 'event'
for name, value in kwargs.items():
setattr(self, name, value)
|
enthought/python-analytics
|
python_analytics/events.py
|
Python
|
bsd-3-clause
| 583
|
var searchData=
[
['cdeactivate',['cDeactivate',['../group___game_object.html#gab3a5c1145d984bfffc6542a1c5326623',1,'GameObject']]],
['cinit',['cInit',['../group___game_object.html#gab6ed5a737f27fa166a782a2b8141df7d',1,'GameObject']]],
['clearassimps',['clearAssimps',['../_lua_binder_8dox.html#ae54b1056949421de790925afdd89b3e7',1,'LuaBinder.dox']]],
['clearlocallights',['clearLocalLights',['../group___graphics3_d.html#gaa5dd02573dd44e82671c79603dc379fa',1,'Game']]],
['clearobjs',['clearObjs',['../_lua_binder_8dox.html#a1d8d7ad169e63dc24f582840cda5872b',1,'LuaBinder.dox']]],
['clearparticleemitters',['clearParticleEmitters',['../group___particles.html#ga9994f7dcd7b0a6450656970e96cec839',1,'Game']]],
['clearphysicsforces',['clearPhysicsForces',['../group___physics.html#gaefc89ef36b27e5a786c0a172443c4cee',1,'Game']]],
['clearphysicsworld',['clearPhysicsWorld',['../group___physics.html#gaa61a14a28a9156831d53dbd8a67ea9dc',1,'Game']]],
['clearscreencontrols',['clearScreenControls',['../group___u_i.html#ga312e3399948789dfda978086d7caddba',1,'Game']]],
['cleartextures',['clearTextures',['../group___graphics2_d.html#ga3804de5b3501fc8f1395f10a455a39cc',1,'LuaBinder.dox']]],
['countphysicscontacts',['countPhysicsContacts',['../group___physics.html#ga39dd50cfc1d93826fd923b2fdfb93aed',1,'GameObject']]],
['createphysicsworld',['createPhysicsWorld',['../group___physics.html#ga8a3a51a00836a0be79df7799a4dcc4ac',1,'Game']]]
];
|
puretekniq/batterytech
|
doc/BatteryTech Engine/doxygen/html/search/functions_63.js
|
JavaScript
|
bsd-3-clause
| 1,457
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.pipeline.stopwords" content="True">
<meta name="lang:search.pipeline.trimmer" content="True">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link href="https://fonts.gstatic.com/" rel="preconnect" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700|Roboto:300,400,400i,700&display=fallback" rel="stylesheet">
<style>
body,
input {
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif
}
code,
kbd,
pre {
font-family: "Roboto Mono", "Courier New", Courier, monospace
}
</style>
<link rel="stylesheet" href="../_static/stylesheets/application.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-palette.css"/>
<link rel="stylesheet" href="../_static/stylesheets/application-fixes.css"/>
<link rel="stylesheet" href="../_static/fonts/material-icons.css"/>
<meta name="theme-color" content="#3f51b5">
<script src="../_static/javascripts/modernizr.js"></script>
<title>statsmodels.tsa.varma_process.VarmaPoly.stacksquare — statsmodels</title>
<link rel="icon" type="image/png" sizes="32x32" href="../_static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../_static/icons/favicon-16x16.png">
<link rel="manifest" href="../_static/icons/site.webmanifest">
<link rel="mask-icon" href="../_static/icons/safari-pinned-tab.svg" color="#919191">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="../_static/icons/browserconfig.xml">
<link rel="stylesheet" href="../_static/stylesheets/examples.css">
<link rel="stylesheet" href="../_static/stylesheets/deprecation.css">
<link rel="stylesheet" href="../_static/material.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="statsmodels.tsa.varma_process.VarmaPoly.vstack" href="statsmodels.tsa.varma_process.VarmaPoly.vstack.html" />
<link rel="prev" title="statsmodels.tsa.varma_process.VarmaPoly.reduceform" href="statsmodels.tsa.varma_process.VarmaPoly.reduceform.html" />
</head>
<body dir=ltr
data-md-color-primary=indigo data-md-color-accent=blue>
<svg class="md-svg">
<defs data-children-count="0">
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#generated/statsmodels.tsa.varma_process.VarmaPoly.stacksquare" tabindex="1" class="md-skip"> Skip to content </a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex navheader">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../index.html" title="statsmodels"
class="md-header-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" height="26"
alt="statsmodels logo">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">statsmodels v0.12.1</span>
<span class="md-header-nav__topic"> statsmodels.tsa.varma_process.VarmaPoly.stacksquare </span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" action="../search.html" method="GET" name="search">
<input type="text" class="md-search__input" name="q" placeholder="Search"
autocapitalize="off" autocomplete="off" spellcheck="false"
data-md-component="query" data-md-state="active">
<label class="md-icon md-search__icon" for="__search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">

</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
</div>
<script src="../_static/javascripts/version_dropdown.js"></script>
<script>
var json_loc = "../_static/versions.json",
target_loc = "../../",
text = "Versions";
$( document ).ready( add_version_dropdown(json_loc, target_loc, text));
</script>
</div>
</nav>
</header>
<div class="md-container">
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item"><a href="../user-guide.html" class="md-tabs__link">User Guide</a></li>
<li class="md-tabs__item"><a href="../tsa.html" class="md-tabs__link">Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a></li>
<li class="md-tabs__item"><a href="statsmodels.tsa.varma_process.VarmaPoly.html" class="md-tabs__link">statsmodels.tsa.varma_process.VarmaPoly</a></li>
</ul>
</div>
</nav>
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a href="../index.html" title="statsmodels" class="md-nav__button md-logo">
<img src="../_static/statsmodels-logo-v2-bw.svg" alt=" logo" width="48" height="48">
</a>
<a href="../index.html"
title="statsmodels">statsmodels v0.12.1</a>
</label>
<div class="md-nav__source">
<a href="https://github.com/statsmodels/statsmodels" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
<use xlink:href="#__github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../install.html" class="md-nav__link">Installing statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../gettingstarted.html" class="md-nav__link">Getting started</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html" class="md-nav__link">User Guide</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../user-guide.html#background" class="md-nav__link">Background</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#regression-and-linear-models" class="md-nav__link">Regression and Linear Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#time-series-analysis" class="md-nav__link">Time Series Analysis</a>
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="../tsa.html" class="md-nav__link">Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a>
</li>
<li class="md-nav__item">
<a href="../statespace.html" class="md-nav__link">Time Series Analysis by State Space Methods <code class="xref py py-mod docutils literal notranslate"><span class="pre">statespace</span></code></a>
</li>
<li class="md-nav__item">
<a href="../vector_ar.html" class="md-nav__link">Vector Autoregressions <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa.vector_ar</span></code></a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#other-models" class="md-nav__link">Other Models</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#statistics-and-tools" class="md-nav__link">Statistics and Tools</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#data-sets" class="md-nav__link">Data Sets</a>
</li>
<li class="md-nav__item">
<a href="../user-guide.html#sandbox" class="md-nav__link">Sandbox</a>
</li></ul>
</li>
<li class="md-nav__item">
<a href="../examples/index.html" class="md-nav__link">Examples</a>
</li>
<li class="md-nav__item">
<a href="../api.html" class="md-nav__link">API Reference</a>
</li>
<li class="md-nav__item">
<a href="../about.html" class="md-nav__link">About statsmodels</a>
</li>
<li class="md-nav__item">
<a href="../dev/index.html" class="md-nav__link">Developer Page</a>
</li>
<li class="md-nav__item">
<a href="../release/index.html" class="md-nav__link">Release Notes</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item"><a class="md-nav__extra_link" href="../_sources/generated/statsmodels.tsa.varma_process.VarmaPoly.stacksquare.rst.txt">Show Source</a> </li>
<li id="searchbox" class="md-nav__item"></li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset" role="main">
<h1 id="generated-statsmodels-tsa-varma-process-varmapoly-stacksquare--page-root">statsmodels.tsa.varma_process.VarmaPoly.stacksquare<a class="headerlink" href="#generated-statsmodels-tsa-varma-process-varmapoly-stacksquare--page-root" title="Permalink to this headline">¶</a></h1>
<dl class="py method">
<dt id="statsmodels.tsa.varma_process.VarmaPoly.stacksquare">
<code class="sig-prename descclassname">VarmaPoly.</code><code class="sig-name descname">stacksquare</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">a</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">name</span><span class="o">=</span><span class="default_value">'ar'</span></em>, <em class="sig-param"><span class="n">orientation</span><span class="o">=</span><span class="default_value">'vertical'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/statsmodels/tsa/varma_process.html#VarmaPoly.stacksquare"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#statsmodels.tsa.varma_process.VarmaPoly.stacksquare" title="Permalink to this definition">¶</a></dt>
<dd><p>stack lagpolynomial vertically in 2d square array with eye</p>
</dd></dl>
</article>
</div>
</div>
</main>
</div>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="statsmodels.tsa.varma_process.VarmaPoly.reduceform.html" title="statsmodels.tsa.varma_process.VarmaPoly.reduceform"
class="md-flex md-footer-nav__link md-footer-nav__link--prev"
rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span
class="md-footer-nav__direction"> Previous </span> statsmodels.tsa.varma_process.VarmaPoly.reduceform </span>
</div>
</a>
<a href="statsmodels.tsa.varma_process.VarmaPoly.vstack.html" title="statsmodels.tsa.varma_process.VarmaPoly.vstack"
class="md-flex md-footer-nav__link md-footer-nav__link--next"
rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"><span
class="md-flex__ellipsis"> <span
class="md-footer-nav__direction"> Next </span> statsmodels.tsa.varma_process.VarmaPoly.vstack </span>
</div>
<div class="md-flex__cell md-flex__cell--shrink"><i
class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
© Copyright 2009-2019, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers.
</div>
Last updated on
Oct 29, 2020.
<br/>
Created using
<a href="http://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
and
<a href="https://github.com/bashtage/sphinx-material/">Material for
Sphinx</a>
</div>
</div>
</div>
</footer>
<script src="../_static/javascripts/application.js"></script>
<script>app.initialize({version: "1.0.4", url: {base: ".."}})</script>
</body>
</html>
|
statsmodels/statsmodels.github.io
|
v0.12.1/generated/statsmodels.tsa.varma_process.VarmaPoly.stacksquare.html
|
HTML
|
bsd-3-clause
| 18,252
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "extensions/browser/content_verify_job.h"
#include <algorithm>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/timer/elapsed_timer.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "extensions/browser/content_hash_reader.h"
#include "extensions/browser/content_verifier.h"
#include "extensions/browser/content_verifier/content_hash.h"
namespace extensions {
namespace {
bool g_ignore_verification_for_tests = false;
base::LazyInstance<scoped_refptr<ContentVerifyJob::TestObserver>>::Leaky
g_content_verify_job_test_observer = LAZY_INSTANCE_INITIALIZER;
scoped_refptr<ContentVerifyJob::TestObserver> GetTestObserver() {
if (!g_content_verify_job_test_observer.IsCreated())
return nullptr;
return g_content_verify_job_test_observer.Get();
}
class ScopedElapsedTimer {
public:
explicit ScopedElapsedTimer(base::TimeDelta* total) : total_(total) {
DCHECK(total_);
}
~ScopedElapsedTimer() { *total_ += timer.Elapsed(); }
private:
// Some total amount of time we should add our elapsed time to at
// destruction.
base::TimeDelta* total_;
// A timer for how long this object has been alive.
base::ElapsedTimer timer;
};
bool IsIgnorableReadError(MojoResult read_result) {
// Extension reload, for example, can cause benign MOJO_RESULT_ABORTED error.
// Do not incorrectly fail content verification in that case.
// See https://crbug.com/977805 for details.
return read_result == MOJO_RESULT_ABORTED;
}
} // namespace
ContentVerifyJob::ContentVerifyJob(const ExtensionId& extension_id,
const base::Version& extension_version,
const base::FilePath& extension_root,
const base::FilePath& relative_path,
FailureCallback failure_callback)
: done_reading_(false),
hashes_ready_(false),
total_bytes_read_(0),
current_block_(0),
current_hash_byte_count_(0),
extension_id_(extension_id),
extension_version_(extension_version),
extension_root_(extension_root),
relative_path_(relative_path),
failure_callback_(std::move(failure_callback)),
failed_(false) {}
ContentVerifyJob::~ContentVerifyJob() {
UMA_HISTOGRAM_COUNTS_1M("ExtensionContentVerifyJob.TimeSpentUS",
time_spent_.InMicroseconds());
}
void ContentVerifyJob::Start(ContentVerifier* verifier) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
base::AutoLock auto_lock(lock_);
verifier->GetContentHash(
extension_id_, extension_root_, extension_version_,
true /* force_missing_computed_hashes_creation */,
base::BindOnce(&ContentVerifyJob::DidGetContentHashOnIO, this));
}
void ContentVerifyJob::DidGetContentHashOnIO(
scoped_refptr<const ContentHash> content_hash) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
base::AutoLock auto_lock(lock_);
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->JobStarted(extension_id_, relative_path_);
// Build |hash_reader_|.
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&ContentHashReader::Create, relative_path_, content_hash),
base::BindOnce(&ContentVerifyJob::OnHashesReady, this));
}
void ContentVerifyJob::Read(const char* data,
int count,
MojoResult read_result) {
base::AutoLock auto_lock(lock_);
DCHECK(!done_reading_);
ReadImpl(data, count, read_result);
}
void ContentVerifyJob::Done() {
base::AutoLock auto_lock(lock_);
ScopedElapsedTimer timer(&time_spent_);
if (failed_)
return;
if (g_ignore_verification_for_tests)
return;
DCHECK(!done_reading_);
done_reading_ = true;
if (!hashes_ready_)
return; // Wait for OnHashesReady.
const bool can_proceed = has_ignorable_read_error_ || FinishBlock();
if (can_proceed) {
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->JobFinished(extension_id_, relative_path_, NONE);
} else {
DispatchFailureCallback(HASH_MISMATCH);
}
}
void ContentVerifyJob::ReadImpl(const char* data,
int count,
MojoResult read_result) {
ScopedElapsedTimer timer(&time_spent_);
if (failed_)
return;
if (g_ignore_verification_for_tests)
return;
if (IsIgnorableReadError(read_result))
has_ignorable_read_error_ = true;
if (has_ignorable_read_error_)
return;
if (!hashes_ready_) {
queue_.append(data, count);
return;
}
DCHECK_GE(count, 0);
int bytes_added = 0;
while (bytes_added < count) {
if (current_block_ >= hash_reader_->block_count())
return DispatchFailureCallback(HASH_MISMATCH);
if (!current_hash_) {
current_hash_byte_count_ = 0;
current_hash_ = crypto::SecureHash::Create(crypto::SecureHash::SHA256);
}
// Compute how many bytes we should hash, and add them to the current hash.
int bytes_to_hash =
std::min(hash_reader_->block_size() - current_hash_byte_count_,
count - bytes_added);
DCHECK_GT(bytes_to_hash, 0);
current_hash_->Update(data + bytes_added, bytes_to_hash);
bytes_added += bytes_to_hash;
current_hash_byte_count_ += bytes_to_hash;
total_bytes_read_ += bytes_to_hash;
// If we finished reading a block worth of data, finish computing the hash
// for it and make sure the expected hash matches.
if (current_hash_byte_count_ == hash_reader_->block_size() &&
!FinishBlock()) {
DispatchFailureCallback(HASH_MISMATCH);
return;
}
}
}
bool ContentVerifyJob::FinishBlock() {
DCHECK(!failed_);
if (current_hash_byte_count_ == 0) {
if (!done_reading_ ||
// If we have checked all blocks already, then nothing else to do here.
current_block_ == hash_reader_->block_count()) {
return true;
}
}
if (!current_hash_) {
// This happens when we fail to read the resource. Compute empty content's
// hash in this case.
current_hash_ = crypto::SecureHash::Create(crypto::SecureHash::SHA256);
}
std::string final(crypto::kSHA256Length, 0);
current_hash_->Finish(base::data(final), final.size());
current_hash_.reset();
current_hash_byte_count_ = 0;
int block = current_block_++;
const std::string* expected_hash = NULL;
if (!hash_reader_->GetHashForBlock(block, &expected_hash) ||
*expected_hash != final) {
return false;
}
return true;
}
void ContentVerifyJob::OnHashesReady(
std::unique_ptr<const ContentHashReader> hash_reader) {
base::AutoLock auto_lock(lock_);
hash_reader_ = std::move(hash_reader);
if (g_ignore_verification_for_tests)
return;
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->OnHashesReady(extension_id_, relative_path_, *hash_reader_);
switch (hash_reader_->status()) {
case ContentHashReader::InitStatus::HASHES_MISSING: {
DispatchFailureCallback(MISSING_ALL_HASHES);
return;
}
case ContentHashReader::InitStatus::HASHES_DAMAGED: {
DispatchFailureCallback(CORRUPTED_HASHES);
return;
}
case ContentHashReader::InitStatus::NO_HASHES_FOR_NON_EXISTING_RESOURCE: {
// Ignore verification of non-existent resources.
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->JobFinished(extension_id_, relative_path_, NONE);
return;
}
case ContentHashReader::InitStatus::NO_HASHES_FOR_RESOURCE: {
DispatchFailureCallback(NO_HASHES_FOR_FILE);
return;
}
case ContentHashReader::InitStatus::SUCCESS: {
// Just proceed with hashes in case of success.
}
}
DCHECK_EQ(ContentHashReader::InitStatus::SUCCESS, hash_reader_->status());
DCHECK(!failed_);
hashes_ready_ = true;
if (!queue_.empty()) {
std::string tmp;
queue_.swap(tmp);
ReadImpl(base::data(tmp), tmp.size(), MOJO_RESULT_OK);
if (failed_)
return;
}
if (done_reading_) {
ScopedElapsedTimer timer(&time_spent_);
if (!has_ignorable_read_error_ && !FinishBlock()) {
DispatchFailureCallback(HASH_MISMATCH);
} else {
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->JobFinished(extension_id_, relative_path_, NONE);
}
}
}
// static
void ContentVerifyJob::SetIgnoreVerificationForTests(bool value) {
DCHECK_NE(g_ignore_verification_for_tests, value);
g_ignore_verification_for_tests = value;
}
// static
void ContentVerifyJob::SetObserverForTests(
scoped_refptr<TestObserver> observer) {
DCHECK(observer == nullptr ||
g_content_verify_job_test_observer.Get() == nullptr)
<< "SetObserverForTests does not support interleaving. Observers should "
<< "be set and then cleared one at a time.";
g_content_verify_job_test_observer.Get() = std::move(observer);
}
void ContentVerifyJob::DispatchFailureCallback(FailureReason reason) {
DCHECK(!failed_);
failed_ = true;
if (!failure_callback_.is_null()) {
VLOG(1) << "job failed for " << extension_id_ << " "
<< relative_path_.MaybeAsASCII() << " reason:" << reason;
std::move(failure_callback_).Run(reason);
}
scoped_refptr<TestObserver> test_observer = GetTestObserver();
if (test_observer)
test_observer->JobFinished(extension_id_, relative_path_, reason);
}
} // namespace extensions
|
endlessm/chromium-browser
|
extensions/browser/content_verify_job.cc
|
C++
|
bsd-3-clause
| 10,010
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.