code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>statsmodels.tsa.arima_model.ARIMAResults.bse — statsmodels v0.10.0 documentation</title>
<link rel="stylesheet" href="../_static/nature.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 async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="shortcut icon" href="../_static/statsmodels_hybi_favico.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.arima_model.ARIMAResults.conf_int" href="statsmodels.tsa.arima_model.ARIMAResults.conf_int.html" />
<link rel="prev" title="statsmodels.tsa.arima_model.ARIMAResults.arfreq" href="statsmodels.tsa.arima_model.ARIMAResults.arfreq.html" />
<link rel="stylesheet" href="../_static/examples.css" type="text/css" />
<link rel="stylesheet" href="../_static/facebox.css" type="text/css" />
<script type="text/javascript" src="../_static/scripts.js">
</script>
<script type="text/javascript" src="../_static/facebox.js">
</script>
<script type="text/javascript">
$.facebox.settings.closeImage = "../_static/closelabel.png"
$.facebox.settings.loadingImage = "../_static/loading.gif"
</script>
<script>
$(document).ready(function() {
$.getJSON("../../versions.json", function(versions) {
var dropdown = document.createElement("div");
dropdown.className = "dropdown";
var button = document.createElement("button");
button.className = "dropbtn";
button.innerHTML = "Other Versions";
var content = document.createElement("div");
content.className = "dropdown-content";
dropdown.appendChild(button);
dropdown.appendChild(content);
$(".header").prepend(dropdown);
for (var i = 0; i < versions.length; i++) {
if (versions[i].substring(0, 1) == "v") {
versions[i] = [versions[i], versions[i].substring(1)];
} else {
versions[i] = [versions[i], versions[i]];
};
};
for (var i = 0; i < versions.length; i++) {
var a = document.createElement("a");
a.innerHTML = versions[i][1];
a.href = "../../" + versions[i][0] + "/index.html";
a.title = versions[i][1];
$(".dropdown-content").append(a);
};
});
});
</script>
</head><body>
<div class="headerwrap">
<div class = "header">
<a href = "../index.html">
<img src="../_static/statsmodels_hybi_banner.png" alt="Logo"
style="padding-left: 15px"/></a>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="statsmodels.tsa.arima_model.ARIMAResults.conf_int.html" title="statsmodels.tsa.arima_model.ARIMAResults.conf_int"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="statsmodels.tsa.arima_model.ARIMAResults.arfreq.html" title="statsmodels.tsa.arima_model.ARIMAResults.arfreq"
accesskey="P">previous</a> |</li>
<li><a href ="../install.html">Install</a></li> |
<li><a href="https://groups.google.com/forum/?hl=en#!forum/pystatsmodels">Support</a></li> |
<li><a href="https://github.com/statsmodels/statsmodels/issues">Bugs</a></li> |
<li><a href="../dev/index.html">Develop</a></li> |
<li><a href="../examples/index.html">Examples</a></li> |
<li><a href="../faq.html">FAQ</a></li> |
<li class="nav-item nav-item-1"><a href="../tsa.html" >Time Series analysis <code class="xref py py-mod docutils literal notranslate"><span class="pre">tsa</span></code></a> |</li>
<li class="nav-item nav-item-2"><a href="statsmodels.tsa.arima_model.ARIMAResults.html" accesskey="U">statsmodels.tsa.arima_model.ARIMAResults</a> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="statsmodels-tsa-arima-model-arimaresults-bse">
<h1>statsmodels.tsa.arima_model.ARIMAResults.bse<a class="headerlink" href="#statsmodels-tsa-arima-model-arimaresults-bse" title="Permalink to this headline">¶</a></h1>
<p>method</p>
<dl class="method">
<dt id="statsmodels.tsa.arima_model.ARIMAResults.bse">
<code class="sig-prename descclassname">ARIMAResults.</code><code class="sig-name descname">bse</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#statsmodels.tsa.arima_model.ARIMAResults.bse" title="Permalink to this definition">¶</a></dt>
<dd><p>The standard errors of the parameter estimates.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="statsmodels.tsa.arima_model.ARIMAResults.arfreq.html"
title="previous chapter">statsmodels.tsa.arima_model.ARIMAResults.arfreq</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="statsmodels.tsa.arima_model.ARIMAResults.conf_int.html"
title="next chapter">statsmodels.tsa.arima_model.ARIMAResults.conf_int</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/generated/statsmodels.tsa.arima_model.ARIMAResults.bse.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer" role="contentinfo">
© Copyright 2009-2018, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2.
</div>
</body>
</html> | statsmodels/statsmodels.github.io | v0.10.0/generated/statsmodels.tsa.arima_model.ARIMAResults.bse.html | HTML | bsd-3-clause | 7,388 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
20950,
3619,
1027,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
2639,
1013,
1060,
11039,
19968,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_EVENT_LISTENER_MAP_H_
#define EXTENSIONS_BROWSER_EVENT_LISTENER_MAP_H_
#include <map>
#include <set>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/common/event_filter.h"
#include "url/gurl.h"
namespace base {
class DictionaryValue;
}
namespace content {
class BrowserContext;
class RenderProcessHost;
}
class ListenerRemovalListener;
namespace extensions {
struct Event;
// A listener for an extension event. A listener is essentially an endpoint
// that an event can be dispatched to.
//
// This is a lazy listener if |IsLazy| is returns true, and a filtered listener
// if |filter| is defined.
//
// A lazy listener is added to an event to indicate that a lazy background page
// is listening to the event. It is associated with no process, so to dispatch
// an event to a lazy listener one must start a process running the associated
// extension and dispatch the event to that.
class EventListener {
public:
// Constructs EventListeners for either an Extension or a URL.
//
// |filter| represents a generic filter structure that EventFilter knows how
// to filter events with. A typical filter instance will look like
//
// {
// url: [{hostSuffix: 'google.com'}],
// tabId: 5
// }
static scoped_ptr<EventListener> ForExtension(
const std::string& event_name,
const std::string& extension_id,
content::RenderProcessHost* process,
scoped_ptr<base::DictionaryValue> filter);
static scoped_ptr<EventListener> ForURL(
const std::string& event_name,
const GURL& listener_url,
content::RenderProcessHost* process,
scoped_ptr<base::DictionaryValue> filter);
~EventListener();
bool Equals(const EventListener* other) const;
scoped_ptr<EventListener> Copy() const;
// Returns true in the case of a lazy background page, and thus no process.
bool IsLazy() const;
// Modifies this listener to be a lazy listener, clearing process references.
void MakeLazy();
// Returns the browser context associated with the listener, or NULL if
// IsLazy.
content::BrowserContext* GetBrowserContext() const;
const std::string& event_name() const { return event_name_; }
const std::string& extension_id() const { return extension_id_; }
const GURL& listener_url() const { return listener_url_; }
content::RenderProcessHost* process() const { return process_; }
base::DictionaryValue* filter() const { return filter_.get(); }
EventFilter::MatcherID matcher_id() const { return matcher_id_; }
void set_matcher_id(EventFilter::MatcherID id) { matcher_id_ = id; }
private:
EventListener(const std::string& event_name,
const std::string& extension_id,
const GURL& listener_url,
content::RenderProcessHost* process,
scoped_ptr<base::DictionaryValue> filter);
const std::string event_name_;
const std::string extension_id_;
const GURL listener_url_;
content::RenderProcessHost* process_;
scoped_ptr<base::DictionaryValue> filter_;
EventFilter::MatcherID matcher_id_; // -1 if unset.
DISALLOW_COPY_AND_ASSIGN(EventListener);
};
// Holds listeners for extension events and can answer questions about which
// listeners are interested in what events.
class EventListenerMap {
public:
typedef std::vector<linked_ptr<EventListener> > ListenerList;
class Delegate {
public:
virtual ~Delegate() {}
virtual void OnListenerAdded(const EventListener* listener) = 0;
virtual void OnListenerRemoved(const EventListener* listener) = 0;
};
explicit EventListenerMap(Delegate* delegate);
~EventListenerMap();
// Add a listener for a particular event. GetEventListeners() will include a
// weak pointer to |listener| in its results if passed a relevant
// extensions::Event.
// Returns true if the listener was added (in the case that it has never been
// seen before).
bool AddListener(scoped_ptr<EventListener> listener);
// Remove a listener that .Equals() |listener|.
// Returns true if the listener was removed .
bool RemoveListener(const EventListener* listener);
// Returns the set of listeners that want to be notified of |event|.
std::set<const EventListener*> GetEventListeners(const Event& event);
const ListenerList& GetEventListenersByName(const std::string& event_name) {
return listeners_[event_name];
}
// Removes all listeners with process equal to |process|.
void RemoveListenersForProcess(const content::RenderProcessHost* process);
// Returns true if there are any listeners on the event named |event_name|.
bool HasListenerForEvent(const std::string& event_name);
// Returns true if there are any listeners on |event_name| from
// |extension_id|.
bool HasListenerForExtension(const std::string& extension_id,
const std::string& event_name,
int instance_id = -1,
std::string* out_extension_id = nullptr);
// Returns true if this map contains an EventListener that .Equals()
// |listener|.
bool HasListener(const EventListener* listener);
// Returns true if there is a listener for |extension_id| in |process|.
bool HasProcessListener(content::RenderProcessHost* process,
const std::string& extension_id);
// Removes any listeners that |extension_id| has added, both lazy and regular.
void RemoveListenersForExtension(const std::string& extension_id);
// Adds unfiltered lazy listeners as described their serialised descriptions.
// |event_names| the names of the lazy events.
// Note that we can only load lazy listeners in this fashion, because there
// is no way to serialise a RenderProcessHost*.
void LoadUnfilteredLazyListeners(const std::string& extension_id,
const std::set<std::string>& event_names);
// Adds filtered lazy listeners as described their serialised descriptions.
// |filtered| contains a map from event names to filters, each pairing
// defining a lazy filtered listener.
void LoadFilteredLazyListeners(
const std::string& extension_id,
const base::DictionaryValue& filtered);
private:
// The key here is an event name.
typedef std::map<std::string, ListenerList> ListenerMap;
void CleanupListener(EventListener* listener);
bool IsFilteredEvent(const Event& event) const;
scoped_ptr<EventMatcher> ParseEventMatcher(
base::DictionaryValue* filter_dict);
// Listens for removals from this map.
Delegate* delegate_;
std::set<std::string> filtered_events_;
ListenerMap listeners_;
std::map<EventFilter::MatcherID, EventListener*> listeners_by_matcher_id_;
EventFilter event_filter_;
DISALLOW_COPY_AND_ASSIGN(EventListenerMap);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_EVENT_LISTENER_MAP_H_
| was4444/chromium.src | extensions/browser/event_listener_map.h | C | bsd-3-clause | 7,097 | [
30522,
1013,
1013,
9385,
2286,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
2008,
2064,
2022,
1013,
1013,
2179,
1999,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* CircularLinkedList implementation
* @author Tyler Smith
* @version 1.0
*/
public class CircularLinkedList<T> implements LinkedListInterface<T> {
private Node<T> head = null, tail = head;
private int size = 0;
@Override
public void addAtIndex(int index, T data) {
if (index < 0 || index > this.size()) {
throw new IndexOutOfBoundsException();
}
if (index == 0) {
this.addToFront(data);
} else if (index == this.size()) {
this.addToBack(data);
} else {
Node<T> current = head;
if (index == 1) {
current.setNext(new Node<T>(data, current.getNext()));
} else {
for (int i = 0; i < index - 1; i++) {
current = current.getNext();
}
Node<T> temp = current;
current = new Node<T>(data, temp);
}
size++;
}
}
@Override
public T get(int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
Node<T> current = head;
for (int i = 0; i < index; i++) {
current = current.getNext();
}
return current.getData();
}
@Override
public T removeAtIndex(int index) {
if (index < 0 || index >= this.size()) {
throw new IndexOutOfBoundsException();
}
if (index == 0) {
T data = head.getData();
head = head.getNext();
tail.setNext(head);
size--;
return data;
} else {
Node<T> before = tail;
Node<T> current = head;
for (int i = 0; i < index; i++) {
before = current;
current = current.getNext();
}
T data = current.getData();
before.setNext(current.getNext());
size--;
return data;
}
}
@Override
public void addToFront(T t) {
if (this.isEmpty()) {
head = new Node<T>(t, tail);
tail = head;
tail.setNext(head);
size++;
return;
}
Node<T> node = new Node<T>(t, head);
head = node;
tail.setNext(head);
size++;
}
@Override
public void addToBack(T t) {
if (this.isEmpty()) {
tail = new Node<T>(t);
head = tail;
tail.setNext(head);
head.setNext(tail);
size++;
} else {
Node<T> temp = tail;
tail = new Node<T>(t, head);
temp.setNext(tail);
size++;
}
}
@Override
public T removeFromFront() {
if (this.isEmpty()) {
return null;
}
Node<T> ret = head;
head = head.getNext();
tail.setNext(head);
size--;
return ret.getData();
}
@Override
public T removeFromBack() {
if (this.isEmpty()) {
return null;
}
Node<T> iterate = head;
while (iterate.getNext() != tail) {
iterate = iterate.getNext();
}
iterate.setNext(head);
Node<T> ret = tail;
tail = iterate;
size--;
return ret.getData();
}
@SuppressWarnings("unchecked")
@Override
public T[] toList() {
Object[] list = new Object[this.size()];
int i = 0;
Node<T> current = head;
while (i < this.size()) {
list[i] = current.getData();
current = current.getNext();
i++;
}
return ((T[]) list);
}
@Override
public boolean isEmpty() {
return (this.size() == 0);
}
@Override
public int size() {
return size;
}
@Override
public void clear() {
head = null;
tail = null;
size = 0;
}
/**
* Reference to the head node of the linked list.
* Normally, you would not do this, but we need it
* for grading your work.
*
* @return Node representing the head of the linked list
*/
public Node<T> getHead() {
return head;
}
/**
* Reference to the tail node of the linked list.
* Normally, you would not do this, but we need it
* for grading your work.
*
* @return Node representing the tail of the linked list
*/
public Node<T> getTail() {
return tail;
}
/**
* This method is for your testing purposes.
* You may choose to implement it if you wish.
*/
@Override
public String toString() {
return "";
}
}
| tsmith328/Homework | Java/CS 1332/Homework 01/CircularLinkedList.java | Java | mit | 4,722 | [
30522,
1013,
1008,
1008,
1008,
8206,
13767,
2098,
9863,
7375,
1008,
1030,
3166,
7482,
3044,
1008,
1030,
2544,
1015,
1012,
1014,
1008,
1013,
2270,
2465,
8206,
13767,
2098,
9863,
1026,
1056,
1028,
22164,
5799,
9863,
18447,
2121,
12172,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.transfer;
import org.alfresco.service.cmr.transfer.TransferTarget;
import org.alfresco.service.cmr.transfer.TransferVersion;
/**
* Information about a transfer which is in progress.
*
* @author Mark Rogers
*/
public class Transfer
{
private String transferId;
private TransferTarget transferTarget;
private TransferVersion toVersion;
public void setTransferId(String transferId)
{
this.transferId = transferId;
}
public String getTransferId()
{
return transferId;
}
// may also have capabilities of the remote system here (for when we are
// transfering accross versions)
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
else if (this == obj)
{
return true;
}
else if (obj instanceof Transfer == false)
{
return false;
}
Transfer that = (Transfer) obj;
return (this.transferId.equals(that.getTransferId()));
}
public int hashCode()
{
return transferId.hashCode();
}
/**
* @param target
*/
public void setTransferTarget(TransferTarget target)
{
this.transferTarget = target;
}
/**
* @return the transferTarget
*/
public TransferTarget getTransferTarget()
{
return transferTarget;
}
public String toString()
{
return "TransferId" + transferId + ", target:" + transferTarget ;
}
public void setToVersion(TransferVersion toVersion)
{
this.toVersion = toVersion;
}
public TransferVersion getToVersion()
{
return toVersion;
}
}
| daniel-he/community-edition | projects/repository/source/java/org/alfresco/repo/transfer/Transfer.java | Java | lgpl-3.0 | 2,608 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2384,
1011,
2230,
24493,
6072,
3597,
4007,
3132,
1012,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
24493,
6072,
3597,
1008,
1008,
24493,
6072,
3597,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Technocraft</title>
<link rel="stylesheet" href="helpers.css" />
<!--Font-->
<link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | Technocraft/Technocraft-Main-Site | store/head.html | HTML | mit | 570 | [
30522,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
4180,
1027,
1000,
9381,
1027,
5080,
1011,
9381,
1010,
3988,
1011,
4094,
1027,
1015,
1010,
4555,
1011,
4094,
1027,
1015,
1000,
1028,
1026,
2516,
1028,
21416,
10419,
1026,
1013,
2516,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Defines for the MSP interrupt controller.
*
* Copyright (C) 1999 MIPS Technologies, Inc. All rights reserved.
* Author: Carsten Langgaard, carstenl@mips.com
*
* ########################################################################
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*
* ########################################################################
*/
#ifndef _MSP_CIC_INT_H
#define _MSP_CIC_INT_H
/*
* The PMC-Sierra CIC interrupts are all centrally managed by the
* CIC sub-system.
* We attempt to keep the interrupt numbers as consistent as possible
* across all of the MSP devices, but some differences will creep in ...
* The interrupts which are directly forwarded to the MIPS core interrupts
* are assigned interrupts in the range 0-7, interrupts cascaded through
* the CIC are assigned interrupts 8-39. The cascade occurs on C_IRQ4
* (MSP_INT_CIC). Currently we don't really distinguish between VPE1
* and VPE0 (or thread contexts for that matter). Will have to fix.
* The PER interrupts are assigned interrupts in the range 40-71.
*/
/*
* IRQs directly forwarded to the CPU
*/
#define MSP_MIPS_INTBASE 0
#define MSP_INT_SW0 0 /* IRQ for swint0, C_SW0 */
#define MSP_INT_SW1 1 /* IRQ for swint1, C_SW1 */
#define MSP_INT_MAC0 2 /* IRQ for MAC 0, C_IRQ0 */
#define MSP_INT_MAC1 3 /* IRQ for MAC 1, C_IRQ1 */
#define MSP_INT_USB 4 /* IRQ for USB, C_IRQ2 */
#define MSP_INT_SAR 5 /* IRQ for ADSL2+ SAR, C_IRQ3 */
#define MSP_INT_CIC 6 /* IRQ for CIC block, C_IRQ4 */
#define MSP_INT_SEC 7 /* IRQ for Sec engine, C_IRQ5 */
/*
* IRQs cascaded on CPU interrupt 4 (CAUSE bit 12, C_IRQ4)
* These defines should be tied to the register definitions for the CIC
* interrupt routine. For now, just use hard-coded values.
*/
#define MSP_CIC_INTBASE (MSP_MIPS_INTBASE + 8)
#define MSP_INT_EXT0 (MSP_CIC_INTBASE + 0)
/* External interrupt 0 */
#define MSP_INT_EXT1 (MSP_CIC_INTBASE + 1)
/* External interrupt 1 */
#define MSP_INT_EXT2 (MSP_CIC_INTBASE + 2)
/* External interrupt 2 */
#define MSP_INT_EXT3 (MSP_CIC_INTBASE + 3)
/* External interrupt 3 */
#define MSP_INT_CPUIF (MSP_CIC_INTBASE + 4)
/* CPU interface interrupt */
#define MSP_INT_EXT4 (MSP_CIC_INTBASE + 5)
/* External interrupt 4 */
#define MSP_INT_CIC_USB (MSP_CIC_INTBASE + 6)
/* Cascaded IRQ for USB */
#define MSP_INT_MBOX (MSP_CIC_INTBASE + 7)
/* Sec engine mailbox IRQ */
#define MSP_INT_EXT5 (MSP_CIC_INTBASE + 8)
/* External interrupt 5 */
#define MSP_INT_TDM (MSP_CIC_INTBASE + 9)
/* TDM interrupt */
#define MSP_INT_CIC_MAC0 (MSP_CIC_INTBASE + 10)
/* Cascaded IRQ for MAC 0 */
#define MSP_INT_CIC_MAC1 (MSP_CIC_INTBASE + 11)
/* Cascaded IRQ for MAC 1 */
#define MSP_INT_CIC_SEC (MSP_CIC_INTBASE + 12)
/* Cascaded IRQ for sec engine */
#define MSP_INT_PER (MSP_CIC_INTBASE + 13)
/* Peripheral interrupt */
#define MSP_INT_TIMER0 (MSP_CIC_INTBASE + 14)
/* SLP timer 0 */
#define MSP_INT_TIMER1 (MSP_CIC_INTBASE + 15)
/* SLP timer 1 */
#define MSP_INT_TIMER2 (MSP_CIC_INTBASE + 16)
/* SLP timer 2 */
#define MSP_INT_VPE0_TIMER (MSP_CIC_INTBASE + 17)
/* VPE0 MIPS timer */
#define MSP_INT_BLKCP (MSP_CIC_INTBASE + 18)
/* Block Copy */
#define MSP_INT_UART0 (MSP_CIC_INTBASE + 19)
/* UART 0 */
#define MSP_INT_PCI (MSP_CIC_INTBASE + 20)
/* PCI subsystem */
#define MSP_INT_EXT6 (MSP_CIC_INTBASE + 21)
/* External interrupt 5 */
#define MSP_INT_PCI_MSI (MSP_CIC_INTBASE + 22)
/* PCI Message Signal */
#define MSP_INT_CIC_SAR (MSP_CIC_INTBASE + 23)
/* Cascaded ADSL2+ SAR IRQ */
#define MSP_INT_DSL (MSP_CIC_INTBASE + 24)
/* ADSL2+ IRQ */
#define MSP_INT_CIC_ERR (MSP_CIC_INTBASE + 25)
/* SLP error condition */
#define MSP_INT_VPE1_TIMER (MSP_CIC_INTBASE + 26)
/* VPE1 MIPS timer */
#define MSP_INT_VPE0_PC (MSP_CIC_INTBASE + 27)
/* VPE0 Performance counter */
#define MSP_INT_VPE1_PC (MSP_CIC_INTBASE + 28)
/* VPE1 Performance counter */
#define MSP_INT_EXT7 (MSP_CIC_INTBASE + 29)
/* External interrupt 5 */
#define MSP_INT_VPE0_SW (MSP_CIC_INTBASE + 30)
/* VPE0 Software interrupt */
#define MSP_INT_VPE1_SW (MSP_CIC_INTBASE + 31)
/* VPE0 Software interrupt */
/*
* IRQs cascaded on CIC PER interrupt (MSP_INT_PER)
*/
#define MSP_PER_INTBASE (MSP_CIC_INTBASE + 32)
/* Reserved 0-1 */
#define MSP_INT_UART1 (MSP_PER_INTBASE + 2)
/* UART 1 */
/* Reserved 3-5 */
#define MSP_INT_2WIRE (MSP_PER_INTBASE + 6)
/* 2-wire */
#define MSP_INT_TM0 (MSP_PER_INTBASE + 7)
/* Peripheral timer block out 0 */
#define MSP_INT_TM1 (MSP_PER_INTBASE + 8)
/* Peripheral timer block out 1 */
/* Reserved 9 */
#define MSP_INT_SPRX (MSP_PER_INTBASE + 10)
/* SPI RX complete */
#define MSP_INT_SPTX (MSP_PER_INTBASE + 11)
/* SPI TX complete */
#define MSP_INT_GPIO (MSP_PER_INTBASE + 12)
/* GPIO */
#define MSP_INT_PER_ERR (MSP_PER_INTBASE + 13)
/* Peripheral error */
/* Reserved 14-31 */
#endif /* !_MSP_CIC_INT_H */
| Jackeagle/android_kernel_sony_c2305 | arch/mips/include/asm/pmc-sierra/msp71xx/msp_cic_int.h | C | gpl-2.0 | 6,376 | [
30522,
1013,
1008,
1008,
11859,
2005,
1996,
5796,
2361,
17938,
11486,
1012,
1008,
1008,
9385,
1006,
1039,
1007,
2639,
2771,
4523,
6786,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
3166,
1024,
3765,
6528,
11374,
18839,
1010,
3765,
6528,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.future.panels;
import javax.swing.JPanel;
public class PanelFactory {
public static JPanel createPanel(String name)
{
JPanel panel;
if(name.equals("SettingPanel"))
{
panel=new SettingPanel();
}else
{
panel=new MainPanel();
}
return panel;
}
}
| simpher/FutureStrategy | src/com/future/panels/PanelFactory.java | Java | apache-2.0 | 298 | [
30522,
7427,
4012,
1012,
2925,
1012,
9320,
1025,
12324,
9262,
2595,
1012,
7370,
1012,
16545,
7231,
2140,
1025,
2270,
2465,
5997,
21450,
1063,
2270,
10763,
16545,
7231,
2140,
3443,
9739,
2884,
1006,
5164,
2171,
1007,
1063,
16545,
7231,
2140,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2010,
* Gavriloaie Eugen-Andrei (shiretu@gmail.com)
*
* This file is part of crtmpserver.
* crtmpserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* crtmpserver 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 crtmpserver. If not, see <http://www.gnu.org/licenses/>.
*/
#include "protocols/baseprotocol.h"
#include "vptestsapplication.h"
#include "rtmpappprotocolhandler.h"
#include "variantappprotocolhandler.h"
using namespace app_vptests;
VPTestsApplication::VPTestsApplication(Variant &configuration)
: BaseClientApplication(configuration) {
#ifdef HAS_PROTOCOL_RTMP
_pRTMPHandler = NULL;
#endif /* HAS_PROTOCOL_RTMP */
#ifdef HAS_PROTOCOL_VAR
_pVariantHandler = NULL;
#endif /* HAS_PROTOCOL_RTMP */
}
VPTestsApplication::~VPTestsApplication() {
#ifdef HAS_PROTOCOL_RTMP
UnRegisterAppProtocolHandler(PT_INBOUND_RTMP);
UnRegisterAppProtocolHandler(PT_OUTBOUND_RTMP);
if (_pRTMPHandler != NULL) {
delete _pRTMPHandler;
_pRTMPHandler = NULL;
}
#endif /* HAS_PROTOCOL_RTMP */
#ifdef HAS_PROTOCOL_VAR
UnRegisterAppProtocolHandler(PT_BIN_VAR);
UnRegisterAppProtocolHandler(PT_XML_VAR);
if (_pVariantHandler != NULL) {
delete _pVariantHandler;
_pVariantHandler = NULL;
}
#endif /* HAS_PROTOCOL_VAR */
}
bool VPTestsApplication::Initialize() {
//TODO: Add your app init code here
//Things like parsing custom sections inside _configuration for example,
//initialize the protocol handler(s)
//1. Initialize the protocol handler(s)
#ifdef HAS_PROTOCOL_RTMP
_pRTMPHandler = new RTMPAppProtocolHandler(_configuration);
RegisterAppProtocolHandler(PT_INBOUND_RTMP, _pRTMPHandler);
RegisterAppProtocolHandler(PT_OUTBOUND_RTMP, _pRTMPHandler);
#endif /* HAS_PROTOCOL_RTMP */
#ifdef HAS_PROTOCOL_VAR
_pVariantHandler = new VariantAppProtocolHandler(_configuration);
RegisterAppProtocolHandler(PT_BIN_VAR, _pVariantHandler);
RegisterAppProtocolHandler(PT_XML_VAR, _pVariantHandler);
#endif /* HAS_PROTOCOL_VAR */
return true;
}
| madhawa/rtmpdplus | sources/applications/vptests/src/vptestsapplication.cpp | C++ | gpl-3.0 | 2,455 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
1010,
1008,
11721,
19716,
22360,
4886,
2063,
29273,
1011,
18125,
1006,
13182,
8525,
1030,
20917,
4014,
1012,
4012,
1007,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
13675,
21246,
29251,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.domain.BeaconDeviceInfo;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.mobile.beacon.device.query response.
*
* @author auto create
* @since 1.0, 2017-02-28 11:12:47
*/
public class AlipayMobileBeaconDeviceQueryResponse extends AlipayResponse {
private static final long serialVersionUID = 4743812712573537958L;
/**
* 蓝牙设备信息
*/
@ApiField("beacon_device_info")
private BeaconDeviceInfo beaconDeviceInfo;
/**
* 操作返回码,200为成功
*/
@ApiField("code")
private String code;
/**
* 请求处理结果
*/
@ApiField("msg")
private String msg;
public void setBeaconDeviceInfo(BeaconDeviceInfo beaconDeviceInfo) {
this.beaconDeviceInfo = beaconDeviceInfo;
}
public BeaconDeviceInfo getBeaconDeviceInfo( ) {
return this.beaconDeviceInfo;
}
public void setCode(String code) {
this.code = code;
}
public String getCode( ) {
return this.code;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg( ) {
return this.msg;
}
}
| wendal/alipay-sdk | src/main/java/com/alipay/api/response/AlipayMobileBeaconDeviceQueryResponse.java | Java | apache-2.0 | 1,140 | [
30522,
7427,
4012,
1012,
4862,
4502,
2100,
1012,
17928,
1012,
3433,
1025,
12324,
4012,
1012,
4862,
4502,
2100,
1012,
17928,
1012,
4722,
1012,
12375,
1012,
30524,
4012,
1012,
4862,
4502,
2100,
1012,
17928,
1012,
5884,
1012,
14400,
24844,
661... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head lang="ru">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Template</title>
<link href="http://themesanytime.com/startui/demo/img/favicon.144x144.png" rel="apple-touch-icon" type="image/png" sizes="144x144">
<link href="http://themesanytime.com/startui/demo/img/favicon.114x114.png" rel="apple-touch-icon" type="image/png" sizes="114x114">
<link href="http://themesanytime.com/startui/demo/img/favicon.72x72.png" rel="apple-touch-icon" type="image/png" sizes="72x72">
<link href="http://themesanytime.com/startui/demo/img/favicon.57x57.png" rel="apple-touch-icon" type="image/png">
<link href="http://themesanytime.com/startui/demo/img/favicon.png" rel="icon" type="image/png">
<link href="http://themesanytime.com/startui/demo/img/favicon.ico" rel="shortcut icon">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="js/plugins.js"></script>
<script src="js/app.js"></script>
<link rel="stylesheet" href="css/lib/font-awesome/font-awesome.min.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header class="site-header">
<div class="container-fluid">
<a href="profile.html#" class="site-logo">
<img class="hidden-md-down" src="img/logo-2.png" alt="">
<img class="hidden-lg-up" src="img/logo-2-mob.png" alt="">
</a>
<button class="hamburger hamburger--htla">
<span>toggle menu</span>
</button>
<div class="site-header-content">
<div class="site-header-content-in">
<div class="site-header-shown">
<div class="dropdown dropdown-notification notif">
<a href="profile.html#"
class="header-alarm dropdown-toggle active"
id="dd-notification"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<i class="font-icon-alarm"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-notif" aria-labelledby="dd-notification">
<div class="dropdown-menu-notif-header">
Notifications
<span class="label label-pill label-danger">4</span>
</div>
<div class="dropdown-menu-notif-list">
<div class="dropdown-menu-notif-item">
<div class="photo">
<img src="img/photo-64-1.jpg" alt="">
</div>
<div class="dot"></div>
<a href="profile.html#">Morgan</a> was bothering about something
<div class="color-blue-grey-lighter">7 hours ago</div>
</div>
<div class="dropdown-menu-notif-item">
<div class="photo">
<img src="img/photo-64-2.jpg" alt="">
</div>
<div class="dot"></div>
<a href="profile.html#">Lioneli</a> had commented on this <a href="profile.html#">Super Important Thing</a>
<div class="color-blue-grey-lighter">7 hours ago</div>
</div>
<div class="dropdown-menu-notif-item">
<div class="photo">
<img src="img/photo-64-3.jpg" alt="">
</div>
<div class="dot"></div>
<a href="profile.html#">Xavier</a> had commented on the <a href="profile.html#">Movie title</a>
<div class="color-blue-grey-lighter">7 hours ago</div>
</div>
<div class="dropdown-menu-notif-item">
<div class="photo">
<img src="img/photo-64-4.jpg" alt="">
</div>
<a href="profile.html#">Lionely</a> wants to go to <a href="profile.html#">Cinema</a> with you to see <a href="profile.html#">This Movie</a>
<div class="color-blue-grey-lighter">7 hours ago</div>
</div>
</div>
<div class="dropdown-menu-notif-more">
<a href="profile.html#">See more</a>
</div>
</div>
</div>
<div class="dropdown dropdown-notification messages">
<a href="profile.html#"
class="header-alarm dropdown-toggle active"
id="dd-messages"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<i class="font-icon-mail"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-messages" aria-labelledby="dd-messages">
<div class="dropdown-menu-messages-header">
<ul class="nav" role="tablist">
<li class="nav-item">
<a class="nav-link active"
data-toggle="tab"
href="profile.html#tab-incoming"
role="tab">
Inbox
<span class="label label-pill label-danger">8</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link"
data-toggle="tab"
href="profile.html#tab-outgoing"
role="tab">Outbox</a>
</li>
</ul>
<!--<button type="button" class="create">
<i class="font-icon font-icon-pen-square"></i>
</button>-->
</div>
<div class="tab-content">
<div class="tab-pane active" id="tab-incoming" role="tabpanel">
<div class="dropdown-menu-messages-list">
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/photo-64-2.jpg" alt=""></span>
<span class="mess-item-name">Tim Collins</span>
<span class="mess-item-txt">Morgan was bothering about something!</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/avatar-2-64.png" alt=""></span>
<span class="mess-item-name">Christian Burton</span>
<span class="mess-item-txt">Morgan was bothering about something! Morgan was bothering about something.</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/photo-64-2.jpg" alt=""></span>
<span class="mess-item-name">Tim Collins</span>
<span class="mess-item-txt">Morgan was bothering about something!</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/avatar-2-64.png" alt=""></span>
<span class="mess-item-name">Christian Burton</span>
<span class="mess-item-txt">Morgan was bothering about something...</span>
</a>
</div>
</div>
<div class="tab-pane" id="tab-outgoing" role="tabpanel">
<div class="dropdown-menu-messages-list">
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/avatar-2-64.png" alt=""></span>
<span class="mess-item-name">Christian Burton</span>
<span class="mess-item-txt">Morgan was bothering about something! Morgan was bothering about something...</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/photo-64-2.jpg" alt=""></span>
<span class="mess-item-name">Tim Collins</span>
<span class="mess-item-txt">Morgan was bothering about something! Morgan was bothering about something.</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/avatar-2-64.png" alt=""></span>
<span class="mess-item-name">Christian Burtons</span>
<span class="mess-item-txt">Morgan was bothering about something!</span>
</a>
<a href="profile.html#" class="mess-item">
<span class="avatar-preview avatar-preview-32"><img src="img/photo-64-2.jpg" alt=""></span>
<span class="mess-item-name">Tim Collins</span>
<span class="mess-item-txt">Morgan was bothering about something!</span>
</a>
</div>
</div>
</div>
<div class="dropdown-menu-notif-more">
<a href="profile.html#">See more</a>
</div>
</div>
</div>
<div class="dropdown dropdown-lang">
<button class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="flag-icon flag-icon-us"></span>
</button>
<div class="dropdown-menu dropdown-menu-right">
<div class="dropdown-menu-col">
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-ru"></span>Русский</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-de"></span>Deutsch</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-it"></span>Italiano</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-es"></span>Español</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-pl"></span>Polski</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-li"></span>Lietuviu</a>
</div>
<div class="dropdown-menu-col">
<a class="dropdown-item current" href="profile.html#"><span class="flag-icon flag-icon-us"></span>English</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-fr"></span>Français</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-by"></span>Беларускi</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-ua"></span>Українська</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-cz"></span>Česky</a>
<a class="dropdown-item" href="profile.html#"><span class="flag-icon flag-icon-ch"></span>中國</a>
</div>
</div>
</div>
<div class="dropdown user-menu">
<button class="dropdown-toggle" id="dd-user-menu" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="img/avatar-2-64.png" alt="">
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dd-user-menu">
<a class="dropdown-item" href="profile.html#"><span class="font-icon glyphicon glyphicon-user"></span>Profile</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon glyphicon glyphicon-cog"></span>Settings</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon glyphicon glyphicon-question-sign"></span>Help</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="profile.html#"><span class="font-icon glyphicon glyphicon-log-out"></span>Logout</a>
</div>
</div>
<button type="button" class="burger-right">
<i class="font-icon-menu-addl"></i>
</button>
</div><!--.site-header-shown-->
<div class="mobile-menu-right-overlay"></div>
<div class="site-header-collapsed">
<div class="site-header-collapsed-in">
<div class="dropdown dropdown-typical">
<a class="dropdown-toggle" id="dd-header-sales" data-target="#" href="http://example.com" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="font-icon font-icon-wallet"></span>
<span class="lbl">Sales</span>
</a>
<div class="dropdown-menu" aria-labelledby="dd-header-sales">
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
</div>
</div>
<div class="dropdown dropdown-typical">
<a class="dropdown-toggle" id="dd-header-marketing" data-target="#" href="http://example.com" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="font-icon font-icon-cogwheel"></span>
<span class="lbl">Marketing automation</span>
</a>
<div class="dropdown-menu" aria-labelledby="dd-header-marketing">
<a class="dropdown-item" href="profile.html#">Current Search</a>
<a class="dropdown-item" href="profile.html#">Search for Issues</a>
<div class="dropdown-divider"></div>
<div class="dropdown-header">Recent issues</div>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
<div class="dropdown-more">
<div class="dropdown-more-caption padding">more...</div>
<div class="dropdown-more-sub">
<div class="dropdown-more-sub-in">
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
</div>
</div>
</div>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="profile.html#">Import Issues from CSV</a>
<div class="dropdown-divider"></div>
<div class="dropdown-header">Filters</div>
<a class="dropdown-item" href="profile.html#">My Open Issues</a>
<a class="dropdown-item" href="profile.html#">Reported by Me</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="profile.html#">Manage filters</a>
<div class="dropdown-divider"></div>
<div class="dropdown-header">Timesheet</div>
<a class="dropdown-item" href="profile.html#">Subscribtions</a>
</div>
</div>
<div class="dropdown dropdown-typical">
<a class="dropdown-toggle" id="dd-header-social" data-target="#" href="http://example.com" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="font-icon font-icon-share"></span>
<span class="lbl">Social media</span>
</a>
<div class="dropdown-menu" aria-labelledby="dd-header-social">
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
</div>
</div>
<div class="dropdown dropdown-typical">
<a href="profile.html#" class="dropdown-toggle no-arr">
<span class="font-icon font-icon-page"></span>
<span class="lbl">Projects</span>
<span class="label label-pill label-danger">35</span>
</a>
</div>
<div class="dropdown dropdown-typical">
<a class="dropdown-toggle" id="dd-header-form-builder" data-target="#" href="http://example.com" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="font-icon font-icon-pencil"></span>
<span class="lbl">Form builder</span>
</a>
<div class="dropdown-menu" aria-labelledby="dd-header-form-builder">
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
</div>
</div>
<div class="dropdown">
<button class="btn btn-rounded dropdown-toggle" id="dd-header-add" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Add
</button>
<div class="dropdown-menu" aria-labelledby="dd-header-add">
<a class="dropdown-item" href="profile.html#">Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#">Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#">Prep Official App</a>
<a class="dropdown-item" href="profile.html#">CATprer Test</a>
<a class="dropdown-item" href="profile.html#">Third Party Test</a>
</div>
</div>
<div class="help-dropdown">
<button type="button">
<i class="font-icon font-icon-help"></i>
</button>
<div class="help-dropdown-popup">
<div class="help-dropdown-popup-side">
<ul>
<li><a href="profile.html#">Getting Started</a></li>
<li><a href="profile.html#" class="active">Creating a new project</a></li>
<li><a href="profile.html#">Adding customers</a></li>
<li><a href="profile.html#">Settings</a></li>
<li><a href="profile.html#">Importing data</a></li>
<li><a href="profile.html#">Exporting data</a></li>
</ul>
</div>
<div class="help-dropdown-popup-cont">
<div class="help-dropdown-popup-cont-in">
<div class="jscroll">
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum is simply
<span class="describe">Lorem Ipsum has been the industry's standard dummy text </span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Contrary to popular belief
<span class="describe">Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
The point of using Lorem Ipsum
<span class="describe">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum
<span class="describe">There are many variations of passages of Lorem Ipsum available</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum is simply
<span class="describe">Lorem Ipsum has been the industry's standard dummy text </span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Contrary to popular belief
<span class="describe">Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
The point of using Lorem Ipsum
<span class="describe">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum
<span class="describe">There are many variations of passages of Lorem Ipsum available</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum is simply
<span class="describe">Lorem Ipsum has been the industry's standard dummy text </span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Contrary to popular belief
<span class="describe">Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
The point of using Lorem Ipsum
<span class="describe">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text</span>
</a>
<a href="profile.html#" class="help-dropdown-popup-item">
Lorem Ipsum
<span class="describe">There are many variations of passages of Lorem Ipsum available</span>
</a>
</div>
</div>
</div>
</div>
</div><!--.help-dropdown-->
<div class="site-header-search-container">
<form class="site-header-search closed">
<input type="text" placeholder="Search"/>
<button type="submit">
<span class="font-icon-search"></span>
</button>
<div class="overlay"></div>
</form>
</div>
</div><!--.site-header-collapsed-in-->
</div><!--.site-header-collapsed-->
</div><!--site-header-content-in-->
</div><!--.site-header-content-->
</div><!--.container-fluid-->
</header><!--.site-header-->
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6 col-lg-push-3 col-md-12">
<form class="box-typical">
<input type="text" class="write-something" placeholder="Write Something..."/>
<div class="box-typical-footer">
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<button type="button" class="btn-icon">
<i class="font-icon font-icon-earth"></i>
</button>
<button type="button" class="btn-icon">
<i class="font-icon font-icon-picture"></i>
</button>
<button type="button" class="btn-icon">
<i class="font-icon font-icon-calend"></i>
</button>
<button type="button" class="btn-icon">
<i class="font-icon font-icon-video-fill"></i>
</button>
</div>
<div class="tbl-cell tbl-cell-action">
<button type="submit" class="btn btn-rounded">Send</button>
</div>
</div>
</div>
</div>
</form><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">
Posts
<div class="slider-arrs">
<button type="button" class="posts-slider-prev">
<i class="font-icon font-icon-arrow-left"></i>
</button>
<button type="button" class="posts-slider-next">
<i class="font-icon font-icon-arrow-right"></i>
</button>
</div>
</header>
<div class="posts-slider">
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-1.jpeg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">3 Myths That Confuse the D Myths That Confuse the D Myths That Confuse the D</a>
</div>
<div class="post-announce-date">Februrary 19, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-2.jpg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">How Much Do We Spend on How Much Do We Spend on How Much Do We Spend on </a>
</div>
<div class="post-announce-date">January 21, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-3.jpeg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">Good News You Might Have Good News You Might Have Good News You Might Have </a>
</div>
<div class="post-announce-date">December 30, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-1.jpeg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">3 Myths That Confuse the D Myths That Confuse the D Myths That Confuse the D</a>
</div>
<div class="post-announce-date">Februrary 19, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-2.jpg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">How Much Do We Spend on How Much Do We Spend on How Much Do We Spend on </a>
</div>
<div class="post-announce-date">January 21, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
<div class="slide">
<article class="post-announce">
<div class="post-announce-pic">
<a href="profile.html#">
<img src="img/post-3.jpeg" alt="">
</a>
</div>
<div class="post-announce-title">
<a href="profile.html#">Good News You Might Have Good News You Might Have Good News You Might Have </a>
</div>
<div class="post-announce-date">December 30, 2016</div>
<ul class="post-announce-meta">
<li>
<i class="font-icon font-icon-eye"></i>
18
</li>
<li>
<i class="font-icon font-icon-heart"></i>
5K
</li>
<li>
<i class="font-icon font-icon-comment"></i>
3K
</li>
</ul>
</article>
</div><!--.slide-->
</div><!--.posts-slider-->
</section><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">Background</header>
<article class="profile-info-item">
<header class="profile-info-item-header">
<i class="font-icon font-icon-notebook-bird"></i>
Summary
</header>
<div class="text-block text-block-typical">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. </p>
</div>
</article><!--.profile-info-item-->
<article class="profile-info-item">
<header class="profile-info-item-header">
<i class="font-icon font-icon-case"></i>
Experience
</header>
<ul class="exp-timeline">
<li class="exp-timeline-item">
<div class="dot"></div>
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<div class="exp-timeline-range">2000 President</div>
<div class="exp-timeline-status">Co-founder, Chairman</div>
<div class="exp-timeline-location"><a href="profile.html#">Company</a></div>
</div>
<div class="tbl-cell tbl-cell-logo">
<img src="img/logo-2.png" alt="">
</div>
</div>
</div>
</li>
<li class="exp-timeline-item">
<div class="dot"></div>
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<div class="exp-timeline-range">1992–1999</div>
<div class="exp-timeline-status">Senior Developer</div>
<div class="exp-timeline-location"><a href="profile.html#">YouTube</a></div>
</div>
<div class="tbl-cell tbl-cell-logo">
<img src="img/logo-2.png" alt="">
</div>
</div>
</div>
</li>
<li class="exp-timeline-item">
<div class="dot"></div>
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<div class="exp-timeline-range">2000 President</div>
<div class="exp-timeline-status">Co-founder, Chairman</div>
<div class="exp-timeline-location"><a href="profile.html#">Company</a></div>
</div>
<div class="tbl-cell tbl-cell-logo">
<img src="img/logo-2.png" alt="">
</div>
</div>
</div>
</li>
</ul>
</article><!--.profile-info-item-->
<article class="profile-info-item">
<header class="profile-info-item-header">
<i class="font-icon font-icon-award"></i>
Edication
</header>
<ul class="exp-timeline">
<li class="exp-timeline-item">
<div class="dot"></div>
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<div class="exp-timeline-range">1973 – 1975</div>
<div class="exp-timeline-status">Harvard University</div>
<div class="exp-timeline-location"><a href="profile.html#">BS Computer Science</a></div>
</div>
<div class="tbl-cell tbl-cell-logo">
<img src="img/logo-2.png" alt="">
</div>
</div>
</div>
</li>
<li class="exp-timeline-item">
<div class="dot"></div>
<div class="tbl">
<div class="tbl-row">
<div class="tbl-cell">
<div class="exp-timeline-range">1960 – 1973</div>
<div class="exp-timeline-status">Lakeside Scool, Seattle</div>
</div>
<div class="tbl-cell tbl-cell-logo">
<img src="img/logo-2.png" alt="">
</div>
</div>
</div>
</li>
</ul>
</article><!--.profile-info-item-->
<article class="profile-info-item">
<header class="profile-info-item-header">
<i class="font-icon font-icon-lamp"></i>
Skills
</header>
<section class="skill-item tbl">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-num">
<div class="skill-circle skill-circle-num">74</div>
</div>
<div class="tbl-cell tbl-cell-txt">Social Media Marketing</div>
<div class="tbl-cell tbl-cell-users">
<img class="skill-user-photo" src="img/avatar-1-64.png" alt=""/>
<img class="skill-user-photo" src="img/photo-64-3.jpg" alt=""/>
<img class="skill-user-photo" src="img/photo-64-4.jpg" alt=""/>
<div class="skill-circle skill-circle-users">+74</div>
</div>
</div>
</section><!--.skill-item-->
<section class="skill-item tbl">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-num">
<div class="skill-circle skill-circle-num">67</div>
</div>
<div class="tbl-cell tbl-cell-txt">Web Development</div>
<div class="tbl-cell tbl-cell-users">
<img class="skill-user-photo" src="img/avatar-2-64.png" alt=""/>
<img class="skill-user-photo" src="img/photo-64-2.jpg" alt=""/>
<img class="skill-user-photo" src="img/photo-64-3.jpg" alt=""/>
<div class="skill-circle skill-circle-users">+82</div>
</div>
</div>
</section><!--.skill-item-->
<section class="skill-item tbl">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-num">
<div class="skill-circle skill-circle-num">25</div>
</div>
<div class="tbl-cell tbl-cell-txt">Search Engine Optimization</div>
<div class="tbl-cell tbl-cell-users">
<img class="skill-user-photo" src="img/avatar-3-64.png" alt=""/>
<img class="skill-user-photo" src="img/photo-64-1.jpg" alt=""/>
<img class="skill-user-photo" src="img/photo-64-2.jpg" alt=""/>
<div class="skill-circle skill-circle-users">+4</div>
</div>
</div>
</section><!--.skill-item-->
<section class="skill-item tbl">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-num">
<div class="skill-circle skill-circle-num">20</div>
</div>
<div class="tbl-cell tbl-cell-txt">User Experience Design</div>
<div class="tbl-cell tbl-cell-users">
<img class="skill-user-photo" src="img/photo-64-3.jpg" alt=""/>
<img class="skill-user-photo" src="img/photo-64-4.jpg" alt=""/>
<img class="skill-user-photo" src="img/photo-64-1.jpg" alt=""/>
<div class="skill-circle skill-circle-users">+13</div>
</div>
</div>
</section><!--.skill-item-->
</article><!--.profile-info-item-->
<article class="profile-info-item">
<header class="profile-info-item-header">
<i class="font-icon font-icon-star"></i>
More interest
</header>
<div class="profile-interests">
<a href="profile.html#" class="label label-light-grey">Interest</a>
<a href="profile.html#" class="label label-light-grey">Example</a>
<a href="profile.html#" class="label label-light-grey">One more</a>
<a href="profile.html#" class="label label-light-grey">Here is example interest</a>
<a href="profile.html#" class="label label-light-grey">Interest</a>
<a href="profile.html#" class="label label-light-grey">Example</a>
<a href="profile.html#" class="label label-light-grey">One more</a>
<a href="profile.html#" class="label label-light-grey">Here is example interest</a>
<a href="profile.html#" class="label label-light-grey">Interest</a>
<a href="profile.html#" class="label label-light-grey">Example</a>
<a href="profile.html#" class="label label-light-grey">One more</a>
<a href="profile.html#" class="label label-light-grey">Here is example interest</a>
</div>
</article><!--.profile-info-item-->
</section><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">
Recomendations
<div class="slider-arrs">
<button type="button" class="recomendations-slider-prev">
<i class="font-icon font-icon-arrow-left"></i>
</button>
<button type="button" class="recomendations-slider-next">
<i class="font-icon font-icon-arrow-right"></i>
</button>
</div>
</header>
<div class="recomendations-slider">
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-3.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-1.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-4.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
<div class="slide">
<div class="citate-speech-bubble">
<i class="font-icon-quote"></i>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-4.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Molly Bridjet</a></p>
<p class="user-card-row-status"><a href="profile.html#">PatchworkLabs</a></p>
</div>
</div>
</div>
</div><!--.slide-->
</div><!--.recomendations-slider-->
</section><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">Following</header>
<div class="profile-following">
<div class="profile-following-grid">
<div class="col">
<article class="follow-group">
<div class="follow-group-logo">
<a href="profile.html#" class="follow-group-logo-in"><img src="img/logo-2.png" alt=""></a>
</div>
<div class="follow-group-name">
<a href="profile.html#">KIPP Foundation</a>
</div>
<div class="follow-group-link">
<a href="profile.html#">
<span class="plus-link-circle"><span>+</span></span>
Follow
</a>
</div>
</article>
</div>
<div class="col">
<article class="follow-group">
<div class="follow-group-logo">
<a href="profile.html#" class="follow-group-logo-in"><img src="img/logo-2.png" alt=""></a>
</div>
<div class="follow-group-name">
<a href="profile.html#">KIPP Foundation</a>
</div>
<div class="follow-group-link">
<a href="profile.html#">
<span class="plus-link-circle"><span>+</span></span>
Follow
</a>
</div>
</article>
</div>
<div class="col">
<article class="follow-group">
<div class="follow-group-logo">
<a href="profile.html#" class="follow-group-logo-in"><img src="img/logo-2.png" alt=""></a>
</div>
<div class="follow-group-name">
<a href="profile.html#">KIPP Foundation</a>
</div>
<div class="follow-group-link">
<a href="profile.html#">
<span class="plus-link-circle"><span>+</span></span>
Follow
</a>
</div>
</article>
</div>
<div class="col">
<article class="follow-group">
<div class="follow-group-logo">
<a href="profile.html#" class="follow-group-logo-in"><img src="img/logo-2.png" alt=""></a>
</div>
<div class="follow-group-name">
<a href="profile.html#">KIPP Foundation</a>
</div>
<div class="follow-group-link">
<a href="profile.html#">
<span class="plus-link-circle"><span>+</span></span>
Follow
</a>
</div>
</article>
</div>
</div>
<a href="profile.html#" class="btn btn-rounded btn-primary-outline">See all (20)</a>
</div><!--.profile-following-->
</section><!--.box-typical-->
</div><!--.col- -->
<div class="col-lg-3 col-lg-pull-6 col-md-6 col-sm-6">
<section class="box-typical">
<div class="profile-card">
<div class="profile-card-photo">
<img src="img/photo-220-1.jpg" alt=""/>
</div>
<div class="profile-card-name">Sarah Sanchez</div>
<div class="profile-card-status">Company Founder</div>
<div class="profile-card-location">Greater Seattle Area</div>
<button type="button" class="btn btn-rounded">Follow</button>
<div class="btn-group">
<button type="button"
class="btn btn-rounded btn-primary-outline dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
Connect
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-home"></span>Quant and Verbal</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-cart"></span>Real Gmat Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-speed"></span>Prep Official App</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-users"></span>CATprer Test</a>
<a class="dropdown-item" href="profile.html#"><span class="font-icon font-icon-comments"></span>Third Party Test</a>
</div>
</div>
</div><!--.profile-card-->
<div class="profile-statistic tbl">
<div class="tbl-row">
<div class="tbl-cell">
<b>200</b>
Connections
</div>
<div class="tbl-cell">
<b>1.9M</b>
Followers
</div>
</div>
</div>
<ul class="profile-links-list">
<li class="nowrap">
<i class="font-icon font-icon-earth-bordered"></i>
<a href="profile.html#">example.com</a>
</li>
<li class="nowrap">
<i class="font-icon font-icon-fb-fill"></i>
<a href="profile.html#">facebook.com/example</a>
</li>
<li class="nowrap">
<i class="font-icon font-icon-vk-fill"></i>
<a href="profile.html#">vk.com/example</a>
</li>
<li class="nowrap">
<i class="font-icon font-icon-in-fill"></i>
<a href="profile.html#">linked.in/example</a>
</li>
<li class="nowrap">
<i class="font-icon font-icon-tw-fill"></i>
<a href="profile.html#">twitter.com/example</a>
</li>
<li class="divider"></li>
<li>
<i class="font-icon font-icon-pdf-fill"></i>
<a href="profile.html#">Export page as PDF</a>
</li>
</ul>
</section><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">
Friends
<a href="profile.html#" class="full-count">268</a>
</header>
<div class="friends-list">
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name status-online"><a href="profile.html#">Dan Cederholm</a></p>
<p class="user-card-row-location">New York</p>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-1.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Oykun Yilmaz</a></p>
<p class="user-card-row-location">Los Angeles</p>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-3.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Bill S Kenney</a></p>
<p class="user-card-row-location">Cardiff</p>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-4.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Maggy Smith</a></p>
<p class="user-card-row-location">Dusseldorf</p>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Dan Cederholm</a></p>
<p class="user-card-row-location">New York</p>
</div>
</div>
</div>
</article>
</div>
</section><!--.box-typical-->
</div><!--.col- -->
<div class="col-lg-3 col-md-6 col-sm-6">
<section class="box-typical">
<header class="box-typical-header-sm">People also viewed</header>
<div class="friends-list stripped">
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name status-online"><a href="profile.html#">Dan Cederholm</a></p>
<p class="user-card-row-status">Co-founder of <a href="profile.html#">Company</a></p>
</div>
<div class="tbl-cell tbl-cell-action">
<a href="profile.html#" class="plus-link-circle"><span>+</span></a>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-1.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Oykun Yilmaz</a></p>
<p class="user-card-row-status">Co-founder of <a href="profile.html#">Company</a></p>
</div>
<div class="tbl-cell tbl-cell-action">
<a href="profile.html#" class="plus-link-circle"><span>+</span></a>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-3.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Bill S Kenney</a></p>
<p class="user-card-row-status">Co-founder of <a href="profile.html#">Company</a></p>
</div>
<div class="tbl-cell tbl-cell-action">
<a href="profile.html#" class="plus-link-circle"><span>+</span></a>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-4.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Maggy Smith</a></p>
<p class="user-card-row-status">Co-founder of <a href="profile.html#">Company</a></p>
</div>
<div class="tbl-cell tbl-cell-action">
<a href="profile.html#" class="plus-link-circle"><span>+</span></a>
</div>
</div>
</div>
</article>
<article class="friends-list-item">
<div class="user-card-row">
<div class="tbl-row">
<div class="tbl-cell tbl-cell-photo">
<a href="profile.html#">
<img src="img/photo-64-2.jpg" alt="">
</a>
</div>
<div class="tbl-cell">
<p class="user-card-row-name"><a href="profile.html#">Susan Andrews</a></p>
<p class="user-card-row-status">Co-founder of <a href="profile.html#">Company</a></p>
</div>
<div class="tbl-cell tbl-cell-action">
<a href="profile.html#" class="plus-link-circle"><span>+</span></a>
</div>
</div>
</div>
</article>
</div>
<div class="see-all">
<a href="profile.html#">See All (300)</a>
</div>
<section>
<header class="box-typical-header-sm">More Influencer</header>
<div class="profile-card-slider">
<div class="slide">
<div class="profile-card">
<div class="profile-card-photo">
<img src="img/photo-220-1.jpg" alt=""/>
</div>
<div class="profile-card-name">Jackie Tran</div>
<div class="profile-card-status">Company Founder</div>
<button type="button" class="btn btn-rounded btn-primary-outline">Follow</button>
</div><!--.profile-card-->
</div><!--.slide-->
<div class="slide">
<div class="profile-card">
<div class="profile-card-photo">
<img src="img/avatar-1-256.png" alt=""/>
</div>
<div class="profile-card-name">Jackie Tran</div>
<div class="profile-card-status">Company Founder</div>
<button type="button" class="btn btn-rounded btn-primary-outline">Follow</button>
</div><!--.profile-card-->
</div><!--.slide-->
<div class="slide">
<div class="profile-card">
<div class="profile-card-photo">
<img src="img/avatar-2-256.png" alt=""/>
</div>
<div class="profile-card-name">Sarah Sanchez</div>
<div class="profile-card-status">Longnameexample<br/>corporation</div>
<button type="button" class="btn btn-rounded btn-primary-outline">Follow</button>
</div><!--.profile-card-->
</div><!--.slide-->
<div class="slide">
<div class="profile-card">
<div class="profile-card-photo">
<img src="img/avatar-3-256.png" alt=""/>
</div>
<div class="profile-card-name">Sarah Sanchez</div>
<div class="profile-card-status">Longnameexample<br/>corporation</div>
<button type="button" class="btn btn-rounded btn-primary-outline">Follow</button>
</div><!--.profile-card-->
</div><!--.slide-->
</div><!--.profile-card-slider-->
</section>
</section><!--.box-typical-->
<section class="box-typical">
<header class="box-typical-header-sm">People you may know</header>
<div class="people-rel-list">
<div class="people-rel-list-name"><a href="profile.html#">Jackie Tran Anh</a> / Designer</div>
<ul class="people-rel-list-photos">
<li><a href="profile.html#"><img src="img/photo-92-1.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-2.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-3.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/avatar-1-128.png" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-2.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/avatar-2-128.png" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-1.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/avatar-3-128.png" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-3.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-1.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-2.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-3.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-1.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-2.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-3.jpg" alt=""></a></li>
<li><a href="profile.html#"><img src="img/photo-92-1.jpg" alt=""></a></li>
</ul>
<form class="site-header-search">
<input type="text" placeholder="Search for people"/>
<button type="submit">
<span class="font-icon-search"></span>
</button>
<div class="overlay"></div>
</form>
</div>
</section><!--.box-typical-->
</div><!--.col- -->
</div><!--.row-->
</div><!--.container-fluid-->
</div><!--.page-content-->
<!--Progress bar-->
<!--<div class="circle-progress-bar pieProgress" role="progressbar" data-goal="100" data-barcolor="#ac6bec" data-barsize="10" aria-valuemin="0" aria-valuemax="100">-->
<!--<span class="pie_progress__number">0%</span>-->
<!--</div>-->
</body>
</html> | racerx2000/ne_stenka | application/demo/profile.html | HTML | mit | 69,361 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
11374,
1027,
1000,
21766,
1000,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
41... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010-2013 OpenXcom Developers.
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include "Ufopaedia.h"
#include "ArticleStateCraftWeapon.h"
#include "../Ruleset/ArticleDefinition.h"
#include "../Ruleset/Ruleset.h"
#include "../Ruleset/RuleCraftWeapon.h"
#include "../Engine/Game.h"
#include "../Engine/Palette.h"
#include "../Engine/Surface.h"
#include "../Engine/Language.h"
#include "../Resource/ResourcePack.h"
#include "../Interface/Text.h"
#include "../Interface/TextButton.h"
#include "../Interface/TextList.h"
namespace OpenXcom
{
ArticleStateCraftWeapon::ArticleStateCraftWeapon(Game *game, ArticleDefinitionCraftWeapon *defs, int palSwitch) : ArticleState(game, defs->id, palSwitch)
{
RuleCraftWeapon *weapon = _game->getRuleset()->getCraftWeapon(defs->id);
// add screen elements
_txtTitle = new Text(200, 32, 5, 24);
// Set palette
_game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_4")->getColors());
ArticleState::initLayout();
// add other elements
add(_txtTitle);
// Set up objects
_game->getResourcePack()->getSurface(defs->image_id)->blit(_bg);
_btnOk->setColor(Palette::blockOffset(1));
_btnPrev->setColor(Palette::blockOffset(1));
_btnNext->setColor(Palette::blockOffset(1));
_txtTitle->setColor(Palette::blockOffset(14)+15);
_txtTitle->setBig();
_txtTitle->setWordWrap(true);
_txtTitle->setText(Ufopaedia::buildText(_game, defs->title));
_txtInfo = new Text(310, 32, 5, 160);
add(_txtInfo);
_txtInfo->setColor(Palette::blockOffset(14)+15);
_txtInfo->setWordWrap(true);
_txtInfo->setText(Ufopaedia::buildText(_game, defs->text));
_lstInfo = new TextList(250, 111, 5, 80);
add(_lstInfo);
std::wstringstream ss;
_lstInfo->setColor(Palette::blockOffset(14)+15);
_lstInfo->setColumns(2, 180, 70);
_lstInfo->setDot(true);
_lstInfo->setBig();
ss.str(L"");ss.clear();
ss << weapon->getDamage();
_lstInfo->addRow(2, _game->getLanguage()->getString("STR_DAMAGE").c_str(), ss.str().c_str());
_lstInfo->setCellColor(0, 1, Palette::blockOffset(15)+4);
ss.str(L"");ss.clear();
ss << weapon->getRange() << _game->getLanguage()->getString("STR_KM").c_str();
_lstInfo->addRow(2, _game->getLanguage()->getString("STR_RANGE").c_str(), ss.str().c_str());
_lstInfo->setCellColor(1, 1, Palette::blockOffset(15)+4);
ss.str(L"");ss.clear();
ss << weapon->getAccuracy() << "%";
_lstInfo->addRow(2, _game->getLanguage()->getString("STR_ACCURACY").c_str(), ss.str().c_str());
_lstInfo->setCellColor(2, 1, Palette::blockOffset(15)+4);
ss.str(L"");ss.clear();
ss << weapon->getStandardReload() << _game->getLanguage()->getString("STR_S").c_str();
_lstInfo->addRow(2, _game->getLanguage()->getString("STR_RE_LOAD_TIME").c_str(), ss.str().c_str());
_lstInfo->setCellColor(3, 1, Palette::blockOffset(15)+4);
}
ArticleStateCraftWeapon::~ArticleStateCraftWeapon()
{}
}
| lt90/RPG | src/Ufopaedia/ArticleStateCraftWeapon.cpp | C++ | gpl-3.0 | 3,553 | [
30522,
1013,
1008,
1008,
9385,
2230,
1011,
2286,
2330,
2595,
9006,
9797,
1012,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
2330,
2595,
9006,
1012,
1008,
1008,
2330,
2595,
9006,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
261... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Drupal\webform;
use Drupal\Core\Archiver\ArchiveTar;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformState;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Plugin\WebformExporterManagerInterface;
/**
* Webform submission exporter.
*/
class WebformSubmissionExporter implements WebformSubmissionExporterInterface {
use StringTranslationTrait;
/**
* The configuration object factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* File system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* Webform submission storage.
*
* @var \Drupal\webform\WebformSubmissionStorageInterface
*/
protected $entityStorage;
/**
* The stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected $streamWrapperManager;
/**
* Webform element manager.
*
* @var \Drupal\webform\Plugin\WebformElementManagerInterface
*/
protected $elementManager;
/**
* Results exporter manager.
*
* @var \Drupal\webform\Plugin\WebformExporterManagerInterface
*/
protected $exporterManager;
/**
* The webform.
*
* @var \Drupal\webform\WebformInterface
*/
protected $webform;
/**
* The source entity.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $sourceEntity;
/**
* The results exporter.
*
* @var \Drupal\webform\Plugin\WebformExporterInterface
*/
protected $exporter;
/**
* Default export options.
*
* @var array
*/
protected $defaultOptions;
/**
* Webform element types.
*
* @var array
*/
protected $elementTypes;
/**
* Constructs a WebformSubmissionExporter object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration object factory.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager
* The stream wrapper manager.
* @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
* The webform element manager.
* @param \Drupal\webform\Plugin\WebformExporterManagerInterface $exporter_manager
* The results exporter manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, FileSystemInterface $file_system, EntityTypeManagerInterface $entity_type_manager, StreamWrapperManagerInterface $stream_wrapper_manager, WebformElementManagerInterface $element_manager, WebformExporterManagerInterface $exporter_manager) {
$this->configFactory = $config_factory;
$this->fileSystem = $file_system;
$this->entityStorage = $entity_type_manager->getStorage('webform_submission');
$this->streamWrapperManager = $stream_wrapper_manager;
$this->elementManager = $element_manager;
$this->exporterManager = $exporter_manager;
}
/**
* {@inheritdoc}
*/
public function setWebform(WebformInterface $webform = NULL) {
$this->webform = $webform;
$this->defaultOptions = NULL;
$this->elementTypes = NULL;
}
/**
* {@inheritdoc}
*/
public function getWebform() {
return $this->webform;
}
/**
* {@inheritdoc}
*/
public function setSourceEntity(EntityInterface $entity = NULL) {
$this->sourceEntity = $entity;
}
/**
* {@inheritdoc}
*/
public function getSourceEntity() {
return $this->sourceEntity;
}
/**
* {@inheritdoc}
*/
public function getWebformOptions() {
$name = $this->getWebformOptionsName();
return $this->getWebform()->getState($name, []);
}
/**
* {@inheritdoc}
*/
public function setWebformOptions(array $options = []) {
$name = $this->getWebformOptionsName();
$this->getWebform()->setState($name, $options);
}
/**
* {@inheritdoc}
*/
public function deleteWebformOptions() {
$name = $this->getWebformOptionsName();
$this->getWebform()->deleteState($name);
}
/**
* Get options name for current webform and source entity.
*
* @return string
* Settings name as 'webform.export.{entity_type}.{entity_id}'.
*/
protected function getWebformOptionsName() {
if ($entity = $this->getSourceEntity()) {
return 'results.export.' . $entity->getEntityTypeId() . '.' . $entity->id();
}
else {
return 'results.export';
}
}
/**
* {@inheritdoc}
*/
public function setExporter(array $export_options = []) {
$export_options += $this->getDefaultExportOptions();
$export_options['webform'] = $this->getWebform();
$export_options['source_entity'] = $this->getSourceEntity();
$this->exporter = $this->exporterManager->createInstance($export_options['exporter'], $export_options);
return $this->exporter;
}
/**
* {@inheritdoc}
*/
public function getExporter() {
return $this->exporter;
}
/**
* {@inheritdoc}
*/
public function getExportOptions() {
return $this->getExporter()->getConfiguration();
}
/****************************************************************************/
// Default options and webform.
/****************************************************************************/
/**
* {@inheritdoc}
*/
public function getDefaultExportOptions() {
if (isset($this->defaultOptions)) {
return $this->defaultOptions;
}
$this->defaultOptions = [
'exporter' => 'delimited',
'delimiter' => ',',
'multiple_delimiter' => ';',
'excel' => FALSE,
'file_name' => 'submission-[webform_submission:serial]',
'header_format' => 'label',
'header_prefix' => TRUE,
'header_prefix_label_delimiter' => ': ',
'header_prefix_key_delimiter' => '__',
'excluded_columns' => [
'uuid' => 'uuid',
'token' => 'token',
'webform_id' => 'webform_id',
],
'entity_type' => '',
'entity_id' => '',
'range_type' => 'all',
'range_latest' => '',
'range_start' => '',
'range_end' => '',
'state' => 'all',
'sticky' => '',
'download' => TRUE,
'files' => FALSE,
];
// Append element handler default options.
$element_types = $this->getWebformElementTypes();
$element_handlers = $this->elementManager->getInstances();
foreach ($element_handlers as $element_type => $element_handler) {
if (empty($element_types) || isset($element_types[$element_type])) {
$this->defaultOptions += $element_handler->getExportDefaultOptions();
}
}
return $this->defaultOptions;
}
/**
* {@inheritdoc}
*/
public function buildExportOptionsForm(array &$form, FormStateInterface $form_state, array $export_options = []) {
$export_options += $this->getDefaultExportOptions();
$this->setExporter($export_options);
$webform = $this->getWebform();
// Get exporter and build #states.
$exporter_plugins = $this->exporterManager->getInstances($export_options);
$states_archive = ['invisible' => []];
$states_options = ['invisible' => []];
foreach ($exporter_plugins as $plugin_id => $exporter_plugin) {
if ($exporter_plugin->isArchive()) {
if ($states_archive['invisible']) {
$states_archive['invisible'][] = 'or';
}
$states_archive['invisible'][] = [':input[name="exporter"]' => ['value' => $plugin_id]];
}
if (!$exporter_plugin->hasOptions()) {
if ($states_options['invisible']) {
$states_options['invisible'][] = 'or';
}
$states_options['invisible'][] = [':input[name="exporter"]' => ['value' => $plugin_id]];
}
}
$form['export']['format'] = [
'#type' => 'details',
'#title' => $this->t('Format options'),
'#open' => TRUE,
];
$form['export']['format']['exporter'] = [
'#type' => 'select',
'#title' => $this->t('Export format'),
'#options' => $this->exporterManager->getOptions(),
'#default_value' => $export_options['exporter'],
// Below .js-webform-exporter is used for exporter configuration form
// #states.
// @see \Drupal\webform\Plugin\WebformExporterBase::buildConfigurationForm
'#attributes' => ['class' => ['js-webform-exporter']],
];
foreach ($exporter_plugins as $plugin_id => $exporter) {
$subform_state = SubformState::createForSubform($form['export']['format'], $form, $form_state);
$form['export']['format'] = $exporter->buildConfigurationForm($form['export']['format'], $subform_state);
}
// Element.
$form['export']['element'] = [
'#type' => 'details',
'#title' => $this->t('Element options'),
'#open' => TRUE,
'#states' => $states_options,
];
$form['export']['element']['multiple_delimiter'] = [
'#type' => 'select',
'#title' => $this->t('Element multiple values delimiter'),
'#description' => $this->t('This is the delimiter when an element has multiple values.'),
'#required' => TRUE,
'#options' => [
';' => $this->t('Semicolon (;)'),
',' => $this->t('Comma (,)'),
'|' => $this->t('Pipe (|)'),
'.' => $this->t('Period (.)'),
' ' => $this->t('Space ()'),
],
'#default_value' => $export_options['multiple_delimiter'],
];
// Header.
$form['export']['header'] = [
'#type' => 'details',
'#title' => $this->t('Header options'),
'#open' => TRUE,
'#states' => $states_options,
];
$form['export']['header']['header_format'] = [
'#type' => 'radios',
'#title' => $this->t('Column header format'),
'#description' => $this->t('Choose whether to show the element label or element key in each column header.'),
'#required' => TRUE,
'#options' => [
'label' => $this->t('Element titles (label)'),
'key' => $this->t('Element keys (key)'),
],
'#default_value' => $export_options['header_format'],
];
$form['export']['header']['header_prefix'] = [
'#type' => 'checkbox',
'#title' => $this->t("Include an element's title with all sub elements and values in each column header."),
'#return_value' => TRUE,
'#default_value' => $export_options['header_prefix'],
];
$form['export']['header']['header_prefix_label_delimiter'] = [
'#type' => 'textfield',
'#title' => $this->t('Column header label delimiter'),
'#required' => TRUE,
'#default_value' => $export_options['header_prefix_label_delimiter'],
];
$form['export']['header']['header_prefix_key_delimiter'] = [
'#type' => 'textfield',
'#title' => $this->t('Column header key delimiter'),
'#required' => TRUE,
'#default_value' => $export_options['header_prefix_key_delimiter'],
];
if ($webform) {
$form['export']['header']['header_prefix_label_delimiter']['#states'] = [
'visible' => [
':input[name="header_prefix"]' => ['checked' => TRUE],
':input[name="header_format"]' => ['value' => 'label'],
],
];
$form['export']['header']['header_prefix_key_delimiter']['#states'] = [
'visible' => [
':input[name="header_prefix"]' => ['checked' => TRUE],
':input[name="header_format"]' => ['value' => 'key'],
],
];
}
// Build element specific export webforms.
// Grouping everything in $form['export']['elements'] so that element handlers can
// assign #weight to its export options webform.
$form['export']['elements'] = [
'#type' => 'container',
'#attributes' => ['class' => ['form-item']],
'#states' => $states_options,
];
$element_types = $this->getWebformElementTypes();
$element_handlers = $this->elementManager->getInstances();
foreach ($element_handlers as $element_type => $element_handler) {
if (empty($element_types) || isset($element_types[$element_type])) {
$subform_state = SubformState::createForSubform($form['export']['elements'], $form, $form_state);
$element_handler->buildExportOptionsForm($form['export']['elements'], $subform_state, $export_options);
}
}
// All the remain options are only applicable to a webform's export.
// @see Drupal\webform\Form\WebformResultsExportForm
if (!$webform) {
return;
}
// Elements.
$form['export']['columns'] = [
'#type' => 'details',
'#title' => $this->t('Column options'),
'#description' => $this->t('The selected columns will be included in the export.'),
'#states' => $states_options,
];
$form['export']['columns']['excluded_columns'] = [
'#type' => 'webform_excluded_columns',
'#webform_id' => $webform->id(),
'#default_value' => $export_options['excluded_columns'],
];
// Download options.
$form['export']['download'] = [
'#type' => 'details',
'#title' => $this->t('Download options'),
'#open' => TRUE,
];
$form['export']['download']['download'] = [
'#type' => 'checkbox',
'#title' => $this->t('Download export file'),
'#description' => $this->t('If checked, the export file will be automatically download to your local machine. If unchecked, the export file will be displayed as plain text within your browser.'),
'#return_value' => TRUE,
'#default_value' => $export_options['download'],
'#access' => !$this->requiresBatch(),
'#states' => $states_archive,
];
$form['export']['download']['files'] = [
'#type' => 'checkbox',
'#title' => $this->t('Download uploaded files'),
'#description' => $this->t('If checked, the exported file and any submission file uploads will be download in a gzipped tar file.'),
'#return_value' => TRUE,
'#default_value' => ($webform->hasManagedFile()) ? $export_options['files'] : 0,
'#access' => $webform->hasManagedFile(),
'#states' => [
'invisible' => [
':input[name="download"]' => ['checked' => FALSE],
],
],
];
$source_entity = $this->getSourceEntity();
if (!$source_entity) {
$entity_types = $this->entityStorage->getSourceEntityTypes($webform);
if ($entity_types) {
$form['export']['download']['submitted'] = [
'#type' => 'item',
'#input' => FALSE,
'#title' => $this->t('Submitted to'),
'#description' => $this->t('Select the entity type and then enter the entity id.'),
'#field_prefix' => '<div class="container-inline">',
'#field_suffix' => '</div>',
];
$form['export']['download']['submitted']['entity_type'] = [
'#type' => 'select',
'#title' => $this->t('Entity type'),
'#title_display' => 'Invisible',
'#options' => ['' => $this->t('All')] + $entity_types,
'#default_value' => $export_options['entity_type'],
];
$form['export']['download']['submitted']['entity_id'] = [
'#type' => 'number',
'#title' => $this->t('Entity id'),
'#title_display' => 'Invisible',
'#min' => 1,
'#size' => 10,
'#default_value' => $export_options['entity_id'],
'#states' => [
'invisible' => [
':input[name="entity_type"]' => ['value' => ''],
],
],
];
}
}
$form['export']['download']['range_type'] = [
'#type' => 'select',
'#title' => $this->t('Limit to'),
'#options' => [
'all' => $this->t('All'),
'latest' => $this->t('Latest'),
'serial' => $this->t('Submission number'),
'sid' => $this->t('Submission ID'),
'date' => $this->t('Date'),
],
'#default_value' => $export_options['range_type'],
];
$form['export']['download']['latest'] = [
'#type' => 'container',
'#attributes' => ['class' => ['container-inline']],
'#states' => [
'visible' => [
':input[name="range_type"]' => ['value' => 'latest'],
],
],
'range_latest' => [
'#type' => 'number',
'#title' => $this->t('Number of submissions'),
'#min' => 1,
'#default_value' => $export_options['range_latest'],
],
];
$ranges = [
'serial' => ['#type' => 'number'],
'sid' => ['#type' => 'number'],
'date' => ['#type' => 'date'],
];
foreach ($ranges as $key => $range_element) {
$form['export']['download'][$key] = [
'#type' => 'container',
'#attributes' => ['class' => ['container-inline']],
'#tree' => TRUE,
'#states' => [
'visible' => [
':input[name="range_type"]' => ['value' => $key],
],
],
];
$form['export']['download'][$key]['range_start'] = $range_element + [
'#title' => $this->t('From'),
'#parents' => [$key, 'range_start'],
'#default_value' => $export_options['range_start'],
];
$form['export']['download'][$key]['range_end'] = $range_element + [
'#title' => $this->t('To'),
'#parents' => [$key, 'range_end'],
'#default_value' => $export_options['range_end'],
];
}
$form['export']['download']['sticky'] = [
'#type' => 'checkbox',
'#title' => $this->t('Starred/flagged submissions'),
'#description' => $this->t('If checked, only starred/flagged submissions will be downloaded. If unchecked, all submissions will downloaded.'),
'#return_value' => TRUE,
'#default_value' => $export_options['sticky'],
];
// If drafts are allowed, provide options to filter download based on
// submission state.
$form['export']['download']['state'] = [
'#type' => 'radios',
'#title' => $this->t('Submission state'),
'#default_value' => $export_options['state'],
'#options' => [
'all' => $this->t('Completed and draft submissions'),
'completed' => $this->t('Completed submissions only'),
'draft' => $this->t('Drafts only'),
],
'#access' => ($webform->getSetting('draft') != WebformInterface::DRAFT_NONE),
];
}
/**
* {@inheritdoc}
*/
public function getValuesFromInput(array $values) {
if (isset($values['range_type'])) {
$range_type = $values['range_type'];
$values['range_type'] = $range_type;
if (isset($values[$range_type])) {
$values += $values[$range_type];
}
}
// Make sure only support options are returned.
$values = array_intersect_key($values, $this->getDefaultExportOptions());
return $values;
}
/****************************************************************************/
// Generate and write.
/****************************************************************************/
/**
* {@inheritdoc}
*/
public function generate() {
$entity_ids = $this->getQuery()->execute();
$webform_submissions = WebformSubmission::loadMultiple($entity_ids);
$this->writeHeader();
$this->writeRecords($webform_submissions);
$this->writeFooter();
}
/**
* {@inheritdoc}
*/
public function writeHeader() {
// If building a new archive make sure to delete the exist archive.
if ($this->isArchive()) {
@unlink($this->getArchiveFilePath());
}
$this->getExporter()->createExport();
$this->getExporter()->writeHeader();
$this->getExporter()->closeExport();
}
/**
* {@inheritdoc}
*/
public function writeRecords(array $webform_submissions) {
$export_options = $this->getExportOptions();
$webform = $this->getWebform();
$is_archive = ($this->isArchive() && $export_options['files']);
$files_directories = [];
if ($is_archive) {
$archiver = new ArchiveTar($this->getArchiveFilePath(), 'gz');
$stream_wrappers = array_keys($this->streamWrapperManager->getNames(StreamWrapperInterface::WRITE_VISIBLE));
foreach ($stream_wrappers as $stream_wrapper) {
$files_directory = $this->fileSystem->realpath($stream_wrapper . '://webform/' . $webform->id());
$files_directories[] = $files_directory;
}
}
$this->getExporter()->openExport();
foreach ($webform_submissions as $webform_submission) {
if ($is_archive) {
foreach ($files_directories as $files_directory) {
$submission_directory = $files_directory . '/' . $webform_submission->id();
if (file_exists($submission_directory)) {
$file_name = $this->getSubmissionBaseName($webform_submission);
$archiver->addModify($submission_directory, $file_name, $submission_directory);
}
}
}
$this->getExporter()->writeSubmission($webform_submission);
}
$this->getExporter()->closeExport();
}
/**
* {@inheritdoc}
*/
public function writeFooter() {
$this->getExporter()->openExport();
$this->getExporter()->writeFooter();
$this->getExporter()->closeExport();
}
/**
* {@inheritdoc}
*/
public function writeExportToArchive() {
$export_file_path = $this->getExportFilePath();
if (file_exists($export_file_path)) {
$archive_file_path = $this->getArchiveFilePath();
$archiver = new ArchiveTar($archive_file_path, 'gz');
$archiver->addModify($export_file_path, $this->getBaseFileName(), $this->getFileTempDirectory());
@unlink($export_file_path);
}
}
/**
* {@inheritdoc}
*/
public function getQuery() {
$export_options = $this->getExportOptions();
$webform = $this->getWebform();
$source_entity = $this->getSourceEntity();
$query = $this->entityStorage->getQuery()->condition('webform_id', $webform->id());
// Filter by source entity or submitted to.
if ($source_entity) {
$query->condition('entity_type', $source_entity->getEntityTypeId());
$query->condition('entity_id', $source_entity->id());
}
elseif ($export_options['entity_type']) {
$query->condition('entity_type', $export_options['entity_type']);
if ($export_options['entity_id']) {
$query->condition('entity_id', $export_options['entity_id']);
}
}
// Filter by sid or date range.
switch ($export_options['range_type']) {
case 'serial':
if ($export_options['range_start']) {
$query->condition('serial', $export_options['range_start'], '>=');
}
if ($export_options['range_end']) {
$query->condition('serial', $export_options['range_end'], '<=');
}
break;
case 'sid':
if ($export_options['range_start']) {
$query->condition('sid', $export_options['range_start'], '>=');
}
if ($export_options['range_end']) {
$query->condition('sid', $export_options['range_end'], '<=');
}
break;
case 'date':
if ($export_options['range_start']) {
$query->condition('created', strtotime($export_options['range_start']), '>=');
}
if ($export_options['range_end']) {
$query->condition('created', strtotime('+1 day', strtotime($export_options['range_end'])), '<');
}
break;
}
// Filter by (completion) state.
switch ($export_options['state']) {
case 'draft':
$query->condition('in_draft', 1);
break;
case 'completed':
$query->condition('in_draft', 0);
break;
}
// Filter by sticky.
if ($export_options['sticky']) {
$query->condition('sticky', 1);
}
// Filter by latest.
if ($export_options['range_type'] == 'latest' && $export_options['range_latest']) {
// Clone the query and use it to get latest sid starting sid.
$latest_query = clone $query;
$latest_query->sort('sid', 'DESC');
$latest_query->range(0, (int) $export_options['range_latest']);
if ($latest_query_entity_ids = $latest_query->execute()) {
$query->condition('sid', end($latest_query_entity_ids), '>=');
}
}
// Sort by sid with the oldest one first.
$query->sort('sid', 'ASC');
return $query;
}
/**
* Get element types from a webform.
*
* @return array
* An array of element types from a webform.
*/
protected function getWebformElementTypes() {
if (isset($this->elementTypes)) {
return $this->elementTypes;
}
// If the webform is not set which only occurs on the admin settings webform,
// return an empty array.
if (!isset($this->webform)) {
return [];
}
$this->elementTypes = [];
$elements = $this->webform->getElementsDecodedAndFlattened();
// Always include 'entity_autocomplete' export settings which is used to
// expand a webform submission's entity references.
$this->elementTypes['entity_autocomplete'] = 'entity_autocomplete';
foreach ($elements as $element) {
if (isset($element['#type'])) {
$type = $this->elementManager->getElementPluginId($element);
$this->elementTypes[$type] = $type;
}
}
return $this->elementTypes;
}
/****************************************************************************/
// Summary and download.
/****************************************************************************/
/**
* {@inheritdoc}
*/
public function getTotal() {
return $this->getQuery()->count()->execute();
}
/**
* {@inheritdoc}
*/
public function getBatchLimit() {
return $this->configFactory->get('webform.settings')->get('batch.default_batch_export_size') ?: 500;
}
/**
* {@inheritdoc}
*/
public function requiresBatch() {
return ($this->getTotal() > $this->getBatchLimit()) ? TRUE : FALSE;
}
/**
* {@inheritdoc}
*/
public function getFileTempDirectory() {
return file_directory_temp();
}
/**
* {@inheritdoc}
*/
public function getSubmissionBaseName(WebformSubmissionInterface $webform_submission) {
return $this->getExporter()->getSubmissionBaseName($webform_submission);
}
/**
* {@inheritdoc}
*/
protected function getBaseFileName() {
return $this->getExporter()->getBaseFileName();
}
/**
* {@inheritdoc}
*/
public function getExportFilePath() {
return $this->getExporter()->getExportFilePath();
}
/**
* {@inheritdoc}
*/
public function getExportFileName() {
return $this->getExporter()->getExportFileName();
}
/**
* {@inheritdoc}
*/
public function getArchiveFilePath() {
return $this->getExporter()->getArchiveFilePath();
}
/**
* {@inheritdoc}
*/
public function getArchiveFileName() {
return $this->getExporter()->getArchiveFileName();
}
/**
* {@inheritdoc}
*/
public function isArchive() {
if ($this->getExporter()->isArchive()) {
return TRUE;
}
else {
$export_options = $this->getExportOptions();
return ($export_options['download'] && $export_options['files']);
}
}
/**
* {@inheritdoc}
*/
public function isBatch() {
return ($this->isArchive() || ($this->getTotal() >= $this->getBatchLimit()));
}
}
| msbtterswrth/mdspca-fosters | modules/webform/src/WebformSubmissionExporter.php | PHP | gpl-2.0 | 27,760 | [
30522,
1026,
1029,
25718,
3415,
15327,
2852,
6279,
2389,
1032,
4773,
14192,
1025,
2224,
2852,
6279,
2389,
1032,
4563,
1032,
8756,
2099,
1032,
8756,
7559,
1025,
2224,
2852,
6279,
2389,
1032,
4563,
1032,
9530,
8873,
2290,
1032,
9530,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"35501614","logradouro":"Rua Um","bairro":"Jardim Copacabana","cidade":"Divin\u00f3polis","uf":"MG","estado":"Minas Gerais"});
| lfreneda/cepdb | api/v1/35501614.jsonp.js | JavaScript | cc0-1.0 | 140 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
26271,
24096,
2575,
16932,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
8529,
1000,
1010,
1000,
21790,
18933,
1000,
1024,
1000,
15723,
221... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The ManaPlus Client
* Copyright (C) 2008 Aethyra Development Team
* Copyright (C) 2011-2019 The ManaPlus Developers
* Copyright (C) 2019-2022 Andrei Karas
*
* This file is part of The ManaPlus Client.
*
* 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
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "resources/db/mapdb.h"
#include "configuration.h"
#include "logger.h"
#include "resources/beingcommon.h"
#include "debug.h"
namespace
{
bool mLoaded = false;
MapDB::Maps mMaps;
MapDB::MapInfos mInfos;
MapDB::Atlases mAtlases;
std::set<std::string> mEmptyTilesets;
} // namespace
namespace MapDB
{
void readMap(XmlNodePtrConst node);
void readAtlas(XmlNodePtrConst node);
} // namespace MapDB
void MapDB::load()
{
if (mLoaded)
unload();
logger->log1("Initializing maps database...");
loadRemapXmlFile(paths.getStringValue("mapsRemapFile"),
SkipError_true);
loadRemapXmlFile(paths.getStringValue("mapsRemapPatchFile"),
SkipError_true);
loadXmlDir("mapsRemapPatchDir", loadRemapXmlFile)
loadInfo(paths.getStringValue("mapsFile"), SkipError_false);
loadInfo(paths.getStringValue("mapsPatchFile"), SkipError_true);
loadXmlDir("mapsPatchDir", loadInfo)
mLoaded = true;
}
void MapDB::loadRemapXmlFile(const std::string &fileName,
const SkipError skipError)
{
XML::Document *const doc = new XML::Document(fileName,
UseVirtFs_true,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
if (root == nullptr)
{
delete doc;
return;
}
for_each_xml_child_node(node, root)
{
if (xmlNameEqual(node, "map"))
{
const std::string name = XML::getProperty(node, "name", "");
if (name.empty())
continue;
const std::string value = XML::getProperty(node, "value", "");
if (value.empty())
continue;
mMaps[name] = value;
}
else if (xmlNameEqual(node, "include"))
{
const std::string name = XML::getProperty(node, "name", "");
if (!name.empty())
loadRemapXmlFile(name, skipError);
continue;
}
}
delete doc;
}
void MapDB::readMap(XmlNodePtrConst node)
{
if (node == nullptr)
return;
const std::string map = XML::getProperty(node, "name", "");
if (map.empty())
return;
for_each_xml_child_node(childNode, node)
{
if (xmlNameEqual(childNode, "atlas"))
{
const std::string atlas = XML::getProperty(childNode, "name", "");
if (atlas.empty())
continue;
mInfos[map].atlas = atlas;
}
}
}
void MapDB::readAtlas(XmlNodePtrConst node)
{
if (node == nullptr)
return;
const std::string atlas = XML::getProperty(node, "name", "");
if (atlas.empty())
return;
for_each_xml_child_node(childNode, node)
{
if (xmlNameEqual(childNode, "file"))
{
const std::string file = XML::getProperty(childNode, "name", "");
if (file.empty())
continue;
mAtlases[atlas].push_back(file);
}
}
if (atlas == paths.getStringValue("emptyAtlasName"))
{
const StringVect *files = &mAtlases[atlas];
FOR_EACHP (StringVectCIter, it, files)
{
mEmptyTilesets.insert(*it);
logger->log("empty tileset: " + *it);
}
}
else if (atlas != "all")
{
const AtlasCIter &allAtlas = mAtlases.find("all");
if (allAtlas != mAtlases.end())
{
FOR_EACH (StringVectCIter, it, (*allAtlas).second)
mAtlases[atlas].push_back(*it);
}
}
}
void MapDB::loadInfo(const std::string &fileName,
const SkipError skipError)
{
XML::Document *doc = new XML::Document(fileName,
UseVirtFs_true,
skipError);
XmlNodeConstPtrConst root = doc->rootNode();
if (root == nullptr)
{
delete doc;
return;
}
for_each_xml_child_node(node, root)
{
if (xmlNameEqual(node, "map"))
{
readMap(node);
}
else if (xmlNameEqual(node, "atlas"))
{
readAtlas(node);
}
else if (xmlNameEqual(node, "include"))
{
const std::string name = XML::getProperty(node, "name", "");
if (!name.empty())
loadInfo(name, skipError);
continue;
}
}
delete doc;
}
void MapDB::unload()
{
logger->log1("Unloading map database...");
mMaps.clear();
mLoaded = false;
}
const std::string MapDB::getMapName(const std::string &name)
{
const MapIterator it = mMaps.find(name);
if (it != mMaps.end())
return it->second;
return name;
}
const MapInfo *MapDB::getMapAtlas(const std::string &name)
{
const MapInfoIter it = mInfos.find(name);
if (it == mInfos.end())
return nullptr;
MapInfo *const info = &(*it).second;
const AtlasCIter it2 = mAtlases.find(info->atlas);
if (it2 == mAtlases.end())
return nullptr;
info->files = &((*it2).second);
return info;
}
const MapInfo *MapDB::getAtlas(const std::string &name)
{
const AtlasCIter it = mAtlases.find(name);
if (it == mAtlases.end())
return nullptr;
MapInfo *const info = new MapInfo;
info->atlas = name;
info->files = &(*it).second;
return info;
}
bool MapDB::isEmptyTileset(const std::string &name)
{
return mEmptyTilesets.find(name) != mEmptyTilesets.end();
}
| ManaPlus/ManaPlus | src/resources/db/mapdb.cpp | C++ | gpl-2.0 | 6,254 | [
30522,
1013,
1008,
1008,
1996,
24951,
24759,
2271,
7396,
1008,
9385,
1006,
1039,
1007,
2263,
29347,
16921,
2527,
2458,
2136,
1008,
9385,
1006,
1039,
1007,
2249,
1011,
10476,
1996,
24951,
24759,
2271,
9797,
1008,
9385,
1006,
1039,
1007,
1047... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.
using System;
using System.Collections.Generic;
using System.Linq;
using Hyak.Common;
using Microsoft.Azure.Management.DataLake.AnalyticsCatalog.Models;
namespace Microsoft.Azure.Management.DataLake.AnalyticsCatalog.Models
{
/// <summary>
/// A Data Lake Analytics catalog U-SQL table valued function item list.
/// </summary>
public partial class USqlTableValuedFunctionList : CatalogItemList
{
private IList<USqlTableValuedFunction> _value;
/// <summary>
/// Optional. Gets or sets the list of table valued functions in the
/// database and schema combination
/// </summary>
public IList<USqlTableValuedFunction> Value
{
get { return this._value; }
set { this._value = value; }
}
/// <summary>
/// Initializes a new instance of the USqlTableValuedFunctionList class.
/// </summary>
public USqlTableValuedFunctionList()
{
this.Value = new LazyList<USqlTableValuedFunction>();
}
}
}
| nemanja88/azure-sdk-for-net | src/ResourceManagement/DataLake.AnalyticsCatalog/DataLakeAnalyticsCatalogManagement/Generated/Models/USqlTableValuedFunctionList.cs | C# | apache-2.0 | 1,862 | [
30522,
1013,
1013,
1013,
1013,
9385,
1006,
1039,
1007,
7513,
1998,
16884,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
1013,
1013,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2012 Roman Kashitsyn
*
* 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.rulesdsl.predicates;
import org.rulesdsl.Selector;
/**
* @author Roman Kashitsyn
*/
public enum StatelessSelectors implements Selector<Object> {
Anything {
public boolean matches(Object o) {
return true;
}
@Override public String toString() {
return "anything";
}
},
Null {
public boolean matches(Object o) {
return o == null;
}
@Override public String toString() {
return "null?";
}
},
NotNull {
public boolean matches(Object o) {
return o != null;
}
@Override public String toString() {
return "notNull?";
}
};
public boolean apply(Object o) {
return matches(o);
}
}
| roman-kashitsyn/rules-dsl | src/main/java/org/rulesdsl/predicates/StatelessSelectors.java | Java | apache-2.0 | 1,449 | [
30522,
1013,
1008,
1008,
9385,
2262,
3142,
10556,
6182,
3215,
6038,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Performance events core code:
*
* Copyright (C) 2008 Thomas Gleixner <tglx@linutronix.de>
* Copyright (C) 2008-2011 Red Hat, Inc., Ingo Molnar
* Copyright (C) 2008-2011 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
* Copyright © 2009 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
*
* For licensing details see kernel-base/COPYING
*/
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/idr.h>
#include <linux/file.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/hash.h>
#include <linux/sysfs.h>
#include <linux/dcache.h>
#include <linux/percpu.h>
#include <linux/ptrace.h>
#include <linux/reboot.h>
#include <linux/vmstat.h>
#include <linux/device.h>
#include <linux/export.h>
#include <linux/vmalloc.h>
#include <linux/hardirq.h>
#include <linux/rculist.h>
#include <linux/uaccess.h>
#include <linux/syscalls.h>
#include <linux/anon_inodes.h>
#include <linux/kernel_stat.h>
#include <linux/perf_event.h>
#include <linux/ftrace_event.h>
#include <linux/hw_breakpoint.h>
#include <linux/compat.h>
#include "internal.h"
#include <asm/irq_regs.h>
struct remote_function_call {
struct task_struct *p;
int (*func)(void *info);
void *info;
int ret;
};
static void remote_function(void *data)
{
struct remote_function_call *tfc = data;
struct task_struct *p = tfc->p;
if (p) {
tfc->ret = -EAGAIN;
if (task_cpu(p) != smp_processor_id() || !task_curr(p))
return;
}
tfc->ret = tfc->func(tfc->info);
}
/**
* task_function_call - call a function on the cpu on which a task runs
* @p: the task to evaluate
* @func: the function to be called
* @info: the function call argument
*
* Calls the function @func when the task is currently running. This might
* be on the current CPU, which just calls the function directly
*
* returns: @func return value, or
* -ESRCH - when the process isn't running
* -EAGAIN - when the process moved away
*/
static int
task_function_call(struct task_struct *p, int (*func) (void *info), void *info)
{
struct remote_function_call data = {
.p = p,
.func = func,
.info = info,
.ret = -ESRCH, /* No such (running) process */
};
if (task_curr(p))
smp_call_function_single(task_cpu(p), remote_function, &data, 1);
return data.ret;
}
/**
* cpu_function_call - call a function on the cpu
* @func: the function to be called
* @info: the function call argument
*
* Calls the function @func on the remote cpu.
*
* returns: @func return value or -ENXIO when the cpu is offline
*/
static int cpu_function_call(int cpu, int (*func) (void *info), void *info)
{
struct remote_function_call data = {
.p = NULL,
.func = func,
.info = info,
.ret = -ENXIO, /* No such CPU */
};
smp_call_function_single(cpu, remote_function, &data, 1);
return data.ret;
}
#define PERF_FLAG_ALL (PERF_FLAG_FD_NO_GROUP |\
PERF_FLAG_FD_OUTPUT |\
PERF_FLAG_PID_CGROUP)
/*
* branch priv levels that need permission checks
*/
#define PERF_SAMPLE_BRANCH_PERM_PLM \
(PERF_SAMPLE_BRANCH_KERNEL |\
PERF_SAMPLE_BRANCH_HV)
enum event_type_t {
EVENT_FLEXIBLE = 0x1,
EVENT_PINNED = 0x2,
EVENT_ALL = EVENT_FLEXIBLE | EVENT_PINNED,
};
/*
* perf_sched_events : >0 events exist
* perf_cgroup_events: >0 per-cpu cgroup events exist on this cpu
*/
struct static_key_deferred perf_sched_events __read_mostly;
static DEFINE_PER_CPU(atomic_t, perf_cgroup_events);
static DEFINE_PER_CPU(atomic_t, perf_branch_stack_events);
static atomic_t nr_mmap_events __read_mostly;
static atomic_t nr_comm_events __read_mostly;
static atomic_t nr_task_events __read_mostly;
static LIST_HEAD(pmus);
static DEFINE_MUTEX(pmus_lock);
static struct srcu_struct pmus_srcu;
/*
* perf event paranoia level:
* -1 - not paranoid at all
* 0 - disallow raw tracepoint access for unpriv
* 1 - disallow cpu events for unpriv
* 2 - disallow kernel profiling for unpriv
*/
int sysctl_perf_event_paranoid __read_mostly = 1;
/* Minimum for 512 kiB + 1 user control page */
int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
/*
* max perf event sample rate
*/
#define DEFAULT_MAX_SAMPLE_RATE 100000
int sysctl_perf_event_sample_rate __read_mostly = DEFAULT_MAX_SAMPLE_RATE;
static int max_samples_per_tick __read_mostly =
DIV_ROUND_UP(DEFAULT_MAX_SAMPLE_RATE, HZ);
int perf_proc_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
int ret = proc_dointvec(table, write, buffer, lenp, ppos);
if (ret || !write)
return ret;
max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ);
return 0;
}
static atomic64_t perf_event_id;
static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
enum event_type_t event_type);
static void cpu_ctx_sched_in(struct perf_cpu_context *cpuctx,
enum event_type_t event_type,
struct task_struct *task);
static void update_context_time(struct perf_event_context *ctx);
static u64 perf_event_time(struct perf_event *event);
void __weak perf_event_print_debug(void) { }
extern __weak const char *perf_pmu_name(void)
{
return "pmu";
}
static inline u64 perf_clock(void)
{
return local_clock();
}
static inline struct perf_cpu_context *
__get_cpu_context(struct perf_event_context *ctx)
{
return this_cpu_ptr(ctx->pmu->pmu_cpu_context);
}
static void perf_ctx_lock(struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
raw_spin_lock(&cpuctx->ctx.lock);
if (ctx)
raw_spin_lock(&ctx->lock);
}
static void perf_ctx_unlock(struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
if (ctx)
raw_spin_unlock(&ctx->lock);
raw_spin_unlock(&cpuctx->ctx.lock);
}
#ifdef CONFIG_CGROUP_PERF
/*
* Must ensure cgroup is pinned (css_get) before calling
* this function. In other words, we cannot call this function
* if there is no cgroup event for the current CPU context.
*/
static inline struct perf_cgroup *
perf_cgroup_from_task(struct task_struct *task)
{
return container_of(task_subsys_state(task, perf_subsys_id),
struct perf_cgroup, css);
}
static inline bool
perf_cgroup_match(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
return !event->cgrp || event->cgrp == cpuctx->cgrp;
}
static inline bool perf_tryget_cgroup(struct perf_event *event)
{
return css_tryget(&event->cgrp->css);
}
static inline void perf_put_cgroup(struct perf_event *event)
{
css_put(&event->cgrp->css);
}
static inline void perf_detach_cgroup(struct perf_event *event)
{
perf_put_cgroup(event);
event->cgrp = NULL;
}
static inline int is_cgroup_event(struct perf_event *event)
{
return event->cgrp != NULL;
}
static inline u64 perf_cgroup_event_time(struct perf_event *event)
{
struct perf_cgroup_info *t;
t = per_cpu_ptr(event->cgrp->info, event->cpu);
return t->time;
}
static inline void __update_cgrp_time(struct perf_cgroup *cgrp)
{
struct perf_cgroup_info *info;
u64 now;
now = perf_clock();
info = this_cpu_ptr(cgrp->info);
info->time += now - info->timestamp;
info->timestamp = now;
}
static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx)
{
struct perf_cgroup *cgrp_out = cpuctx->cgrp;
if (cgrp_out)
__update_cgrp_time(cgrp_out);
}
static inline void update_cgrp_time_from_event(struct perf_event *event)
{
struct perf_cgroup *cgrp;
/*
* ensure we access cgroup data only when needed and
* when we know the cgroup is pinned (css_get)
*/
if (!is_cgroup_event(event))
return;
cgrp = perf_cgroup_from_task(current);
/*
* Do not update time when cgroup is not active
*/
if (cgrp == event->cgrp)
__update_cgrp_time(event->cgrp);
}
static inline void
perf_cgroup_set_timestamp(struct task_struct *task,
struct perf_event_context *ctx)
{
struct perf_cgroup *cgrp;
struct perf_cgroup_info *info;
/*
* ctx->lock held by caller
* ensure we do not access cgroup data
* unless we have the cgroup pinned (css_get)
*/
if (!task || !ctx->nr_cgroups)
return;
cgrp = perf_cgroup_from_task(task);
info = this_cpu_ptr(cgrp->info);
info->timestamp = ctx->timestamp;
}
#define PERF_CGROUP_SWOUT 0x1 /* cgroup switch out every event */
#define PERF_CGROUP_SWIN 0x2 /* cgroup switch in events based on task */
/*
* reschedule events based on the cgroup constraint of task.
*
* mode SWOUT : schedule out everything
* mode SWIN : schedule in based on cgroup for next
*/
void perf_cgroup_switch(struct task_struct *task, int mode)
{
struct perf_cpu_context *cpuctx;
struct pmu *pmu;
unsigned long flags;
/*
* disable interrupts to avoid geting nr_cgroup
* changes via __perf_event_disable(). Also
* avoids preemption.
*/
local_irq_save(flags);
/*
* we reschedule only in the presence of cgroup
* constrained events.
*/
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->unique_pmu != pmu)
continue; /* ensure we process each cpuctx once */
/*
* perf_cgroup_events says at least one
* context on this CPU has cgroup events.
*
* ctx->nr_cgroups reports the number of cgroup
* events for a context.
*/
if (cpuctx->ctx.nr_cgroups > 0) {
perf_ctx_lock(cpuctx, cpuctx->task_ctx);
perf_pmu_disable(cpuctx->ctx.pmu);
if (mode & PERF_CGROUP_SWOUT) {
cpu_ctx_sched_out(cpuctx, EVENT_ALL);
/*
* must not be done before ctxswout due
* to event_filter_match() in event_sched_out()
*/
cpuctx->cgrp = NULL;
}
if (mode & PERF_CGROUP_SWIN) {
WARN_ON_ONCE(cpuctx->cgrp);
/*
* set cgrp before ctxsw in to allow
* event_filter_match() to not have to pass
* task around
*/
cpuctx->cgrp = perf_cgroup_from_task(task);
cpu_ctx_sched_in(cpuctx, EVENT_ALL, task);
}
perf_pmu_enable(cpuctx->ctx.pmu);
perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
}
}
rcu_read_unlock();
local_irq_restore(flags);
}
static inline void perf_cgroup_sched_out(struct task_struct *task,
struct task_struct *next)
{
struct perf_cgroup *cgrp1;
struct perf_cgroup *cgrp2 = NULL;
/*
* we come here when we know perf_cgroup_events > 0
*/
cgrp1 = perf_cgroup_from_task(task);
/*
* next is NULL when called from perf_event_enable_on_exec()
* that will systematically cause a cgroup_switch()
*/
if (next)
cgrp2 = perf_cgroup_from_task(next);
/*
* only schedule out current cgroup events if we know
* that we are switching to a different cgroup. Otherwise,
* do no touch the cgroup events.
*/
if (cgrp1 != cgrp2)
perf_cgroup_switch(task, PERF_CGROUP_SWOUT);
}
static inline void perf_cgroup_sched_in(struct task_struct *prev,
struct task_struct *task)
{
struct perf_cgroup *cgrp1;
struct perf_cgroup *cgrp2 = NULL;
/*
* we come here when we know perf_cgroup_events > 0
*/
cgrp1 = perf_cgroup_from_task(task);
/* prev can never be NULL */
cgrp2 = perf_cgroup_from_task(prev);
/*
* only need to schedule in cgroup events if we are changing
* cgroup during ctxsw. Cgroup events were not scheduled
* out of ctxsw out if that was not the case.
*/
if (cgrp1 != cgrp2)
perf_cgroup_switch(task, PERF_CGROUP_SWIN);
}
static inline int perf_cgroup_connect(int fd, struct perf_event *event,
struct perf_event_attr *attr,
struct perf_event *group_leader)
{
struct perf_cgroup *cgrp;
struct cgroup_subsys_state *css;
struct file *file;
int ret = 0, fput_needed;
file = fget_light(fd, &fput_needed);
if (!file)
return -EBADF;
css = cgroup_css_from_dir(file, perf_subsys_id);
if (IS_ERR(css)) {
ret = PTR_ERR(css);
goto out;
}
cgrp = container_of(css, struct perf_cgroup, css);
event->cgrp = cgrp;
/* must be done before we fput() the file */
if (!perf_tryget_cgroup(event)) {
event->cgrp = NULL;
ret = -ENOENT;
goto out;
}
/*
* all events in a group must monitor
* the same cgroup because a task belongs
* to only one perf cgroup at a time
*/
if (group_leader && group_leader->cgrp != cgrp) {
perf_detach_cgroup(event);
ret = -EINVAL;
}
out:
fput_light(file, fput_needed);
return ret;
}
static inline void
perf_cgroup_set_shadow_time(struct perf_event *event, u64 now)
{
struct perf_cgroup_info *t;
t = per_cpu_ptr(event->cgrp->info, event->cpu);
event->shadow_ctx_time = now - t->timestamp;
}
static inline void
perf_cgroup_defer_enabled(struct perf_event *event)
{
/*
* when the current task's perf cgroup does not match
* the event's, we need to remember to call the
* perf_mark_enable() function the first time a task with
* a matching perf cgroup is scheduled in.
*/
if (is_cgroup_event(event) && !perf_cgroup_match(event))
event->cgrp_defer_enabled = 1;
}
static inline void
perf_cgroup_mark_enabled(struct perf_event *event,
struct perf_event_context *ctx)
{
struct perf_event *sub;
u64 tstamp = perf_event_time(event);
if (!event->cgrp_defer_enabled)
return;
event->cgrp_defer_enabled = 0;
event->tstamp_enabled = tstamp - event->total_time_enabled;
list_for_each_entry(sub, &event->sibling_list, group_entry) {
if (sub->state >= PERF_EVENT_STATE_INACTIVE) {
sub->tstamp_enabled = tstamp - sub->total_time_enabled;
sub->cgrp_defer_enabled = 0;
}
}
}
#else /* !CONFIG_CGROUP_PERF */
static inline bool
perf_cgroup_match(struct perf_event *event)
{
return true;
}
static inline void perf_detach_cgroup(struct perf_event *event)
{}
static inline int is_cgroup_event(struct perf_event *event)
{
return 0;
}
static inline u64 perf_cgroup_event_cgrp_time(struct perf_event *event)
{
return 0;
}
static inline void update_cgrp_time_from_event(struct perf_event *event)
{
}
static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx)
{
}
static inline void perf_cgroup_sched_out(struct task_struct *task,
struct task_struct *next)
{
}
static inline void perf_cgroup_sched_in(struct task_struct *prev,
struct task_struct *task)
{
}
static inline int perf_cgroup_connect(pid_t pid, struct perf_event *event,
struct perf_event_attr *attr,
struct perf_event *group_leader)
{
return -EINVAL;
}
static inline void
perf_cgroup_set_timestamp(struct task_struct *task,
struct perf_event_context *ctx)
{
}
void
perf_cgroup_switch(struct task_struct *task, struct task_struct *next)
{
}
static inline void
perf_cgroup_set_shadow_time(struct perf_event *event, u64 now)
{
}
static inline u64 perf_cgroup_event_time(struct perf_event *event)
{
return 0;
}
static inline void
perf_cgroup_defer_enabled(struct perf_event *event)
{
}
static inline void
perf_cgroup_mark_enabled(struct perf_event *event,
struct perf_event_context *ctx)
{
}
#endif
void perf_pmu_disable(struct pmu *pmu)
{
int *count = this_cpu_ptr(pmu->pmu_disable_count);
if (!(*count)++)
pmu->pmu_disable(pmu);
}
void perf_pmu_enable(struct pmu *pmu)
{
int *count = this_cpu_ptr(pmu->pmu_disable_count);
if (!--(*count))
pmu->pmu_enable(pmu);
}
static DEFINE_PER_CPU(struct list_head, rotation_list);
/*
* perf_pmu_rotate_start() and perf_rotate_context() are fully serialized
* because they're strictly cpu affine and rotate_start is called with IRQs
* disabled, while rotate_context is called from IRQ context.
*/
static void perf_pmu_rotate_start(struct pmu *pmu)
{
struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
struct list_head *head = &__get_cpu_var(rotation_list);
WARN_ON(!irqs_disabled());
if (list_empty(&cpuctx->rotation_list))
list_add(&cpuctx->rotation_list, head);
}
static void get_ctx(struct perf_event_context *ctx)
{
WARN_ON(!atomic_inc_not_zero(&ctx->refcount));
}
static void put_ctx(struct perf_event_context *ctx)
{
if (atomic_dec_and_test(&ctx->refcount)) {
if (ctx->parent_ctx)
put_ctx(ctx->parent_ctx);
if (ctx->task)
put_task_struct(ctx->task);
kfree_rcu(ctx, rcu_head);
}
}
static void unclone_ctx(struct perf_event_context *ctx)
{
if (ctx->parent_ctx) {
put_ctx(ctx->parent_ctx);
ctx->parent_ctx = NULL;
}
}
static u32 perf_event_pid(struct perf_event *event, struct task_struct *p)
{
/*
* only top level events have the pid namespace they were created in
*/
if (event->parent)
event = event->parent;
return task_tgid_nr_ns(p, event->ns);
}
static u32 perf_event_tid(struct perf_event *event, struct task_struct *p)
{
/*
* only top level events have the pid namespace they were created in
*/
if (event->parent)
event = event->parent;
return task_pid_nr_ns(p, event->ns);
}
/*
* If we inherit events we want to return the parent event id
* to userspace.
*/
static u64 primary_event_id(struct perf_event *event)
{
u64 id = event->id;
if (event->parent)
id = event->parent->id;
return id;
}
/*
* Get the perf_event_context for a task and lock it.
* This has to cope with with the fact that until it is locked,
* the context could get moved to another task.
*/
static struct perf_event_context *
perf_lock_task_context(struct task_struct *task, int ctxn, unsigned long *flags)
{
struct perf_event_context *ctx;
retry:
/*
* One of the few rules of preemptible RCU is that one cannot do
* rcu_read_unlock() while holding a scheduler (or nested) lock when
* part of the read side critical section was preemptible -- see
* rcu_read_unlock_special().
*
* Since ctx->lock nests under rq->lock we must ensure the entire read
* side critical section is non-preemptible.
*/
preempt_disable();
rcu_read_lock();
ctx = rcu_dereference(task->perf_event_ctxp[ctxn]);
if (ctx) {
/*
* If this context is a clone of another, it might
* get swapped for another underneath us by
* perf_event_task_sched_out, though the
* rcu_read_lock() protects us from any context
* getting freed. Lock the context and check if it
* got swapped before we could get the lock, and retry
* if so. If we locked the right context, then it
* can't get swapped on us any more.
*/
raw_spin_lock_irqsave(&ctx->lock, *flags);
if (ctx != rcu_dereference(task->perf_event_ctxp[ctxn])) {
raw_spin_unlock_irqrestore(&ctx->lock, *flags);
rcu_read_unlock();
preempt_enable();
goto retry;
}
if (!atomic_inc_not_zero(&ctx->refcount)) {
raw_spin_unlock_irqrestore(&ctx->lock, *flags);
ctx = NULL;
}
}
rcu_read_unlock();
preempt_enable();
return ctx;
}
/*
* Get the context for a task and increment its pin_count so it
* can't get swapped to another task. This also increments its
* reference count so that the context can't get freed.
*/
static struct perf_event_context *
perf_pin_task_context(struct task_struct *task, int ctxn)
{
struct perf_event_context *ctx;
unsigned long flags;
ctx = perf_lock_task_context(task, ctxn, &flags);
if (ctx) {
++ctx->pin_count;
raw_spin_unlock_irqrestore(&ctx->lock, flags);
}
return ctx;
}
static void perf_unpin_context(struct perf_event_context *ctx)
{
unsigned long flags;
raw_spin_lock_irqsave(&ctx->lock, flags);
--ctx->pin_count;
raw_spin_unlock_irqrestore(&ctx->lock, flags);
}
/*
* Update the record of the current time in a context.
*/
static void update_context_time(struct perf_event_context *ctx)
{
u64 now = perf_clock();
ctx->time += now - ctx->timestamp;
ctx->timestamp = now;
}
static u64 perf_event_time(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
if (is_cgroup_event(event))
return perf_cgroup_event_time(event);
return ctx ? ctx->time : 0;
}
/*
* Update the total_time_enabled and total_time_running fields for a event.
* The caller of this function needs to hold the ctx->lock.
*/
static void update_event_times(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
u64 run_end;
if (event->state < PERF_EVENT_STATE_INACTIVE ||
event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
return;
/*
* in cgroup mode, time_enabled represents
* the time the event was enabled AND active
* tasks were in the monitored cgroup. This is
* independent of the activity of the context as
* there may be a mix of cgroup and non-cgroup events.
*
* That is why we treat cgroup events differently
* here.
*/
if (is_cgroup_event(event))
run_end = perf_cgroup_event_time(event);
else if (ctx->is_active)
run_end = ctx->time;
else
run_end = event->tstamp_stopped;
event->total_time_enabled = run_end - event->tstamp_enabled;
if (event->state == PERF_EVENT_STATE_INACTIVE)
run_end = event->tstamp_stopped;
else
run_end = perf_event_time(event);
event->total_time_running = run_end - event->tstamp_running;
}
/*
* Update total_time_enabled and total_time_running for all events in a group.
*/
static void update_group_times(struct perf_event *leader)
{
struct perf_event *event;
update_event_times(leader);
list_for_each_entry(event, &leader->sibling_list, group_entry)
update_event_times(event);
}
static struct list_head *
ctx_group_list(struct perf_event *event, struct perf_event_context *ctx)
{
if (event->attr.pinned)
return &ctx->pinned_groups;
else
return &ctx->flexible_groups;
}
/*
* Add a event from the lists for its context.
* Must be called with ctx->mutex and ctx->lock held.
*/
static void
list_add_event(struct perf_event *event, struct perf_event_context *ctx)
{
WARN_ON_ONCE(event->attach_state & PERF_ATTACH_CONTEXT);
event->attach_state |= PERF_ATTACH_CONTEXT;
/*
* If we're a stand alone event or group leader, we go to the context
* list, group events are kept attached to the group so that
* perf_group_detach can, at all times, locate all siblings.
*/
if (event->group_leader == event) {
struct list_head *list;
if (is_software_event(event))
event->group_flags |= PERF_GROUP_SOFTWARE;
list = ctx_group_list(event, ctx);
list_add_tail(&event->group_entry, list);
}
if (is_cgroup_event(event))
ctx->nr_cgroups++;
if (has_branch_stack(event))
ctx->nr_branch_stack++;
list_add_rcu(&event->event_entry, &ctx->event_list);
if (!ctx->nr_events)
perf_pmu_rotate_start(ctx->pmu);
ctx->nr_events++;
if (event->attr.inherit_stat)
ctx->nr_stat++;
}
/*
* Initialize event state based on the perf_event_attr::disabled.
*/
static inline void perf_event__state_init(struct perf_event *event)
{
event->state = event->attr.disabled ? PERF_EVENT_STATE_OFF :
PERF_EVENT_STATE_INACTIVE;
}
/*
* Called at perf_event creation and when events are attached/detached from a
* group.
*/
static void perf_event__read_size(struct perf_event *event)
{
int entry = sizeof(u64); /* value */
int size = 0;
int nr = 1;
if (event->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
size += sizeof(u64);
if (event->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
size += sizeof(u64);
if (event->attr.read_format & PERF_FORMAT_ID)
entry += sizeof(u64);
if (event->attr.read_format & PERF_FORMAT_GROUP) {
nr += event->group_leader->nr_siblings;
size += sizeof(u64);
}
size += entry * nr;
event->read_size = size;
}
static void perf_event__header_size(struct perf_event *event)
{
struct perf_sample_data *data;
u64 sample_type = event->attr.sample_type;
u16 size = 0;
perf_event__read_size(event);
if (sample_type & PERF_SAMPLE_IP)
size += sizeof(data->ip);
if (sample_type & PERF_SAMPLE_ADDR)
size += sizeof(data->addr);
if (sample_type & PERF_SAMPLE_PERIOD)
size += sizeof(data->period);
if (sample_type & PERF_SAMPLE_READ)
size += event->read_size;
event->header_size = size;
}
static void perf_event__id_header_size(struct perf_event *event)
{
struct perf_sample_data *data;
u64 sample_type = event->attr.sample_type;
u16 size = 0;
if (sample_type & PERF_SAMPLE_TID)
size += sizeof(data->tid_entry);
if (sample_type & PERF_SAMPLE_TIME)
size += sizeof(data->time);
if (sample_type & PERF_SAMPLE_ID)
size += sizeof(data->id);
if (sample_type & PERF_SAMPLE_STREAM_ID)
size += sizeof(data->stream_id);
if (sample_type & PERF_SAMPLE_CPU)
size += sizeof(data->cpu_entry);
event->id_header_size = size;
}
static void perf_group_attach(struct perf_event *event)
{
struct perf_event *group_leader = event->group_leader, *pos;
/*
* We can have double attach due to group movement in perf_event_open.
*/
if (event->attach_state & PERF_ATTACH_GROUP)
return;
event->attach_state |= PERF_ATTACH_GROUP;
if (group_leader == event)
return;
if (group_leader->group_flags & PERF_GROUP_SOFTWARE &&
!is_software_event(event))
group_leader->group_flags &= ~PERF_GROUP_SOFTWARE;
list_add_tail(&event->group_entry, &group_leader->sibling_list);
group_leader->nr_siblings++;
perf_event__header_size(group_leader);
list_for_each_entry(pos, &group_leader->sibling_list, group_entry)
perf_event__header_size(pos);
}
/*
* Remove a event from the lists for its context.
* Must be called with ctx->mutex and ctx->lock held.
*/
static void
list_del_event(struct perf_event *event, struct perf_event_context *ctx)
{
struct perf_cpu_context *cpuctx;
/*
* We can have double detach due to exit/hot-unplug + close.
*/
if (!(event->attach_state & PERF_ATTACH_CONTEXT))
return;
event->attach_state &= ~PERF_ATTACH_CONTEXT;
if (is_cgroup_event(event)) {
ctx->nr_cgroups--;
cpuctx = __get_cpu_context(ctx);
/*
* if there are no more cgroup events
* then cler cgrp to avoid stale pointer
* in update_cgrp_time_from_cpuctx()
*/
if (!ctx->nr_cgroups)
cpuctx->cgrp = NULL;
}
if (has_branch_stack(event))
ctx->nr_branch_stack--;
ctx->nr_events--;
if (event->attr.inherit_stat)
ctx->nr_stat--;
list_del_rcu(&event->event_entry);
if (event->group_leader == event)
list_del_init(&event->group_entry);
update_group_times(event);
/*
* If event was in error state, then keep it
* that way, otherwise bogus counts will be
* returned on read(). The only way to get out
* of error state is by explicit re-enabling
* of the event
*/
if (event->state > PERF_EVENT_STATE_OFF)
event->state = PERF_EVENT_STATE_OFF;
}
static void perf_group_detach(struct perf_event *event)
{
struct perf_event *sibling, *tmp;
struct list_head *list = NULL;
/*
* We can have double detach due to exit/hot-unplug + close.
*/
if (!(event->attach_state & PERF_ATTACH_GROUP))
return;
event->attach_state &= ~PERF_ATTACH_GROUP;
/*
* If this is a sibling, remove it from its group.
*/
if (event->group_leader != event) {
list_del_init(&event->group_entry);
event->group_leader->nr_siblings--;
goto out;
}
if (!list_empty(&event->group_entry))
list = &event->group_entry;
/*
* If this was a group event with sibling events then
* upgrade the siblings to singleton events by adding them
* to whatever list we are on.
*/
list_for_each_entry_safe(sibling, tmp, &event->sibling_list, group_entry) {
if (list)
list_move_tail(&sibling->group_entry, list);
sibling->group_leader = sibling;
/* Inherit group flags from the previous leader */
sibling->group_flags = event->group_flags;
}
out:
perf_event__header_size(event->group_leader);
list_for_each_entry(tmp, &event->group_leader->sibling_list, group_entry)
perf_event__header_size(tmp);
}
static inline int
event_filter_match(struct perf_event *event)
{
return (event->cpu == -1 || event->cpu == smp_processor_id())
&& perf_cgroup_match(event);
}
static void
event_sched_out(struct perf_event *event,
struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
u64 tstamp = perf_event_time(event);
u64 delta;
/*
* An event which could not be activated because of
* filter mismatch still needs to have its timings
* maintained, otherwise bogus information is return
* via read() for time_enabled, time_running:
*/
if (event->state == PERF_EVENT_STATE_INACTIVE
&& !event_filter_match(event)) {
delta = tstamp - event->tstamp_stopped;
event->tstamp_running += delta;
event->tstamp_stopped = tstamp;
}
if (event->state != PERF_EVENT_STATE_ACTIVE)
return;
event->state = PERF_EVENT_STATE_INACTIVE;
if (event->pending_disable) {
event->pending_disable = 0;
event->state = PERF_EVENT_STATE_OFF;
}
event->tstamp_stopped = tstamp;
event->pmu->del(event, 0);
event->oncpu = -1;
if (!is_software_event(event))
cpuctx->active_oncpu--;
ctx->nr_active--;
if (event->attr.freq && event->attr.sample_freq)
ctx->nr_freq--;
if (event->attr.exclusive || !cpuctx->active_oncpu)
cpuctx->exclusive = 0;
}
static void
group_sched_out(struct perf_event *group_event,
struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
struct perf_event *event;
int state = group_event->state;
event_sched_out(group_event, cpuctx, ctx);
/*
* Schedule out siblings (if any):
*/
list_for_each_entry(event, &group_event->sibling_list, group_entry)
event_sched_out(event, cpuctx, ctx);
if (state == PERF_EVENT_STATE_ACTIVE && group_event->attr.exclusive)
cpuctx->exclusive = 0;
}
struct remove_event {
struct perf_event *event;
bool detach_group;
};
/*
* Cross CPU call to remove a performance event
*
* We disable the event on the hardware level first. After that we
* remove it from the context list.
*/
static int __perf_remove_from_context(void *info)
{
struct remove_event *re = info;
struct perf_event *event = re->event;
struct perf_event_context *ctx = event->ctx;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
raw_spin_lock(&ctx->lock);
event_sched_out(event, cpuctx, ctx);
if (re->detach_group)
perf_group_detach(event);
list_del_event(event, ctx);
if (!ctx->nr_events && cpuctx->task_ctx == ctx) {
ctx->is_active = 0;
cpuctx->task_ctx = NULL;
}
raw_spin_unlock(&ctx->lock);
return 0;
}
#ifdef CONFIG_SMP
static void perf_retry_remove(struct remove_event *re)
{
int up_ret;
/*
* CPU was offline. Bring it online so we can
* gracefully exit a perf context.
*/
up_ret = cpu_up(re->event->cpu);
if (!up_ret)
/* Try the remove call once again. */
cpu_function_call(re->event->cpu, __perf_remove_from_context, re);
else
pr_err("Failed to bring up CPU: %d, ret: %d\n",
re->event->cpu, up_ret);
}
#else
static void perf_retry_remove(struct remove_event *re)
{
}
#endif
/*
* Remove the event from a task's (or a CPU's) list of events.
*
* CPU events are removed with a smp call. For task events we only
* call when the task is on a CPU.
*
* If event->ctx is a cloned context, callers must make sure that
* every task struct that event->ctx->task could possibly point to
* remains valid. This is OK when called from perf_release since
* that only calls us on the top-level context, which can't be a clone.
* When called from perf_event_exit_task, it's OK because the
* context has been detached from its task.
*/
static void __ref perf_remove_from_context(struct perf_event *event, bool detach_group)
{
struct perf_event_context *ctx = event->ctx;
struct task_struct *task = ctx->task;
struct remove_event re = {
.event = event,
.detach_group = detach_group,
};
int ret;
lockdep_assert_held(&ctx->mutex);
if (!task) {
/*
* Per cpu events are removed via an smp call
*/
ret = cpu_function_call(event->cpu, __perf_remove_from_context, &re);
if (ret == -ENXIO)
perf_retry_remove(&re);
return;
}
retry:
if (!task_function_call(task, __perf_remove_from_context, &re))
return;
raw_spin_lock_irq(&ctx->lock);
/*
* If we failed to find a running task, but find the context active now
* that we've acquired the ctx->lock, retry.
*/
if (ctx->is_active) {
raw_spin_unlock_irq(&ctx->lock);
goto retry;
}
/*
* Since the task isn't running, its safe to remove the event, us
* holding the ctx->lock ensures the task won't get scheduled in.
*/
if (detach_group)
perf_group_detach(event);
list_del_event(event, ctx);
raw_spin_unlock_irq(&ctx->lock);
}
/*
* Cross CPU call to disable a performance event
*/
static int __perf_event_disable(void *info)
{
struct perf_event *event = info;
struct perf_event_context *ctx = event->ctx;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
/*
* If this is a per-task event, need to check whether this
* event's task is the current task on this cpu.
*
* Can trigger due to concurrent perf_event_context_sched_out()
* flipping contexts around.
*/
if (ctx->task && cpuctx->task_ctx != ctx)
return -EINVAL;
raw_spin_lock(&ctx->lock);
/*
* If the event is on, turn it off.
* If it is in error state, leave it in error state.
*/
if (event->state >= PERF_EVENT_STATE_INACTIVE) {
update_context_time(ctx);
update_cgrp_time_from_event(event);
update_group_times(event);
if (event == event->group_leader)
group_sched_out(event, cpuctx, ctx);
else
event_sched_out(event, cpuctx, ctx);
event->state = PERF_EVENT_STATE_OFF;
}
raw_spin_unlock(&ctx->lock);
return 0;
}
/*
* Disable a event.
*
* If event->ctx is a cloned context, callers must make sure that
* every task struct that event->ctx->task could possibly point to
* remains valid. This condition is satisifed when called through
* perf_event_for_each_child or perf_event_for_each because they
* hold the top-level event's child_mutex, so any descendant that
* goes to exit will block in sync_child_event.
* When called from perf_pending_event it's OK because event->ctx
* is the current context on this CPU and preemption is disabled,
* hence we can't get into perf_event_task_sched_out for this context.
*/
void perf_event_disable(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
struct task_struct *task = ctx->task;
if (!task) {
/*
* Disable the event on the cpu that it's on
*/
cpu_function_call(event->cpu, __perf_event_disable, event);
return;
}
retry:
if (!task_function_call(task, __perf_event_disable, event))
return;
raw_spin_lock_irq(&ctx->lock);
/*
* If the event is still active, we need to retry the cross-call.
*/
if (event->state == PERF_EVENT_STATE_ACTIVE) {
raw_spin_unlock_irq(&ctx->lock);
/*
* Reload the task pointer, it might have been changed by
* a concurrent perf_event_context_sched_out().
*/
task = ctx->task;
goto retry;
}
/*
* Since we have the lock this context can't be scheduled
* in, so we can change the state safely.
*/
if (event->state == PERF_EVENT_STATE_INACTIVE) {
update_group_times(event);
event->state = PERF_EVENT_STATE_OFF;
}
raw_spin_unlock_irq(&ctx->lock);
}
EXPORT_SYMBOL_GPL(perf_event_disable);
static void perf_set_shadow_time(struct perf_event *event,
struct perf_event_context *ctx,
u64 tstamp)
{
/*
* use the correct time source for the time snapshot
*
* We could get by without this by leveraging the
* fact that to get to this function, the caller
* has most likely already called update_context_time()
* and update_cgrp_time_xx() and thus both timestamp
* are identical (or very close). Given that tstamp is,
* already adjusted for cgroup, we could say that:
* tstamp - ctx->timestamp
* is equivalent to
* tstamp - cgrp->timestamp.
*
* Then, in perf_output_read(), the calculation would
* work with no changes because:
* - event is guaranteed scheduled in
* - no scheduled out in between
* - thus the timestamp would be the same
*
* But this is a bit hairy.
*
* So instead, we have an explicit cgroup call to remain
* within the time time source all along. We believe it
* is cleaner and simpler to understand.
*/
if (is_cgroup_event(event))
perf_cgroup_set_shadow_time(event, tstamp);
else
event->shadow_ctx_time = tstamp - ctx->timestamp;
}
#define MAX_INTERRUPTS (~0ULL)
static void perf_log_throttle(struct perf_event *event, int enable);
static int
event_sched_in(struct perf_event *event,
struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
u64 tstamp = perf_event_time(event);
if (event->state <= PERF_EVENT_STATE_OFF)
return 0;
event->state = PERF_EVENT_STATE_ACTIVE;
event->oncpu = smp_processor_id();
/*
* Unthrottle events, since we scheduled we might have missed several
* ticks already, also for a heavily scheduling task there is little
* guarantee it'll get a tick in a timely manner.
*/
if (unlikely(event->hw.interrupts == MAX_INTERRUPTS)) {
perf_log_throttle(event, 1);
event->hw.interrupts = 0;
}
/*
* The new state must be visible before we turn it on in the hardware:
*/
smp_wmb();
if (event->pmu->add(event, PERF_EF_START)) {
event->state = PERF_EVENT_STATE_INACTIVE;
event->oncpu = -1;
return -EAGAIN;
}
event->tstamp_running += tstamp - event->tstamp_stopped;
perf_set_shadow_time(event, ctx, tstamp);
if (!is_software_event(event))
cpuctx->active_oncpu++;
ctx->nr_active++;
if (event->attr.freq && event->attr.sample_freq)
ctx->nr_freq++;
if (event->attr.exclusive)
cpuctx->exclusive = 1;
return 0;
}
static int
group_sched_in(struct perf_event *group_event,
struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx)
{
struct perf_event *event, *partial_group = NULL;
struct pmu *pmu = group_event->pmu;
u64 now = ctx->time;
bool simulate = false;
if (group_event->state == PERF_EVENT_STATE_OFF)
return 0;
pmu->start_txn(pmu);
if (event_sched_in(group_event, cpuctx, ctx)) {
pmu->cancel_txn(pmu);
return -EAGAIN;
}
/*
* Schedule in siblings as one group (if any):
*/
list_for_each_entry(event, &group_event->sibling_list, group_entry) {
if (event_sched_in(event, cpuctx, ctx)) {
partial_group = event;
goto group_error;
}
}
if (!pmu->commit_txn(pmu))
return 0;
group_error:
/*
* Groups can be scheduled in as one unit only, so undo any
* partial group before returning:
* The events up to the failed event are scheduled out normally,
* tstamp_stopped will be updated.
*
* The failed events and the remaining siblings need to have
* their timings updated as if they had gone thru event_sched_in()
* and event_sched_out(). This is required to get consistent timings
* across the group. This also takes care of the case where the group
* could never be scheduled by ensuring tstamp_stopped is set to mark
* the time the event was actually stopped, such that time delta
* calculation in update_event_times() is correct.
*/
list_for_each_entry(event, &group_event->sibling_list, group_entry) {
if (event == partial_group)
simulate = true;
if (simulate) {
event->tstamp_running += now - event->tstamp_stopped;
event->tstamp_stopped = now;
} else {
event_sched_out(event, cpuctx, ctx);
}
}
event_sched_out(group_event, cpuctx, ctx);
pmu->cancel_txn(pmu);
return -EAGAIN;
}
/*
* Work out whether we can put this event group on the CPU now.
*/
static int group_can_go_on(struct perf_event *event,
struct perf_cpu_context *cpuctx,
int can_add_hw)
{
/*
* Groups consisting entirely of software events can always go on.
*/
if (event->group_flags & PERF_GROUP_SOFTWARE)
return 1;
/*
* If an exclusive group is already on, no other hardware
* events can go on.
*/
if (cpuctx->exclusive)
return 0;
/*
* If this group is exclusive and there are already
* events on the CPU, it can't go on.
*/
if (event->attr.exclusive && cpuctx->active_oncpu)
return 0;
/*
* Otherwise, try to add it if all previous groups were able
* to go on.
*/
return can_add_hw;
}
static void add_event_to_ctx(struct perf_event *event,
struct perf_event_context *ctx)
{
u64 tstamp = perf_event_time(event);
list_add_event(event, ctx);
perf_group_attach(event);
event->tstamp_enabled = tstamp;
event->tstamp_running = tstamp;
event->tstamp_stopped = tstamp;
}
static void task_ctx_sched_out(struct perf_event_context *ctx);
static void
ctx_sched_in(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx,
enum event_type_t event_type,
struct task_struct *task);
static void perf_event_sched_in(struct perf_cpu_context *cpuctx,
struct perf_event_context *ctx,
struct task_struct *task)
{
cpu_ctx_sched_in(cpuctx, EVENT_PINNED, task);
if (ctx)
ctx_sched_in(ctx, cpuctx, EVENT_PINNED, task);
cpu_ctx_sched_in(cpuctx, EVENT_FLEXIBLE, task);
if (ctx)
ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE, task);
}
/*
* Cross CPU call to install and enable a performance event
*
* Must be called with ctx->mutex held
*/
static int __perf_install_in_context(void *info)
{
struct perf_event *event = info;
struct perf_event_context *ctx = event->ctx;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
struct perf_event_context *task_ctx = cpuctx->task_ctx;
struct task_struct *task = current;
perf_ctx_lock(cpuctx, task_ctx);
perf_pmu_disable(cpuctx->ctx.pmu);
/*
* If there was an active task_ctx schedule it out.
*/
if (task_ctx)
task_ctx_sched_out(task_ctx);
/*
* If the context we're installing events in is not the
* active task_ctx, flip them.
*/
if (ctx->task && task_ctx != ctx) {
if (task_ctx)
raw_spin_unlock(&task_ctx->lock);
raw_spin_lock(&ctx->lock);
task_ctx = ctx;
}
if (task_ctx) {
cpuctx->task_ctx = task_ctx;
task = task_ctx->task;
}
cpu_ctx_sched_out(cpuctx, EVENT_ALL);
update_context_time(ctx);
/*
* update cgrp time only if current cgrp
* matches event->cgrp. Must be done before
* calling add_event_to_ctx()
*/
update_cgrp_time_from_event(event);
add_event_to_ctx(event, ctx);
/*
* Schedule everything back in
*/
perf_event_sched_in(cpuctx, task_ctx, task);
perf_pmu_enable(cpuctx->ctx.pmu);
perf_ctx_unlock(cpuctx, task_ctx);
return 0;
}
/*
* Attach a performance event to a context
*
* First we add the event to the list with the hardware enable bit
* in event->hw_config cleared.
*
* If the event is attached to a task which is on a CPU we use a smp
* call to enable it in the task context. The task might have been
* scheduled away, but we check this in the smp call again.
*/
static void
perf_install_in_context(struct perf_event_context *ctx,
struct perf_event *event,
int cpu)
{
struct task_struct *task = ctx->task;
lockdep_assert_held(&ctx->mutex);
event->ctx = ctx;
if (!task) {
/*
* Per cpu events are installed via an smp call and
* the install is always successful.
*/
cpu_function_call(cpu, __perf_install_in_context, event);
return;
}
retry:
if (!task_function_call(task, __perf_install_in_context, event))
return;
raw_spin_lock_irq(&ctx->lock);
/*
* If we failed to find a running task, but find the context active now
* that we've acquired the ctx->lock, retry.
*/
if (ctx->is_active) {
raw_spin_unlock_irq(&ctx->lock);
/*
* Reload the task pointer, it might have been changed by
* a concurrent perf_event_context_sched_out().
*/
task = ctx->task;
/*
* Reload the task pointer, it might have been changed by
* a concurrent perf_event_context_sched_out().
*/
task = ctx->task;
goto retry;
}
/*
* Since the task isn't running, its safe to add the event, us holding
* the ctx->lock ensures the task won't get scheduled in.
*/
add_event_to_ctx(event, ctx);
raw_spin_unlock_irq(&ctx->lock);
}
/*
* Put a event into inactive state and update time fields.
* Enabling the leader of a group effectively enables all
* the group members that aren't explicitly disabled, so we
* have to update their ->tstamp_enabled also.
* Note: this works for group members as well as group leaders
* since the non-leader members' sibling_lists will be empty.
*/
static void __perf_event_mark_enabled(struct perf_event *event)
{
struct perf_event *sub;
u64 tstamp = perf_event_time(event);
event->state = PERF_EVENT_STATE_INACTIVE;
event->tstamp_enabled = tstamp - event->total_time_enabled;
list_for_each_entry(sub, &event->sibling_list, group_entry) {
if (sub->state >= PERF_EVENT_STATE_INACTIVE)
sub->tstamp_enabled = tstamp - sub->total_time_enabled;
}
}
/*
* Cross CPU call to enable a performance event
*/
static int __perf_event_enable(void *info)
{
struct perf_event *event = info;
struct perf_event_context *ctx = event->ctx;
struct perf_event *leader = event->group_leader;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
int err;
/*
* There's a time window between 'ctx->is_active' check
* in perf_event_enable function and this place having:
* - IRQs on
* - ctx->lock unlocked
*
* where the task could be killed and 'ctx' deactivated
* by perf_event_exit_task.
*/
if (!ctx->is_active)
return -EINVAL;
raw_spin_lock(&ctx->lock);
update_context_time(ctx);
if (event->state >= PERF_EVENT_STATE_INACTIVE)
goto unlock;
/*
* set current task's cgroup time reference point
*/
perf_cgroup_set_timestamp(current, ctx);
__perf_event_mark_enabled(event);
if (!event_filter_match(event)) {
if (is_cgroup_event(event))
perf_cgroup_defer_enabled(event);
goto unlock;
}
/*
* If the event is in a group and isn't the group leader,
* then don't put it on unless the group is on.
*/
if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE)
goto unlock;
if (!group_can_go_on(event, cpuctx, 1)) {
err = -EEXIST;
} else {
if (event == leader)
err = group_sched_in(event, cpuctx, ctx);
else
err = event_sched_in(event, cpuctx, ctx);
}
if (err) {
/*
* If this event can't go on and it's part of a
* group, then the whole group has to come off.
*/
if (leader != event)
group_sched_out(leader, cpuctx, ctx);
if (leader->attr.pinned) {
update_group_times(leader);
leader->state = PERF_EVENT_STATE_ERROR;
}
}
unlock:
raw_spin_unlock(&ctx->lock);
return 0;
}
/*
* Enable a event.
*
* If event->ctx is a cloned context, callers must make sure that
* every task struct that event->ctx->task could possibly point to
* remains valid. This condition is satisfied when called through
* perf_event_for_each_child or perf_event_for_each as described
* for perf_event_disable.
*/
void perf_event_enable(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
struct task_struct *task = ctx->task;
if (!task) {
/*
* Enable the event on the cpu that it's on
*/
cpu_function_call(event->cpu, __perf_event_enable, event);
return;
}
raw_spin_lock_irq(&ctx->lock);
if (event->state >= PERF_EVENT_STATE_INACTIVE)
goto out;
/*
* If the event is in error state, clear that first.
* That way, if we see the event in error state below, we
* know that it has gone back into error state, as distinct
* from the task having been scheduled away before the
* cross-call arrived.
*/
if (event->state == PERF_EVENT_STATE_ERROR)
event->state = PERF_EVENT_STATE_OFF;
retry:
if (!ctx->is_active) {
__perf_event_mark_enabled(event);
goto out;
}
raw_spin_unlock_irq(&ctx->lock);
if (!task_function_call(task, __perf_event_enable, event))
return;
raw_spin_lock_irq(&ctx->lock);
/*
* If the context is active and the event is still off,
* we need to retry the cross-call.
*/
if (ctx->is_active && event->state == PERF_EVENT_STATE_OFF) {
/*
* task could have been flipped by a concurrent
* perf_event_context_sched_out()
*/
task = ctx->task;
goto retry;
}
out:
raw_spin_unlock_irq(&ctx->lock);
}
EXPORT_SYMBOL_GPL(perf_event_enable);
int perf_event_refresh(struct perf_event *event, int refresh)
{
/*
* not supported on inherited events
*/
if (event->attr.inherit || !is_sampling_event(event))
return -EINVAL;
atomic_add(refresh, &event->event_limit);
perf_event_enable(event);
return 0;
}
EXPORT_SYMBOL_GPL(perf_event_refresh);
static void ctx_sched_out(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx,
enum event_type_t event_type)
{
struct perf_event *event;
int is_active = ctx->is_active;
ctx->is_active &= ~event_type;
if (likely(!ctx->nr_events))
return;
update_context_time(ctx);
update_cgrp_time_from_cpuctx(cpuctx);
if (!ctx->nr_active)
return;
perf_pmu_disable(ctx->pmu);
if ((is_active & EVENT_PINNED) && (event_type & EVENT_PINNED)) {
list_for_each_entry(event, &ctx->pinned_groups, group_entry)
group_sched_out(event, cpuctx, ctx);
}
if ((is_active & EVENT_FLEXIBLE) && (event_type & EVENT_FLEXIBLE)) {
list_for_each_entry(event, &ctx->flexible_groups, group_entry)
group_sched_out(event, cpuctx, ctx);
}
perf_pmu_enable(ctx->pmu);
}
/*
* Test whether two contexts are equivalent, i.e. whether they
* have both been cloned from the same version of the same context
* and they both have the same number of enabled events.
* If the number of enabled events is the same, then the set
* of enabled events should be the same, because these are both
* inherited contexts, therefore we can't access individual events
* in them directly with an fd; we can only enable/disable all
* events via prctl, or enable/disable all events in a family
* via ioctl, which will have the same effect on both contexts.
*/
static int context_equiv(struct perf_event_context *ctx1,
struct perf_event_context *ctx2)
{
return ctx1->parent_ctx && ctx1->parent_ctx == ctx2->parent_ctx
&& ctx1->parent_gen == ctx2->parent_gen
&& !ctx1->pin_count && !ctx2->pin_count;
}
static void __perf_event_sync_stat(struct perf_event *event,
struct perf_event *next_event)
{
u64 value;
if (!event->attr.inherit_stat)
return;
/*
* Update the event value, we cannot use perf_event_read()
* because we're in the middle of a context switch and have IRQs
* disabled, which upsets smp_call_function_single(), however
* we know the event must be on the current CPU, therefore we
* don't need to use it.
*/
switch (event->state) {
case PERF_EVENT_STATE_ACTIVE:
event->pmu->read(event);
/* fall-through */
case PERF_EVENT_STATE_INACTIVE:
update_event_times(event);
break;
default:
break;
}
/*
* In order to keep per-task stats reliable we need to flip the event
* values when we flip the contexts.
*/
value = local64_read(&next_event->count);
value = local64_xchg(&event->count, value);
local64_set(&next_event->count, value);
swap(event->total_time_enabled, next_event->total_time_enabled);
swap(event->total_time_running, next_event->total_time_running);
/*
* Since we swizzled the values, update the user visible data too.
*/
perf_event_update_userpage(event);
perf_event_update_userpage(next_event);
}
static void perf_event_sync_stat(struct perf_event_context *ctx,
struct perf_event_context *next_ctx)
{
struct perf_event *event, *next_event;
if (!ctx->nr_stat)
return;
update_context_time(ctx);
event = list_first_entry(&ctx->event_list,
struct perf_event, event_entry);
next_event = list_first_entry(&next_ctx->event_list,
struct perf_event, event_entry);
while (&event->event_entry != &ctx->event_list &&
&next_event->event_entry != &next_ctx->event_list) {
__perf_event_sync_stat(event, next_event);
event = list_next_entry(event, event_entry);
next_event = list_next_entry(next_event, event_entry);
}
}
static void perf_event_context_sched_out(struct task_struct *task, int ctxn,
struct task_struct *next)
{
struct perf_event_context *ctx = task->perf_event_ctxp[ctxn];
struct perf_event_context *next_ctx;
struct perf_event_context *parent;
struct perf_cpu_context *cpuctx;
int do_switch = 1;
if (likely(!ctx))
return;
cpuctx = __get_cpu_context(ctx);
if (!cpuctx->task_ctx)
return;
rcu_read_lock();
parent = rcu_dereference(ctx->parent_ctx);
next_ctx = next->perf_event_ctxp[ctxn];
if (parent && next_ctx &&
rcu_dereference(next_ctx->parent_ctx) == parent) {
/*
* Looks like the two contexts are clones, so we might be
* able to optimize the context switch. We lock both
* contexts and check that they are clones under the
* lock (including re-checking that neither has been
* uncloned in the meantime). It doesn't matter which
* order we take the locks because no other cpu could
* be trying to lock both of these tasks.
*/
raw_spin_lock(&ctx->lock);
raw_spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING);
if (context_equiv(ctx, next_ctx)) {
/*
* XXX do we need a memory barrier of sorts
* wrt to rcu_dereference() of perf_event_ctxp
*/
task->perf_event_ctxp[ctxn] = next_ctx;
next->perf_event_ctxp[ctxn] = ctx;
ctx->task = next;
next_ctx->task = task;
do_switch = 0;
perf_event_sync_stat(ctx, next_ctx);
}
raw_spin_unlock(&next_ctx->lock);
raw_spin_unlock(&ctx->lock);
}
rcu_read_unlock();
if (do_switch) {
raw_spin_lock(&ctx->lock);
ctx_sched_out(ctx, cpuctx, EVENT_ALL);
cpuctx->task_ctx = NULL;
raw_spin_unlock(&ctx->lock);
}
}
#define for_each_task_context_nr(ctxn) \
for ((ctxn) = 0; (ctxn) < perf_nr_task_contexts; (ctxn)++)
/*
* Called from scheduler to remove the events of the current task,
* with interrupts disabled.
*
* We stop each event and update the event value in event->count.
*
* This does not protect us against NMI, but disable()
* sets the disabled bit in the control field of event _before_
* accessing the event control register. If a NMI hits, then it will
* not restart the event.
*/
void __perf_event_task_sched_out(struct task_struct *task,
struct task_struct *next)
{
int ctxn;
for_each_task_context_nr(ctxn)
perf_event_context_sched_out(task, ctxn, next);
/*
* if cgroup events exist on this CPU, then we need
* to check if we have to switch out PMU state.
* cgroup event are system-wide mode only
*/
if (atomic_read(&__get_cpu_var(perf_cgroup_events)))
perf_cgroup_sched_out(task, next);
}
static void task_ctx_sched_out(struct perf_event_context *ctx)
{
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
if (!cpuctx->task_ctx)
return;
if (WARN_ON_ONCE(ctx != cpuctx->task_ctx))
return;
ctx_sched_out(ctx, cpuctx, EVENT_ALL);
cpuctx->task_ctx = NULL;
}
/*
* Called with IRQs disabled
*/
static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
enum event_type_t event_type)
{
ctx_sched_out(&cpuctx->ctx, cpuctx, event_type);
}
static void
ctx_pinned_sched_in(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx)
{
struct perf_event *event;
list_for_each_entry(event, &ctx->pinned_groups, group_entry) {
if (event->state <= PERF_EVENT_STATE_OFF)
continue;
if (!event_filter_match(event))
continue;
/* may need to reset tstamp_enabled */
if (is_cgroup_event(event))
perf_cgroup_mark_enabled(event, ctx);
if (group_can_go_on(event, cpuctx, 1))
group_sched_in(event, cpuctx, ctx);
/*
* If this pinned group hasn't been scheduled,
* put it in error state.
*/
if (event->state == PERF_EVENT_STATE_INACTIVE) {
update_group_times(event);
event->state = PERF_EVENT_STATE_ERROR;
}
}
}
static void
ctx_flexible_sched_in(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx)
{
struct perf_event *event;
int can_add_hw = 1;
list_for_each_entry(event, &ctx->flexible_groups, group_entry) {
/* Ignore events in OFF or ERROR state */
if (event->state <= PERF_EVENT_STATE_OFF)
continue;
/*
* Listen to the 'cpu' scheduling filter constraint
* of events:
*/
if (!event_filter_match(event))
continue;
/* may need to reset tstamp_enabled */
if (is_cgroup_event(event))
perf_cgroup_mark_enabled(event, ctx);
if (group_can_go_on(event, cpuctx, can_add_hw)) {
if (group_sched_in(event, cpuctx, ctx))
can_add_hw = 0;
}
}
}
static void
ctx_sched_in(struct perf_event_context *ctx,
struct perf_cpu_context *cpuctx,
enum event_type_t event_type,
struct task_struct *task)
{
u64 now;
int is_active = ctx->is_active;
ctx->is_active |= event_type;
if (likely(!ctx->nr_events))
return;
now = perf_clock();
ctx->timestamp = now;
perf_cgroup_set_timestamp(task, ctx);
/*
* First go through the list and put on any pinned groups
* in order to give them the best chance of going on.
*/
if (!(is_active & EVENT_PINNED) && (event_type & EVENT_PINNED))
ctx_pinned_sched_in(ctx, cpuctx);
/* Then walk through the lower prio flexible groups */
if (!(is_active & EVENT_FLEXIBLE) && (event_type & EVENT_FLEXIBLE))
ctx_flexible_sched_in(ctx, cpuctx);
}
static void cpu_ctx_sched_in(struct perf_cpu_context *cpuctx,
enum event_type_t event_type,
struct task_struct *task)
{
struct perf_event_context *ctx = &cpuctx->ctx;
ctx_sched_in(ctx, cpuctx, event_type, task);
}
static void perf_event_context_sched_in(struct perf_event_context *ctx,
struct task_struct *task)
{
struct perf_cpu_context *cpuctx;
cpuctx = __get_cpu_context(ctx);
if (cpuctx->task_ctx == ctx)
return;
perf_ctx_lock(cpuctx, ctx);
perf_pmu_disable(ctx->pmu);
/*
* We want to keep the following priority order:
* cpu pinned (that don't need to move), task pinned,
* cpu flexible, task flexible.
*/
cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
if (ctx->nr_events)
cpuctx->task_ctx = ctx;
perf_event_sched_in(cpuctx, cpuctx->task_ctx, task);
perf_pmu_enable(ctx->pmu);
perf_ctx_unlock(cpuctx, ctx);
/*
* Since these rotations are per-cpu, we need to ensure the
* cpu-context we got scheduled on is actually rotating.
*/
perf_pmu_rotate_start(ctx->pmu);
}
/*
* When sampling the branck stack in system-wide, it may be necessary
* to flush the stack on context switch. This happens when the branch
* stack does not tag its entries with the pid of the current task.
* Otherwise it becomes impossible to associate a branch entry with a
* task. This ambiguity is more likely to appear when the branch stack
* supports priv level filtering and the user sets it to monitor only
* at the user level (which could be a useful measurement in system-wide
* mode). In that case, the risk is high of having a branch stack with
* branch from multiple tasks. Flushing may mean dropping the existing
* entries or stashing them somewhere in the PMU specific code layer.
*
* This function provides the context switch callback to the lower code
* layer. It is invoked ONLY when there is at least one system-wide context
* with at least one active event using taken branch sampling.
*/
static void perf_branch_stack_sched_in(struct task_struct *prev,
struct task_struct *task)
{
struct perf_cpu_context *cpuctx;
struct pmu *pmu;
unsigned long flags;
/* no need to flush branch stack if not changing task */
if (prev == task)
return;
local_irq_save(flags);
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
/*
* check if the context has at least one
* event using PERF_SAMPLE_BRANCH_STACK
*/
if (cpuctx->ctx.nr_branch_stack > 0
&& pmu->flush_branch_stack) {
pmu = cpuctx->ctx.pmu;
perf_ctx_lock(cpuctx, cpuctx->task_ctx);
perf_pmu_disable(pmu);
pmu->flush_branch_stack();
perf_pmu_enable(pmu);
perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
}
}
rcu_read_unlock();
local_irq_restore(flags);
}
/*
* Called from scheduler to add the events of the current task
* with interrupts disabled.
*
* We restore the event value and then enable it.
*
* This does not protect us against NMI, but enable()
* sets the enabled bit in the control field of event _before_
* accessing the event control register. If a NMI hits, then it will
* keep the event running.
*/
void __perf_event_task_sched_in(struct task_struct *prev,
struct task_struct *task)
{
struct perf_event_context *ctx;
int ctxn;
for_each_task_context_nr(ctxn) {
ctx = task->perf_event_ctxp[ctxn];
if (likely(!ctx))
continue;
perf_event_context_sched_in(ctx, task);
}
/*
* if cgroup events exist on this CPU, then we need
* to check if we have to switch in PMU state.
* cgroup event are system-wide mode only
*/
if (atomic_read(&__get_cpu_var(perf_cgroup_events)))
perf_cgroup_sched_in(prev, task);
/* check for system-wide branch_stack events */
if (atomic_read(&__get_cpu_var(perf_branch_stack_events)))
perf_branch_stack_sched_in(prev, task);
}
static u64 perf_calculate_period(struct perf_event *event, u64 nsec, u64 count)
{
u64 frequency = event->attr.sample_freq;
u64 sec = NSEC_PER_SEC;
u64 divisor, dividend;
int count_fls, nsec_fls, frequency_fls, sec_fls;
count_fls = fls64(count);
nsec_fls = fls64(nsec);
frequency_fls = fls64(frequency);
sec_fls = 30;
/*
* We got @count in @nsec, with a target of sample_freq HZ
* the target period becomes:
*
* @count * 10^9
* period = -------------------
* @nsec * sample_freq
*
*/
/*
* Reduce accuracy by one bit such that @a and @b converge
* to a similar magnitude.
*/
#define REDUCE_FLS(a, b) \
do { \
if (a##_fls > b##_fls) { \
a >>= 1; \
a##_fls--; \
} else { \
b >>= 1; \
b##_fls--; \
} \
} while (0)
/*
* Reduce accuracy until either term fits in a u64, then proceed with
* the other, so that finally we can do a u64/u64 division.
*/
while (count_fls + sec_fls > 64 && nsec_fls + frequency_fls > 64) {
REDUCE_FLS(nsec, frequency);
REDUCE_FLS(sec, count);
}
if (count_fls + sec_fls > 64) {
divisor = nsec * frequency;
while (count_fls + sec_fls > 64) {
REDUCE_FLS(count, sec);
divisor >>= 1;
}
dividend = count * sec;
} else {
dividend = count * sec;
while (nsec_fls + frequency_fls > 64) {
REDUCE_FLS(nsec, frequency);
dividend >>= 1;
}
divisor = nsec * frequency;
}
if (!divisor)
return dividend;
return div64_u64(dividend, divisor);
}
static DEFINE_PER_CPU(int, perf_throttled_count);
static DEFINE_PER_CPU(u64, perf_throttled_seq);
static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count, bool disable)
{
struct hw_perf_event *hwc = &event->hw;
s64 period, sample_period;
s64 delta;
period = perf_calculate_period(event, nsec, count);
delta = (s64)(period - hwc->sample_period);
delta = (delta + 7) / 8; /* low pass filter */
sample_period = hwc->sample_period + delta;
if (!sample_period)
sample_period = 1;
hwc->sample_period = sample_period;
if (local64_read(&hwc->period_left) > 8*sample_period) {
if (disable)
event->pmu->stop(event, PERF_EF_UPDATE);
local64_set(&hwc->period_left, 0);
if (disable)
event->pmu->start(event, PERF_EF_RELOAD);
}
}
/*
* combine freq adjustment with unthrottling to avoid two passes over the
* events. At the same time, make sure, having freq events does not change
* the rate of unthrottling as that would introduce bias.
*/
static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx,
int needs_unthr)
{
struct perf_event *event;
struct hw_perf_event *hwc;
u64 now, period = TICK_NSEC;
s64 delta;
/*
* only need to iterate over all events iff:
* - context have events in frequency mode (needs freq adjust)
* - there are events to unthrottle on this cpu
*/
if (!(ctx->nr_freq || needs_unthr))
return;
raw_spin_lock(&ctx->lock);
perf_pmu_disable(ctx->pmu);
list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
if (event->state != PERF_EVENT_STATE_ACTIVE)
continue;
if (!event_filter_match(event))
continue;
hwc = &event->hw;
if (needs_unthr && hwc->interrupts == MAX_INTERRUPTS) {
hwc->interrupts = 0;
perf_log_throttle(event, 1);
event->pmu->start(event, 0);
}
if (!event->attr.freq || !event->attr.sample_freq)
continue;
/*
* stop the event and update event->count
*/
event->pmu->stop(event, PERF_EF_UPDATE);
now = local64_read(&event->count);
delta = now - hwc->freq_count_stamp;
hwc->freq_count_stamp = now;
/*
* restart the event
* reload only if value has changed
* we have stopped the event so tell that
* to perf_adjust_period() to avoid stopping it
* twice.
*/
if (delta > 0)
perf_adjust_period(event, period, delta, false);
event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0);
}
perf_pmu_enable(ctx->pmu);
raw_spin_unlock(&ctx->lock);
}
/*
* Round-robin a context's events:
*/
static void rotate_ctx(struct perf_event_context *ctx)
{
/*
* Rotate the first entry last of non-pinned groups. Rotation might be
* disabled by the inheritance code.
*/
if (!ctx->rotate_disable)
list_rotate_left(&ctx->flexible_groups);
}
/*
* perf_pmu_rotate_start() and perf_rotate_context() are fully serialized
* because they're strictly cpu affine and rotate_start is called with IRQs
* disabled, while rotate_context is called from IRQ context.
*/
static void perf_rotate_context(struct perf_cpu_context *cpuctx)
{
struct perf_event_context *ctx = NULL;
int rotate = 0, remove = 1;
if (cpuctx->ctx.nr_events) {
remove = 0;
if (cpuctx->ctx.nr_events != cpuctx->ctx.nr_active)
rotate = 1;
}
ctx = cpuctx->task_ctx;
if (ctx && ctx->nr_events) {
remove = 0;
if (ctx->nr_events != ctx->nr_active)
rotate = 1;
}
if (!rotate)
goto done;
perf_ctx_lock(cpuctx, cpuctx->task_ctx);
perf_pmu_disable(cpuctx->ctx.pmu);
cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
if (ctx)
ctx_sched_out(ctx, cpuctx, EVENT_FLEXIBLE);
rotate_ctx(&cpuctx->ctx);
if (ctx)
rotate_ctx(ctx);
perf_event_sched_in(cpuctx, ctx, current);
perf_pmu_enable(cpuctx->ctx.pmu);
perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
done:
if (remove)
list_del_init(&cpuctx->rotation_list);
}
void perf_event_task_tick(void)
{
struct list_head *head = &__get_cpu_var(rotation_list);
struct perf_cpu_context *cpuctx, *tmp;
struct perf_event_context *ctx;
int throttled;
WARN_ON(!irqs_disabled());
__this_cpu_inc(perf_throttled_seq);
throttled = __this_cpu_xchg(perf_throttled_count, 0);
list_for_each_entry_safe(cpuctx, tmp, head, rotation_list) {
ctx = &cpuctx->ctx;
perf_adjust_freq_unthr_context(ctx, throttled);
ctx = cpuctx->task_ctx;
if (ctx)
perf_adjust_freq_unthr_context(ctx, throttled);
if (cpuctx->jiffies_interval == 1 ||
!(jiffies % cpuctx->jiffies_interval))
perf_rotate_context(cpuctx);
}
}
static int event_enable_on_exec(struct perf_event *event,
struct perf_event_context *ctx)
{
if (!event->attr.enable_on_exec)
return 0;
event->attr.enable_on_exec = 0;
if (event->state >= PERF_EVENT_STATE_INACTIVE)
return 0;
__perf_event_mark_enabled(event);
return 1;
}
/*
* Enable all of a task's events that have been marked enable-on-exec.
* This expects task == current.
*/
static void perf_event_enable_on_exec(struct perf_event_context *ctx)
{
struct perf_event *event;
unsigned long flags;
int enabled = 0;
int ret;
local_irq_save(flags);
if (!ctx || !ctx->nr_events)
goto out;
/*
* We must ctxsw out cgroup events to avoid conflict
* when invoking perf_task_event_sched_in() later on
* in this function. Otherwise we end up trying to
* ctxswin cgroup events which are already scheduled
* in.
*/
perf_cgroup_sched_out(current, NULL);
raw_spin_lock(&ctx->lock);
task_ctx_sched_out(ctx);
list_for_each_entry(event, &ctx->event_list, event_entry) {
ret = event_enable_on_exec(event, ctx);
if (ret)
enabled = 1;
}
/*
* Unclone this context if we enabled any event.
*/
if (enabled)
unclone_ctx(ctx);
raw_spin_unlock(&ctx->lock);
/*
* Also calls ctxswin for cgroup events, if any:
*/
perf_event_context_sched_in(ctx, ctx->task);
out:
local_irq_restore(flags);
}
/*
* Cross CPU call to read the hardware event
*/
static void __perf_event_read(void *info)
{
struct perf_event *event = info;
struct perf_event_context *ctx = event->ctx;
struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
/*
* If this is a task context, we need to check whether it is
* the current task context of this cpu. If not it has been
* scheduled out before the smp call arrived. In that case
* event->count would have been updated to a recent sample
* when the event was scheduled out.
*/
if (ctx->task && cpuctx->task_ctx != ctx)
return;
raw_spin_lock(&ctx->lock);
if (ctx->is_active) {
update_context_time(ctx);
update_cgrp_time_from_event(event);
}
update_event_times(event);
if (event->state == PERF_EVENT_STATE_ACTIVE)
event->pmu->read(event);
raw_spin_unlock(&ctx->lock);
}
static inline u64 perf_event_count(struct perf_event *event)
{
return local64_read(&event->count) + atomic64_read(&event->child_count);
}
static u64 perf_event_read(struct perf_event *event)
{
/*
* If event is enabled and currently active on a CPU, update the
* value in the event structure:
*/
if (event->state == PERF_EVENT_STATE_ACTIVE) {
smp_call_function_single(event->oncpu,
__perf_event_read, event, 1);
} else if (event->state == PERF_EVENT_STATE_INACTIVE) {
struct perf_event_context *ctx = event->ctx;
unsigned long flags;
raw_spin_lock_irqsave(&ctx->lock, flags);
/*
* may read while context is not active
* (e.g., thread is blocked), in that case
* we cannot update context time
*/
if (ctx->is_active) {
update_context_time(ctx);
update_cgrp_time_from_event(event);
}
update_event_times(event);
raw_spin_unlock_irqrestore(&ctx->lock, flags);
}
return perf_event_count(event);
}
/*
* Initialize the perf_event context in a task_struct:
*/
static void __perf_event_init_context(struct perf_event_context *ctx)
{
raw_spin_lock_init(&ctx->lock);
mutex_init(&ctx->mutex);
INIT_LIST_HEAD(&ctx->pinned_groups);
INIT_LIST_HEAD(&ctx->flexible_groups);
INIT_LIST_HEAD(&ctx->event_list);
atomic_set(&ctx->refcount, 1);
}
static struct perf_event_context *
alloc_perf_context(struct pmu *pmu, struct task_struct *task)
{
struct perf_event_context *ctx;
ctx = kzalloc(sizeof(struct perf_event_context), GFP_KERNEL);
if (!ctx)
return NULL;
__perf_event_init_context(ctx);
if (task) {
ctx->task = task;
get_task_struct(task);
}
ctx->pmu = pmu;
return ctx;
}
static struct task_struct *
find_lively_task_by_vpid(pid_t vpid)
{
struct task_struct *task;
int err;
rcu_read_lock();
if (!vpid)
task = current;
else
task = find_task_by_vpid(vpid);
if (task)
get_task_struct(task);
rcu_read_unlock();
if (!task)
return ERR_PTR(-ESRCH);
/* Reuse ptrace permission checks for now. */
err = -EACCES;
if (!ptrace_may_access(task, PTRACE_MODE_READ))
goto errout;
return task;
errout:
put_task_struct(task);
return ERR_PTR(err);
}
/*
* Returns a matching context with refcount and pincount.
*/
static struct perf_event_context *
find_get_context(struct pmu *pmu, struct task_struct *task, int cpu)
{
struct perf_event_context *ctx;
struct perf_cpu_context *cpuctx;
unsigned long flags;
int ctxn, err;
if (!task) {
/* Must be root to operate on a CPU event: */
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
return ERR_PTR(-EACCES);
/*
* We could be clever and allow to attach a event to an
* offline CPU and activate it when the CPU comes up, but
* that's for later.
*/
if (!cpu_online(cpu))
return ERR_PTR(-ENODEV);
cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
ctx = &cpuctx->ctx;
get_ctx(ctx);
++ctx->pin_count;
return ctx;
}
err = -EINVAL;
ctxn = pmu->task_ctx_nr;
if (ctxn < 0)
goto errout;
retry:
ctx = perf_lock_task_context(task, ctxn, &flags);
if (ctx) {
unclone_ctx(ctx);
++ctx->pin_count;
raw_spin_unlock_irqrestore(&ctx->lock, flags);
} else {
ctx = alloc_perf_context(pmu, task);
err = -ENOMEM;
if (!ctx)
goto errout;
err = 0;
mutex_lock(&task->perf_event_mutex);
/*
* If it has already passed perf_event_exit_task().
* we must see PF_EXITING, it takes this mutex too.
*/
if (task->flags & PF_EXITING)
err = -ESRCH;
else if (task->perf_event_ctxp[ctxn])
err = -EAGAIN;
else {
get_ctx(ctx);
++ctx->pin_count;
rcu_assign_pointer(task->perf_event_ctxp[ctxn], ctx);
}
mutex_unlock(&task->perf_event_mutex);
if (unlikely(err)) {
put_ctx(ctx);
if (err == -EAGAIN)
goto retry;
goto errout;
}
}
return ctx;
errout:
return ERR_PTR(err);
}
static void perf_event_free_filter(struct perf_event *event);
static void free_event_rcu(struct rcu_head *head)
{
struct perf_event *event;
event = container_of(head, struct perf_event, rcu_head);
if (event->ns)
put_pid_ns(event->ns);
perf_event_free_filter(event);
kfree(event);
}
static void ring_buffer_put(struct ring_buffer *rb);
static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb);
static void free_event(struct perf_event *event)
{
irq_work_sync(&event->pending);
if (!event->parent) {
if (event->attach_state & PERF_ATTACH_TASK)
static_key_slow_dec_deferred(&perf_sched_events);
if (event->attr.mmap || event->attr.mmap_data)
atomic_dec(&nr_mmap_events);
if (event->attr.comm)
atomic_dec(&nr_comm_events);
if (event->attr.task)
atomic_dec(&nr_task_events);
if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
put_callchain_buffers();
if (is_cgroup_event(event)) {
atomic_dec(&per_cpu(perf_cgroup_events, event->cpu));
static_key_slow_dec_deferred(&perf_sched_events);
}
if (has_branch_stack(event)) {
static_key_slow_dec_deferred(&perf_sched_events);
/* is system-wide event */
if (!(event->attach_state & PERF_ATTACH_TASK)) {
atomic_dec(&per_cpu(perf_branch_stack_events,
event->cpu));
}
}
}
if (event->rb) {
struct ring_buffer *rb;
/*
* Can happen when we close an event with re-directed output.
*
* Since we have a 0 refcount, perf_mmap_close() will skip
* over us; possibly making our ring_buffer_put() the last.
*/
mutex_lock(&event->mmap_mutex);
rb = event->rb;
if (rb) {
rcu_assign_pointer(event->rb, NULL);
ring_buffer_detach(event, rb);
ring_buffer_put(rb); /* could be last */
}
mutex_unlock(&event->mmap_mutex);
}
if (is_cgroup_event(event))
perf_detach_cgroup(event);
if (event->destroy)
event->destroy(event);
if (event->ctx)
put_ctx(event->ctx);
call_rcu(&event->rcu_head, free_event_rcu);
}
int perf_event_release_kernel(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
WARN_ON_ONCE(ctx->parent_ctx);
/*
* There are two ways this annotation is useful:
*
* 1) there is a lock recursion from perf_event_exit_task
* see the comment there.
*
* 2) there is a lock-inversion with mmap_sem through
* perf_event_read_group(), which takes faults while
* holding ctx->mutex, however this is called after
* the last filedesc died, so there is no possibility
* to trigger the AB-BA case.
*/
mutex_lock_nested(&ctx->mutex, SINGLE_DEPTH_NESTING);
perf_remove_from_context(event, true);
mutex_unlock(&ctx->mutex);
free_event(event);
return 0;
}
EXPORT_SYMBOL_GPL(perf_event_release_kernel);
/*
* Called when the last reference to the file is gone.
*/
static void put_event(struct perf_event *event)
{
struct task_struct *owner;
/*
* Event can be in state OFF because of a constraint check.
* Change to ACTIVE so that it gets cleaned up correctly.
*/
if ((event->state == PERF_EVENT_STATE_OFF) &&
event->attr.constraint_duplicate)
event->state = PERF_EVENT_STATE_ACTIVE;
if (!atomic_long_dec_and_test(&event->refcount))
return;
rcu_read_lock();
owner = ACCESS_ONCE(event->owner);
/*
* Matches the smp_wmb() in perf_event_exit_task(). If we observe
* !owner it means the list deletion is complete and we can indeed
* free this event, otherwise we need to serialize on
* owner->perf_event_mutex.
*/
smp_read_barrier_depends();
if (owner) {
/*
* Since delayed_put_task_struct() also drops the last
* task reference we can safely take a new reference
* while holding the rcu_read_lock().
*/
get_task_struct(owner);
}
rcu_read_unlock();
if (owner) {
mutex_lock(&owner->perf_event_mutex);
/*
* We have to re-check the event->owner field, if it is cleared
* we raced with perf_event_exit_task(), acquiring the mutex
* ensured they're done, and we can proceed with freeing the
* event.
*/
if (event->owner)
list_del_init(&event->owner_entry);
mutex_unlock(&owner->perf_event_mutex);
put_task_struct(owner);
}
perf_event_release_kernel(event);
}
static int perf_release(struct inode *inode, struct file *file)
{
put_event(file->private_data);
return 0;
}
u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
{
struct perf_event *child;
u64 total = 0;
*enabled = 0;
*running = 0;
mutex_lock(&event->child_mutex);
total += perf_event_read(event);
*enabled += event->total_time_enabled +
atomic64_read(&event->child_total_time_enabled);
*running += event->total_time_running +
atomic64_read(&event->child_total_time_running);
list_for_each_entry(child, &event->child_list, child_list) {
total += perf_event_read(child);
*enabled += child->total_time_enabled;
*running += child->total_time_running;
}
mutex_unlock(&event->child_mutex);
return total;
}
EXPORT_SYMBOL_GPL(perf_event_read_value);
static int perf_event_read_group(struct perf_event *event,
u64 read_format, char __user *buf)
{
struct perf_event *leader = event->group_leader, *sub;
int n = 0, size = 0, ret = -EFAULT;
struct perf_event_context *ctx = leader->ctx;
u64 values[5];
u64 count, enabled, running;
mutex_lock(&ctx->mutex);
count = perf_event_read_value(leader, &enabled, &running);
values[n++] = 1 + leader->nr_siblings;
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
values[n++] = count;
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(leader);
size = n * sizeof(u64);
if (copy_to_user(buf, values, size))
goto unlock;
ret = size;
list_for_each_entry(sub, &leader->sibling_list, group_entry) {
n = 0;
values[n++] = perf_event_read_value(sub, &enabled, &running);
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(sub);
size = n * sizeof(u64);
if (copy_to_user(buf + ret, values, size)) {
ret = -EFAULT;
goto unlock;
}
ret += size;
}
unlock:
mutex_unlock(&ctx->mutex);
return ret;
}
static int perf_event_read_one(struct perf_event *event,
u64 read_format, char __user *buf)
{
u64 enabled, running;
u64 values[4];
int n = 0;
values[n++] = perf_event_read_value(event, &enabled, &running);
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(event);
if (copy_to_user(buf, values, n * sizeof(u64)))
return -EFAULT;
return n * sizeof(u64);
}
/*
* Read the performance event - simple non blocking version for now
*/
static ssize_t
perf_read_hw(struct perf_event *event, char __user *buf, size_t count)
{
u64 read_format = event->attr.read_format;
int ret;
/*
* Return end-of-file for a read on a event that is in
* error state (i.e. because it was pinned but it couldn't be
* scheduled on to the CPU at some point).
*/
if (event->state == PERF_EVENT_STATE_ERROR)
return 0;
if (count < event->read_size)
return -ENOSPC;
WARN_ON_ONCE(event->ctx->parent_ctx);
if (read_format & PERF_FORMAT_GROUP)
ret = perf_event_read_group(event, read_format, buf);
else
ret = perf_event_read_one(event, read_format, buf);
return ret;
}
static ssize_t
perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
struct perf_event *event = file->private_data;
return perf_read_hw(event, buf, count);
}
static unsigned int perf_poll(struct file *file, poll_table *wait)
{
struct perf_event *event = file->private_data;
struct ring_buffer *rb;
unsigned int events = POLL_HUP;
/*
* Pin the event->rb by taking event->mmap_mutex; otherwise
* perf_event_set_output() can swizzle our rb and make us miss wakeups.
*/
mutex_lock(&event->mmap_mutex);
rb = event->rb;
if (rb)
events = atomic_xchg(&rb->poll, 0);
mutex_unlock(&event->mmap_mutex);
poll_wait(file, &event->waitq, wait);
return events;
}
static void perf_event_reset(struct perf_event *event)
{
(void)perf_event_read(event);
local64_set(&event->count, 0);
perf_event_update_userpage(event);
}
/*
* Holding the top-level event's child_mutex means that any
* descendant process that has inherited this event will block
* in sync_child_event if it goes to exit, thus satisfying the
* task existence requirements of perf_event_enable/disable.
*/
static void perf_event_for_each_child(struct perf_event *event,
void (*func)(struct perf_event *))
{
struct perf_event *child;
WARN_ON_ONCE(event->ctx->parent_ctx);
mutex_lock(&event->child_mutex);
func(event);
list_for_each_entry(child, &event->child_list, child_list)
func(child);
mutex_unlock(&event->child_mutex);
}
static void perf_event_for_each(struct perf_event *event,
void (*func)(struct perf_event *))
{
struct perf_event_context *ctx = event->ctx;
struct perf_event *sibling;
WARN_ON_ONCE(ctx->parent_ctx);
mutex_lock(&ctx->mutex);
event = event->group_leader;
perf_event_for_each_child(event, func);
func(event);
list_for_each_entry(sibling, &event->sibling_list, group_entry)
perf_event_for_each_child(sibling, func);
mutex_unlock(&ctx->mutex);
}
static int perf_event_period(struct perf_event *event, u64 __user *arg)
{
struct perf_event_context *ctx = event->ctx;
int ret = 0;
u64 value;
if (!is_sampling_event(event))
return -EINVAL;
if (copy_from_user(&value, arg, sizeof(value)))
return -EFAULT;
if (!value)
return -EINVAL;
raw_spin_lock_irq(&ctx->lock);
if (event->attr.freq) {
if (value > sysctl_perf_event_sample_rate) {
ret = -EINVAL;
goto unlock;
}
event->attr.sample_freq = value;
} else {
event->attr.sample_period = value;
event->hw.sample_period = value;
}
unlock:
raw_spin_unlock_irq(&ctx->lock);
return ret;
}
static const struct file_operations perf_fops;
static struct file *perf_fget_light(int fd, int *fput_needed)
{
struct file *file;
file = fget_light(fd, fput_needed);
if (!file)
return ERR_PTR(-EBADF);
if (file->f_op != &perf_fops) {
fput_light(file, *fput_needed);
*fput_needed = 0;
return ERR_PTR(-EBADF);
}
return file;
}
static int perf_event_set_output(struct perf_event *event,
struct perf_event *output_event);
static int perf_event_set_filter(struct perf_event *event, void __user *arg);
static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct perf_event *event = file->private_data;
void (*func)(struct perf_event *);
u32 flags = arg;
switch (cmd) {
case PERF_EVENT_IOC_ENABLE:
func = perf_event_enable;
break;
case PERF_EVENT_IOC_DISABLE:
func = perf_event_disable;
break;
case PERF_EVENT_IOC_RESET:
func = perf_event_reset;
break;
case PERF_EVENT_IOC_REFRESH:
return perf_event_refresh(event, arg);
case PERF_EVENT_IOC_PERIOD:
return perf_event_period(event, (u64 __user *)arg);
case PERF_EVENT_IOC_SET_OUTPUT:
{
struct file *output_file = NULL;
struct perf_event *output_event = NULL;
int fput_needed = 0;
int ret;
if (arg != -1) {
output_file = perf_fget_light(arg, &fput_needed);
if (IS_ERR(output_file))
return PTR_ERR(output_file);
output_event = output_file->private_data;
}
ret = perf_event_set_output(event, output_event);
if (output_event)
fput_light(output_file, fput_needed);
return ret;
}
case PERF_EVENT_IOC_SET_FILTER:
return perf_event_set_filter(event, (void __user *)arg);
default:
return -ENOTTY;
}
if (flags & PERF_IOC_FLAG_GROUP)
perf_event_for_each(event, func);
else
perf_event_for_each_child(event, func);
return 0;
}
#ifdef CONFIG_COMPAT
static long perf_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
switch (_IOC_NR(cmd)) {
case _IOC_NR(PERF_EVENT_IOC_SET_FILTER):
/* Fix up pointer size (usually 4 -> 8 in 32-on-64-bit case */
if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) {
cmd &= ~IOCSIZE_MASK;
cmd |= sizeof(void *) << IOCSIZE_SHIFT;
}
break;
}
return perf_ioctl(file, cmd, arg);
}
#else
# define perf_compat_ioctl NULL
#endif
int perf_event_task_enable(void)
{
struct perf_event *event;
mutex_lock(¤t->perf_event_mutex);
list_for_each_entry(event, ¤t->perf_event_list, owner_entry)
perf_event_for_each_child(event, perf_event_enable);
mutex_unlock(¤t->perf_event_mutex);
return 0;
}
int perf_event_task_disable(void)
{
struct perf_event *event;
mutex_lock(¤t->perf_event_mutex);
list_for_each_entry(event, ¤t->perf_event_list, owner_entry)
perf_event_for_each_child(event, perf_event_disable);
mutex_unlock(¤t->perf_event_mutex);
return 0;
}
static int perf_event_index(struct perf_event *event)
{
if (event->hw.state & PERF_HES_STOPPED)
return 0;
if (event->state != PERF_EVENT_STATE_ACTIVE)
return 0;
return event->pmu->event_idx(event);
}
static void calc_timer_values(struct perf_event *event,
u64 *now,
u64 *enabled,
u64 *running)
{
u64 ctx_time;
*now = perf_clock();
ctx_time = event->shadow_ctx_time + *now;
*enabled = ctx_time - event->tstamp_enabled;
*running = ctx_time - event->tstamp_running;
}
void __weak arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now)
{
}
/*
* Callers need to ensure there can be no nesting of this function, otherwise
* the seqlock logic goes bad. We can not serialize this because the arch
* code calls this from NMI context.
*/
void perf_event_update_userpage(struct perf_event *event)
{
struct perf_event_mmap_page *userpg;
struct ring_buffer *rb;
u64 enabled, running, now;
rcu_read_lock();
/*
* compute total_time_enabled, total_time_running
* based on snapshot values taken when the event
* was last scheduled in.
*
* we cannot simply called update_context_time()
* because of locking issue as we can be called in
* NMI context
*/
calc_timer_values(event, &now, &enabled, &running);
rb = rcu_dereference(event->rb);
if (!rb)
goto unlock;
userpg = rb->user_page;
/*
* Disable preemption so as to not let the corresponding user-space
* spin too long if we get preempted.
*/
preempt_disable();
++userpg->lock;
barrier();
userpg->index = perf_event_index(event);
userpg->offset = perf_event_count(event);
if (userpg->index)
userpg->offset -= local64_read(&event->hw.prev_count);
userpg->time_enabled = enabled +
atomic64_read(&event->child_total_time_enabled);
userpg->time_running = running +
atomic64_read(&event->child_total_time_running);
arch_perf_update_userpage(userpg, now);
barrier();
++userpg->lock;
preempt_enable();
unlock:
rcu_read_unlock();
}
static int perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct perf_event *event = vma->vm_file->private_data;
struct ring_buffer *rb;
int ret = VM_FAULT_SIGBUS;
if (vmf->flags & FAULT_FLAG_MKWRITE) {
if (vmf->pgoff == 0)
ret = 0;
return ret;
}
rcu_read_lock();
rb = rcu_dereference(event->rb);
if (!rb)
goto unlock;
if (vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE))
goto unlock;
vmf->page = perf_mmap_to_page(rb, vmf->pgoff);
if (!vmf->page)
goto unlock;
get_page(vmf->page);
vmf->page->mapping = vma->vm_file->f_mapping;
vmf->page->index = vmf->pgoff;
ret = 0;
unlock:
rcu_read_unlock();
return ret;
}
static void ring_buffer_attach(struct perf_event *event,
struct ring_buffer *rb)
{
unsigned long flags;
if (!list_empty(&event->rb_entry))
return;
spin_lock_irqsave(&rb->event_lock, flags);
if (list_empty(&event->rb_entry))
list_add(&event->rb_entry, &rb->event_list);
spin_unlock_irqrestore(&rb->event_lock, flags);
}
static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb)
{
unsigned long flags;
if (list_empty(&event->rb_entry))
return;
spin_lock_irqsave(&rb->event_lock, flags);
list_del_init(&event->rb_entry);
wake_up_all(&event->waitq);
spin_unlock_irqrestore(&rb->event_lock, flags);
}
static void ring_buffer_wakeup(struct perf_event *event)
{
struct ring_buffer *rb;
rcu_read_lock();
rb = rcu_dereference(event->rb);
if (rb) {
list_for_each_entry_rcu(event, &rb->event_list, rb_entry)
wake_up_all(&event->waitq);
}
rcu_read_unlock();
}
static void rb_free_rcu(struct rcu_head *rcu_head)
{
struct ring_buffer *rb;
rb = container_of(rcu_head, struct ring_buffer, rcu_head);
rb_free(rb);
}
static struct ring_buffer *ring_buffer_get(struct perf_event *event)
{
struct ring_buffer *rb;
rcu_read_lock();
rb = rcu_dereference(event->rb);
if (rb) {
if (!atomic_inc_not_zero(&rb->refcount))
rb = NULL;
}
rcu_read_unlock();
return rb;
}
static void ring_buffer_put(struct ring_buffer *rb)
{
if (!atomic_dec_and_test(&rb->refcount))
return;
WARN_ON_ONCE(!list_empty(&rb->event_list));
call_rcu(&rb->rcu_head, rb_free_rcu);
}
static void perf_mmap_open(struct vm_area_struct *vma)
{
struct perf_event *event = vma->vm_file->private_data;
atomic_inc(&event->mmap_count);
atomic_inc(&event->rb->mmap_count);
}
/*
* A buffer can be mmap()ed multiple times; either directly through the same
* event, or through other events by use of perf_event_set_output().
*
* In order to undo the VM accounting done by perf_mmap() we need to destroy
* the buffer here, where we still have a VM context. This means we need
* to detach all events redirecting to us.
*/
static void perf_mmap_close(struct vm_area_struct *vma)
{
struct perf_event *event = vma->vm_file->private_data;
struct ring_buffer *rb = event->rb;
struct user_struct *mmap_user = rb->mmap_user;
int mmap_locked = rb->mmap_locked;
unsigned long size = perf_data_size(rb);
atomic_dec(&rb->mmap_count);
if (!atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex))
return;
/* Detach current event from the buffer. */
rcu_assign_pointer(event->rb, NULL);
ring_buffer_detach(event, rb);
mutex_unlock(&event->mmap_mutex);
/* If there's still other mmap()s of this buffer, we're done. */
if (atomic_read(&rb->mmap_count)) {
ring_buffer_put(rb); /* can't be last */
return;
}
/*
* No other mmap()s, detach from all other events that might redirect
* into the now unreachable buffer. Somewhat complicated by the
* fact that rb::event_lock otherwise nests inside mmap_mutex.
*/
again:
rcu_read_lock();
list_for_each_entry_rcu(event, &rb->event_list, rb_entry) {
if (!atomic_long_inc_not_zero(&event->refcount)) {
/*
* This event is en-route to free_event() which will
* detach it and remove it from the list.
*/
continue;
}
rcu_read_unlock();
mutex_lock(&event->mmap_mutex);
/*
* Check we didn't race with perf_event_set_output() which can
* swizzle the rb from under us while we were waiting to
* acquire mmap_mutex.
*
* If we find a different rb; ignore this event, a next
* iteration will no longer find it on the list. We have to
* still restart the iteration to make sure we're not now
* iterating the wrong list.
*/
if (event->rb == rb) {
rcu_assign_pointer(event->rb, NULL);
ring_buffer_detach(event, rb);
ring_buffer_put(rb); /* can't be last, we still have one */
}
mutex_unlock(&event->mmap_mutex);
put_event(event);
/*
* Restart the iteration; either we're on the wrong list or
* destroyed its integrity by doing a deletion.
*/
goto again;
}
rcu_read_unlock();
/*
* It could be there's still a few 0-ref events on the list; they'll
* get cleaned up by free_event() -- they'll also still have their
* ref on the rb and will free it whenever they are done with it.
*
* Aside from that, this buffer is 'fully' detached and unmapped,
* undo the VM accounting.
*/
atomic_long_sub((size >> PAGE_SHIFT) + 1, &mmap_user->locked_vm);
vma->vm_mm->pinned_vm -= mmap_locked;
free_uid(mmap_user);
ring_buffer_put(rb); /* could be last */
}
static const struct vm_operations_struct perf_mmap_vmops = {
.open = perf_mmap_open,
.close = perf_mmap_close,
.fault = perf_mmap_fault,
.page_mkwrite = perf_mmap_fault,
};
static int perf_mmap(struct file *file, struct vm_area_struct *vma)
{
struct perf_event *event = file->private_data;
unsigned long user_locked, user_lock_limit;
struct user_struct *user = current_user();
unsigned long locked, lock_limit;
struct ring_buffer *rb;
unsigned long vma_size;
unsigned long nr_pages;
long user_extra, extra;
int ret = 0, flags = 0;
/*
* Don't allow mmap() of inherited per-task counters. This would
* create a performance issue due to all children writing to the
* same rb.
*/
if (event->cpu == -1 && event->attr.inherit)
return -EINVAL;
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
vma_size = vma->vm_end - vma->vm_start;
nr_pages = (vma_size / PAGE_SIZE) - 1;
/*
* If we have rb pages ensure they're a power-of-two number, so we
* can do bitmasks instead of modulo.
*/
if (nr_pages != 0 && !is_power_of_2(nr_pages))
return -EINVAL;
if (vma_size != PAGE_SIZE * (1 + nr_pages))
return -EINVAL;
if (vma->vm_pgoff != 0)
return -EINVAL;
WARN_ON_ONCE(event->ctx->parent_ctx);
again:
mutex_lock(&event->mmap_mutex);
if (event->rb) {
if (event->rb->nr_pages != nr_pages) {
ret = -EINVAL;
goto unlock;
}
if (!atomic_inc_not_zero(&event->rb->mmap_count)) {
/*
* Raced against perf_mmap_close() through
* perf_event_set_output(). Try again, hope for better
* luck.
*/
mutex_unlock(&event->mmap_mutex);
goto again;
}
goto unlock;
}
user_extra = nr_pages + 1;
user_lock_limit = sysctl_perf_event_mlock >> (PAGE_SHIFT - 10);
/*
* Increase the limit linearly with more CPUs:
*/
user_lock_limit *= num_online_cpus();
user_locked = atomic_long_read(&user->locked_vm) + user_extra;
extra = 0;
if (user_locked > user_lock_limit)
extra = user_locked - user_lock_limit;
lock_limit = rlimit(RLIMIT_MEMLOCK);
lock_limit >>= PAGE_SHIFT;
locked = vma->vm_mm->pinned_vm + extra;
if ((locked > lock_limit) && perf_paranoid_tracepoint_raw() &&
!capable(CAP_IPC_LOCK)) {
ret = -EPERM;
goto unlock;
}
WARN_ON(event->rb);
if (vma->vm_flags & VM_WRITE)
flags |= RING_BUFFER_WRITABLE;
rb = rb_alloc(nr_pages,
event->attr.watermark ? event->attr.wakeup_watermark : 0,
event->cpu, flags);
if (!rb) {
ret = -ENOMEM;
goto unlock;
}
atomic_set(&rb->mmap_count, 1);
rb->mmap_locked = extra;
rb->mmap_user = get_current_user();
atomic_long_add(user_extra, &user->locked_vm);
vma->vm_mm->pinned_vm += extra;
ring_buffer_attach(event, rb);
rcu_assign_pointer(event->rb, rb);
perf_event_update_userpage(event);
unlock:
if (!ret)
atomic_inc(&event->mmap_count);
mutex_unlock(&event->mmap_mutex);
/*
* Since pinned accounting is per vm we cannot allow fork() to copy our
* vma.
*/
vma->vm_flags |= VM_DONTCOPY | VM_RESERVED;
vma->vm_ops = &perf_mmap_vmops;
return ret;
}
static int perf_fasync(int fd, struct file *filp, int on)
{
struct inode *inode = filp->f_path.dentry->d_inode;
struct perf_event *event = filp->private_data;
int retval;
mutex_lock(&inode->i_mutex);
retval = fasync_helper(fd, filp, on, &event->fasync);
mutex_unlock(&inode->i_mutex);
if (retval < 0)
return retval;
return 0;
}
static const struct file_operations perf_fops = {
.llseek = no_llseek,
.release = perf_release,
.read = perf_read,
.poll = perf_poll,
.unlocked_ioctl = perf_ioctl,
.compat_ioctl = perf_compat_ioctl,
.mmap = perf_mmap,
.fasync = perf_fasync,
};
/*
* Perf event wakeup
*
* If there's data, ensure we set the poll() state and publish everything
* to user-space before waking everybody up.
*/
void perf_event_wakeup(struct perf_event *event)
{
ring_buffer_wakeup(event);
if (event->pending_kill) {
kill_fasync(&event->fasync, SIGIO, event->pending_kill);
event->pending_kill = 0;
}
}
static void perf_pending_event(struct irq_work *entry)
{
struct perf_event *event = container_of(entry,
struct perf_event, pending);
int rctx;
rctx = perf_swevent_get_recursion_context();
/*
* If we 'fail' here, that's OK, it means recursion is already disabled
* and we won't recurse 'further'.
*/
if (event->pending_disable) {
event->pending_disable = 0;
__perf_event_disable(event);
}
if (event->pending_wakeup) {
event->pending_wakeup = 0;
perf_event_wakeup(event);
}
if (rctx >= 0)
perf_swevent_put_recursion_context(rctx);
}
/*
* We assume there is only KVM supporting the callbacks.
* Later on, we might change it to a list if there is
* another virtualization implementation supporting the callbacks.
*/
struct perf_guest_info_callbacks *perf_guest_cbs;
int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
{
perf_guest_cbs = cbs;
return 0;
}
EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks);
int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
{
perf_guest_cbs = NULL;
return 0;
}
EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks);
static void __perf_event_header__init_id(struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_event *event)
{
u64 sample_type = event->attr.sample_type;
data->type = sample_type;
header->size += event->id_header_size;
if (sample_type & PERF_SAMPLE_TID) {
/* namespace issues */
data->tid_entry.pid = perf_event_pid(event, current);
data->tid_entry.tid = perf_event_tid(event, current);
}
if (sample_type & PERF_SAMPLE_TIME)
data->time = perf_clock();
if (sample_type & PERF_SAMPLE_ID)
data->id = primary_event_id(event);
if (sample_type & PERF_SAMPLE_STREAM_ID)
data->stream_id = event->id;
if (sample_type & PERF_SAMPLE_CPU) {
data->cpu_entry.cpu = raw_smp_processor_id();
data->cpu_entry.reserved = 0;
}
}
void perf_event_header__init_id(struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_event *event)
{
if (event->attr.sample_id_all)
__perf_event_header__init_id(header, data, event);
}
static void __perf_event__output_id_sample(struct perf_output_handle *handle,
struct perf_sample_data *data)
{
u64 sample_type = data->type;
if (sample_type & PERF_SAMPLE_TID)
perf_output_put(handle, data->tid_entry);
if (sample_type & PERF_SAMPLE_TIME)
perf_output_put(handle, data->time);
if (sample_type & PERF_SAMPLE_ID)
perf_output_put(handle, data->id);
if (sample_type & PERF_SAMPLE_STREAM_ID)
perf_output_put(handle, data->stream_id);
if (sample_type & PERF_SAMPLE_CPU)
perf_output_put(handle, data->cpu_entry);
}
void perf_event__output_id_sample(struct perf_event *event,
struct perf_output_handle *handle,
struct perf_sample_data *sample)
{
if (event->attr.sample_id_all)
__perf_event__output_id_sample(handle, sample);
}
static void perf_output_read_one(struct perf_output_handle *handle,
struct perf_event *event,
u64 enabled, u64 running)
{
u64 read_format = event->attr.read_format;
u64 values[4];
int n = 0;
values[n++] = perf_event_count(event);
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
values[n++] = enabled +
atomic64_read(&event->child_total_time_enabled);
}
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
values[n++] = running +
atomic64_read(&event->child_total_time_running);
}
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(event);
__output_copy(handle, values, n * sizeof(u64));
}
/*
* XXX PERF_FORMAT_GROUP vs inherited events seems difficult.
*/
static void perf_output_read_group(struct perf_output_handle *handle,
struct perf_event *event,
u64 enabled, u64 running)
{
struct perf_event *leader = event->group_leader, *sub;
u64 read_format = event->attr.read_format;
u64 values[5];
int n = 0;
values[n++] = 1 + leader->nr_siblings;
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
if (leader != event)
leader->pmu->read(leader);
values[n++] = perf_event_count(leader);
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(leader);
__output_copy(handle, values, n * sizeof(u64));
list_for_each_entry(sub, &leader->sibling_list, group_entry) {
n = 0;
if (sub != event)
sub->pmu->read(sub);
values[n++] = perf_event_count(sub);
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(sub);
__output_copy(handle, values, n * sizeof(u64));
}
}
#define PERF_FORMAT_TOTAL_TIMES (PERF_FORMAT_TOTAL_TIME_ENABLED|\
PERF_FORMAT_TOTAL_TIME_RUNNING)
static void perf_output_read(struct perf_output_handle *handle,
struct perf_event *event)
{
u64 enabled = 0, running = 0, now;
u64 read_format = event->attr.read_format;
/*
* compute total_time_enabled, total_time_running
* based on snapshot values taken when the event
* was last scheduled in.
*
* we cannot simply called update_context_time()
* because of locking issue as we are called in
* NMI context
*/
if (read_format & PERF_FORMAT_TOTAL_TIMES)
calc_timer_values(event, &now, &enabled, &running);
if (event->attr.read_format & PERF_FORMAT_GROUP)
perf_output_read_group(handle, event, enabled, running);
else
perf_output_read_one(handle, event, enabled, running);
}
void perf_output_sample(struct perf_output_handle *handle,
struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_event *event)
{
u64 sample_type = data->type;
perf_output_put(handle, *header);
if (sample_type & PERF_SAMPLE_IP)
perf_output_put(handle, data->ip);
if (sample_type & PERF_SAMPLE_TID)
perf_output_put(handle, data->tid_entry);
if (sample_type & PERF_SAMPLE_TIME)
perf_output_put(handle, data->time);
if (sample_type & PERF_SAMPLE_ADDR)
perf_output_put(handle, data->addr);
if (sample_type & PERF_SAMPLE_ID)
perf_output_put(handle, data->id);
if (sample_type & PERF_SAMPLE_STREAM_ID)
perf_output_put(handle, data->stream_id);
if (sample_type & PERF_SAMPLE_CPU)
perf_output_put(handle, data->cpu_entry);
if (sample_type & PERF_SAMPLE_PERIOD)
perf_output_put(handle, data->period);
if (sample_type & PERF_SAMPLE_READ)
perf_output_read(handle, event);
if (sample_type & PERF_SAMPLE_CALLCHAIN) {
if (data->callchain) {
int size = 1;
if (data->callchain)
size += data->callchain->nr;
size *= sizeof(u64);
__output_copy(handle, data->callchain, size);
} else {
u64 nr = 0;
perf_output_put(handle, nr);
}
}
if (sample_type & PERF_SAMPLE_RAW) {
if (data->raw) {
perf_output_put(handle, data->raw->size);
__output_copy(handle, data->raw->data,
data->raw->size);
} else {
struct {
u32 size;
u32 data;
} raw = {
.size = sizeof(u32),
.data = 0,
};
perf_output_put(handle, raw);
}
}
if (!event->attr.watermark) {
int wakeup_events = event->attr.wakeup_events;
if (wakeup_events) {
struct ring_buffer *rb = handle->rb;
int events = local_inc_return(&rb->events);
if (events >= wakeup_events) {
local_sub(wakeup_events, &rb->events);
local_inc(&rb->wakeup);
}
}
}
if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
if (data->br_stack) {
size_t size;
size = data->br_stack->nr
* sizeof(struct perf_branch_entry);
perf_output_put(handle, data->br_stack->nr);
perf_output_copy(handle, data->br_stack->entries, size);
} else {
/*
* we always store at least the value of nr
*/
u64 nr = 0;
perf_output_put(handle, nr);
}
}
}
void perf_prepare_sample(struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_event *event,
struct pt_regs *regs)
{
u64 sample_type = event->attr.sample_type;
header->type = PERF_RECORD_SAMPLE;
header->size = sizeof(*header) + event->header_size;
header->misc = 0;
header->misc |= perf_misc_flags(regs);
__perf_event_header__init_id(header, data, event);
if (sample_type & PERF_SAMPLE_IP)
data->ip = perf_instruction_pointer(regs);
if (sample_type & PERF_SAMPLE_CALLCHAIN) {
int size = 1;
data->callchain = perf_callchain(regs);
if (data->callchain)
size += data->callchain->nr;
header->size += size * sizeof(u64);
}
if (sample_type & PERF_SAMPLE_RAW) {
int size = sizeof(u32);
if (data->raw)
size += data->raw->size;
else
size += sizeof(u32);
WARN_ON_ONCE(size & (sizeof(u64)-1));
header->size += size;
}
if (sample_type & PERF_SAMPLE_BRANCH_STACK) {
int size = sizeof(u64); /* nr */
if (data->br_stack) {
size += data->br_stack->nr
* sizeof(struct perf_branch_entry);
}
header->size += size;
}
}
static void perf_event_output(struct perf_event *event,
struct perf_sample_data *data,
struct pt_regs *regs)
{
struct perf_output_handle handle;
struct perf_event_header header;
/* protect the callchain buffers */
rcu_read_lock();
perf_prepare_sample(&header, data, event, regs);
if (perf_output_begin(&handle, event, header.size))
goto exit;
perf_output_sample(&handle, &header, data, event);
perf_output_end(&handle);
exit:
rcu_read_unlock();
}
/*
* read event_id
*/
struct perf_read_event {
struct perf_event_header header;
u32 pid;
u32 tid;
};
static void
perf_event_read_event(struct perf_event *event,
struct task_struct *task)
{
struct perf_output_handle handle;
struct perf_sample_data sample;
struct perf_read_event read_event = {
.header = {
.type = PERF_RECORD_READ,
.misc = 0,
.size = sizeof(read_event) + event->read_size,
},
.pid = perf_event_pid(event, task),
.tid = perf_event_tid(event, task),
};
int ret;
perf_event_header__init_id(&read_event.header, &sample, event);
ret = perf_output_begin(&handle, event, read_event.header.size);
if (ret)
return;
perf_output_put(&handle, read_event);
perf_output_read(&handle, event);
perf_event__output_id_sample(event, &handle, &sample);
perf_output_end(&handle);
}
/*
* task tracking -- fork/exit
*
* enabled by: attr.comm | attr.mmap | attr.mmap_data | attr.task
*/
struct perf_task_event {
struct task_struct *task;
struct perf_event_context *task_ctx;
struct {
struct perf_event_header header;
u32 pid;
u32 ppid;
u32 tid;
u32 ptid;
u64 time;
} event_id;
};
static void perf_event_task_output(struct perf_event *event,
struct perf_task_event *task_event)
{
struct perf_output_handle handle;
struct perf_sample_data sample;
struct task_struct *task = task_event->task;
int ret, size = task_event->event_id.header.size;
perf_event_header__init_id(&task_event->event_id.header, &sample, event);
ret = perf_output_begin(&handle, event,
task_event->event_id.header.size);
if (ret)
goto out;
task_event->event_id.pid = perf_event_pid(event, task);
task_event->event_id.ppid = perf_event_pid(event, current);
task_event->event_id.tid = perf_event_tid(event, task);
task_event->event_id.ptid = perf_event_tid(event, current);
perf_output_put(&handle, task_event->event_id);
perf_event__output_id_sample(event, &handle, &sample);
perf_output_end(&handle);
out:
task_event->event_id.header.size = size;
}
static int perf_event_task_match(struct perf_event *event)
{
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;
if (!event_filter_match(event))
return 0;
if (event->attr.comm || event->attr.mmap ||
event->attr.mmap_data || event->attr.task)
return 1;
return 0;
}
static void perf_event_task_ctx(struct perf_event_context *ctx,
struct perf_task_event *task_event)
{
struct perf_event *event;
list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
if (perf_event_task_match(event))
perf_event_task_output(event, task_event);
}
}
static void perf_event_task_event(struct perf_task_event *task_event)
{
struct perf_cpu_context *cpuctx;
struct perf_event_context *ctx;
struct pmu *pmu;
int ctxn;
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_task_ctx(&cpuctx->ctx, task_event);
ctx = task_event->task_ctx;
if (!ctx) {
ctxn = pmu->task_ctx_nr;
if (ctxn < 0)
goto next;
ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
}
if (ctx)
perf_event_task_ctx(ctx, task_event);
next:
put_cpu_ptr(pmu->pmu_cpu_context);
}
rcu_read_unlock();
}
static void perf_event_task(struct task_struct *task,
struct perf_event_context *task_ctx,
int new)
{
struct perf_task_event task_event;
if (!atomic_read(&nr_comm_events) &&
!atomic_read(&nr_mmap_events) &&
!atomic_read(&nr_task_events))
return;
task_event = (struct perf_task_event){
.task = task,
.task_ctx = task_ctx,
.event_id = {
.header = {
.type = new ? PERF_RECORD_FORK : PERF_RECORD_EXIT,
.misc = 0,
.size = sizeof(task_event.event_id),
},
/* .pid */
/* .ppid */
/* .tid */
/* .ptid */
.time = perf_clock(),
},
};
perf_event_task_event(&task_event);
}
void perf_event_fork(struct task_struct *task)
{
perf_event_task(task, NULL, 1);
}
/*
* comm tracking
*/
struct perf_comm_event {
struct task_struct *task;
char *comm;
int comm_size;
struct {
struct perf_event_header header;
u32 pid;
u32 tid;
} event_id;
};
static void perf_event_comm_output(struct perf_event *event,
struct perf_comm_event *comm_event)
{
struct perf_output_handle handle;
struct perf_sample_data sample;
int size = comm_event->event_id.header.size;
int ret;
perf_event_header__init_id(&comm_event->event_id.header, &sample, event);
ret = perf_output_begin(&handle, event,
comm_event->event_id.header.size);
if (ret)
goto out;
comm_event->event_id.pid = perf_event_pid(event, comm_event->task);
comm_event->event_id.tid = perf_event_tid(event, comm_event->task);
perf_output_put(&handle, comm_event->event_id);
__output_copy(&handle, comm_event->comm,
comm_event->comm_size);
perf_event__output_id_sample(event, &handle, &sample);
perf_output_end(&handle);
out:
comm_event->event_id.header.size = size;
}
static int perf_event_comm_match(struct perf_event *event)
{
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;
if (!event_filter_match(event))
return 0;
if (event->attr.comm)
return 1;
return 0;
}
static void perf_event_comm_ctx(struct perf_event_context *ctx,
struct perf_comm_event *comm_event)
{
struct perf_event *event;
list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
if (perf_event_comm_match(event))
perf_event_comm_output(event, comm_event);
}
}
static void perf_event_comm_event(struct perf_comm_event *comm_event)
{
struct perf_cpu_context *cpuctx;
struct perf_event_context *ctx;
char comm[TASK_COMM_LEN];
unsigned int size;
struct pmu *pmu;
int ctxn;
memset(comm, 0, sizeof(comm));
strlcpy(comm, comm_event->task->comm, sizeof(comm));
size = ALIGN(strlen(comm)+1, sizeof(u64));
comm_event->comm = comm;
comm_event->comm_size = size;
comm_event->event_id.header.size = sizeof(comm_event->event_id) + size;
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_comm_ctx(&cpuctx->ctx, comm_event);
ctxn = pmu->task_ctx_nr;
if (ctxn < 0)
goto next;
ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
if (ctx)
perf_event_comm_ctx(ctx, comm_event);
next:
put_cpu_ptr(pmu->pmu_cpu_context);
}
rcu_read_unlock();
}
void perf_event_comm(struct task_struct *task)
{
struct perf_comm_event comm_event;
struct perf_event_context *ctx;
int ctxn;
for_each_task_context_nr(ctxn) {
ctx = task->perf_event_ctxp[ctxn];
if (!ctx)
continue;
perf_event_enable_on_exec(ctx);
}
if (!atomic_read(&nr_comm_events))
return;
comm_event = (struct perf_comm_event){
.task = task,
/* .comm */
/* .comm_size */
.event_id = {
.header = {
.type = PERF_RECORD_COMM,
.misc = 0,
/* .size */
},
/* .pid */
/* .tid */
},
};
perf_event_comm_event(&comm_event);
}
/*
* mmap tracking
*/
struct perf_mmap_event {
struct vm_area_struct *vma;
const char *file_name;
int file_size;
struct {
struct perf_event_header header;
u32 pid;
u32 tid;
u64 start;
u64 len;
u64 pgoff;
} event_id;
};
static void perf_event_mmap_output(struct perf_event *event,
struct perf_mmap_event *mmap_event)
{
struct perf_output_handle handle;
struct perf_sample_data sample;
int size = mmap_event->event_id.header.size;
int ret;
perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);
ret = perf_output_begin(&handle, event,
mmap_event->event_id.header.size);
if (ret)
goto out;
mmap_event->event_id.pid = perf_event_pid(event, current);
mmap_event->event_id.tid = perf_event_tid(event, current);
perf_output_put(&handle, mmap_event->event_id);
__output_copy(&handle, mmap_event->file_name,
mmap_event->file_size);
perf_event__output_id_sample(event, &handle, &sample);
perf_output_end(&handle);
out:
mmap_event->event_id.header.size = size;
}
static int perf_event_mmap_match(struct perf_event *event,
struct perf_mmap_event *mmap_event,
int executable)
{
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;
if (!event_filter_match(event))
return 0;
if ((!executable && event->attr.mmap_data) ||
(executable && event->attr.mmap))
return 1;
return 0;
}
static void perf_event_mmap_ctx(struct perf_event_context *ctx,
struct perf_mmap_event *mmap_event,
int executable)
{
struct perf_event *event;
list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
if (perf_event_mmap_match(event, mmap_event, executable))
perf_event_mmap_output(event, mmap_event);
}
}
static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
{
struct perf_cpu_context *cpuctx;
struct perf_event_context *ctx;
struct vm_area_struct *vma = mmap_event->vma;
struct file *file = vma->vm_file;
unsigned int size;
char tmp[16];
char *buf = NULL;
const char *name;
struct pmu *pmu;
int ctxn;
memset(tmp, 0, sizeof(tmp));
if (file) {
/*
* d_path works from the end of the rb backwards, so we
* need to add enough zero bytes after the string to handle
* the 64bit alignment we do later.
*/
buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
if (!buf) {
name = strncpy(tmp, "//enomem", sizeof(tmp));
goto got_name;
}
name = d_path(&file->f_path, buf, PATH_MAX);
if (IS_ERR(name)) {
name = strncpy(tmp, "//toolong", sizeof(tmp));
goto got_name;
}
} else {
if (arch_vma_name(mmap_event->vma)) {
name = strncpy(tmp, arch_vma_name(mmap_event->vma),
sizeof(tmp));
goto got_name;
}
if (!vma->vm_mm) {
name = strncpy(tmp, "[vdso]", sizeof(tmp));
goto got_name;
} else if (vma->vm_start <= vma->vm_mm->start_brk &&
vma->vm_end >= vma->vm_mm->brk) {
name = strncpy(tmp, "[heap]", sizeof(tmp));
goto got_name;
} else if (vma->vm_start <= vma->vm_mm->start_stack &&
vma->vm_end >= vma->vm_mm->start_stack) {
name = strncpy(tmp, "[stack]", sizeof(tmp));
goto got_name;
}
name = strncpy(tmp, "//anon", sizeof(tmp));
goto got_name;
}
got_name:
size = ALIGN(strlen(name)+1, sizeof(u64));
mmap_event->file_name = name;
mmap_event->file_size = size;
mmap_event->event_id.header.size = sizeof(mmap_event->event_id) + size;
rcu_read_lock();
list_for_each_entry_rcu(pmu, &pmus, entry) {
cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
if (cpuctx->unique_pmu != pmu)
goto next;
perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
vma->vm_flags & VM_EXEC);
ctxn = pmu->task_ctx_nr;
if (ctxn < 0)
goto next;
ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
if (ctx) {
perf_event_mmap_ctx(ctx, mmap_event,
vma->vm_flags & VM_EXEC);
}
next:
put_cpu_ptr(pmu->pmu_cpu_context);
}
rcu_read_unlock();
kfree(buf);
}
void perf_event_mmap(struct vm_area_struct *vma)
{
struct perf_mmap_event mmap_event;
if (!atomic_read(&nr_mmap_events))
return;
mmap_event = (struct perf_mmap_event){
.vma = vma,
/* .file_name */
/* .file_size */
.event_id = {
.header = {
.type = PERF_RECORD_MMAP,
.misc = PERF_RECORD_MISC_USER,
/* .size */
},
/* .pid */
/* .tid */
.start = vma->vm_start,
.len = vma->vm_end - vma->vm_start,
.pgoff = (u64)vma->vm_pgoff << PAGE_SHIFT,
},
};
perf_event_mmap_event(&mmap_event);
}
/*
* IRQ throttle logging
*/
static void perf_log_throttle(struct perf_event *event, int enable)
{
struct perf_output_handle handle;
struct perf_sample_data sample;
int ret;
struct {
struct perf_event_header header;
u64 time;
u64 id;
u64 stream_id;
} throttle_event = {
.header = {
.type = PERF_RECORD_THROTTLE,
.misc = 0,
.size = sizeof(throttle_event),
},
.time = perf_clock(),
.id = primary_event_id(event),
.stream_id = event->id,
};
if (enable)
throttle_event.header.type = PERF_RECORD_UNTHROTTLE;
perf_event_header__init_id(&throttle_event.header, &sample, event);
ret = perf_output_begin(&handle, event,
throttle_event.header.size);
if (ret)
return;
perf_output_put(&handle, throttle_event);
perf_event__output_id_sample(event, &handle, &sample);
perf_output_end(&handle);
}
/*
* Generic event overflow handling, sampling.
*/
static int __perf_event_overflow(struct perf_event *event,
int throttle, struct perf_sample_data *data,
struct pt_regs *regs)
{
int events = atomic_read(&event->event_limit);
struct hw_perf_event *hwc = &event->hw;
u64 seq;
int ret = 0;
/*
* Non-sampling counters might still use the PMI to fold short
* hardware counters, ignore those.
*/
if (unlikely(!is_sampling_event(event)))
return 0;
seq = __this_cpu_read(perf_throttled_seq);
if (seq != hwc->interrupts_seq) {
hwc->interrupts_seq = seq;
hwc->interrupts = 1;
} else {
hwc->interrupts++;
if (unlikely(throttle
&& hwc->interrupts >= max_samples_per_tick)) {
__this_cpu_inc(perf_throttled_count);
hwc->interrupts = MAX_INTERRUPTS;
perf_log_throttle(event, 0);
ret = 1;
}
}
if (event->attr.freq) {
u64 now = perf_clock();
s64 delta = now - hwc->freq_time_stamp;
hwc->freq_time_stamp = now;
if (delta > 0 && delta < 2*TICK_NSEC)
perf_adjust_period(event, delta, hwc->last_period, true);
}
/*
* XXX event_limit might not quite work as expected on inherited
* events
*/
event->pending_kill = POLL_IN;
if (events && atomic_dec_and_test(&event->event_limit)) {
ret = 1;
event->pending_kill = POLL_HUP;
event->pending_disable = 1;
irq_work_queue(&event->pending);
}
if (event->overflow_handler)
event->overflow_handler(event, data, regs);
else
perf_event_output(event, data, regs);
if (event->fasync && event->pending_kill) {
event->pending_wakeup = 1;
irq_work_queue(&event->pending);
}
return ret;
}
int perf_event_overflow(struct perf_event *event,
struct perf_sample_data *data,
struct pt_regs *regs)
{
return __perf_event_overflow(event, 1, data, regs);
}
/*
* Generic software event infrastructure
*/
struct swevent_htable {
struct swevent_hlist *swevent_hlist;
struct mutex hlist_mutex;
int hlist_refcount;
/* Recursion avoidance in each contexts */
int recursion[PERF_NR_CONTEXTS];
/* Keeps track of cpu being initialized/exited */
bool online;
};
static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
/*
* We directly increment event->count and keep a second value in
* event->hw.period_left to count intervals. This period event
* is kept in the range [-sample_period, 0] so that we can use the
* sign as trigger.
*/
static u64 perf_swevent_set_period(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;
u64 period = hwc->last_period;
u64 nr, offset;
s64 old, val;
hwc->last_period = hwc->sample_period;
again:
old = val = local64_read(&hwc->period_left);
if (val < 0)
return 0;
nr = div64_u64(period + val, period);
offset = nr * period;
val -= offset;
if (local64_cmpxchg(&hwc->period_left, old, val) != old)
goto again;
return nr;
}
static void perf_swevent_overflow(struct perf_event *event, u64 overflow,
struct perf_sample_data *data,
struct pt_regs *regs)
{
struct hw_perf_event *hwc = &event->hw;
int throttle = 0;
if (!overflow)
overflow = perf_swevent_set_period(event);
if (hwc->interrupts == MAX_INTERRUPTS)
return;
for (; overflow; overflow--) {
if (__perf_event_overflow(event, throttle,
data, regs)) {
/*
* We inhibit the overflow from happening when
* hwc->interrupts == MAX_INTERRUPTS.
*/
break;
}
throttle = 1;
}
}
static void perf_swevent_event(struct perf_event *event, u64 nr,
struct perf_sample_data *data,
struct pt_regs *regs)
{
struct hw_perf_event *hwc = &event->hw;
local64_add(nr, &event->count);
if (!regs)
return;
if (!is_sampling_event(event))
return;
if ((event->attr.sample_type & PERF_SAMPLE_PERIOD) && !event->attr.freq) {
data->period = nr;
return perf_swevent_overflow(event, 1, data, regs);
} else
data->period = event->hw.last_period;
if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq)
return perf_swevent_overflow(event, 1, data, regs);
if (local64_add_negative(nr, &hwc->period_left))
return;
perf_swevent_overflow(event, 0, data, regs);
}
static int perf_exclude_event(struct perf_event *event,
struct pt_regs *regs)
{
if (event->hw.state & PERF_HES_STOPPED)
return 1;
if (regs) {
if (event->attr.exclude_user && user_mode(regs))
return 1;
if (event->attr.exclude_kernel && !user_mode(regs))
return 1;
}
return 0;
}
static int perf_swevent_match(struct perf_event *event,
enum perf_type_id type,
u32 event_id,
struct perf_sample_data *data,
struct pt_regs *regs)
{
if (event->attr.type != type)
return 0;
if (event->attr.config != event_id)
return 0;
if (perf_exclude_event(event, regs))
return 0;
return 1;
}
static inline u64 swevent_hash(u64 type, u32 event_id)
{
u64 val = event_id | (type << 32);
return hash_64(val, SWEVENT_HLIST_BITS);
}
static inline struct hlist_head *
__find_swevent_head(struct swevent_hlist *hlist, u64 type, u32 event_id)
{
u64 hash = swevent_hash(type, event_id);
return &hlist->heads[hash];
}
/* For the read side: events when they trigger */
static inline struct hlist_head *
find_swevent_head_rcu(struct swevent_htable *swhash, u64 type, u32 event_id)
{
struct swevent_hlist *hlist;
hlist = rcu_dereference(swhash->swevent_hlist);
if (!hlist)
return NULL;
return __find_swevent_head(hlist, type, event_id);
}
/* For the event head insertion and removal in the hlist */
static inline struct hlist_head *
find_swevent_head(struct swevent_htable *swhash, struct perf_event *event)
{
struct swevent_hlist *hlist;
u32 event_id = event->attr.config;
u64 type = event->attr.type;
/*
* Event scheduling is always serialized against hlist allocation
* and release. Which makes the protected version suitable here.
* The context lock guarantees that.
*/
hlist = rcu_dereference_protected(swhash->swevent_hlist,
lockdep_is_held(&event->ctx->lock));
if (!hlist)
return NULL;
return __find_swevent_head(hlist, type, event_id);
}
static void do_perf_sw_event(enum perf_type_id type, u32 event_id,
u64 nr,
struct perf_sample_data *data,
struct pt_regs *regs)
{
struct swevent_htable *swhash = &__get_cpu_var(swevent_htable);
struct perf_event *event;
struct hlist_node *node;
struct hlist_head *head;
rcu_read_lock();
head = find_swevent_head_rcu(swhash, type, event_id);
if (!head)
goto end;
hlist_for_each_entry_rcu(event, node, head, hlist_entry) {
if (perf_swevent_match(event, type, event_id, data, regs))
perf_swevent_event(event, nr, data, regs);
}
end:
rcu_read_unlock();
}
int perf_swevent_get_recursion_context(void)
{
struct swevent_htable *swhash = &__get_cpu_var(swevent_htable);
return get_recursion_context(swhash->recursion);
}
EXPORT_SYMBOL_GPL(perf_swevent_get_recursion_context);
inline void perf_swevent_put_recursion_context(int rctx)
{
struct swevent_htable *swhash = &__get_cpu_var(swevent_htable);
put_recursion_context(swhash->recursion, rctx);
}
void __perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
{
struct perf_sample_data data;
int rctx;
preempt_disable_notrace();
rctx = perf_swevent_get_recursion_context();
if (rctx < 0)
return;
perf_sample_data_init(&data, addr);
do_perf_sw_event(PERF_TYPE_SOFTWARE, event_id, nr, &data, regs);
perf_swevent_put_recursion_context(rctx);
preempt_enable_notrace();
}
static void perf_swevent_read(struct perf_event *event)
{
}
static int perf_swevent_add(struct perf_event *event, int flags)
{
struct swevent_htable *swhash = &__get_cpu_var(swevent_htable);
struct hw_perf_event *hwc = &event->hw;
struct hlist_head *head;
if (is_sampling_event(event)) {
hwc->last_period = hwc->sample_period;
perf_swevent_set_period(event);
}
hwc->state = !(flags & PERF_EF_START);
head = find_swevent_head(swhash, event);
if (!head) {
/*
* We can race with cpu hotplug code. Do not
* WARN if the cpu just got unplugged.
*/
WARN_ON_ONCE(swhash->online);
return -EINVAL;
}
hlist_add_head_rcu(&event->hlist_entry, head);
return 0;
}
static void perf_swevent_del(struct perf_event *event, int flags)
{
hlist_del_rcu(&event->hlist_entry);
}
static void perf_swevent_start(struct perf_event *event, int flags)
{
event->hw.state = 0;
}
static void perf_swevent_stop(struct perf_event *event, int flags)
{
event->hw.state = PERF_HES_STOPPED;
}
/* Deref the hlist from the update side */
static inline struct swevent_hlist *
swevent_hlist_deref(struct swevent_htable *swhash)
{
return rcu_dereference_protected(swhash->swevent_hlist,
lockdep_is_held(&swhash->hlist_mutex));
}
static void swevent_hlist_release(struct swevent_htable *swhash)
{
struct swevent_hlist *hlist = swevent_hlist_deref(swhash);
if (!hlist)
return;
rcu_assign_pointer(swhash->swevent_hlist, NULL);
kfree_rcu(hlist, rcu_head);
}
static void swevent_hlist_put_cpu(struct perf_event *event, int cpu)
{
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
mutex_lock(&swhash->hlist_mutex);
if (!--swhash->hlist_refcount)
swevent_hlist_release(swhash);
mutex_unlock(&swhash->hlist_mutex);
}
static void swevent_hlist_put(struct perf_event *event)
{
int cpu;
if (event->cpu != -1) {
swevent_hlist_put_cpu(event, event->cpu);
return;
}
for_each_possible_cpu(cpu)
swevent_hlist_put_cpu(event, cpu);
}
static int swevent_hlist_get_cpu(struct perf_event *event, int cpu)
{
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
int err = 0;
mutex_lock(&swhash->hlist_mutex);
if (!swevent_hlist_deref(swhash) && cpu_online(cpu)) {
struct swevent_hlist *hlist;
hlist = kzalloc(sizeof(*hlist), GFP_KERNEL);
if (!hlist) {
err = -ENOMEM;
goto exit;
}
rcu_assign_pointer(swhash->swevent_hlist, hlist);
}
swhash->hlist_refcount++;
exit:
mutex_unlock(&swhash->hlist_mutex);
return err;
}
static int swevent_hlist_get(struct perf_event *event)
{
int err;
int cpu, failed_cpu;
if (event->cpu != -1)
return swevent_hlist_get_cpu(event, event->cpu);
get_online_cpus();
for_each_possible_cpu(cpu) {
err = swevent_hlist_get_cpu(event, cpu);
if (err) {
failed_cpu = cpu;
goto fail;
}
}
put_online_cpus();
return 0;
fail:
for_each_possible_cpu(cpu) {
if (cpu == failed_cpu)
break;
swevent_hlist_put_cpu(event, cpu);
}
put_online_cpus();
return err;
}
struct static_key perf_swevent_enabled[PERF_COUNT_SW_MAX];
static void sw_perf_event_destroy(struct perf_event *event)
{
u64 event_id = event->attr.config;
WARN_ON(event->parent);
static_key_slow_dec(&perf_swevent_enabled[event_id]);
swevent_hlist_put(event);
}
static int perf_swevent_init(struct perf_event *event)
{
u64 event_id = event->attr.config;
if (event->attr.type != PERF_TYPE_SOFTWARE)
return -ENOENT;
/*
* no branch sampling for software events
*/
if (has_branch_stack(event))
return -EOPNOTSUPP;
switch (event_id) {
case PERF_COUNT_SW_CPU_CLOCK:
case PERF_COUNT_SW_TASK_CLOCK:
return -ENOENT;
default:
break;
}
if (event_id >= PERF_COUNT_SW_MAX)
return -ENOENT;
if (!event->parent) {
int err;
err = swevent_hlist_get(event);
if (err)
return err;
static_key_slow_inc(&perf_swevent_enabled[event_id]);
event->destroy = sw_perf_event_destroy;
}
return 0;
}
static int perf_swevent_event_idx(struct perf_event *event)
{
return 0;
}
static struct pmu perf_swevent = {
.task_ctx_nr = perf_sw_context,
.event_init = perf_swevent_init,
.add = perf_swevent_add,
.del = perf_swevent_del,
.start = perf_swevent_start,
.stop = perf_swevent_stop,
.read = perf_swevent_read,
.event_idx = perf_swevent_event_idx,
.events_across_hotplug = 1,
};
#ifdef CONFIG_EVENT_TRACING
static int perf_tp_filter_match(struct perf_event *event,
struct perf_sample_data *data)
{
void *record = data->raw->data;
if (likely(!event->filter) || filter_match_preds(event->filter, record))
return 1;
return 0;
}
static int perf_tp_event_match(struct perf_event *event,
struct perf_sample_data *data,
struct pt_regs *regs)
{
if (event->hw.state & PERF_HES_STOPPED)
return 0;
/*
* All tracepoints are from kernel-space.
*/
if (event->attr.exclude_kernel)
return 0;
if (!perf_tp_filter_match(event, data))
return 0;
return 1;
}
void perf_tp_event(u64 addr, u64 count, void *record, int entry_size,
struct pt_regs *regs, struct hlist_head *head, int rctx)
{
struct perf_sample_data data;
struct perf_event *event;
struct hlist_node *node;
struct perf_raw_record raw = {
.size = entry_size,
.data = record,
};
perf_sample_data_init(&data, addr);
data.raw = &raw;
hlist_for_each_entry_rcu(event, node, head, hlist_entry) {
if (perf_tp_event_match(event, &data, regs))
perf_swevent_event(event, count, &data, regs);
}
perf_swevent_put_recursion_context(rctx);
}
EXPORT_SYMBOL_GPL(perf_tp_event);
static void tp_perf_event_destroy(struct perf_event *event)
{
perf_trace_destroy(event);
}
static int perf_tp_event_init(struct perf_event *event)
{
int err;
if (event->attr.type != PERF_TYPE_TRACEPOINT)
return -ENOENT;
/*
* no branch sampling for tracepoint events
*/
if (has_branch_stack(event))
return -EOPNOTSUPP;
err = perf_trace_init(event);
if (err)
return err;
event->destroy = tp_perf_event_destroy;
return 0;
}
static struct pmu perf_tracepoint = {
.task_ctx_nr = perf_sw_context,
.event_init = perf_tp_event_init,
.add = perf_trace_add,
.del = perf_trace_del,
.start = perf_swevent_start,
.stop = perf_swevent_stop,
.read = perf_swevent_read,
.event_idx = perf_swevent_event_idx,
.events_across_hotplug = 1,
};
static inline void perf_tp_register(void)
{
perf_pmu_register(&perf_tracepoint, "tracepoint", PERF_TYPE_TRACEPOINT);
}
static int perf_event_set_filter(struct perf_event *event, void __user *arg)
{
char *filter_str;
int ret;
if (event->attr.type != PERF_TYPE_TRACEPOINT)
return -EINVAL;
filter_str = strndup_user(arg, PAGE_SIZE);
if (IS_ERR(filter_str))
return PTR_ERR(filter_str);
ret = ftrace_profile_set_filter(event, event->attr.config, filter_str);
kfree(filter_str);
return ret;
}
static void perf_event_free_filter(struct perf_event *event)
{
ftrace_profile_free_filter(event);
}
#else
static inline void perf_tp_register(void)
{
}
static int perf_event_set_filter(struct perf_event *event, void __user *arg)
{
return -ENOENT;
}
static void perf_event_free_filter(struct perf_event *event)
{
}
#endif /* CONFIG_EVENT_TRACING */
#ifdef CONFIG_HAVE_HW_BREAKPOINT
void perf_bp_event(struct perf_event *bp, void *data)
{
struct perf_sample_data sample;
struct pt_regs *regs = data;
perf_sample_data_init(&sample, bp->attr.bp_addr);
if (!bp->hw.state && !perf_exclude_event(bp, regs))
perf_swevent_event(bp, 1, &sample, regs);
}
#endif
/*
* hrtimer based swevent callback
*/
static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
{
enum hrtimer_restart ret = HRTIMER_RESTART;
struct perf_sample_data data;
struct pt_regs *regs;
struct perf_event *event;
u64 period;
event = container_of(hrtimer, struct perf_event, hw.hrtimer);
if (event->state != PERF_EVENT_STATE_ACTIVE)
return HRTIMER_NORESTART;
event->pmu->read(event);
perf_sample_data_init(&data, 0);
data.period = event->hw.last_period;
regs = get_irq_regs();
if (regs && !perf_exclude_event(event, regs)) {
if (!(event->attr.exclude_idle && is_idle_task(current)))
if (perf_event_overflow(event, &data, regs))
ret = HRTIMER_NORESTART;
}
period = max_t(u64, 10000, event->hw.sample_period);
hrtimer_forward_now(hrtimer, ns_to_ktime(period));
return ret;
}
static void perf_swevent_start_hrtimer(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;
s64 period;
if (!is_sampling_event(event))
return;
period = local64_read(&hwc->period_left);
if (period) {
if (period < 0)
period = 10000;
local64_set(&hwc->period_left, 0);
} else {
period = max_t(u64, 10000, hwc->sample_period);
}
__hrtimer_start_range_ns(&hwc->hrtimer,
ns_to_ktime(period), 0,
HRTIMER_MODE_REL_PINNED, 0);
}
static void perf_swevent_cancel_hrtimer(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;
if (is_sampling_event(event)) {
ktime_t remaining = hrtimer_get_remaining(&hwc->hrtimer);
local64_set(&hwc->period_left, ktime_to_ns(remaining));
hrtimer_cancel(&hwc->hrtimer);
}
}
static void perf_swevent_init_hrtimer(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;
if (!is_sampling_event(event))
return;
hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hwc->hrtimer.function = perf_swevent_hrtimer;
/*
* Since hrtimers have a fixed rate, we can do a static freq->period
* mapping and avoid the whole period adjust feedback stuff.
*/
if (event->attr.freq) {
long freq = event->attr.sample_freq;
event->attr.sample_period = NSEC_PER_SEC / freq;
hwc->sample_period = event->attr.sample_period;
local64_set(&hwc->period_left, hwc->sample_period);
event->attr.freq = 0;
}
}
/*
* Software event: cpu wall time clock
*/
static void cpu_clock_event_update(struct perf_event *event)
{
s64 prev;
u64 now;
now = local_clock();
prev = local64_xchg(&event->hw.prev_count, now);
local64_add(now - prev, &event->count);
}
static void cpu_clock_event_start(struct perf_event *event, int flags)
{
local64_set(&event->hw.prev_count, local_clock());
perf_swevent_start_hrtimer(event);
}
static void cpu_clock_event_stop(struct perf_event *event, int flags)
{
perf_swevent_cancel_hrtimer(event);
cpu_clock_event_update(event);
}
static int cpu_clock_event_add(struct perf_event *event, int flags)
{
if (flags & PERF_EF_START)
cpu_clock_event_start(event, flags);
return 0;
}
static void cpu_clock_event_del(struct perf_event *event, int flags)
{
cpu_clock_event_stop(event, flags);
}
static void cpu_clock_event_read(struct perf_event *event)
{
cpu_clock_event_update(event);
}
static int cpu_clock_event_init(struct perf_event *event)
{
if (event->attr.type != PERF_TYPE_SOFTWARE)
return -ENOENT;
if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK)
return -ENOENT;
/*
* no branch sampling for software events
*/
if (has_branch_stack(event))
return -EOPNOTSUPP;
perf_swevent_init_hrtimer(event);
return 0;
}
static struct pmu perf_cpu_clock = {
.task_ctx_nr = perf_sw_context,
.event_init = cpu_clock_event_init,
.add = cpu_clock_event_add,
.del = cpu_clock_event_del,
.start = cpu_clock_event_start,
.stop = cpu_clock_event_stop,
.read = cpu_clock_event_read,
.event_idx = perf_swevent_event_idx,
.events_across_hotplug = 1,
};
/*
* Software event: task time clock
*/
static void task_clock_event_update(struct perf_event *event, u64 now)
{
u64 prev;
s64 delta;
prev = local64_xchg(&event->hw.prev_count, now);
delta = now - prev;
local64_add(delta, &event->count);
}
static void task_clock_event_start(struct perf_event *event, int flags)
{
local64_set(&event->hw.prev_count, event->ctx->time);
perf_swevent_start_hrtimer(event);
}
static void task_clock_event_stop(struct perf_event *event, int flags)
{
perf_swevent_cancel_hrtimer(event);
task_clock_event_update(event, event->ctx->time);
}
static int task_clock_event_add(struct perf_event *event, int flags)
{
if (flags & PERF_EF_START)
task_clock_event_start(event, flags);
return 0;
}
static void task_clock_event_del(struct perf_event *event, int flags)
{
task_clock_event_stop(event, PERF_EF_UPDATE);
}
static void task_clock_event_read(struct perf_event *event)
{
u64 now = perf_clock();
u64 delta = now - event->ctx->timestamp;
u64 time = event->ctx->time + delta;
task_clock_event_update(event, time);
}
static int task_clock_event_init(struct perf_event *event)
{
if (event->attr.type != PERF_TYPE_SOFTWARE)
return -ENOENT;
if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK)
return -ENOENT;
/*
* no branch sampling for software events
*/
if (has_branch_stack(event))
return -EOPNOTSUPP;
perf_swevent_init_hrtimer(event);
return 0;
}
static struct pmu perf_task_clock = {
.task_ctx_nr = perf_sw_context,
.event_init = task_clock_event_init,
.add = task_clock_event_add,
.del = task_clock_event_del,
.start = task_clock_event_start,
.stop = task_clock_event_stop,
.read = task_clock_event_read,
.event_idx = perf_swevent_event_idx,
.events_across_hotplug = 1,
};
static void perf_pmu_nop_void(struct pmu *pmu)
{
}
static int perf_pmu_nop_int(struct pmu *pmu)
{
return 0;
}
static void perf_pmu_start_txn(struct pmu *pmu)
{
perf_pmu_disable(pmu);
}
static int perf_pmu_commit_txn(struct pmu *pmu)
{
perf_pmu_enable(pmu);
return 0;
}
static void perf_pmu_cancel_txn(struct pmu *pmu)
{
perf_pmu_enable(pmu);
}
static int perf_event_idx_default(struct perf_event *event)
{
return event->hw.idx + 1;
}
/*
* Ensures all contexts with the same task_ctx_nr have the same
* pmu_cpu_context too.
*/
static void *find_pmu_context(int ctxn)
{
struct pmu *pmu;
if (ctxn < 0)
return NULL;
list_for_each_entry(pmu, &pmus, entry) {
if (pmu->task_ctx_nr == ctxn)
return pmu->pmu_cpu_context;
}
return NULL;
}
static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu)
{
int cpu;
for_each_possible_cpu(cpu) {
struct perf_cpu_context *cpuctx;
cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
if (cpuctx->unique_pmu == old_pmu)
cpuctx->unique_pmu = pmu;
}
}
static void free_pmu_context(struct pmu *pmu)
{
struct pmu *i;
mutex_lock(&pmus_lock);
/*
* Like a real lame refcount.
*/
list_for_each_entry(i, &pmus, entry) {
if (i->pmu_cpu_context == pmu->pmu_cpu_context) {
update_pmu_context(i, pmu);
goto out;
}
}
free_percpu(pmu->pmu_cpu_context);
out:
mutex_unlock(&pmus_lock);
}
static struct idr pmu_idr;
static ssize_t
type_show(struct device *dev, struct device_attribute *attr, char *page)
{
struct pmu *pmu = dev_get_drvdata(dev);
return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->type);
}
static struct device_attribute pmu_dev_attrs[] = {
__ATTR_RO(type),
__ATTR_NULL,
};
static int pmu_bus_running;
static struct bus_type pmu_bus = {
.name = "event_source",
.dev_attrs = pmu_dev_attrs,
};
static void pmu_dev_release(struct device *dev)
{
kfree(dev);
}
static int pmu_dev_alloc(struct pmu *pmu)
{
int ret = -ENOMEM;
pmu->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!pmu->dev)
goto out;
pmu->dev->groups = pmu->attr_groups;
device_initialize(pmu->dev);
ret = dev_set_name(pmu->dev, "%s", pmu->name);
if (ret)
goto free_dev;
dev_set_drvdata(pmu->dev, pmu);
pmu->dev->bus = &pmu_bus;
pmu->dev->release = pmu_dev_release;
ret = device_add(pmu->dev);
if (ret)
goto free_dev;
out:
return ret;
free_dev:
put_device(pmu->dev);
goto out;
}
static struct lock_class_key cpuctx_mutex;
static struct lock_class_key cpuctx_lock;
int perf_pmu_register(struct pmu *pmu, char *name, int type)
{
int cpu, ret;
mutex_lock(&pmus_lock);
ret = -ENOMEM;
pmu->pmu_disable_count = alloc_percpu(int);
if (!pmu->pmu_disable_count)
goto unlock;
pmu->type = -1;
if (!name)
goto skip_type;
pmu->name = name;
if (type < 0) {
int err = idr_pre_get(&pmu_idr, GFP_KERNEL);
if (!err)
goto free_pdc;
err = idr_get_new_above(&pmu_idr, pmu, PERF_TYPE_MAX, &type);
if (err) {
ret = err;
goto free_pdc;
}
}
pmu->type = type;
if (pmu_bus_running) {
ret = pmu_dev_alloc(pmu);
if (ret)
goto free_idr;
}
skip_type:
pmu->pmu_cpu_context = find_pmu_context(pmu->task_ctx_nr);
if (pmu->pmu_cpu_context)
goto got_cpu_context;
ret = -ENOMEM;
pmu->pmu_cpu_context = alloc_percpu(struct perf_cpu_context);
if (!pmu->pmu_cpu_context)
goto free_dev;
for_each_possible_cpu(cpu) {
struct perf_cpu_context *cpuctx;
cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
__perf_event_init_context(&cpuctx->ctx);
lockdep_set_class(&cpuctx->ctx.mutex, &cpuctx_mutex);
lockdep_set_class(&cpuctx->ctx.lock, &cpuctx_lock);
cpuctx->ctx.type = cpu_context;
cpuctx->ctx.pmu = pmu;
cpuctx->jiffies_interval = 1;
INIT_LIST_HEAD(&cpuctx->rotation_list);
cpuctx->unique_pmu = pmu;
}
got_cpu_context:
if (!pmu->start_txn) {
if (pmu->pmu_enable) {
/*
* If we have pmu_enable/pmu_disable calls, install
* transaction stubs that use that to try and batch
* hardware accesses.
*/
pmu->start_txn = perf_pmu_start_txn;
pmu->commit_txn = perf_pmu_commit_txn;
pmu->cancel_txn = perf_pmu_cancel_txn;
} else {
pmu->start_txn = perf_pmu_nop_void;
pmu->commit_txn = perf_pmu_nop_int;
pmu->cancel_txn = perf_pmu_nop_void;
}
}
if (!pmu->pmu_enable) {
pmu->pmu_enable = perf_pmu_nop_void;
pmu->pmu_disable = perf_pmu_nop_void;
}
if (!pmu->event_idx)
pmu->event_idx = perf_event_idx_default;
list_add_rcu(&pmu->entry, &pmus);
ret = 0;
unlock:
mutex_unlock(&pmus_lock);
return ret;
free_dev:
device_del(pmu->dev);
put_device(pmu->dev);
free_idr:
if (pmu->type >= PERF_TYPE_MAX)
idr_remove(&pmu_idr, pmu->type);
free_pdc:
free_percpu(pmu->pmu_disable_count);
goto unlock;
}
void perf_pmu_unregister(struct pmu *pmu)
{
mutex_lock(&pmus_lock);
list_del_rcu(&pmu->entry);
mutex_unlock(&pmus_lock);
/*
* We dereference the pmu list under both SRCU and regular RCU, so
* synchronize against both of those.
*/
synchronize_srcu(&pmus_srcu);
synchronize_rcu();
free_percpu(pmu->pmu_disable_count);
if (pmu->type >= PERF_TYPE_MAX)
idr_remove(&pmu_idr, pmu->type);
device_del(pmu->dev);
put_device(pmu->dev);
free_pmu_context(pmu);
}
struct pmu *perf_init_event(struct perf_event *event)
{
struct pmu *pmu = NULL;
int idx;
int ret;
idx = srcu_read_lock(&pmus_srcu);
rcu_read_lock();
pmu = idr_find(&pmu_idr, event->attr.type);
rcu_read_unlock();
if (pmu) {
event->pmu = pmu;
ret = pmu->event_init(event);
if (ret)
pmu = ERR_PTR(ret);
goto unlock;
}
list_for_each_entry_rcu(pmu, &pmus, entry) {
event->pmu = pmu;
ret = pmu->event_init(event);
if (!ret)
goto unlock;
if (ret != -ENOENT) {
pmu = ERR_PTR(ret);
goto unlock;
}
}
pmu = ERR_PTR(-ENOENT);
unlock:
srcu_read_unlock(&pmus_srcu, idx);
return pmu;
}
/*
* Allocate and initialize a event structure
*/
static struct perf_event *
perf_event_alloc(struct perf_event_attr *attr, int cpu,
struct task_struct *task,
struct perf_event *group_leader,
struct perf_event *parent_event,
perf_overflow_handler_t overflow_handler,
void *context)
{
struct pmu *pmu;
struct perf_event *event;
struct hw_perf_event *hwc;
long err;
if ((unsigned)cpu >= nr_cpu_ids) {
if (!task || cpu != -1)
return ERR_PTR(-EINVAL);
}
event = kzalloc(sizeof(*event), GFP_KERNEL);
if (!event)
return ERR_PTR(-ENOMEM);
/*
* Single events are their own group leaders, with an
* empty sibling list:
*/
if (!group_leader)
group_leader = event;
mutex_init(&event->child_mutex);
INIT_LIST_HEAD(&event->child_list);
INIT_LIST_HEAD(&event->group_entry);
INIT_LIST_HEAD(&event->event_entry);
INIT_LIST_HEAD(&event->sibling_list);
INIT_LIST_HEAD(&event->rb_entry);
init_waitqueue_head(&event->waitq);
init_irq_work(&event->pending, perf_pending_event);
mutex_init(&event->mmap_mutex);
atomic_long_set(&event->refcount, 1);
event->cpu = cpu;
event->attr = *attr;
event->group_leader = group_leader;
event->pmu = NULL;
event->oncpu = -1;
event->parent = parent_event;
event->ns = get_pid_ns(current->nsproxy->pid_ns);
event->id = atomic64_inc_return(&perf_event_id);
event->state = PERF_EVENT_STATE_INACTIVE;
if (task) {
event->attach_state = PERF_ATTACH_TASK;
#ifdef CONFIG_HAVE_HW_BREAKPOINT
/*
* hw_breakpoint is a bit difficult here..
*/
if (attr->type == PERF_TYPE_BREAKPOINT)
event->hw.bp_target = task;
#endif
}
if (!overflow_handler && parent_event) {
overflow_handler = parent_event->overflow_handler;
context = parent_event->overflow_handler_context;
}
event->overflow_handler = overflow_handler;
event->overflow_handler_context = context;
perf_event__state_init(event);
pmu = NULL;
hwc = &event->hw;
hwc->sample_period = attr->sample_period;
if (attr->freq && attr->sample_freq)
hwc->sample_period = 1;
hwc->last_period = hwc->sample_period;
local64_set(&hwc->period_left, hwc->sample_period);
/*
* we currently do not support PERF_FORMAT_GROUP on inherited events
*/
if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP))
goto done;
pmu = perf_init_event(event);
done:
err = 0;
if (!pmu)
err = -EINVAL;
else if (IS_ERR(pmu))
err = PTR_ERR(pmu);
if (err) {
if (event->ns)
put_pid_ns(event->ns);
kfree(event);
return ERR_PTR(err);
}
if (!event->parent) {
if (event->attach_state & PERF_ATTACH_TASK)
static_key_slow_inc(&perf_sched_events.key);
if (event->attr.mmap || event->attr.mmap_data)
atomic_inc(&nr_mmap_events);
if (event->attr.comm)
atomic_inc(&nr_comm_events);
if (event->attr.task)
atomic_inc(&nr_task_events);
if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
err = get_callchain_buffers();
if (err) {
free_event(event);
return ERR_PTR(err);
}
}
if (has_branch_stack(event)) {
static_key_slow_inc(&perf_sched_events.key);
if (!(event->attach_state & PERF_ATTACH_TASK))
atomic_inc(&per_cpu(perf_branch_stack_events,
event->cpu));
}
}
return event;
}
static int perf_copy_attr(struct perf_event_attr __user *uattr,
struct perf_event_attr *attr)
{
u32 size;
int ret;
if (!access_ok(VERIFY_WRITE, uattr, PERF_ATTR_SIZE_VER0))
return -EFAULT;
/*
* zero the full structure, so that a short copy will be nice.
*/
memset(attr, 0, sizeof(*attr));
ret = get_user(size, &uattr->size);
if (ret)
return ret;
if (size > PAGE_SIZE) /* silly large */
goto err_size;
if (!size) /* abi compat */
size = PERF_ATTR_SIZE_VER0;
if (size < PERF_ATTR_SIZE_VER0)
goto err_size;
/*
* If we're handed a bigger struct than we know of,
* ensure all the unknown bits are 0 - i.e. new
* user-space does not rely on any kernel feature
* extensions we dont know about yet.
*/
if (size > sizeof(*attr)) {
unsigned char __user *addr;
unsigned char __user *end;
unsigned char val;
addr = (void __user *)uattr + sizeof(*attr);
end = (void __user *)uattr + size;
for (; addr < end; addr++) {
ret = get_user(val, addr);
if (ret)
return ret;
if (val)
goto err_size;
}
size = sizeof(*attr);
}
ret = copy_from_user(attr, uattr, size);
if (ret)
return -EFAULT;
if (attr->__reserved_1)
return -EINVAL;
if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))
return -EINVAL;
if (attr->read_format & ~(PERF_FORMAT_MAX-1))
return -EINVAL;
if (attr->sample_type & PERF_SAMPLE_BRANCH_STACK) {
u64 mask = attr->branch_sample_type;
/* only using defined bits */
if (mask & ~(PERF_SAMPLE_BRANCH_MAX-1))
return -EINVAL;
/* at least one branch bit must be set */
if (!(mask & ~PERF_SAMPLE_BRANCH_PLM_ALL))
return -EINVAL;
/* kernel level capture: check permissions */
if ((mask & PERF_SAMPLE_BRANCH_PERM_PLM)
&& perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
return -EACCES;
/* propagate priv level, when not set for branch */
if (!(mask & PERF_SAMPLE_BRANCH_PLM_ALL)) {
/* exclude_kernel checked on syscall entry */
if (!attr->exclude_kernel)
mask |= PERF_SAMPLE_BRANCH_KERNEL;
if (!attr->exclude_user)
mask |= PERF_SAMPLE_BRANCH_USER;
if (!attr->exclude_hv)
mask |= PERF_SAMPLE_BRANCH_HV;
/*
* adjust user setting (for HW filter setup)
*/
attr->branch_sample_type = mask;
}
}
out:
return ret;
err_size:
put_user(sizeof(*attr), &uattr->size);
ret = -E2BIG;
goto out;
}
static int
perf_event_set_output(struct perf_event *event, struct perf_event *output_event)
{
struct ring_buffer *rb = NULL, *old_rb = NULL;
int ret = -EINVAL;
if (!output_event)
goto set;
/* don't allow circular references */
if (event == output_event)
goto out;
/*
* Don't allow cross-cpu buffers
*/
if (output_event->cpu != event->cpu)
goto out;
/*
* If its not a per-cpu rb, it must be the same task.
*/
if (output_event->cpu == -1 && output_event->ctx != event->ctx)
goto out;
set:
mutex_lock(&event->mmap_mutex);
/* Can't redirect output if we've got an active mmap() */
if (atomic_read(&event->mmap_count))
goto unlock;
old_rb = event->rb;
if (output_event) {
/* get the rb we want to redirect to */
rb = ring_buffer_get(output_event);
if (!rb)
goto unlock;
}
if (old_rb)
ring_buffer_detach(event, old_rb);
if (rb)
ring_buffer_attach(event, rb);
rcu_assign_pointer(event->rb, rb);
if (old_rb) {
ring_buffer_put(old_rb);
/*
* Since we detached before setting the new rb, so that we
* could attach the new rb, we could have missed a wakeup.
* Provide it now.
*/
wake_up_all(&event->waitq);
}
ret = 0;
unlock:
mutex_unlock(&event->mmap_mutex);
out:
return ret;
}
/**
* sys_perf_event_open - open a performance event, associate it to a task/cpu
*
* @attr_uptr: event_id type attributes for monitoring/sampling
* @pid: target pid
* @cpu: target cpu
* @group_fd: group leader event fd
*/
SYSCALL_DEFINE5(perf_event_open,
struct perf_event_attr __user *, attr_uptr,
pid_t, pid, int, cpu, int, group_fd, unsigned long, flags)
{
struct perf_event *group_leader = NULL, *output_event = NULL;
struct perf_event *event, *sibling;
struct perf_event_attr attr;
struct perf_event_context *ctx;
struct file *event_file = NULL;
struct file *group_file = NULL;
struct task_struct *task = NULL;
struct pmu *pmu;
int event_fd;
int move_group = 0;
int fput_needed = 0;
int err;
/* for future expandability... */
if (flags & ~PERF_FLAG_ALL)
return -EINVAL;
err = perf_copy_attr(attr_uptr, &attr);
if (err)
return err;
if (!attr.exclude_kernel) {
if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
return -EACCES;
}
if (attr.freq) {
if (attr.sample_freq > sysctl_perf_event_sample_rate)
return -EINVAL;
} else {
if (attr.sample_period & (1ULL << 63))
return -EINVAL;
}
/*
* In cgroup mode, the pid argument is used to pass the fd
* opened to the cgroup directory in cgroupfs. The cpu argument
* designates the cpu on which to monitor threads from that
* cgroup.
*/
if ((flags & PERF_FLAG_PID_CGROUP) && (pid == -1 || cpu == -1))
return -EINVAL;
event_fd = get_unused_fd_flags(O_RDWR);
if (event_fd < 0)
return event_fd;
if (group_fd != -1) {
group_file = perf_fget_light(group_fd, &fput_needed);
if (IS_ERR(group_file)) {
err = PTR_ERR(group_file);
goto err_fd;
}
group_leader = group_file->private_data;
if (flags & PERF_FLAG_FD_OUTPUT)
output_event = group_leader;
if (flags & PERF_FLAG_FD_NO_GROUP)
group_leader = NULL;
}
if (pid != -1 && !(flags & PERF_FLAG_PID_CGROUP)) {
task = find_lively_task_by_vpid(pid);
if (IS_ERR(task)) {
err = PTR_ERR(task);
goto err_group_fd;
}
}
event = perf_event_alloc(&attr, cpu, task, group_leader, NULL,
NULL, NULL);
if (IS_ERR(event)) {
err = PTR_ERR(event);
goto err_task;
}
if (flags & PERF_FLAG_PID_CGROUP) {
err = perf_cgroup_connect(pid, event, &attr, group_leader);
if (err)
goto err_alloc;
/*
* one more event:
* - that has cgroup constraint on event->cpu
* - that may need work on context switch
*/
atomic_inc(&per_cpu(perf_cgroup_events, event->cpu));
static_key_slow_inc(&perf_sched_events.key);
}
/*
* Special case software events and allow them to be part of
* any hardware group.
*/
pmu = event->pmu;
if (group_leader &&
(is_software_event(event) != is_software_event(group_leader))) {
if (is_software_event(event)) {
/*
* If event and group_leader are not both a software
* event, and event is, then group leader is not.
*
* Allow the addition of software events to !software
* groups, this is safe because software events never
* fail to schedule.
*/
pmu = group_leader->pmu;
} else if (is_software_event(group_leader) &&
(group_leader->group_flags & PERF_GROUP_SOFTWARE)) {
/*
* In case the group is a pure software group, and we
* try to add a hardware event, move the whole group to
* the hardware context.
*/
move_group = 1;
}
}
/*
* Get the target context (task or percpu):
*/
ctx = find_get_context(pmu, task, cpu);
if (IS_ERR(ctx)) {
err = PTR_ERR(ctx);
goto err_alloc;
}
if (task) {
put_task_struct(task);
task = NULL;
}
/*
* Look up the group leader (we will attach this event to it):
*/
if (group_leader) {
err = -EINVAL;
/*
* Do not allow a recursive hierarchy (this new sibling
* becoming part of another group-sibling):
*/
if (group_leader->group_leader != group_leader)
goto err_context;
/*
* Do not allow to attach to a group in a different
* task or CPU context:
*/
if (move_group) {
if (group_leader->ctx->type != ctx->type)
goto err_context;
} else {
if (group_leader->ctx != ctx)
goto err_context;
}
/*
* Only a group leader can be exclusive or pinned
*/
if (attr.exclusive || attr.pinned)
goto err_context;
}
if (output_event) {
err = perf_event_set_output(event, output_event);
if (err)
goto err_context;
}
event_file = anon_inode_getfile("[perf_event]", &perf_fops, event, O_RDWR);
if (IS_ERR(event_file)) {
err = PTR_ERR(event_file);
goto err_context;
}
if (move_group) {
struct perf_event_context *gctx = group_leader->ctx;
mutex_lock(&gctx->mutex);
perf_remove_from_context(group_leader, false);
/*
* Removing from the context ends up with disabled
* event. What we want here is event in the initial
* startup state, ready to be add into new context.
*/
perf_event__state_init(group_leader);
list_for_each_entry(sibling, &group_leader->sibling_list,
group_entry) {
perf_remove_from_context(sibling, false);
perf_event__state_init(sibling);
put_ctx(gctx);
}
mutex_unlock(&gctx->mutex);
put_ctx(gctx);
}
WARN_ON_ONCE(ctx->parent_ctx);
mutex_lock(&ctx->mutex);
if (move_group) {
perf_install_in_context(ctx, group_leader, cpu);
get_ctx(ctx);
list_for_each_entry(sibling, &group_leader->sibling_list,
group_entry) {
perf_install_in_context(ctx, sibling, cpu);
get_ctx(ctx);
}
}
perf_install_in_context(ctx, event, cpu);
++ctx->generation;
perf_unpin_context(ctx);
mutex_unlock(&ctx->mutex);
event->owner = current;
mutex_lock(¤t->perf_event_mutex);
list_add_tail(&event->owner_entry, ¤t->perf_event_list);
mutex_unlock(¤t->perf_event_mutex);
/*
* Precalculate sample_data sizes
*/
perf_event__header_size(event);
perf_event__id_header_size(event);
/*
* Drop the reference on the group_event after placing the
* new event on the sibling_list. This ensures destruction
* of the group leader will find the pointer to itself in
* perf_group_detach().
*/
fput_light(group_file, fput_needed);
fd_install(event_fd, event_file);
return event_fd;
err_context:
perf_unpin_context(ctx);
put_ctx(ctx);
err_alloc:
free_event(event);
err_task:
if (task)
put_task_struct(task);
err_group_fd:
fput_light(group_file, fput_needed);
err_fd:
put_unused_fd(event_fd);
return err;
}
/**
* perf_event_create_kernel_counter
*
* @attr: attributes of the counter to create
* @cpu: cpu in which the counter is bound
* @task: task to profile (NULL for percpu)
*/
struct perf_event *
perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
struct task_struct *task,
perf_overflow_handler_t overflow_handler,
void *context)
{
struct perf_event_context *ctx;
struct perf_event *event;
int err;
/*
* Get the target context (task or percpu):
*/
event = perf_event_alloc(attr, cpu, task, NULL, NULL,
overflow_handler, context);
if (IS_ERR(event)) {
err = PTR_ERR(event);
goto err;
}
ctx = find_get_context(event->pmu, task, cpu);
if (IS_ERR(ctx)) {
err = PTR_ERR(ctx);
goto err_free;
}
WARN_ON_ONCE(ctx->parent_ctx);
mutex_lock(&ctx->mutex);
perf_install_in_context(ctx, event, cpu);
++ctx->generation;
perf_unpin_context(ctx);
mutex_unlock(&ctx->mutex);
return event;
err_free:
free_event(event);
err:
return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);
static void sync_child_event(struct perf_event *child_event,
struct task_struct *child)
{
struct perf_event *parent_event = child_event->parent;
u64 child_val;
if (child_event->attr.inherit_stat)
perf_event_read_event(child_event, child);
child_val = perf_event_count(child_event);
/*
* Add back the child's count to the parent's count:
*/
atomic64_add(child_val, &parent_event->child_count);
atomic64_add(child_event->total_time_enabled,
&parent_event->child_total_time_enabled);
atomic64_add(child_event->total_time_running,
&parent_event->child_total_time_running);
/*
* Remove this event from the parent's list
*/
WARN_ON_ONCE(parent_event->ctx->parent_ctx);
mutex_lock(&parent_event->child_mutex);
list_del_init(&child_event->child_list);
mutex_unlock(&parent_event->child_mutex);
/*
* Release the parent event, if this was the last
* reference to it.
*/
put_event(parent_event);
}
static void
__perf_event_exit_task(struct perf_event *child_event,
struct perf_event_context *child_ctx,
struct task_struct *child)
{
perf_remove_from_context(child_event, !!child_event->parent);
/*
* It can happen that the parent exits first, and has events
* that are still around due to the child reference. These
* events need to be zapped.
*/
if (child_event->parent) {
sync_child_event(child_event, child);
free_event(child_event);
}
}
static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
{
struct perf_event *child_event, *tmp;
struct perf_event_context *child_ctx;
unsigned long flags;
if (likely(!child->perf_event_ctxp[ctxn])) {
perf_event_task(child, NULL, 0);
return;
}
local_irq_save(flags);
/*
* We can't reschedule here because interrupts are disabled,
* and either child is current or it is a task that can't be
* scheduled, so we are now safe from rescheduling changing
* our context.
*/
child_ctx = rcu_dereference_raw(child->perf_event_ctxp[ctxn]);
/*
* Take the context lock here so that if find_get_context is
* reading child->perf_event_ctxp, we wait until it has
* incremented the context's refcount before we do put_ctx below.
*/
raw_spin_lock(&child_ctx->lock);
task_ctx_sched_out(child_ctx);
child->perf_event_ctxp[ctxn] = NULL;
/*
* If this context is a clone; unclone it so it can't get
* swapped to another process while we're removing all
* the events from it.
*/
unclone_ctx(child_ctx);
update_context_time(child_ctx);
raw_spin_unlock_irqrestore(&child_ctx->lock, flags);
/*
* Report the task dead after unscheduling the events so that we
* won't get any samples after PERF_RECORD_EXIT. We can however still
* get a few PERF_RECORD_READ events.
*/
perf_event_task(child, child_ctx, 0);
/*
* We can recurse on the same lock type through:
*
* __perf_event_exit_task()
* sync_child_event()
* put_event()
* mutex_lock(&ctx->mutex)
*
* But since its the parent context it won't be the same instance.
*/
mutex_lock(&child_ctx->mutex);
again:
list_for_each_entry_safe(child_event, tmp, &child_ctx->pinned_groups,
group_entry)
__perf_event_exit_task(child_event, child_ctx, child);
list_for_each_entry_safe(child_event, tmp, &child_ctx->flexible_groups,
group_entry)
__perf_event_exit_task(child_event, child_ctx, child);
/*
* If the last event was a group event, it will have appended all
* its siblings to the list, but we obtained 'tmp' before that which
* will still point to the list head terminating the iteration.
*/
if (!list_empty(&child_ctx->pinned_groups) ||
!list_empty(&child_ctx->flexible_groups))
goto again;
mutex_unlock(&child_ctx->mutex);
put_ctx(child_ctx);
}
/*
* When a child task exits, feed back event values to parent events.
*/
void perf_event_exit_task(struct task_struct *child)
{
struct perf_event *event, *tmp;
int ctxn;
mutex_lock(&child->perf_event_mutex);
list_for_each_entry_safe(event, tmp, &child->perf_event_list,
owner_entry) {
list_del_init(&event->owner_entry);
/*
* Ensure the list deletion is visible before we clear
* the owner, closes a race against perf_release() where
* we need to serialize on the owner->perf_event_mutex.
*/
smp_wmb();
event->owner = NULL;
}
mutex_unlock(&child->perf_event_mutex);
for_each_task_context_nr(ctxn)
perf_event_exit_task_context(child, ctxn);
}
static void perf_free_event(struct perf_event *event,
struct perf_event_context *ctx)
{
struct perf_event *parent = event->parent;
if (WARN_ON_ONCE(!parent))
return;
mutex_lock(&parent->child_mutex);
list_del_init(&event->child_list);
mutex_unlock(&parent->child_mutex);
put_event(parent);
perf_group_detach(event);
list_del_event(event, ctx);
free_event(event);
}
/*
* free an unexposed, unused context as created by inheritance by
* perf_event_init_task below, used by fork() in case of fail.
*/
void perf_event_free_task(struct task_struct *task)
{
struct perf_event_context *ctx;
struct perf_event *event, *tmp;
int ctxn;
for_each_task_context_nr(ctxn) {
ctx = task->perf_event_ctxp[ctxn];
if (!ctx)
continue;
mutex_lock(&ctx->mutex);
again:
list_for_each_entry_safe(event, tmp, &ctx->pinned_groups,
group_entry)
perf_free_event(event, ctx);
list_for_each_entry_safe(event, tmp, &ctx->flexible_groups,
group_entry)
perf_free_event(event, ctx);
if (!list_empty(&ctx->pinned_groups) ||
!list_empty(&ctx->flexible_groups))
goto again;
mutex_unlock(&ctx->mutex);
put_ctx(ctx);
}
}
void perf_event_delayed_put(struct task_struct *task)
{
int ctxn;
for_each_task_context_nr(ctxn)
WARN_ON_ONCE(task->perf_event_ctxp[ctxn]);
}
/*
* inherit a event from parent task to child task:
*/
static struct perf_event *
inherit_event(struct perf_event *parent_event,
struct task_struct *parent,
struct perf_event_context *parent_ctx,
struct task_struct *child,
struct perf_event *group_leader,
struct perf_event_context *child_ctx)
{
struct perf_event *child_event;
unsigned long flags;
/*
* Instead of creating recursive hierarchies of events,
* we link inherited events back to the original parent,
* which has a filp for sure, which we use as the reference
* count:
*/
if (parent_event->parent)
parent_event = parent_event->parent;
child_event = perf_event_alloc(&parent_event->attr,
parent_event->cpu,
child,
group_leader, parent_event,
NULL, NULL);
if (IS_ERR(child_event))
return child_event;
if (!atomic_long_inc_not_zero(&parent_event->refcount)) {
free_event(child_event);
return NULL;
}
get_ctx(child_ctx);
/*
* Make the child state follow the state of the parent event,
* not its attr.disabled bit. We hold the parent's mutex,
* so we won't race with perf_event_{en, dis}able_family.
*/
if (parent_event->state >= PERF_EVENT_STATE_INACTIVE)
child_event->state = PERF_EVENT_STATE_INACTIVE;
else
child_event->state = PERF_EVENT_STATE_OFF;
if (parent_event->attr.freq) {
u64 sample_period = parent_event->hw.sample_period;
struct hw_perf_event *hwc = &child_event->hw;
hwc->sample_period = sample_period;
hwc->last_period = sample_period;
local64_set(&hwc->period_left, sample_period);
}
child_event->ctx = child_ctx;
child_event->overflow_handler = parent_event->overflow_handler;
child_event->overflow_handler_context
= parent_event->overflow_handler_context;
/*
* Precalculate sample_data sizes
*/
perf_event__header_size(child_event);
perf_event__id_header_size(child_event);
/*
* Link it up in the child's context:
*/
raw_spin_lock_irqsave(&child_ctx->lock, flags);
add_event_to_ctx(child_event, child_ctx);
raw_spin_unlock_irqrestore(&child_ctx->lock, flags);
/*
* Link this into the parent event's child list
*/
WARN_ON_ONCE(parent_event->ctx->parent_ctx);
mutex_lock(&parent_event->child_mutex);
list_add_tail(&child_event->child_list, &parent_event->child_list);
mutex_unlock(&parent_event->child_mutex);
return child_event;
}
static int inherit_group(struct perf_event *parent_event,
struct task_struct *parent,
struct perf_event_context *parent_ctx,
struct task_struct *child,
struct perf_event_context *child_ctx)
{
struct perf_event *leader;
struct perf_event *sub;
struct perf_event *child_ctr;
leader = inherit_event(parent_event, parent, parent_ctx,
child, NULL, child_ctx);
if (IS_ERR(leader))
return PTR_ERR(leader);
list_for_each_entry(sub, &parent_event->sibling_list, group_entry) {
child_ctr = inherit_event(sub, parent, parent_ctx,
child, leader, child_ctx);
if (IS_ERR(child_ctr))
return PTR_ERR(child_ctr);
}
return 0;
}
static int
inherit_task_group(struct perf_event *event, struct task_struct *parent,
struct perf_event_context *parent_ctx,
struct task_struct *child, int ctxn,
int *inherited_all)
{
int ret;
struct perf_event_context *child_ctx;
if (!event->attr.inherit) {
*inherited_all = 0;
return 0;
}
child_ctx = child->perf_event_ctxp[ctxn];
if (!child_ctx) {
/*
* This is executed from the parent task context, so
* inherit events that have been marked for cloning.
* First allocate and initialize a context for the
* child.
*/
child_ctx = alloc_perf_context(parent_ctx->pmu, child);
if (!child_ctx)
return -ENOMEM;
child->perf_event_ctxp[ctxn] = child_ctx;
}
ret = inherit_group(event, parent, parent_ctx,
child, child_ctx);
if (ret)
*inherited_all = 0;
return ret;
}
/*
* Initialize the perf_event context in task_struct
*/
int perf_event_init_context(struct task_struct *child, int ctxn)
{
struct perf_event_context *child_ctx, *parent_ctx;
struct perf_event_context *cloned_ctx;
struct perf_event *event;
struct task_struct *parent = current;
int inherited_all = 1;
unsigned long flags;
int ret = 0;
if (likely(!parent->perf_event_ctxp[ctxn]))
return 0;
/*
* If the parent's context is a clone, pin it so it won't get
* swapped under us.
*/
parent_ctx = perf_pin_task_context(parent, ctxn);
/*
* No need to check if parent_ctx != NULL here; since we saw
* it non-NULL earlier, the only reason for it to become NULL
* is if we exit, and since we're currently in the middle of
* a fork we can't be exiting at the same time.
*/
/*
* Lock the parent list. No need to lock the child - not PID
* hashed yet and not running, so nobody can access it.
*/
mutex_lock(&parent_ctx->mutex);
/*
* We dont have to disable NMIs - we are only looking at
* the list, not manipulating it:
*/
list_for_each_entry(event, &parent_ctx->pinned_groups, group_entry) {
ret = inherit_task_group(event, parent, parent_ctx,
child, ctxn, &inherited_all);
if (ret)
break;
}
/*
* We can't hold ctx->lock when iterating the ->flexible_group list due
* to allocations, but we need to prevent rotation because
* rotate_ctx() will change the list from interrupt context.
*/
raw_spin_lock_irqsave(&parent_ctx->lock, flags);
parent_ctx->rotate_disable = 1;
raw_spin_unlock_irqrestore(&parent_ctx->lock, flags);
list_for_each_entry(event, &parent_ctx->flexible_groups, group_entry) {
ret = inherit_task_group(event, parent, parent_ctx,
child, ctxn, &inherited_all);
if (ret)
break;
}
raw_spin_lock_irqsave(&parent_ctx->lock, flags);
parent_ctx->rotate_disable = 0;
child_ctx = child->perf_event_ctxp[ctxn];
if (child_ctx && inherited_all) {
/*
* Mark the child context as a clone of the parent
* context, or of whatever the parent is a clone of.
*
* Note that if the parent is a clone, the holding of
* parent_ctx->lock avoids it from being uncloned.
*/
cloned_ctx = parent_ctx->parent_ctx;
if (cloned_ctx) {
child_ctx->parent_ctx = cloned_ctx;
child_ctx->parent_gen = parent_ctx->parent_gen;
} else {
child_ctx->parent_ctx = parent_ctx;
child_ctx->parent_gen = parent_ctx->generation;
}
get_ctx(child_ctx->parent_ctx);
}
raw_spin_unlock_irqrestore(&parent_ctx->lock, flags);
mutex_unlock(&parent_ctx->mutex);
perf_unpin_context(parent_ctx);
put_ctx(parent_ctx);
return ret;
}
/*
* Initialize the perf_event context in task_struct
*/
int perf_event_init_task(struct task_struct *child)
{
int ctxn, ret;
memset(child->perf_event_ctxp, 0, sizeof(child->perf_event_ctxp));
mutex_init(&child->perf_event_mutex);
INIT_LIST_HEAD(&child->perf_event_list);
for_each_task_context_nr(ctxn) {
ret = perf_event_init_context(child, ctxn);
if (ret) {
perf_event_free_task(child);
return ret;
}
}
return 0;
}
static void __init perf_event_init_all_cpus(void)
{
struct swevent_htable *swhash;
int cpu;
for_each_possible_cpu(cpu) {
swhash = &per_cpu(swevent_htable, cpu);
mutex_init(&swhash->hlist_mutex);
INIT_LIST_HEAD(&per_cpu(rotation_list, cpu));
}
}
static void __cpuinit perf_event_init_cpu(int cpu)
{
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
mutex_lock(&swhash->hlist_mutex);
swhash->online = true;
if (swhash->hlist_refcount > 0) {
struct swevent_hlist *hlist;
hlist = kzalloc_node(sizeof(*hlist), GFP_KERNEL, cpu_to_node(cpu));
WARN_ON(!hlist);
rcu_assign_pointer(swhash->swevent_hlist, hlist);
}
mutex_unlock(&swhash->hlist_mutex);
}
#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC
static void perf_pmu_rotate_stop(struct pmu *pmu)
{
struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
WARN_ON(!irqs_disabled());
list_del_init(&cpuctx->rotation_list);
}
static void __perf_event_exit_context(void *__info)
{
struct remove_event re = { .detach_group = false };
struct perf_event_context *ctx = __info;
perf_pmu_rotate_stop(ctx->pmu);
rcu_read_lock();
list_for_each_entry_rcu(re.event, &ctx->event_list, event_entry)
__perf_remove_from_context(&re);
rcu_read_unlock();
}
static void perf_event_exit_cpu_context(int cpu)
{
struct perf_event_context *ctx;
struct pmu *pmu;
int idx;
idx = srcu_read_lock(&pmus_srcu);
list_for_each_entry_rcu(pmu, &pmus, entry) {
/*
* If keeping events across hotplugging is supported, do not
* remove the event list, but keep it alive across CPU hotplug.
* The context is exited via an fd close path when userspace
* is done and the target CPU is online.
*/
if (!pmu->events_across_hotplug) {
ctx = &per_cpu_ptr(pmu->pmu_cpu_context, cpu)->ctx;
mutex_lock(&ctx->mutex);
smp_call_function_single(cpu, __perf_event_exit_context,
ctx, 1);
mutex_unlock(&ctx->mutex);
}
}
srcu_read_unlock(&pmus_srcu, idx);
}
static void perf_event_exit_cpu(int cpu)
{
struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
perf_event_exit_cpu_context(cpu);
mutex_lock(&swhash->hlist_mutex);
swhash->online = false;
swevent_hlist_release(swhash);
mutex_unlock(&swhash->hlist_mutex);
}
#else
static inline void perf_event_exit_cpu(int cpu) { }
#endif
static int
perf_reboot(struct notifier_block *notifier, unsigned long val, void *v)
{
int cpu;
for_each_online_cpu(cpu)
perf_event_exit_cpu(cpu);
return NOTIFY_OK;
}
/*
* Run the perf reboot notifier at the very last possible moment so that
* the generic watchdog code runs as long as possible.
*/
static struct notifier_block perf_reboot_notifier = {
.notifier_call = perf_reboot,
.priority = INT_MIN,
};
static int __cpuinit
perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
{
unsigned int cpu = (long)hcpu;
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_UP_PREPARE:
case CPU_DOWN_FAILED:
perf_event_init_cpu(cpu);
break;
case CPU_UP_CANCELED:
case CPU_DOWN_PREPARE:
perf_event_exit_cpu(cpu);
break;
default:
break;
}
return NOTIFY_OK;
}
void __init perf_event_init(void)
{
int ret;
idr_init(&pmu_idr);
perf_event_init_all_cpus();
init_srcu_struct(&pmus_srcu);
perf_pmu_register(&perf_swevent, "software", PERF_TYPE_SOFTWARE);
perf_pmu_register(&perf_cpu_clock, NULL, -1);
perf_pmu_register(&perf_task_clock, NULL, -1);
perf_tp_register();
perf_cpu_notifier(perf_cpu_notify);
register_reboot_notifier(&perf_reboot_notifier);
ret = init_hw_breakpoint();
WARN(ret, "hw_breakpoint initialization failed with: %d", ret);
/* do not patch jump label more than once per second */
jump_label_rate_limit(&perf_sched_events, HZ);
/*
* Build time assertion that we keep the data_head at the intended
* location. IOW, validation we got the __reserved[] size right.
*/
BUILD_BUG_ON((offsetof(struct perf_event_mmap_page, data_head))
!= 1024);
}
static int __init perf_event_sysfs_init(void)
{
struct pmu *pmu;
int ret;
mutex_lock(&pmus_lock);
ret = bus_register(&pmu_bus);
if (ret)
goto unlock;
list_for_each_entry(pmu, &pmus, entry) {
if (!pmu->name || pmu->type < 0)
continue;
ret = pmu_dev_alloc(pmu);
WARN(ret, "Failed to register pmu: %s, reason %d\n", pmu->name, ret);
}
pmu_bus_running = 1;
ret = 0;
unlock:
mutex_unlock(&pmus_lock);
return ret;
}
device_initcall(perf_event_sysfs_init);
#ifdef CONFIG_CGROUP_PERF
static struct cgroup_subsys_state *perf_cgroup_create(struct cgroup *cont)
{
struct perf_cgroup *jc;
jc = kzalloc(sizeof(*jc), GFP_KERNEL);
if (!jc)
return ERR_PTR(-ENOMEM);
jc->info = alloc_percpu(struct perf_cgroup_info);
if (!jc->info) {
kfree(jc);
return ERR_PTR(-ENOMEM);
}
return &jc->css;
}
static void perf_cgroup_destroy(struct cgroup *cont)
{
struct perf_cgroup *jc;
jc = container_of(cgroup_subsys_state(cont, perf_subsys_id),
struct perf_cgroup, css);
free_percpu(jc->info);
kfree(jc);
}
static int __perf_cgroup_move(void *info)
{
struct task_struct *task = info;
perf_cgroup_switch(task, PERF_CGROUP_SWOUT | PERF_CGROUP_SWIN);
return 0;
}
static void perf_cgroup_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
{
struct task_struct *task;
cgroup_taskset_for_each(task, cgrp, tset)
task_function_call(task, __perf_cgroup_move, task);
}
static void perf_cgroup_exit(struct cgroup *cgrp, struct cgroup *old_cgrp,
struct task_struct *task)
{
/*
* cgroup_exit() is called in the copy_process() failure path.
* Ignore this case since the task hasn't ran yet, this avoids
* trying to poke a half freed task state from generic code.
*/
if (!(task->flags & PF_EXITING))
return;
task_function_call(task, __perf_cgroup_move, task);
}
struct cgroup_subsys perf_subsys = {
.name = "perf_event",
.subsys_id = perf_subsys_id,
.create = perf_cgroup_create,
.destroy = perf_cgroup_destroy,
.exit = perf_cgroup_exit,
.attach = perf_cgroup_attach,
};
#endif /* CONFIG_CGROUP_PERF */
| lasithwaruna/android_kernel_motorola_otus | kernel/events/core.c | C | gpl-2.0 | 176,770 | [
30522,
1013,
1008,
1008,
2836,
2824,
4563,
3642,
1024,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
2726,
1043,
23057,
2595,
3678,
1026,
1056,
23296,
2595,
1030,
11409,
4904,
4948,
7646,
1012,
2139,
1028,
1008,
9385,
1006,
1039,
1007,
2263,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Automatically generated file. Please do not edit.
* @author Highcharts Config Generator by Karasiq
* @see [[http://api.highcharts.com/highmaps]]
*/
package com.highmaps.config
import scalajs.js, js.`|`
import com.highcharts.CleanJsObject
import com.highcharts.HighchartsUtils._
/**
* @note JavaScript name: <code>series<stochastic>-states-select-marker-states-select</code>
*/
@js.annotation.ScalaJSDefined
class SeriesStochasticStatesSelectMarkerStatesSelect extends com.highcharts.HighchartsGenericObject {
/**
* <p>The fill color of the point marker.</p>
* @example <a href="https://jsfiddle.net/gh/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-marker-states-select-fillcolor/">Solid red discs for selected points</a>
* @since 6.0.0
*/
val fillColor: js.UndefOr[String | js.Object] = js.undefined
/**
* <p>The color of the point marker's outline. When <code>undefined</code>,
* the series' or point's color is used.</p>
* @example <a href="https://jsfiddle.net/gh/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-marker-states-select-linecolor/">Red line color for selected points</a>
* @since 6.0.0
*/
val lineColor: js.UndefOr[String | js.Object] = js.undefined
/**
* <p>The width of the point marker's outline.</p>
* @example <a href="https://jsfiddle.net/gh/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-marker-states-select-linewidth/">3px line width for selected points</a>
* @since 6.0.0
*/
val lineWidth: js.UndefOr[Double] = js.undefined
/**
* <p>The radius of the point marker. In hover state, it defaults
* to the normal state's radius + 2.</p>
* @example <a href="https://jsfiddle.net/gh/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-marker-states-select-radius/">10px radius for selected points</a>
* @since 6.0.0
*/
val radius: js.UndefOr[Double] = js.undefined
/**
* <p>Enable or disable visible feedback for selection.</p>
* @example <a href="https://jsfiddle.net/gh/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-marker-states-select-enabled/">Disabled select state</a>
* @since 6.0.0
*/
val enabled: js.UndefOr[Boolean] = js.undefined
}
object SeriesStochasticStatesSelectMarkerStatesSelect {
/**
* @param fillColor <p>The fill color of the point marker.</p>
* @param lineColor <p>The color of the point marker's outline. When <code>undefined</code>,. the series' or point's color is used.</p>
* @param lineWidth <p>The width of the point marker's outline.</p>
* @param radius <p>The radius of the point marker. In hover state, it defaults. to the normal state's radius + 2.</p>
* @param enabled <p>Enable or disable visible feedback for selection.</p>
*/
def apply(fillColor: js.UndefOr[String | js.Object] = js.undefined, lineColor: js.UndefOr[String | js.Object] = js.undefined, lineWidth: js.UndefOr[Double] = js.undefined, radius: js.UndefOr[Double] = js.undefined, enabled: js.UndefOr[Boolean] = js.undefined): SeriesStochasticStatesSelectMarkerStatesSelect = {
val fillColorOuter: js.UndefOr[String | js.Object] = fillColor
val lineColorOuter: js.UndefOr[String | js.Object] = lineColor
val lineWidthOuter: js.UndefOr[Double] = lineWidth
val radiusOuter: js.UndefOr[Double] = radius
val enabledOuter: js.UndefOr[Boolean] = enabled
com.highcharts.HighchartsGenericObject.toCleanObject(new SeriesStochasticStatesSelectMarkerStatesSelect {
override val fillColor: js.UndefOr[String | js.Object] = fillColorOuter
override val lineColor: js.UndefOr[String | js.Object] = lineColorOuter
override val lineWidth: js.UndefOr[Double] = lineWidthOuter
override val radius: js.UndefOr[Double] = radiusOuter
override val enabled: js.UndefOr[Boolean] = enabledOuter
})
}
}
| Karasiq/scalajs-highcharts | src/main/scala/com/highmaps/config/SeriesStochasticStatesSelectMarkerStatesSelect.scala | Scala | mit | 4,046 | [
30522,
1013,
1008,
1008,
1008,
8073,
7013,
5371,
1012,
3531,
2079,
2025,
10086,
1012,
1008,
1030,
3166,
2152,
7507,
21217,
9530,
8873,
2290,
13103,
2011,
13173,
5332,
4160,
1008,
1030,
2156,
1031,
1031,
8299,
1024,
1013,
1013,
17928,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from sentry.utils.query import RangeQuerySetWrapperWithProgressBar
DEFAULT_SAVED_SEARCHES = [
{
'name': 'Unresolved Issues',
'query': 'is:unresolved',
},
{
'name': 'Needs Triage',
'query': 'is:unresolved is:unassigned'
},
{
'name': 'Assigned To Me',
'query': 'is:unresolved assigned:me'
},
{
'name': 'My Bookmarks',
'query': 'is:unresolved bookmarks:me'
},
{
'name': 'New Today',
'query': 'is:unresolved age:-24h'
},
]
class Migration(DataMigration):
# Flag to indicate if this migration is too risky
# to run online and needs to be coordinated for offline
is_dangerous = True
def forwards(self, orm):
db.commit_transaction()
try:
self._forwards(orm)
except Exception:
db.start_transaction()
raise
db.start_transaction()
def _forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
SavedSearch = orm['sentry.SavedSearch']
for search in RangeQuerySetWrapperWithProgressBar(
SavedSearch.objects.filter(is_global__isnull=True)
):
search.is_global = False
search.save()
default_searches = []
for search in DEFAULT_SAVED_SEARCHES:
default_searches.append(
SavedSearch(
name=search['name'],
query=search['query'],
is_global=True,
)
)
SavedSearch.objects.bulk_create(default_searches)
def backwards(self, orm):
"Write your backwards methods here."
# These will be the only rows with a null `project_id`, so we can safely
# make the column `not null` after deleting them.
SavedSearch = orm['sentry.SavedSearch']
SavedSearch.objects.filter(is_global=True).delete()
models = {
'sentry.activity': {
'Meta': {'object_name': 'Activity'},
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {'null': 'True'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True'})
},
'sentry.apiapplication': {
'Meta': {'object_name': 'ApiApplication'},
'allowed_origins': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'client_id': ('django.db.models.fields.CharField', [], {'default': "'82029f091b094a2ca18ef45d3958513c683b4643c65f4fbfacfbd1cdee187a51'", 'unique': 'True', 'max_length': '64'}),
'client_secret': ('sentry.db.models.fields.encrypted.EncryptedTextField', [], {'default': "'74093ba9478e4d41ae25dfcb036bd062ea58b43d394140a4989d6ec19f179b6a'"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'homepage_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'default': "'Proper Crawdad'", 'max_length': '64', 'blank': 'True'}),
'owner': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"}),
'privacy_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'}),
'redirect_uris': ('django.db.models.fields.TextField', [], {}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'terms_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'})
},
'sentry.apiauthorization': {
'Meta': {'unique_together': "(('user', 'application'),)", 'object_name': 'ApiAuthorization'},
'application': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ApiApplication']", 'null': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'scope_list': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'scopes': ('django.db.models.fields.BigIntegerField', [], {'default': 'None'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.apigrant': {
'Meta': {'object_name': 'ApiGrant'},
'application': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ApiApplication']"}),
'code': ('django.db.models.fields.CharField', [], {'default': "'12d42834d62142d4beaecf34588354dd'", 'max_length': '64', 'db_index': 'True'}),
'expires_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2019, 1, 18, 0, 0)', 'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'redirect_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'scope_list': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'scopes': ('django.db.models.fields.BigIntegerField', [], {'default': 'None'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.apikey': {
'Meta': {'object_name': 'ApiKey'},
'allowed_origins': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}),
'label': ('django.db.models.fields.CharField', [], {'default': "'Default'", 'max_length': '64', 'blank': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'key_set'", 'to': "orm['sentry.Organization']"}),
'scope_list': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'scopes': ('django.db.models.fields.BigIntegerField', [], {'default': 'None'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'})
},
'sentry.apitoken': {
'Meta': {'object_name': 'ApiToken'},
'application': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ApiApplication']", 'null': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'expires_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2019, 2, 17, 0, 0)', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'refresh_token': ('django.db.models.fields.CharField', [], {'default': "'85185474cfa44548852999d7e605898adf44aa5a15b04d0da501445694f622a7'", 'max_length': '64', 'unique': 'True', 'null': 'True'}),
'scope_list': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'scopes': ('django.db.models.fields.BigIntegerField', [], {'default': 'None'}),
'token': ('django.db.models.fields.CharField', [], {'default': "'7ff1f4918fe84acfa4172b59731cc504d6faae0cc6234271a6dcbc8c332cd65a'", 'unique': 'True', 'max_length': '64'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.assistantactivity': {
'Meta': {'unique_together': "(('user', 'guide_id'),)", 'object_name': 'AssistantActivity', 'db_table': "'sentry_assistant_activity'"},
'dismissed_ts': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'guide_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'useful': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"}),
'viewed_ts': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
},
'sentry.auditlogentry': {
'Meta': {'object_name': 'AuditLogEntry'},
'actor': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'blank': 'True', 'related_name': "'audit_actors'", 'null': 'True', 'to': "orm['sentry.User']"}),
'actor_key': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ApiKey']", 'null': 'True', 'blank': 'True'}),
'actor_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'event': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39', 'null': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'target_object': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'target_user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'blank': 'True', 'related_name': "'audit_targets'", 'null': 'True', 'to': "orm['sentry.User']"})
},
'sentry.authenticator': {
'Meta': {'unique_together': "(('user', 'type'),)", 'object_name': 'Authenticator', 'db_table': "'auth_authenticator'"},
'config': ('sentry.db.models.fields.encrypted.EncryptedPickledObjectField', [], {}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedAutoField', [], {'primary_key': 'True'}),
'last_used_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.authidentity': {
'Meta': {'unique_together': "(('auth_provider', 'ident'), ('auth_provider', 'user'))", 'object_name': 'AuthIdentity'},
'auth_provider': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.AuthProvider']"}),
'data': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'last_synced': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_verified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.authprovider': {
'Meta': {'object_name': 'AuthProvider'},
'config': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'default_global_access': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'default_role': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '50'}),
'default_teams': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sentry.Team']", 'symmetrical': 'False', 'blank': 'True'}),
'flags': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_sync': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']", 'unique': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'sync_time': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'})
},
'sentry.broadcast': {
'Meta': {'object_name': 'Broadcast'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_expires': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2019, 1, 25, 0, 0)', 'null': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
'link': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'message': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'upstream_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'})
},
'sentry.broadcastseen': {
'Meta': {'unique_together': "(('broadcast', 'user'),)", 'object_name': 'BroadcastSeen'},
'broadcast': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Broadcast']"}),
'date_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.commit': {
'Meta': {'unique_together': "(('repository_id', 'key'),)", 'object_name': 'Commit', 'index_together': "(('repository_id', 'date_added'),)"},
'author': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.CommitAuthor']", 'null': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'message': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'repository_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {})
},
'sentry.commitauthor': {
'Meta': {'unique_together': "(('organization_id', 'email'), ('organization_id', 'external_id'))", 'object_name': 'CommitAuthor'},
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '164', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'})
},
'sentry.commitfilechange': {
'Meta': {'unique_together': "(('commit', 'filename'),)", 'object_name': 'CommitFileChange'},
'commit': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Commit']"}),
'filename': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '1'})
},
'sentry.counter': {
'Meta': {'object_name': 'Counter', 'db_table': "'sentry_projectcounter'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'unique': 'True'}),
'value': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.dashboard': {
'Meta': {'unique_together': "(('organization', 'title'),)", 'object_name': 'Dashboard'},
'created_by': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'sentry.deletedorganization': {
'Meta': {'object_name': 'DeletedOrganization'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'actor_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'actor_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'date_deleted': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39', 'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'})
},
'sentry.deletedproject': {
'Meta': {'object_name': 'DeletedProject'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'actor_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'actor_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'date_deleted': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39', 'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'organization_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'organization_slug': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'platform': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'})
},
'sentry.deletedteam': {
'Meta': {'object_name': 'DeletedTeam'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'actor_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'actor_label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'date_deleted': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39', 'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'organization_name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'organization_slug': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'})
},
'sentry.deploy': {
'Meta': {'object_name': 'Deploy'},
'date_finished': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_started': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'environment_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'notified': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
},
'sentry.discoversavedquery': {
'Meta': {'object_name': 'DiscoverSavedQuery'},
'created_by': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'date_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'projects': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sentry.Project']", 'through': "orm['sentry.DiscoverSavedQueryProject']", 'symmetrical': 'False'}),
'query': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'})
},
'sentry.discoversavedqueryproject': {
'Meta': {'unique_together': "(('project', 'discover_saved_query'),)", 'object_name': 'DiscoverSavedQueryProject'},
'discover_saved_query': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.DiscoverSavedQuery']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.distribution': {
'Meta': {'unique_together': "(('release', 'name'),)", 'object_name': 'Distribution'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.email': {
'Meta': {'object_name': 'Email'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('sentry.db.models.fields.citext.CIEmailField', [], {'unique': 'True', 'max_length': '75'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'})
},
'sentry.environment': {
'Meta': {'unique_together': "(('organization_id', 'name'),)", 'object_name': 'Environment'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'projects': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sentry.Project']", 'through': "orm['sentry.EnvironmentProject']", 'symmetrical': 'False'})
},
'sentry.environmentproject': {
'Meta': {'unique_together': "(('project', 'environment'),)", 'object_name': 'EnvironmentProject'},
'environment': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Environment']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_hidden': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.event': {
'Meta': {'unique_together': "(('project_id', 'event_id'),)", 'object_name': 'Event', 'db_table': "'sentry_message'", 'index_together': "(('group_id', 'datetime'),)"},
'data': ('sentry.db.models.fields.node.NodeField', [], {'null': 'True', 'blank': 'True'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'db_column': "'message_id'"}),
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'message': ('django.db.models.fields.TextField', [], {}),
'platform': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True', 'blank': 'True'}),
'time_spent': ('sentry.db.models.fields.bounded.BoundedIntegerField', [], {'null': 'True'})
},
'sentry.eventattachment': {
'Meta': {'unique_together': "(('project_id', 'event_id', 'file'),)", 'object_name': 'EventAttachment', 'index_together': "(('project_id', 'date_added'),)"},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.eventmapping': {
'Meta': {'unique_together': "(('project_id', 'event_id'),)", 'object_name': 'EventMapping'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.eventprocessingissue': {
'Meta': {'unique_together': "(('raw_event', 'processing_issue'),)", 'object_name': 'EventProcessingIssue'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'processing_issue': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ProcessingIssue']"}),
'raw_event': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.RawEvent']"})
},
'sentry.eventtag': {
'Meta': {'unique_together': "(('event_id', 'key_id', 'value_id'),)", 'object_name': 'EventTag', 'index_together': "(('group_id', 'key_id', 'value_id'),)"},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'event_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'value_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.eventuser': {
'Meta': {'unique_together': "(('project_id', 'ident'), ('project_id', 'hash'))", 'object_name': 'EventUser', 'index_together': "(('project_id', 'email'), ('project_id', 'username'), ('project_id', 'ip_address'))"},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True'}),
'hash': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39', 'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'})
},
'sentry.externalissue': {
'Meta': {'unique_together': "(('organization_id', 'integration_id', 'key'),)", 'object_name': 'ExternalIssue'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'integration_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'metadata': ('sentry.db.models.fields.jsonfield.JSONField', [], {'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'title': ('django.db.models.fields.TextField', [], {'null': 'True'})
},
'sentry.featureadoption': {
'Meta': {'unique_together': "(('organization', 'feature_id'),)", 'object_name': 'FeatureAdoption'},
'applicable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_completed': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'feature_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"})
},
'sentry.file': {
'Meta': {'object_name': 'File'},
'blob': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'legacy_blob'", 'null': 'True', 'to': "orm['sentry.FileBlob']"}),
'blobs': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sentry.FileBlob']", 'through': "orm['sentry.FileBlobIndex']", 'symmetrical': 'False'}),
'checksum': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'db_index': 'True'}),
'headers': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.TextField', [], {}),
'path': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'size': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '64'})
},
'sentry.fileblob': {
'Meta': {'object_name': 'FileBlob'},
'checksum': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'path': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'size': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'})
},
'sentry.fileblobindex': {
'Meta': {'unique_together': "(('file', 'blob', 'offset'),)", 'object_name': 'FileBlobIndex'},
'blob': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.FileBlob']"}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'offset': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {})
},
'sentry.fileblobowner': {
'Meta': {'unique_together': "(('blob', 'organization'),)", 'object_name': 'FileBlobOwner'},
'blob': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.FileBlob']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"})
},
'sentry.group': {
'Meta': {'unique_together': "(('project', 'short_id'),)", 'object_name': 'Group', 'db_table': "'sentry_groupedmessage'", 'index_together': "(('project', 'first_release'),)"},
'active_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
'culprit': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'db_column': "'view'", 'blank': 'True'}),
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {'null': 'True', 'blank': 'True'}),
'first_release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']", 'null': 'True', 'on_delete': 'models.PROTECT'}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_public': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'level': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '40', 'db_index': 'True', 'blank': 'True'}),
'logger': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '64', 'db_index': 'True', 'blank': 'True'}),
'message': ('django.db.models.fields.TextField', [], {}),
'num_comments': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'null': 'True'}),
'platform': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'resolved_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
'score': ('sentry.db.models.fields.bounded.BoundedIntegerField', [], {'default': '0'}),
'short_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'time_spent_count': ('sentry.db.models.fields.bounded.BoundedIntegerField', [], {'default': '0'}),
'time_spent_total': ('sentry.db.models.fields.bounded.BoundedIntegerField', [], {'default': '0'}),
'times_seen': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '1', 'db_index': 'True'})
},
'sentry.groupassignee': {
'Meta': {'object_name': 'GroupAssignee', 'db_table': "'sentry_groupasignee'"},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'assignee_set'", 'unique': 'True', 'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'assignee_set'", 'to': "orm['sentry.Project']"}),
'team': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'sentry_assignee_set'", 'null': 'True', 'to': "orm['sentry.Team']"}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'sentry_assignee_set'", 'null': 'True', 'to': "orm['sentry.User']"})
},
'sentry.groupbookmark': {
'Meta': {'unique_together': "(('project', 'user', 'group'),)", 'object_name': 'GroupBookmark'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'bookmark_set'", 'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'bookmark_set'", 'to': "orm['sentry.Project']"}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'sentry_bookmark_set'", 'to': "orm['sentry.User']"})
},
'sentry.groupcommitresolution': {
'Meta': {'unique_together': "(('group_id', 'commit_id'),)", 'object_name': 'GroupCommitResolution'},
'commit_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'})
},
'sentry.groupemailthread': {
'Meta': {'unique_together': "(('email', 'group'), ('email', 'msgid'))", 'object_name': 'GroupEmailThread'},
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'groupemail_set'", 'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'msgid': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'groupemail_set'", 'to': "orm['sentry.Project']"})
},
'sentry.groupenvironment': {
'Meta': {'unique_together': "[('group_id', 'environment_id')]", 'object_name': 'GroupEnvironment', 'index_together': "[('environment_id', 'first_release_id')]"},
'environment_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'first_release_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'db_index': 'True'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'})
},
'sentry.grouphash': {
'Meta': {'unique_together': "(('project', 'hash'),)", 'object_name': 'GroupHash'},
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'null': 'True'}),
'group_tombstone_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'hash': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'state': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'})
},
'sentry.grouplink': {
'Meta': {'unique_together': "(('group_id', 'linked_type', 'linked_id'),)", 'object_name': 'GroupLink'},
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'linked_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'linked_type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '1'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'db_index': 'True'}),
'relationship': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '2'})
},
'sentry.groupmeta': {
'Meta': {'unique_together': "(('group', 'key'),)", 'object_name': 'GroupMeta'},
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'value': ('django.db.models.fields.TextField', [], {})
},
'sentry.groupredirect': {
'Meta': {'object_name': 'GroupRedirect'},
'group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'previous_group_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'unique': 'True'})
},
'sentry.grouprelease': {
'Meta': {'unique_together': "(('group_id', 'release_id', 'environment'),)", 'object_name': 'GroupRelease'},
'environment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '64'}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'release_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'})
},
'sentry.groupresolution': {
'Meta': {'object_name': 'GroupResolution'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'unique': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'})
},
'sentry.grouprulestatus': {
'Meta': {'unique_together': "(('rule', 'group'),)", 'object_name': 'GroupRuleStatus'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_active': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'rule': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Rule']"}),
'status': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'})
},
'sentry.groupseen': {
'Meta': {'unique_together': "(('user', 'group'),)", 'object_name': 'GroupSeen'},
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'db_index': 'False'})
},
'sentry.groupshare': {
'Meta': {'object_name': 'GroupShare'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'unique': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True'}),
'uuid': ('django.db.models.fields.CharField', [], {'default': "'971a077057f54734809e8dc332408db4'", 'unique': 'True', 'max_length': '32'})
},
'sentry.groupsnooze': {
'Meta': {'object_name': 'GroupSnooze'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'count': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'unique': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'state': ('sentry.db.models.fields.jsonfield.JSONField', [], {'null': 'True'}),
'until': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'user_count': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'user_window': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'window': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'})
},
'sentry.groupsubscription': {
'Meta': {'unique_together': "(('group', 'user'),)", 'object_name': 'GroupSubscription'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'subscription_set'", 'to': "orm['sentry.Group']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'subscription_set'", 'to': "orm['sentry.Project']"}),
'reason': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.grouptagkey': {
'Meta': {'unique_together': "(('project_id', 'group_id', 'key'),)", 'object_name': 'GroupTagKey'},
'group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'values_seen': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.grouptagvalue': {
'Meta': {'unique_together': "(('group_id', 'key', 'value'),)", 'object_name': 'GroupTagValue', 'db_table': "'sentry_messagefiltervalue'", 'index_together': "(('project_id', 'key', 'value', 'last_seen'),)"},
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'db_index': 'True'}),
'group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'db_index': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'times_seen': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'value': ('django.db.models.fields.CharField', [], {'max_length': '200'})
},
'sentry.grouptombstone': {
'Meta': {'object_name': 'GroupTombstone'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'culprit': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {'null': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'level': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '40', 'blank': 'True'}),
'message': ('django.db.models.fields.TextField', [], {}),
'previous_group_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'unique': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.identity': {
'Meta': {'unique_together': "(('idp', 'external_id'), ('idp', 'user'))", 'object_name': 'Identity'},
'data': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_verified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'idp': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.IdentityProvider']"}),
'scopes': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.identityprovider': {
'Meta': {'unique_together': "(('type', 'external_id'),)", 'object_name': 'IdentityProvider'},
'config': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '64'})
},
'sentry.integration': {
'Meta': {'unique_together': "(('provider', 'external_id'),)", 'object_name': 'Integration'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'metadata': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'organizations': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'integrations'", 'symmetrical': 'False', 'through': "orm['sentry.OrganizationIntegration']", 'to': "orm['sentry.Organization']"}),
'projects': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'integrations'", 'symmetrical': 'False', 'through': "orm['sentry.ProjectIntegration']", 'to': "orm['sentry.Project']"}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'null': 'True'})
},
'sentry.integrationexternalproject': {
'Meta': {'unique_together': "(('organization_integration_id', 'external_id'),)", 'object_name': 'IntegrationExternalProject'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'organization_integration_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'resolved_status': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'unresolved_status': ('django.db.models.fields.CharField', [], {'max_length': '64'})
},
'sentry.latestrelease': {
'Meta': {'unique_together': "(('repository_id', 'environment_id'),)", 'object_name': 'LatestRelease'},
'commit_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'deploy_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'environment_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'release_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {}),
'repository_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.lostpasswordhash': {
'Meta': {'object_name': 'LostPasswordHash'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'hash': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'unique': 'True'})
},
'sentry.option': {
'Meta': {'object_name': 'Option'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'value': ('sentry.db.models.fields.encrypted.EncryptedPickledObjectField', [], {})
},
'sentry.organization': {
'Meta': {'object_name': 'Organization'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'default_role': ('django.db.models.fields.CharField', [], {'default': "'member'", 'max_length': '32'}),
'flags': ('django.db.models.fields.BigIntegerField', [], {'default': '1'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'members': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'org_memberships'", 'symmetrical': 'False', 'through': "orm['sentry.OrganizationMember']", 'to': "orm['sentry.User']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.organizationaccessrequest': {
'Meta': {'unique_together': "(('team', 'member'),)", 'object_name': 'OrganizationAccessRequest'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'member': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.OrganizationMember']"}),
'team': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Team']"})
},
'sentry.organizationavatar': {
'Meta': {'object_name': 'OrganizationAvatar'},
'avatar_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'avatar'", 'unique': 'True', 'to': "orm['sentry.Organization']"})
},
'sentry.organizationintegration': {
'Meta': {'unique_together': "(('organization', 'integration'),)", 'object_name': 'OrganizationIntegration'},
'config': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'default_auth_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'integration': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Integration']"}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.organizationmember': {
'Meta': {'unique_together': "(('organization', 'user'), ('organization', 'email'))", 'object_name': 'OrganizationMember'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
'flags': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
'has_global_access': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'member_set'", 'to': "orm['sentry.Organization']"}),
'role': ('django.db.models.fields.CharField', [], {'default': "'member'", 'max_length': '32'}),
'teams': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sentry.Team']", 'symmetrical': 'False', 'through': "orm['sentry.OrganizationMemberTeam']", 'blank': 'True'}),
'token': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
'token_expires_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
'type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '50', 'blank': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'blank': 'True', 'related_name': "'sentry_orgmember_set'", 'null': 'True', 'to': "orm['sentry.User']"})
},
'sentry.organizationmemberteam': {
'Meta': {'unique_together': "(('team', 'organizationmember'),)", 'object_name': 'OrganizationMemberTeam', 'db_table': "'sentry_organizationmember_teams'"},
'id': ('sentry.db.models.fields.bounded.BoundedAutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'organizationmember': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.OrganizationMember']"}),
'team': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Team']"})
},
'sentry.organizationonboardingtask': {
'Meta': {'unique_together': "(('organization', 'task'),)", 'object_name': 'OrganizationOnboardingTask'},
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_completed': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True', 'blank': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'task': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True'})
},
'sentry.organizationoption': {
'Meta': {'unique_together': "(('organization', 'key'),)", 'object_name': 'OrganizationOption', 'db_table': "'sentry_organizationoptions'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'value': ('sentry.db.models.fields.encrypted.EncryptedPickledObjectField', [], {})
},
'sentry.processingissue': {
'Meta': {'unique_together': "(('project', 'checksum', 'type'),)", 'object_name': 'ProcessingIssue'},
'checksum': ('django.db.models.fields.CharField', [], {'max_length': '40', 'db_index': 'True'}),
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '30'})
},
'sentry.project': {
'Meta': {'unique_together': "(('organization', 'slug'),)", 'object_name': 'Project'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'first_event': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'flags': ('django.db.models.fields.BigIntegerField', [], {'default': '0', 'null': 'True'}),
'forced_color': ('django.db.models.fields.CharField', [], {'max_length': '6', 'null': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'platform': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'null': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'teams': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'teams'", 'symmetrical': 'False', 'through': "orm['sentry.ProjectTeam']", 'to': "orm['sentry.Team']"})
},
'sentry.projectavatar': {
'Meta': {'object_name': 'ProjectAvatar'},
'avatar_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'avatar'", 'unique': 'True', 'to': "orm['sentry.Project']"})
},
'sentry.projectbookmark': {
'Meta': {'unique_together': "(('project', 'user'),)", 'object_name': 'ProjectBookmark'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True', 'blank': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.projectcficachefile': {
'Meta': {'unique_together': "(('project', 'debug_file'),)", 'object_name': 'ProjectCfiCacheFile'},
'cache_file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'checksum': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'debug_file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ProjectDebugFile']", 'on_delete': 'models.DO_NOTHING', 'db_column': "'dsym_file_id'"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'version': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {})
},
'sentry.projectdebugfile': {
'Meta': {'object_name': 'ProjectDebugFile', 'db_table': "'sentry_projectdsymfile'", 'index_together': "(('project', 'debug_id'),)"},
'cpu_name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'null': 'True'}),
'debug_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'db_column': "'uuid'"}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'object_name': ('django.db.models.fields.TextField', [], {}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'})
},
'sentry.projectintegration': {
'Meta': {'unique_together': "(('project', 'integration'),)", 'object_name': 'ProjectIntegration'},
'config': ('sentry.db.models.fields.encrypted.EncryptedJsonField', [], {'default': '{}'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'integration': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Integration']"}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.projectkey': {
'Meta': {'object_name': 'ProjectKey'},
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'key_set'", 'to': "orm['sentry.Project']"}),
'public_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'unique': 'True', 'null': 'True'}),
'rate_limit_count': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'rate_limit_window': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'roles': ('django.db.models.fields.BigIntegerField', [], {'default': '1'}),
'secret_key': ('django.db.models.fields.CharField', [], {'max_length': '32', 'unique': 'True', 'null': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'})
},
'sentry.projectoption': {
'Meta': {'unique_together': "(('project', 'key'),)", 'object_name': 'ProjectOption', 'db_table': "'sentry_projectoptions'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'value': ('sentry.db.models.fields.encrypted.EncryptedPickledObjectField', [], {})
},
'sentry.projectownership': {
'Meta': {'object_name': 'ProjectOwnership'},
'date_created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'fallthrough': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'unique': 'True'}),
'raw': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'schema': ('sentry.db.models.fields.jsonfield.JSONField', [], {'null': 'True'})
},
'sentry.projectplatform': {
'Meta': {'unique_together': "(('project_id', 'platform'),)", 'object_name': 'ProjectPlatform'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'platform': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.projectredirect': {
'Meta': {'unique_together': "(('organization', 'redirect_slug'),)", 'object_name': 'ProjectRedirect'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'redirect_slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'})
},
'sentry.projectsymcachefile': {
'Meta': {'unique_together': "(('project', 'debug_file'),)", 'object_name': 'ProjectSymCacheFile'},
'cache_file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'checksum': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'debug_file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ProjectDebugFile']", 'on_delete': 'models.DO_NOTHING', 'db_column': "'dsym_file_id'"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'version': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {})
},
'sentry.projectteam': {
'Meta': {'unique_together': "(('project', 'team'),)", 'object_name': 'ProjectTeam'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'team': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Team']"})
},
'sentry.promptsactivity': {
'Meta': {'unique_together': "(('user', 'feature', 'organization_id', 'project_id'),)", 'object_name': 'PromptsActivity'},
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'feature': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.pullrequest': {
'Meta': {'unique_together': "(('repository_id', 'key'),)", 'object_name': 'PullRequest', 'db_table': "'sentry_pull_request'", 'index_together': "(('repository_id', 'date_added'), ('organization_id', 'merge_commit_sha'))"},
'author': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.CommitAuthor']", 'null': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'merge_commit_sha': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'message': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'repository_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'title': ('django.db.models.fields.TextField', [], {'null': 'True'})
},
'sentry.pullrequestcommit': {
'Meta': {'unique_together': "(('pull_request', 'commit'),)", 'object_name': 'PullRequestCommit', 'db_table': "'sentry_pullrequest_commit'"},
'commit': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Commit']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'pull_request': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.PullRequest']"})
},
'sentry.rawevent': {
'Meta': {'unique_together': "(('project', 'event_id'),)", 'object_name': 'RawEvent'},
'data': ('sentry.db.models.fields.node.NodeField', [], {'null': 'True', 'blank': 'True'}),
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.relay': {
'Meta': {'object_name': 'Relay'},
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_internal': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'public_key': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'relay_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'})
},
'sentry.release': {
'Meta': {'unique_together': "(('organization', 'version'),)", 'object_name': 'Release'},
'authors': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'commit_count': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'null': 'True'}),
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_released': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'date_started': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_commit_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'last_deploy_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'new_groups': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'owner': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'projects': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'releases'", 'symmetrical': 'False', 'through': "orm['sentry.ReleaseProject']", 'to': "orm['sentry.Project']"}),
'ref': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
'total_deploys': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'null': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'version': ('django.db.models.fields.CharField', [], {'max_length': '250'})
},
'sentry.releasecommit': {
'Meta': {'unique_together': "(('release', 'commit'), ('release', 'order'))", 'object_name': 'ReleaseCommit'},
'commit': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Commit']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'order': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.releaseenvironment': {
'Meta': {'unique_together': "(('organization', 'release', 'environment'),)", 'object_name': 'ReleaseEnvironment', 'db_table': "'sentry_environmentrelease'"},
'environment': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Environment']"}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.releasefile': {
'Meta': {'unique_together': "(('release', 'ident'),)", 'object_name': 'ReleaseFile', 'index_together': "(('release', 'name'),)"},
'dist': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Distribution']", 'null': 'True'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
'name': ('django.db.models.fields.TextField', [], {}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.releaseheadcommit': {
'Meta': {'unique_together': "(('repository_id', 'release'),)", 'object_name': 'ReleaseHeadCommit'},
'commit': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Commit']"}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"}),
'repository_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {})
},
'sentry.releaseproject': {
'Meta': {'unique_together': "(('project', 'release'),)", 'object_name': 'ReleaseProject', 'db_table': "'sentry_release_project'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'new_groups': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.releaseprojectenvironment': {
'Meta': {'unique_together': "(('project', 'release', 'environment'),)", 'object_name': 'ReleaseProjectEnvironment'},
'environment': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Environment']"}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'last_deploy_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'new_issues_count': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'release': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Release']"})
},
'sentry.repository': {
'Meta': {'unique_together': "(('organization_id', 'name'), ('organization_id', 'provider', 'external_id'))", 'object_name': 'Repository'},
'config': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'integration_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'organization_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'})
},
'sentry.reprocessingreport': {
'Meta': {'unique_together': "(('project', 'event_id'),)", 'object_name': 'ReprocessingReport'},
'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.rule': {
'Meta': {'object_name': 'Rule'},
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'environment_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'label': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'})
},
'sentry.savedsearch': {
'Meta': {'unique_together': "(('project', 'name'),)", 'object_name': 'SavedSearch'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_default': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_global': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'db_index': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'owner': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']", 'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'query': ('django.db.models.fields.TextField', [], {})
},
'sentry.savedsearchuserdefault': {
'Meta': {'unique_together': "(('project', 'user'),)", 'object_name': 'SavedSearchUserDefault', 'db_table': "'sentry_savedsearch_userdefault'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"}),
'savedsearch': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.SavedSearch']"}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.scheduleddeletion': {
'Meta': {'unique_together': "(('app_label', 'model_name', 'object_id'),)", 'object_name': 'ScheduledDeletion'},
'aborted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'actor_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_scheduled': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2019, 2, 17, 0, 0)'}),
'guid': ('django.db.models.fields.CharField', [], {'default': "'872e507076244783876be9f74901e6ae'", 'unique': 'True', 'max_length': '32'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'in_progress': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'model_name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'object_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {})
},
'sentry.scheduledjob': {
'Meta': {'object_name': 'ScheduledJob'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_scheduled': ('django.db.models.fields.DateTimeField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'payload': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'})
},
'sentry.sentryapp': {
'Meta': {'object_name': 'SentryApp'},
'application': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'sentry_app'", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['sentry.ApiApplication']"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_deleted': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'date_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'events': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_alertable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.TextField', [], {}),
'overview': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'owner': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'owned_sentry_apps'", 'to': "orm['sentry.Organization']"}),
'proxy_user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'sentry_app'", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['sentry.User']"}),
'redirect_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'}),
'scope_list': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'scopes': ('django.db.models.fields.BigIntegerField', [], {'default': 'None'}),
'slug': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'uuid': ('django.db.models.fields.CharField', [], {'default': "'3e3a2f6f-9136-4a26-8155-31829e66ecc4'", 'max_length': '64'}),
'webhook_url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
},
'sentry.sentryappavatar': {
'Meta': {'object_name': 'SentryAppAvatar'},
'avatar_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}),
'sentry_app': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'avatar'", 'unique': 'True', 'to': "orm['sentry.SentryApp']"})
},
'sentry.sentryappinstallation': {
'Meta': {'object_name': 'SentryAppInstallation'},
'api_grant': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'sentry_app_installation'", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['sentry.ApiGrant']"}),
'authorization': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'sentry_app_installation'", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['sentry.ApiAuthorization']"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'date_deleted': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'date_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'sentry_app_installations'", 'to': "orm['sentry.Organization']"}),
'sentry_app': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'installations'", 'to': "orm['sentry.SentryApp']"}),
'uuid': ('django.db.models.fields.CharField', [], {'default': "'227713f5-78ab-401b-a90d-80720b8ed80e'", 'max_length': '64'})
},
'sentry.servicehook': {
'Meta': {'object_name': 'ServiceHook'},
'actor_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'application': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.ApiApplication']", 'null': 'True'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'events': ('sentry.db.models.fields.array.ArrayField', [], {'of': (u'django.db.models.fields.TextField', [], {})}),
'guid': ('django.db.models.fields.CharField', [], {'max_length': '32', 'unique': 'True', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'secret': ('sentry.db.models.fields.encrypted.EncryptedTextField', [], {'default': "'f9f6f76988ea45d5b1029e2e604e95ace68b3d9e8c2743b9a7755a347e488f74'"}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0', 'db_index': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '512'}),
'version': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.tagkey': {
'Meta': {'unique_together': "(('project_id', 'key'),)", 'object_name': 'TagKey', 'db_table': "'sentry_filterkey'"},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'label': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'db_index': 'True'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'values_seen': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.tagvalue': {
'Meta': {'unique_together': "(('project_id', 'key', 'value'),)", 'object_name': 'TagValue', 'db_table': "'sentry_filtervalue'", 'index_together': "(('project_id', 'key', 'last_seen'),)"},
'data': ('sentry.db.models.fields.gzippeddict.GzippedDictField', [], {'null': 'True', 'blank': 'True'}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'db_index': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'db_index': 'True'}),
'project_id': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'null': 'True', 'db_index': 'True'}),
'times_seen': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'value': ('django.db.models.fields.CharField', [], {'max_length': '200'})
},
'sentry.team': {
'Meta': {'unique_together': "(('organization', 'slug'),)", 'object_name': 'Team'},
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']"}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'})
},
'sentry.teamavatar': {
'Meta': {'object_name': 'TeamAvatar'},
'avatar_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}),
'team': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'avatar'", 'unique': 'True', 'to': "orm['sentry.Team']"})
},
'sentry.user': {
'Meta': {'object_name': 'User', 'db_table': "'auth_user'"},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'flags': ('django.db.models.fields.BigIntegerField', [], {'default': '0', 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedAutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_managed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_password_expired': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_sentry_app': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_active': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True'}),
'last_password_change': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_column': "'first_name'", 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'session_nonce': ('django.db.models.fields.CharField', [], {'max_length': '12', 'null': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'})
},
'sentry.useravatar': {
'Meta': {'object_name': 'UserAvatar'},
'avatar_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'file': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.File']", 'unique': 'True', 'null': 'True', 'on_delete': 'models.SET_NULL'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ident': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32', 'db_index': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'avatar'", 'unique': 'True', 'to': "orm['sentry.User']"})
},
'sentry.useremail': {
'Meta': {'unique_together': "(('user', 'email'),)", 'object_name': 'UserEmail'},
'date_hash_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'is_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'related_name': "'emails'", 'to': "orm['sentry.User']"}),
'validation_hash': ('django.db.models.fields.CharField', [], {'default': "u'flfk8HwwLBodD7uLZ8Jy6PhjawDBeBKT'", 'max_length': '32'})
},
'sentry.userip': {
'Meta': {'unique_together': "(('user', 'ip_address'),)", 'object_name': 'UserIP'},
'country_code': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True'}),
'first_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}),
'last_seen': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'region_code': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.useroption': {
'Meta': {'unique_together': "(('user', 'project', 'key'), ('user', 'organization', 'key'))", 'object_name': 'UserOption'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'organization': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Organization']", 'null': 'True'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']", 'null': 'True'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"}),
'value': ('sentry.db.models.fields.encrypted.EncryptedPickledObjectField', [], {})
},
'sentry.userpermission': {
'Meta': {'unique_together': "(('user', 'permission'),)", 'object_name': 'UserPermission'},
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'permission': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'user': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.User']"})
},
'sentry.userreport': {
'Meta': {'unique_together': "(('project', 'event_id'),)", 'object_name': 'UserReport', 'index_together': "(('project', 'event_id'), ('project', 'date_added'))"},
'comments': ('django.db.models.fields.TextField', [], {}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'environment': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Environment']", 'null': 'True'}),
'event_id': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
'event_user_id': ('sentry.db.models.fields.bounded.BoundedBigIntegerField', [], {'null': 'True'}),
'group': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Group']", 'null': 'True'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'project': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Project']"})
},
'sentry.widget': {
'Meta': {'unique_together': "(('dashboard', 'order'), ('dashboard', 'title'))", 'object_name': 'Widget'},
'dashboard': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Dashboard']"}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'display_options': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'display_type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'order': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'sentry.widgetdatasource': {
'Meta': {'unique_together': "(('widget', 'name'), ('widget', 'order'))", 'object_name': 'WidgetDataSource'},
'data': ('sentry.db.models.fields.jsonfield.JSONField', [], {'default': '{}'}),
'date_added': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('sentry.db.models.fields.bounded.BoundedBigAutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'order': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'status': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {'default': '0'}),
'type': ('sentry.db.models.fields.bounded.BoundedPositiveIntegerField', [], {}),
'widget': ('sentry.db.models.fields.foreignkey.FlexibleForeignKey', [], {'to': "orm['sentry.Widget']"})
}
}
complete_apps = ['sentry']
symmetrical = True
| mvaled/sentry | src/sentry/south_migrations/0458_global_searches_data_migration.py | Python | bsd-3-clause | 120,420 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
2148,
1012,
21183,
12146,
12324,
3058,
7292,
1035,
21183,
12146,
2004,
3058,
7292,
2013,
2148,
1012,
16962,
12324,
16962,
2013,
2148,
1012,
1058,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// AppDelegate.h
// CusNavigationAnimation
//
// Created by JianRongCao on 15/7/24.
// Copyright (c) 2015年 JianRongCao. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "SNNavigationController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) SNNavigationController *rootNavigationController;
@end
| HarrisLee/CusNavigationController | CusNavigationAnimation/CusNavigationAnimation/AppDelegate.h | C | mit | 412 | [
30522,
1013,
1013,
1013,
1013,
10439,
9247,
29107,
2618,
1012,
1044,
1013,
1013,
12731,
2015,
2532,
5737,
12540,
7088,
28649,
1013,
1013,
1013,
1013,
2580,
2011,
29214,
17583,
20808,
2006,
2321,
1013,
1021,
1013,
2484,
1012,
1013,
1013,
938... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* @file NWayBlender.cpp
* @brief N-Way shape blend deformer plugin for Maya
* @section LICENSE The MIT License
* @section requirements: Eigen 3: http://eigen.tuxfamily.org/
* @section Autodesk Maya: http://www.autodesk.com/products/autodesk-maya/overview
* @section (included) AffineLib: https://github.com/shizuo-kaji/AffineLib
* @version 0.20
* @date 18/Jul/2015
* @author Shizuo KAJI
*/
#include "StdAfx.h"
#include "nwayBlender.h"
#include <set>
#include <queue>
#include <ctime>
using namespace Eigen;
using namespace AffineLib;
using namespace Tetrise;
MTypeId nwayDeformerNode::id( 0x00000300 );
MString nwayDeformerNode::nodeName( "nwayBlender" );
MObject nwayDeformerNode::aBlendMode;
MObject nwayDeformerNode::aTetMode;
MObject nwayDeformerNode::aBlendMesh;
MObject nwayDeformerNode::aWeight;
MObject nwayDeformerNode::aIteration;
MObject nwayDeformerNode::aRotationConsistency;
MObject nwayDeformerNode::aVisualiseEnergy;
MObject nwayDeformerNode::aVisualisationMultiplier;
MObject nwayDeformerNode::aEnergy;
MObject nwayDeformerNode::aInitRotation;
MObject nwayDeformerNode::aAreaWeighted;
MObject nwayDeformerNode::aARAP;
// blend matrices
template<typename T>
void blendMatList(const std::vector< std::vector<T> >& A, const std::vector<double>& weight, std::vector<T>& X){
int numMesh= (int)A.size();
if(numMesh == 0) return;
int numTet= (int)A[0].size();
for(int i=0;i<numTet;i++){
X[i].setZero();
for(int j=0;j<numMesh;j++){
X[i] += weight[j]*A[j][i];
}
}
}
template<typename T>
void blendMatLinList(const std::vector< std::vector<T> >& A, const std::vector<double>& weight, std::vector<T>& X){
int numMesh= (int)A.size();
if(numMesh == 0) return;
int numTet= (int)A[0].size();
for(int i=0;i<numTet;i++){
double sum = 0.0;
X[i].setZero();
for(int j=0;j<numMesh;j++){
X[i] += weight[j] * A[j][i];
sum += weight[j];
}
X[i] += (1.0-sum) * T::Identity();
}
}
// blend quaternion linearly
void blendQuatList(const std::vector< std::vector<Vector4d> >& A, const std::vector<double>& weight,
std::vector<Vector4d>& X){
int numMesh= (int)A.size();
if(numMesh == 0) return;
int numTet= (int)A[0].size();
Vector4d I(0,0,0,1);
for(int i=0;i<numTet;i++){
double sum = 0.0;
X[i].setZero();
for(int j=0;j<numMesh;j++){
X[i] += weight[j] * A[j][i];
sum += weight[j];
}
X[i] += (1.0-sum) * I;
X[i].normalized();
}
}
//
void* nwayDeformerNode::creator() { return new nwayDeformerNode; }
MStatus nwayDeformerNode::deform( MDataBlock& data, MItGeometry& itGeo, const MMatrix &localToWorldMatrix, unsigned int mIndex )
{
// clock_t clock_start=clock();
MObject thisNode = thisMObject();
MStatus status;
MThreadUtils::syncNumOpenMPThreads(); // for OpenMP
MArrayDataHandle hBlendMesh = data.inputArrayValue(aBlendMesh);
short numIter = data.inputValue( aIteration ).asShort();
short nblendMode = data.inputValue( aBlendMode ).asShort();
short tetMode = data.inputValue( aTetMode ).asShort();
double visualisationMultiplier = data.inputValue(aVisualisationMultiplier).asDouble();
bool visualiseEnergy = data.inputValue( aVisualiseEnergy ).asBool();
bool nrotationCosistency = data.inputValue( aRotationConsistency ).asBool();
MPointArray Mpts;
itGeo.allPositions(Mpts);
int nnumMesh = hBlendMesh.elementCount();
int numPts = Mpts.length();
// initialisation
if(!data.isClean(aARAP)){
// clock_t clock_start=clock();
numMesh = 0;
// point list
pts.resize(numPts);
for(int i=0;i<numPts;i++){
pts[i] << Mpts[i].x, Mpts[i].y, Mpts[i].z;
}
// make tetrahedral structure
getMeshData(data, input, inputGeom, mIndex, tetMode, pts, mesh.tetList, faceList, edgeList, vertexList, mesh.tetMatrix, mesh.tetWeight);
mesh.dim = removeDegenerate(tetMode, numPts, mesh.tetList, faceList, edgeList, vertexList, mesh.tetMatrix);
makeTetMatrix(tetMode, pts, mesh.tetList, faceList, edgeList, vertexList, mesh.tetMatrix, mesh.tetWeight);
makeAdjacencyList(tetMode, mesh.tetList, edgeList, vertexList, adjacencyList);
mesh.numTet = (int)mesh.tetList.size()/4;
mesh.computeTetMatrixInverse();
// prepare ARAP solver
if(!data.inputValue( aAreaWeighted ).asBool()){
mesh.tetWeight.clear();
mesh.tetWeight.resize(mesh.numTet,1.0);
}
mesh.constraintWeight.resize(1);
mesh.constraintWeight[0] = std::make_pair(0,1.0);
mesh.constraintVal.resize(1,3);
mesh.constraintVal(0,0) = pts[0][0];
mesh.constraintVal(0,1) = pts[0][1];
mesh.constraintVal(0,2) = pts[0][2];
isError = mesh.ARAPprecompute();
status = data.setClean(aARAP);
// MString es="Init timing: ";
// double timing=(double)(clock()- clock_start)/CLOCKS_PER_SEC;
// es += timing;
// MGlobal::displayInfo(es);
}
if(isError>0) return MS::kFailure;
// if blend mesh is added, compute log for each tet
logR.resize(nnumMesh); logS.resize(nnumMesh);
R.resize(nnumMesh); S.resize(nnumMesh);
GL.resize(nnumMesh); logGL.resize(nnumMesh);
quat.resize(nnumMesh);
L.resize(nnumMesh);
// for recomputation of parametrisation
if(numMesh>nnumMesh || nblendMode != blendMode || nrotationCosistency != rotationCosistency){
numMesh =0;
blendMode = nblendMode;
rotationCosistency = nrotationCosistency;
}
for(int j=numMesh; j<nnumMesh; j++){
hBlendMesh.jumpToElement(j);
MFnMesh blendMesh(hBlendMesh.inputValue().asMesh());
MPointArray Mbpts;
blendMesh.getPoints( Mbpts );
if(numPts != Mbpts.length()){
MGlobal::displayInfo("incompatible mesh");
return MS::kFailure;
}
std::vector<Vector3d> bpts(numPts);
for(int i=0;i<numPts;i++){
bpts[i] << Mbpts[i].x, Mbpts[i].y, Mbpts[i].z;
}
makeTetMatrix(tetMode, bpts, mesh.tetList, faceList, edgeList, vertexList, Q, dummy_weight);
logR[j].resize(mesh.numTet); logS[j].resize(mesh.numTet);
R[j].resize(mesh.numTet); S[j].resize(mesh.numTet);
GL[j].resize(mesh.numTet); L[j].resize(mesh.numTet);
for(int i=0;i<mesh.numTet;i++) {
Matrix4d aff=mesh.tetMatrixInverse[i]*Q[i];
GL[j][i]=aff.block(0,0,3,3);
L[j][i]=transPart(aff);
parametriseGL(GL[j][i], logS[j][i] ,R[j][i]);
}
if( blendMode == BM_LOG3){
logGL[j].resize(mesh.numTet);
for(int i=0;i<mesh.numTet;i++)
logGL[j][i]=GL[j][i].log();
}else if( blendMode == BM_SQL){
quat[j].resize(mesh.numTet);
for(int i=0;i<mesh.numTet;i++){
S[j][i]=expSym(logS[j][i]);
Quaternion<double> q(R[j][i].transpose());
quat[j][i] << q.x(), q.y(), q.z(), q.w();
}
}else if( blendMode == BM_SlRL){
for(int i=0;i<mesh.numTet;i++){
S[j][i]=expSym(logS[j][i]);
}
}
// traverse tetrahedra to compute continuous log of rotation
if(rotationCosistency){
std::set<int> remain;
std::queue<int> later;
// load initial rotation from the attr
Matrix3d initR;
double angle = data.inputValue(aInitRotation).asDouble();
initR << 0,M_PI * angle/180.0,0, -M_PI * angle/180.0,0,0, 0,0,0;
std::vector<Matrix3d> prevSO(mesh.numTet, initR);
// create the adjacency graph to traverse
for(int i=0;i<mesh.numTet;i++){
remain.insert(remain.end(),i);
}
while(!remain.empty()){
int next;
if( !later.empty()){
next = later.front();
later.pop();
remain.erase(next);
}else{
next = *remain.begin();
remain.erase(remain.begin());
}
logR[j][next]=logSOc(R[j][next],prevSO[next]);
for(int k=0;k<adjacencyList[next].size();k++){
int f=adjacencyList[next][k];
if(remain.erase(f)>0){
prevSO[f]=logR[j][next];
later.push(f);
}
}
}
}else{
for(int i=0;i<mesh.numTet;i++)
logR[j][i] = logSO(R[j][i]);
}
}
numMesh=nnumMesh;
if(numMesh == 0) return MS::kSuccess;
// load weights
std::vector<double> weight(numMesh);
MArrayDataHandle hWeight = data.inputArrayValue(aWeight);
if(hWeight.elementCount() != numMesh) { return MS::kSuccess; }
for(int i=0;i<numMesh;i++){
hWeight.jumpToArrayElement(i);
weight[i]=hWeight.inputValue().asDouble();
}
// compute ideal affine
std::vector<Vector3d> new_pts(numPts);
std::vector<Matrix4d> A(mesh.numTet);
std::vector<Matrix3d> AR(mesh.numTet),AS(mesh.numTet);
std::vector<Vector3d> AL(mesh.numTet);
blendMatList(L, weight, AL);
if(blendMode==BM_SRL){
blendMatList(logR, weight, AR);
blendMatList(logS, weight, AS);
#pragma omp parallel for
for(int i=0;i<mesh.numTet;i++){
AR[i] = expSO(AR[i]);
AS[i] = expSym(AS[i]);
}
}else if(blendMode == BM_LOG3){ // log
blendMatList(logGL, weight, AR);
#pragma omp parallel for
for(int i=0;i<mesh.numTet;i++){
AR[i] = AR[i].exp();
AS[i] = Matrix3d::Identity();
}
}else if(blendMode == BM_SQL){ // quaternion
std::vector<Vector4d> Aq(mesh.numTet);
blendMatLinList(S, weight, AS);
blendQuatList(quat, weight, Aq);
#pragma omp parallel for
for(int i=0;i<mesh.numTet;i++){
Quaternion<double> Q(Aq[i]);
AR[i] = Q.matrix().transpose();
}
}else if(blendMode == BM_SlRL){ // expSO+linear Sym
blendMatList(logR, weight, AR);
blendMatLinList(S, weight, AS);
#pragma omp parallel for
for(int i=0;i<mesh.numTet;i++){
AR[i] = expSO(AR[i]);
}
}else if(blendMode == BM_AFF){ // linear
blendMatLinList(GL, weight, AR);
for(int i=0;i<mesh.numTet;i++){
AS[i] = Matrix3d::Identity();
}
}else{
return MS::kFailure;
}
std::vector<double> tetEnergy(mesh.numTet);
// iterate to determine vertices position
for(int k=0;k<numIter;k++){
for(int i=0;i<mesh.numTet;i++){
A[i]=pad(AS[i]*AR[i],AL[i]);
}
// solve ARAP
mesh.ARAPSolve(A);
// set new vertices position
for(int i=0;i<numPts;i++){
new_pts[i][0]=mesh.Sol(i,0);
new_pts[i][1]=mesh.Sol(i,1);
new_pts[i][2]=mesh.Sol(i,2);
}
// if iteration continues
if(k+1<numIter || visualiseEnergy){
makeTetMatrix(tetMode, new_pts, mesh.tetList, faceList, edgeList, vertexList, Q, dummy_weight);
Matrix3d S,R;
#pragma omp parallel for
for(int i=0;i<mesh.numTet;i++) {
polarHigham((mesh.tetMatrixInverse[i]*Q[i]).block(0,0,3,3), S, AR[i]);
tetEnergy[i] = (S-AS[i]).squaredNorm();
}
}
}
// set new vertex position
for(int i=0;i<numPts;i++){
Mpts[i].x=mesh.Sol(i,0);
Mpts[i].y=mesh.Sol(i,1);
Mpts[i].z=mesh.Sol(i,2);
}
itGeo.setAllPositions(Mpts);
// set vertex color according to ARAP energy
if(visualiseEnergy){
std::vector<double> ptsEnergy;
makePtsWeightList(tetMode, numPts, mesh.tetList, faceList, edgeList, vertexList, tetEnergy, ptsEnergy);
//double max_energy = *std::max_element(ptsEnergy.begin(), ptsEnergy.end());
outputAttr(data, aEnergy, ptsEnergy);
for(int i=0;i<numPts;i++){
ptsEnergy[i] *= visualisationMultiplier; // or /= max_energy
}
visualise(data, outputGeom, ptsEnergy);
}
// MString es="Runtime timing: ";
// double timing=(double)(clock()- clock_start)/CLOCKS_PER_SEC;
// es += timing;
// MGlobal::displayInfo(es);
return MS::kSuccess;
}
// plugin (un)initialiser
MStatus nwayDeformerNode::initialize()
{
MFnTypedAttribute tAttr;
MFnNumericAttribute nAttr;
MFnEnumAttribute eAttr;
MFnMatrixAttribute mAttr;
// this attr will be dirtied when ARAP recomputation is needed
aARAP = nAttr.create( "arap", "arap", MFnNumericData::kBoolean, true );
nAttr.setStorable(false);
nAttr.setKeyable(false);
nAttr.setHidden(true);
addAttribute( aARAP );
aBlendMesh = tAttr.create("blendMesh", "mesh", MFnData::kMesh);
tAttr.setArray(true);
tAttr.setUsesArrayDataBuilder(true);
addAttribute(aBlendMesh);
attributeAffects( aBlendMesh, outputGeom );
aWeight = nAttr.create("blendWeight", "bw", MFnNumericData::kDouble, 0.0);
nAttr.setArray(true);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setUsesArrayDataBuilder(true);
addAttribute(aWeight);
attributeAffects( aWeight, outputGeom );
aRotationConsistency = nAttr.create( "rotationConsistency", "rc", MFnNumericData::kBoolean, false );
nAttr.setStorable(true);
addAttribute( aRotationConsistency );
attributeAffects( aRotationConsistency, outputGeom );
aInitRotation = nAttr.create("initRotation", "ir", MFnNumericData::kDouble);
addAttribute(aInitRotation);
attributeAffects( aInitRotation, outputGeom );
aVisualiseEnergy = nAttr.create( "visualiseEnergy", "ve", MFnNumericData::kBoolean, false );
nAttr.setStorable(true);
addAttribute( aVisualiseEnergy );
attributeAffects( aVisualiseEnergy, outputGeom );
aAreaWeighted = nAttr.create( "areaWeighted", "aw", MFnNumericData::kBoolean, false );
nAttr.setStorable(true);
addAttribute( aAreaWeighted );
attributeAffects( aAreaWeighted, outputGeom );
attributeAffects( aAreaWeighted, aARAP );
aVisualisationMultiplier = nAttr.create("visualisationMultiplier", "vmp", MFnNumericData::kDouble, 1.0);
nAttr.setStorable(true);
addAttribute( aVisualisationMultiplier );
attributeAffects( aVisualisationMultiplier, outputGeom );
aBlendMode = eAttr.create( "blendMode", "bm", BM_SRL );
eAttr.addField( "expSO+expSym", BM_SRL );
eAttr.addField( "logmatrix3", BM_LOG3 );
eAttr.addField( "quat+linear", BM_SQL );
eAttr.addField( "expSO+linear", BM_SlRL );
eAttr.addField( "linear", BM_AFF );
eAttr.addField( "off", BM_OFF );
addAttribute( aBlendMode );
attributeAffects( aBlendMode, outputGeom );
aTetMode = eAttr.create( "tetMode", "tm", TM_FACE );
eAttr.addField( "face", TM_FACE );
eAttr.addField( "edge", TM_EDGE );
eAttr.addField( "vertex", TM_VERTEX );
eAttr.addField( "vface", TM_VFACE );
addAttribute( aTetMode );
attributeAffects( aTetMode, outputGeom );
attributeAffects( aTetMode, aARAP );
aIteration = nAttr.create("iteration", "it", MFnNumericData::kShort, 1);
addAttribute(aIteration);
attributeAffects(aIteration, outputGeom);
// this shouldn't affect outputGeom
aEnergy = nAttr.create("energy", "energy", MFnNumericData::kDouble, 0.0);
nAttr.setArray(true);
nAttr.setKeyable(true);
nAttr.setStorable(true);
nAttr.setUsesArrayDataBuilder(true);
addAttribute(aEnergy);
// Make the deformer weights paintable
MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer nwayBlender weights;" );
return MS::kSuccess;
}
// this deformer also changes colours
void nwayDeformerNode::postConstructor(){
setDeformationDetails(kDeformsColors);
}
MStatus initializePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj, "Shizuo KAJI", "0.1", "Any");
status = plugin.registerNode( nwayDeformerNode::nodeName, nwayDeformerNode::id, nwayDeformerNode::creator, nwayDeformerNode::initialize, MPxNode::kDeformerNode );
CHECK_MSTATUS_AND_RETURN_IT( status );
return status;
}
MStatus uninitializePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj );
status = plugin.deregisterNode( nwayDeformerNode::id );
CHECK_MSTATUS_AND_RETURN_IT( status );
return status;
}
| shizuo-kaji/NWayBlenderMaya | nwayBlender/nwayBlender.cpp | C++ | mit | 17,135 | [
30522,
1013,
1008,
1008,
1008,
1030,
5371,
15737,
2100,
3468,
11563,
1012,
18133,
2361,
1008,
1030,
4766,
1050,
1011,
2126,
4338,
12586,
13366,
2953,
5017,
13354,
2378,
2005,
9815,
1008,
1030,
2930,
6105,
1996,
10210,
6105,
1008,
1030,
2930... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env node
let layouts = [
`# French
&é"'(-è_çà)=
azertyuiop^$*
qsdfghjklmù
wxcvbn,;:!
`,
`# German (German (IBM) is the same)
1234567890ß
qwertzuiopü+#
asdfghjklöä
yxcvbnm,.-
`,
`# Spanish
1234567890'¡
qwertyuiop+ç
asdfghjklñ
zxcvbnm,.-
## ESV
1234567890-
qwertyuiop÷
asdfghjklñç
zxcvbnm,.=
`,
`# Português
1234567890'«
qwertyuiop+´~
asdfghjklçº
zxcvbnm,.-
## PTB
1234567890-=
qwertyuiop´[]
asdfghjklç~~
zxcvbnm,.;
`,
`# Russian
1234567890-=
йцукенгшщзхъ\
фывапролджэ
ячсмитьбю.
`,
`# Cyrillic
1234567890'+
љњертзуиопшђж
асдфгхјклчћ
ѕџцвбнм,.-
`,
`# Arabic
1234567890-=
ضصثقفغعهخحجد\
شسيبلاتنمكط
ئءؤرلاىةوزظ
`,
`# Korean
1234567890-=
qwertyuiop[]\
asdfghjkl;'
zxcvbnm,./
# Turkish
1234567890*-
qwertyuıopğü,
asdfghjklşi
zxcvbnmöç.
!'^+%&/()=?_
QWERTYUIOPĞÜ;
ASDFGHJKLŞİ
ZXCVBNMÖÇ:
`
].join("\n").split("\n").filter(
line => !(line[0] === "#" || line[0] === "(" && line.slice(-1) === ")")
).join("");
const getRe = name => name instanceof RegExp ? name : new RegExp(`[\\p{${name}}]`, "ug");
const filter = (text, re) => [...new Set(text.match(re, ""))].sort();
const parse = arr => [
arr,
arr.map(i=>i.codePointAt()).filter(i => i >= 128),
arr.length
];
const print = (category, text) => console.log(`${category}:`, ...parse(filter(text, getRe(category))));
print("Ll", layouts);
print("Lo", layouts);
print("Lu", layouts);
print("Lt", layouts);
print("Lm", layouts);
const range = (start, end, conv=String.fromCharCode) => {
const arr = [];
for (let i = start, end2 = end || start + 1; i < end2; i++) { arr.push(i); }
return conv ? conv(...arr) : arr;
};
const hex = (start, end) => range(start, end, null).map(i => i.toString(16));
print("Ll", range(1070, 1120));
print("Lo", range(1569, 1614));
var hasConsole = 1;
// hasConsole = 0;
if (typeof require === "function" && hasConsole) {
Object.assign(require('repl').start("node> ").context, {
hex, range, print, filter, parse, getRe, layouts
});
}
| gdh1995/vimium-plus | tests/unit/keyboard-layouts.js | JavaScript | mit | 2,107 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
13045,
2292,
9621,
2015,
1027,
1031,
1036,
1001,
2413,
1004,
1041,
1000,
1005,
30524,
15992,
13728,
2226,
1059,
2595,
2278,
26493,
2078,
1010,
1025,
1024,
999,
1036,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
// No direct access
defined('_JEXEC') or die;
class RentalModelBroker_Profile extends JModel
{
/**
* Function to get broker info
* @return Object Broker Info
*/
public function getItem()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$id = JRequest::getInt('id');
$query->select('*')->from('#__retal_agents')->where('id = ' . $id);
$db->setQuery($query);
$obj = $db->loadObject();
return $obj;
}
/**
* Get list apartments of broker
* @return Objects - List apartments
*/
public function getItems()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$agentId = JRequest::getInt('id');
$query->select('*')->from('#__rental_apartments')->where('agent_id = ' . $agentId);
$db->setQuery($query);
$rs = $db->loadObjectList();
return $rs;
}
} | salomalo/nbs-01 | components/com_rental/models/broker_profile.php | PHP | gpl-2.0 | 879 | [
30522,
1026,
1029,
25718,
1013,
1013,
2053,
3622,
3229,
4225,
1006,
1005,
1035,
15333,
2595,
8586,
1005,
1007,
2030,
3280,
1025,
2465,
12635,
5302,
9247,
12618,
5484,
1035,
6337,
8908,
1046,
5302,
9247,
1063,
1013,
1008,
1008,
1008,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var ps, acorn;
function start(){
ps = new PointStream();
ps.setup(document.getElementById('canvas'));
ps.pointSize(5);
ps.onKeyDown = function(){
ps.println(window.key);
};
ps.onRender = function(){
ps.translate(0, 0, -25);
ps.clear();
ps.render(acorn);
};
acorn = ps.load("../../clouds/acorn.asc");
}
| asalga/XB-PointStream | tests/leakedKey/acorn.js | JavaScript | mit | 335 | [
30522,
13075,
8827,
1010,
9353,
9691,
1025,
3853,
2707,
1006,
1007,
1063,
8827,
1027,
2047,
2685,
25379,
1006,
1007,
1025,
8827,
1012,
16437,
1006,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1005,
10683,
1005,
1007,
1007,
1025,
8827,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package consolealiensgame;
import alieninterfaces.*;
import java.lang.reflect.Constructor;
/**
*
* @author guberti
*/
public class AlienContainer {
public final String alienPackageName;
public final String alienClassName;
public final Constructor<?> alienConstructor;
private final Alien alien;
private final AlienAPI api;
int tech;
int energy;
boolean fought;
public int x;
public int y;
public boolean action; // Whether the alien has performed an action this turn
// Declare stats here
//
// Heads up: This constructs an AlienContainer and contained Alien
//
public AlienContainer(int x, int y, String alienPackageName, String alienClassName, Constructor<?> cns, int energy, int tech) {
Alien a;
this.alienPackageName = alienPackageName;
this.alienClassName = alienClassName;
this.alienConstructor = cns;
this.energy = energy;
this.tech = tech;
this.api = new AlienAPI(this);
// construct and initialize alien
try
{
a = (Alien) cns.newInstance();
a.init(this.api);
} catch (Throwable t)
{
a = null;
t.printStackTrace();
}
this.alien = a;
}
public void move(ViewImplementation view) throws NotEnoughTechException {
// Whether the move goes off the board will be determined by the grid
api.view = view;
MoveDir direction = alien.getMove();
checkMove(direction); // Throws an exception if illegal
x += direction.x();
y += direction.y();
}
public void kill() {
energy = Integer.MIN_VALUE;
}
public Action getAction(ViewImplementation view) throws NotEnoughEnergyException, UnknownActionException {
api.view = view;
Action action = alien.getAction();
switch (action.code) {
case None:
case Gain:
return new Action (action.code);
case Research:
if (tech > energy) { // If the tech can't be researched due to lack of energy
throw new NotEnoughEnergyException();
}
// Otherwise
return new Action (ActionCode.Research, tech);
case Spawn:
if (action.power + 3 > energy) {
throw new NotEnoughEnergyException();
}
return action;
default:
throw new UnknownActionException();
}
}
public int fight() throws NotEnoughEnergyException, NotEnoughTechException {
int fightPower = 0; //alien.getFightPower(api); GM need to fix this up after reconciling fighting into Action
// If the alien cannot fight with the amount of energy it wants
// Throw the appropriate exception
if (fightPower > energy) {
throw new NotEnoughEnergyException();
}
if (fightPower > tech) {
throw new NotEnoughTechException();
}
// If the move is valid, subtract the energy expended
energy -= fightPower;
// Return how much power the alien will fight with
return fightPower;
}
private void checkMove(MoveDir direction) throws NotEnoughTechException {
// If the move is farther than the alien has the tech to move
if (Math.pow(direction.x(), 2) + Math.pow(direction.y(), 2)
> Math.pow(tech, 2)) {
throw new NotEnoughTechException();
}
}
}
class NotEnoughEnergyException extends Exception {}
class NotEnoughTechException extends Exception {}
class UnknownActionException extends Exception {} | guberti/AliensGame | ConsoleAliensGame/src/consolealiensgame/AlienContainer.java | Java | mit | 4,017 | [
30522,
1013,
1008,
1008,
2000,
2689,
2023,
6105,
20346,
1010,
5454,
6105,
20346,
2015,
1999,
2622,
5144,
1012,
1008,
2000,
2689,
2023,
23561,
5371,
1010,
5454,
5906,
1064,
23561,
2015,
1008,
1998,
2330,
1996,
23561,
1999,
1996,
3559,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.aggregations.bucket;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
import org.elasticsearch.search.aggregations.BucketOrder;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregatorFactory.ExecutionMode;
import org.elasticsearch.test.ESIntegTestCase;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.search.aggregations.AggregationBuilders.sum;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.core.IsNull.notNullValue;
@ESIntegTestCase.SuiteScopeTestCase
public class TermsDocCountErrorIT extends ESIntegTestCase {
private static final String STRING_FIELD_NAME = "s_value";
private static final String LONG_FIELD_NAME = "l_value";
private static final String DOUBLE_FIELD_NAME = "d_value";
public static String randomExecutionHint() {
return randomBoolean() ? null : randomFrom(ExecutionMode.values()).toString();
}
private static int numRoutingValues;
@Override
public void setupSuiteScopeCluster() throws Exception {
assertAcked(client().admin().indices().prepareCreate("idx").setMapping(STRING_FIELD_NAME, "type=keyword").get());
List<IndexRequestBuilder> builders = new ArrayList<>();
int numDocs = between(10, 200);
int numUniqueTerms = between(2, numDocs / 2);
for (int i = 0; i < numDocs; i++) {
builders.add(
client().prepareIndex("idx")
.setId("" + i)
.setSource(
jsonBuilder().startObject()
.field(STRING_FIELD_NAME, "val" + randomInt(numUniqueTerms))
.field(LONG_FIELD_NAME, randomInt(numUniqueTerms))
.field(DOUBLE_FIELD_NAME, 1.0 * randomInt(numUniqueTerms))
.endObject()
)
);
}
assertAcked(
prepareCreate("idx_single_shard").setMapping(STRING_FIELD_NAME, "type=keyword")
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
);
for (int i = 0; i < numDocs; i++) {
builders.add(
client().prepareIndex("idx_single_shard")
.setId("" + i)
.setSource(
jsonBuilder().startObject()
.field(STRING_FIELD_NAME, "val" + randomInt(numUniqueTerms))
.field(LONG_FIELD_NAME, randomInt(numUniqueTerms))
.field(DOUBLE_FIELD_NAME, 1.0 * randomInt(numUniqueTerms))
.endObject()
)
);
}
numRoutingValues = between(1, 40);
assertAcked(prepareCreate("idx_with_routing").setMapping("{ \"_routing\" : { \"required\" : true } }"));
for (int i = 0; i < numDocs; i++) {
builders.add(
client().prepareIndex("idx_single_shard")
.setId("" + i)
.setRouting(String.valueOf(randomInt(numRoutingValues)))
.setSource(
jsonBuilder().startObject()
.field(STRING_FIELD_NAME, "val" + randomInt(numUniqueTerms))
.field(LONG_FIELD_NAME, randomInt(numUniqueTerms))
.field(DOUBLE_FIELD_NAME, 1.0 * randomInt(numUniqueTerms))
.endObject()
)
);
}
Map<String, Integer> shard0DocsPerTerm = new HashMap<>();
shard0DocsPerTerm.put("A", 25);
shard0DocsPerTerm.put("B", 18);
shard0DocsPerTerm.put("C", 6);
shard0DocsPerTerm.put("D", 3);
shard0DocsPerTerm.put("E", 2);
shard0DocsPerTerm.put("F", 2);
shard0DocsPerTerm.put("G", 2);
shard0DocsPerTerm.put("H", 2);
shard0DocsPerTerm.put("I", 1);
shard0DocsPerTerm.put("J", 1);
buildIndex(shard0DocsPerTerm, "idx_fixed_docs_0", 0, builders);
Map<String, Integer> shard1DocsPerTerm = new HashMap<>();
shard1DocsPerTerm.put("A", 30);
shard1DocsPerTerm.put("B", 25);
shard1DocsPerTerm.put("F", 17);
shard1DocsPerTerm.put("Z", 16);
shard1DocsPerTerm.put("G", 15);
shard1DocsPerTerm.put("H", 14);
shard1DocsPerTerm.put("I", 10);
shard1DocsPerTerm.put("Q", 6);
shard1DocsPerTerm.put("J", 8);
shard1DocsPerTerm.put("C", 4);
buildIndex(shard1DocsPerTerm, "idx_fixed_docs_1", 1, builders);
Map<String, Integer> shard2DocsPerTerm = new HashMap<>();
shard2DocsPerTerm.put("A", 45);
shard2DocsPerTerm.put("C", 44);
shard2DocsPerTerm.put("Z", 36);
shard2DocsPerTerm.put("G", 30);
shard2DocsPerTerm.put("E", 29);
shard2DocsPerTerm.put("H", 28);
shard2DocsPerTerm.put("Q", 2);
shard2DocsPerTerm.put("D", 1);
buildIndex(shard2DocsPerTerm, "idx_fixed_docs_2", 2, builders);
Map<String, Integer> shard3DocsPerTerm = Map.of("A", 1, "B", 1, "C", 1);
buildIndex(shard3DocsPerTerm, "idx_fixed_docs_3", 3, builders);
Map<String, Integer> shard4DocsPerTerm = Map.of("K", 1, "L", 1, "M", 1);
buildIndex(shard4DocsPerTerm, "idx_fixed_docs_4", 4, builders);
Map<String, Integer> shard5DocsPerTerm = Map.of("X", 1, "Y", 1, "Z", 1);
buildIndex(shard5DocsPerTerm, "idx_fixed_docs_5", 5, builders);
indexRandom(true, builders);
ensureSearchable();
}
private void buildIndex(Map<String, Integer> docsPerTerm, String index, int shard, List<IndexRequestBuilder> builders)
throws IOException {
assertAcked(
prepareCreate(index).setMapping(STRING_FIELD_NAME, "type=keyword")
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1))
);
for (Map.Entry<String, Integer> entry : docsPerTerm.entrySet()) {
for (int i = 0; i < entry.getValue(); i++) {
String term = entry.getKey();
builders.add(
client().prepareIndex(index)
.setId(term + "-" + i)
.setSource(jsonBuilder().startObject().field(STRING_FIELD_NAME, term).field("shard", shard).endObject())
);
}
}
}
private void assertDocCountErrorWithinBounds(int size, SearchResponse accurateResponse, SearchResponse testResponse) {
Terms accurateTerms = accurateResponse.getAggregations().get("terms");
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0L));
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
assertThat(testTerms.getDocCountError(), greaterThanOrEqualTo(0L));
List<? extends Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
assertThat(accurateBucket, notNullValue());
assertThat(accurateBucket.getDocCountError(), equalTo(0L));
assertThat(testBucket.getDocCountError(), lessThanOrEqualTo(testTerms.getDocCountError()));
assertThat(testBucket.getDocCount() + testBucket.getDocCountError(), greaterThanOrEqualTo(accurateBucket.getDocCount()));
assertThat(testBucket.getDocCount() - testBucket.getDocCountError(), lessThanOrEqualTo(accurateBucket.getDocCount()));
}
for (Terms.Bucket accurateBucket : accurateTerms.getBuckets()) {
assertThat(accurateBucket, notNullValue());
Terms.Bucket testBucket = accurateTerms.getBucketByKey(accurateBucket.getKeyAsString());
if (testBucket == null) {
assertThat(accurateBucket.getDocCount(), lessThanOrEqualTo(testTerms.getDocCountError()));
}
}
}
private void assertNoDocCountError(int size, SearchResponse accurateResponse, SearchResponse testResponse) {
Terms accurateTerms = accurateResponse.getAggregations().get("terms");
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0L));
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
assertThat(testTerms.getDocCountError(), equalTo(0L));
List<? extends Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
assertThat(accurateBucket, notNullValue());
assertThat(accurateBucket.getDocCountError(), equalTo(0L));
assertThat(testBucket.getDocCountError(), equalTo(0L));
}
}
private void assertNoDocCountErrorSingleResponse(int size, SearchResponse testResponse) {
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
assertThat(testTerms.getDocCountError(), equalTo(0L));
List<? extends Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
assertThat(testBucket.getDocCountError(), equalTo(0L));
}
}
private void assertUnboundedDocCountError(int size, SearchResponse accurateResponse, SearchResponse testResponse) {
Terms accurateTerms = accurateResponse.getAggregations().get("terms");
assertThat(accurateTerms, notNullValue());
assertThat(accurateTerms.getName(), equalTo("terms"));
assertThat(accurateTerms.getDocCountError(), equalTo(0L));
Terms testTerms = testResponse.getAggregations().get("terms");
assertThat(testTerms, notNullValue());
assertThat(testTerms.getName(), equalTo("terms"));
assertThat(testTerms.getDocCountError(), anyOf(equalTo(-1L), equalTo(0L)));
List<? extends Bucket> testBuckets = testTerms.getBuckets();
assertThat(testBuckets.size(), lessThanOrEqualTo(size));
assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size()));
for (Terms.Bucket testBucket : testBuckets) {
assertThat(testBucket, notNullValue());
Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString());
assertThat(accurateBucket, notNullValue());
assertThat(accurateBucket.getDocCountError(), equalTo(0L));
assertThat(testBucket.getDocCountError(), anyOf(equalTo(-1L), equalTo(0L)));
}
}
public void testStringValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
public void testStringValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testStringValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse testResponse = client().prepareSearch("idx_with_routing")
.setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountErrorSingleResponse(size, testResponse);
}
public void testStringValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testStringValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testStringValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testStringValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testStringValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
public void testLongValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse testResponse = client().prepareSearch("idx_with_routing")
.setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountErrorSingleResponse(size, testResponse);
}
public void testLongValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testLongValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(DOUBLE_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(LONG_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(DOUBLE_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueField() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertDocCountErrorWithinBounds(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldSingleShard() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldWithRouting() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse testResponse = client().prepareSearch("idx_with_routing")
.setRouting(String.valueOf(between(1, numRoutingValues)))
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountErrorSingleResponse(size, testResponse);
}
public void testDoubleValueFieldDocCountAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.count(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldTermSortAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldTermSortDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.key(false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(testResponse);
assertNoDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldSubAggAsc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", true))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
public void testDoubleValueFieldSubAggDesc() throws Exception {
int size = randomIntBetween(1, 20);
int shardSize = randomIntBetween(size, size * 2);
SearchResponse accurateResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(10000)
.shardSize(10000)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(accurateResponse);
SearchResponse testResponse = client().prepareSearch("idx_single_shard")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(DOUBLE_FIELD_NAME)
.showTermDocCountError(true)
.size(size)
.shardSize(shardSize)
.order(BucketOrder.aggregation("sortAgg", false))
.collectMode(randomFrom(SubAggCollectionMode.values()))
.subAggregation(sum("sortAgg").field(LONG_FIELD_NAME))
)
.get();
assertSearchResponse(testResponse);
assertUnboundedDocCountError(size, accurateResponse, testResponse);
}
/**
* Test a case where we know exactly how many of each term is on each shard
* so we know the exact error value for each term. To do this we search over
* 3 one-shard indices.
*/
public void testFixedDocs() throws Exception {
SearchResponse response = client().prepareSearch("idx_fixed_docs_0", "idx_fixed_docs_1", "idx_fixed_docs_2")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(5)
.shardSize(5)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(response);
Terms terms = response.getAggregations().get("terms");
assertThat(terms, notNullValue());
assertThat(terms.getDocCountError(), equalTo(46L));
List<? extends Bucket> buckets = terms.getBuckets();
assertThat(buckets, notNullValue());
assertThat(buckets.size(), equalTo(5));
Bucket bucket = buckets.get(0);
assertThat(bucket, notNullValue());
assertThat(bucket.getKey(), equalTo("A"));
assertThat(bucket.getDocCount(), equalTo(100L));
assertThat(bucket.getDocCountError(), equalTo(0L));
bucket = buckets.get(1);
assertThat(bucket, notNullValue());
assertThat(bucket.getKey(), equalTo("Z"));
assertThat(bucket.getDocCount(), equalTo(52L));
assertThat(bucket.getDocCountError(), equalTo(2L));
bucket = buckets.get(2);
assertThat(bucket, notNullValue());
assertThat(bucket.getKey(), equalTo("C"));
assertThat(bucket.getDocCount(), equalTo(50L));
assertThat(bucket.getDocCountError(), equalTo(15L));
bucket = buckets.get(3);
assertThat(bucket, notNullValue());
assertThat(bucket.getKey(), equalTo("G"));
assertThat(bucket.getDocCount(), equalTo(45L));
assertThat(bucket.getDocCountError(), equalTo(2L));
bucket = buckets.get(4);
assertThat(bucket, notNullValue());
assertThat(bucket.getKey(), equalTo("B"));
assertThat(bucket.getDocCount(), equalTo(43L));
assertThat(bucket.getDocCountError(), equalTo(29L));
}
/**
* Tests the upper bounds are correct when performing incremental reductions
* See https://github.com/elastic/elasticsearch/issues/40005 for more details
*/
public void testIncrementalReduction() {
SearchResponse response = client().prepareSearch("idx_fixed_docs_3", "idx_fixed_docs_4", "idx_fixed_docs_5")
.addAggregation(
terms("terms").executionHint(randomExecutionHint())
.field(STRING_FIELD_NAME)
.showTermDocCountError(true)
.size(5)
.shardSize(5)
.collectMode(randomFrom(SubAggCollectionMode.values()))
)
.get();
assertSearchResponse(response);
Terms terms = response.getAggregations().get("terms");
assertThat(terms.getDocCountError(), equalTo(0L));
}
}
| GlenRSmith/elasticsearch | server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java | Java | apache-2.0 | 47,671 | [
30522,
1013,
1008,
1008,
9385,
21274,
17310,
11140,
1038,
1012,
1058,
1012,
1998,
1013,
2030,
7000,
2000,
21274,
17310,
11140,
1038,
1012,
1058,
1012,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
7000,
2104,
1996,
21274,
6105,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Embed\Providers;
use Embed\Adapters\Adapter;
use Embed\Utils;
/**
* Provider to get the data from the Open Graph elements in the HTML
*/
class OpenGraph extends Provider
{
/**
* {@inheritdoc}
*/
public function __construct(Adapter $adapter)
{
parent::__construct($adapter);
if (!($html = $adapter->getResponse()->getHtmlContent())) {
return;
}
foreach ($html->getElementsByTagName('meta') as $meta) {
$name = trim(strtolower($meta->getAttribute('property')));
$value = $meta->getAttribute('content');
if (empty($name)) {
$name = trim(strtolower($meta->getAttribute('name')));
}
if (empty($name) || empty($value)) {
continue;
}
if (strpos($name, 'og:') === 0) {
$name = substr($name, 3);
} elseif (
strpos($name, 'article:') !== 0
&& strpos($name, 'image:') !== 0
&& strpos($name, 'video:') !== 0
&& strpos($name, 'book:') !== 0
&& strpos($name, 'music:') !== 0
&& strpos($name, 'profile:') !== 0
) {
continue;
}
switch ($name) {
case 'image':
case 'image:url':
case 'image:secure_url':
$this->bag->add('images', $value);
break;
case 'article:tag':
case 'video:tag':
case 'book:tag':
$this->bag->add('tags', $value);
break;
default:
$this->bag->set($name, $value);
}
}
}
/**
* {@inheritdoc}
*/
public function getTitle()
{
return $this->bag->get('title');
}
/**
* {@inheritdoc}
*/
public function getDescription()
{
return $this->bag->get('description');
}
/**
* {@inheritdoc}
*/
public function getType()
{
$type = $this->bag->get('type');
if (strpos($type, ':') !== false) {
$type = substr(strrchr($type, ':'), 1);
}
switch ($type) {
case 'video':
case 'photo':
case 'link':
case 'rich':
return $type;
case 'article':
return 'link';
}
if ($this->bag->has('video')) {
return 'video';
}
}
/**
* {@inheritdoc}
*/
public function getCode()
{
$names = ['video:secure_url', 'video:url', 'video'];
foreach ($names as $name) {
if ($this->bag->has($name)) {
$video = $this->normalizeUrl($this->bag->get($name));
if (!($videoPath = parse_url($video, PHP_URL_PATH)) || !($type = pathinfo($videoPath, PATHINFO_EXTENSION))) {
$type = $this->bag->get('video:type');
}
switch ($type) {
case 'swf':
case 'application/x-shockwave-flash':
return Utils::flash($video, $this->getWidth(), $this->getHeight());
case 'mp4':
case 'ogg':
case 'ogv':
case 'webm':
case 'application/mp4':
case 'video/mp4':
case 'video/ogg':
case 'video/ogv':
case 'video/webm':
$images = $this->getImagesUrls();
return Utils::videoHtml(current($images), $video, $this->getWidth(), $this->getHeight());
case 'text/html':
return Utils::iframe($video, $this->getWidth(), $this->getHeight());
}
}
}
}
/**
* {@inheritdoc}
*/
public function getUrl()
{
return $this->normalizeUrl($this->bag->get('url'));
}
/**
* {@inheritdoc}
*/
public function getTags()
{
return (array) $this->bag->get('tags') ?: [];
}
/**
* {@inheritdoc}
*/
public function getAuthorName()
{
return $this->bag->get('article:author') ?: $this->bag->get('book:author');
}
/**
* {@inheritdoc}
*/
public function getProviderName()
{
return $this->bag->get('site_name');
}
/**
* {@inheritdoc}
*/
public function getImagesUrls()
{
return $this->normalizeUrls($this->bag->get('images'));
}
/**
* {@inheritdoc}
*/
public function getWidth()
{
return $this->bag->get('image:width') ?: $this->bag->get('video:width');
}
/**
* {@inheritdoc}
*/
public function getHeight()
{
return $this->bag->get('image:height') ?: $this->bag->get('video:height');
}
/**
* {@inheritdoc}
*/
public function getPublishedTime()
{
return $this->bag->get('article:published_time')
?: $this->bag->get('article:modified_time')
?: $this->bag->get('video:release_date')
?: $this->bag->get('music:release_date');
}
/**
* {@inheritdoc}
*/
public function getProviderUrl()
{
return $this->bag->get('website');
}
}
| acrylian/zp_oembed | zp_oembed/Providers/OpenGraph.php | PHP | gpl-3.0 | 5,488 | [
30522,
1026,
1029,
25718,
3415,
15327,
7861,
8270,
1032,
11670,
1025,
2224,
7861,
8270,
1032,
15581,
2545,
1032,
15581,
2121,
1025,
2224,
7861,
8270,
1032,
21183,
12146,
1025,
1013,
1008,
1008,
1008,
10802,
2000,
2131,
1996,
2951,
2013,
199... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<extend name="Public:registBase"/>
<block name="content">
<div class="box">
<div class="top">
<a class="tjt" href="__URL__/welcome"><img src="__PUBLIC__/images/tjt_03.png"></a>
<a class="a1">登陆</a>
<a class="a2" href="#">完成</a>
</div>
<div class="zc1_k">
<p class="zc_p1"></p>
<div class="zc_phone">
<p class="zc_p2">+86</p>
<p class="zc_p3"></p>
<form action="" method="get">
<input class="zc_hm" type="text" value="填写手机号" onfocus="if(this.value=' 请写您的电话号') this.value = ''" onblur="if(this.value == '') this.value = ' 请写您的电话号'" name='shoper_phone'/>
</form>
</div>
<div class="zc_phone">
<form action="" method="get">
<input class="zc_hm" type="text" value="请输入密码" name="hidepassword" />
<input class="zc_hm" type="password" style="display:none" name='password'/>
</form>
</div>
</div>
</div>
</block>
<block name="js">
<script type="text/javascript">
$('.a2').click(function(event){
var shoper_phone = $('input[name="shoper_phone"]').val();
var password = $('input[name="password"]').val();
event.preventDefault();
$.post('__URL__/loginPro',{shoper_phone:shoper_phone,password:password},function(data){
if (data.status) {
location.href = "{:U('Home/Store/dashboardDis')}";
}else{
alert(data.info);
};
});
});
$('.zc_hm[name="hidepassword"]').focus(function(){
$(this).hide();
$('.zc_hm[name="password"]').show().focus();
});
</script>
</block> | kkme/WxShop | Application/Home/View/Regist/login.html | HTML | mit | 1,931 | [
30522,
1026,
7949,
2171,
1027,
1000,
2270,
1024,
20588,
2102,
15058,
1000,
1013,
1028,
1026,
3796,
2171,
1027,
1000,
4180,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
3482,
1000,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
2327,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using DigitalImageProcessingLib.ImageType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DigitalImageProcessingLib.Interface
{
public interface IGlobalTresholdBinarization: IBinarization
{
int Treshold { get; set; }
int Countreshold(GreyImage image);
}
}
| ValeriyaSyomina/TextDetector | src/DigitalImageProcessingLib/Interface/IGlobalTresholdBinarization.cs | C# | apache-2.0 | 367 | [
30522,
2478,
3617,
9581,
3351,
21572,
9623,
7741,
29521,
1012,
3746,
13874,
1025,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?PHP
require_once('inc/ircplugin.php');
require_once('inc/ircformat.php');
require_once('mpd/mpd.class.php');
if(!class_exists('MbotMpd')) {
class MbotMpd extends IrcPlugin {
private $host = 'localhost';
private $port = 6600;
private $password = '';
private $max_list = 10;
private $last_search = array();
public function OnMpd(&$channel, IrcPrivMsg $priv_msg, array $argv) {
$this->Connect();
switch(strtolower($argv[0])) {
case 'np':
return $this->HandleNp($channel);
case 'pause':
return $this->HandlePause();
case 'search':
return $this->HandleSearch($channel, $argv[1], $argv[2]);
case 'play':
return $this->HandlePlay($channel, $argv[1], $argv[2]);
}
}
//a few shorthands
public function OnSearch(&$channel, IrcPrivMsg $priv_msg, array $argv) {
$this->Connect();
return $this->HandleSearch($channel, 'title', $argv[0]);
}
public function OnPlay(&$channel, IrcPrivMsg $priv_msg, array $argv) {
$this->Connect();
return $this->HandlePlay($channel, 'title', $argv[0]);
}
public function OnList(&$channel, IrcPrivMsg $priv_msg, array $argv) {
$this->Connect();
return $this->PlayLastSearch($argv[0]);
}
private function HandleNp(&$channel) {
$this->mpd->RefreshInfo();
$current_track = $this->mpd->playlist[$this->mpd->current_track_id];
$channel->Send($current_track['Artist'].' - '.$current_track['Title']);
}
private function HandlePause() {
$this->mpd->Pause();
}
private function HandleSearch(&$channel, $type, $str) {
$return = $this->SearchDB($type, $str);
if(count($return) == 0) {
$channel->Send("Nothing found");
}
elseif(count($return) <= $this->max_list) {
$this->SearchResults(&$channel, $return);
}
else {
$channel->Send('I\'m not going to list '.count($return).' songs');
}
}
private function HandlePlay(&$channel, $type, $str) {
if(strtolower($type) === 'list')
return $this->PlayLastSearch($type);
$return = $this->SearchDB($type, $str);
if(count($return) == 1) {
$this->Play($return[0]['file']);
$channel->Send('Playing: '.$return[0]['Artist'].' - '.$return[0]['Title']);
}
elseif(count($return) == 0) {
$channel->Send("Nothing found");
}
else {
$channel->Send('More than one song matches...');
if(count($return) <= $this->max_list) {
$this->SearchResults(&$channel, $return);
}
else
$channel->Send('Actually there are too many matching songs that match even to list');
}
}
private function Connect() {
$this->mpd = empty($this->password) ? new mpd($this->host, $this->port) : new mpd($this->host, $this->port, $this->password);
}
private function SearchDB($type, $str) {
$allowed_types = array('artist' => MPD_SEARCH_ARTIST, 'title' => MPD_SEARCH_TITLE, 'album' => MPD_SEARCH_ALBUM);
if(!isset($allowed_types[strtolower($type)]))
return;
return $this->mpd->Search($allowed_types[strtolower($type)], $str);
}
private function Play($file) {
//if song is already on the playlist, do not add it again
$found = false;
foreach($this->mpd->playlist as $idx => $song) {
if($song['file'] == $file) {
echo 'Song is already in the playlist'."\n";
$this->mpd->SkipTo($idx);
$found = true;
break;
}
}
if(!$found) {
$this->mpd->PLAdd($file);
$this->mpd->RefreshInfo();
$this->mpd->SkipTo(count($this->mpd->playlist)-1);
}
}
private function PlayLastSearch($idx) {
if(isset($this->last_search[$idx]))
$this->Play($this->last_search[$idx]['file']);
}
private function SearchResults(&$channel, $songs) {
$this->last_search = $songs;
foreach($songs as $idx => $song) {
$channel->Send(IrcFormat::Bold($idx).'. '.$song['Artist'].' - '.$song['Title']);
}
$channel->Send('To play: '.IrcFormat::Green('!list #'));
}
}
}
return new MbotMpd;
?>
| mylssi/mbot-php | plugins/mbot_mpd.php | PHP | gpl-3.0 | 3,883 | [
30522,
1026,
1029,
25718,
5478,
1035,
2320,
1006,
1005,
4297,
1013,
20868,
21906,
7630,
11528,
1012,
25718,
1005,
1007,
1025,
5478,
1035,
2320,
1006,
1005,
4297,
1013,
20868,
2278,
14192,
4017,
1012,
25718,
1005,
1007,
1025,
5478,
1035,
232... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <cpp3ds/Config.hpp>
#include <map>
namespace cpp3ds {
namespace priv {
struct ResourceInfo {
ResourceInfo() : data(nullptr), size(0) { }
ResourceInfo(const Uint8 *x, const Uint32 y) : data(x), size(y) { }
const Uint8 *data;
const Uint32 size;
};
// Defined by source file generated by res_compile.py
extern std::map<std::string, ResourceInfo> core_resources;
} // namespace priv
} // namespace cpp3ds | cpp3ds/cpp3ds | include/cpp3ds/Resources.hpp | C++ | mit | 495 | [
30522,
1001,
2421,
1026,
18133,
2361,
29097,
2015,
1013,
9530,
8873,
2290,
1012,
6522,
2361,
1028,
1001,
2421,
1026,
4949,
1028,
3415,
15327,
18133,
2361,
29097,
2015,
1063,
3415,
15327,
26927,
2615,
1063,
2358,
6820,
6593,
7692,
2378,
1487... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using TwitterAPI;
using System.Net;
using Core;
using System.Security.Cryptography;
using System.IO;
namespace TwitterAPI
{
[DataContract]
public class TwitterDirectMessage
{
/// <summary>
/// ダイレクトメッセージのID
/// </summary>
[DataMember(Name = "id")]
public decimal Id { get; set; }
[DataMember(Name = "created_at")]
private string created_at { get; set; }
public DateTime CreateDate
{
get
{
return DateTime.ParseExact(created_at, "ddd MMM dd HH':'mm':'ss zz'00' yyyy",
System.Globalization.DateTimeFormatInfo.InvariantInfo,
System.Globalization.DateTimeStyles.None);
}
}
/// <summary>
/// ダイレクトメッセージのID(文字列)
/// </summary>
[DataMember(Name = "id_str")]
public string StringId { get; set; }
/// <summary>
/// ダイレクトメッセージの受信者
/// </summary>
[DataMember(Name = "recipient")]
public TwitterUser Recipient { get; set; }
/// <summary>
/// ダイレクトメッセージの送信者
/// </summary>
[DataMember(Name = "sender")]
public TwitterUser Sender { get; set; }
/// <summary>
/// ダイレクトメッセージの内容
/// </summary>
[DataMember(Name = "text")]
public string Text { get; set; }
[DataMember(Name = "sender_id")]
public decimal SenderId { get; set; }
[DataMember(Name = "sender_id_str")]
public string SenderStringId { get; set; }
[DataMember(Name = "sender_screen_name")]
public string SenderScreenName { get; set; }
[DataMember(Name = "recipient_id")]
public decimal RecipientId { get; set; }
[DataMember(Name = "recipient_id_str")]
public string RecipientStringId { get; set; }
[DataMember(Name = "recipient_screen_name")]
public string RecipientScreenName { get; set; }
[DataMember(Name = "entities")]
public TwitterStatus.TweetEntities Entities { get; set; }
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessage(OAuthTokens tokens, DirectMessageOptions options)
{
return new TwitterResponse<TwitterDirectMessageCollection>(Method.Get(UrlBank.DirectMessages, tokens, options));
}
public static TwitterResponse<TwitterDirectMessageCollection> DirectMessageSent(OAuthTokens tokens, DirectMessageOptions options)
{
return new TwitterResponse<TwitterDirectMessageCollection>(Method.Get(UrlBank.DirectMessagesSent, tokens, options));
}
public static TwitterResponse<TwitterDirectMessage> Show(OAuthTokens tokens, decimal id)
{
return new TwitterResponse<TwitterDirectMessage>(Method.Get(string.Format(UrlBank.DirectMessageShow, id), tokens, null));
}
public static TwitterResponse<TwitterDirectMessage> Destroy(OAuthTokens tokens, decimal id, bool IncludeEntities = false)
{
return new TwitterResponse<TwitterDirectMessage>(Method.GenerateResponseResult(Method.GenerateWebRequest(string.Format("{0}?id={1}", UrlBank.DirectMessagesDestroy, id), WebMethod.POST, tokens, null, "application/x-www-form-urlencoded", null, null)));
}
public static TwitterResponse<TwitterDirectMessage> New(OAuthTokens tokens, string ScreenName, string Text)
{
string data = string.Format("text={0}&screen_name={1}", Uri.EscapeDataString(Text), Uri.EscapeDataString(ScreenName));
return new TwitterResponse<TwitterDirectMessage>(Method.GenerateResponseResult(Method.GenerateWebRequest("https://api.twitter.com/1.1/direct_messages/new.json?" + data, WebMethod.POST, tokens, null, "application/x-www-form-urlencoded", null, null)));
}
public static TwitterResponse<TwitterDirectMessage> New(OAuthTokens tokens, decimal UserId, string Text)
{
string data = string.Format("text={0}&screen_name={1}", Uri.EscapeDataString(Text), UserId);
return new TwitterResponse<TwitterDirectMessage>(Method.GenerateResponseResult(Method.GenerateWebRequest("https://api.twitter.com/1.1/direct_messages/new.json?" + data, WebMethod.POST, tokens, null, "application/x-www-form-urlencoded", null, null)));
}
private class DMDestroyOption : ParameterClass
{
[Parameters("id", ParameterMethodType.POSTData)]
public decimal Id { get; set; }
[Parameters("include_entities")]
public bool? IncludeEntities { get; set; }
}
}
public class TwitterDirectMessageCollection : List<TwitterDirectMessage> { }
}
| atst1996/TwitterAPI | TwitterAPI/Method/DirectMessages/DirectMessage.cs | C# | mit | 4,411 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
2448,
7292,
1012,
7642,
3989,
1025,
2478,
10474,
9331,
2072,
1025,
2478,
2291,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu {
line-height: 1.0;
}
.sf-menu ul {
position: absolute;
top: -999em;
width: 10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width: 100%;
}
.sf-menu li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float: left;
position: relative;
}
.sf-menu a {
display: block;
position: relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left: 0;
top: 2.5em; /* match top ul list item height */
z-index: 9999;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left: 13.5em; /* match ul width */
top: 0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left: 10em; /* match ul width */
top: 0;
}
/*** DEMO SKIN ***/
.sf-menu {
float: left;
margin-bottom: 1px;
}
.sf-menu a {
padding: .75em 1em;
text-decoration:none;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
color: #bbbbbb;
/*font-weight: bold;*/
}
.sf-menu li {
}
.sf-menu li li {
background: url("img/sub-menu-center.png") repeat-y transparent;
float: left;
}
.sf-menu .sub-menu {
margin-top: -26px;
padding-top: 17px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
z-index: 99999;
}
.sf-menu .sub-menu li{}
.sf-menu .sub-menu li a{
color: #4e4d4c!important;
margin: 5px 15px 5px 16px;
padding-bottom: 10px;
border-bottom: 1px solid rgba(153, 153, 153, 0.28);
}
.sf-menu .sub-menu li:last-child a {border: none}
.sf-menu .sub-menu li:first-child a {margin-top: 10px}
.sf-menu .sub-menu li:last-child {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom: 1px solid rgba(0, 0, 0, 0.21);
}
.sf-menu .sub-menu-last ul li a{
border-bottom: 1px solid #e9e8e8!important;
padding: 0.7em 0;
width: 94%;
}
.sf-menu .sub-menu-last ul li a.sub-sub-menu-last{border-bottom:0px solid #fff!important;}
.sf-menu li li li {}
.sf-menu li:hover, .sf-menu li.sfHover,
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
color: #fff;
outline: 0;
}
.sf-menu .sub-menu a:hover{
color:#ff6825!important;
outline: 0;
background: none!important;
}
.sf-menu .sub-menu li:hover{}
/*** arrows **/
.sf-menu a.sf-with-ul {
min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
}
.sf-sub-indicator {
position: absolute;
display: block;
right: .75em;
top: 1.05em; /* IE6 only */
width: 10px;
height: 10px;
text-indent: -999em;
overflow: hidden;
}
a > .sf-sub-indicator { /* give all except IE6 the correct values */
top: .8em;
background-position: 0 -100px; /* use translucent arrow for modern browsers*/
}
/* apply hovers to modern browsers */
a:focus > .sf-sub-indicator,
a:hover > .sf-sub-indicator,
a:active > .sf-sub-indicator,
li:hover > a > .sf-sub-indicator,
li.sfHover > a > .sf-sub-indicator {
background-position: -10px -100px; /* arrow hovers for modern browsers*/
}
/* point right for anchors in subs */
.sf-menu ul .sf-sub-indicator { background-position: -10px 0; }
.sf-menu ul a > .sf-sub-indicator { background-position: 0 0; }
/* apply hovers to modern browsers */
.sf-menu ul a:focus > .sf-sub-indicator,
.sf-menu ul a:hover > .sf-sub-indicator,
.sf-menu ul a:active > .sf-sub-indicator,
.sf-menu ul li:hover > a > .sf-sub-indicator,
.sf-menu ul li.sfHover > a > .sf-sub-indicator {
background-position: -10px 0; /* arrow hovers for modern browsers*/
}
/*** shadows for all but IE6 ***/
.sf-shadow ul { margin: 5px 0 0 0; }
.sf-shadow ul.sf-shadow-off {
background: transparent;
}
/*--- TOP, BOTTOM SUB-MENU --*/
.sub-menu-top{
background: url("img/sub-menu-top.png") no-repeat transparent;
float: left;
height: 3px;
width: 191px;
}
.sub-menu-bottom{
background: url("img/sub-menu-bottom.png") no-repeat transparent;
float: left;
height: 8px;
width: 191px;
}
| ajyn17/wp-khouse | wp-content/themes/eventor/script/menu/superfish.css | CSS | gpl-2.0 | 4,259 | [
30522,
1013,
1008,
1008,
1008,
6827,
6782,
1008,
1008,
1008,
1013,
1012,
16420,
1011,
12183,
1010,
1012,
16420,
1011,
12183,
1008,
1063,
7785,
1024,
1014,
1025,
11687,
4667,
1024,
1014,
1025,
2862,
1011,
2806,
1024,
3904,
1025,
1065,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Newsfeeds component
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.0
*/
class NewsfeedsViewNewsfeed extends JViewLegacy
{
/**
* @var object
* @since 1.6
*/
protected $state;
/**
* @var object
* @since 1.6
*/
protected $item;
/**
* @var boolean
* @since 1.6
*/
protected $print;
/**
* @since 1.6
*/
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
// Get view related request variables.
$print = $app->input->getBool('print');
// Get model data.
$state = $this->get('State');
$item = $this->get('Item');
if ($item)
{
// Get Category Model data
$categoryModel = JModelLegacy::getInstance('Category', 'NewsfeedsModel', array('ignore_request' => true));
$categoryModel->setState('category.id', $item->catid);
$categoryModel->setState('list.ordering', 'a.name');
$categoryModel->setState('list.direction', 'asc');
// TODO: $items is not used. Remove this line?
$items = $categoryModel->getItems();
}
// Check for errors.
// @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Add router helpers.
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = $item->category_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
// check if cache directory is writeable
$cacheDir = JPATH_CACHE . '/';
if (!is_writable($cacheDir))
{
JError::raiseNotice('0', JText::_('COM_NEWSFEEDS_CACHE_DIRECTORY_UNWRITABLE'));
return;
}
// Merge newsfeed params. If this is single-newsfeed view, menu params override newsfeed params
// Otherwise, newsfeed params override menu item params
$params = $state->get('params');
$newsfeed_params = clone $item->params;
$active = $app->getMenu()->getActive();
$temp = clone ($params);
// Check to see which parameters should take priority
if ($active)
{
$currentLink = $active->link;
// If the current view is the active item and an newsfeed view for this feed, then the menu item params take priority
if (strpos($currentLink, 'view=newsfeed') && (strpos($currentLink, '&id='.(string) $item->id)))
{
// $item->params are the newsfeed params, $temp are the menu item params
// Merge so that the menu item params take priority
$newsfeed_params->merge($temp);
$item->params = $newsfeed_params;
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
{
$this->setLayout($active->query['layout']);
}
}
else
{
// Current view is not a single newsfeed, so the newsfeed params take priority here
// Merge the menu item params with the newsfeed params so that the newsfeed params take priority
$temp->merge($newsfeed_params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout = $item->params->get('newsfeed_layout'))
{
$this->setLayout($layout);
}
}
}
else
{
// Merge so that newsfeed params take priority
$temp->merge($newsfeed_params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout = $item->params->get('newsfeed_layout'))
{
$this->setLayout($layout);
}
}
// Check the access to the newsfeed
$levels = $user->getAuthorisedViewLevels();
if (!in_array($item->access, $levels) or ((in_array($item->access, $levels) and (!in_array($item->category_access, $levels)))))
{
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// Get the current menu item
$params = $app->getParams();
// Get the newsfeed
$newsfeed = $item;
$temp = new JRegistry;
$temp->loadString($item->params);
$params->merge($temp);
try
{
$feed = new JFeedFactory;
$this->rssDoc = $feed->getFeed($newsfeed->link);
}
catch (InvalidArgumentException $e)
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
catch (RunTimeException $e)
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
if (empty($this->rssDoc))
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
$feed_display_order = $params->get('feed_display_order', 'des');
if ($feed_display_order == 'asc')
{
$newsfeed->items = array_reverse($newsfeed->items);
}
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->assignRef('params', $params);
$this->assignRef('newsfeed', $newsfeed);
$this->assignRef('state', $state);
$this->assignRef('item', $item);
$this->assignRef('user', $user);
if (!empty($msg))
{
$this->assignRef('msg', $msg);
}
$this->print = $print;
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
* @since 1.6
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
$id = (int) @$menu->query['id'];
// if the menu item does not concern this newsfeed
if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] != 'newsfeed' || $id != $this->item->id))
{
// If this is not a single newsfeed menu item, set the page title to the newsfeed title
if ($this->item->name)
{
$title = $this->item->name;
}
$path = array(array('title' => $this->item->name, 'link' => ''));
$category = JCategories::getInstance('Newsfeeds')->get($this->item->catid);
while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
if (empty($title))
{
$title = $this->item->name;
}
$this->document->setTitle($title);
if ($this->item->metadesc)
{
$this->document->setDescription($this->item->metadesc);
}
elseif (!$this->item->metadesc && $this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->item->metakey)
{
$this->document->setMetadata('keywords', $this->item->metakey);
}
elseif (!$this->item->metakey && $this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
if ($app->getCfg('MetaTitle') == '1')
{
$this->document->setMetaData('title', $this->item->name);
}
if ($app->getCfg('MetaAuthor') == '1')
{
$this->document->setMetaData('author', $this->item->author);
}
$mdata = $this->item->metadata->toArray();
foreach ($mdata as $k => $v)
{
if ($v)
{
$this->document->setMetadata($k, $v);
}
}
}
}
| RCBiczok/ArticleRefs | src/test/lib/joomla/3_1_5/components/com_newsfeeds/views/newsfeed/view.html.php | PHP | gpl-3.0 | 8,625 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1030,
7427,
28576,
19968,
2050,
1012,
2609,
1008,
1030,
4942,
23947,
4270,
4012,
1035,
2739,
7959,
2098,
2015,
1008,
1008,
1030,
9385,
9385,
1006,
1039,
1007,
2384,
1011,
2286,
2330,
3120,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import logger from './logger';
import app from './app';
const port = app.get('port');
const server = app.listen(port);
process.on('unhandledRejection', (reason, p) =>
logger.error('Unhandled Rejection at: Promise ', p, reason)
);
server.on('listening', () =>
logger.info('Feathers application started on http://%s:%d', app.get('host'), port)
);
| feathersjs/generator-feathers | generators/app/templates/ts/src/index.ts | TypeScript | mit | 352 | [
30522,
12324,
8833,
30524,
8241,
1027,
10439,
1012,
4952,
1006,
3417,
1007,
1025,
2832,
1012,
2006,
1006,
1005,
4895,
11774,
3709,
2890,
20614,
3258,
1005,
1010,
1006,
3114,
1010,
1052,
1007,
1027,
1028,
8833,
4590,
1012,
7561,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- xml-patterns.qdoc -->
<title>XQuery | Qt XML Patterns 5.7</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
window.onload = function(){document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");};
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td ><a href="../qtdoc/supported-platforms-and-configurations.html#qt-5-7">Qt 5.7</a></td><td ><a href="qtxmlpatterns-index.html">Qt XML Patterns</a></td><td >XQuery</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.7.0 Reference Documentation</td>
</tr></table>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<link rel="prev" href="../qtxml/xml-dom-tml.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="../qtxml/xml-dom-tml.html">Working with the DOM Tree</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#introduction">Introduction</a></li>
<li class="level1"><a href="#advantages-of-using-qt-xml-patterns-and-xquery">Advantages of Using Qt XML Patterns and XQuery</a></li>
<li class="level1"><a href="#using-the-qt-xml-patterns-module">Using the Qt XML Patterns Module</a></li>
<li class="level2"><a href="#running-the-query-engine-from-your-qt-application">Running the query engine from your Qt application</a></li>
<li class="level2"><a href="#running-the-query-engine-from-the-command-line-utility">Running the query engine from the command line utility</a></li>
<li class="level1"><a href="#the-xquery-data-model">The XQuery Data Model</a></li>
<li class="level2"><a href="#binding-program-variables-to-xquery-variables">Binding program variables to XQuery variables</a></li>
<li class="level2"><a href="#interpreting-xquery-results">Interpreting XQuery results</a></li>
<li class="level1"><a href="#using-xquery-with-non-xml-data">Using XQuery with Non-XML Data</a></li>
<li class="level1"><a href="#more-on-using-qt-xml-patterns-with-non-xml-data">More on Using Qt XML Patterns with Non-XML Data</a></li>
<li class="level1"><a href="#security-considerations">Security Considerations</a></li>
<li class="level2"><a href="#code-injection">Code Injection</a></li>
<li class="level2"><a href="#denial-of-service-attacks">Denial of Service Attacks</a></li>
<li class="level1"><a href="#features-and-conformance">Features and Conformance</a></li>
<li class="level2"><a href="#xquery-1-0">XQuery 1.0</a></li>
<li class="level2"><a href="#xslt-2-0">XSLT 2.0</a></li>
<li class="level2"><a href="#xpath-2-0">XPath 2.0</a></li>
<li class="level2"><a href="#xml-id">xml:id</a></li>
<li class="level2"><a href="#xml-schema-1-0">XML Schema 1.0</a></li>
<li class="level2"><a href="#resource-loading">Resource Loading</a></li>
<li class="level2"><a href="#xml">XML</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">XQuery</h1>
<span class="subtitle"></span>
<!-- $$$xmlprocessing.html-description -->
<div class="descr"> <a name="details"></a>
<a name="introduction"></a>
<h2 id="introduction">Introduction</h2>
<p><a href="xmlprocessing.html">XQuery</a> is a language for traversing XML documents to select and aggregate items of interest and to transform them for output as XML or some other format. XPath is the <i>element selection</i> part of <a href="xmlprocessing.html">XQuery</a>.</p>
<p>The Qt XML Patterns module supports using <a href="http://www.w3.org/TR/xquery">XQuery 1.0</a> and <a href="http://www.w3.org/TR/xpath20">XPath 2.0</a> in Qt applications, for querying XML data <i>and</i> for querying <a href="qabstractxmlnodemodel.html">non-XML data that can be modeled to look like XML</a>. Readers who are not familiar with the <a href="xmlprocessing.html">XQuery</a>/XPath language can read <a href="xquery-introduction.html">A Short Path to XQuery</a> for a brief introduction.</p>
<a name="advantages-of-using-qt-xml-patterns-and-xquery"></a>
<h2 id="advantages-of-using-qt-xml-patterns-and-xquery">Advantages of Using Qt XML Patterns and XQuery</h2>
<p>The <a href="xmlprocessing.html">XQuery</a>/XPath language simplifies data searching and transformation tasks by eliminating the need for doing a lot of C++ or Java procedural programming for each new query task. Here is an <a href="xmlprocessing.html">XQuery</a> that constructs a bibliography of the contents of a library:</p>
<a name="qtxmlpatterns-example-query"></a><pre class="cpp">
<bibliography>
{doc("library.xml")/bib/book[publisher="Addison-Wesley" and @year>1991]/<book year="{@year}">{title}</book>}
</bibliography>
</pre>
<p>First, the query opens a <code><bibliography></code> element in the output. The <a href="xquery-introduction.html#using-path-expressions-to-match-and-select-items">embedded path expression</a> then loads the XML document describing the contents of the library (<code>library.xml</code>) and begins the search. For each <code><book></code> element it finds, where the publisher was Addison-Wesley and the publication year was after 1991, it creates a new <code><book></code> element in the output as a child of the open <code><bibliography></code> element. Each new <code><book></code> element gets the book's title as its contents and the book's publication year as an attribute. Finally, the <code><bibliography></code> element is closed.</p>
<p>The advantages of using Qt XML Patterns and <a href="xmlprocessing.html">XQuery</a> in your Qt programs are summarized as follows:</p>
<ul>
<li><b>Ease of development</b>: All the C++ programming required to perform data query tasks can be replaced by a simple <a href="xmlprocessing.html">XQuery</a> like the example above.</li>
<li><b>Comprehensive functionality</b>: The <a href="http://www.w3.org/TR/xquery/#id-expressions">expression syntax</a> and rich set of <a href="http://www.w3.org/TR/xpath-functions">functions and operators</a> provided by <a href="xmlprocessing.html">XQuery</a> are sufficient for performing any data searching, selecting, and sorting tasks.</li>
<li><b>Conformance to standards</b>: Conformance to all applicable XML and <a href="xmlprocessing.html">XQuery</a> standards ensures that Qt XML Patterns can always process XML documents generated by other conformant applications, and that XML documents created with Qt XML Patterns can be processed by other conformant applications.</li>
<li><b>Maximal flexibility</b> The Qt XML Patterns module can be used to query XML data <i>and</i> non-XML data that can be <a href="qabstractxmlnodemodel.html">modeled to look like XML</a>.</li>
</ul>
<a name="using-the-qt-xml-patterns-module"></a>
<h2 id="using-the-qt-xml-patterns-module">Using the Qt XML Patterns Module</h2>
<p>There are two ways Qt XML Patterns can be used to evaluate queries. You can run the query engine in your Qt application using the Qt XML Patterns C++ API, or you can run the query engine from the command line using Qt's <code>xmlpatterns</code> command line utility.</p>
<a name="running-the-query-engine-from-your-qt-application"></a>
<h3 >Running the query engine from your Qt application</h3>
<p>If we save the example <a href="xmlprocessing.html">XQuery</a> shown above in a text file (e.g. <code>myquery.xq</code>), we can run it from a Qt application using a standard Qt XML Patterns code sequence:</p>
<pre class="cpp">
<span class="type"><a href="../qtcore/qfile.html">QFile</a></span> xq(<span class="string">"myquery.xq"</span>);
<span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
query<span class="operator">.</span>setQuery(<span class="operator">&</span>xq<span class="operator">,</span> <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(xq<span class="operator">.</span>fileName()));
<span class="type"><a href="qxmlserializer.html">QXmlSerializer</a></span> serializer(query<span class="operator">,</span> myOutputDevice);
query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>serializer);
</pre>
<p>First construct a <a href="../qtcore/qfile.html">QFile</a> for the text file containing the <a href="xmlprocessing.html">XQuery</a> (<code>myquery.xq</code>). Then create an instance of <a href="qxmlquery.html">QXmlQuery</a> and call its <a href="qxmlquery.html#setQuery">setQuery()</a> function to load and parse the <a href="xmlprocessing.html">XQuery</a> file. Then create an <a href="qxmlserializer.html">XML serializer</a> to output the query's result set as unformatted XML. Finally, call the <a href="qxmlquery.html#evaluateTo">evaluateTo()</a> function to evaluate the query and serialize the results as XML.</p>
<p><b>Note: </b>If you compile Qt yourself, the Qt XML Patterns module will <i>not</i> be built if exceptions are disabled, or if you compile Qt with a compiler that doesn't support member templates, e.g., MSVC 6.</p><p>See the <a href="qxmlquery.html">QXmlQuery</a> documentation for more information about the Qt XML Patterns C++ API.</p>
<a name="running-the-query-engine-from-the-command-line-utility"></a>
<h3 >Running the query engine from the command line utility</h3>
<p><i>xmlpatterns</i> is a command line utility for running XQueries. It expects the name of a file containing the <a href="xmlprocessing.html">XQuery</a> text.</p>
<pre class="cpp">
xmlpatterns myQuery<span class="operator">.</span>xq
</pre>
<p>The <a href="xmlprocessing.html">XQuery</a> in <code>myQuery.xq</code> will be evaluated and its output written to <code>stdout</code>. Pass the <code>-help</code> switch to get the list of input flags and their meanings.</p>
<p>xmlpatterns can be used in scripting. However, the descriptions and messages it outputs were not meant to be parsed and may be changed in future releases of Qt.</p>
<a name="qtxdm"></a><a name="the-xquery-data-model"></a>
<h2 id="the-xquery-data-model">The XQuery Data Model</h2>
<p><a href="xmlprocessing.html">XQuery</a> represents data items as <i>atomic values</i> or <i>nodes</i>. An atomic value is a value in the domain of one of the <a href="http://www.w3.org/TR/xmlschema-2/#built-in-datatypes">built-in datatypes</a> defined in <a href="http://www.w3.org/TR/xmlschema-2">Part 2</a> of the W3C XML Schema. A node is normally an XML element or attribute, but when non-XML data is <a href="qabstractxmlnodemodel.html">modeled to look like XML</a>, a node can also represent a non-XML data items.</p>
<p>When you run an <a href="xmlprocessing.html">XQuery</a> using the C++ API in a Qt application, you will often want to bind program variables to $variables in the <a href="xmlprocessing.html">XQuery</a>. After the query is evaluated, you will want to interpret the sequence of data items in the result set.</p>
<a name="binding-program-variables-to-xquery-variables"></a>
<h3 >Binding program variables to XQuery variables</h3>
<p>When you want to run a parameterized <a href="xmlprocessing.html">XQuery</a> from your Qt application, you will need to <a href="qxmlquery.html#bindVariable">bind variables</a> in your program to $name variables in your <a href="xmlprocessing.html">XQuery</a>.</p>
<p>Suppose you want to parameterize the bibliography <a href="xmlprocessing.html">XQuery</a> in the example above. You could define variables for the catalog that contains the library (<code>$file</code>), the publisher name (<code>$publisher</code>), and the year of publication (<code>$year</code>):</p>
<a name="qtxmlpatterns-example-query2"></a><pre class="cpp">
<bibliography>
{
doc($file)/bib/book[publisher = $publisher and @year > $year]/<book year="{@year}">{title}</book>
}
</bibliography>
</pre>
<p>Modify the Qt XML Patterns code to use one of the <a href="qxmlquery.html#bindVariable">bindVariable()</a> functions to bind a program variable to each <a href="xmlprocessing.html">XQuery</a> $variable:</p>
<pre class="cpp">
<span class="type"><a href="../qtcore/qfile.html">QFile</a></span> xq(<span class="string">"myquery.xq"</span>);
<span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName(<span class="string">"the filename"</span>);
<span class="type"><a href="../qtcore/qstring.html">QString</a></span> publisherName(<span class="string">"the publisher"</span>);
<span class="type"><a href="../qtcore/qtglobal.html#qlonglong-typedef">qlonglong</a></span> year <span class="operator">=</span> <span class="number">1234</span>;
<span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
query<span class="operator">.</span>bindVariable(<span class="string">"file"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(fileName));
query<span class="operator">.</span>bindVariable(<span class="string">"publisher"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(publisherName));
query<span class="operator">.</span>bindVariable(<span class="string">"year"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(year));
query<span class="operator">.</span>setQuery(<span class="operator">&</span>xq<span class="operator">,</span> <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(xq<span class="operator">.</span>fileName()));
<span class="type"><a href="qxmlserializer.html">QXmlSerializer</a></span> serializer(query<span class="operator">,</span> myOutputDevice);
query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>serializer);
</pre>
<p>Each program variable is passed to Qt XML Patterns as a <a href="../qtcore/qvariant.html">QVariant</a> of the type of the C++ variable or constant from which it is constructed. Note that Qt XML Patterns assumes that the type of the <a href="../qtcore/qvariant.html">QVariant</a> in the bindVariable() call is the correct type, so the $variable it is bound to must be used in the <a href="xmlprocessing.html">XQuery</a> accordingly. The following table shows how <a href="../qtcore/qvariant.html">QVariant</a> types are mapped to <a href="xmlprocessing.html">XQuery</a> $variable types:</p>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th ><a href="../qtcore/qvariant.html">QVariant</a> type</th><th ><a href="xmlprocessing.html">XQuery</a> $variable type</th></tr></thead>
<tr valign="top" class="odd"><td >QVariant::LongLong</td><td ><code>xs:integer</code></td></tr>
<tr valign="top" class="even"><td >QVariant::Int</td><td ><code>xs:integer</code></td></tr>
<tr valign="top" class="odd"><td >QVariant::UInt</td><td ><code>xs:nonNegativeInteger</code></td></tr>
<tr valign="top" class="even"><td >QVariant::ULongLong</td><td ><code>xs:unsignedLong</code></td></tr>
<tr valign="top" class="odd"><td >QVariant::String</td><td ><code>xs:string</code></td></tr>
<tr valign="top" class="even"><td >QVariant::Double</td><td ><code>xs:double</code></td></tr>
<tr valign="top" class="odd"><td >QVariant::Bool</td><td ><code>xs:boolean</code></td></tr>
<tr valign="top" class="even"><td >QVariant::Double</td><td ><code>xs:decimal</code></td></tr>
<tr valign="top" class="odd"><td >QVariant::ByteArray</td><td ><code>xs:base64Binary</code></td></tr>
<tr valign="top" class="even"><td >QVariant::StringList</td><td ><code>xs:string*</code></td></tr>
<tr valign="top" class="odd"><td >QVariant::Url</td><td ><code>xs:string</code></td></tr>
<tr valign="top" class="even"><td >QVariant::Date</td><td ><code>xs:date</code>.</td></tr>
<tr valign="top" class="odd"><td >QVariant::DateTime</td><td ><code>xs:dateTime</code></td></tr>
<tr valign="top" class="even"><td >QVariant::Time.</td><td ><code>xs:time</code>. (see <a href="xmlprocessing.html#binding-to-time">Binding To QVariant::Time</a> below)</td></tr>
<tr valign="top" class="odd"><td ><a href="../qtcore/qvariant.html#QVariantList-typedef">QVariantList</a></td><td >(see <a href="xmlprocessing.html#binding-to-qvariantlist">Binding To QVariantList</a> below)</td></tr>
</table></div>
<p>A type not shown in the table is not supported and will cause undefined <a href="xmlprocessing.html">XQuery</a> behavior or a $variable binding error, depending on the context in the <a href="xmlprocessing.html">XQuery</a> where the variable is used.</p>
<a name="binding-to-time"></a><a name="binding-to-qvariant-time"></a>
<h4 >Binding To QVariant::Time</h4>
<p>Because the instance of <a href="../qtcore/qtime.html">QTime</a> used in QVariant::Time does not include a zone offset, an instance of QVariant::Time should not be bound to an <a href="xmlprocessing.html">XQuery</a> variable of type <code>xs:time</code>, unless the <a href="../qtcore/qtime.html">QTime</a> is UTC. When binding a non-UTC <a href="../qtcore/qtime.html">QTime</a> to an <a href="xmlprocessing.html">XQuery</a> variable, it should first be passed as a string, or converted to a <a href="../qtcore/qdatetime.html">QDateTime</a> with an arbitrary date, and then bound to an <a href="xmlprocessing.html">XQuery</a> variable of type <code>xs:dateTime</code>.</p>
<a name="binding-to-qvariantlist"></a><a name="binding-to-qvariantlist"></a>
<h4 >Binding To QVariantList</h4>
<p>A <a href="../qtcore/qvariant.html#QVariantList-typedef">QVariantList</a> can be bound to an <a href="xmlprocessing.html">XQuery</a> $variable. All the <a href="../qtcore/qvariant.html">QVariant</a>s in the list must be of the same atomic type, and the $variable the variant list is bound to must be of that same atomic type. If the QVariants in the list are not all of the same atomic type, the <a href="xmlprocessing.html">XQuery</a> behavior is undefined.</p>
<a name="interpreting-xquery-results"></a>
<h3 >Interpreting XQuery results</h3>
<p>When the results of an <a href="xmlprocessing.html">XQuery</a> are returned in a sequence of <a href="qxmlresultitems.html">result items</a>, atomic values in the sequence are treated as instances of <a href="../qtcore/qvariant.html">QVariant</a>. Suppose that instead of serializing the results of the <a href="xmlprocessing.html">XQuery</a> as XML, we process the results programatically. Modify the standard Qt XML Patterns code sequence to call the overload of <a href="qxmlquery.html#evaluateTo">QXmlQuery::evaluateTo</a>() that populates a sequence of <a href="qxmlresultitems.html">result items</a> with the <a href="xmlprocessing.html">XQuery</a> results:</p>
<pre class="cpp">
<span class="type"><a href="../qtcore/qfile.html">QFile</a></span> xq(<span class="string">"myquery.xq"</span>);
<span class="type"><a href="../qtcore/qstring.html">QString</a></span> fileName(<span class="string">"the filename"</span>);
<span class="type"><a href="../qtcore/qstring.html">QString</a></span> publisherName(<span class="string">"the publisher"</span>);
<span class="type"><a href="../qtcore/qtglobal.html#qlonglong-typedef">qlonglong</a></span> year <span class="operator">=</span> <span class="number">1234</span>;
<span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
query<span class="operator">.</span>bindVariable(<span class="string">"file"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(fileName));
query<span class="operator">.</span>bindVariable(<span class="string">"publisher"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(publisherName));
query<span class="operator">.</span>bindVariable(<span class="string">"year"</span><span class="operator">,</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span>(year));
query<span class="operator">.</span>setQuery(<span class="operator">&</span>xq<span class="operator">,</span> <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(xq<span class="operator">.</span>fileName()));
<span class="type"><a href="qxmlresultitems.html">QXmlResultItems</a></span> result;
query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>result);
<span class="type"><a href="qxmlitem.html">QXmlItem</a></span> item(result<span class="operator">.</span>next());
<span class="keyword">while</span> (<span class="operator">!</span>item<span class="operator">.</span>isNull()) {
<span class="keyword">if</span> (item<span class="operator">.</span>isAtomicValue()) {
<span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> v <span class="operator">=</span> item<span class="operator">.</span>toAtomicValue();
<span class="keyword">switch</span> (v<span class="operator">.</span>type()) {
<span class="keyword">case</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span><span class="operator">::</span>LongLong:
<span class="comment">// xs:integer</span>
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span><span class="operator">::</span>String:
<span class="comment">// xs:string</span>
<span class="keyword">break</span>;
<span class="keyword">default</span>:
<span class="comment">// error</span>
<span class="keyword">break</span>;
}
}
<span class="keyword">else</span> <span class="keyword">if</span> (item<span class="operator">.</span>isNode()) {
<span class="preprocessor">#ifdef qdoc</span>
<span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> i <span class="operator">=</span> item<span class="operator">.</span>toNodeModelIndex();
<span class="comment">// process node</span>
<span class="preprocessor">#endif // qdoc</span>
}
item <span class="operator">=</span> result<span class="operator">.</span>next();
}
</pre>
<p>Iterate through the <a href="qxmlresultitems.html">result items</a> and test each <a href="qxmlitem.html">QXmlItem</a> to see if it is an atomic value or a node. If it is an atomic value, convert it to a <a href="../qtcore/qvariant.html">QVariant</a> with <a href="qxmlitem.html#toAtomicValue">toAtomicValue()</a> and switch on its <a href="../qtcore/qvariant.html#type">variant type</a> to handle all the atomic values your <a href="xmlprocessing.html">XQuery</a> might return. The following table shows the <a href="../qtcore/qvariant.html">QVariant</a> type to expect for each atomic value type (or <a href="qxmlname.html">QXmlName</a>):</p>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th ><a href="xmlprocessing.html">XQuery</a> result item type</th><th ><a href="../qtcore/qvariant.html">QVariant</a> type returned</th></tr></thead>
<tr valign="top" class="odd"><td ><code>xs:QName</code></td><td ><a href="qxmlname.html">QXmlName</a> (see <a href="xmlprocessing.html#handling-qxmlnames">Handling QXmlNames</a> below)</td></tr>
<tr valign="top" class="even"><td ><code>xs:integer</code></td><td >QVariant::LongLong</td></tr>
<tr valign="top" class="odd"><td ><code>xs:string</code></td><td >QVariant::String</td></tr>
<tr valign="top" class="even"><td ><code>xs:string*</code></td><td >QVariant::StringList</td></tr>
<tr valign="top" class="odd"><td ><code>xs:double</code></td><td >QVariant::Double</td></tr>
<tr valign="top" class="even"><td ><code>xs:float</code></td><td >QVariant::Double</td></tr>
<tr valign="top" class="odd"><td ><code>xs:boolean</code></td><td >QVariant::Bool</td></tr>
<tr valign="top" class="even"><td ><code>xs:decimal</code></td><td >QVariant::Double</td></tr>
<tr valign="top" class="odd"><td ><code>xs:hexBinary</code></td><td >QVariant::ByteArray</td></tr>
<tr valign="top" class="even"><td ><code>xs:base64Binary</code></td><td >QVariant::ByteArray</td></tr>
<tr valign="top" class="odd"><td ><code>xs:gYear</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="even"><td ><code>xs:gYearMonth</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="odd"><td ><code>xs:gMonthDay</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="even"><td ><code>xs:gDay</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="odd"><td ><code>xs:gMonth</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="even"><td ><code>xs:anyURI</code></td><td >QVariant::Url</td></tr>
<tr valign="top" class="odd"><td ><code>xs:untypedAtomic</code></td><td >QVariant::String</td></tr>
<tr valign="top" class="even"><td ><code>xs:ENTITY</code></td><td >QVariant::String</td></tr>
<tr valign="top" class="odd"><td ><code>xs:date</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="even"><td ><code>xs:dateTime</code></td><td >QVariant::DateTime</td></tr>
<tr valign="top" class="odd"><td ><code>xs:time</code></td><td >(see <a href="xmlprocessing.html#xstime-not-mapped">No mapping for xs:time</a> below)</td></tr>
</table></div>
<a name="handling-qxmlnames"></a><a name="handling-qxmlnames"></a>
<h4 >Handling QXmlNames</h4>
<p>If your <a href="xmlprocessing.html">XQuery</a> can return atomic value items of type <code>xs:QName</code>, they will appear in your <a href="qxmlresultitems.html">QXmlResultItems</a> as instances of <a href="qxmlname.html">QXmlName</a>. Since the <a href="../qtcore/qvariant.html">QVariant</a> class does not support the <a href="qxmlname.html">QXmlName</a> class directly, extracting them from <a href="qxmlresultitems.html">QXmlResultItems</a> requires a bit of slight-of-hand using the <a href="../qtcore/qmetatype.html">Qt metatype system</a>. We must modify our example to use a couple of template functions, a friend of <a href="../qtcore/qmetatype.html">QMetaType</a> (<a href="../qtcore/qmetatype.html#qMetaTypeId">qMetaTypeId</a><T>()) and a friend of <a href="../qtcore/qvariant.html">QVariant</a> (<a href="../qtcore/qvariant.html#qvariant_cast">qvariant_cast</a><T>()):</p>
<pre class="cpp">
<span class="type"><a href="../qtcore/qfile.html">QFile</a></span> xq(<span class="string">"myquery.xq"</span>);
<span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
query<span class="operator">.</span>setQuery(<span class="operator">&</span>xq<span class="operator">,</span> <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(xq<span class="operator">.</span>fileName()));
<span class="type"><a href="qxmlresultitems.html">QXmlResultItems</a></span> result;
query<span class="operator">.</span>evaluateTo(<span class="operator">&</span>result);
<span class="type"><a href="qxmlitem.html">QXmlItem</a></span> item(result<span class="operator">.</span>next());
<span class="keyword">while</span> (<span class="operator">!</span>item<span class="operator">.</span>isNull()) {
<span class="keyword">if</span> (item<span class="operator">.</span>isAtomicValue()) {
<span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> v <span class="operator">=</span> item<span class="operator">.</span>toAtomicValue();
<span class="keyword">switch</span> (v<span class="operator">.</span>type()) {
<span class="keyword">case</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span><span class="operator">::</span>LongLong:
<span class="comment">// xs:integer</span>
<span class="keyword">break</span>;
<span class="keyword">case</span> <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span><span class="operator">::</span>String:
<span class="comment">// xs:string</span>
<span class="keyword">break</span>;
<span class="keyword">default</span>:
<span class="keyword">if</span> (v<span class="operator">.</span>userType() <span class="operator">=</span><span class="operator">=</span> <a href="../qtcore/qmetatype.html#qMetaTypeId">qMetaTypeId</a><span class="operator"><</span><span class="type"><a href="qxmlname.html">QXmlName</a></span><span class="operator">></span>()) {
<span class="preprocessor">#ifdef qdoc</span>
<span class="type"><a href="qxmlname.html">QXmlName</a></span> n <span class="operator">=</span> qvariant_cast<span class="operator"><</span><span class="type"><a href="qxmlname.html">QXmlName</a></span><span class="operator">></span>(v);
<span class="comment">// process QXmlName n...</span>
<span class="preprocessor">#endif // qdoc</span>
}
<span class="keyword">else</span> {
<span class="comment">// error</span>
}
<span class="keyword">break</span>;
}
}
<span class="keyword">else</span> <span class="keyword">if</span> (item<span class="operator">.</span>isNode()) {
<span class="preprocessor">#ifdef qdoc</span>
<span class="type"><a href="qxmlnodemodelindex.html">QXmlNodeModelIndex</a></span> i <span class="operator">=</span> item<span class="operator">.</span>toNodeModelIndex();
<span class="comment">// process node</span>
<span class="preprocessor">#endif // qdoc</span>
}
item <span class="operator">=</span> result<span class="operator">.</span>next();
}
</pre>
<p>To access the strings in a <a href="qxmlname.html">QXmlName</a> returned by an <a href="qxmlquery.html#evaluateTo">XQuery evaluation</a>, the <a href="qxmlname.html">QXmlName</a> must be accessed with the <a href="qxmlnamepool.html">name pool</a> from the instance of <a href="qxmlquery.html">QXmlQuery</a> that was used for the evaluation.</p>
<a name="xstime-not-mapped"></a><a name="no-mapping-for-xs-time"></a>
<h4 >No mapping for xs:time</h4>
<p>An instance of <code>xs:time</code> can't be represented correctly as an instance of QVariant::Time, unless the <code>xs:time</code> is a UTC time. This is because xs:time has a zone offset (0 for UTC) in addition to the time value, which the <a href="../qtcore/qtime.html">QTime</a> in QVariant::Time does not have. This means that if an <a href="xmlprocessing.html">XQuery</a> tries to return an atomic value of type <code>xs:time</code>, an invalid <a href="../qtcore/qvariant.html">QVariant</a> will be returned. A query can return an atomic value of type xs:time by either converting it to an <code>xs:dateTime</code> with an arbitrary date, or to an <code>xs:string</code>.</p>
<a name="using-xquery-with-non-xml-data"></a>
<h2 id="using-xquery-with-non-xml-data">Using XQuery with Non-XML Data</h2>
<p>Although the <a href="xmlprocessing.html">XQuery</a> language was designed for querying XML, with Qt XML Patterns one can use <a href="xmlprocessing.html">XQuery</a> for querying any data that can be modeled to look like XML. Non-XML data is modeled to look like XML by loading it into a custom subclass of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>, where it is then presented to the Qt XML Patterns <a href="xmlprocessing.html">XQuery</a> engine via the same API the <a href="xmlprocessing.html">XQuery</a> engine uses for querying XML.</p>
<p>When Qt XML Patterns loads and queries XML files and produces XML output, it can always load the XML data into its default XML node model, where it can be traversed efficiently. The <a href="xmlprocessing.html">XQuery</a> below traverses the product orders found in the XML file <i>myOrders.xml</i> to find all the skin care product orders and output them ordered by shipping date.</p>
<pre class="cpp">
<result>
<para>The following skin care products have shipped, ordered by shipping date(oldest first):</para>
{
for $i in doc("myOrders.xml")/orders/order[@product = "Acme Skin Care"]
order by xs:date($i/@shippingDate) descending
return $i
}
</result>
</pre>
<p>Qt XML Patterns can be used out of the box to perform this query, provided <i>myOrders.xml</i> actually contains well-formed XML. It can be loaded directly into the default XML node model and traversed. But suppose we want Qt XML Patterns to perform queries on the hierarchical structure of the local file system. The default XML node model in Qt XML Patterns is not suitable for navigating the file system, because there is no XML file to load that contains a description of it. Such an XML file, if it existed, might look something like this:</p>
<pre class="cpp">
<?xml version="1.0" encoding="UTF-8"?>
<directory name="home">
<file name="myNote.txt" mimetype="text/plain" size="8" extension="txt" uri="file:///home/frans/myNote.txt">
<content asBase64Binary="TXkgTm90ZSE=" asStringFromUTF-8="My Note!"/>
</file>
<directory name="src">
...
</directory>
...
</directory>
</pre>
<p>The <a href="qtxmlpatterns-filetree-example.html">File System Example</a> does exactly this.</p>
<p>There is no such file to load into the default XML node model, but one can write a subclass of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> to represent the file system. This custom XML node model, once populated with all the directory and file descriptors obtained directly from the system, presents the complete file system hierarchy to the query engine via the same API used by the default XML node model to present the contents of an XML file. In other words, once the custom XML node model is populated, it presents the file system to the query engine as if a description of it had been loaded into the default XML node model from an XML file like the one shown above.</p>
<p>Now we can write an <a href="xmlprocessing.html">XQuery</a> to find all the XML files and parse them to find the ones that don't contain well-formed XML.</p>
<pre class="qml">
<html>
<body>
{
$myRoot//file[@mimetype = 'text/xml' or @mimetype = 'application/xml']
/
(if(doc-available(@uri))
then ()
else <p>Failed to parse file {@uri}.</p>)
}
</body>
</html>
</pre>
<p>Without Qt XML Patterns, there is no simple way to solve this kind of problem. You might do it by writing a C++ program to traverse the file system, sniff out all the XML files, and submit each one to an XML parser to test that it contains valid XML. The C++ code required to write that program will probably be more complex than the C++ code required to subclass <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>, but even if the two are comparable, your custom C++ program can be used only for that one task, while your custom XML node model can be used by any <a href="xmlprocessing.html">XQuery</a> that must navigate the file system.</p>
<p>The general approach to using <a href="xmlprocessing.html">XQuery</a> to perform queries on non-XML data has been a three step process. In the first step, the data is loaded into a non-XML data model. In the second step, the non-XML data model is serialized as XML and output to XML (text) files. In the final step, an XML tool loads the XML files into a second, XML data model, where the XQueries can be performed. The development cost of implementing this process is often high, and the three step system that results is inefficient because the two data models must be built and maintained separately.</p>
<p>With Qt XML Patterns, subclassing <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> eliminates the transformation required to convert the non-XML data model to the XML data model, because there is only ever one data model required. The non-XML data model presents the non-XML data to the query engine via the XML data model API. Also, since the query engine uses the API to access the <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a>, the data model subclass can construct the elements, attributes and other data on demand, responding to the query's specific requests. This can greatly improve efficiency, because it means the entire model might not have to be built. For example, in the file system model above, it is not necessary to build an instance for a whole XML file representing the whole file system. Instead nodes are created on demand, which also likely is a small subset of the file system.</p>
<p>Examples of other places where <a href="xmlprocessing.html">XQuery</a> could be used in Qt XML Patterns to query non-XML data:</p>
<ul>
<li>The internal representation for word processor documents</li>
<li>The set of dependencies for a software build system</li>
<li>The hierarchy (or graph) that links a set of HTML documents from a web crawler</li>
<li>The images and meta-data in an image collection</li>
<li>The set of D-Bus interfaces available in a system</li>
<li>A <a href="../qtcore/qobject.html">QObject</a> hierarchy.</li>
</ul>
<p>See the <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> documentation for information about how to implement custom XML node models.</p>
<a name="more-on-using-qt-xml-patterns-with-non-xml-data"></a>
<h2 id="more-on-using-qt-xml-patterns-with-non-xml-data">More on Using Qt XML Patterns with Non-XML Data</h2>
<p>Subclassing <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> to let the query engine access non-XML data by the same API it uses for XML is the feature that enables Qt XML Patterns to query non-XML data with <a href="xmlprocessing.html">XQuery</a>. It allows <a href="xmlprocessing.html">XQuery</a> to be used as a mapping layer between different non-XML node models or between a non-XML node model and the built-in XML node model. Once the subclass(es) of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> have been written, <a href="xmlprocessing.html">XQuery</a> can be used to select a set of elements from one node model, transform the selected elements, and then write them out, either as XML using <a href="qxmlquery.html#evaluateTo">QXmlQuery::evaluateTo</a>() and <a href="qxmlserializer.html">QXmlSerializer</a>, or as some other format using a subclass of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a>.</p>
<p>Consider a word processor application that must import and export data in several different formats. Rather than writing a lot of C++ code to convert each input format to an intermediate form, and more C++ code to convert the intermediate form back to each output format, one can implement a solution based on Qt XML Patterns that uses simple XQueries to transform each XML or non-XML format (e.g. MathFormula.xml below) to the intermediate form (e.g. the DocumentRepresentation node model class below), and more simple XQueries to transform the intermediate form back to each XML or non-XML format.</p>
<p class="centerAlign"><img src="images/patternist-wordProcessor.png" alt="" /></p><p>Because CSV files are not XML, a subclass of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> is used to present the CSV data to the <a href="xmlprocessing.html">XQuery</a> engine as if it were XML. What are not shown are the subclasses of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> that would then send the selected elements into the DocumentRepresentation node model, and the subclasses of <a href="qabstractxmlnodemodel.html">QAbstractXmlNodeModel</a> that would ultimately write the output files in each format.</p>
<a name="security-considerations"></a>
<h2 id="security-considerations">Security Considerations</h2>
<a name="code-injection"></a>
<h3 >Code Injection</h3>
<p><a href="xmlprocessing.html">XQuery</a> is vulnerable to <a href="http://en.wikipedia.org/wiki/Code_injection">code injection attacks</a> in the same way as the SQL language. If an <a href="xmlprocessing.html">XQuery</a> is constructed by concatenating strings, and the strings come from user input, the constructed <a href="xmlprocessing.html">XQuery</a> could be malevolent. The best way to prevent code injection attacks is to not construct XQueries from user-written strings, but only accept user data input using <a href="../qtcore/qvariant.html">QVariant</a> and variable bindings. See <a href="qxmlquery.html#bindVariable">QXmlQuery::bindVariable</a>().</p>
<p>The articles <a href="http://www.ibm.com/developerworks/xml/library/x-xpathinjection.html">Avoid the dangers of XPath injection</a>, by Robi Sen and <a href="http://www.packetstormsecurity.org/papers/bypass/Blind_XPath_Injection_20040518.pdf">Blind XPath Injection</a>, by Amit Klein, discuss the <a href="xmlprocessing.html">XQuery</a> code injection problem in more detail.</p>
<a name="denial-of-service-attacks"></a>
<h3 >Denial of Service Attacks</h3>
<p>Applications using Qt XML Patterns are subject to the same limitations of software as other systems. Generally, these can not be checked. This means Qt XML Patterns does not prevent rogue queries from consuming too many resources. For example, a query could take too much time to execute or try to transfer too much data. A query could also do too much recursion, which could crash the system. XQueries can do these things accidentally, but they can also be done as deliberate denial of service attacks.</p>
<a name="features-and-conformance"></a>
<h2 id="features-and-conformance">Features and Conformance</h2>
<a name="xquery-1-0"></a>
<h3 >XQuery 1.0</h3>
<p>Qt XML Patterns aims at being a <a href="http://www.w3.org/TR/xquery/#id-xquery-conformance">conformant XQuery processor</a>. It adheres to <a href="http://www.w3.org/TR/xquery/#id-minimal-conformance">Minimal Conformance</a> and supports the <a href="http://www.w3.org/TR/xquery/#id-serialization-feature">Serialization Feature</a> and the <a href="http://www.w3.org/TR/xquery/#id-full-axis-feature">Full Axis Feature</a>. Qt XML Patterns currently passes 97% of the tests in the <a href="http://www.w3.org/XML/Query/test-suite">XML Query Test Suite</a>. Areas where conformance may be questionable and where behavior may be changed in future releases include:</p>
<ul>
<li>Some corner cases involving namespaces and element constructors are incorrect.</li>
<li>XPath is a subset of <a href="xmlprocessing.html">XQuery</a> and the implementation of Qt XML Patterns uses XPath 2.0 with <a href="xmlprocessing.html">XQuery</a> 1.0.</li>
</ul>
<p>The specifications discusses conformance further: <a href="http://www.w3.org/TR/xquery/">XQuery 1.0: An XML Query Language</a>. W3C's <a href="xmlprocessing.html">XQuery</a> testing effort can be of interest as well, <a href="http://www.w3.org/XML/Query/test-suite/">XML Query Test Suite</a>.</p>
<p>Currently <code>fn:collection()</code> does not access any data set, and there is no API for providing data through the collection. As a result, evaluating <code>fn:collection()</code> returns the empty sequence. We intend to provide functionality for this in a future release of Qt.</p>
<p>Only queries encoded in UTF-8 are supported.</p>
<a name="xslt-2-0"></a>
<h3 >XSLT 2.0</h3>
<p>Partial support for XSLT was introduced in Qt 4.5. Future releases of Qt XML Patterns will aim to support these XSLT features:</p>
<ul>
<li>Basic XSLT 2.0 processor</li>
<li>Serialization feature</li>
<li>Backwards Compatibility feature</li>
</ul>
<p>For details, see <a href="http://www.w3.org/TR/xslt20/#conformance">XSL Transformations (XSLT) Version 2.0, 21 Conformance</a>.</p>
<p><b>Note: </b>In this release, XSLT support is considered experimental.</p><p>Unsupported or partially supported XSLT features are documented in the following table. The implementation of XSLT in Qt 4.5 can be seen as XSLT 1.0 but with the data model of XPath 2.0 and XSLT 2.0, and using the using the functionality of XPath 2.0 and its accompanying function library. When Qt XML Patterns encounters an unsupported or partially support feature, it will either report a syntax error or silently continue, unless otherwise noted in the table.</p>
<p>The implementation currently passes 42% of W3C's XSLT test suite, which focus on features introduced in XSLT 2.0.</p>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th >XSL Feature</th><th >Support Status</th></tr></thead>
<tr valign="top" class="odd"><td ><code>xsl:key</code> and <code>fn:key()</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:include</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:import</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:copy</code></td><td >The <code>copy-namespaces</code> and <code>inherit-namespaces</code> attributes have no effect. For copied comments, attributes and processing instructions, the copy has the same node identity as the original.</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:copy-of</code></td><td >The <code>copy-namespaces</code> attribute has no effect.</td></tr>
<tr valign="top" class="even"><td ><code>fn:format-number()</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:message</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:use-when</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>Tunnel</code> Parameters</td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:attribute-set</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:decimal-format</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:fallback</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:apply-imports</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:character-map</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:number</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:namespace-alias</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:output</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:output-character</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td ><code>xsl:preserve-space</code></td><td >not supported</td></tr>
<tr valign="top" class="even"><td ><code>xsl:result-document</code></td><td >not supported</td></tr>
<tr valign="top" class="odd"><td >Patterns</td><td >Complex patterns or patterns with predicates have issues.</td></tr>
<tr valign="top" class="even"><td ><code>2.0</code> Compatibility Mode</td><td >Stylesheets are interpreted as XSLT 2.0 stylesheets, even if the <code>version</code> attribute is in the XSLT source is 1.0. In other words, the version attribute is ignored.</td></tr>
<tr valign="top" class="odd"><td >Grouping</td><td ><code>fn:current-group()</code>, <code>fn:grouping-key()</code> and <code>xsl:for-each-group</code>.</td></tr>
<tr valign="top" class="even"><td >Regexp elements</td><td ><code>xsl:analyze-string</code>, <code>xsl:matching-substring</code>, <code>xsl:non-matching-substring</code>, and <code>fn:regex-group()</code></td></tr>
<tr valign="top" class="odd"><td >Date & Time formatting</td><td ><code>fn:format-dateTime()</code>, <code>fn:format-date()</code> and fn:format-time().</td></tr>
<tr valign="top" class="even"><td >XPath Conformance</td><td >Since XPath is a subset of XSLT, its issues are in affect too.</td></tr>
</table></div>
<p>The Qt XML Patterns implementation of the XPath Data Model does not include entities (due to <a href="../qtcore/qxmlstreamreader.html">QXmlStreamReader</a> not reporting them). This means that functions <code>unparsed-entity-uri()</code> and <code>unparsed-entity-public-id()</code> always return negatively.</p>
<a name="xpath-2-0"></a>
<h3 >XPath 2.0</h3>
<p>Since XPath 2.0 is a subset of <a href="xmlprocessing.html">XQuery</a> 1.0, XPath 2.0 is supported. Areas where conformance may be questionable and, consequently, where behavior may be changed in future releases include:</p>
<ul>
<li>Regular expression support is currently not conformant but follows Qt's <a href="../qtcore/qregexp.html">QRegExp</a> standard syntax.</li>
<li>Operators for <code>xs:time</code>, <code>xs:date</code>, and <code>xs:dateTime</code> are incomplete.</li>
<li>Formatting of very large or very small <code>xs:double</code>, <code>xs:float</code>, and <code>xs:decimal</code> values may be incorrect.</li>
</ul>
<a name="xml-id"></a>
<h3 >xml:id</h3>
<p>Processing of XML files supports <code>xml:id</code>. This allows elements that have an attribute named <code>xml:id</code> to be looked up efficiently with the <code>fn:id()</code> function. See <a href="http://www.w3.org/TR/xml-id/">xml:id Version 1.0</a> for details.</p>
<a name="xml-schema-1-0"></a>
<h3 >XML Schema 1.0</h3>
<p>There are two ways Qt XML Patterns can be used to validate schemas: You can use the C++ API in your Qt application using the classes <a href="qxmlschema.html">QXmlSchema</a> and <a href="qxmlschemavalidator.html">QXmlSchemaValidator</a>, or you can use the command line utility named xmlpatternsvalidator (located in the "bin" directory of your Qt build).</p>
<p>The Qt XML Patterns implementation of XML Schema validation supports the schema specification version 1.0 in large parts. Known problems of the implementation and areas where conformancy may be questionable are:</p>
<ul>
<li>Large <code>minOccurs</code> or <code>maxOccurs</code> values or deeply nested ones require huge amount of memory which might cause the system to freeze. Such a schema should be rewritten to use <code>unbounded</code> as value instead of large numbers. This restriction will hopefully be fixed in a later release.</li>
<li>Comparison of really small or large floating point values might lead to wrong results in some cases. However such numbers should not be relevant for day-to-day usage.</li>
<li>Regular expression support is currently not conformant but follows Qt's <a href="../qtcore/qregexp.html">QRegExp</a> standard syntax.</li>
<li>Identity constraint checks can not use the values of default or fixed attribute definitions.</li>
</ul>
<a name="resource-loading"></a>
<h3 >Resource Loading</h3>
<p>When Qt XML Patterns loads an XML resource, e.g., using the <code>fn:doc()</code> function, the following schemes are supported:</p>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th >Scheme Name</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>file</code></td><td >Local files.</td></tr>
<tr valign="top" class="even"><td ><code>data</code></td><td >The bytes are encoded in the URI itself. e.g., <code>data:application/xml,%3Ce%2F%3E</code> is <code><e/></code>.</td></tr>
<tr valign="top" class="odd"><td ><code>ftp</code></td><td >Resources retrieved via FTP.</td></tr>
<tr valign="top" class="even"><td ><code>http</code></td><td >Resources retrieved via HTTP.</td></tr>
<tr valign="top" class="odd"><td ><code>https</code></td><td >Resources retrieved via HTTPS. This will succeed if no SSL errors are encountered.</td></tr>
<tr valign="top" class="even"><td ><code>qrc</code></td><td >Qt Resource files. Expressing it as an empty scheme, :/..., is not supported.</td></tr>
</table></div>
<a name="xml"></a>
<h3 >XML</h3>
<p>XML 1.0 and XML Namespaces 1.0 are supported, as opposed to the 1.1 versions. When a strings is passed to a query as a <a href="../qtcore/qstring.html">QString</a>, the characters must be XML 1.0 characters. Otherwise, the behavior is undefined. This is not checked.</p>
<p>URIs are first passed to <a href="qabstracturiresolver.html">QAbstractUriResolver</a>. Check <a href="qxmlquery.html#setUriResolver">QXmlQuery::setUriResolver</a>() for possible rewrites.</p>
</div>
<!-- @@@xmlprocessing.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="../qtxml/xml-dom-tml.html">Working with the DOM Tree</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2016 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
| angeloprudentino/QtNets | Doc/qtxmlpatterns/xmlprocessing.html | HTML | gpl-3.0 | 54,104 | [
30522,
1026,
1029,
20950,
2544,
1027,
1000,
1015,
1012,
1014,
1000,
17181,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1029,
1028,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
30524,
1013,
1028,
1026,
999,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { Injectable } from '@angular/core';
@Injectable()
export class JsonReferenceService {
constructor() { }
dereference<T>(obj: any, $ref: string): T {
if(!$ref.startsWith('#/')) {
console.warn('Invalid $ref. Only references to current document supported.', $ref);
return null;
}
let parts = $ref.substr(2).split('/');
for(let i = 0; i < parts.length; i++) {
obj = obj[parts[i]];
if(obj === undefined) return null;
}
return <T>obj;
}
}
| gislikonrad/swangular-components | src/app/swangular-components/services/json-reference.service.ts | TypeScript | unlicense | 498 | [
30522,
12324,
1063,
1999,
20614,
3085,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
1030,
1999,
20614,
3085,
1006,
1007,
9167,
2465,
1046,
3385,
2890,
25523,
8043,
7903,
2063,
1063,
9570,
2953,
1006,
1007,
1063,
1065,
4315,
27235,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>string rect</title>
</head>
<script type="text/javascript" src="string_rect.js"></script>
<body>
<div id="string_rect">js-string-rect A Simple Demo.</div>
<script type="text/javascript">
(function(doc) {
var rects = doc.getElementById("string_rect").retrieveStringRects();
for(var key in rects) {
var rect = rects[key].rect;
var mark = document.createElement("div");
mark.style.backgroundColor = (key % 2 == 0) ? "#ff0000" : "#0000ff";
mark.style.opacity = "0.5";
mark.style.position = "absolute";
mark.style.left = rect.left + "px";
mark.style.top = rect.top + "px";
mark.style.width = rect.right - rect.left + "px";
mark.style.height = rect.bottom - rect.top + "px";
doc.body.appendChild(mark);
}
})(document);
</script>
</body>
</html>
| mattatz/js-string-rect | sample.html | HTML | mit | 922 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
5164,
28667,
2102,
1026,
1013,
251... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Clinopodium calamintha (L.) Stace SPECIES
#### Status
ACCEPTED
#### According to
International Plant Names Index
#### Published in
null
#### Original name
Melissa calamintha L.
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Magnoliopsida/Lamiales/Lamiaceae/Clinopodium/Clinopodium calamintha/README.md | Markdown | apache-2.0 | 200 | [
30522,
1001,
18856,
5740,
27633,
5007,
10250,
10631,
3372,
3270,
1006,
1048,
1012,
1007,
2358,
10732,
2427,
1001,
1001,
1001,
1001,
3570,
3970,
1001,
1001,
1001,
1001,
2429,
2000,
2248,
3269,
3415,
5950,
1001,
1001,
1001,
1001,
2405,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!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' xml:lang='en' lang='en'><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<title>108-64-5.smi.png.html</title>
</head>
<body>ID108-64-5<br/>
<img border="0" src="108-64-5.smi.png" alt="108-64-5.smi.png"></img><br/>
<br/>
<table border="1">
<tr>
<td></td><td>ID</td><td>Formula</td><td>FW</td><td>DSSTox_CID</td><td>DSSTox_RID</td><td>DSSTox_GSID</td><td>DSSTox_FileID_Sort</td><td>TS_ChemName</td><td>TS_ChemName_Synonyms</td><td>TS_CASRN</td><td>CASRN_ChemName_Relationship</td><td>TS_Description</td><td>ChemNote</td><td>STRUCTURE_Shown</td><td>STRUCTURE_Formula</td><td>STRUCTURE_MW</td><td>STRUCTURE_ChemType</td><td>STRUCTURE_DefinedOrganicForm</td><td>STRUCTURE_IUPAC</td><td>STRUCTURE_SMILES</td><td>STRUCTURE_SMILES_Desalt</td><td>Substance_modify_yyyymmdd</td></tr>
<tr>
<td>108-64-5</td><td>12211</td><td>C7H14O2</td><td>130.1849</td><td>27057</td><td>82074</td><td>47057</td><td>6755</td><td>Ethyl isovalerate</td><td></td><td>108-64-5</td><td>primary</td><td>single chemical compound</td><td></td><td>tested chemical</td><td>C7H14O2</td><td>130.1849</td><td>defined organic</td><td>parent</td><td>ethyl 3-methylbutanoate</td><td>CC(C)CC(=O)OCC</td><td>CC(C)CC(=O)OCC</td><td>20100429</td></tr>
</table>
<br/><br/><font size="-2">(Page generated on Wed Sep 17 04:03:17 2014 by <a href="http://www.embl.de/~gpau/hwriter/index.html">hwriter</a> 1.3)</font><br/>
</body></html> | andrewdefries/ToxCast | Figure3/Tox21_nnm/WorkHere/108-64-5.smi.png.html | HTML | mit | 1,586 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.nosolojava.fsm.impl.runtime.executable.basic;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.nosolojava.fsm.runtime.Context;
import com.nosolojava.fsm.runtime.executable.Elif;
import com.nosolojava.fsm.runtime.executable.Else;
import com.nosolojava.fsm.runtime.executable.Executable;
import com.nosolojava.fsm.runtime.executable.If;
public class BasicIf extends BasicConditional implements If {
private static final long serialVersionUID = -415238773021486012L;
private final List<Elif> elifs = new ArrayList<Elif>();
private final Else elseOperation;
public BasicIf(String condition) {
this(condition, null, null, null);
}
public BasicIf(String condition, List<Executable> executables) {
this(condition, null, null, executables);
}
public BasicIf(String condition, Else elseOperation, List<Executable> executables) {
this(condition, null, elseOperation, executables);
}
public BasicIf(String condition, List<Elif> elifs, Else elseOperation, List<Executable> executables) {
super(condition, executables);
if (elifs != null) {
this.elifs.addAll(elifs);
}
this.elseOperation = elseOperation;
}
@Override
public boolean runIf(Context context) {
boolean result = false;
// if condition fails
if (super.runIf(context)) {
result = true;
} else {
// try with elifs
boolean enterElif = false;
Iterator<Elif> iterElif = elifs.iterator();
Elif elif;
while (!enterElif && iterElif.hasNext()) {
elif = iterElif.next();
enterElif = elif.runIf(context);
}
// if no elif and else
if (!enterElif && this.elseOperation != null) {
elseOperation.run(context);
}
}
return result;
}
public List<Elif> getElifs() {
return this.elifs;
}
public void addElif(Elif elif) {
this.elifs.add(elif);
}
public void addElifs(List<Elif> elifs) {
this.elifs.addAll(elifs);
}
public void clearAndSetElifs(List<Elif> elifs) {
this.elifs.clear();
addElifs(elifs);
}
}
| nosolojava/scxml-java | scxml-java-implementation/src/main/java/com/nosolojava/fsm/impl/runtime/executable/basic/BasicIf.java | Java | apache-2.0 | 2,082 | [
30522,
7427,
4012,
1012,
16839,
12898,
3900,
3567,
1012,
1042,
6491,
1012,
17727,
2140,
1012,
2448,
7292,
1012,
4654,
8586,
23056,
1012,
3937,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/bin/bash
# This script will build the project.
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
./gradlew build --stacktrace --info
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build snapshot
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
case "$TRAVIS_TAG" in
*-rc\.*)
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" candidate
;;
*)
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" final
;;
esac
else
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
./gradlew build
fi
| elandau/karyon | buildViaTravis.sh | Shell | apache-2.0 | 1,358 | [
30522,
1001,
999,
1013,
8026,
1013,
24234,
1001,
2023,
5896,
2097,
3857,
1996,
2622,
1012,
2065,
1031,
1000,
1002,
10001,
1035,
4139,
1035,
5227,
1000,
999,
1027,
1000,
6270,
1000,
1033,
1025,
2059,
9052,
1011,
1041,
1000,
3857,
4139,
522... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>elpi: Not compatible 👼</title>
<link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
<link href="../../../../../bootstrap.min.css" rel="stylesheet">
<link href="../../../../../bootstrap-custom.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="../../../../../moment.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../..">clean / released</a></li>
<li class="active"><a href="">8.5.1 / elpi - 1.12.1</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
elpi
<small>
1.12.1
<span class="label label-info">Not compatible 👼</span>
</small>
</h1>
<p>📅 <em><script>document.write(moment("2022-03-02 19:39:01 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2022-03-02 19:39:01 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-num base Num library distributed with the OCaml compiler
base-ocamlbuild base OCamlbuild binary and libraries distributed with the OCaml compiler
base-threads base
base-unix base
camlp5 7.14 Preprocessor-pretty-printer of OCaml
conf-findutils 1 Virtual package relying on findutils
conf-perl 2 Virtual package relying on perl
coq 8.5.1 Formal proof management system
num 0 The Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.02.3 The OCaml compiler (virtual package)
ocaml-base-compiler 4.02.3 Official 4.02.3 release
ocaml-config 1 OCaml Switch Configuration
# opam file:
opam-version: "2.0"
maintainer: "Enrico Tassi <enrico.tassi@inria.fr>"
authors: [ "Enrico Tassi" ]
license: "LGPL-2.1-or-later"
homepage: "https://github.com/LPCIC/coq-elpi"
bug-reports: "https://github.com/LPCIC/coq-elpi/issues"
dev-repo: "git+https://github.com/LPCIC/coq-elpi"
build: [ [ make "build" "COQBIN=%{bin}%/" "ELPIDIR=%{prefix}%/lib/elpi" "OCAMLWARN=" ]
[ make "test" "COQBIN=%{bin}%/" "ELPIDIR=%{prefix}%/lib/elpi" ] {with-test}
]
install: [ make "install" "COQBIN=%{bin}%/" "ELPIDIR=%{prefix}%/lib/elpi" ]
depends: [
"stdlib-shims"
"ocaml" {>= "4.07"}
"elpi" {>= "1.13.6" & < "1.14.0~"}
"coq" {>= "8.15" & < "8.16~" }
]
tags: [ "logpath:elpi" ]
synopsis: "Elpi extension language for Coq"
description: """
Coq-elpi provides a Coq plugin that embeds ELPI.
It also provides a way to embed Coq's terms into λProlog using
the Higher-Order Abstract Syntax approach
and a way to read terms back. In addition to that it exports to ELPI a
set of Coq's primitives, e.g. printing a message, accessing the
environment of theorems and data types, defining a new constant and so on.
For convenience it also provides a quotation and anti-quotation for Coq's
syntax in λProlog. E.g. `{{nat}}` is expanded to the type name of natural
numbers, or `{{A -> B}}` to the representation of a product by unfolding
the `->` notation. Finally it provides a way to define new vernacular commands
and
new tactics."""
url {
src: "https://github.com/LPCIC/coq-elpi/archive/v1.12.1.tar.gz"
checksum: "sha256=32eac6be5172eb945df6e80b1b6e0b784cbf1d7dca15ee780bb60716a0bb9ce5"
}
</pre>
<h2>Lint</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Dry install 🏜️</h2>
<p>Dry install with the current Coq version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam install -y --show-action coq-elpi.1.12.1 coq.8.5.1</code></dd>
<dt>Return code</dt>
<dd>5120</dd>
<dt>Output</dt>
<dd><pre>[NOTE] Package coq is already installed (current version is 8.5.1).
The following dependencies couldn't be met:
- coq-elpi -> ocaml >= 4.07
base of this switch (use `--unlock-base' to force)
No solution found, exiting
</pre></dd>
</dl>
<p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam remove -y coq; opam install -y --show-action --unlock-base coq-elpi.1.12.1</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Install 🚀</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Installation size</h2>
<p>No files were installed.</p>
<h2>Uninstall 🧹</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.02.3-2.0.6/released/8.5.1/elpi/1.12.1.html | HTML | mit | 7,729 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
418... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright © 2013-2021, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.business.fixtures.identity;
import javax.inject.Named;
import org.seedstack.business.domain.Entity;
import org.seedstack.business.util.SequenceGenerator;
@Named("guice")
public class GuiceIdentityGenerator implements SequenceGenerator {
@Override
public <E extends Entity<Long>> Long generate(Class<E> entityClass) {
return (long) Math.random();
}
}
| seedstack/business | core/src/test/java/org/seedstack/business/fixtures/identity/GuiceIdentityGenerator.java | Java | mpl-2.0 | 678 | [
30522,
1013,
1008,
1008,
9385,
1075,
2286,
1011,
25682,
1010,
1996,
8079,
2696,
3600,
6048,
1026,
8299,
1024,
1013,
1013,
8079,
2696,
3600,
1012,
8917,
1028,
1008,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Quasar: lightweight threads and actors for the JVM.
* Copyright (c) 2013-2015, Parallel Universe Software Co. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 3.0
* as published by the Free Software Foundation.
*/
package co.paralleluniverse.strands.channels;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.strands.Timeout;
import java.util.concurrent.TimeUnit;
/**
* A channel's producer-side interface.
*
* @param Message the type of messages that can be sent to this channel.
* @author pron
*/
public interface SendPort<Message> extends Port<Message>, AutoCloseable {
/**
* Sends a message to the channel, possibly blocking until there's room available in the channel.
*
* If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from
* the channel. The behavior is determined by the channel's {@link Channels.OverflowPolicy OverflowPolicy}, set at construction time.
*
* @param message
* @throws SuspendExecution
*/
void send(Message message) throws SuspendExecution, InterruptedException;
/**
* Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the
* specified timeout.
*
* If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from
* the channel. The behavior is determined by the channel's {@link Channels.OverflowPolicy OverflowPolicy}, set at construction time.
*
* @param message
* @param timeout the maximum duration this method is allowed to wait.
* @param unit the timeout's time unit
* @return {@code true} if the message has been sent successfully; {@code false} if the timeout has expired.
* @throws SuspendExecution
*/
boolean send(Message message, long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException;
/**
* Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the
* specified timeout.
*
* If the channel is full, this method may block, throw an exception, silently drop the message, or displace an old message from
* the channel. The behavior is determined by the channel's {@link Channels.OverflowPolicy OverflowPolicy}, set at construction time.
*
* @param message
* @param timeout the method will not block for longer than the amount remaining in the {@link Timeout}
* @return {@code true} if the message has been sent successfully; {@code false} if the timeout has expired.
* @throws SuspendExecution
*/
boolean send(Message message, Timeout timeout) throws SuspendExecution, InterruptedException;
/**
* Sends a message to the channel if the channel has room available. This method never blocks.
* <p>
* @param message
* @return {@code true} if the message has been sent; {@code false} otherwise.
*/
boolean trySend(Message message);
/**
* Closes the channel so that no more messages could be sent to it. Messages already sent to the channel will still be received.
*/
@Override
void close();
/**
* Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer.
* The exception will be thrown when the consumer calls {@link ReceivePort}'s {@code receive} or {@code tryReceive},
* wrapped by a {@link ProducerException}.
* Messages already sent to the channel prior to calling this method will still be received.
*/
void close(Throwable t);
}
| tbrooks8/quasar | quasar-core/src/jdk7/java/co/paralleluniverse/strands/channels/SendPort.java | Java | gpl-3.0 | 3,989 | [
30522,
1013,
1008,
1008,
24209,
16782,
2099,
1024,
12038,
16457,
1998,
5889,
2005,
1996,
1046,
2615,
2213,
1012,
1008,
9385,
1006,
1039,
1007,
2286,
1011,
2325,
1010,
5903,
5304,
4007,
2522,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// ${KIND:Unity.EventFunctions}
using UnityEngine;
class A : StateMachineBehaviour
{
{caret}
}
| JetBrains/resharper-unity | resharper/resharper-unity/test/data/Unity/CSharp/Generate/ListElements19.cs | C# | apache-2.0 | 100 | [
30522,
1013,
1013,
1002,
1063,
2785,
1024,
8499,
1012,
2724,
11263,
27989,
2015,
1065,
2478,
8499,
13159,
3170,
1025,
2465,
1037,
1024,
2110,
22911,
14014,
4783,
3270,
25500,
3126,
1063,
1063,
2729,
2102,
1065,
1065,
102,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=1024" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Submitting Bugs the Right Way | TJ VanToll</title>
<meta name="description" content="Submitting Bugs the Right Way" />
<meta name="author" content="TJ VanToll - tj.vantoll@gmail.com - tjvantoll.com" />
<link href="http://fonts.googleapis.com/css?family=Open+Sans:regular,semibold,italic,italicsemibold|PT+Sans:400,700,400italic,700italic|PT+Serif:400,700,400italic,700italic" rel="stylesheet" />
<script src="js/jquery-1.9.0.min.js"></script>
<script src="prettify/prettify.js"></script>
<link rel="stylesheet" href="css/impress-demo.css" />
<link rel="stylesheet" href="prettify/prettify.css" />
<link rel="stylesheet/less" href="less/style.less" />
<script src="js/less-1.3.3.min.js"></script>
<script>
var firstExampleStep, lastExampleStep;
$(function() {
var $example1Slides = $('.example_1_slide').hide();
$example1Slides.first().show();
firstExampleStep = $example1Slides[0].id.replace('step-', '');
lastExampleStep = $example1Slides[$example1Slides.length - 1].id.replace('step-', '');
firstExampleStep = parseInt(firstExampleStep, 10);
lastExampleStep = parseInt(lastExampleStep, 10);
var updateCode = function(event) {
var step = event ? event.target.id.replace('step-', '') : $example1Slides[0].id.replace('step-', '');
var numericStep = parseInt(step, 10);
if (event && event.type == 'impress:stepenter' && numericStep <= (firstExampleStep - 1)) {
$example1Slides.first().show();
return;
}
if (event && event.type == 'impress:stepleave' && numericStep <= firstExampleStep) {
$example1Slides.first().show();
return;
}
if (event && event.type == 'impress:stepenter' && numericStep >= lastExampleStep) {
$example1Slides.last().show();
return;
}
$example1Slides.hide();
$('.active').show();
};
updateCode();
$(document)
.on('impress:stepleave', updateCode)
.on('impress:stepenter', updateCode);
});
if (window.location.host.indexOf('local') == -1) {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29179796-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}
</script>
</head>
<body class="impress-not-supported" onload="prettyPrint();">
<div class="fallback-message">
<p>Your browser <b>doesn't support the features required</b> by impress.js, so you are presented with a simplified version of this presentation.</p>
<p>For the best experience please use the latest <b>Chrome</b>, <b>Safari</b> or <b>Firefox</b> browser.</p>
</div>
<div id="impress">
<!-- START SLIDES -->
<div class="step slide">
<h1>Submitting Bugs the Right Way</h1>
<h2>TJ VanToll</h2>
</div>
<div class="step slide" data-x="1000">
<h2>Hi!</h2>
<ul>
<li>Web Developer - <a href="http://liquidweb.com">Liquid Web</a></li>
<li>Lansing, MI</li>
<li>Twin two year old sons</li>
</ul>
<img src="img/chase.jpg">
<img src="img/max.jpg">
<p class="sorry" style="display: none;"><i>You should feel really sorry for them.</i></p>
<script>
$(document).on('keypress', function(event) {
if (event.keyCode == 114) {
$('.sorry').show();
}
});
</script>
</div>
<style>
.jquery-ui {
background: #BB6F04;
}
.jquery-ui ul {
color: white;
}
</style>
<div class="step slide jquery-ui" data-x="2000">
<img src="img/jquery-ui.png">
<ul>
<li>jQuery UI Team Member</li>
<li>I triage bugs.</li>
</ul>
</div>
<div class="step slide full_screen" data-x="3000">
<h2 style="opacity: 0.8;">Story</h2>
<img src="img/story.jpg">
<!-- http://www.flickr.com/photos/michaelcasey/3462280483/ -->
</div>
<div class="step slide" data-x="4000">
<h2>A Simple CRUD Table</h2>
<img src="img/table.png" style="display: block; margin: 50px; auto;">
</div>
<div class="step slide" data-x="5000">
<h2>Uh Oh</h2>
<pre class="prettyprint">$('tr').remove();</pre>
<img src="img/ie8_error.png" style="display: block; margin: 30px auto;">
</div>
<div class="step slide full_screen" data-x="6000">
<h2 style="top: 85%;">Average Developer's Reaction</h2>
<img src="img/reaction.jpg">
</div>
<div class="step slide full_screen" data-x="7000">
<h2>This is JavaScript</h2>
<img src="img/tools.jpg">
</div>
<div class="step slide" data-x="8000">
<h2>Hack #1</h2>
<pre class="prettyprint lang-js">
var row = $('tr');
try {
row.remove();
} catch(e) {
row.hide();
}
</pre>
</div>
<div class="step slide" data-x="9000">
<h2>Hack #2</h2>
<pre class="prettyprint lang-js">
var row = $('tr');
if ($.browser.msie
&& parseInt($.browser.version, 10) == 8) {
$('tr').hide();
} else {
$('tr').remove();
}
</pre>
</div>
<div class="step slide" data-x="10000">
<h2>Hack #3</h2>
<pre class="prettyprint lang-js">
var row = $('tr');
if ($.browser.msie
&& parseInt($.browser.version, 10) == 8) {
window.location = window.location;
}
$('tr').remove();
</pre>
</div>
<div class="step slide point" data-x="11000">
<h3>Why bother?</h3>
</div>
<div class="step slide full_screen" data-x="12000">
<h2>Make the world a better place</h2>
<img src="img/sunrise.jpg">
<!-- http://www.flickr.com/photos/66069842@N03/6847080293/ -->
</div>
<div class="step slide full_screen" data-x="13000">
<h2 style="opacity: 0.8;">Learn</h2>
<img src="img/books.jpg">
<!-- http://www.flickr.com/photos/cransell/1955227307/ -->
</div>
<div class="step slide point" data-x="14000">
<h3>Get your bug fixed!</h3>
</div>
<div class="step slide point" data-x="15000">
<h3>Where to go?</h3>
</div>
<div class="step slide" data-x="16000">
<h2>Bug Trackers - jQuery</h2>
<ul>
<li>jQuery: <a href="http://bugs.jquery.com/newticket">bugs.jquery.com/newticket</a></li>
<li>jQuery UI: <a href="http://bugs.jqueryui.com/newticket">bugs.jqueryui.com/newticket</a></li>
<li>jQuery Mobile: <a href="https://github.com/jquery/jquery-mobile/issues/new">github.com/jquery/jquery-mobile/issues</a></li>
</ul>
</div>
<div class="step slide" data-x="17000">
<h2>Bug Trackers - Browsers</h2>
<ul>
<li><a href="http://blog.reybango.com/2013/02/28/submitting-an-internet-explorer-bug-to-microsoft/">Internet Explorer</a></li>
<li><a href="https://bugzilla.mozilla.org/">Firefox</a></li>
<li><a href="http://www.chromium.org/for-testers/bug-reporting-guidelines">Chrome</a></li>
<li><a href="https://bugs.webkit.org/">WebKit</a></li>
<li><a href="https://bugreport.apple.com">Safari</a></li>
<li><a href="https://bugs.opera.com/wizard/">Opera</a></li>
</ul>
</div>
<div class="step slide" data-x="18000">
<h2>BIG RED BOX!</h2>
<img src="img/jQuery_box.png">
</div>
<div class="step slide point" data-x="19000">
<h3 style="margin-top: 210px; line-height: 60px;">Search the bug trackers. Try to make sure the bug doesn't already exist.</h3>
</div>
<div class="step slide" data-x="20000">
<h2>Use the latest versions</h2>
<ul>
<li><a href="http://code.jquery.com/jquery-git.js">http://code.jquery.com/jquery-git.js</a></li>
<li><a href="http://code.jquery.com/ui/jquery-ui-git.css">http://code.jquery.com/ui/jquery-ui-git.css</a></li>
<li><a href="http://code.jquery.com/ui/jquery-ui-git.js">http://code.jquery.com/ui/jquery-ui-git.js</a></li>
<li><a href="https://www.google.com/intl/en/chrome/browser/canary.html">Chrome Canary</a></li>
<li><a href="http://www.mozilla.org/en-US/firefox/aurora/">Firefox Aurora</a></li>
</ul>
</div>
<div class="step slide point" data-x="21000" style="border: 50px solid red;">
<h2 style="color: red; text-align: center">IMPORTANT!</h2>
<h3 style="font-weight: bold; margin-top: 200px;">Create a reduced test case.</h3>
</div>
<div class="step slide" data-x="22000">
<h2>Reduced Test Case</h2>
<p>The <b>absolute minimum</b> amount of code you can use to recreate the problem.</p>
</div>
<div class="step slide" data-x="23000">
<h2>Reducing</h2>
<ul>
<li>Remove Code</li>
<li>Refresh</li>
<li>Repeat</li>
</ul>
</div>
<div class="step slide point" data-x="24000">
<h3>Don't link to your live site.</h3>
</div>
<style>
.online_test_case > div {
float: left;
width: 33%;
}
.online_test_case a {
text-align: center;
display: block;
padding-top: 35px;
padding-bottom: 20px;
}
</style>
<div class="step slide online_test_case" data-x="25000">
<h2>Test Cases - Your Friends</h2>
<div>
<a href="http://jsfiddle.net">jsFiddle</a>
<img src="img/jsfiddle.png">
</div>
<div>
<a href="http://jsbin.com">JS Bin</a>
<img src="img/jsbin.png">
</div>
<div>
<a href="http://codepen.io">Codepen</a>
<img src="img/codepen.png">
</div>
</div>
<div class="step slide" data-x="26000">
<h2>Example</h2>
<p><a href="jQuery UI #8677">jQuery UI #8677</a></p>
<img src="img/ie10_error.png">
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre style="font-size: 0.5em;"><span class="tag"><style></span><span class="pln">input</span><span class="pun">.</span><span class="pln">textbox </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><form</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"aspnetForm"</span><span class="pln"> </span><span class="atn">method</span><span class="pun">=</span><span class="atv">"post"</span><span class="pln"> </span><span class="atn">action</span><span class="pun">=</span><span class="atv">"test.aspx"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"aspnetForm"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></span><span class="pln">Settings </span><span class="tag"></a></li><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab2"</span><span class="tag">></span><span class="pln">Logins </span><span class="tag"></a></li></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><table</span><span class="pln"> </span><span class="atn">border</span><span class="pun">=</span><span class="atv">"0"</span><span class="pln"> </span><span class="atn">cellspacing</span><span class="pun">=</span><span class="atv">"3"</span><span class="pln"> </span><span class="atn">cellpadding</span><span class="pun">=</span><span class="atv">"3"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><tbody><tr></span><span class="pln">
</span><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span><span class="pln">Account Name:</span><span class="tag"><span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"red"</span><span class="tag">></span><span class="pln">*</span><span class="tag"></span></td></span><span class="pln">
</span><span class="tag"><td><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyName"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyName"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"200"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"yauhen"</span><span class="tag">></td></span><span class="pln">
</span><span class="tag"></tr></span><span class="pln">
</span><span class="tag"><tr</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"trCompanyURL"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span><span class="pln">Company URL:</span><span class="tag"></td></span><span class="pln">
</span><span class="tag"><td><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyURL"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyURL"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"256"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"http://localhost:81"</span><span class="tag">></td></span><span class="pln">
</span><span class="tag"></tr></tbody></span><span class="pln">
</span><span class="tag"></table></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab2"</span><span class="tag">></span><span class="pln">tabs2</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></form></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre style="font-size: 0.5em;"><span class="tag"><style></span><span class="pln">input</span><span class="pun">.</span><span class="pln">textbox </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="tag"></style></span><span class="pln">
</span><span class="axe_it"><span class="tag"><form</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"aspnetForm"</span><span class="pln"> </span><span class="atn">method</span><span class="pun">=</span><span class="atv">"post"</span><span class="pln"> </span><span class="atn">action</span><span class="pun">=</span><span class="atv">"test.aspx"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"aspnetForm"</span><span class="tag">></span></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></span><span class="pln">Settings </span><span class="tag"></a></li><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab2"</span><span class="tag">></span><span class="pln">Logins </span><span class="tag"></a></li></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><table</span><span class="pln"> </span><span class="atn">border</span><span class="pun">=</span><span class="atv">"0"</span><span class="pln"> </span><span class="atn">cellspacing</span><span class="pun">=</span><span class="atv">"3"</span><span class="pln"> </span><span class="atn">cellpadding</span><span class="pun">=</span><span class="atv">"3"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><tbody><tr></span><span class="pln">
</span><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span><span class="pln">Account Name:</span><span class="tag"><span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"red"</span><span class="tag">></span><span class="pln">*</span><span class="tag"></span></td></span><span class="pln">
</span><span class="tag"><td><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyName"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyName"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"200"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"yauhen"</span><span class="tag">></td></span><span class="pln">
</span><span class="tag"></tr></span><span class="pln">
</span><span class="tag"><tr</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"trCompanyURL"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span><span class="pln">Company URL:</span><span class="tag"></td></span><span class="pln">
</span><span class="tag"><td><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyURL"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyURL"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"256"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"http://localhost:81"</span><span class="tag">></td></span><span class="pln">
</span><span class="tag"></tr></tbody></span><span class="pln">
</span><span class="tag"></table></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab2"</span><span class="tag">></span><span class="pln">tabs2</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="axe_it"><span class="tag"></form></span></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.53em;">
<style>input.textbox { width:185px; padding:0px; margin:0px; } </style>
<div id="tabs">
<ul>
<li><a href="#tab1">Settings </a></li><li><a href="#tab2">Logins </a></li>
</ul>
<div id="tab1">
<table border="0" cellspacing="3" cellpadding="3">
<tbody><tr>
<td class="bold">Account Name:<span class="red">*</span></td>
<td><input name="companyName" class="textbox" id="txtCompanyName"
type="text" maxlength="200" value="yauhen"></td>
</tr>
<tr id="trCompanyURL">
<td class="bold">Company URL:</td>
<td><input name="companyURL" class="textbox" id="txtCompanyURL"
type="text" maxlength="256" value="http://localhost:81"></td>
</tr></tbody>
</table>
</div>
<div id="tab2">tabs2</div>
</div>
<script>$('#tabs').tabs();</script>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.53em;"><span class="tag"><style></span><span class="pln">input</span><span class="pun">.</span><span class="pln">textbox </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></span><span class="pln">Settings </span><span class="tag"></a></li><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab2"</span><span class="tag">></span><span class="pln">Logins </span><span class="tag"></a></li></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
</span><span class="axe_it"><span class="tag"><table</span><span class="pln"> </span><span class="atn">border</span><span class="pun">=</span><span class="atv">"0"</span><span class="pln"> </span><span class="atn">cellspacing</span><span class="pun">=</span><span class="atv">"3"</span><span class="pln"> </span><span class="atn">cellpadding</span><span class="pun">=</span><span class="atv">"3"</span><span class="tag">></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><tbody><tr></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span></span><span class="pln">Account Name:</span><span class="tag"><span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"red"</span><span class="tag">></span><span class="pln">*</span><span class="tag"></span></span><span class="axe_it"><span class="tag"></td></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><td></span></span><span class="tag"><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyName"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyName"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"200"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"yauhen"</span><span class="tag">></span><span class="axe_it"><span class="tag"></td></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"></tr></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><tr</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"trCompanyURL"</span><span class="tag">></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><td</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"bold"</span><span class="tag">></span></span><span class="pln">Company URL:</span><span class="axe_it"><span class="tag"></td></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"><td></span></span><span class="tag"><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyURL"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyURL"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"256"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"http://localhost:81"</span><span class="tag">></span><span class="axe_it"><span class="tag"></td></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"></tr></tbody></span></span><span class="pln">
</span><span class="axe_it"><span class="tag"></table></span></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab2"</span><span class="tag">></span><span class="pln">tabs2</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.6em;">
<style>
input.textbox { width:185px; padding:0px; margin:0px; }
</style>
<div id="tabs">
<ul>
<li><a href="#tab1">Settings </a></li>
<li><a href="#tab2">Logins </a></li>
</ul>
<div id="tab1">
Account Name:<span class="red">*</span>
<input name="companyName" class="textbox" id="txtCompanyName"
type="text" maxlength="200" value="yauhen">
Company URL:
<input name="companyURL" class="textbox" id="txtCompanyURL"
type="text" maxlength="256" value="http://localhost:81">
</div>
<div id="tab2">tabs2</div>
</div>
<script>$('#tabs').tabs();</script>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.6em;"><span class="tag"><style></span><span class="pln">
input</span><span class="pun">.</span><span class="pln">textbox </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
</span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></span><span class="pln">Settings </span><span class="tag"></a></li></span><span class="pln">
</span><span class="axe_it"><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab2"</span><span class="tag">></span><span class="pln">Logins </span><span class="tag"></a></li></span></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
Account Name:</span><span class="tag"><span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"red"</span><span class="tag">></span><span class="pln">*</span><span class="tag"></span></span><span class="pln">
</span><span class="tag"><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyName"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyName"</span><span class="pln">
</span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"200"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"yauhen"</span><span class="tag">></span><span class="pln">
<span class="axe_it">Company URL:</span></span>
<span class="axe_it"><span class="tag"><input</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyURL"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyURL"</span></span><span class="pln">
</span><span class="axe_it"><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"256"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"http://localhost:81"</span><span class="tag">></span></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="axe_it"><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab2"</span><span class="tag">></span><span class="pln">tabs2</span><span class="tag"></div></span></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.63em;">
<style>
input.textbox { width:185px; padding:0px; margin:0px; }
</style>
<div id="tabs">
<ul>
<li><a href="#tab1">Settings </a></li>
</ul>
<div id="tab1">
Account Name:<span class="red">*</span>
<input name="companyName" class="textbox" id="txtCompanyName"
type="text" maxlength="200" value="yauhen">
</div>
</div>
<script>$('#tabs').tabs();</script>
</pre>
</div>
<div class="slide step example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.63em;"><span class="tag"><style></span><span class="pln">
input</span><span class="axe_it"><span class="pun">.</span><span class="pln">textbox </span></span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
</span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></span><span class="pln"><span class="axe_it">Settings </span></span><span class="tag"></a></li></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
<span class="axe_it">Account Name:</span></span><span class="axe_it"><span class="tag"><span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"red"</span><span class="tag">></span><span class="pln">*</span><span class="tag"></span></span></span><span class="pln">
</span><span class="tag"><input</span><span class="pln"> </span><span class="axe_it"><span class="atn">name</span><span class="pun">=</span><span class="atv">"companyName"</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"textbox"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"txtCompanyName"</span></span><span class="pln">
</span><span class="axe_it"><span class="atn">type</span><span class="pun">=</span><span class="atv">"text"</span><span class="pln"> </span><span class="atn">maxlength</span><span class="pun">=</span><span class="atv">"200"</span></span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"yauhen"</span><span class="tag">></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.7em;">
<style>
input { width:185px; padding:0px; margin:0px; }
</style>
<div id="tabs">
<ul>
<li><a href="#tab1"></a></li>
</ul>
<div id="tab1">
<input value="yauhen">
</div>
</div>
<script>$('#tabs').tabs();</script>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.7em;"><span class="tag"><style></span><span class="pln">
input </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">width</span><span class="pun">:</span><span class="lit">185px</span><span class="pun">;</span><span class="pln"> </span><span class="axe_it"><span class="kwd">padding</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">margin</span><span class="pun">:</span><span class="lit">0px</span><span class="pun">;</span></span><span class="pln"> </span><span class="pun">}</span><span class="pln">
</span><span class="tag"></style></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tabs"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><ul></span><span class="pln">
</span><span class="tag"><li><a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"#tab1"</span><span class="tag">></a></li></span><span class="pln">
</span><span class="tag"></ul></span><span class="pln">
</span><span class="tag"><div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"tab1"</span><span class="tag">></span><span class="pln">
</span><span class="tag"><input</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"<span class="axe_it">yauhen</span>"</span><span class="tag">></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"></div></span><span class="pln">
</span><span class="tag"><script></span><span class="pln">$</span><span class="pun">(</span><span class="str">'#tabs'</span><span class="pun">).</span><span class="pln">tabs</span><span class="pun">();</span><span class="tag"></script></span></pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<pre class="prettyprint" style="font-size: 0.7em;">
<style>
input { width:185px; }
</style>
<div id="tabs">
<ul>
<li><a href="#tab1"></a></li>
</ul>
<div id="tab1">
<input value="lorem ipsum">
</div>
</div>
<script>$('#tabs').tabs();</script>
</pre>
</div>
<div class="step slide example_1_slide" data-x="27000">
<h2>Test Case with no jQuery</h2>
<pre class="prettyprint" style="font-size: 0.7em;">
<div>
<input value="Whatever">
</div>
<button>Break It</button>
<style>
input { width: 150px; }
div.on input { font-size: 1em; }
</style>
<script>
var div = document.getElementsByTagName('div')[0],
button = document.getElementsByTagName('button')[0];
button.addEventListener('click', function() {
div.classList.add('on');
});
</script>
</pre>
</div>
<div class="step slide" data-x="28000">
<h2>Reduced version of $('tr').remove()</h2>
<pre class="prettyprint">
<table>
<tr>
<td><a href="#">Cancel</a></td>
</tr>
</table>
<script>
$(document).on('click', '#whatever', function(){});
$('table').on('click', 'a', function() {
$(this).parents('tr').remove();
});
</script>
</pre>
</div>
<div class="step slide" data-x="29000">
<h2>Don't be Rude</h2>
<img src="img/rude.png" style="width: 100%;">
</div>
<div class="step slide" data-x="30000">
<p>Bug trackers aren't the best place to discuss large feature requests.</p>
<img src="img/bubble.png">
<img src="img/mikesherov.png" style="width: 100%;">
<img src="img/joernzaefferer.png" style="width: 100%;">
</div>
<div class="step slide" data-x="31000">
<h2>Bug tracker != Support</h2>
<ul>
<li><a href="http://stackoverflow.com">Stack Overflow</a></li>
<li><a href="http://forum.jquery.com/">Forums</a></li>
<li><a href="http://irc.jquery.org/">#jquery on IRC</a></li>
</ul>
</div>
<div class="step slide" data-x="32000">
<h2>Review</h2>
<ol>
<li>Search for existing bugs.</li>
<li>Test against the latest version.</li>
<li>Create a reduced test case.</li>
</ol>
</div>
<div class="step slide" id="end" data-x="33000" data-y="-1000" data-z="5000" data-rotate-x="-10" data-rotate-z="-60">
<h3>Thanks!</h3>
<a href="http://twitter.com/tjvantoll">@tjvantoll</a>
<a href="http://tjvantoll.com">http://tjvantoll.com</a>
</div>
</div><!-- end #impress -->
<div class="hint">
<p>Use a spacebar or arrow keys to navigate</p>
</div>
<script>
if ("ontouchstart" in document.documentElement) {
document.querySelector(".hint").innerHTML = "<p>Tap on the left or right to navigate</p>";
}
</script>
<script src="js/impress.js"></script>
<script>impress().init();</script>
</body>
</html>
| tjvantoll/tjvantoll.github.com | speaking/slides/Submitting-Bugs-the-Right-Way/Toronto/index.html | HTML | mit | 44,876 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*~
* Copyright (C) 2013 - 2016 George Makrydakis <george@irrequietus.eu>
*
* This file is part of 'clause', a highly generic C++ meta-programming library,
* subject to the terms and conditions of the Mozilla Public License v 2.0. If
* a copy of the MPLv2 license text was not distributed with this file, you can
* obtain it at: http://mozilla.org/MPL/2.0/.
*
* The 'clause' library is an experimental library in active development with
* a source code repository at: https://github.com/irrequietus/clause.git and
* issue tracker at https://github.com/irrequietus/clause/issues.
*
*/
#ifndef CLAUSE_AMPLE_FOLD_HH
#define CLAUSE_AMPLE_FOLD_HH
#include <clause/ample/oprt/fundamentals.hh>
#include <clause/ample/logic/logical.hh>
#include <clause/ample/logic/when.hh>
#include <clause/ample/logic/relational.hh>
#include <clause/ample/applying.hh>
namespace clause {
namespace ample {
/*~
* @desc Perform a catamorphism (left fold), over an abstraction containing a
* sequence of types according to the clause semantical model. Notice that
* the parameter types to be used for instantiating this template have to
* obey the 'clause::ample' model.
* @tprm Fnc_T : An abstraction to be applied as a binary function using the
* `clause::ample::apply` operation.
* @tprm Seed_T : An abstraction serving as the seed value for the folding to
* occur properly.
* @tprm Vector_T: The abstraction containing the types over which the left
* fold is to be performed.
* @inst To an abstraction providing the semantics of Seed_T oprt handlers. In
* case of failure to instantiate for any reason, it adops the failure<>
* metaprogramming interface.
*/
template<typename Fnc_T, typename Seed_T, typename Vector_T>
struct foldl
: where< size_of<Vector_T>
, where< greater_than<size_of<Vector_T>, natural<1>>
, foldl< Fnc_T
, apply<Fnc_T, Seed_T, head_of<Vector_T>>
, tail_of<Vector_T>>
, apply<Fnc_T, Seed_T, head_of<Vector_T>>>
, Seed_T >
{};
/*~
* @desc Perform a catamorphism (right fold), over an abstraction containing a
* sequence of types according to the clause semantical model. Notice that
* the parameter types to be used for instantiating this template have to
* obey the 'clause::ample' model.
* @tprm Fnc_T : An abstraction to be applied as a binary function using the
* `clause::ample::apply` operation.
* @tprm Seed_T : An abstraction serving as the seed value for the folding to
* occur properly.
* @tprm Vector_T: The abstraction containing the types over which the right
* fold is to be performed.
* @inst To an abstraction providing the semantics of Seed_T oprt handlers. In
* case of failure to instantiate for any reason, it adops the failure<>
* metaprogramming interface.
*/
template<typename Fnc_T, typename Seed_T, typename Vector_T>
struct foldr
: where< size_of<Vector_T>
, where< greater_than<size_of<Vector_T>, natural<1>>
, foldr< Fnc_T
, apply<Fnc_T, back_of<Vector_T>, Seed_T>
, pop_back<Vector_T>>
, apply<Fnc_T, back_of<Vector_T>, Seed_T>>
, Seed_T >
{};
} /* ample */
} /* clause */
#endif /* CLAUSE_AMPLE_ALGORITHM_HH */
| irrequietus/clause | clause/ample/fold.hh | C++ | mpl-2.0 | 3,487 | [
30522,
1013,
1008,
1066,
1008,
9385,
1006,
1039,
1007,
2286,
1011,
2355,
2577,
5003,
21638,
25688,
8978,
2015,
1026,
2577,
1030,
20868,
2890,
15549,
3388,
2271,
1012,
7327,
1028,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1005,
11075,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jsonp({"cep":"88704750","logradouro":"Rua Nestor Pereira Habkost","bairro":"Revoredo","cidade":"Tubar\u00e3o","uf":"SC","estado":"Santa Catarina"});
| lfreneda/cepdb | api/v1/88704750.jsonp.js | JavaScript | cc0-1.0 | 149 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6070,
19841,
22610,
12376,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
21766,
2050,
25397,
23857,
5292,
2497,
15710,
2102,
1000,
1010,
1000,
21790,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*****************************************************************************
*
* IIDCoacam.h -- header for IEE1394/IIDC camera API
*
* Copyright 2013,2014,2015,2016,2017,2018,2019
* James Fidell (james@openastroproject.org)
*
* License:
*
* This file is part of the Open Astro Project.
*
* The Open Astro Project is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Open Astro Project 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 the Open Astro Project. If not, see
* <http://www.gnu.org/licenses/>.
*
*****************************************************************************/
#ifndef OA_IIDC_OACAM_H
#define OA_IIDC_OACAM_H
extern int oaIIDCGetCameras ( CAMERA_LIST*, unsigned long, int );
extern oaCamera* oaIIDCInitCamera ( oaCameraDevice* );
extern int oaIIDCCloseCamera ( oaCamera* );
extern int oaIIDCCameraTestControl ( oaCamera*, int,
oaControlValue* );
extern int oaIIDCCameraGetControlRange ( oaCamera*, int,
int64_t*, int64_t*, int64_t*, int64_t* );
extern void* oacamIIDCcontroller ( void* );
extern void* oacamIIDCcallbackHandler ( void* );
extern const FRAMESIZES* oaIIDCCameraGetFrameSizes ( oaCamera* );
extern const FRAMERATES* oaIIDCCameraGetFrameRates ( oaCamera*, int, int );
extern int oaIIDCCameraGetFramePixelFormat ( oaCamera* );
extern const char* oaIIDCCameraGetMenuString ( oaCamera*, int, int );
struct iidcCtrl {
int iidcControl;
int oaControl;
};
extern struct iidcCtrl dc1394Controls[];
extern unsigned int numIIDCControls;
struct iidcFrameRate {
int iidcFrameRate;
int numerator;
int denominator;
};
extern struct iidcFrameRate dc1394FrameRates[];
extern unsigned int numIIDCFrameRates;
#endif /* OA_IIDC_OACAM_H */
| openastroproject/openastro | liboacam/iidc/IIDCoacam.h | C | gpl-3.0 | 2,176 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// K-3D
// Copyright (c) 1995-2008, Timothy M. Shead
//
// Contact: tshead@k-3d.com
//
// 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
#include <boost/python.hpp>
#include <k3dsdk/iscript_engine.h>
#include <k3dsdk/python/any_python.h>
#include <k3dsdk/scripting.h>
namespace k3d
{
namespace python
{
class script
{
public:
static void execute_with_context(const string_t& Script, const boost::python::dict& PythonContext)
{
k3d::iscript_engine::context context;
boost::python::dict python_context = PythonContext;
while(len(python_context))
{
boost::python::tuple python_item = python_context.popitem();
boost::python::object python_key = python_item[0];
boost::python::object python_value = python_item[1];
const string_t key = PyString_AsString(python_key.ptr());
boost::any value = python_to_any(python_value);
context.insert(std::make_pair(key, value));
}
bool recognized = false;
bool executed = false;
k3d::script::execute(k3d::script::code(Script), "Python Text", context, recognized, executed);
if(!recognized)
throw std::invalid_argument("Unrecognized scripting language");
if(!executed)
throw std::runtime_error("Error executing script");
}
static void execute(const string_t& Script)
{
execute_with_context(Script, boost::python::dict());
}
};
static int context_len(const k3d::iscript_engine::context& Self)
{
return Self.size();
}
static boost::python::object context_get_item(const k3d::iscript_engine::context& Self, const k3d::string_t& Key)
{
k3d::iscript_engine::context::const_iterator item = Self.find(Key);
if(item == Self.end())
throw std::out_of_range("unknown key");
return any_to_python(item->second);
}
static void context_set_item(k3d::iscript_engine::context& Self, const k3d::string_t& Key, const boost::python::object& Value)
{
Self[Key] = python_to_any(Value);
}
static void context_del_item(k3d::iscript_engine::context& Self, const k3d::string_t& Key)
{
k3d::iscript_engine::context::iterator item = Self.find(Key);
if(item == Self.end())
throw std::out_of_range("unknown key");
Self.erase(item);
}
static bool_t context_has_key(const k3d::iscript_engine::context& Self, const k3d::string_t& Key)
{
return Self.count(Key);
}
static boost::python::list context_keys(const k3d::iscript_engine::context& Self)
{
boost::python::list results;
for(k3d::iscript_engine::context::const_iterator pair = Self.begin(); pair != Self.end(); ++pair)
results.append(pair->first);
return results;
}
static boost::python::list context_values(const k3d::iscript_engine::context& Self)
{
boost::python::list results;
for(k3d::iscript_engine::context::const_iterator pair = Self.begin(); pair != Self.end(); ++pair)
results.append(any_to_python(pair->second));
return results;
}
void define_namespace_script()
{
boost::python::scope outer = boost::python::class_<script>("script", boost::python::no_init)
.def("execute", script::execute,
"Executes a script (which does not have to be written in Python).")
.def("execute", script::execute_with_context,
"Executes a script (which does not have to be written in Python).")
.staticmethod("execute")
;
boost::python::class_<k3d::iscript_engine::context>("context", "")
.def("__len__", &context_len)
.def("__getattr__", &context_get_item)
.def("__setattr__", &context_set_item)
.def("__delattr__", &context_del_item)
.def("__getitem__", &context_get_item)
.def("__setitem__", &context_set_item)
.def("__delitem__", &context_del_item)
.def("has_key", &context_has_key)
.def("keys", &context_keys)
.def("values", &context_values)
;
}
} // namespace python
} // namespace k3d
| barche/k3d | k3dsdk/python/script_python.cpp | C++ | gpl-2.0 | 4,335 | [
30522,
1013,
1013,
1047,
1011,
7605,
1013,
1013,
9385,
1006,
1039,
1007,
2786,
1011,
2263,
1010,
10805,
1049,
1012,
16994,
2094,
1013,
1013,
1013,
1013,
3967,
1024,
24529,
4974,
1030,
1047,
1011,
7605,
1012,
4012,
1013,
1013,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
namespace Google\Service\Dfareporting;
class DirectorySiteSettings extends \Google\Model
{
/**
* @var bool
*/
public $activeViewOptOut;
protected $dfpSettingsType = DfpSettings::class;
protected $dfpSettingsDataType = '';
/**
* @var bool
*/
public $instreamVideoPlacementAccepted;
/**
* @var bool
*/
public $interstitialPlacementAccepted;
/**
* @param bool
*/
public function setActiveViewOptOut($activeViewOptOut)
{
$this->activeViewOptOut = $activeViewOptOut;
}
/**
* @return bool
*/
public function getActiveViewOptOut()
{
return $this->activeViewOptOut;
}
/**
* @param DfpSettings
*/
public function setDfpSettings(DfpSettings $dfpSettings)
{
$this->dfpSettings = $dfpSettings;
}
/**
* @return DfpSettings
*/
public function getDfpSettings()
{
return $this->dfpSettings;
}
/**
* @param bool
*/
public function setInstreamVideoPlacementAccepted($instreamVideoPlacementAccepted)
{
$this->instreamVideoPlacementAccepted = $instreamVideoPlacementAccepted;
}
/**
* @return bool
*/
public function getInstreamVideoPlacementAccepted()
{
return $this->instreamVideoPlacementAccepted;
}
/**
* @param bool
*/
public function setInterstitialPlacementAccepted($interstitialPlacementAccepted)
{
$this->interstitialPlacementAccepted = $interstitialPlacementAccepted;
}
/**
* @return bool
*/
public function getInterstitialPlacementAccepted()
{
return $this->interstitialPlacementAccepted;
}
}
// Adding a class alias for backwards compatibility with the previous class name.
class_alias(DirectorySiteSettings::class, 'Google_Service_Dfareporting_DirectorySiteSettings');
| googleapis/google-api-php-client-services | src/Dfareporting/DirectorySiteSettings.php | PHP | apache-2.0 | 2,340 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
9385,
2297,
8224,
4297,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
1008,
2224,
2023,
5371,
3272,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "umiss_project.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
| CadeiraCuidadora/UMISS-backend | umiss_project/manage.py | Python | gpl-3.0 | 811 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
12324,
9808,
12324,
25353,
2015,
2065,
1035,
1035,
2171,
1035,
1035,
1027,
1027,
1000,
1035,
1035,
2364,
1035,
1035,
1000,
1024,
9808,
1012,
4372,
21663,
2239,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.tll.canyon.service;
import java.util.List;
import java.util.ArrayList;
import org.jmock.Mock;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.tll.canyon.dao.AssetRoleDao;
import org.tll.canyon.model.AssetRole;
import org.tll.canyon.service.BaseManagerTestCase;
import org.tll.canyon.service.impl.AssetRoleManagerImpl;
public class AssetRoleManagerTest extends BaseManagerTestCase {
private final String assetRoleId = "1";
private AssetRoleManagerImpl assetRoleManager = new AssetRoleManagerImpl();
private Mock assetRoleDao = null;
protected void setUp() throws Exception {
super.setUp();
assetRoleDao = new Mock(AssetRoleDao.class);
assetRoleManager.setAssetRoleDao((AssetRoleDao) assetRoleDao.proxy());
}
protected void tearDown() throws Exception {
super.tearDown();
assetRoleManager = null;
}
public void testGetAssetRoles() throws Exception {
List results = new ArrayList();
AssetRole assetRole = new AssetRole();
results.add(assetRole);
// set expected behavior on dao
assetRoleDao.expects(once()).method("getAssetRoles")
.will(returnValue(results));
List assetRoles = assetRoleManager.getAssetRoles(null);
assertTrue(assetRoles.size() == 1);
assetRoleDao.verify();
}
public void testGetAssetRole() throws Exception {
// set expected behavior on dao
assetRoleDao.expects(once()).method("getAssetRole")
.will(returnValue(new AssetRole()));
AssetRole assetRole = assetRoleManager.getAssetRole(assetRoleId);
assertTrue(assetRole != null);
assetRoleDao.verify();
}
public void testSaveAssetRole() throws Exception {
AssetRole assetRole = new AssetRole();
// set expected behavior on dao
assetRoleDao.expects(once()).method("saveAssetRole")
.with(same(assetRole)).isVoid();
assetRoleManager.saveAssetRole(assetRole);
assetRoleDao.verify();
}
public void testAddAndRemoveAssetRole() throws Exception {
AssetRole assetRole = new AssetRole();
// set required fields
// set expected behavior on dao
assetRoleDao.expects(once()).method("saveAssetRole")
.with(same(assetRole)).isVoid();
assetRoleManager.saveAssetRole(assetRole);
assetRoleDao.verify();
// reset expectations
assetRoleDao.reset();
assetRoleDao.expects(once()).method("removeAssetRole").with(eq(new Long(assetRoleId)));
assetRoleManager.removeAssetRole(assetRoleId);
assetRoleDao.verify();
// reset expectations
assetRoleDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(AssetRole.class, assetRole.getId());
assetRoleDao.expects(once()).method("removeAssetRole").isVoid();
assetRoleDao.expects(once()).method("getAssetRole").will(throwException(ex));
assetRoleManager.removeAssetRole(assetRoleId);
try {
assetRoleManager.getAssetRole(assetRoleId);
fail("AssetRole with identifier '" + assetRoleId + "' found in database");
} catch (ObjectRetrievalFailureException e) {
assertNotNull(e.getMessage());
}
assetRoleDao.verify();
}
}
| clafonta/canyon | test/service/org/tll/canyon/service/AssetRoleManagerTest.java | Java | apache-2.0 | 3,376 | [
30522,
7427,
8917,
1012,
1056,
3363,
1012,
8399,
1012,
2326,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
8917,
1012,
1046,
5302,
3600,
1012,
12934,
1025,
12324,
8917... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Django Media Albums
[](https://travis-ci.org/VelocityWebworks/django-media-albums)
This app is used to create albums consisting of any combination of the
following:
* Photos
* Video files
* Audio files
This app also optionally allows regular (non-staff) users to upload photos.
This app requires Django 1.8, 1.9, 1.10, or 1.11.
## Installation
### Step 1 of 5: Install the required packages
Install using pip:
```bash
pip install django-media-albums
```
If you will be using the templates that come with this app, also install these
packages using pip:
```bash
pip install django-bootstrap-pagination sorl-thumbnail
```
If you will be allowing regular (non-staff) users to upload photos and will be
using the `upload.html` template that comes with this app, also install the
`django-crispy-forms` package using pip:
```bash
pip install django-crispy-forms
```
### Step 2 of 5: Update `settings.py`
Make sure the following settings are all configured the way you want them in
your `settings.py`:
```
MEDIA_ROOT
MEDIA_URL
STATIC_ROOT
STATIC_URL
```
If you will be allowing regular (non-staff) users to upload photos, you will
also need to have the `DEFAULT_FROM_EMAIL` setting present in your
`settings.py` (for the notification email that gets sent out when a user
uploads a photo).
Add `'media_albums'` to your `settings.py` INSTALLED_APPS:
```python
INSTALLED_APPS = (
...
'media_albums',
...
)
```
If you will be using the templates that come with this app, also add the
following to your `settings.py` INSTALLED_APPS:
```python
INSTALLED_APPS = (
...
'bootstrap_pagination',
'sorl.thumbnail',
...
)
```
If you will be allowing regular (non-staff) users to upload photos and will be
using the `upload.html` template that comes with this app, also add
`'crispy_forms'` to your `settings.py` INSTALLED_APPS and make sure the
`CRISPY_TEMPLATE_PACK` setting is configured the way you want it:
```python
INSTALLED_APPS = (
...
'crispy_forms',
...
)
CRISPY_TEMPLATE_PACK = 'bootstrap3'
```
If you will be enabling audio and/or video and will be using the templates that
come with this app, also enable the
`'django.template.context_processors.media'` context processor:
```python
TEMPLATES = [
...
{
...
'OPTIONS': {
...
'context_processors': [
...
'django.template.context_processors.media',
...
],
...
},
...
},
...
]
```
### Step 3 of 5: Update `urls.py`
Create a URL pattern in your `urls.py`:
```python
from django.conf.urls import include, url
urlpatterns = [
...
url(r'^media-albums/', include('media_albums.urls')),
...
]
```
### Step 4 of 5: Add the database tables
Run the following command:
```bash
python manage.py migrate
```
### Step 5 of 5: Update your project's `base.html` template (if necessary)
If you will be using the templates that come with this app, make sure your
project has a `base.html` template and that it has these blocks:
```
content
extra_styles
```
## Configuration
To override any of the default settings, create a dictionary named
`MEDIA_ALBUMS` in your `settings.py` with each setting you want to override.
For example, if you wanted to enable audio and video, but leave all of the
other settings alone, you would add this to your `settings.py`:
```python
MEDIA_ALBUMS = {
'audio_files_enabled': True,
'video_files_enabled': True,
}
```
These are the settings:
### `photos_enabled` (default: `True`)
When set to `True`, albums may contain photos.
### `audio_files_enabled` (default: `False`)
When set to `True`, albums may contain audio files.
### `audio_files_format1_extension` (default: `'mp3'`)
When an audio file is uploaded, the "Audio file 1" field must have this
extension. This setting is only relevant if `audio_files_enabled` is set to
`True`.
### `audio_files_format2_extension` (default: `'ogg'`)
When an audio file is uploaded, the "Audio file 2" field must have this
extension. This setting is only relevant if `audio_files_enabled` is set to
`True`.
### `audio_files_format2_required` (default: `False`)
When set to `True`, the "Audio file 2" field will be marked as required. This
setting is only relevant if `audio_files_enabled` is set to `True`.
### `video_files_enabled` (default: `False`)
When set to `True`, albums may contain video files.
### `video_files_format1_extension` (default: `'mp4'`)
When an video file is uploaded, the "Video file 1" field must have this
extension. This setting is only relevant if `video_files_enabled` is set to
`True`.
### `video_files_format2_extension` (default: `'webm'`)
When an video file is uploaded, the "Video file 2" field must have this
extension. This setting is only relevant if `video_files_enabled` is set to
`True`.
### `video_files_format2_required` (default: `False`)
When set to `True`, the "Video file 2" field will be marked as required. This
setting is only relevant if `video_files_enabled` is set to `True`.
### `user_uploaded_photos_enabled` (default: `False`)
When set to `True`, regular (non-staff) users may upload photos. However, they
still must be approved by a staff user.
### `user_uploaded_photos_login_required` (default: `True`)
When set to `True`, regular (non-staff) users may only upload photos if they
are logged in. This setting is only relevant if `user_uploaded_photos_enabled`
is set to `True`.
### `user_uploaded_photos_album_name` (default: `'User Photos'`)
When a staff user approves a photo uploaded by a regular (non-staff) user, the
photo will be added to the album with this name. This setting is only relevant
if `user_uploaded_photos_enabled` is set to `True`.
### `user_uploaded_photos_album_slug` (default: `'user-photos'`)
When a staff user approves a photo uploaded by a regular (non-staff) user, the
photo will be added to the album with this slug. This setting is only relevant
if `user_uploaded_photos_enabled` is set to `True`.
### `paginate_by` (default: `10`)
This setting determines how many items can be on a single page. This applies to
the list of albums as well as the list of items within albums.
| VelocityWebworks/django-media-albums | README.md | Markdown | mit | 6,320 | [
30522,
1001,
6520,
23422,
2865,
4042,
1031,
999,
1031,
3857,
3570,
1033,
1006,
16770,
1024,
1013,
1013,
10001,
1011,
25022,
1012,
8917,
1013,
10146,
8545,
2497,
9316,
1013,
6520,
23422,
1011,
2865,
1011,
4042,
1012,
17917,
2290,
1029,
3589,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php require_once 'header.php';?>
<div class="page-header">
<h1><?=APP_NAME ?></h1>
</div>
<a href="auth">auth</a>
<!--echo "role=".<?=$role ?>; -->
<?php
$app = \Slim\Slim::getInstance();
// echo "user->role=".$app->user->role;
?>
<?php require_once 'footer.php';?> | winguse/GithubApp | assets/index.php | PHP | gpl-3.0 | 279 | [
30522,
1026,
1029,
25718,
5478,
1035,
2320,
1005,
20346,
1012,
25718,
1005,
1025,
1029,
1028,
1026,
4487,
2615,
2465,
1027,
1000,
3931,
1011,
20346,
1000,
1028,
1026,
1044,
2487,
1028,
1026,
1029,
1027,
10439,
1035,
2171,
1029,
1028,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.riskitbiskit.gameofflicks;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.riskitbiskit.gameofflicks", appContext.getPackageName());
}
}
| CarloAntonio/Game-Of-Flicks | GameOfFlicks/app/src/androidTest/java/com/riskitbiskit/gameofflicks/ExampleInstrumentedTest.java | Java | apache-2.0 | 762 | [
30522,
7427,
4012,
1012,
3891,
4183,
18477,
23615,
1012,
2208,
7245,
25230,
2015,
1025,
12324,
11924,
1012,
4180,
1012,
6123,
1025,
12324,
11924,
1012,
2490,
1012,
3231,
1012,
16015,
2890,
24063,
2854,
1025,
12324,
11924,
1012,
2490,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
\hypertarget{dir_69e90594a788f98104874fc223099bb1}{\section{src/precosat Directory Reference}
\label{dir_69e90594a788f98104874fc223099bb1}\index{src/precosat Directory Reference@{src/precosat Directory Reference}}
}
\subsection*{Files}
\begin{DoxyCompactItemize}
\item
file {\bfseries precobnr.\-cc}
\item
file {\bfseries precobnr.\-hh}
\item
file {\bfseries precocfg.\-hh}
\item
file {\bfseries precomain.\-cc}
\item
file {\bfseries precosat.\-cc}
\item
file {\bfseries precosat.\-hh}
\end{DoxyCompactItemize}
| MORZorg/SemOptRZ | docs/latex/dir_69e90594a788f98104874fc223099bb1.tex | TeX | gpl-3.0 | 517 | [
30522,
1032,
23760,
7559,
18150,
1063,
16101,
1035,
6353,
2063,
21057,
28154,
2549,
2050,
2581,
2620,
2620,
2546,
2683,
30524,
2683,
10322,
2487,
1065,
1063,
1032,
2930,
1063,
5034,
2278,
1013,
3653,
13186,
4017,
14176,
4431,
1065,
1032,
38... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.java110.fee.bmo.feeDiscount;
import com.alibaba.fastjson.JSONArray;
import com.java110.po.feeDiscount.FeeDiscountPo;
import org.springframework.http.ResponseEntity;
public interface IUpdateFeeDiscountBMO {
/**
* 修改费用折扣
* add by wuxw
*
* @param feeDiscountPo
* @return
*/
ResponseEntity<String> update(FeeDiscountPo feeDiscountPo, JSONArray feeDiscountRuleSpecs);
}
| java110/MicroCommunity | service-fee/src/main/java/com/java110/fee/bmo/feeDiscount/IUpdateFeeDiscountBMO.java | Java | apache-2.0 | 433 | [
30522,
7427,
4012,
1012,
9262,
14526,
2692,
1012,
7408,
1012,
1038,
5302,
1012,
5438,
2483,
3597,
16671,
1025,
12324,
4012,
1012,
4862,
3676,
3676,
1012,
3435,
22578,
2239,
1012,
1046,
3385,
2906,
9447,
1025,
12324,
4012,
1012,
9262,
14526,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* The MIT License (MIT)
*
* Copyright 2015 Anatoliy Bereznyak
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
namespace Workers;
/**
* Class Worker
* @package Bezk
* @author Анатолий Березняк <bereznyak@me.com>
* @homepage http://unrealmac.ru
* @link https://github.com/Bezk/Workers
*/
final class Worker
{
/**
* @const string номер версии скрипта
*/
const VERSION = '1.0.0-beta';
/**
* @var int PID текущего процесса
*/
private $iPID;
/**
* @var int PID родительского процесса
*/
private $iParentPID;
/**
* @var int PID процесса, при завершении которого сработает
* родительский деструктор
*/
private $iParentDestructorPID;
/**
* @var string путь к временной директории
*/
private $sTempDirectory;
/**
* @var string путь к директории для логов
*/
private $sLogsDirectory;
/**
* @var int приоритет процесса
*/
private $iWorkerPriority = 0;
/**
* @var string путь к PID файлу
*/
private $sPIDFilePath;
/**
* @var string префикс технических файлов (PID, логи)
*/
private $sFilesBasename;
/**
* @var int максимальное количество одновременно работающих процессов
*/
private $iNumberOfWorkers = 1;
/**
* @var int лимит на время исполнения дочернего процесса (в секундах)
*/
private $iMaxExecutionTimeInSeconds = 0;
/**
* @var bool флаг остановки демона
*/
private $bIsStop = false;
/**
* @var array массив работающих воркеров
*/
private $aInstances = array();
/**
* @var callable функция с программой воркера
*/
private $cExecutingFunction = null;
/**
* @var callable функция с деструктором родительского процесса
*/
private $cDestructorFunction = null;
/**
* @var callable функция с деструктором воркера
*/
private $cWorkerDestructorFunction = null;
/**
* @var callable функция выполняемая по завершению родительского процесса
*/
private $cShutdownFunction = null;
/**
* @var int время первичной задержки для асинхронного запуска в секундах
*/
private $iFirstDelayBetweenLaunch = 0;
/**
* @var int номер процесса
*/
private $iNumberWorker = 0;
/**
* @var int порядковый номер процесса
*/
private $iSerialNumberWorker = 0;
/**
* @var int время задержки между попытками запуска новых воркеров
* в милисекундах
* (при достижении максимального количества работающих воркеров)
*/
private $iDelayBetweenLaunch = 1000;
/**
* @var array массив с данными для воркеров
*/
private $aWorkers = array();
/**
* @var array ключи воркеров
*/
private $aWorkersNames = array();
/**
* @var array данные воркеров
*/
private $aWorkersData = array();
/**
* @var bool флаг цикличной работы
*/
private $bIsLooped = true;
/**
* @var bool флаг привязки к консоли
*/
private $bHookedConsole = false;
/**
* @var bool флаг вывода в консоль
*/
private $bSTDInConsole = false;
/**
* @var bool флаг подробного вывода
*/
private $bVerbose = false;
/**
* @var bool флаг последовательной (один за одним) работы
*/
private $bInSequence = false;
/**
* @var array массив мета информации процессов
*/
private $aMeta = array();
/**
* @var mixed переменная с данными, которые могут использоваться в воркере
*/
private $mInstanceData = null;
/**
* @var bool флаг "запущенности" скрипта
*/
private $bIsActive = false;
/**
* @var bool флаг первичного запуска метода run
*/
private $bIsFirstRun = true;
/**
* @var bool флаг быстрого запуска
*/
private $bFastRun = true;
/**
* @var bool флаг запуска метода run
*/
private $bIsRun = false;
/**
* @var array массив воркеров завершивших работу
*/
private $aStopped = array();
/**
* @var array массив воркеров завершивших работу
*/
private $bVerboseInOUT = false;
/**
* @var array ключ воркера
*/
private $sInstanceName = null;
/**
* @var array массив с ресурсами на потоки ввода/вывода
*/
private $STD = array(
'IN' => STDIN,
'OUT' => STDOUT,
'ERR' => STDERR
);
final public function __construct(
$bFastRun = null,
$aWorkersData = null,
callable $cExecutingFunction = null,
callable $cDestructorFunction = null,
callable $cWorkerDestructorFunction = null,
callable $cShutdownFunction = null,
$sTempDirectory = null,
$sLogsDirectory = null,
$iNumberOfWorkers = null,
$iWorkerPriority = null,
$iMaxExecutionTimeInSeconds = null,
$iFirstDelayBetweenLaunch = null,
$iDelayBetweenLaunch = null,
$bIsLooped = null,
$bInSequence = null,
$bHookedConsole = null,
$bSTDInConsole = null,
$bVerbose = null,
$bVerboseInOUT = null
)
{
declare(ticks=1);
if (isset($bInSequence))
$this->bInSequence = (bool) $bInSequence;
if ($cExecutingFunction)
$this->cExecutingFunction = (string) $cExecutingFunction;
$this->iPID = getmypid();
$this->iParentPID = $this->iPID;
$this->sTempDirectory = $sTempDirectory
? (string) $sTempDirectory
: sys_get_temp_dir();
$this->sLogsDirectory = $sLogsDirectory
? (string) $sLogsDirectory
: $this->sTempDirectory;
if ($iFirstDelayBetweenLaunch)
$this->iFirstDelayBetweenLaunch = $iFirstDelayBetweenLaunch;
$this->sFilesBasename = basename($_SERVER['PHP_SELF']);
$this->sPIDFilePath = $this->sTempDirectory
. DIRECTORY_SEPARATOR
. $this->sFilesBasename
. '.pid';
if (isset($bHookedConsole))
$this->bHookedConsole = (bool) $bHookedConsole;
if (isset($bSTDInConsole))
$this->bSTDInConsole = (bool) $bSTDInConsole;
if (isset($bIsLooped))
$this->bIsLooped = (bool) $bIsLooped;
if ($cDestructorFunction)
$this->cDestructorFunction = (string) $cDestructorFunction;
if ($cWorkerDestructorFunction)
$this->cWorkerDestructorFunction = (string) $cWorkerDestructorFunction;
if ($cShutdownFunction)
$this->cShutdownFunction = (string) $cShutdownFunction;
if ($iMaxExecutionTimeInSeconds)
$this->iMaxExecutionTimeInSeconds = (int) $iMaxExecutionTimeInSeconds;
if ($iWorkerPriority)
$this->iWorkerPriority = (int) $iWorkerPriority;
if (isset($bVerbose))
$this->bVerbose = (bool) $bVerbose;
if ($iDelayBetweenLaunch)
$this->iDelayBetweenLaunch = (int) $iDelayBetweenLaunch;
$this->bIsActive = $this->isActive();
if ($aWorkersData) {
// выставляем количество воркеров
$this->iNumberOfWorkers = count((array) $aWorkersData);
// массив имен демонов => значений для воркеров
$this->aWorkers = (array) $aWorkersData;
// массив имен демонов
$this->aWorkersNames = array_keys((array) $aWorkersData);
// массив значений для воркеров
$this->aWorkersData = array_values((array) $aWorkersData);
}
if ($iNumberOfWorkers) {
if ($aWorkersData) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "The numbers of processes" because set up'
. ' option "Workers data"'
);
} else {
$this->iNumberOfWorkers = (int) $iNumberOfWorkers;
for ($i = 1; $i <= $this->iNumberOfWorkers; $i++)
$this->aWorkers[] = null;
// массив имен демонов
$this->aWorkersNames = array_keys((array) $this->aWorkers);
// массив значений для воркеров
$this->aWorkersData = array_values((array) $this->aWorkers);
}
}
if (isset($bVerboseInOUT))
$this->bVerboseInOUT = (bool) $bVerboseInOUT;
if (isset($bFastRun))
$this->bFastRun = $bFastRun;
$this->rVerboseStream = $this->bVerboseInOUT
? $this->STD['OUT']
: $this->STD['ERR'];
$this->aStopped = $this->getInstancesKeys($this->aWorkersNames);
// быстрый старт
if ($this->bFastRun)
$this->run();
}
/**
* Деструкторы родительского и дочернего процессов
*
* @return void
*/
final public function __destruct()
{
switch (getmypid()) {
// деструктор родительского процесса
case $this->iParentDestructorPID:
$this->setStopMeta();
$this->writeInLog($this->rVerboseStream, 'Stopped');
if ($this->bVerbose)
$this->writeMeta();
$this->writeInLog(
$this->rVerboseStream,
'-----------------------------------------'
);
if ($this->cDestructorFunction)
call_user_func($this->cDestructorFunction);
unlink($this->sPIDFilePath);
break;
case $this->iParentPID:
break;
// деструктор дочерних процессов
default:
$sContent = $this->getOutput(ob_get_contents());
ob_end_clean();
echo $sContent;
$this->setStopMeta();
if ($this->bVerbose) {
$this->writeInLog($this->rVerboseStream, 'Stopped');
$this->writeMeta();
$this->writeInLog(
$this->rVerboseStream,
'-----------------------------------------'
);
}
if ($this->cWorkerDestructorFunction)
call_user_func($this->cWorkerDestructorFunction);
}
}
/**
* Класс запрещено клонировать
*
* @return void
*/
final private function __clone()
{
}
/**
* Выводит дебаг-инфо
*
* @return array
*/
public function __debugInfo()
{
return array(
'instance' => array(
'name'
=> $this->sInstanceName,
'data'
=> $this->mInstanceData,
'meta'
=> $this->aMeta,
'serial number worker'
=> $this->iSerialNumberWorker,
'number worker'
=> $this->iNumberWorker,
'PID'
=> $this->iPID,
'parent PID'
=> $this->iParentPID
),
'common' => array(
'version'
=> self::VERSION,
'parent PID'
=> $this->iParentPID,
'parent PID in file'
=> $this->getPIDFromFile(),
'PID file'
=> realpath($this->sPIDFilePath),
'fast run'
=> $this->bFastRun,
'workers'
=> $this->aWorkers,
'workers names'
=> $this->aWorkersNames,
'workers data'
=> $this->aWorkersData,
'meta'
=> $this->aMeta,
'workers program function'
=> $this->cExecutingFunction,
'parent destructor function'
=> $this->cDestructorFunction,
'worker destructor function'
=> $this->cWorkerDestructorFunction,
'shutdown function'
=> $this->cShutdownFunction,
'files prefix'
=> $this->sFilesBasename,
'temporary directory'
=> realpath($this->sTempDirectory),
'logs directory'
=> realpath($this->sLogsDirectory),
'numbers of workers'
=> $this->iNumberOfWorkers,
'worker priority'
=> $this->iWorkerPriority,
'maximum execution time limit'
=> $this->iMaxExecutionTimeInSeconds,
'first delay between launch workers'
=> $this->iFirstDelayBetweenLaunch,
'delay between attempts launch workers'
=> $this->iDelayBetweenLaunch,
'looped mode'
=> $this->bIsLooped,
'in sequence mode'
=> $this->bInSequence,
'is unhook console'
=> !$this->bHookedConsole,
'IO in console'
=> $this->bSTDInConsole,
'IO'
=> $this->STD,
'verbose mode'
=> $this->bVerbose,
'is verbose in out stream'
=> $this->bVerboseInOUT
)
);
}
/**
* Запускает работу демона (если объект вызывается как функция)
*
* @return void
*/
public function __invoke()
{
$this->run();
}
/**
* Приостанавливает работу демона
*
* @return void
*/
public function __sleep()
{
$this->iNumberOfWorkers = 0;
foreach ($this->aInstances as $iPID => $sValue) {
pcntl_waitpid($iPID, $iStatus);
if ($iStatus === 0) {
$this->aStopped[$this->aInstances[$iPID]]
= $this->aInstances[$iPID];
unset($this->aInstances[$iPID]);
}
}
pcntl_sigwaitinfo(array(SIGCONT), $aInfo);
$this->iNumberOfWorkers = count($this->aWorkers);
}
/**
* Возобновляет работу демона после остановки
*
* @return void
*/
public function __wakeup()
{
$this->bIsStop = false;
$this->iNumberOfWorkers = count($this->aWorkers);
}
/**
* Возвращает строковое представление объекта
*
* @return string
*/
public function __toString()
{
return (string) $this->sFilesBasename;
}
/**
* Отвязывает демона от консоли
*
* @return boolean
*/
private function unhookConsole()
{
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'Unhook console: Fork process and kill parent, set up children'
. ' as parent...'
);
}
$iChildPID = pcntl_fork();
if ($iChildPID === -1) {
$this->writeInLog($this->STD['ERR'], 'Fork ended with error');
return false;
}
// выходим из родительского (привязанного к консоли) процесса
if ($iChildPID)
exit(0);
// продолжим работу после завершения родительского процесса
$bResult = true;
while ($bResult)
$bResult = posix_kill($this->iPID, 0);
// делаем дочерний процесс основным
$bResult = posix_setsid();
if ($bResult === -1)
throw new WorkerException(
'Set up current process a session leader ended with error'
);
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, "\t done");
return true;
}
/**
* Запускает работу демона
*
* @return void
*/
public function run()
{
$this->aMeta['time']['start'] = round(microtime(true), 2);
// проверка окружения
$this->checkWorkflow();
$this->writeInLog(
$this->STD['OUT'],
$this->bIsLooped ? 'Looped mode' : 'One-off mode'
);
$this->bIsRun = true;
$this->bIsFirstRun = false;
// установка кастомных потоков IO
$this->setStreamsIO();
// отвязываемся от консоли
if (!$this->bHookedConsole)
$this->unhookConsole();
// назначаем функцию завершения
if ($this->cShutdownFunction)
register_shutdown_function($this->cShutdownFunction);
// необходимо обновить данные после отвязки от консоли
$this->iPID = getmypid();
$this->iParentPID = $this->iPID;
$this->iParentDestructorPID = $this->iPID;
// помечаем родительский процесс
if (function_exists('cli_set_process_title')
&& $_SERVER['TERM_PROGRAM'] !== 'Apple_Terminal'
) {
cli_set_process_title($this->sFilesBasename . '.parent');
}
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, 'Write PID...');
// фиксируем PID
$this->writePIDInFile($this->iPID);
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, "\t write PID " . $this->iPID);
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, 'Set up signal handler...');
// устанавливаем обработку сигналов
$this->setSignalHandlers();
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, "\t set");
while (!$this->bIsStop) {
$this->iSerialNumberWorker++;
$this->iNumberWorker++;
if ($this->iNumberWorker > $this->iNumberOfWorkers) {
// если демон не зациклен, выход
if (!$this->bIsLooped)
break;
// сбрасываем порядковый номер дочернего процесса
$this->iNumberWorker = 1;
}
// запущено максимальное количество дочерних процессов, ждем завершения
while(count($this->aStopped) === 0)
usleep($this->iDelayBetweenLaunch);
$this->sInstanceName = array_values($this->aStopped)[0];
unset($this->aStopped[$this->sInstanceName]);
// распределяем деление, чтобы не грузить процессор
if (
($this->iSerialNumberWorker > 1
&& $this->iSerialNumberWorker <= $this->iNumberOfWorkers)
&& $this->iFirstDelayBetweenLaunch
) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'Delay between launching instances: '
. $this->iFirstDelayBetweenLaunch . ' seconds'
);
}
sleep($this->iFirstDelayBetweenLaunch);
}
$iChildPID = pcntl_fork();
if ($iChildPID === -1) {
throw new WorkerException('Create new instance ended with error');
} elseif ($iChildPID) {
if ($this->bInSequence)
pcntl_wait($sStatus);
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'New instance: ' . $this->sInstanceName . ' PID: ' . $iChildPID
);
}
unset($this->aStopped[$this->sInstanceName]);
$this->aInstances[$iChildPID] = $this->sInstanceName;
} else {
$this->worker();
}
// выходим из цикла в дочернем процессе
if ($this->iPID !== $this->iParentPID)
break;
$this->checkZombie();
}
if ($this->iPID === $this->iParentPID) {
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, 'No work. Stopping');
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, ' waiting…');
while (count($this->aInstances))
usleep($this->iDelayBetweenLaunch);
$this->stop();
// не будем продолжать работу родительского процесса
exit(0);
}
}
private function stop()
{
$this->bIsStop = true;
while ($this->aInstances) {
foreach ($this->aInstances as $iPID => $mValue) {
$iPID = pcntl_waitpid($iPID, $iStatus, WNOHANG|WUNTRACED);
if ($iPID > 0) {
if (isset($this->aInstances[$iPID])) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'End instance: ' . $this->aInstances[$iPID]
. ' PID: ' . $iPID
);
}
$this->aStopped[$this->aInstances[$iPID]]
= $this->aInstances[$iPID];
unset($this->aInstances[$iPID]);
}
}
}
}
}
/**
* Выполняет отлов зомби-процессов
*
* @return void
*/
private function checkZombie()
{
foreach ($this->aInstances as $iPID => $mValue) {
$iPID = pcntl_waitpid($iPID, $iStatus, WNOHANG|WUNTRACED);
if ($iPID > 0) {
if (isset($this->aInstances[$iPID])) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'End instance: ' . $this->aInstances[$iPID]
. ' PID: ' . $iPID
);
}
$this->aStopped[$this->aInstances[$iPID]]
= $this->aInstances[$iPID];
unset($this->aInstances[$iPID]);
}
}
}
}
/**
* Выполняет проверку окружения
*
* @return void
*/
public function checkWorkflow()
{
// процесс не должен запускаться в нескольких экземплярах
if ($this->bIsActive)
throw new WorkerException('Already running');
// нельзя дважды запускать метод run
if (!$this->bIsFirstRun)
throw new WorkerException('Method "run" called only once');
if (!function_exists('pcntl_fork')) {
throw new WorkerException(
'PCNTL: Process control doesn\'t support.'
. ' Compile PHP with --enable-pcntl'
);
}
if (!function_exists('pcntl_wait') && $this->bInSequence) {
throw new WorkerException(
'PCNTL: Function pcntl_wait doesn\'t support.'
. ' Function "In sequence" don\'t work'
);
}
if (function_exists('pcntl_fork') && !function_exists('pcntl_sigwaitinfo')) {
$this->writeInLog(
$this->STD['OUT'],
'PCNTL: OS X doesn\'t support function pcntl_sigwaitinfo.'
. ' Send SIGTSTP or SIGSTOP return error of undefined function'
);
}
if ($this->iWorkerPriority < -20 || $this->iWorkerPriority > 20) {
throw new WorkerException(
'Incorrect value for option "workers priority".'
. ' Set value range from -20 to 20.');
}
if (!is_dir($this->sTempDirectory) || !is_writable($this->sTempDirectory)) {
throw new WorkerException(
'Incorrect value for option "temp directory" or directory'
. ' not allowed write.'
);
}
if (!is_dir($this->sLogsDirectory) || !is_writable($this->sLogsDirectory)) {
throw new WorkerException(
'Incorrect value for option "logs directory" or directory'
. ' not allowed write.'
);
}
}
/**
* Выполняет работу воркера
*
* @return void
*/
private function worker()
{
$this->iPID = getmypid();
$this->aMeta['time']['start'] = round(microtime(true), 2);
// ключ для вызова в функции пользовательской
$this->mInstanceData = (bool) $this->aWorkersData
? $this->aWorkersData[$this->iNumberWorker - 1]
: null;
if (function_exists('cli_set_process_title')
&& isset($_SERVER['TERM_PROGRAM'])
&& $_SERVER['TERM_PROGRAM'] !== 'Apple_Terminal'
) {
cli_set_process_title($this->sFilesBasename . '.' . $this->sInstanceName);
}
$this->setStreamsIO($this->sInstanceName);
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, 'PID: ' . $this->iPID);
// установка приоритета на процесс
if ($this->iWorkerPriority) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'Set process priority equal ' . $this->iWorkerPriority
);
}
$this->setPriority($this->iWorkerPriority);
}
// лимит на время исполнения дочернего процесса
if ($this->iMaxExecutionTimeInSeconds) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'Set process lifetime ' . $this->iMaxExecutionTimeInSeconds
. ' seconds'
);
}
// считает время работы скрипта
set_time_limit($this->iMaxExecutionTimeInSeconds);
// считает время исполнения вне скрипта (потоки, коннекты, sleep, etc)
pcntl_alarm($this->iMaxExecutionTimeInSeconds);
}
if ($this->bVerbose)
$this->writeInLog($this->rVerboseStream, 'Started');
// перехватываем вывод
ob_start();
// запускаем функцию
if ($this->cExecutingFunction) {
call_user_func($this->cExecutingFunction, $this->mInstanceData);
// успешно выходим
exit(0);
}
}
/**
* Обработчик сигналов
*
* @param integer $iSignalNumber
* @param integer $iPID
* @param integer $iPID
* @return void
*/
public function sigHandler($iSignalNumber, $iPID = null, $iStatus = null)
{
switch($iSignalNumber) {
// при получении сигнала завершения работы устанавливаем флаг
case SIGTERM:
case SIGHUP:
case SIGINT;
$this->stop();
break;
// сигнал от дочернего процесса
case SIGCHLD:
$iPID = pcntl_waitpid(-1, $iStatus, WNOHANG|WUNTRACED);
if ($iPID == -1) {
$this->writeInLog(
$this->STD['ERR'],
'Error receive ' . SIGCHLD . ' (sigchld) signal'
);
return true;
}
// юниксовый код выхода
$iExitCode = pcntl_wexitstatus($iStatus);
// закончим всю работу, если воркеры выходят с фатальной ошибкой
if ($iExitCode === 255)
$this->stop();
if (isset($this->aInstances[$iPID])) {
if ($this->bVerbose) {
$this->writeInLog(
$this->rVerboseStream,
'End instance: ' . $this->aInstances[$iPID]
. ' PID: ' . $iPID
);
}
$this->aStopped[$this->aInstances[$iPID]]
= $this->aInstances[$iPID];
unset($this->aInstances[$iPID]);
}
break;
case SIGALRM:
case SIGVTALRM:
// код выхода дочернего процесса
exit(1);
echo 'Child exit on timeout' . PHP_EOL;
break;
case SIGTSTP:
case SIGSTOP:
$this->__sleep();
break;
case SIGCONT:
$this->__wakeup();
break;
}
return true;
}
/**
* Возвращает флаг, является ли PID записанный в файле активным процессом
*
* @return boolean
*/
private function isActive()
{
// очищаем файловый кеш для PID файла
clearstatcache(true, $this->sPIDFilePath);
if (file_exists($this->sPIDFilePath) && is_readable($this->sPIDFilePath)) {
$iPID = $this->getPIDFromFile();
return (is_numeric($iPID) && posix_kill($iPID, 0) === true)
? true
: false;
}
return false;
}
/**
* Возвращает флаг, является ли массив ассоциативным
*
* @param array $aArray
* @return boolean
*/
private function isAssoc(array $aArray)
{
return array_keys($aArray) !== range(0, count($aArray) - 1);
}
/**
* Записывает в файл PID процесса
*
* @param integer $iPID
* @return boolean
*/
private function writePIDInFile($iPID)
{
return file_put_contents($this->sPIDFilePath, $iPID, LOCK_EX);
}
/**
* Записывает строку в файл, возвращает количество записанных байт
*
* @param resource $rLog
* @param string $sMessage
* @return integer
*/
public function writeInLog($rLog, $sMessage)
{
return fwrite(
$rLog, '[' . date('d-M-Y H:i:s e') . '] ' . $sMessage . PHP_EOL
);
}
/**
* Пишет в лог мета-информацию
*
* @return void
*/
private function writeMeta()
{
$this->writeInLog(
$this->rVerboseStream,
'Execution time: ' . round($this->aMeta['execution_time'], 2)
. ' seconds'
);
$this->writeInLog($this->rVerboseStream,
'Load average: '
. round($this->aMeta['load_average'][0], 2)
. ', ' . round($this->aMeta['load_average'][1], 2)
. ', ' . round($this->aMeta['load_average'][2], 2)
);
}
/**
* Устанавливает флаг привязки к консоли
*
* @return boolean
*/
public function setUnhookConsole($bHookedConsole) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "unhook console" because workers already run'
);
return false;
}
$this->bHookedConsole = (bool) !$bHookedConsole;
return true;
}
/**
* Устанавливает флаг цикличности
*
* @return boolean
*/
public function setLoopedMode($bIsLooped) {
$this->bIsLooped = (bool) $bIsLooped;
return true;
}
/**
* Устанавливает задержку для асинхронного запуска
*
* @return boolean
*/
public function setLaunchInstancesDelay($iFirstDelayBetweenLaunch) {
$this->iFirstDelayBetweenLaunch = $iFirstDelayBetweenLaunch;
return true;
}
/**
* Устанавливает задержку между повторными попытками запуска новых воркеров
*
* @return boolean
*/
public function setDelayBetweenLaunchAttempts($iDelayBetweenLaunch) {
$this->iDelayBetweenLaunch = $iDelayBetweenLaunch;
return true;
}
/**
* Устанавливает максимальное время работы воркеров в секундах
*
* @return boolean
*/
public function setMaxExecutionTime($iMaxExecutionTimeInSeconds) {
$this->iMaxExecutionTimeInSeconds = $iMaxExecutionTimeInSeconds;
return true;
}
/**
* Устанавливает мод подробного вывода
*
* @return boolean
*/
public function setVerboseMode($bVerbose) {
$this->bVerbose = $bVerbose;
return true;
}
/**
* Устанавливает количество воркеров
*
* @return boolean
*/
public function setNumberOfWorkers($iWorkers) {
if ($this->aWorkers) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "The numbers of processes" because set up option'
. ' "Workers data"'
);
return false;
} else {
$this->iNumberOfWorkers = (int) $iWorkers;
for ($i = 1; $i <= $this->iNumberOfWorkers; $i++)
$this->aWorkers[] = null;
// массив имен демонов
$this->aWorkersNames = array_keys((array) $this->aWorkers);
// массив значений для воркеров
$this->aWorkersData = array_values((array) $this->aWorkers);
$this->aStopped = $this->getInstancesKeys($this->aWorkersNames);
return true;
}
}
/**
* Устанавливает данные для проброса в воркер
*
* @return boolean
*/
public function setWorkersData($aWorkersData) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "workers data" because workers already run'
);
return false;
}
if ($this->iNumberOfWorkers)
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "The numbers of processes" because set up option'
. ' "Workers data"'
);
// выставляем количество воркеров
$this->iNumberOfWorkers = count((array) $aWorkersData);
// массив имен демонов => значений для воркеров
$this->aWorkers = (array) $aWorkersData;
// массив имен демонов
$this->aWorkersNames = array_keys((array) $aWorkersData);
// массив значений для воркеров
$this->aWorkersData = array_values((array) $aWorkersData);
$this->aStopped = $this->getInstancesKeys($this->aWorkersNames);
return true;
}
/**
* Устанавливает функцию, в которой находится программа воркеров
*
* @return void
*/
public function setWorkersFunction(callable $cExecutingFunction) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "workers function" because workers already run'
);
return false;
}
$this->cExecutingFunction = (string) $cExecutingFunction;
return true;
}
/**
* Устанавливает функцию деструктора родительского процесса
*
* @return void
*/
public function setDestructorFunction($cDestructorFunction) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "destructor function" because workers already run'
);
return false;
}
$this->cDestructorFunction = (string) $cDestructorFunction;
return true;
}
/**
* Устанавливает функцию деструктора дочерних процессов
*
* @return void
*/
public function setWorkercDestructorFunction($cWorkerDestructorFunction) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "workers destructor function" because workers'
. ' already run'
);
return false;
}
$this->cWorkerDestructorFunction = (string) $cWorkerDestructorFunction;
return true;
}
/**
* Устанавливает вывод потоков ввода/вывода в консоль
*
* @return void
*/
public function setIOInConsole($bSTDInConsole) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "set IO in console" because workers already run'
);
return false;
}
$this->bSTDInConsole = (bool) $bSTDInConsole;
}
/**
* Устанавливает временную директорию
*
* @return boolean
*/
public function setTempDirectory($sTempDirectory) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "set temp directory" because workers already run'
);
return false;
}
$this->sTempDirectory = $sTempDirectory;
$this->sPIDFilePath = $this->sTempDirectory
. DIRECTORY_SEPARATOR
. $this->sFilesBasename
. '.pid';
return true;
}
/**
* Устанавливает директорию логов
*
* @return boolean
*/
public function setLogsDirectory($sLogsDirectory) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "set logs directory" because workers already run'
);
return false;
}
$this->sLogsDirectory = $sLogsDirectory;
return true;
}
/**
* Устанавливает приоритет для воркерных процессов
*
* @return void
*/
public function setWorkersPriority($iWorkerPriority) {
if ($this->bIsRun) {
$this->writeInLog(
$this->STD['OUT'],
'Ignore option "set workers priority" because workers already run'
);
return false;
}
$this->iWorkerPriority = (int) $iWorkerPriority;
return true;
}
/**
* Устанавливает обработчики сигналов
*
* @return void
*/
private function setSignalHandlers() {
pcntl_signal(SIGTERM, array(&$this, "sigHandler")); // сигнал завершения работы
pcntl_signal(SIGHUP, array(&$this, "sigHandler")); // закрытия консоли
pcntl_signal(SIGINT, array(&$this, "sigHandler")); // ctrl-c c консоли
pcntl_signal(SIGALRM, array(&$this, "sigHandler")); // alarm
pcntl_signal(SIGVTALRM, array(&$this, "sigHandler")); // alarm
pcntl_signal(SIGCHLD, array(&$this, "sigHandler")); // сигналы завершения дочернего процессв
pcntl_signal(SIGTSTP, array(&$this, "sigHandler")); // сигналы остановки с консоли ctrl-z
pcntl_signal(SIGCONT, array(&$this, "sigHandler")); // продолжение работы
}
/**
* Переопределяет потоки ввода/вывода
*
* @param $sInstanceName
* @return void
*/
private function setStreamsIO($sInstanceName = null)
{
if (!$this->bSTDInConsole) {
if (!$sInstanceName)
$this->writeInLog($this->STD['OUT'], 'Reassignment STD streams');
ini_set('display_errors', 'off');
ini_set(
'error_log',
$this->sLogsDirectory
. DIRECTORY_SEPARATOR
. $this->sFilesBasename
. '.error.log'
);
$sInstanceName = ($sInstanceName)
? '.' . $sInstanceName
: null;
// закрываем потоки
fclose($this->STD['IN']);
fclose($this->STD['OUT']);
fclose($this->STD['ERR']);
// переопределяем
$this->STD['IN'] = fopen(
'/dev/null',
'r'
);
$this->STD['OUT'] = fopen(
$this->sLogsDirectory
. DIRECTORY_SEPARATOR
. $this->sFilesBasename
. $sInstanceName
. '.application.log',
'ab'
);
$this->STD['ERR'] = fopen(
$this->sLogsDirectory
. DIRECTORY_SEPARATOR
. $this->sFilesBasename
. $sInstanceName
. '.daemon.log',
'ab'
);
// переобпределяем зависимое свойство
$this->rVerboseStream = $this->bVerboseInOUT
? $this->STD['OUT']
: $this->STD['ERR'];
}
}
/**
* Устанавливает приоритет для дочерних процессов
*
* @param integer $iWorkerPriority
* @return boolean
*/
private function setPriority($iWorkerPriority)
{
return $iWorkerPriority
? pcntl_setpriority($iWorkerPriority)
: false;
}
/**
* Записывает начальную мета-информацию
*
* @return void
*/
private function setStartMeta()
{
$this->aMeta['time']['start'] = round(microtime(true), 2);
}
/**
* Записывает конечную мета-информацию
*
* @return void
*/
private function setStopMeta()
{
$this->aMeta['time']['stop'] = round(microtime(true), 2);
$this->aMeta['execution_time']
= $this->aMeta['time']['stop'] - $this->aMeta['time']['start'];
$this->aMeta['load_average'] = sys_getloadavg();
}
/**
* Возвращает имена инстансов
*
* @return array
*/
private function getInstancesKeys()
{
$bIsAssoc = $this->isAssoc($this->aWorkers);
$aKeys = array();
foreach ($this->aWorkersNames as $mKey)
$aKeys[$bIsAssoc ? $mKey : $mKey + 1] = $bIsAssoc
? $mKey
: $mKey + 1;
return $aKeys;
}
/**
* Обрабатывает строки, добавляя дату в начало строки
*
* @param string $sMessage
* @return string
*/
private function getOutput($sMessage) {
$aOutput = explode(PHP_EOL, $sMessage);
$aOUT = array();
foreach ($aOutput as $sRow) {
$aOUT[] = '[' . date('d-M-Y H:i:s e') . '] ' . rtrim($sRow);
}
return implode(PHP_EOL, $aOUT) . PHP_EOL;
}
/**
* Возвращает PID из файла
*
* @return integer
*/
private function getPIDFromFile()
{
return (int) trim(file_get_contents($this->sPIDFilePath));
}
/**
* Возвращает PID родительского процесса
*
* @return integer
*/
private function getPID()
{
return (int) $this->iParentPID;
}
/**
* Возвращает данные для использования в воркере
*
* @return mixed
*/
public function getWorkerData()
{
return $this->mInstanceData;
}
/**
* Возвращает путь к каталогу временных файлов
*
* @return string
*/
public function getTempDirectory()
{
return $this->sTempDirectory;
}
/**
* Возвращает путь к каталогу логов
*
* @return string
*/
public function getLogsDirectory()
{
return $this->sLogsDirectory;
}
/**
* Возвращает префикс файлов (имя скрипта в котором работает демон)
*
* @return string
*/
public function getFilesBasename()
{
return $this->sFilesBasename;
}
/**
* Возвращает путь к PID файлу
*
* @return string
*/
public function getPIDFilePath()
{
return $this->sPIDFilePath;
}
} | Bezk/Workers | src/Workers/Worker.php | PHP | mit | 49,415 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1996,
10210,
6105,
1006,
10210,
1007,
1008,
1008,
9385,
2325,
9617,
3406,
3669,
2100,
2022,
2890,
2480,
17238,
2243,
1008,
1008,
6656,
2003,
2182,
3762,
4379,
30524,
1000,
4007,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::DevTestLabs::Mgmt::V2018_09_15
module Models
#
# Defines values for SourceControlType
#
module SourceControlType
VsoGit = "VsoGit"
GitHub = "GitHub"
end
end
end
| Azure/azure-sdk-for-ruby | management/azure_mgmt_devtestlabs/lib/2018-09-15/generated/azure_mgmt_devtestlabs/models/source_control_type.rb | Ruby | mit | 375 | [
30522,
1001,
17181,
1024,
21183,
2546,
1011,
1022,
1001,
3642,
7013,
2011,
7513,
1006,
1054,
1007,
8285,
28533,
3642,
13103,
1012,
1001,
3431,
2089,
3426,
16542,
5248,
1998,
2097,
2022,
2439,
2065,
1996,
3642,
2003,
1001,
19723,
24454,
4383... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2009, Cybozu Labs, 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 <ORGANIZATION> 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 <Python.h>
#include <errno.h>
#include <sys/epoll.h>
#include <unistd.h>
#include "picoev.h"
#include "time_cache.h"
#ifndef PICOEV_EPOLL_DEFER_DELETES
# define PICOEV_EPOLL_DEFER_DELETES 1
#endif
typedef struct picoev_loop_epoll_st {
picoev_loop loop;
int epfd;
struct epoll_event events[1024];
} picoev_loop_epoll;
picoev_globals picoev;
picoev_loop* picoev_create_loop(int max_timeout)
{
picoev_loop_epoll* loop;
/* init parent */
assert(PICOEV_IS_INITED);
if ((loop = (picoev_loop_epoll*)malloc(sizeof(picoev_loop_epoll))) == NULL) {
return NULL;
}
if (picoev_init_loop_internal(&loop->loop, max_timeout) != 0) {
free(loop);
return NULL;
}
/* init myself */
if ((loop->epfd = epoll_create(picoev.max_fd)) == -1) {
picoev_deinit_loop_internal(&loop->loop);
free(loop);
return NULL;
}
loop->loop.now = current_msec / 1000;
return &loop->loop;
}
int picoev_destroy_loop(picoev_loop* _loop)
{
picoev_loop_epoll* loop = (picoev_loop_epoll*)_loop;
if (close(loop->epfd) != 0) {
return -1;
}
picoev_deinit_loop_internal(&loop->loop);
free(loop);
return 0;
}
int picoev_update_events_internal(picoev_loop* _loop, int fd, int events)
{
picoev_loop_epoll* loop = (picoev_loop_epoll*)_loop;
picoev_fd* target = picoev.fds + fd;
struct epoll_event ev;
int epoll_ret;
assert(PICOEV_FD_BELONGS_TO_LOOP(&loop->loop, fd));
if (unlikely((events & PICOEV_READWRITE) == target->events)) {
return 0;
}
ev.events = ((events & PICOEV_READ) != 0 ? EPOLLIN : 0)
| ((events & PICOEV_WRITE) != 0 ? EPOLLOUT : 0);
ev.data.fd = fd;
#define SET(op, check_error) do { \
epoll_ret = epoll_ctl(loop->epfd, op, fd, &ev); \
assert(! check_error || epoll_ret == 0); \
} while (0)
#if PICOEV_EPOLL_DEFER_DELETES
if ((events & PICOEV_DEL) != 0) {
/* nothing to do */
} else if ((events & PICOEV_READWRITE) == 0) {
SET(EPOLL_CTL_DEL, 1);
} else {
SET(EPOLL_CTL_MOD, 0);
if (epoll_ret != 0) {
assert(errno == ENOENT);
SET(EPOLL_CTL_ADD, 1);
}
}
#else
if ((events & PICOEV_READWRITE) == 0) {
SET(EPOLL_CTL_DEL, 1);
} else {
SET(target->events == 0 ? EPOLL_CTL_ADD : EPOLL_CTL_MOD, 1);
}
#endif
#undef SET
target->events = events;
return 0;
}
int picoev_poll_once_internal(picoev_loop* _loop, int max_wait)
{
picoev_loop_epoll* loop = (picoev_loop_epoll*)_loop;
int i, nevents;
Py_BEGIN_ALLOW_THREADS
nevents = epoll_wait(loop->epfd, loop->events,
sizeof(loop->events) / sizeof(loop->events[0]),
max_wait * 1000);
Py_END_ALLOW_THREADS
cache_time_update();
if (nevents == -1) {
return -1;
}
for (i = 0; likely(i < nevents); ++i) {
struct epoll_event* event = loop->events + i;
picoev_fd* target = picoev.fds + event->data.fd;
if (loop->loop.loop_id == target->loop_id && likely((target->events & PICOEV_READWRITE) != 0)) {
int revents = ((event->events & EPOLLIN) != 0 ? PICOEV_READ : 0) | ((event->events & EPOLLOUT) != 0 ? PICOEV_WRITE : 0);
if (likely(revents != 0)) {
(*target->callback)(&loop->loop, event->data.fd, revents, target->cb_arg);
}
} else {
#if PICOEV_EPOLL_DEFER_DELETES
event->events = 0;
epoll_ctl(loop->epfd, EPOLL_CTL_DEL, event->data.fd, event);
#endif
}
}
return 0;
}
| methane/minefield | minefield/server/picoev_epoll.c | C | bsd-3-clause | 4,974 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2268,
1010,
22330,
5092,
9759,
13625,
1010,
4297,
1012,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
2007,
2030,
2302,
1008,
14080,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <stdio.h>
#include <stdlib.h>
#include "queue.h"
#include "pingpong.h"
// --------------------------PINGPONG.C------------------------------
// Autor: Edgar Teixeira
// Trabalho desenvolvido para a disciplina de Sistemas Operacionais
// ------------------------------------------------------------------
// -------------Definição de estruturas de dados úteis---------------
typedef struct taskqueue_t {
struct taskqueue_t *prev;
struct taskqueue_t *next;
task_t* task;
} taskqueue_t;
typedef enum ExitCode {
TO_DISPATCHER = 0,
TO_MAIN = 1
} ExitCode;
// ------------------------------------------------------------------
// --------------------Variáveis globais e macros--------------------
#define STACKSIZE 32768 /* tamanho de pilha das threads */
#define _XOPEN_SOURCE 600 /* para compilar no MacOS */
#define TO_DISPATCHER 0 /* código de retorno para dispatcher */
#define TO_MAIN 1 /* código de retorno para main */
#ifndef NULL
#define NULL ((void*) 0)
#endif
// Ponteiro para a tarefa que está em execução
task_t *currentTask;
// Tarefa main
task_t mainTask;
// Tarefa dispatcher
task_t dispatcher;
// Fila de tarefas prontas para serem executadas
taskqueue_t *ready;
// Tarefa que está atualmente em execução
taskqueue_t *exec;
// ------------------------------------------------------------------
// -----------------------Tarefa Dispatcher--------------------------
task_t* scheduler() {
// Retorna o primeiro elemento da fila
exec = (taskqueue_t*) queue_remove((queue_t**) &ready, (queue_t*) ready);
return exec->task;
}
void dispatcher_body(void* arg) {
// Enquanto houverem tarefas prontas para serem executadas
while(queue_size((queue_t*) ready) > 0) {
task_t* next = scheduler();
if(next)
task_switch(next);
}
// Retorna o controle para a tarefa main
task_exit(TO_MAIN);
}
// ------------------------------------------------------------------
void pingpong_init() {
#ifdef DEBUG
puts("Ping Pong OS inicializado!\n");
#endif
/* desativa o buffer de saída padrão (stdout), usado pela função printf */
setvbuf(stdout, 0, _IONBF, 0);
// Cria a tarefa main
task_create(&mainTask, NULL, NULL);
// Ajusta a tarefa atual como a tarefa main
currentTask = &mainTask;
// Retira a tarefa main da fila de prontas
exec = (taskqueue_t*) queue_remove((queue_t**) &ready, (queue_t*) ready);
free(exec);
// Cria a tarefa dispatcher
task_create(&dispatcher, dispatcher_body, NULL);
// Retira a tarefa dispathcer da fila de prontas
exec = (taskqueue_t*) queue_remove((queue_t**) &ready, (queue_t*) ready);
free(exec);
}
int task_create(task_t *task, void (*start_routine)(void*), void *arg) {
// Variável estática para garantir unicidade do id
static int id = 0;
// Ajusta os parâmetros da tarefa
task->tid = id;
// Aloca memória para a pilha que será utilizada pelo contexto da tarefa
char* stack = (char*) malloc(STACKSIZE);
if(!stack)
return -1;
// Configura o contexto
getcontext(&task->context);
task->context.uc_stack.ss_size = STACKSIZE;
task->context.uc_link = 0;
task->context.uc_stack.ss_sp = stack;
task->context.uc_stack.ss_flags = 0;
// Ajusta a função que será executada pelo contexto
makecontext(&task->context, start_routine, 1, arg);
// Adiciona a tarefa na fila 'pronta'
taskqueue_t* item = (taskqueue_t*) malloc(sizeof(taskqueue_t));
item->prev = NULL;
item->next = NULL;
item->task = task;
queue_append((queue_t**) &ready, (queue_t*) item);
// Incrementa o id para que cada tarefa tenha um tid diferente
++id;
#ifdef DEBUG
printf("task_create: Tarefa %d criada com sucesso.\n", task->tid);
#endif
return task->tid;
}
int task_switch(task_t* task) {
#ifdef DEBUG
printf("task_switch: Trocando contexto da tarefa %d pela tarefa %d.\n", currentTask->tid, task->tid);
#endif
// Salva o contexto da tarefa em execução em uma variável temporária
ucontext_t* aux = ¤tTask->context;
// Atualiza a tarefa em execução para 'task'
currentTask = task;
// Faz a troca de contexto entre as tarefas 'currentTask' e 'task'
swapcontext(aux, &task->context);
return 0;
}
void task_exit(int exit_code) {
#ifdef DEBUG
printf("task_exit: Encerrando a tarefa %d.\n", currentTask->tid);
#endif
// Libera a memória usada pela tarefa atual
if(exec && exec->task == currentTask)
free(exec);
if(exit_code == TO_DISPATCHER)
task_switch(&dispatcher);
else
task_switch(&mainTask);
}
int task_id() {
return currentTask->tid;
}
void task_yield() {
// Adiciona a tarefa em execução na fila de prontas
queue_append((queue_t**) &ready, (queue_t*) exec);
// Retorna o controle para a tarefa dispatcher
task_switch(&dispatcher);
}
| B30S/IF66D | Dispatcher/pingpoong.c | C | mit | 4,818 | [
30522,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
19422,
12322,
1012,
1044,
1028,
1001,
2421,
1000,
24240,
1012,
1044,
1000,
1001,
2421,
1000,
17852,
26029,
2290,
1012,
1044,
1000,
1013,
1013,
1011,
1011,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* Debrief - the Open Source Maritime Analysis Application
* http://debrief.info
*
* (C) 2000-2020, Deep Blue C Technology Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html)
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*******************************************************************************/
package Debrief.Tools.Tote;
import MWC.GUI.PlainChart;
import MWC.GUI.ToolParent;
import MWC.GUI.Tools.Action;
import MWC.GUI.Tools.PlainTool;
public final class StartTote extends PlainTool {
/**
*
*/
private static final long serialVersionUID = 1L;
/////////////////////////////////////////////////////////////
// member variables
////////////////////////////////////////////////////////////
private final PlainChart _theChart;
/////////////////////////////////////////////////////////////
// constructor
////////////////////////////////////////////////////////////
public StartTote(final ToolParent theParent, final PlainChart theChart) {
super(theParent, "Step Forward", null);
_theChart = theChart;
}
@Override
public final void execute() {
_theChart.update();
}
/////////////////////////////////////////////////////////////
// member functions
////////////////////////////////////////////////////////////
@Override
public final Action getData() {
// return the product
return null;
}
}
| debrief/debrief | org.mwc.debrief.legacy/src/Debrief/Tools/Tote/StartTote.java | Java | epl-1.0 | 1,752 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { AppPage } from './app.po';
describe('material2 App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
});
});
| dylan-smith/pokerleaguemanager | spikes/Material2/e2e/app.e2e-spec.ts | TypeScript | mit | 291 | [
30522,
12324,
1063,
10439,
13704,
1065,
2013,
1005,
1012,
1013,
10439,
1012,
13433,
1005,
1025,
6235,
1006,
1005,
3430,
2475,
10439,
1005,
1010,
1006,
1007,
1027,
1028,
1063,
2292,
3931,
1024,
10439,
13704,
1025,
2077,
5243,
2818,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
title: "A Post with a Video"
description: "Custom written post descriptions are the way to go... if you're not lazy."
tags: [sample post, video]
---
<iframe width="560" height="315" src="//www.youtube.com/embed/SU3kYxJmWuQ" frameborder="0"> </iframe>
Video embeds are responsive and scale with the width of the main content block with the help of [FitVids](http://fitvidsjs.com/).
Not sure if this only effects Kramdown or if it's an issue with Markdown in general. But adding YouTube video embeds causes errors when building your Jekyll site. To fix add a space between the `<iframe>` tags and remove `allowfullscreen`. Example below:
{% highlight html %}
<iframe width="560" height="315" src="//www.youtube.com/embed/SU3kYxJmWuQ" frameborder="0"> </iframe>
{% endhighlight %} | emeraldjava/emeraldjava.github.io | jekyll/_posts/2013/2013-06-25-video-post.md | Markdown | mit | 786 | [
30522,
1011,
1011,
1011,
2516,
1024,
1000,
1037,
2695,
2007,
1037,
2678,
1000,
6412,
1024,
1000,
7661,
2517,
2695,
13271,
2024,
1996,
2126,
2000,
2175,
1012,
1012,
1012,
2065,
2017,
1005,
2128,
2025,
13971,
1012,
1000,
22073,
1024,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Obione tularensis (Coville) Ulbr. SPECIES
#### Status
ACCEPTED
#### According to
International Plant Names Index
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Magnoliopsida/Caryophyllales/Chenopodiaceae/Obione/Obione tularensis/README.md | Markdown | apache-2.0 | 183 | [
30522,
1001,
27885,
3258,
2063,
10722,
8017,
9911,
1006,
2522,
3077,
1007,
17359,
19892,
1012,
2427,
1001,
1001,
1001,
1001,
3570,
3970,
1001,
1001,
1001,
1001,
2429,
2000,
2248,
3269,
3415,
5950,
1001,
1001,
1001,
1001,
2405,
1999,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Gdata
* @subpackage Exif
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Distance.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/**
* @see Zend_Gdata_Extension
*/
require_once 'Zend/Gdata/Extension.php';
/**
* @see Zend_Gdata_Exif
*/
require_once 'Zend/Gdata/Exif.php';
/**
* Represents the exif:distance element used by the Gdata Exif extensions.
*
* @category Zend
* @package Zend_Gdata
* @subpackage Exif
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Gdata_Exif_Extension_Distance extends Zend_Gdata_Extension
{
protected $_rootNamespace = 'exif';
protected $_rootElement = 'distance';
/**
* Constructs a new Zend_Gdata_Exif_Extension_Distance object.
*
* @param string $text (optional) The value to use for this element.
*/
public function __construct($text = null)
{
$this->registerAllNamespaces(Zend_Gdata_Exif::$namespaces);
parent::__construct();
$this->setText($text);
}
}
| ivesbai/server | vendor/ZendFramework/library/Zend/Gdata/Exif/Extension/Distance.php | PHP | agpl-3.0 | 1,748 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
16729,
2094,
7705,
1008,
1008,
6105,
1008,
1008,
2023,
3120,
5371,
2003,
3395,
2000,
1996,
2047,
18667,
2094,
6105,
2008,
2003,
24378,
1008,
2007,
2023,
7427,
1999,
1996,
5371,
6105,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2007 Scott Lembcke
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/**
@file
Based on Chipmunk cpArray.
ccArray is a faster alternative to CCMutableArray, it does pretty much the
same thing (stores CCObjects and retains/releases them appropriately). It's
faster because:
- it uses a plain C interface so it doesn't incur Objective-c messaging overhead
- it assumes you know what you're doing, so it doesn't spend time on safety checks
(index out of bounds, required capacity etc.)
- comparisons are done using pointer equality instead of isEqual
*/
#ifndef CC_ARRAY_H
#define CC_ARRAY_H
#include <stdlib.h>
#include <string.h>
#include "CCMutableArray.h"
#include "CCObject.h"
namespace cocos2d {
// Easy integration
#define CCARRAYDATA_FOREACH(__array__, __object__) \
__object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
typedef struct _ccArray
{
unsigned int num, max;
CCObject** arr; //equals CCObject** arr;
} ccArray;
/** Allocates and initializes a new array with specified capacity */
static inline ccArray* ccArrayNew(unsigned int capacity)
{
if (capacity == 0)
{
capacity = 1;
}
ccArray *arr = (ccArray*)malloc( sizeof(ccArray) );
arr->num = 0;
arr->arr = (CCObject**)malloc( capacity * sizeof(CCObject*) );
arr->max = capacity;
return arr;
}
static inline void ccArrayRemoveAllObjects(ccArray *arr);
/** Frees array after removing all remaining objects. Silently ignores nil arr. */
static inline void ccArrayFree(ccArray *arr)
{
if( arr == NULL )
{
return;
}
ccArrayRemoveAllObjects(arr);
//delete arr->m_pObjectArray;
free(arr->arr);
free(arr);
}
/** Doubles array capacity */
static inline void ccArrayDoubleCapacity(ccArray *arr)
{
arr->max *= 2;
arr->arr = (CCObject**) realloc(arr->arr, arr->max * sizeof(CCObject*));
}
/** Increases array capacity such that max >= num + extra. */
static inline void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra)
{
while (arr->max < arr->num + extra)
{
ccArrayDoubleCapacity(arr);
}
}
/** Returns index of first occurence of object, UXNotFound if object not found. */
static inline unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object)
{
for ( unsigned int i = 0; i < arr->num; i++)
{
if (arr->arr[i] == object)
{
return i;
}
}
return -1;
}
/** Returns a Boolean value that indicates whether object is present in array. */
static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object)
{
return ccArrayGetIndexOfObject(arr, object) != -1;
}
/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */
static inline void ccArrayAppendObject(ccArray *arr, CCObject* object)
{
arr->arr[arr->num] = object; object->retain();
arr->num++;
}
/** Appends an object. Capacity of arr is increased if needed. */
static inline void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object)
{
ccArrayEnsureExtraCapacity(arr, 1);
ccArrayAppendObject(arr, object);
}
/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have
enough capacity. */
static inline void ccArrayAppendArray(ccArray *arr, ccArray *plusArr)
{
for( unsigned int i = 0; i < plusArr->num; i++)
{
ccArrayAppendObject(arr, plusArr->arr[i]);
}
}
/** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */
static inline void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr)
{
ccArrayEnsureExtraCapacity(arr, plusArr->num);
ccArrayAppendArray(arr, plusArr);
}
/** Removes all objects from arr */
static inline void ccArrayRemoveAllObjects(ccArray *arr)
{
while(arr->num > 0)
{
arr->arr[--arr->num]->release();
}
}
/** Removes object at specified index and pushes back all subsequent objects.
Behaviour undefined if index outside [0, num-1]. */
static inline void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index)
{
arr->arr[index]->release();
arr->num--;
int remaining = arr->num - index;
if (remaining > 0)
{
memmove(&arr->arr[index], &arr->arr[index+1], remaining * sizeof(void*));
}
}
/** Removes object at specified index and fills the gap with the last object,
thereby avoiding the need to push back subsequent objects.
Behaviour undefined if index outside [0, num-1]. */
static inline void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index)
{
arr->arr[index]->release();
unsigned int last = --arr->num;
arr->arr[index] = arr->arr[last];
}
/** Searches for the first occurance of object and removes it. If object is not
found the function has no effect. */
static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object)
{
unsigned int index = ccArrayGetIndexOfObject(arr, object);
if (index != -1)
{
ccArrayRemoveObjectAtIndex(arr, index);
}
}
/** Removes from arr all objects in minusArr. For each object in minusArr, the
first matching instance in arr will be removed. */
static inline void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
{
for( unsigned int i = 0; i < minusArr->num; i++)
{
ccArrayRemoveObject(arr, minusArr->arr[i]);
}
}
/** Removes from arr all objects in minusArr. For each object in minusArr, all
matching instances in arr will be removed. */
static inline void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
{
unsigned int back = 0;
for( unsigned int i = 0; i < arr->num; i++)
{
if( ccArrayContainsObject(minusArr, arr->arr[i]) )
{
delete arr->arr[i];
back++;
}
else
{
arr->arr[i - back] = arr->arr[i];
}
}
arr->num -= back;
}
typedef struct _ccCArray
{
unsigned int num, max;
void** arr; //equals CCObject** arr;
} ccCArray;
static inline void ccCArrayRemoveAllValues(ccCArray *arr);
/** Allocates and initializes a new C array with specified capacity */
static inline ccCArray* ccCArrayNew(unsigned int capacity)
{
if (capacity == 0)
{
capacity = 1;
}
ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) );
arr->num = 0;
arr->arr = (void**) malloc( capacity * sizeof(void*) );
arr->max = capacity;
return arr;
}
/** Frees C array after removing all remaining values. Silently ignores nil arr. */
static inline void ccCArrayFree(ccCArray *arr)
{
if( arr == NULL )
{
return;
}
ccCArrayRemoveAllValues(arr);
free(arr->arr);
free(arr);
}
/** Doubles C array capacity */
static inline void ccCArrayDoubleCapacity(ccCArray *arr)
{
arr->max *= 2;
arr->arr = (void**) realloc(arr->arr, arr->max * sizeof(void*));
}
/** Increases array capacity such that max >= num + extra. */
static inline void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra)
{
while (arr->max < arr->num + extra)
{
ccCArrayDoubleCapacity(arr);
}
}
/** Returns index of first occurence of value, NSNotFound if value not found. */
static inline int ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
{
for (unsigned int i = 0; i < arr->num; i++)
{
if (arr->arr[i] == value)
{
return i;
}
}
return -1;
}
/** Returns a Boolean value that indicates whether value is present in the C array. */
static inline bool ccCArrayContainsValue(ccCArray *arr, void* value)
{
return ccCArrayGetIndexOfValue(arr, value) != -1;
}
/** Inserts a value at a certain position. The valid index is [0, num] */
static inline void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index)
{
int remaining = arr->num - index;
// make sure it has enough capacity
if (arr->num + 1 == arr->max)
{
ccCArrayDoubleCapacity(arr);
}
// last Value doesn't need to be moved
if( remaining > 0)
{
// tex coordinates
memmove( &arr->arr[index+1],&arr->arr[index], sizeof(void*) * remaining );
}
arr->num++;
arr->arr[index] = value;
}
/** Appends an value */
static inline void ccCArrayAppendValue(ccCArray *arr, void* value)
{
arr->arr[arr->num] = value;
arr->num++;
// double the capacity for the next append action
// if the num >= max
if (arr->num >= arr->max)
{
ccCArrayDoubleCapacity(arr);
}
}
/** Appends an value. Capacity of arr is increased if needed. */
static inline void ccCArrayAppendValueWithResize(ccCArray *arr, void* value)
{
ccCArrayEnsureExtraCapacity(arr, 1);
ccCArrayAppendValue(arr, value);
}
/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have
enough capacity. */
static inline void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr)
{
for (unsigned int i = 0; i < plusArr->num; i++)
{
ccCArrayAppendValue(arr, plusArr->arr[i]);
}
}
/** Appends values from plusArr to arr. Capacity of arr is increased if needed. */
static inline void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr)
{
ccCArrayEnsureExtraCapacity(arr, plusArr->num);
ccCArrayAppendArray(arr, plusArr);
}
/** Removes all values from arr */
static inline void ccCArrayRemoveAllValues(ccCArray *arr)
{
arr->num = 0;
}
/** Removes value at specified index and pushes back all subsequent values.
Behaviour undefined if index outside [0, num-1]. */
static inline void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index)
{
for (unsigned int last = --arr->num; index < last; index++)
{
arr->arr[index] = arr->arr[index + 1];
}
}
/** Removes value at specified index and fills the gap with the last value,
thereby avoiding the need to push back subsequent values.
Behaviour undefined if index outside [0, num-1]. */
static inline void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index)
{
unsigned int last = --arr->num;
arr->arr[index] = arr->arr[last];
}
/** Searches for the first occurance of value and removes it. If value is not
found the function has no effect. */
static inline void ccCArrayRemoveValue(ccCArray *arr, void* value)
{
unsigned int index = ccCArrayGetIndexOfValue(arr, value);
if (index != -1)
{
ccCArrayRemoveValueAtIndex(arr, index);
}
}
/** Removes from arr all values in minusArr. For each Value in minusArr, the
first matching instance in arr will be removed. */
static inline void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
{
for( unsigned int i = 0; i < minusArr->num; i++)
{
ccCArrayRemoveValue(arr, minusArr->arr[i]);
}
}
/** Removes from arr all values in minusArr. For each value in minusArr, all
matching instances in arr will be removed. */
static inline void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr)
{
unsigned int back = 0;
for (unsigned int i = 0; i < arr->num; i++)
{
if( ccCArrayContainsValue(minusArr, arr->arr[i]) )
{
back++;
} else
{
arr->arr[i - back] = arr->arr[i];
}
}
arr->num -= back;
}
}
#endif // CC_ARRAY_H
| DmitriyKirakosyan/testNinjaX | libs/cocos2dx/support/data_support/ccCArray.h | C | mit | 11,872 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
capstone.controller("RegisterCtrl", function($scope,$http,AuthFactory,$location,user1){
// $(".button-collapse").sideNav();
$http.get(`states.json`)
.then((data)=>{
$scope.stateName = data.data
console.log($scope.stateName)
$('input.autocomplete').autocomplete({
data: $scope.stateName,
limit: 10 // The max amount of results that can be shown at once. Default: Infinity.
});
})
$scope.date = new Date();
let storageRef = firebase.storage().ref();
let inputElement = document.getElementById("fileInput");
inputElement.addEventListener("change", handleFiles, false)
function handleFiles() {
var fileList = this.files; /* now you can work with the file list */
console.log("filelist[0]", fileList[0])
storageRef.child(fileList[0].name).put(fileList[0])
.then(function(snapshot) {
console.log('Uploaded a blob or file!');
storageRef.child(fileList[0].name).getDownloadURL()
.then((url)=>{
var img =document.getElementById("myImg")
img.src = url;
$scope.img = img.src;
})
.catch((error)=>{
alert("error")
})
});
}
$scope.register = () => {
if($scope.user_email === $scope.user_confirmEmail){
AuthFactory.getter($scope.user_email,$scope.user_password)
.then ((data)=> {
console.log(data)
$scope.UID = data
// $http.post(`https://frontendcapstone.firebaseio.com/users/.json`,{
// uid: $scope.UID
// })
$http.post(`https://frontendcapstone.firebaseio.com/users/${$scope.UID}.json`,{
uid: $scope.UID,
Firstname: $scope.firstName,
Lastname: $scope.lastName,
email: $scope.user_email,
password: $scope.user_password,
DOB: $scope.user_dob,
imageUrl : $scope.img,
Address: {Address1: $scope.user_addressLine1,
Address2: $scope.user_addressLine2,
City: $scope.user_city,
state: $scope.user_state,
zipcode: $scope.user_zipcode}
})
Materialize.toast("registered successfully", 2000)
$location.path(`/`)
})
}
else {
Materialize.toast("Emails have to match", 1000)
$("input[type='email']").focus()
}
}
})
| priyakamesh/frontendcapstone-priya | app/controller/registerCtrl.js | JavaScript | mit | 2,390 | [
30522,
9700,
5524,
1012,
11486,
1006,
1000,
4236,
6593,
12190,
1000,
1010,
3853,
1006,
1002,
9531,
1010,
1002,
8299,
1010,
8740,
2705,
21450,
1010,
1002,
3295,
1010,
5310,
2487,
1007,
1063,
1013,
1013,
1002,
1006,
1000,
1012,
6462,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* The Apereo Foundation licenses this file to you under the Apache License,
* Version 2.0, (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tle.web.copyright;
import com.tle.beans.item.Item;
import com.tle.beans.item.ItemId;
import com.tle.beans.item.ItemKey;
import com.tle.beans.item.attachments.Attachment;
import com.tle.beans.item.attachments.IAttachment;
import com.tle.core.activation.ActivationConstants;
import com.tle.core.copyright.Holding;
import com.tle.core.copyright.Portion;
import com.tle.core.copyright.Section;
import com.tle.core.copyright.service.AgreementStatus;
import com.tle.core.copyright.service.CopyrightService;
import com.tle.core.security.TLEAclManager;
import com.tle.web.viewitem.FilestoreContentFilter;
import com.tle.web.viewitem.FilestoreContentStream;
import com.tle.web.viewurl.ViewAttachmentUrl;
import com.tle.web.viewurl.ViewItemUrl;
import com.tle.web.viewurl.ViewItemUrlFactory;
import java.io.IOException;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public abstract class AbstractCopyrightFilestoreFilter<
H extends Holding, P extends Portion, S extends Section>
implements FilestoreContentFilter {
private static final Log LOGGER = LogFactory.getLog(AbstractCopyrightFilestoreFilter.class);
@Inject private ViewItemUrlFactory urlFactory;
@Inject private TLEAclManager aclService;
@Override
public FilestoreContentStream filter(
FilestoreContentStream contentStream,
HttpServletRequest request,
HttpServletResponse response)
throws IOException {
String filepath = contentStream.getFilepath();
ItemKey itemKey = contentStream.getItemId();
CopyrightService<H, P, S> copyrightService = getCopyrightService();
ItemId itemId = ItemId.fromKey(itemKey);
Item item = copyrightService.getCopyrightedItem(itemId);
if (item != null) {
Attachment attachment = copyrightService.getSectionAttachmentForFilepath(item, filepath);
if (attachment == null) {
return contentStream;
}
AgreementStatus status;
try {
status = copyrightService.getAgreementStatus(item, attachment);
} catch (IllegalStateException bad) {
LOGGER.error("Error getting AgreementStatus", bad); // $NON-NLS-1$
return contentStream;
}
if (status.isInactive()
&& aclService
.filterNonGrantedPrivileges(ActivationConstants.VIEW_INACTIVE_PORTIONS)
.isEmpty()) {
throw copyrightService.createViolation(item);
}
if (status.isNeedsAgreement()) {
// FIXME: This creates /items/ urls, what if they came from
// /integ/ ?
ViewItemUrl vurl = urlFactory.createFullItemUrl(itemKey);
vurl.add(new ViewAttachmentUrl(attachment.getUuid()));
response.sendRedirect(vurl.getHref());
return null;
}
}
return contentStream;
}
@Override
public boolean canView(Item i, IAttachment attach) {
CopyrightService<H, P, S> copyrightService = getCopyrightService();
Item item = copyrightService.getCopyrightedItem(i.getItemId());
if (item != null) {
AgreementStatus status;
try {
status = copyrightService.getAgreementStatus(item, attach);
} catch (IllegalStateException bad) {
return false;
}
if (status.isNeedsAgreement()) {
return false;
}
}
return true;
}
protected abstract CopyrightService<H, P, S> getCopyrightService();
}
| equella/Equella | Source/Plugins/Core/com.equella.core/src/com/tle/web/copyright/AbstractCopyrightFilestoreFilter.java | Java | apache-2.0 | 4,308 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
23957,
2890,
2080,
3192,
2104,
2028,
2030,
2062,
12130,
6105,
1008,
10540,
1012,
2156,
1996,
5060,
5371,
5500,
2007,
2023,
2147,
2005,
3176,
1008,
2592,
4953,
9385,
6095,
1012,
1008,
1008,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2006-2013
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/intrusive for documentation.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_INTRUSIVE_HASHTABLE_HPP
#define BOOST_INTRUSIVE_HASHTABLE_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/intrusive_fwd.hpp>
//std C++
#include <functional> //std::equal_to
#include <utility> //std::pair
#include <algorithm> //std::swap, std::lower_bound, std::upper_bound
#include <cstddef> //std::size_t
//boost
#include <boost/intrusive/detail/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/functional/hash.hpp>
//General intrusive utilities
#include <boost/intrusive/detail/hashtable_node.hpp>
#include <boost/intrusive/detail/transform_iterator.hpp>
#include <boost/intrusive/link_mode.hpp>
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
#include <boost/intrusive/detail/is_stateful_value_traits.hpp>
#include <boost/intrusive/detail/node_to_value.hpp>
#include <boost/intrusive/detail/exception_disposer.hpp>
#include <boost/intrusive/detail/node_cloner_disposer.hpp>
#include <boost/intrusive/detail/simple_disposers.hpp>
#include <boost/intrusive/detail/size_holder.hpp>
//Implementation utilities
#include <boost/intrusive/unordered_set_hook.hpp>
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/intrusive/detail/mpl.hpp>
#include <boost/move/utility_core.hpp>
namespace boost {
namespace intrusive {
/// @cond
template<int Dummy = 0>
struct prime_list_holder
{
static const std::size_t prime_list[];
static const std::size_t prime_list_size;
};
//We only support LLP64(Win64) or LP64(most Unix) data models
#ifdef _WIN64 //In 64 bit windows sizeof(size_t) == sizeof(unsigned long long)
#define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##ULL
#define BOOST_INTRUSIVE_64_BIT_SIZE_T 1
#else //In 32 bit windows and 32/64 bit unixes sizeof(size_t) == sizeof(unsigned long)
#define BOOST_INTRUSIVE_PRIME_C(NUMBER) NUMBER##UL
#define BOOST_INTRUSIVE_64_BIT_SIZE_T (((((ULONG_MAX>>16)>>16)>>16)>>15) != 0)
#endif
template<int Dummy>
const std::size_t prime_list_holder<Dummy>::prime_list[] = {
BOOST_INTRUSIVE_PRIME_C(3), BOOST_INTRUSIVE_PRIME_C(7),
BOOST_INTRUSIVE_PRIME_C(11), BOOST_INTRUSIVE_PRIME_C(17),
BOOST_INTRUSIVE_PRIME_C(29), BOOST_INTRUSIVE_PRIME_C(53),
BOOST_INTRUSIVE_PRIME_C(97), BOOST_INTRUSIVE_PRIME_C(193),
BOOST_INTRUSIVE_PRIME_C(389), BOOST_INTRUSIVE_PRIME_C(769),
BOOST_INTRUSIVE_PRIME_C(1543), BOOST_INTRUSIVE_PRIME_C(3079),
BOOST_INTRUSIVE_PRIME_C(6151), BOOST_INTRUSIVE_PRIME_C(12289),
BOOST_INTRUSIVE_PRIME_C(24593), BOOST_INTRUSIVE_PRIME_C(49157),
BOOST_INTRUSIVE_PRIME_C(98317), BOOST_INTRUSIVE_PRIME_C(196613),
BOOST_INTRUSIVE_PRIME_C(393241), BOOST_INTRUSIVE_PRIME_C(786433),
BOOST_INTRUSIVE_PRIME_C(1572869), BOOST_INTRUSIVE_PRIME_C(3145739),
BOOST_INTRUSIVE_PRIME_C(6291469), BOOST_INTRUSIVE_PRIME_C(12582917),
BOOST_INTRUSIVE_PRIME_C(25165843), BOOST_INTRUSIVE_PRIME_C(50331653),
BOOST_INTRUSIVE_PRIME_C(100663319), BOOST_INTRUSIVE_PRIME_C(201326611),
BOOST_INTRUSIVE_PRIME_C(402653189), BOOST_INTRUSIVE_PRIME_C(805306457),
BOOST_INTRUSIVE_PRIME_C(1610612741), BOOST_INTRUSIVE_PRIME_C(3221225473),
#if BOOST_INTRUSIVE_64_BIT_SIZE_T
//Taken from Boost.MultiIndex code, thanks to Joaquin M Lopez Munoz.
BOOST_INTRUSIVE_PRIME_C(6442450939), BOOST_INTRUSIVE_PRIME_C(12884901893),
BOOST_INTRUSIVE_PRIME_C(25769803751), BOOST_INTRUSIVE_PRIME_C(51539607551),
BOOST_INTRUSIVE_PRIME_C(103079215111), BOOST_INTRUSIVE_PRIME_C(206158430209),
BOOST_INTRUSIVE_PRIME_C(412316860441), BOOST_INTRUSIVE_PRIME_C(824633720831),
BOOST_INTRUSIVE_PRIME_C(1649267441651), BOOST_INTRUSIVE_PRIME_C(3298534883309),
BOOST_INTRUSIVE_PRIME_C(6597069766657), BOOST_INTRUSIVE_PRIME_C(13194139533299),
BOOST_INTRUSIVE_PRIME_C(26388279066623), BOOST_INTRUSIVE_PRIME_C(52776558133303),
BOOST_INTRUSIVE_PRIME_C(105553116266489), BOOST_INTRUSIVE_PRIME_C(211106232532969),
BOOST_INTRUSIVE_PRIME_C(422212465066001), BOOST_INTRUSIVE_PRIME_C(844424930131963),
BOOST_INTRUSIVE_PRIME_C(1688849860263953), BOOST_INTRUSIVE_PRIME_C(3377699720527861),
BOOST_INTRUSIVE_PRIME_C(6755399441055731), BOOST_INTRUSIVE_PRIME_C(13510798882111483),
BOOST_INTRUSIVE_PRIME_C(27021597764222939), BOOST_INTRUSIVE_PRIME_C(54043195528445957),
BOOST_INTRUSIVE_PRIME_C(108086391056891903), BOOST_INTRUSIVE_PRIME_C(216172782113783843),
BOOST_INTRUSIVE_PRIME_C(432345564227567621), BOOST_INTRUSIVE_PRIME_C(864691128455135207),
BOOST_INTRUSIVE_PRIME_C(1729382256910270481), BOOST_INTRUSIVE_PRIME_C(3458764513820540933),
BOOST_INTRUSIVE_PRIME_C(6917529027641081903), BOOST_INTRUSIVE_PRIME_C(13835058055282163729),
BOOST_INTRUSIVE_PRIME_C(18446744073709551557)
#else
BOOST_INTRUSIVE_PRIME_C(4294967291)
#endif
};
#undef BOOST_INTRUSIVE_PRIME_C
#undef BOOST_INTRUSIVE_64_BIT_SIZE_T
template<int Dummy>
const std::size_t prime_list_holder<Dummy>::prime_list_size
= sizeof(prime_list)/sizeof(std::size_t);
struct hash_bool_flags
{
static const std::size_t unique_keys_pos = 1u;
static const std::size_t constant_time_size_pos = 2u;
static const std::size_t power_2_buckets_pos = 4u;
static const std::size_t cache_begin_pos = 8u;
static const std::size_t compare_hash_pos = 16u;
static const std::size_t incremental_pos = 32u;
};
namespace detail {
template<class SupposedValueTraits>
struct get_slist_impl_from_supposed_value_traits
{
typedef SupposedValueTraits value_traits;
typedef typename detail::get_node_traits
<value_traits>::type node_traits;
typedef typename get_slist_impl
<typename reduced_slist_node_traits
<node_traits>::type
>::type type;
};
template<class SupposedValueTraits>
struct unordered_bucket_impl
{
typedef typename
get_slist_impl_from_supposed_value_traits
<SupposedValueTraits>::type slist_impl;
typedef detail::bucket_impl<slist_impl> implementation_defined;
typedef implementation_defined type;
};
template<class SupposedValueTraits>
struct unordered_bucket_ptr_impl
{
typedef typename detail::get_node_traits
<SupposedValueTraits>::type::node_ptr node_ptr;
typedef typename unordered_bucket_impl
<SupposedValueTraits>::type bucket_type;
typedef typename pointer_traits
<node_ptr>::template rebind_pointer
< bucket_type >::type implementation_defined;
typedef implementation_defined type;
};
template <class T>
struct store_hash_bool
{
template<bool Add>
struct two_or_three {one _[2 + Add];};
template <class U> static one test(...);
template <class U> static two_or_three<U::store_hash> test (int);
static const std::size_t value = sizeof(test<T>(0));
};
template <class T>
struct store_hash_is_true
{
static const bool value = store_hash_bool<T>::value > sizeof(one)*2;
};
template <class T>
struct optimize_multikey_bool
{
template<bool Add>
struct two_or_three {one _[2 + Add];};
template <class U> static one test(...);
template <class U> static two_or_three<U::optimize_multikey> test (int);
static const std::size_t value = sizeof(test<T>(0));
};
template <class T>
struct optimize_multikey_is_true
{
static const bool value = optimize_multikey_bool<T>::value > sizeof(one)*2;
};
struct insert_commit_data_impl
{
std::size_t hash;
};
template<class Node, class SlistNodePtr>
inline typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::type
dcast_bucket_ptr(const SlistNodePtr &p)
{
typedef typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::type node_ptr;
return pointer_traits<node_ptr>::pointer_to(static_cast<Node&>(*p));
}
template<class NodeTraits>
struct group_functions
{
typedef NodeTraits node_traits;
typedef unordered_group_adapter<node_traits> group_traits;
typedef typename node_traits::node_ptr node_ptr;
typedef typename node_traits::node node;
typedef typename reduced_slist_node_traits
<node_traits>::type reduced_node_traits;
typedef typename reduced_node_traits::node_ptr slist_node_ptr;
typedef typename reduced_node_traits::node slist_node;
typedef circular_slist_algorithms<group_traits> group_algorithms;
static slist_node_ptr get_bucket_before_begin
(const slist_node_ptr &bucket_beg, const slist_node_ptr &bucket_end, const node_ptr &p)
{
//First find the last node of p's group.
//This requires checking the first node of the next group or
//the bucket node.
node_ptr prev_node = p;
node_ptr nxt(node_traits::get_next(p));
while(!(bucket_beg <= nxt && nxt <= bucket_end) &&
(group_traits::get_next(nxt) == prev_node)){
prev_node = nxt;
nxt = node_traits::get_next(nxt);
}
//If we've reached the bucket node just return it.
if(bucket_beg <= nxt && nxt <= bucket_end){
return nxt;
}
//Otherwise, iterate using group links until the bucket node
node_ptr first_node_of_group = nxt;
node_ptr last_node_group = group_traits::get_next(first_node_of_group);
slist_node_ptr possible_end = node_traits::get_next(last_node_group);
while(!(bucket_beg <= possible_end && possible_end <= bucket_end)){
first_node_of_group = detail::dcast_bucket_ptr<node>(possible_end);
last_node_group = group_traits::get_next(first_node_of_group);
possible_end = node_traits::get_next(last_node_group);
}
return possible_end;
}
static node_ptr get_prev_to_first_in_group(const slist_node_ptr &bucket_node, const node_ptr &first_in_group)
{
//Just iterate using group links and obtain the node
//before "first_in_group)"
node_ptr prev_node = detail::dcast_bucket_ptr<node>(bucket_node);
node_ptr nxt(node_traits::get_next(prev_node));
while(nxt != first_in_group){
prev_node = group_traits::get_next(nxt);
nxt = node_traits::get_next(prev_node);
}
return prev_node;
}
static node_ptr get_first_in_group_of_last_in_group(const node_ptr &last_in_group)
{
//Just iterate using group links and obtain the node
//before "last_in_group"
node_ptr possible_first = group_traits::get_next(last_in_group);
node_ptr possible_first_prev = group_traits::get_next(possible_first);
// The deleted node is at the end of the group, so the
// node in the group pointing to it is at the beginning
// of the group. Find that to change its pointer.
while(possible_first_prev != last_in_group){
possible_first = possible_first_prev;
possible_first_prev = group_traits::get_next(possible_first);
}
return possible_first;
}
static void erase_from_group(const slist_node_ptr &end_ptr, const node_ptr &to_erase_ptr, detail::true_)
{
node_ptr nxt_ptr(node_traits::get_next(to_erase_ptr));
node_ptr prev_in_group_ptr(group_traits::get_next(to_erase_ptr));
bool last_in_group = (end_ptr == nxt_ptr) ||
(group_traits::get_next(nxt_ptr) != to_erase_ptr);
bool is_first_in_group = node_traits::get_next(prev_in_group_ptr) != to_erase_ptr;
if(is_first_in_group && last_in_group){
group_algorithms::init(to_erase_ptr);
}
else if(is_first_in_group){
group_algorithms::unlink_after(nxt_ptr);
}
else if(last_in_group){
node_ptr first_in_group =
get_first_in_group_of_last_in_group(to_erase_ptr);
group_algorithms::unlink_after(first_in_group);
}
else{
group_algorithms::unlink_after(nxt_ptr);
}
}
static void erase_from_group(const slist_node_ptr&, const node_ptr&, detail::false_)
{}
static node_ptr get_last_in_group(const node_ptr &first_in_group, detail::true_)
{ return group_traits::get_next(first_in_group); }
static node_ptr get_last_in_group(const node_ptr &n, detail::false_)
{ return n; }
static void init_group(const node_ptr &n, true_)
{ group_algorithms::init(n); }
static void init_group(const node_ptr &, false_)
{}
static void insert_in_group(const node_ptr &first_in_group, const node_ptr &n, true_)
{
if(first_in_group){
if(group_algorithms::unique(first_in_group))
group_algorithms::link_after(first_in_group, n);
else{
group_algorithms::link_after(node_traits::get_next(first_in_group), n);
}
}
else{
group_algorithms::init_header(n);
}
}
static slist_node_ptr get_previous_and_next_in_group
( const slist_node_ptr &i, node_ptr &nxt_in_group
//If first_end_ptr == last_end_ptr, then first_end_ptr is the bucket of i
//Otherwise first_end_ptr is the first bucket and last_end_ptr the last one.
, const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr)
{
slist_node_ptr prev;
node_ptr elem(detail::dcast_bucket_ptr<node>(i));
//It's the last in group if the next_node is a bucket
slist_node_ptr nxt(node_traits::get_next(elem));
bool last_in_group = (first_end_ptr <= nxt && nxt <= last_end_ptr) ||
(group_traits::get_next(detail::dcast_bucket_ptr<node>(nxt)) != elem);
//It's the first in group if group_previous's next_node is not
//itself, as group list does not link bucket
node_ptr prev_in_group(group_traits::get_next(elem));
bool first_in_group = node_traits::get_next(prev_in_group) != elem;
if(first_in_group){
node_ptr start_pos;
if(last_in_group){
start_pos = elem;
nxt_in_group = node_ptr();
}
else{
start_pos = prev_in_group;
nxt_in_group = node_traits::get_next(elem);
}
slist_node_ptr bucket_node;
if(first_end_ptr != last_end_ptr){
bucket_node = group_functions::get_bucket_before_begin
(first_end_ptr, last_end_ptr, start_pos);
}
else{
bucket_node = first_end_ptr;
}
prev = group_functions::get_prev_to_first_in_group(bucket_node, elem);
}
else{
if(last_in_group){
nxt_in_group = group_functions::get_first_in_group_of_last_in_group(elem);
}
else{
nxt_in_group = node_traits::get_next(elem);
}
prev = group_traits::get_next(elem);
}
return prev;
}
static void insert_in_group(const node_ptr&, const node_ptr&, false_)
{}
};
template<class BucketType, class SplitTraits>
class incremental_rehash_rollback
{
private:
typedef BucketType bucket_type;
typedef SplitTraits split_traits;
incremental_rehash_rollback();
incremental_rehash_rollback & operator=(const incremental_rehash_rollback &);
incremental_rehash_rollback (const incremental_rehash_rollback &);
public:
incremental_rehash_rollback
(bucket_type &source_bucket, bucket_type &destiny_bucket, split_traits &split_traits)
: source_bucket_(source_bucket), destiny_bucket_(destiny_bucket)
, split_traits_(split_traits), released_(false)
{}
void release()
{ released_ = true; }
~incremental_rehash_rollback()
{
if(!released_){
//If an exception is thrown, just put all moved nodes back in the old bucket
//and move back the split mark.
destiny_bucket_.splice_after(destiny_bucket_.before_begin(), source_bucket_);
split_traits_.decrement();
}
}
private:
bucket_type &source_bucket_;
bucket_type &destiny_bucket_;
split_traits &split_traits_;
bool released_;
};
template<class NodeTraits>
struct node_functions
{
static void store_hash(typename NodeTraits::node_ptr p, std::size_t h, true_)
{ return NodeTraits::set_hash(p, h); }
static void store_hash(typename NodeTraits::node_ptr, std::size_t, false_)
{}
};
inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::false_)
{ return hash_value % bucket_cnt; }
inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::true_)
{ return hash_value & (bucket_cnt - 1); }
template<bool Power2Buckets, bool Incremental>
inline std::size_t hash_to_bucket_split(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split)
{
std::size_t bucket_number = detail::hash_to_bucket(hash_value, bucket_cnt, detail::bool_<Power2Buckets>());
if(Incremental)
if(bucket_number >= split)
bucket_number -= bucket_cnt/2;
return bucket_number;
}
} //namespace detail {
//!This metafunction will obtain the type of a bucket
//!from the value_traits or hook option to be used with
//!a hash container.
template<class ValueTraitsOrHookOption>
struct unordered_bucket
: public detail::unordered_bucket_impl
<typename ValueTraitsOrHookOption::
template pack<empty>::proto_value_traits
>
{};
//!This metafunction will obtain the type of a bucket pointer
//!from the value_traits or hook option to be used with
//!a hash container.
template<class ValueTraitsOrHookOption>
struct unordered_bucket_ptr
: public detail::unordered_bucket_ptr_impl
<typename ValueTraitsOrHookOption::
template pack<empty>::proto_value_traits
>
{};
//!This metafunction will obtain the type of the default bucket traits
//!(when the user does not specify the bucket_traits<> option) from the
//!value_traits or hook option to be used with
//!a hash container.
template<class ValueTraitsOrHookOption>
struct unordered_default_bucket_traits
{
typedef typename ValueTraitsOrHookOption::
template pack<empty>::proto_value_traits supposed_value_traits;
typedef typename detail::
get_slist_impl_from_supposed_value_traits
<supposed_value_traits>::type slist_impl;
typedef detail::bucket_traits_impl
<slist_impl> implementation_defined;
typedef implementation_defined type;
};
struct default_bucket_traits;
//hashtable default hook traits
struct default_hashtable_hook_applier
{ template <class T> struct apply{ typedef typename T::default_hashtable_hook type; }; };
template<>
struct is_default_hook_tag<default_hashtable_hook_applier>
{ static const bool value = true; };
struct hashtable_defaults
{
typedef default_hashtable_hook_applier proto_value_traits;
typedef std::size_t size_type;
typedef void equal;
typedef void hash;
typedef default_bucket_traits bucket_traits;
static const bool constant_time_size = true;
static const bool power_2_buckets = false;
static const bool cache_begin = false;
static const bool compare_hash = false;
static const bool incremental = false;
};
template<class ValueTraits, bool IsConst>
struct downcast_node_to_value_t
: public detail::node_to_value<ValueTraits, IsConst>
{
typedef detail::node_to_value<ValueTraits, IsConst> base_t;
typedef typename base_t::result_type result_type;
typedef ValueTraits value_traits;
typedef typename detail::get_slist_impl
<typename detail::reduced_slist_node_traits
<typename value_traits::node_traits>::type
>::type slist_impl;
typedef typename detail::add_const_if_c
<typename slist_impl::node, IsConst>::type & first_argument_type;
typedef typename detail::add_const_if_c
< typename ValueTraits::node_traits::node
, IsConst>::type & intermediate_argument_type;
typedef typename pointer_traits
<typename ValueTraits::pointer>::
template rebind_pointer
<const ValueTraits>::type const_value_traits_ptr;
downcast_node_to_value_t(const const_value_traits_ptr &ptr)
: base_t(ptr)
{}
result_type operator()(first_argument_type arg) const
{ return this->base_t::operator()(static_cast<intermediate_argument_type>(arg)); }
};
template<class F, class SlistNodePtr, class NodePtr>
struct node_cast_adaptor
: private detail::ebo_functor_holder<F>
{
typedef detail::ebo_functor_holder<F> base_t;
typedef typename pointer_traits<SlistNodePtr>::element_type slist_node;
typedef typename pointer_traits<NodePtr>::element_type node;
template<class ConvertibleToF, class RealValuTraits>
node_cast_adaptor(const ConvertibleToF &c2f, const RealValuTraits *traits)
: base_t(base_t(c2f, traits))
{}
typename base_t::node_ptr operator()(const slist_node &to_clone)
{ return base_t::operator()(static_cast<const node &>(to_clone)); }
void operator()(SlistNodePtr to_clone)
{
base_t::operator()(pointer_traits<NodePtr>::pointer_to(static_cast<node &>(*to_clone)));
}
};
static const std::size_t hashtable_data_bool_flags_mask =
( hash_bool_flags::cache_begin_pos
| hash_bool_flags::constant_time_size_pos
| hash_bool_flags::incremental_pos
);
//bucket_plus_vtraits stores ValueTraits + BucketTraits
//this data is needed by iterators to obtain the
//value from the iterator and detect the bucket
template<class ValueTraits, class BucketTraits>
struct bucket_plus_vtraits : public ValueTraits
{
typedef BucketTraits bucket_traits;
typedef ValueTraits value_traits;
static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
typedef typename
detail::get_slist_impl_from_supposed_value_traits
<value_traits>::type slist_impl;
typedef typename value_traits::node_traits node_traits;
typedef unordered_group_adapter<node_traits> group_traits;
typedef typename slist_impl::iterator siterator;
typedef typename slist_impl::size_type size_type;
typedef detail::bucket_impl<slist_impl> bucket_type;
typedef detail::group_functions<node_traits> group_functions_t;
typedef typename slist_impl::node_algorithms node_algorithms;
typedef typename slist_impl::node_ptr slist_node_ptr;
typedef typename node_traits::node_ptr node_ptr;
typedef typename node_traits::node node;
typedef typename value_traits::value_type value_type;
typedef circular_slist_algorithms<group_traits> group_algorithms;
typedef typename pointer_traits
<typename value_traits::pointer>::
template rebind_pointer
<const value_traits>::type const_value_traits_ptr;
typedef typename pointer_traits
<typename value_traits::pointer>::
template rebind_pointer
<const bucket_plus_vtraits>::type const_bucket_value_traits_ptr;
typedef typename detail::unordered_bucket_ptr_impl
<value_traits>::type bucket_ptr;
typedef detail::bool_<detail::optimize_multikey_is_true
<node_traits>::value> optimize_multikey_t;
template<class BucketTraitsType>
bucket_plus_vtraits(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits)
: ValueTraits(val_traits), bucket_traits_(::boost::forward<BucketTraitsType>(b_traits))
{}
bucket_plus_vtraits & operator =(const bucket_plus_vtraits &x)
{ bucket_traits_ = x.bucket_traits_; return *this; }
const_value_traits_ptr priv_value_traits_ptr() const
{ return pointer_traits<const_value_traits_ptr>::pointer_to(this->priv_value_traits()); }
//bucket_value_traits
//
const bucket_plus_vtraits &get_bucket_value_traits() const
{ return *this; }
bucket_plus_vtraits &get_bucket_value_traits()
{ return *this; }
const_bucket_value_traits_ptr bucket_value_traits_ptr() const
{ return pointer_traits<const_bucket_value_traits_ptr>::pointer_to(this->get_bucket_value_traits()); }
//value traits
//
const value_traits &priv_value_traits() const
{ return *this; }
value_traits &priv_value_traits()
{ return *this; }
//bucket_traits
//
const bucket_traits &priv_bucket_traits() const
{ return this->bucket_traits_; }
bucket_traits &priv_bucket_traits()
{ return this->bucket_traits_; }
//bucket operations
bucket_ptr priv_bucket_pointer() const
{ return this->priv_bucket_traits().bucket_begin(); }
typename slist_impl::size_type priv_bucket_count() const
{ return this->priv_bucket_traits().bucket_count(); }
bucket_ptr priv_invalid_bucket() const
{
const bucket_traits &rbt = this->priv_bucket_traits();
return rbt.bucket_begin() + rbt.bucket_count();
}
siterator priv_invalid_local_it() const
{ return this->priv_bucket_traits().bucket_begin()->before_begin(); }
static siterator priv_get_last(bucket_type &b, detail::true_) //optimize multikey
{
//First find the last node of p's group.
//This requires checking the first node of the next group or
//the bucket node.
slist_node_ptr end_ptr(b.end().pointed_node());
node_ptr possible_end(node_traits::get_next( detail::dcast_bucket_ptr<node>(end_ptr)));
node_ptr last_node_group(possible_end);
while(end_ptr != possible_end){
last_node_group = group_traits::get_next(detail::dcast_bucket_ptr<node>(possible_end));
possible_end = node_traits::get_next(last_node_group);
}
return bucket_type::s_iterator_to(*last_node_group);
}
static siterator priv_get_last(bucket_type &b, detail::false_) //NOT optimize multikey
{ return b.previous(b.end()); }
static siterator priv_get_previous(bucket_type &b, siterator i, detail::true_) //optimize multikey
{
node_ptr elem(detail::dcast_bucket_ptr<node>(i.pointed_node()));
node_ptr prev_in_group(group_traits::get_next(elem));
bool first_in_group = node_traits::get_next(prev_in_group) != elem;
typename bucket_type::node &n = first_in_group
? *group_functions_t::get_prev_to_first_in_group(b.end().pointed_node(), elem)
: *group_traits::get_next(elem)
;
return bucket_type::s_iterator_to(n);
}
static siterator priv_get_previous(bucket_type &b, siterator i, detail::false_) //NOT optimize multikey
{ return b.previous(i); }
static void priv_clear_group_nodes(bucket_type &b, detail::true_) //optimize multikey
{
siterator it(b.begin()), itend(b.end());
while(it != itend){
node_ptr to_erase(detail::dcast_bucket_ptr<node>(it.pointed_node()));
++it;
group_algorithms::init(to_erase);
}
}
static void priv_clear_group_nodes(bucket_type &, detail::false_) //NOT optimize multikey
{}
std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_) //optimize multikey
{
const bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
slist_node_ptr bb = group_functions_t::get_bucket_before_begin
( f->end().pointed_node()
, l->end().pointed_node()
, detail::dcast_bucket_ptr<node>(it.pointed_node()));
//Now get the bucket_impl from the iterator
const bucket_type &b = static_cast<const bucket_type&>
(bucket_type::slist_type::container_from_end_iterator(bucket_type::s_iterator_to(*bb)));
//Now just calculate the index b has in the bucket array
return static_cast<size_type>(&b - &*f);
}
std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_) //NO optimize multikey
{
bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
slist_node_ptr first_ptr(f->cend().pointed_node())
, last_ptr(l->cend().pointed_node());
//The end node is embedded in the singly linked list:
//iterate until we reach it.
while(!(first_ptr <= it.pointed_node() && it.pointed_node() <= last_ptr)){
++it;
}
//Now get the bucket_impl from the iterator
const bucket_type &b = static_cast<const bucket_type&>
(bucket_type::container_from_end_iterator(it));
//Now just calculate the index b has in the bucket array
return static_cast<std::size_t>(&b - &*f);
}
static std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) //store_hash
{ return node_traits::get_hash(detail::dcast_bucket_ptr<node>(n)); }
static std::size_t priv_stored_hash(slist_node_ptr, detail::false_) //NO store_hash (This should never be called)
{ BOOST_INTRUSIVE_INVARIANT_ASSERT(0); return 0; }
node &priv_value_to_node(value_type &v)
{ return *this->priv_value_traits().to_node_ptr(v); }
const node &priv_value_to_node(const value_type &v) const
{ return *this->priv_value_traits().to_node_ptr(v); }
value_type &priv_value_from_slist_node(slist_node_ptr n)
{ return *this->priv_value_traits().to_value_ptr(detail::dcast_bucket_ptr<node>(n)); }
const value_type &priv_value_from_slist_node(slist_node_ptr n) const
{ return *this->priv_value_traits().to_value_ptr(detail::dcast_bucket_ptr<node>(n)); }
void priv_clear_buckets(const bucket_ptr buckets_ptr, const size_type bucket_cnt)
{
bucket_ptr buckets_it = buckets_ptr;
for(size_type bucket_i = 0; bucket_i != bucket_cnt; ++buckets_it, ++bucket_i){
if(safemode_or_autounlink){
bucket_plus_vtraits::priv_clear_group_nodes(*buckets_it, optimize_multikey_t());
buckets_it->clear_and_dispose(detail::init_disposer<node_algorithms>());
}
else{
buckets_it->clear();
}
}
}
bucket_traits bucket_traits_;
};
template<class Hash, class T>
struct get_hash
{
typedef Hash type;
};
template<class T>
struct get_hash<void, T>
{
typedef ::boost::hash<T> type;
};
//bucket_hash_t
//Stores bucket_plus_vtraits plust the hash function
template<class VoidOrKeyHash, class ValueTraits, class BucketTraits>
struct bucket_hash_t
: public detail::ebo_functor_holder
<typename get_hash< VoidOrKeyHash
, typename bucket_plus_vtraits<ValueTraits,BucketTraits>::value_traits::value_type
>::type
>
{
typedef typename bucket_plus_vtraits<ValueTraits,BucketTraits>::value_traits value_traits;
typedef typename value_traits::value_type value_type;
typedef typename value_traits::node_traits node_traits;
typedef typename get_hash< VoidOrKeyHash, value_type>::type hasher;
typedef BucketTraits bucket_traits;
typedef bucket_plus_vtraits<ValueTraits, BucketTraits> bucket_plus_vtraits_t;
template<class BucketTraitsType>
bucket_hash_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h)
: detail::ebo_functor_holder<hasher>(h), internal(val_traits, ::boost::forward<BucketTraitsType>(b_traits))
{}
const hasher &priv_hasher() const
{ return this->detail::ebo_functor_holder<hasher>::get(); }
hasher &priv_hasher()
{ return this->detail::ebo_functor_holder<hasher>::get(); }
std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const //For store_hash == true
{ return node_traits::get_hash(this->internal.priv_value_traits().to_node_ptr(v)); }
std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const //For store_hash == false
{ return this->priv_hasher()(v); }
bucket_plus_vtraits_t internal; //4
};
template<class EqualTo, class T>
struct get_equal_to
{
typedef EqualTo type;
};
template<class T>
struct get_equal_to<void, T>
{
typedef ::std::equal_to<T> type;
};
//bucket_hash_equal_t
//Stores bucket_hash_t and the equality function when the first
//non-empty bucket shall not be cached.
template<class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits, bool>
struct bucket_hash_equal_t
: public detail::ebo_functor_holder //equal
<typename get_equal_to< VoidOrKeyEqual
, typename bucket_plus_vtraits<ValueTraits,BucketTraits>::value_traits::value_type
>::type
>
{
typedef bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> bucket_hash_type;
typedef bucket_plus_vtraits<ValueTraits,BucketTraits> bucket_plus_vtraits_t;
typedef typename bucket_plus_vtraits_t::value_traits value_traits;
typedef typename get_equal_to< VoidOrKeyEqual
, typename value_traits::value_type
>::type value_equal;
typedef typename bucket_hash_type::hasher hasher;
typedef BucketTraits bucket_traits;
typedef typename bucket_plus_vtraits_t::slist_impl slist_impl;
typedef typename slist_impl::size_type size_type;
typedef typename slist_impl::iterator siterator;
typedef detail::bucket_impl<slist_impl> bucket_type;
typedef typename detail::unordered_bucket_ptr_impl<value_traits>::type bucket_ptr;
template<class BucketTraitsType>
bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e)
: detail::ebo_functor_holder<value_equal>(e)
, internal(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h)
{}
bucket_ptr priv_get_cache()
{ return this->internal.internal.priv_bucket_pointer(); }
void priv_set_cache(const bucket_ptr &)
{}
size_type priv_get_cache_bucket_num()
{ return 0u; }
void priv_initialize_cache()
{}
void priv_swap_cache(bucket_hash_equal_t &)
{}
siterator priv_begin() const
{
size_type n = 0;
size_type bucket_cnt = this->internal.internal.priv_bucket_count();
for (n = 0; n < bucket_cnt; ++n){
bucket_type &b = this->internal.internal.priv_bucket_pointer()[n];
if(!b.empty()){
return b.begin();
}
}
return this->internal.internal.priv_invalid_local_it();
}
void priv_insertion_update_cache(size_type)
{}
void priv_erasure_update_cache_range(size_type, size_type)
{}
void priv_erasure_update_cache()
{}
const value_equal &priv_equal() const
{ return this->detail::ebo_functor_holder<value_equal>::get(); }
value_equal &priv_equal()
{ return this->detail::ebo_functor_holder<value_equal>::get(); }
bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> internal; //3
};
//bucket_hash_equal_t
//Stores bucket_hash_t and the equality function when the first
//non-empty bucket shall be cached.
template<class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits> //cache_begin == true version
struct bucket_hash_equal_t<VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits, true>
: public detail::ebo_functor_holder //equal
<typename get_equal_to< VoidOrKeyEqual
, typename bucket_plus_vtraits<ValueTraits,BucketTraits>::value_traits::value_type
>::type
>
{
typedef bucket_plus_vtraits<ValueTraits, BucketTraits> bucket_plus_vtraits_t;
typedef bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> bucket_hash_type;
typedef typename bucket_plus_vtraits
<ValueTraits,BucketTraits>::value_traits value_traits;
typedef typename get_equal_to
< VoidOrKeyEqual
, typename value_traits::value_type>::type value_equal;
typedef typename bucket_hash_type::hasher hasher;
typedef BucketTraits bucket_traits;
typedef typename bucket_plus_vtraits_t::slist_impl::size_type size_type;
typedef typename bucket_plus_vtraits_t::slist_impl::iterator siterator;
template<class BucketTraitsType>
bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e)
: detail::ebo_functor_holder<value_equal>(e)
, internal(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h)
{}
typedef typename detail::unordered_bucket_ptr_impl
<typename bucket_hash_type::value_traits>::type bucket_ptr;
bucket_ptr &priv_get_cache()
{ return cached_begin_; }
const bucket_ptr &priv_get_cache() const
{ return cached_begin_; }
void priv_set_cache(const bucket_ptr &p)
{ cached_begin_ = p; }
std::size_t priv_get_cache_bucket_num()
{ return this->cached_begin_ - this->internal.internal.priv_bucket_pointer(); }
void priv_initialize_cache()
{ this->cached_begin_ = this->internal.internal.priv_invalid_bucket(); }
void priv_swap_cache(bucket_hash_equal_t &other)
{
std::swap(this->cached_begin_, other.cached_begin_);
}
siterator priv_begin() const
{
if(this->cached_begin_ == this->internal.internal.priv_invalid_bucket()){
return this->internal.internal.priv_invalid_local_it();
}
else{
return this->cached_begin_->begin();
}
}
void priv_insertion_update_cache(size_type insertion_bucket)
{
bucket_ptr p = this->internal.internal.priv_bucket_pointer() + insertion_bucket;
if(p < this->cached_begin_){
this->cached_begin_ = p;
}
}
const value_equal &priv_equal() const
{ return this->detail::ebo_functor_holder<value_equal>::get(); }
value_equal &priv_equal()
{ return this->detail::ebo_functor_holder<value_equal>::get(); }
void priv_erasure_update_cache_range(size_type first_bucket_num, size_type last_bucket_num)
{
//If the last bucket is the end, the cache must be updated
//to the last position if all
if(this->priv_get_cache_bucket_num() == first_bucket_num &&
this->internal.internal.priv_bucket_pointer()[first_bucket_num].empty() ){
this->priv_set_cache(this->internal.internal.priv_bucket_pointer() + last_bucket_num);
this->priv_erasure_update_cache();
}
}
void priv_erasure_update_cache()
{
if(this->cached_begin_ != this->internal.internal.priv_invalid_bucket()){
size_type current_n = this->priv_get_cache() - this->internal.internal.priv_bucket_pointer();
for( const size_type num_buckets = this->internal.internal.priv_bucket_count()
; current_n < num_buckets
; ++current_n, ++this->priv_get_cache()){
if(!this->priv_get_cache()->empty()){
return;
}
}
this->priv_initialize_cache();
}
}
bucket_ptr cached_begin_;
bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> internal; //2
};
//hashdata_internal
//Stores bucket_hash_equal_t and split_traits
template<class SizeType, std::size_t BoolFlags, class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits>
struct hashdata_internal
: public detail::size_holder< 0 != (BoolFlags & hash_bool_flags::incremental_pos), SizeType, int> //split_traits
{
typedef bucket_hash_equal_t
< VoidOrKeyHash, VoidOrKeyEqual
, ValueTraits, BucketTraits
, 0 != (BoolFlags & hash_bool_flags::cache_begin_pos)
> internal_type;
typedef typename internal_type::value_equal value_equal;
typedef typename internal_type::hasher hasher;
typedef bucket_plus_vtraits<ValueTraits,BucketTraits> bucket_plus_vtraits_t;
typedef typename bucket_plus_vtraits_t::size_type size_type;
typedef typename bucket_plus_vtraits_t::bucket_ptr bucket_ptr;
typedef detail::size_holder
<0 != (BoolFlags & hash_bool_flags::incremental_pos)
, SizeType, int> split_traits;
typedef typename bucket_plus_vtraits_t::
value_traits::node_traits node_traits;
typedef detail::bool_<detail::optimize_multikey_is_true
<node_traits>::value> optimize_multikey_t;
template<class BucketTraitsType>
hashdata_internal( const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits
, const hasher & h, const value_equal &e)
: internal(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h, e)
{}
split_traits &priv_split_traits()
{ return *this; }
const split_traits &priv_split_traits() const
{ return *this; }
~hashdata_internal()
{ this->priv_clear_buckets(); }
void priv_clear_buckets()
{
this->internal.internal.internal.priv_clear_buckets
( this->internal.priv_get_cache()
, this->internal.internal.internal.priv_bucket_count()
- (this->internal.priv_get_cache()
- this->internal.internal.internal.priv_bucket_pointer()));
}
void priv_clear_buckets_and_cache()
{
this->priv_clear_buckets();
this->internal.priv_initialize_cache();
}
void priv_initialize_buckets_and_cache()
{
this->internal.internal.internal.priv_clear_buckets
( this->internal.internal.internal.priv_bucket_pointer()
, this->internal.internal.internal.priv_bucket_count());
this->internal.priv_initialize_cache();
}
internal_type internal; //2
};
//hashtable_data_t
//Stores hashdata_internal and size_traits
template<class SizeType, std::size_t BoolFlags, class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits>
struct hashtable_data_t
: public detail::size_holder
< 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos), SizeType> //size_traits
{
typedef detail::size_holder
< 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos)
, SizeType> size_traits;
typedef hashdata_internal
< SizeType
, BoolFlags & (hash_bool_flags::incremental_pos | hash_bool_flags::cache_begin_pos)
, VoidOrKeyHash, VoidOrKeyEqual
, ValueTraits, BucketTraits> internal_type;
typedef ValueTraits value_traits;
typedef typename internal_type::value_equal value_equal;
typedef typename internal_type::hasher hasher;
typedef BucketTraits bucket_traits;
typedef bucket_plus_vtraits
<ValueTraits,BucketTraits> bucket_plus_vtraits_t;
template<class BucketTraitsType>
hashtable_data_t( BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h
, const value_equal &e, const value_traits &val_traits)
: internal(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h, e)
{}
internal_type internal; //1
};
/// @endcond
//! The class template hashtable is an intrusive hash table container, that
//! is used to construct intrusive unordered_set and unordered_multiset containers. The
//! no-throw guarantee holds only, if the VoidOrKeyEqual object and Hasher don't throw.
//!
//! hashtable is a semi-intrusive container: each object to be stored in the
//! container must contain a proper hook, but the container also needs
//! additional auxiliary memory to work: hashtable needs a pointer to an array
//! of type `bucket_type` to be passed in the constructor. This bucket array must
//! have at least the same lifetime as the container. This makes the use of
//! hashtable more complicated than purely intrusive containers.
//! `bucket_type` is default-constructible, copyable and assignable
//!
//! The template parameter \c T is the type to be managed by the container.
//! The user can specify additional options and if no options are provided
//! default options are used.
//!
//! The container supports the following options:
//! \c base_hook<>/member_hook<>/value_traits<>,
//! \c constant_time_size<>, \c size_type<>, \c hash<> and \c equal<>
//! \c bucket_traits<>, power_2_buckets<>, cache_begin<> and incremental<>.
//!
//! hashtable only provides forward iterators but it provides 4 iterator types:
//! iterator and const_iterator to navigate through the whole container and
//! local_iterator and const_local_iterator to navigate through the values
//! stored in a single bucket. Local iterators are faster and smaller.
//!
//! It's not recommended to use non constant-time size hashtables because several
//! key functions, like "empty()", become non-constant time functions. Non
//! constant_time size hashtables are mainly provided to support auto-unlink hooks.
//!
//! hashtables, does not make automatic rehashings nor
//! offers functions related to a load factor. Rehashing can be explicitly requested
//! and the user must provide a new bucket array that will be used from that moment.
//!
//! Since no automatic rehashing is done, iterators are never invalidated when
//! inserting or erasing elements. Iterators are only invalidated when rehashing.
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
template<class T, class ...Options>
#else
template<class ValueTraits, class VoidOrKeyHash, class VoidOrKeyEqual, class SizeType, class BucketTraits, std::size_t BoolFlags>
#endif
class hashtable_impl
: private hashtable_data_t
< SizeType
, BoolFlags & hashtable_data_bool_flags_mask
, VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits>
{
typedef hashtable_data_t
< SizeType
, BoolFlags & hashtable_data_bool_flags_mask
, VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> data_type;
public:
typedef ValueTraits value_traits;
/// @cond
typedef BucketTraits bucket_traits;
typedef typename detail::get_slist_impl
<typename detail::reduced_slist_node_traits
<typename value_traits::node_traits>::type
>::type slist_impl;
typedef bucket_plus_vtraits<ValueTraits, BucketTraits> bucket_plus_vtraits_t;
typedef typename bucket_plus_vtraits_t::const_value_traits_ptr const_value_traits_ptr;
/// @endcond
typedef typename value_traits::pointer pointer;
typedef typename value_traits::const_pointer const_pointer;
typedef typename value_traits::value_type value_type;
typedef typename pointer_traits<pointer>::reference reference;
typedef typename pointer_traits<const_pointer>::reference const_reference;
typedef typename pointer_traits<pointer>::difference_type difference_type;
typedef SizeType size_type;
typedef value_type key_type;
typedef typename data_type::value_equal key_equal;
typedef typename data_type::value_equal value_equal;
typedef typename data_type::hasher hasher;
typedef detail::bucket_impl<slist_impl> bucket_type;
typedef typename pointer_traits
<pointer>::template rebind_pointer
< bucket_type >::type bucket_ptr;
typedef typename pointer_traits
<pointer>::template rebind_pointer
< const bucket_type >::type const_bucket_ptr;
typedef typename pointer_traits
<bucket_ptr>::reference bucket_reference;
typedef typename pointer_traits
<bucket_ptr>::reference const_bucket_reference;
typedef typename slist_impl::iterator siterator;
typedef typename slist_impl::const_iterator const_siterator;
typedef hashtable_iterator<bucket_plus_vtraits_t, false> iterator;
typedef hashtable_iterator<bucket_plus_vtraits_t, true> const_iterator;
typedef typename value_traits::node_traits node_traits;
typedef typename node_traits::node node;
typedef typename pointer_traits
<pointer>::template rebind_pointer
< node >::type node_ptr;
typedef typename pointer_traits
<pointer>::template rebind_pointer
< const node >::type const_node_ptr;
typedef typename pointer_traits
<node_ptr>::reference node_reference;
typedef typename pointer_traits
<const_node_ptr>::reference const_node_reference;
typedef typename slist_impl::node_algorithms node_algorithms;
static const bool stateful_value_traits = detail::is_stateful_value_traits<value_traits>::value;
static const bool store_hash = detail::store_hash_is_true<node_traits>::value;
static const bool unique_keys = 0 != (BoolFlags & hash_bool_flags::unique_keys_pos);
static const bool constant_time_size = 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos);
static const bool cache_begin = 0 != (BoolFlags & hash_bool_flags::cache_begin_pos);
static const bool compare_hash = 0 != (BoolFlags & hash_bool_flags::compare_hash_pos);
static const bool incremental = 0 != (BoolFlags & hash_bool_flags::incremental_pos);
static const bool power_2_buckets = incremental || (0 != (BoolFlags & hash_bool_flags::power_2_buckets_pos));
static const bool optimize_multikey
= detail::optimize_multikey_is_true<node_traits>::value && !unique_keys;
/// @cond
private:
//Configuration error: compare_hash<> can't be specified without store_hash<>
//See documentation for more explanations
BOOST_STATIC_ASSERT((!compare_hash || store_hash));
typedef typename slist_impl::node_ptr slist_node_ptr;
typedef typename pointer_traits
<slist_node_ptr>::template rebind_pointer
< void >::type void_pointer;
//We'll define group traits, but these won't be instantiated if
//optimize_multikey is not true
typedef unordered_group_adapter<node_traits> group_traits;
typedef circular_slist_algorithms<group_traits> group_algorithms;
typedef detail::bool_<store_hash> store_hash_t;
typedef detail::bool_<optimize_multikey> optimize_multikey_t;
typedef detail::bool_<cache_begin> cache_begin_t;
typedef detail::bool_<power_2_buckets> power_2_buckets_t;
typedef detail::size_holder<constant_time_size, size_type> size_traits;
typedef detail::size_holder<incremental, size_type, int> split_traits;
typedef detail::group_functions<node_traits> group_functions_t;
typedef detail::node_functions<node_traits> node_functions_t;
private:
//noncopyable, movable
BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable_impl)
static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
//Constant-time size is incompatible with auto-unlink hooks!
BOOST_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink)));
//Cache begin is incompatible with auto-unlink hooks!
BOOST_STATIC_ASSERT(!(cache_begin && ((int)value_traits::link_mode == (int)auto_unlink)));
template<class Disposer>
node_cast_adaptor< detail::node_disposer<Disposer, value_traits, CircularSListAlgorithms>
, slist_node_ptr, node_ptr >
make_node_disposer(const Disposer &disposer) const
{
return node_cast_adaptor
< detail::node_disposer<Disposer, value_traits, CircularSListAlgorithms>
, slist_node_ptr, node_ptr >
(disposer, &this->priv_value_traits());
}
/// @endcond
public:
typedef detail::insert_commit_data_impl insert_commit_data;
typedef detail::transform_iterator
< typename slist_impl::iterator
, downcast_node_to_value_t
< value_traits
, false> > local_iterator;
typedef detail::transform_iterator
< typename slist_impl::iterator
, downcast_node_to_value_t
< value_traits
, true> > const_local_iterator;
public:
//! <b>Requires</b>: buckets must not be being used by any other resource.
//!
//! <b>Effects</b>: Constructs an empty unordered_set, storing a reference
//! to the bucket array and copies of the key_hasher and equal_func functors.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If value_traits::node_traits::node
//! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
//! or the copy constructor or invocation of hash_func or equal_func throws.
//!
//! <b>Notes</b>: buckets array must be disposed only after
//! *this is disposed.
explicit hashtable_impl ( const bucket_traits &b_traits
, const hasher & hash_func = hasher()
, const key_equal &equal_func = key_equal()
, const value_traits &v_traits = value_traits())
: data_type(b_traits, hash_func, equal_func, v_traits)
{
this->data_type::internal.priv_initialize_buckets_and_cache();
this->priv_size_traits().set_size(size_type(0));
size_type bucket_sz = this->priv_bucket_count();
BOOST_INTRUSIVE_INVARIANT_ASSERT(bucket_sz != 0);
//Check power of two bucket array if the option is activated
BOOST_INTRUSIVE_INVARIANT_ASSERT
(!power_2_buckets || (0 == (bucket_sz & (bucket_sz-1))));
this->priv_split_traits().set_size(bucket_sz>>1);
}
//! <b>Effects</b>: to-do
//!
hashtable_impl(BOOST_RV_REF(hashtable_impl) x)
: data_type( ::boost::move(x.priv_bucket_traits())
, ::boost::move(x.priv_hasher())
, ::boost::move(x.priv_equal())
, ::boost::move(x.priv_value_traits())
)
{
this->priv_swap_cache(x);
x.priv_initialize_cache();
if(constant_time_size){
this->priv_size_traits().set_size(size_type(0));
this->priv_size_traits().set_size(x.priv_size_traits().get_size());
x.priv_size_traits().set_size(size_type(0));
}
if(incremental){
this->priv_split_traits().set_size(x.priv_split_traits().get_size());
x.priv_split_traits().set_size(size_type(0));
}
}
//! <b>Effects</b>: to-do
//!
hashtable_impl& operator=(BOOST_RV_REF(hashtable_impl) x)
{ this->swap(x); return *this; }
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
//! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_set
//! are not deleted (i.e. no destructors are called).
//!
//! <b>Complexity</b>: Linear to the number of elements in the unordered_set, if
//! it's a safe-mode or auto-unlink value. Otherwise constant.
//!
//! <b>Throws</b>: Nothing.
~hashtable_impl();
#endif
//! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_set.
//!
//! <b>Complexity</b>: Amortized constant time.
//! Worst case (empty unordered_set): O(this->bucket_count())
//!
//! <b>Throws</b>: Nothing.
iterator begin()
{ return iterator(this->priv_begin(), &this->get_bucket_value_traits()); }
//! <b>Effects</b>: Returns a const_iterator pointing to the beginning
//! of the unordered_set.
//!
//! <b>Complexity</b>: Amortized constant time.
//! Worst case (empty unordered_set): O(this->bucket_count())
//!
//! <b>Throws</b>: Nothing.
const_iterator begin() const
{ return this->cbegin(); }
//! <b>Effects</b>: Returns a const_iterator pointing to the beginning
//! of the unordered_set.
//!
//! <b>Complexity</b>: Amortized constant time.
//! Worst case (empty unordered_set): O(this->bucket_count())
//!
//! <b>Throws</b>: Nothing.
const_iterator cbegin() const
{ return const_iterator(this->priv_begin(), &this->get_bucket_value_traits()); }
//! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_set.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
iterator end()
{ return iterator(this->priv_invalid_local_it(), 0); }
//! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
const_iterator end() const
{ return this->cend(); }
//! <b>Effects</b>: Returns a const_iterator pointing to the end of the unordered_set.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
const_iterator cend() const
{ return const_iterator(this->priv_invalid_local_it(), 0); }
//! <b>Effects</b>: Returns the hasher object used by the unordered_set.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If hasher copy-constructor throws.
hasher hash_function() const
{ return this->priv_hasher(); }
//! <b>Effects</b>: Returns the key_equal object used by the unordered_set.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If key_equal copy-constructor throws.
key_equal key_eq() const
{ return this->priv_equal(); }
//! <b>Effects</b>: Returns true if the container is empty.
//!
//! <b>Complexity</b>: if constant-time size and cache_begin options are disabled,
//! average constant time (worst case, with empty() == true: O(this->bucket_count()).
//! Otherwise constant.
//!
//! <b>Throws</b>: Nothing.
bool empty() const
{
if(constant_time_size){
return !this->size();
}
else if(cache_begin){
return this->begin() == this->end();
}
else{
size_type bucket_cnt = this->priv_bucket_count();
const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
for (size_type n = 0; n < bucket_cnt; ++n, ++b){
if(!b->empty()){
return false;
}
}
return true;
}
}
//! <b>Effects</b>: Returns the number of elements stored in the unordered_set.
//!
//! <b>Complexity</b>: Linear to elements contained in *this if
//! constant_time_size is false. Constant-time otherwise.
//!
//! <b>Throws</b>: Nothing.
size_type size() const
{
if(constant_time_size)
return this->priv_size_traits().get_size();
else{
size_type len = 0;
size_type bucket_cnt = this->priv_bucket_count();
const bucket_type *b = boost::intrusive::detail::to_raw_pointer(this->priv_bucket_pointer());
for (size_type n = 0; n < bucket_cnt; ++n, ++b){
len += b->size();
}
return len;
}
}
//! <b>Requires</b>: the hasher and the equality function unqualified swap
//! call should not throw.
//!
//! <b>Effects</b>: Swaps the contents of two unordered_sets.
//! Swaps also the contained bucket array and equality and hasher functors.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If the swap() call for the comparison or hash functors
//! found using ADL throw. Basic guarantee.
void swap(hashtable_impl& other)
{
using std::swap;
//These can throw
swap(this->priv_equal(), other.priv_equal());
swap(this->priv_hasher(), other.priv_hasher());
//These can't throw
swap(this->priv_bucket_traits(), other.priv_bucket_traits());
swap(this->priv_value_traits(), other.priv_value_traits());
this->priv_swap_cache(other);
if(constant_time_size){
size_type backup = this->priv_size_traits().get_size();
this->priv_size_traits().set_size(other.priv_size_traits().get_size());
other.priv_size_traits().set_size(backup);
}
if(incremental){
size_type backup = this->priv_split_traits().get_size();
this->priv_split_traits().set_size(other.priv_split_traits().get_size());
other.priv_split_traits().set_size(backup);
}
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw
//! Cloner should yield to nodes that compare equal and produce the same
//! hash than the original node.
//!
//! <b>Effects</b>: Erases all the elements from *this
//! calling Disposer::operator()(pointer), clones all the
//! elements from src calling Cloner::operator()(const_reference )
//! and inserts them on *this. The hash function and the equality
//! predicate are copied from the source.
//!
//! If store_hash option is true, this method does not use the hash function.
//!
//! If any operation throws, all cloned elements are unlinked and disposed
//! calling Disposer::operator()(pointer).
//!
//! <b>Complexity</b>: Linear to erased plus inserted elements.
//!
//! <b>Throws</b>: If cloner or hasher throw or hash or equality predicate copying
//! throws. Basic guarantee.
template <class Cloner, class Disposer>
void clone_from(const hashtable_impl &src, Cloner cloner, Disposer disposer)
{
this->clear_and_dispose(disposer);
if(!constant_time_size || !src.empty()){
const size_type src_bucket_count = src.bucket_count();
const size_type dst_bucket_count = this->bucket_count();
//Check power of two bucket array if the option is activated
BOOST_INTRUSIVE_INVARIANT_ASSERT
(!power_2_buckets || (0 == (src_bucket_count & (src_bucket_count-1))));
BOOST_INTRUSIVE_INVARIANT_ASSERT
(!power_2_buckets || (0 == (dst_bucket_count & (dst_bucket_count-1))));
//If src bucket count is bigger or equal, structural copy is possible
if(!incremental && (src_bucket_count >= dst_bucket_count)){
//First clone the first ones
const bucket_ptr src_buckets = src.priv_bucket_pointer();
const bucket_ptr dst_buckets = this->priv_bucket_pointer();
size_type constructed;
typedef node_cast_adaptor< detail::node_disposer<Disposer, value_traits, CircularSListAlgorithms>
, slist_node_ptr, node_ptr > NodeDisposer;
typedef node_cast_adaptor< detail::node_cloner <Cloner, value_traits, CircularSListAlgorithms>
, slist_node_ptr, node_ptr > NodeCloner;
NodeDisposer node_disp(disposer, &this->priv_value_traits());
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback(dst_buckets[0], node_disp, constructed);
for( constructed = 0
; constructed < dst_bucket_count
; ++constructed){
dst_buckets[constructed].clone_from
( src_buckets[constructed]
, NodeCloner(cloner, &this->priv_value_traits()), node_disp);
}
if(src_bucket_count != dst_bucket_count){
//Now insert the remaining ones using the modulo trick
for(//"constructed" comes from the previous loop
; constructed < src_bucket_count
; ++constructed){
bucket_type &dst_b =
dst_buckets[detail::hash_to_bucket_split<power_2_buckets, incremental>(constructed, dst_bucket_count, dst_bucket_count)];
bucket_type &src_b = src_buckets[constructed];
for( siterator b(src_b.begin()), e(src_b.end())
; b != e
; ++b){
dst_b.push_front(*(NodeCloner(cloner, &this->priv_value_traits())(*b.pointed_node())));
}
}
}
this->priv_hasher() = src.priv_hasher();
this->priv_equal() = src.priv_equal();
rollback.release();
this->priv_size_traits().set_size(src.priv_size_traits().get_size());
this->priv_split_traits().set_size(dst_bucket_count);
this->priv_insertion_update_cache(0u);
this->priv_erasure_update_cache();
}
else if(store_hash){
//Unlike previous cloning algorithm, this can throw
//if cloner, hasher or comparison functor throw
const_iterator b(src.cbegin()), e(src.cend());
detail::exception_disposer<hashtable_impl, Disposer>
rollback(*this, disposer);
for(; b != e; ++b){
std::size_t hash_value = this->priv_stored_or_compute_hash(*b, store_hash_t());;
this->priv_insert_equal_with_hash(*cloner(*b), hash_value);
}
rollback.release();
}
else{
//Unlike previous cloning algorithm, this can throw
//if cloner, hasher or comparison functor throw
const_iterator b(src.cbegin()), e(src.cend());
detail::exception_disposer<hashtable_impl, Disposer>
rollback(*this, disposer);
for(; b != e; ++b){
this->insert_equal(*cloner(*b));
}
rollback.release();
}
}
}
//! <b>Requires</b>: value must be an lvalue
//!
//! <b>Effects</b>: Inserts the value into the unordered_set.
//!
//! <b>Returns</b>: An iterator to the inserted value.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
//! No copy-constructors are called.
iterator insert_equal(reference value)
{
size_type bucket_num;
std::size_t hash_value;
siterator prev;
siterator it = this->priv_find
(value, this->priv_hasher(), this->priv_equal(), bucket_num, hash_value, prev);
return this->priv_insert_equal_find(value, bucket_num, hash_value, it);
}
//! <b>Requires</b>: Dereferencing iterator must yield an lvalue
//! of type value_type.
//!
//! <b>Effects</b>: Equivalent to this->insert_equal(t) for each element in [b, e).
//!
//! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e).
//! Worst case O(N*this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
//! No copy-constructors are called.
template<class Iterator>
void insert_equal(Iterator b, Iterator e)
{
for (; b != e; ++b)
this->insert_equal(*b);
}
//! <b>Requires</b>: value must be an lvalue
//!
//! <b>Effects</b>: Tries to inserts value into the unordered_set.
//!
//! <b>Returns</b>: If the value
//! is not already present inserts it and returns a pair containing the
//! iterator to the new value and true. If there is an equivalent value
//! returns a pair containing an iterator to the already present value
//! and false.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws. Strong guarantee.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
//! No copy-constructors are called.
std::pair<iterator, bool> insert_unique(reference value)
{
insert_commit_data commit_data;
std::pair<iterator, bool> ret = this->insert_unique_check
(value, this->priv_hasher(), this->priv_equal(), commit_data);
if(!ret.second)
return ret;
return std::pair<iterator, bool>
(this->insert_unique_commit(value, commit_data), true);
}
//! <b>Requires</b>: Dereferencing iterator must yield an lvalue
//! of type value_type.
//!
//! <b>Effects</b>: Equivalent to this->insert_unique(t) for each element in [b, e).
//!
//! <b>Complexity</b>: Average case O(N), where N is std::distance(b, e).
//! Worst case O(N*this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws. Basic guarantee.
//!
//! <b>Note</b>: Does not affect the validity of iterators and references.
//! No copy-constructors are called.
template<class Iterator>
void insert_unique(Iterator b, Iterator e)
{
for (; b != e; ++b)
this->insert_unique(*b);
}
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Checks if a value can be inserted in the unordered_set, using
//! a user provided key instead of the value itself.
//!
//! <b>Returns</b>: If there is an equivalent value
//! returns a pair containing an iterator to the already present value
//! and false. If the value can be inserted returns true in the returned
//! pair boolean and fills "commit_data" that is meant to be used with
//! the "insert_commit" function.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal_func throw. Strong guarantee.
//!
//! <b>Notes</b>: This function is used to improve performance when constructing
//! a value_type is expensive: if there is an equivalent value
//! the constructed object must be discarded. Many times, the part of the
//! node that is used to impose the hash or the equality is much cheaper to
//! construct than the value_type and this function offers the possibility to
//! use that the part to check if the insertion will be successful.
//!
//! If the check is successful, the user can construct the value_type and use
//! "insert_commit" to insert the object in constant-time.
//!
//! "commit_data" remains valid for a subsequent "insert_commit" only if no more
//! objects are inserted or erased from the unordered_set.
//!
//! After a successful rehashing insert_commit_data remains valid.
template<class KeyType, class KeyHasher, class KeyValueEqual>
std::pair<iterator, bool> insert_unique_check
( const KeyType &key
, KeyHasher hash_func
, KeyValueEqual equal_func
, insert_commit_data &commit_data)
{
size_type bucket_num;
siterator prev;
siterator prev_pos =
this->priv_find(key, hash_func, equal_func, bucket_num, commit_data.hash, prev);
bool success = prev_pos == this->priv_invalid_local_it();
if(success){
prev_pos = prev;
}
return std::pair<iterator, bool>(iterator(prev_pos, &this->get_bucket_value_traits()),success);
}
//! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
//! must have been obtained from a previous call to "insert_check".
//! No objects should have been inserted or erased from the unordered_set between
//! the "insert_check" that filled "commit_data" and the call to "insert_commit".
//!
//! <b>Effects</b>: Inserts the value in the unordered_set using the information obtained
//! from the "commit_data" that a previous "insert_check" filled.
//!
//! <b>Returns</b>: An iterator to the newly inserted object.
//!
//! <b>Complexity</b>: Constant time.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Notes</b>: This function has only sense if a "insert_check" has been
//! previously executed to fill "commit_data". No value should be inserted or
//! erased between the "insert_check" and "insert_commit" calls.
//!
//! After a successful rehashing insert_commit_data remains valid.
iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
{
size_type bucket_num = this->priv_hash_to_bucket(commit_data.hash);
bucket_type &b = this->priv_bucket_pointer()[bucket_num];
this->priv_size_traits().increment();
node_ptr n = pointer_traits<node_ptr>::pointer_to(this->priv_value_to_node(value));
node_functions_t::store_hash(n, commit_data.hash, store_hash_t());
if(safemode_or_autounlink)
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
this->priv_insertion_update_cache(bucket_num);
group_functions_t::insert_in_group(node_ptr(), n, optimize_multikey_t());
return iterator(b.insert_after(b.before_begin(), *n), &this->get_bucket_value_traits());
}
//! <b>Effects</b>: Erases the element pointed to by i.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased element. No destructors are called.
void erase(const_iterator i)
{ this->erase_and_dispose(i, detail::null_disposer()); }
//! <b>Effects</b>: Erases the range pointed to by b end e.
//!
//! <b>Complexity</b>: Average case O(std::distance(b, e)),
//! worst case O(this->size()).
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
void erase(const_iterator b, const_iterator e)
{ this->erase_and_dispose(b, e, detail::null_disposer()); }
//! <b>Effects</b>: Erases all the elements with the given value.
//!
//! <b>Returns</b>: The number of erased elements.
//!
//! <b>Complexity</b>: Average case O(this->count(value)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
//! Basic guarantee.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
size_type erase(const_reference value)
{ return this->erase(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Erases all the elements that have the same hash and
//! compare equal with the given key.
//!
//! <b>Returns</b>: The number of erased elements.
//!
//! <b>Complexity</b>: Average case O(this->count(value)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
template<class KeyType, class KeyHasher, class KeyValueEqual>
size_type erase(const KeyType& key, KeyHasher hash_func, KeyValueEqual equal_func)
{ return this->erase_and_dispose(key, hash_func, equal_func, detail::null_disposer()); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
//! <b>Effects</b>: Erases the element pointed to by i.
//! Disposer::operator()(pointer) is called for the removed element.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
void erase_and_dispose(const_iterator i, Disposer disposer
/// @cond
, typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
/// @endcond
)
{
this->priv_erase(i, disposer, optimize_multikey_t());
this->priv_size_traits().decrement();
this->priv_erasure_update_cache();
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
//! <b>Effects</b>: Erases the range pointed to by b end e.
//! Disposer::operator()(pointer) is called for the removed elements.
//!
//! <b>Complexity</b>: Average case O(std::distance(b, e)),
//! worst case O(this->size()).
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
{
if(b != e){
//Get the bucket number and local iterator for both iterators
siterator first_local_it(b.slist_it());
size_type first_bucket_num = this->priv_get_bucket_num(first_local_it);
const bucket_ptr buck_ptr = this->priv_bucket_pointer();
siterator before_first_local_it
= this->priv_get_previous(buck_ptr[first_bucket_num], first_local_it);
size_type last_bucket_num;
siterator last_local_it;
//For the end iterator, we will assign the end iterator
//of the last bucket
if(e == this->end()){
last_bucket_num = this->bucket_count() - 1;
last_local_it = buck_ptr[last_bucket_num].end();
}
else{
last_local_it = e.slist_it();
last_bucket_num = this->priv_get_bucket_num(last_local_it);
}
this->priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer);
this->priv_erasure_update_cache_range(first_bucket_num, last_bucket_num);
}
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
//! <b>Effects</b>: Erases all the elements with the given value.
//! Disposer::operator()(pointer) is called for the removed elements.
//!
//! <b>Returns</b>: The number of erased elements.
//!
//! <b>Complexity</b>: Average case O(this->count(value)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
//! Basic guarantee.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
template<class Disposer>
size_type erase_and_dispose(const_reference value, Disposer disposer)
{ return this->erase_and_dispose(value, this->priv_hasher(), this->priv_equal(), disposer); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
//! <b>Effects</b>: Erases all the elements with the given key.
//! according to the comparison functor "equal_func".
//! Disposer::operator()(pointer) is called for the removed elements.
//!
//! <b>Returns</b>: The number of erased elements.
//!
//! <b>Complexity</b>: Average case O(this->count(value)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal_func throw. Basic guarantee.
//!
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class KeyType, class KeyHasher, class KeyValueEqual, class Disposer>
size_type erase_and_dispose(const KeyType& key, KeyHasher hash_func
,KeyValueEqual equal_func, Disposer disposer)
{
size_type bucket_num;
std::size_t h;
siterator prev;
siterator it = this->priv_find(key, hash_func, equal_func, bucket_num, h, prev);
bool success = it != this->priv_invalid_local_it();
size_type cnt(0);
if(!success){
return 0;
}
else if(optimize_multikey){
siterator last = bucket_type::s_iterator_to
(*node_traits::get_next(group_functions_t::get_last_in_group
(detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t())));
this->priv_erase_range_impl(bucket_num, prev, last, disposer, cnt);
}
else{
//If found erase all equal values
bucket_type &b = this->priv_bucket_pointer()[bucket_num];
for(siterator end_sit = b.end(); it != end_sit; ++cnt, ++it){
slist_node_ptr n(it.pointed_node());
const value_type &v = this->priv_value_from_slist_node(n);
if(compare_hash){
std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t());
if(h != vh || !equal_func(key, v)){
break;
}
}
else if(!equal_func(key, v)){
break;
}
this->priv_size_traits().decrement();
}
b.erase_after_and_dispose(prev, it, make_node_disposer(disposer));
}
this->priv_erasure_update_cache();
return cnt;
}
//! <b>Effects</b>: Erases all of the elements.
//!
//! <b>Complexity</b>: Linear to the number of elements on the container.
//! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
void clear()
{
this->data_type::internal.priv_clear_buckets_and_cache();
this->priv_size_traits().set_size(size_type(0));
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
//! <b>Effects</b>: Erases all of the elements.
//!
//! <b>Complexity</b>: Linear to the number of elements on the container.
//! Disposer::operator()(pointer) is called for the removed elements.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
template<class Disposer>
void clear_and_dispose(Disposer disposer)
{
if(!constant_time_size || !this->empty()){
size_type num_buckets = this->bucket_count();
bucket_ptr b = this->priv_bucket_pointer();
for(; num_buckets--; ++b){
b->clear_and_dispose(make_node_disposer(disposer));
}
this->priv_size_traits().set_size(size_type(0));
}
this->priv_initialize_cache();
}
//! <b>Effects</b>: Returns the number of contained elements with the given value
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
size_type count(const_reference value) const
{ return this->count(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Returns the number of contained elements with the given key
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal throw.
template<class KeyType, class KeyHasher, class KeyValueEqual>
size_type count(const KeyType &key, const KeyHasher &hash_func, const KeyValueEqual &equal_func) const
{
size_type bucket_n1, bucket_n2, cnt;
this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return cnt;
}
//! <b>Effects</b>: Finds an iterator to the first element is equal to
//! "value" or end() if that element does not exist.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
iterator find(const_reference value)
{ return this->find(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Finds an iterator to the first element whose key is
//! "key" according to the given hash and equality functor or end() if
//! that element does not exist.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal_func throw.
//!
//! <b>Note</b>: This function is used when constructing a value_type
//! is expensive and the value_type can be compared with a cheaper
//! key type. Usually this key is part of the value_type.
template<class KeyType, class KeyHasher, class KeyValueEqual>
iterator find(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func)
{
size_type bucket_n;
std::size_t hash;
siterator prev;
siterator local_it = this->priv_find(key, hash_func, equal_func, bucket_n, hash, prev);
return iterator(local_it, &this->get_bucket_value_traits());
}
//! <b>Effects</b>: Finds a const_iterator to the first element whose key is
//! "key" or end() if that element does not exist.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
const_iterator find(const_reference value) const
{ return this->find(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Finds an iterator to the first element whose key is
//! "key" according to the given hasher and equality functor or end() if
//! that element does not exist.
//!
//! <b>Complexity</b>: Average case O(1), worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or equal_func throw.
//!
//! <b>Note</b>: This function is used when constructing a value_type
//! is expensive and the value_type can be compared with a cheaper
//! key type. Usually this key is part of the value_type.
template<class KeyType, class KeyHasher, class KeyValueEqual>
const_iterator find
(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const
{
size_type bucket_n;
std::size_t hash_value;
siterator prev;
siterator sit = this->priv_find(key, hash_func, equal_func, bucket_n, hash_value, prev);
return const_iterator(sit, &this->get_bucket_value_traits());
}
//! <b>Effects</b>: Returns a range containing all elements with values equivalent
//! to value. Returns std::make_pair(this->end(), this->end()) if no such
//! elements exist.
//!
//! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
std::pair<iterator,iterator> equal_range(const_reference value)
{ return this->equal_range(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Returns a range containing all elements with equivalent
//! keys. Returns std::make_pair(this->end(), this->end()) if no such
//! elements exist.
//!
//! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If hash_func or the equal_func throw.
//!
//! <b>Note</b>: This function is used when constructing a value_type
//! is expensive and the value_type can be compared with a cheaper
//! key type. Usually this key is part of the value_type.
template<class KeyType, class KeyHasher, class KeyValueEqual>
std::pair<iterator,iterator> equal_range
(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func)
{
size_type bucket_n1, bucket_n2, cnt;
std::pair<siterator, siterator> ret = this->priv_equal_range
(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return std::pair<iterator, iterator>
(iterator(ret.first, &this->get_bucket_value_traits()), iterator(ret.second, &this->get_bucket_value_traits()));
}
//! <b>Effects</b>: Returns a range containing all elements with values equivalent
//! to value. Returns std::make_pair(this->end(), this->end()) if no such
//! elements exist.
//!
//! <b>Complexity</b>: Average case O(this->count(value)). Worst case O(this->size()).
//!
//! <b>Throws</b>: If the internal hasher or the equality functor throws.
std::pair<const_iterator, const_iterator>
equal_range(const_reference value) const
{ return this->equal_range(value, this->priv_hasher(), this->priv_equal()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! "equal_func" must be a equality function that induces
//! the same equality as key_equal. The difference is that
//! "equal_func" compares an arbitrary key with the contained values.
//!
//! <b>Effects</b>: Returns a range containing all elements with equivalent
//! keys. Returns std::make_pair(this->end(), this->end()) if no such
//! elements exist.
//!
//! <b>Complexity</b>: Average case O(this->count(key, hash_func, equal_func)).
//! Worst case O(this->size()).
//!
//! <b>Throws</b>: If the hasher or equal_func throw.
//!
//! <b>Note</b>: This function is used when constructing a value_type
//! is expensive and the value_type can be compared with a cheaper
//! key type. Usually this key is part of the value_type.
template<class KeyType, class KeyHasher, class KeyValueEqual>
std::pair<const_iterator,const_iterator> equal_range
(const KeyType &key, KeyHasher hash_func, KeyValueEqual equal_func) const
{
size_type bucket_n1, bucket_n2, cnt;
std::pair<siterator, siterator> ret =
this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
return std::pair<const_iterator, const_iterator>
( const_iterator(ret.first, &this->get_bucket_value_traits())
, const_iterator(ret.second, &this->get_bucket_value_traits()));
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid iterator belonging to the unordered_set
//! that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If the internal hash function throws.
iterator iterator_to(reference value)
{
return iterator(bucket_type::s_iterator_to
(this->priv_value_to_node(value)), &this->get_bucket_value_traits());
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid const_iterator belonging to the
//! unordered_set that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If the internal hash function throws.
const_iterator iterator_to(const_reference value) const
{
node_reference r = *pointer_traits<node_ptr>::const_cast_from
(pointer_traits<const_node_ptr>::pointer_to(this->priv_value_to_node(value)));
siterator sit = bucket_type::s_iterator_to(r);
return const_iterator(sit, &this->get_bucket_value_traits());
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
//! that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: This static function is available only if the <i>value traits</i>
//! is stateless.
static local_iterator s_local_iterator_to(reference value)
{
BOOST_STATIC_ASSERT((!stateful_value_traits));
siterator sit = bucket_type::s_iterator_to(*value_traits::to_node_ptr(value));
return local_iterator(sit, const_value_traits_ptr());
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
//! the unordered_set that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: This static function is available only if the <i>value traits</i>
//! is stateless.
static const_local_iterator s_local_iterator_to(const_reference value)
{
BOOST_STATIC_ASSERT((!stateful_value_traits));
node_reference r = *pointer_traits<node_ptr>::const_cast_from
(value_traits::to_node_ptr(value));
siterator sit = bucket_type::s_iterator_to(r);
return const_local_iterator(sit, const_value_traits_ptr());
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid local_iterator belonging to the unordered_set
//! that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
local_iterator local_iterator_to(reference value)
{
siterator sit = bucket_type::s_iterator_to(this->priv_value_to_node(value));
return local_iterator(sit, this->priv_value_traits_ptr());
}
//! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
//! appropriate type. Otherwise the behavior is undefined.
//!
//! <b>Effects</b>: Returns: a valid const_local_iterator belonging to
//! the unordered_set that points to the value
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
const_local_iterator local_iterator_to(const_reference value) const
{
node_reference r = *pointer_traits<node_ptr>::const_cast_from
(pointer_traits<const_node_ptr>::pointer_to(this->priv_value_to_node(value)));
siterator sit = bucket_type::s_iterator_to(r);
return const_local_iterator(sit, this->priv_value_traits_ptr());
}
//! <b>Effects</b>: Returns the number of buckets passed in the constructor
//! or the last rehash function.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
size_type bucket_count() const
{ return this->priv_bucket_count(); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns the number of elements in the nth bucket.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
size_type bucket_size(size_type n) const
{ return this->priv_bucket_pointer()[n].size(); }
//! <b>Effects</b>: Returns the index of the bucket in which elements
//! with keys equivalent to k would be found, if any such element existed.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If the hash functor throws.
//!
//! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
size_type bucket(const key_type& k) const
{ return this->bucket(k, this->priv_hasher()); }
//! <b>Requires</b>: "hash_func" must be a hash function that induces
//! the same hash values as the stored hasher. The difference is that
//! "hash_func" hashes the given key instead of the value_type.
//!
//! <b>Effects</b>: Returns the index of the bucket in which elements
//! with keys equivalent to k would be found, if any such element existed.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: If hash_func throws.
//!
//! <b>Note</b>: the return value is in the range [0, this->bucket_count()).
template<class KeyType, class KeyHasher>
size_type bucket(const KeyType& k, const KeyHasher &hash_func) const
{ return this->priv_hash_to_bucket(hash_func(k)); }
//! <b>Effects</b>: Returns the bucket array pointer passed in the constructor
//! or the last rehash function.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
bucket_ptr bucket_pointer() const
{ return this->priv_bucket_pointer(); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a local_iterator pointing to the beginning
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
local_iterator begin(size_type n)
{ return local_iterator(this->priv_bucket_pointer()[n].begin(), this->priv_value_traits_ptr()); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
const_local_iterator begin(size_type n) const
{ return this->cbegin(n); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a const_local_iterator pointing to the beginning
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
const_local_iterator cbegin(size_type n) const
{
bucket_reference br = pointer_traits<bucket_ptr>::const_cast_from(this->priv_bucket_pointer())[n];
return const_local_iterator(br.begin(), this->priv_value_traits_ptr());
}
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a local_iterator pointing to the end
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
local_iterator end(size_type n)
{ return local_iterator(this->priv_bucket_pointer()[n].end(), this->priv_value_traits_ptr()); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a const_local_iterator pointing to the end
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
const_local_iterator end(size_type n) const
{ return this->cend(n); }
//! <b>Requires</b>: n is in the range [0, this->bucket_count()).
//!
//! <b>Effects</b>: Returns a const_local_iterator pointing to the end
//! of the sequence stored in the bucket n.
//!
//! <b>Complexity</b>: Constant.
//!
//! <b>Throws</b>: Nothing.
//!
//! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
//! containing all of the elements in the nth bucket.
const_local_iterator cend(size_type n) const
{
bucket_reference br = pointer_traits<bucket_ptr>::const_cast_from(this->priv_bucket_pointer())[n];
return const_local_iterator ( br.end(), this->priv_value_traits_ptr());
}
//! <b>Requires</b>: new_bucket_traits can hold a pointer to a new bucket array
//! or the same as the old bucket array with a different length. new_size is the length of the
//! the array pointed by new_buckets. If new_bucket_traits.bucket_begin() == this->bucket_pointer()
//! new_bucket_traits.bucket_count() can be bigger or smaller than this->bucket_count().
//! 'new_bucket_traits' copy constructor should not throw.
//!
//! <b>Effects</b>: Updates the internal reference with the new bucket, erases
//! the values from the old bucket and inserts then in the new one.
//! Bucket traits hold by *this is assigned from new_bucket_traits.
//! If the container is configured as incremental<>, the split bucket is set
//! to the new bucket_count().
//!
//! If store_hash option is true, this method does not use the hash function.
//!
//! <b>Complexity</b>: Average case linear in this->size(), worst case quadratic.
//!
//! <b>Throws</b>: If the hasher functor throws. Basic guarantee.
void rehash(const bucket_traits &new_bucket_traits)
{
const bucket_ptr new_buckets = new_bucket_traits.bucket_begin();
size_type new_bucket_count = new_bucket_traits.bucket_count();
const bucket_ptr old_buckets = this->priv_bucket_pointer();
size_type old_bucket_count = this->priv_bucket_count();
//Check power of two bucket array if the option is activated
BOOST_INTRUSIVE_INVARIANT_ASSERT
(!power_2_buckets || (0 == (new_bucket_count & (new_bucket_count-1u))));
size_type n = this->priv_get_cache_bucket_num();
const bool same_buffer = old_buckets == new_buckets;
//If the new bucket length is a common factor
//of the old one we can avoid hash calculations.
const bool fast_shrink = (!incremental) && (old_bucket_count > new_bucket_count) &&
(power_2_buckets ||(old_bucket_count % new_bucket_count) == 0);
//If we are shrinking the same bucket array and it's
//is a fast shrink, just rehash the last nodes
size_type new_first_bucket_num = new_bucket_count;
if(same_buffer && fast_shrink && (n < new_bucket_count)){
n = new_bucket_count;
new_first_bucket_num = this->priv_get_cache_bucket_num();
}
//Anti-exception stuff: they destroy the elements if something goes wrong.
//If the source and destination buckets are the same, the second rollback function
//is harmless, because all elements have been already unlinked and destroyed
typedef detail::init_disposer<node_algorithms> NodeDisposer;
NodeDisposer node_disp;
bucket_type & newbuck = new_buckets[0];
bucket_type & oldbuck = old_buckets[0];
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback1(newbuck, node_disp, new_bucket_count);
detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
rollback2(oldbuck, node_disp, old_bucket_count);
//Put size in a safe value for rollback exception
size_type size_backup = this->priv_size_traits().get_size();
this->priv_size_traits().set_size(0);
//Put cache to safe position
this->priv_initialize_cache();
this->priv_insertion_update_cache(size_type(0u));
//Iterate through nodes
for(; n < old_bucket_count; ++n){
bucket_type &old_bucket = old_buckets[n];
if(!fast_shrink){
siterator before_i(old_bucket.before_begin());
siterator end_sit(old_bucket.end());
siterator i(old_bucket.begin());
for(;i != end_sit; ++i){
const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
const size_type new_n = detail::hash_to_bucket_split<power_2_buckets, incremental>(hash_value, new_bucket_count, new_bucket_count);
if(cache_begin && new_n < new_first_bucket_num)
new_first_bucket_num = new_n;
siterator last = bucket_type::s_iterator_to
(*group_functions_t::get_last_in_group
(detail::dcast_bucket_ptr<node>(i.pointed_node()), optimize_multikey_t()));
if(same_buffer && new_n == n){
before_i = last;
}
else{
bucket_type &new_b = new_buckets[new_n];
new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last);
}
i = before_i;
}
}
else{
const size_type new_n = detail::hash_to_bucket_split<power_2_buckets, incremental>(n, new_bucket_count, new_bucket_count);
if(cache_begin && new_n < new_first_bucket_num)
new_first_bucket_num = new_n;
bucket_type &new_b = new_buckets[new_n];
if(!old_bucket.empty()){
new_b.splice_after( new_b.before_begin()
, old_bucket
, old_bucket.before_begin()
, hashtable_impl::priv_get_last(old_bucket));
}
}
}
this->priv_size_traits().set_size(size_backup);
this->priv_split_traits().set_size(new_bucket_count);
this->priv_bucket_traits() = new_bucket_traits;
this->priv_initialize_cache();
this->priv_insertion_update_cache(new_first_bucket_num);
rollback1.release();
rollback2.release();
}
//! <b>Requires</b>:
//!
//! <b>Effects</b>:
//!
//! <b>Complexity</b>:
//!
//! <b>Throws</b>:
//!
//! <b>Note</b>: this method is only available if incremental<true> option is activated.
bool incremental_rehash(bool grow = true)
{
//This function is only available for containers with incremental hashing
BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
const size_type split_idx = this->priv_split_traits().get_size();
const size_type bucket_cnt = this->priv_bucket_count();
const bucket_ptr buck_ptr = this->priv_bucket_pointer();
if(grow){
//Test if the split variable can be changed
if(split_idx >= bucket_cnt)
return false;
const size_type bucket_to_rehash = split_idx - bucket_cnt/2;
bucket_type &old_bucket = buck_ptr[bucket_to_rehash];
siterator before_i(old_bucket.before_begin());
const siterator end_sit(old_bucket.end());
siterator i(old_bucket.begin());
this->priv_split_traits().increment();
//Anti-exception stuff: if an exception is thrown while
//moving elements from old_bucket to the target bucket, all moved
//elements are moved back to the original one.
detail::incremental_rehash_rollback<bucket_type, split_traits> rollback
( buck_ptr[split_idx], old_bucket, this->priv_split_traits());
for(;i != end_sit; ++i){
const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
const size_type new_n = this->priv_hash_to_bucket(hash_value);
siterator last = bucket_type::s_iterator_to
(*group_functions_t::get_last_in_group
(detail::dcast_bucket_ptr<node>(i.pointed_node()), optimize_multikey_t()));
if(new_n == bucket_to_rehash){
before_i = last;
}
else{
bucket_type &new_b = buck_ptr[new_n];
new_b.splice_after(new_b.before_begin(), old_bucket, before_i, last);
}
i = before_i;
}
rollback.release();
this->priv_erasure_update_cache();
return true;
}
else{
//Test if the split variable can be changed
if(split_idx <= bucket_cnt/2)
return false;
const size_type target_bucket_num = split_idx - 1 - bucket_cnt/2;
bucket_type &target_bucket = buck_ptr[target_bucket_num];
bucket_type &source_bucket = buck_ptr[split_idx-1];
target_bucket.splice_after(target_bucket.cbefore_begin(), source_bucket);
this->priv_split_traits().decrement();
this->priv_insertion_update_cache(target_bucket_num);
return true;
}
}
//! <b>Effects</b>: If new_bucket_traits.bucket_count() is not
//! this->bucket_count()/2 or this->bucket_count()*2, or
//! this->split_bucket() != new_bucket_traits.bucket_count() returns false
//! and does nothing.
//!
//! Otherwise, copy assigns new_bucket_traits to the internal bucket_traits
//! and transfers all the objects from old buckets to the new ones.
//!
//! <b>Complexity</b>: Linear to size().
//!
//! <b>Throws</b>: Nothing
//!
//! <b>Note</b>: this method is only available if incremental<true> option is activated.
bool incremental_rehash(const bucket_traits &new_bucket_traits)
{
//This function is only available for containers with incremental hashing
BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
size_type new_bucket_traits_size = new_bucket_traits.bucket_count();
size_type cur_bucket_traits = this->priv_bucket_count();
if(new_bucket_traits_size/2 != cur_bucket_traits && new_bucket_traits_size != cur_bucket_traits/2){
return false;
}
const size_type split_idx = this->split_count();
if(new_bucket_traits_size/2 == cur_bucket_traits){
//Test if the split variable can be changed
if(!(split_idx >= cur_bucket_traits))
return false;
}
else{
//Test if the split variable can be changed
if(!(split_idx <= cur_bucket_traits/2))
return false;
}
const size_type ini_n = this->priv_get_cache_bucket_num();
const bucket_ptr old_buckets = this->priv_bucket_pointer();
this->priv_bucket_traits() = new_bucket_traits;
if(new_bucket_traits.bucket_begin() != old_buckets){
for(size_type n = ini_n; n < split_idx; ++n){
bucket_type &new_bucket = new_bucket_traits.bucket_begin()[n];
bucket_type &old_bucket = old_buckets[n];
new_bucket.splice_after(new_bucket.cbefore_begin(), old_bucket);
}
//Put cache to safe position
this->priv_initialize_cache();
this->priv_insertion_update_cache(ini_n);
}
return true;
}
//! <b>Requires</b>:
//!
//! <b>Effects</b>:
//!
//! <b>Complexity</b>:
//!
//! <b>Throws</b>:
size_type split_count() const
{
//This function is only available if incremental hashing is activated
BOOST_STATIC_ASSERT(( incremental && power_2_buckets ));
return this->priv_split_traits().get_size();
}
//! <b>Effects</b>: Returns the nearest new bucket count optimized for
//! the container that is bigger or equal than n. This suggestion can be
//! used to create bucket arrays with a size that will usually improve
//! container's performance. If such value does not exist, the
//! higher possible value is returned.
//!
//! <b>Complexity</b>: Amortized constant time.
//!
//! <b>Throws</b>: Nothing.
static size_type suggested_upper_bucket_count(size_type n)
{
const std::size_t *primes = &prime_list_holder<0>::prime_list[0];
const std::size_t *primes_end = primes + prime_list_holder<0>::prime_list_size;
std::size_t const* bound = std::lower_bound(primes, primes_end, n);
bound -= (bound == primes_end);
return size_type(*bound);
}
//! <b>Effects</b>: Returns the nearest new bucket count optimized for
//! the container that is smaller or equal than n. This suggestion can be
//! used to create bucket arrays with a size that will usually improve
//! container's performance. If such value does not exist, the
//! lowest possible value is returned.
//!
//! <b>Complexity</b>: Amortized constant time.
//!
//! <b>Throws</b>: Nothing.
static size_type suggested_lower_bucket_count(size_type n)
{
const std::size_t *primes = &prime_list_holder<0>::prime_list[0];
const std::size_t *primes_end = primes + prime_list_holder<0>::prime_list_size;
size_type const* bound = std::upper_bound(primes, primes_end, n);
bound -= (bound != primes);
return size_type(*bound);
}
/// @cond
void check() const {}
private:
size_traits &priv_size_traits()
{ return static_cast<size_traits&>(static_cast<data_type&>(*this)); }
const size_traits &priv_size_traits() const
{ return static_cast<const size_traits&>(static_cast<const data_type&>(*this)); }
bucket_ptr priv_bucket_pointer() const
{ return this->data_type::internal.internal.internal.internal.priv_bucket_pointer(); }
SizeType priv_bucket_count() const
{ return this->data_type::internal.internal.internal.internal.priv_bucket_count(); }
const bucket_plus_vtraits<ValueTraits, BucketTraits> &get_bucket_value_traits() const
{ return this->data_type::internal.internal.internal.internal.get_bucket_value_traits(); }
bucket_plus_vtraits<ValueTraits, BucketTraits> &get_bucket_value_traits()
{ return this->data_type::internal.internal.internal.internal.get_bucket_value_traits(); }
bucket_traits &priv_bucket_traits()
{ return this->data_type::internal.internal.internal.internal.priv_bucket_traits(); }
const bucket_traits &priv_bucket_traits() const
{ return this->data_type::internal.internal.internal.internal.priv_bucket_traits(); }
value_traits &priv_value_traits()
{ return this->data_type::internal.internal.internal.internal.priv_value_traits(); }
const value_traits &priv_value_traits() const
{ return this->data_type::internal.internal.internal.internal.priv_value_traits(); }
const_value_traits_ptr priv_value_traits_ptr() const
{ return this->data_type::internal.internal.internal.internal.priv_value_traits_ptr(); }
siterator priv_invalid_local_it() const
{ return this->data_type::internal.internal.internal.internal.priv_invalid_local_it(); }
split_traits &priv_split_traits()
{ return this->data_type::internal.priv_split_traits(); }
const split_traits &priv_split_traits() const
{ return this->data_type::internal.priv_split_traits(); }
bucket_ptr priv_get_cache()
{ return this->data_type::internal.internal.priv_get_cache(); }
void priv_initialize_cache()
{ return this->data_type::internal.internal.priv_initialize_cache(); }
siterator priv_begin() const
{ return this->data_type::internal.internal.priv_begin(); }
const value_equal &priv_equal() const
{ return this->data_type::internal.internal.priv_equal(); }
value_equal &priv_equal()
{ return this->data_type::internal.internal.priv_equal(); }
const hasher &priv_hasher() const
{ return this->data_type::internal.internal.internal.priv_hasher(); }
hasher &priv_hasher()
{ return this->data_type::internal.internal.internal.priv_hasher(); }
void priv_swap_cache(hashtable_impl &h)
{ this->data_type::internal.internal.priv_swap_cache(h.data_type::internal.internal); }
node &priv_value_to_node(value_type &v)
{ return this->data_type::internal.internal.internal.internal.priv_value_to_node(v); }
const node &priv_value_to_node(const value_type &v) const
{ return this->data_type::internal.internal.internal.internal.priv_value_to_node(v); }
SizeType priv_get_cache_bucket_num()
{ return this->data_type::internal.internal.priv_get_cache_bucket_num(); }
void priv_insertion_update_cache(SizeType n)
{ return this->data_type::internal.internal.priv_insertion_update_cache(n); }
template<bool Boolean>
std::size_t priv_stored_or_compute_hash(const value_type &v, detail::bool_<Boolean> b) const
{ return this->data_type::internal.internal.internal.priv_stored_or_compute_hash(v, b); }
value_type &priv_value_from_slist_node(slist_node_ptr n)
{ return this->data_type::internal.internal.internal.internal.priv_value_from_slist_node(n); }
const value_type &priv_value_from_slist_node(slist_node_ptr n) const
{ return this->data_type::internal.internal.internal.internal.priv_value_from_slist_node(n); }
void priv_erasure_update_cache_range(SizeType first_bucket_num, SizeType last_bucket_num)
{ return this->data_type::internal.internal.priv_erasure_update_cache_range(first_bucket_num, last_bucket_num); }
void priv_erasure_update_cache()
{ return this->data_type::internal.internal.priv_erasure_update_cache(); }
static std::size_t priv_stored_hash(slist_node_ptr n, detail::true_ true_value)
{ return bucket_plus_vtraits<ValueTraits, BucketTraits>::priv_stored_hash(n, true_value); }
static std::size_t priv_stored_hash(slist_node_ptr n, detail::false_ false_value)
{ return bucket_plus_vtraits<ValueTraits, BucketTraits>::priv_stored_hash(n, false_value); }
std::size_t priv_hash_to_bucket(std::size_t hash_value) const
{
return detail::hash_to_bucket_split<power_2_buckets, incremental>
(hash_value, this->priv_bucket_traits().bucket_count(), this->priv_split_traits().get_size());
}
template<class Disposer>
void priv_erase_range_impl
(size_type bucket_num, siterator before_first_it, siterator end_sit, Disposer disposer, size_type &num_erased)
{
const bucket_ptr buckets = this->priv_bucket_pointer();
bucket_type &b = buckets[bucket_num];
if(before_first_it == b.before_begin() && end_sit == b.end()){
this->priv_erase_range_impl(bucket_num, 1, disposer, num_erased);
}
else{
num_erased = 0;
siterator to_erase(before_first_it);
++to_erase;
slist_node_ptr end_ptr = end_sit.pointed_node();
while(to_erase != end_sit){
group_functions_t::erase_from_group(end_ptr, detail::dcast_bucket_ptr<node>(to_erase.pointed_node()), optimize_multikey_t());
to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer));
++num_erased;
}
this->priv_size_traits().set_size(this->priv_size_traits().get_size()-num_erased);
}
}
template<class Disposer>
void priv_erase_range_impl
(size_type first_bucket_num, size_type num_buckets, Disposer disposer, size_type &num_erased)
{
//Now fully clear the intermediate buckets
const bucket_ptr buckets = this->priv_bucket_pointer();
num_erased = 0;
for(size_type i = first_bucket_num; i < (num_buckets + first_bucket_num); ++i){
bucket_type &b = buckets[i];
siterator b_begin(b.before_begin());
siterator nxt(b_begin);
++nxt;
siterator end_sit(b.end());
while(nxt != end_sit){
group_functions_t::init_group(detail::dcast_bucket_ptr<node>(nxt.pointed_node()), optimize_multikey_t());
nxt = b.erase_after_and_dispose
(b_begin, make_node_disposer(disposer));
this->priv_size_traits().decrement();
++num_erased;
}
}
}
template<class Disposer>
void priv_erase_range( siterator before_first_it, size_type first_bucket
, siterator last_it, size_type last_bucket
, Disposer disposer)
{
size_type num_erased;
if (first_bucket == last_bucket){
this->priv_erase_range_impl(first_bucket, before_first_it, last_it, disposer, num_erased);
}
else {
bucket_type *b = (&this->priv_bucket_pointer()[0]);
this->priv_erase_range_impl(first_bucket, before_first_it, b[first_bucket].end(), disposer, num_erased);
if(size_type n = (last_bucket - first_bucket - 1))
this->priv_erase_range_impl(first_bucket + 1, n, disposer, num_erased);
this->priv_erase_range_impl(last_bucket, b[last_bucket].before_begin(), last_it, disposer, num_erased);
}
}
std::size_t priv_get_bucket_num(siterator it)
{ return this->priv_get_bucket_num_hash_dispatch(it, store_hash_t()); }
std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_) //store_hash
{
return this->priv_hash_to_bucket
(this->priv_stored_hash(it.pointed_node(), store_hash_t()));
}
std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_) //NO store_hash
{ return this->data_type::internal.internal.internal.internal.priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); }
static siterator priv_get_previous(bucket_type &b, siterator i)
{ return bucket_plus_vtraits_t::priv_get_previous(b, i, optimize_multikey_t()); }
static siterator priv_get_last(bucket_type &b)
{ return bucket_plus_vtraits_t::priv_get_last(b, optimize_multikey_t()); }
template<class Disposer>
void priv_erase(const_iterator i, Disposer disposer, detail::true_)
{
slist_node_ptr elem(i.slist_it().pointed_node());
slist_node_ptr f_bucket_end, l_bucket_end;
if(store_hash){
f_bucket_end = l_bucket_end =
(this->priv_bucket_pointer()
[this->priv_hash_to_bucket
(this->priv_stored_hash(elem, store_hash_t()))
]).before_begin().pointed_node();
}
else{
f_bucket_end = this->priv_bucket_pointer()->cend().pointed_node();
l_bucket_end = f_bucket_end + this->priv_bucket_count() - 1;
}
node_ptr nxt_in_group;
siterator prev = bucket_type::s_iterator_to
(*group_functions_t::get_previous_and_next_in_group
( elem, nxt_in_group, f_bucket_end, l_bucket_end)
);
bucket_type::s_erase_after_and_dispose(prev, make_node_disposer(disposer));
if(nxt_in_group)
group_algorithms::unlink_after(nxt_in_group);
if(safemode_or_autounlink)
group_algorithms::init(detail::dcast_bucket_ptr<node>(elem));
}
template <class Disposer>
void priv_erase(const_iterator i, Disposer disposer, detail::false_)
{
siterator to_erase(i.slist_it());
bucket_type &b = this->priv_bucket_pointer()[this->priv_get_bucket_num(to_erase)];
siterator prev(this->priv_get_previous(b, to_erase));
b.erase_after_and_dispose(prev, make_node_disposer(disposer));
}
template<class KeyType, class KeyHasher, class KeyValueEqual>
siterator priv_find
( const KeyType &key, KeyHasher hash_func
, KeyValueEqual equal_func, size_type &bucket_number, std::size_t &h, siterator &previt) const
{
h = hash_func(key);
return this->priv_find_with_hash(key, equal_func, bucket_number, h, previt);
}
template<class KeyType, class KeyValueEqual>
siterator priv_find_with_hash
( const KeyType &key, KeyValueEqual equal_func, size_type &bucket_number, const std::size_t h, siterator &previt) const
{
bucket_number = this->priv_hash_to_bucket(h);
bucket_type &b = this->priv_bucket_pointer()[bucket_number];
previt = b.before_begin();
if(constant_time_size && this->empty()){
return this->priv_invalid_local_it();
}
siterator it = previt;
++it;
while(it != b.end()){
const value_type &v = this->priv_value_from_slist_node(it.pointed_node());
if(compare_hash){
std::size_t vh = this->priv_stored_or_compute_hash(v, store_hash_t());
if(h == vh && equal_func(key, v)){
return it;
}
}
else if(equal_func(key, v)){
return it;
}
if(optimize_multikey){
previt = bucket_type::s_iterator_to
(*group_functions_t::get_last_in_group
(detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t()));
it = previt;
}
else{
previt = it;
}
++it;
}
previt = b.before_begin();
return this->priv_invalid_local_it();
}
iterator priv_insert_equal_with_hash(reference value, std::size_t hash_value)
{
size_type bucket_num;
siterator prev;
siterator it = this->priv_find_with_hash
(value, this->priv_equal(), bucket_num, hash_value, prev);
return this->priv_insert_equal_find(value, bucket_num, hash_value, it);
}
iterator priv_insert_equal_find(reference value, size_type bucket_num, std::size_t hash_value, siterator it)
{
bucket_type &b = this->priv_bucket_pointer()[bucket_num];
bool found_equal = it != this->priv_invalid_local_it();
if(!found_equal){
it = b.before_begin();
}
//Now store hash if needed
node_ptr n = pointer_traits<node_ptr>::pointer_to(this->priv_value_to_node(value));
node_functions_t::store_hash(n, hash_value, store_hash_t());
//Checks for some modes
if(safemode_or_autounlink)
BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
//Shortcut for optimize_multikey cases
if(optimize_multikey){
node_ptr first_in_group = found_equal ?
detail::dcast_bucket_ptr<node>(it.pointed_node()) : node_ptr();
group_functions_t::insert_in_group(first_in_group, n, optimize_multikey_t());
}
//Update cache and increment size if needed
this->priv_insertion_update_cache(bucket_num);
this->priv_size_traits().increment();
//Insert the element in the bucket after it
return iterator(b.insert_after(it, *n), &this->get_bucket_value_traits());
}
template<class KeyType, class KeyHasher, class KeyValueEqual>
std::pair<siterator, siterator> priv_equal_range
( const KeyType &key
, KeyHasher hash_func
, KeyValueEqual equal_func
, size_type &bucket_number_first
, size_type &bucket_number_second
, size_type &cnt) const
{
std::size_t h;
cnt = 0;
siterator prev;
//Let's see if the element is present
std::pair<siterator, siterator> to_return
( this->priv_find(key, hash_func, equal_func, bucket_number_first, h, prev)
, this->priv_invalid_local_it());
if(to_return.first == to_return.second){
bucket_number_second = bucket_number_first;
return to_return;
}
{
//If it's present, find the first that it's not equal in
//the same bucket
bucket_type &b = this->priv_bucket_pointer()[bucket_number_first];
siterator it = to_return.first;
if(optimize_multikey){
to_return.second = bucket_type::s_iterator_to
(*node_traits::get_next(group_functions_t::get_last_in_group
(detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t())));
cnt = 0;
for(; it != to_return.second; ++it){ ++cnt; }
if(to_return.second != b.end()){
bucket_number_second = bucket_number_first;
return to_return;
}
}
else{
++cnt;
++it;
while(it != b.end()){
const value_type &v = this->priv_value_from_slist_node(it.pointed_node());
if(compare_hash){
std::size_t hv = this->priv_stored_or_compute_hash(v, store_hash_t());
if(hv != h || !equal_func(key, v)){
to_return.second = it;
bucket_number_second = bucket_number_first;
return to_return;
}
}
else if(!equal_func(key, v)){
to_return.second = it;
bucket_number_second = bucket_number_first;
return to_return;
}
++it;
++cnt;
}
}
}
//If we reached the end, find the first, non-empty bucket
for(bucket_number_second = bucket_number_first+1
; bucket_number_second != this->priv_bucket_count()
; ++bucket_number_second){
bucket_type &b = this->priv_bucket_pointer()[bucket_number_second];
if(!b.empty()){
to_return.second = b.begin();
return to_return;
}
}
//Otherwise, return the end node
to_return.second = this->priv_invalid_local_it();
return to_return;
}
/// @endcond
};
/// @cond
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template < class T
, bool UniqueKeys
, class PackedOptions
>
#else
template <class T, bool UniqueKeys, class ...Options>
#endif
struct make_bucket_traits
{
//Real value traits must be calculated from options
typedef typename detail::get_value_traits
<T, typename PackedOptions::proto_value_traits>::type value_traits;
typedef typename PackedOptions::bucket_traits specified_bucket_traits;
//Real bucket traits must be calculated from options and calculated value_traits
typedef typename detail::get_slist_impl
<typename detail::reduced_slist_node_traits
<typename value_traits::node_traits>::type
>::type slist_impl;
typedef typename
detail::if_c< detail::is_same
< specified_bucket_traits
, default_bucket_traits
>::value
, detail::bucket_traits_impl<slist_impl>
, specified_bucket_traits
>::type type;
};
/// @endcond
//! Helper metafunction to define a \c hashtable that yields to the same type when the
//! same options (either explicitly or implicitly) are used.
#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class ...Options>
#else
template<class T, class O1 = void, class O2 = void
, class O3 = void, class O4 = void
, class O5 = void, class O6 = void
, class O7 = void, class O8 = void
, class O9 = void, class O10= void
>
#endif
struct make_hashtable
{
/// @cond
typedef typename pack_options
< hashtable_defaults,
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
#else
Options...
#endif
>::type packed_options;
typedef typename detail::get_value_traits
<T, typename packed_options::proto_value_traits>::type value_traits;
typedef typename make_bucket_traits
<T, false, packed_options>::type bucket_traits;
typedef hashtable_impl
< value_traits
, typename packed_options::hash
, typename packed_options::equal
, typename packed_options::size_type
, bucket_traits
, (std::size_t(false)*hash_bool_flags::unique_keys_pos)
| (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
| (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
| (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
| (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
| (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
> implementation_defined;
/// @endcond
typedef implementation_defined type;
};
#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
#if defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template<class T, class ...Options>
#else
template<class T, class O1, class O2, class O3, class O4, class O5, class O6, class O7, class O8, class O9, class O10>
#endif
class hashtable
: public make_hashtable<T,
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
#else
Options...
#endif
>::type
{
typedef typename make_hashtable<T,
#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
#else
Options...
#endif
>::type Base;
BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable)
public:
typedef typename Base::value_traits value_traits;
typedef typename Base::iterator iterator;
typedef typename Base::const_iterator const_iterator;
typedef typename Base::bucket_ptr bucket_ptr;
typedef typename Base::size_type size_type;
typedef typename Base::hasher hasher;
typedef typename Base::bucket_traits bucket_traits;
typedef typename Base::key_equal key_equal;
//Assert if passed value traits are compatible with the type
BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
explicit hashtable ( const bucket_traits &b_traits
, const hasher & hash_func = hasher()
, const key_equal &equal_func = key_equal()
, const value_traits &v_traits = value_traits())
: Base(b_traits, hash_func, equal_func, v_traits)
{}
hashtable(BOOST_RV_REF(hashtable) x)
: Base(::boost::move(static_cast<Base&>(x)))
{}
hashtable& operator=(BOOST_RV_REF(hashtable) x)
{ return static_cast<hashtable&>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
};
#endif
} //namespace intrusive
} //namespace boost
#include <boost/intrusive/detail/config_end.hpp>
#endif //BOOST_INTRUSIVE_HASHTABLE_HPP
| revelator/The-Darkmod-Experimental | src/include/boost/intrusive/hashtable.hpp | C++ | lgpl-3.0 | 137,318 | [
30522,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<b>Users Currently Logged In</b>
<ul>
<?php if (!empty($currentUsers)):foreach($currentUsers as $u):?>
<li>
<?php echo $u->getFullName();?>
</li>
<?php endforeach;endif;?>
</ul>
| 2pisoftware/cmfive | system/modules/admin/templates/index.tpl.php | PHP | gpl-3.0 | 214 | [
30522,
1026,
1038,
1028,
5198,
2747,
26618,
1999,
1026,
1013,
1038,
1028,
1026,
17359,
1028,
1026,
1029,
25718,
2065,
1006,
999,
4064,
1006,
1002,
2783,
20330,
2015,
1007,
1007,
1024,
18921,
6776,
1006,
1002,
2783,
20330,
2015,
2004,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/********************************************************************
* Copyright © 2016 Computational Molecular Biology Group, *
* Freie Universität Berlin (GER) *
* *
* This file is part of ReaDDy. *
* *
* ReaDDy is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General *
* Public License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
********************************************************************/
/**
* This header file contains:
* * the `readdy::model::particle_flavor` type which takes values as defined in the `readdy::model::particleflavor`
* namespace
* * the definition of ParticleTypeInfo, backing structure for all particle types
* * the definition of ParticleTypeRegistry, an object managing all particle types for a reaction diffusion system
*
* @file ParticleTypeRegistry.h
* @brief Header file containing definitions for particle flavors, particle type info and the particle type registry.
* @author clonker
* @date 29.03.17
* @copyright GNU Lesser General Public License v3.0
*/
#pragma once
#include <readdy/common/common.h>
#include "Particle.h"
NAMESPACE_BEGIN(readdy)
NAMESPACE_BEGIN(model)
using particle_flavor = std::uint8_t;
NAMESPACE_BEGIN(particleflavor)
static constexpr particle_flavor NORMAL = 0;
static constexpr particle_flavor TOPOLOGY = 1;
static constexpr particle_flavor MEMBRANE = 2;
inline static std::string particle_flavor_to_str(particle_flavor flavor) {
switch(flavor) {
case model::particleflavor::NORMAL: return "NORMAL";
case model::particleflavor::TOPOLOGY: return "TOPOLOGY";
case model::particleflavor::MEMBRANE: return "MEMBRANE";
default: return "UNKNOWN";
}
}
NAMESPACE_END(particleflavor)
struct ParticleTypeInfo {
std::string name;
scalar diffusionConstant;
particle_flavor flavor;
particle_type_type typeId;
ParticleTypeInfo(const std::string &name, scalar diffusionConstant,
particle_flavor flavor, Particle::type_type typeId);
};
class ParticleTypeRegistry {
public:
using type_map = std::unordered_map<std::string, particle_type_type>;
ParticleTypeRegistry() = default;
ParticleTypeRegistry(const ParticleTypeRegistry &) = default;
ParticleTypeRegistry &operator=(const ParticleTypeRegistry &) = default;
ParticleTypeRegistry(ParticleTypeRegistry &&) = default;
ParticleTypeRegistry &operator=(ParticleTypeRegistry &&) = default;
~ParticleTypeRegistry() = default;
particle_type_type idOf(const std::string &name) const {
return _idOf(name);
}
particle_type_type operator()(const std::string &name) const {
return idOf(name);
}
void add(const std::string &name, scalar diffusionConst, particle_flavor flavor = particleflavor::NORMAL);
void addTopologyType(const std::string &name, scalar diffusionConst) {
add(name, diffusionConst, particleflavor::TOPOLOGY);
}
const ParticleTypeInfo &infoOf(const std::string &name) const {
return infoOf(_idOf(name));
}
const ParticleTypeInfo &infoOf(Particle::type_type type) const {
return particle_info_.at(type);
}
scalar diffusionConstantOf(const std::string &particleType) const {
return diffusionConstantOf(idOf(particleType));
}
scalar diffusionConstantOf(particle_type_type particleType) const {
return particle_info_.at(particleType).diffusionConstant;
}
const std::size_t &nTypes() const {
return n_types_;
}
std::vector<particle_type_type> typesFlat() const {
std::vector<particle_type_type> v;
std::transform(std::begin(type_mapping_), std::end(type_mapping_), std::back_inserter(v), [](const auto &e) {
return e.second;
});
return v;
}
std::string nameOf(particle_type_type id) const {
auto it = std::find_if(std::begin(type_mapping_), std::end(type_mapping_), [id](const auto &e) {
return e.second == id;
});
return it == std::end(type_mapping_) ? "" : it->first;
}
const type_map &typeMapping() const {
return type_mapping_;
}
std::string describe() const;
void configure() {
/*no op*/
}
private:
particle_type_type _idOf(const std::string &name) const {
auto it = type_mapping_.find(name);
if (it == type_mapping_.end()) {
throw std::invalid_argument(
fmt::format("Could not find type \"{}\", did you forget to register it before accessing it?", name)
);
}
return it->second;
}
std::size_t n_types_ = 0;
particle_type_type type_counter_ = 0;
type_map type_mapping_ {};
std::unordered_map<particle_type_type, ParticleTypeInfo> particle_info_ {};
};
NAMESPACE_END(model)
NAMESPACE_END(readdy)
| chrisfroe/readdy | include/readdy/model/ParticleTypeRegistry.h | C | lgpl-3.0 | 5,843 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* board/omap3621_boxer/max17042.c
*
* Copyright (C) 2010 Barnes & Noble, Inc.
* Intrinsyc Software International, Inc. on behalf of Barnes & Noble, Inc.
*
* Max17042 Gas Gauge initialization for u-boot
*
* 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
*/
#include <common.h>
#include <asm/arch/cpu.h>
#include <asm/io.h>
#include <asm/arch/bits.h>
#include <asm/arch/mux.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/sys_info.h>
#include <asm/arch/clocks.h>
#include <asm/arch/mem.h>
#include <i2c.h>
#include <asm/mach-types.h>
#define TEMP_RESOLUTION 3900 /*3900uC*/
#define COMPLEMENT_VAL(x, y, z) (( ((((~x) & 0x7FFF) + 1) * y) / z ) * (-1))
#define MAX17042_ADDR 0x36
#define MAX_WRITE(reg, val) i2c_multidata_write(MAX17042_ADDR, (reg), 1, (val), 2)
#define MAX_READ(reg, val) i2c_read_2_byte(MAX17042_ADDR,(reg), (val))
struct max17042_saved_data {
uint16_t tag;
uint16_t val_FullCAP;
uint16_t val_Cycles;
uint16_t val_FullCAPNom;
uint16_t val_SOCempty;
uint16_t val_Iavg_empty;
uint16_t val_RCOMP0;
uint16_t val_TempCo;
uint16_t val_k_empty0;
uint16_t val_dQacc;
uint16_t val_dPacc;
uint16_t val_SOCmix;
uint16_t val_Empty_TempCo;
uint16_t val_ICHGTerm;
uint16_t val_Vempty;
uint16_t val_FilterCFG;
uint16_t val_TempNom;
uint16_t val_DesignCap;
uint16_t val_Capacity;
uint16_t val_SOCREP;
};
static struct max17042_saved_data save_store;
static int is_power_on = 1; //battery flat, battery removed,
static int is_history_exist = 1; //max17042.bin is in ROM partition
static uint16_t VFSOC = 0;
#define DEBUG(x...) printf(x)
#define TEMPLIM 0x2305 // hard POR value
#define MISCCFG 0x0810 // hard POR value -- and with 0xCC1F
#define MISCCFG_MASK 0xCC1F
#define TGAIN 0xE3E1 // hard POR value
#define TOFF 0x290E // hard POR value
#define CGAIN 0x4000 // hard POR value
#define COFF 0x0000 // hard POR value
#define FCTC 0x05E0 // hard POR value
#define MAX17042_STATUS 0x00
#define MAX17042_RemCapREP 0x05
#define MAX17042_SOCREP 0x06
#define MAX17042_Vcell 0x09
#define MAX17042_SOCmix 0x0D
#define MAX17042_RemCapmix 0x0F
#define MAX17042_FullCap 0x10
#define MAX17042_Vempty 0x12
#define MAX17042_Cycles 0x17
#define MAX17042_DesignCap 0x18
#define MAX17042_CONFIG 0x1D
#define MAX17042_ICHGTerm 0x1E
#define MAX17042_Version 0x21
#define MAX17042_FullCAPNom 0x23
#define MAX17042_TempNom 0x24
#define MAX17042_TempLim 0x25
#define MAX17042_LearnCFG 0x28
#define MAX17042_RelaxCFG 0x2A
#define MAX17042_FilterCFG 0x29
#define MAX17042_MiscCFG 0x2B
#define MAX17042_TGAIN 0x2C
#define MAX17042_TOFF 0x2D
#define MAX17042_CGAIN 0x2E
#define MAX17042_COFF 0x2F
#define MAX17042_SOCempty 0x33
#define MAX17042_FullCap0 0x35
#define MAX17042_Iavg_empty 0x36
#define MAX17042_FCTC 0x37
#define MAX17042_RCOMP0 0x38
#define MAX17042_TempCo 0x39
#define MAX17042_Empty_TempCo 0x3A
#define MAX17042_k_empty0 0x3B
#define MAX17042_dQacc 0x45
#define MAX17042_dPacc 0x46
#define MAX17042_VFSOC_Unlock 0x60
#define MAX17042_OCV 0xFB
#define MAX17042_FSTAT 0xFD
#define MAX17042_SOCvf 0xFF
#define MAX17042_STATUS_bit_POR (1<<1)
typedef enum
{
BATT_LG = 0,
BATT_MCNAIR,
/* add new battery type here */
BATT_MAX
} batt_type;
// This struct contains registers for initialize configuration
typedef struct
{
uint16_t RelaxCFG;
uint16_t Config;
uint16_t FilterCFG;
uint16_t LearnCFG;
uint16_t Vempty;
uint16_t RCOMP0;
uint16_t TempCo;
uint16_t ETC;
uint16_t Kempty0;
uint16_t ICHGTerm;
uint16_t Capacity;
} max17042_init_params;
// 48-word custom model params
typedef struct
{
uint16_t buf_80h[16];
uint16_t buf_90h[16];
uint16_t buf_A0h[16];
} max17042_custom_model;
// All the registers for initializing max17042
typedef struct
{
const max17042_init_params* init_params;
const max17042_custom_model* model;
} batt_type_params;
// This table containas default initialization values provided by maxim for different battery types.
static const max17042_init_params const init_param_table[BATT_MAX] =
{
//RelaxCFG Config FilterCFG LearnCFG Vempty RCOMP0 TempCo ETC Kempty0 ICHGTerm Capacity
/*LG */{ 0x083B, 0x2210, 0x87A4, 0x2406, 0x7D5A, 0x0080, 0x3670, 0x2F2C, 0x078F, 0x0140, 0x205C},
/*MCNAIR*/{ 0x083B, 0x2210, 0x87A4, 0x2406, 0x7D5A, 0x0081, 0x1921, 0x0635, 0x0679, 0x04F3, 0x1EB9},
// add an entry here for new battery type
};
// This table containas 48-word custom model params provided by maxim for different battery types.
static const max17042_custom_model const model_table[BATT_MAX] =
{
// LG
{
/*80h*/{0xA0D0, 0xB3F0, 0xB820, 0xB940, 0xBB80, 0xBBF0, 0xBC90, 0xBD00, 0xBDA0, 0xBE80, 0xBF70, 0xC280, 0xC5B0, 0xC7F0, 0xCAB0, 0xD030},
/*90h*/{0x0100, 0x0700, 0x1400, 0x0B00, 0x2640, 0x3210, 0x1D40, 0x2C00, 0x1760, 0x15D0, 0x09C0, 0x0CE0, 0x0BD0, 0x09F0, 0x08F0, 0x08F0},
/*A0h*/{0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100},
},
// MCNAIR
{
/*80h*/{0x9EE0, 0xB660, 0xB7D0, 0xB980, 0xBB00, 0xBBD0, 0xBCA0, 0xBD70, 0xBE60, 0xBF70, 0xC0A0, 0xC410, 0xC710, 0xCA50, 0xCC80, 0xD100},
/*90h*/{0x0060, 0x13F0, 0x0AF0, 0x10B0, 0x1920, 0x2720, 0x1E30, 0x1A20, 0x1600, 0x14F0, 0x0BF0, 0x0CF0, 0x0610, 0x0A00, 0x0A80, 0x0A80},
/*A0h*/{0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100},
},
// add an entry here for new battery type
};
static const batt_type_params param_table[BATT_MAX] =
{
/*LG */ {&init_param_table[BATT_LG], &model_table[BATT_LG] },
/*MCNAIR*/ {&init_param_table[BATT_MCNAIR], &model_table[BATT_MCNAIR]},
// add an entry here for new battery type
};
static const batt_type_params* type_params = ¶m_table[BATT_LG];
static inline int max17042_dumpreg( char *pRegName, int iReg ) {
uint16_t val;
MAX_READ( iReg, (uchar*)&val);
DEBUG("%s (%02xh) is 0x%04x\n", pRegName, iReg, val );
return val;
}
#define MAX17042_DUMPREG( reg ) max17042_dumpreg( #reg, reg )
static int max17042_check_init_config(void)
{
uint16_t buf=0;
const max17042_init_params* params = type_params->init_params;
MAX_READ(MAX17042_CONFIG, (uchar*)&buf);
DEBUG("uboot verify: %02x CONFIG is %04x ; should be %04x & 0xFDFB\n",
MAX17042_CONFIG, buf, params->Config);
// in case of warm boot, kernel might have changed bits Ten and Aen
if ( (buf & ~0x0204) != ( params->Config & ~0x0204) )
return 1;
buf=0;
MAX_READ(MAX17042_RelaxCFG, (uchar*)&buf);
DEBUG("uboot verify: %02x RELAXCFG is %04x ; should be %04x\n",
MAX17042_RelaxCFG, buf, params->RelaxCFG);
if ( buf != params->RelaxCFG )
return 1;
buf=0;
MAX_READ(MAX17042_FilterCFG, (uchar*)&buf);
DEBUG("uboot verify: %02x FILTERCFG is %04x ; should be %04x\n",
MAX17042_FilterCFG, buf, params->FilterCFG);
if ( buf != params->FilterCFG )
return 1;
buf=0;
MAX_READ(MAX17042_LearnCFG, (uchar*)&buf);
DEBUG("uboot verify: %02x LEARNCFG is %04x ; should be %04x & 0xFF0F\n",
MAX17042_LearnCFG, buf, params->LearnCFG);
if ( (buf & 0xFF0F) != ( params->LearnCFG & 0xFF0F) )
return 1;
MAX_READ( MAX17042_DesignCap, (u8*)&buf);
DEBUG("uboot verify: %02x DesignCap is %04x ; should be %04x\n",
MAX17042_DesignCap, buf, params->Capacity);
if ( buf != params->Capacity )
return 1;
MAX_READ( MAX17042_Vempty, (u8*)&buf);
DEBUG("uboot verify: %02x Vempty is %04x ; should be %04x\n",
MAX17042_Vempty, buf, params->Vempty);
if ( buf != params->Vempty )
return 1;
buf=0;
MAX_READ(MAX17042_TempLim, (uchar*)&buf);
DEBUG("uboot verify: %02x TEMPLIM is %04x ; should be %04x\n",
MAX17042_TempLim, buf, TEMPLIM);
if ( buf != TEMPLIM )
return 1;
buf=0;
MAX_READ(MAX17042_MiscCFG, (uchar*)&buf);
DEBUG("uboot verify: %02x MiscCFG is %04x ; should be %04x & %04x\n",
MAX17042_MiscCFG, buf, MISCCFG, MISCCFG_MASK );
if ( (buf & MISCCFG_MASK) != (MISCCFG & MISCCFG_MASK) )
return 1;
buf=0;
MAX_READ(MAX17042_TGAIN, (uchar*)&buf);
DEBUG("uboot verify: %02x TGAIN is %04x ; should be %04x\n",
MAX17042_TGAIN, buf, TGAIN);
if ( buf != TGAIN )
return 1;
buf=0;
MAX_READ(MAX17042_TOFF, (uchar*)&buf);
DEBUG("uboot verify: %02x TOFF is %04x ; should be %04x\n",
MAX17042_TOFF, buf, TOFF);
if ( buf != TOFF )
return 1;
buf=0;
MAX_READ(MAX17042_CGAIN, (uchar*)&buf);
DEBUG("uboot verify: %02x CGAIN is %04x ; should be %04x\n",
MAX17042_CGAIN, buf, CGAIN);
if ( buf != CGAIN )
return 1;
buf=0;
MAX_READ(MAX17042_COFF, (uchar*)&buf);
DEBUG("uboot verify: %02x COFF is %04x ; should be %04x\n",
MAX17042_COFF, buf, COFF);
if ( buf != COFF )
return 1;
buf=0;
MAX_READ(MAX17042_FCTC, (uchar*)&buf);
DEBUG("uboot verify: %02x FCTC is %04x ; should be %04x\n",
MAX17042_FCTC, buf, FCTC);
if ( buf != FCTC )
return 1;
return 0;
}
static int max17042_init_config(void)
{
int err;
const max17042_init_params* params = type_params->init_params;
err =MAX_WRITE(MAX17042_CONFIG, (uchar*)&(params->Config));
if ( err != 0 ) {
DEBUG("uboot: write err CONFIG \n");
return err;
}
// DEBUG("config = 0x%04x\n", params->Config);
err =MAX_WRITE(MAX17042_RelaxCFG, (uchar*)¶ms->RelaxCFG);
if ( err != 0 ) {
DEBUG( "uboot: write err RelaxCFG \n");
return err;
}
// DEBUG("relaxcfg = 0x%04x\n", params->RelaxCFG);
err =MAX_WRITE(MAX17042_FilterCFG, (uchar*)¶ms->FilterCFG);
if ( err != 0 ) {
DEBUG( "write err FilterCFG \n");
return err;
}
// DEBUG("filtercfg = 0x%04x\n", params->FilterCFG);
err =MAX_WRITE(MAX17042_LearnCFG, (uchar*)& params->LearnCFG);
if ( err != 0 ) {
DEBUG( "write err LearnCFG\n");
return err;
}
// DEBUG("LearnCFG = 0x%04x\n", params->learncfg);
err =MAX_WRITE(MAX17042_Vempty, (uchar*)& params->Vempty);
if ( err != 0 ) {
DEBUG( "write err Vempty\n");
return err;
}
// DEBUG("Vempty = 0x%04x\n", params->Vempty);
return max17042_check_init_config();
}
int is_max17042_por(void)
{
uint16_t stat = 0;
int ret;
stat = MAX17042_DUMPREG(MAX17042_STATUS);
ret = (stat & MAX17042_STATUS_bit_POR) ? 1: 0 ;
return ret;
}
//return 1: memory lost on power_on
//return 0; memory is in place
static int is_power_on_rst(void)
{
int ret = 0;
uint16_t stat = 0;
stat = MAX17042_DUMPREG(MAX17042_STATUS);
/*POR bit check*/
/*
previous code has the operator precedence problem where
!= is evaluated before bitand !
*/
if ( (stat & MAX17042_STATUS_bit_POR) != 0 ) {
ret = 1;
}
if( (stat & (1 <<15))!=0)
DEBUG("MAX17042+UBOOT: POWER SUPPLY Detected!\n");
else
DEBUG("MAX17042+UBOOT: BATTERY Detected!\n");
is_power_on = ret;
return ret;
}
static void max17042_clear_POR(void)
{
uint16_t stat = 0;
stat = MAX17042_DUMPREG(MAX17042_STATUS);
if ( stat & MAX17042_STATUS_bit_POR ) {
DEBUG("STATUS = 0x%04x -- clearing POR\n", stat );
stat &= ~MAX17042_STATUS_bit_POR;
MAX_WRITE(MAX17042_STATUS,(uchar*)&stat);
MAX17042_DUMPREG(MAX17042_STATUS);
}
}
static int max17042_save_start_para(void)
{
int err;
uint16_t buf;
err =MAX_READ(MAX17042_SOCmix, (uchar*)&buf);
if ( err != 0 ) {
DEBUG("read err MixedSOC \n");
return err;
}
else
save_store.val_SOCmix = buf;
err =MAX_READ(MAX17042_dQacc, (uchar*)&buf);
if ( err != 0 ) {
DEBUG( "read err dQ_acc \n");
return err;
}
else
save_store.val_dQacc = buf;
err =MAX_READ(MAX17042_dPacc, (uchar*)&buf);
if ( err != 0 ) {
DEBUG( "read err dP_acc \n");
return err;
}
else
save_store.val_dPacc = buf;
return 0;
}
static void max17042_unlock_model(void)
{
static uint16_t val1 = 0x0059;
static uint16_t val2 = 0x00C4;
MAX_WRITE(0x62, (uchar*)&val1);
udelay(10);
MAX_WRITE(0x63, (uchar*)&val2);
}
static int max17042_write_model(void)
{
int i;
int err=1;
const max17042_custom_model* model = type_params->model;
for ( i = 0; i < 16; i++) {
err = MAX_WRITE((0x80+i), (uchar*)(&model->buf_80h[i]));
if ( err != 0 ) {
DEBUG( "write err model 0x80 \n");
return err;
}
//DEBUG(" %x write %04x\n", (0x80+i), model->buf_80h[i]);
udelay(10);
err = MAX_WRITE((0x90+i), (uchar*)(&model->buf_90h[i]));
if ( err != 0 ) {
DEBUG( "write err model 0x90 \n");
return err;
}
//DEBUG(" %x write %04x\n", (0x90+i), model->buf_90h[i]);
udelay(10);
MAX_WRITE((0xA0+i), (uchar*)(&model->buf_A0h[i]));
if ( err != 0 ) {
DEBUG( "write err model 0xA0 \n");
return err;
}
//DEBUG(" %x write %04x\n", (0xA0+i), model->buf_A0h[i]);
udelay(10);
}
return 0;
}
static int max17042_read_verify_model(void)
{
int i;
uint16_t buf;
int err = 1;
const max17042_custom_model* model = type_params->model;
for ( i = 0; i < 16; i++) {
err = MAX_READ((0x80+i), (uchar*)&buf);
if ( err != 0 ) {
DEBUG( "read err model 0x80 \n");
return err;
} else if ( buf != model->buf_80h[i] ) {
DEBUG(" err 80h item %d not matched\n", i);
return 1;
}
//DEBUG(" %x model: %04x\n", (0x80+i), buf);
udelay(10);
err = MAX_READ((0x90+i), (uchar*)&buf);
if ( err != 0 ) {
DEBUG( "read err model 0x90 \n");
return err;
}else if ( buf != model->buf_90h[i] ) {
DEBUG(" err 90h item %d not matched\n", i);
return 1;
}
//DEBUG(" %x model: %04x\n", (0x90+i), buf);
udelay(10);
err = MAX_READ((0xA0+i), (uchar*)&buf);
if ( err != 0 ) {
DEBUG( "read err model 0xA0 \n");
return err;
}else if ( buf != model->buf_A0h[i] ) {
DEBUG(" err A0h item %d not matched\n", i);
return 1;
}
//DEBUG(" %x model: %04x\n", (0xA0+i), buf);
udelay(10);
}
return 0;
}
static void max17042_lock_model(void)
{
static const uint16_t lock = 0x0000;
MAX_WRITE(0x62, (uchar*)&lock);
udelay(10);
MAX_WRITE(0x63, (uchar*)&lock);
udelay(100);
return;
}
static int max17042_verify_lock_model(void)
{
int i;
uint16_t buf;
int err = 1;
for ( i = 0; i < 16; i++) {
err = MAX_READ((0x80+i), (uchar*)&buf);
//DEBUG(" %x model: %04x\n", (0x80+i), buf);
if ( err != 0 ) {
DEBUG( "read err model 0x80 \n");
return err;
} else if ( buf != 0x0000 ) {
DEBUG(" err model not locked!\n", i);
return 1;
}
udelay(10);
err = MAX_READ((0x90+i), (uchar*)&buf);
//DEBUG(" %x model: %04x\n", (0x90+i), buf);
if ( err != 0 ) {
DEBUG( "read err model 0x90 \n");
return err;
}else if ( buf != 0x0000 ) {
DEBUG(" err model not locked\n", i);
return 1;
}
udelay(10);
err = MAX_READ((0xA0+i), (uchar*)&buf);
//DEBUG(" %x model: %04x\n", (0xA0+i), buf);
if ( err != 0 ) {
DEBUG( "read err model 0xA0 \n");
return err;
}else if ( buf != 0x0000 ) {
DEBUG(" err model not locked\n", i);
return 1;
}
udelay(10);
}
return 0;
}
int max17042_soft_por(void)
{
uint16_t buf = 0;
int iReps;
iReps = 0;
while ( 1 ) {
if ( iReps++ > 10 ) {
DEBUG("Soft POR : unlock failure\n");
return 1;
}
// DEBUG("Soft POR : attempting unlock\n");
max17042_lock_model();
buf = 0;
MAX_WRITE(MAX17042_STATUS, (uchar*)&buf); // clear all Status
// note: clear POR bit is not enough here
udelay(1000);
MAX_READ(MAX17042_STATUS, (uchar*)&buf);
if ( buf != 0 )
continue;
MAX_READ(0x62, (uchar*)&buf);
if ( buf != 0 )
continue;
MAX_READ(0x63, (uchar*)&buf);
if ( buf != 0 )
continue;
break;
}
// DEBUG("Soft POR: unlocked\n");
for ( iReps = 0; iReps < 10; iReps++ ) {
buf = 0x000F;
MAX_WRITE(0x60, (uchar*)&buf);
udelay(2*1000);
if ( is_max17042_por() ) {
DEBUG("Soft POR: Success!\n");
return 0;
}
}
DEBUG("Soft POR: failed\n");
return 1;
}
static int max_write_verify( u8 reg, const u8* val)
{
int err;
uint16_t buf1, buf2;
int iTmp;
buf1 = *(uint16_t*)val;
// DEBUG("%s: write 0x%04x to reg 0x%x\n", __FUNCTION__, buf1, reg );
for ( iTmp=0; iTmp < 3; iTmp++ ) {
err = MAX_WRITE( reg, (uchar*)val );
udelay(50);
err = MAX_READ( reg, (u8*)&buf2 );
if ( buf1 == buf2 )
return 0;
DEBUG("Retry write 0x%04x to reg 0x%x\n", buf1, reg );
}
DEBUG ("Failed to write 0x%04x to reg 0x%x (contains 0x%04x)\n", buf1, reg, buf2 );
return 1;
}
static int max17042_set_cycles( uint16_t cycles )
{
return max_write_verify(MAX17042_Cycles, (u8*)&cycles);
}
static int max17042_restore_fullcap(void)
{
int err;
uint16_t fullcap0, remcap, SOCmix, dPacc, dQacc;
if ( !is_history_exist ) {
printf("%s: no history file exists!\n", __FUNCTION__);
return 1;
}
DEBUG("Restoring learned full capacity\n");
err = MAX_READ(MAX17042_FullCap0, (u8*)&fullcap0);
if ( err != 0 ) {
DEBUG( "read err reg 0x%x\n", MAX17042_FullCap0);
return err;
}
err =MAX_READ(MAX17042_SOCmix, (uchar*)&SOCmix);
if ( err != 0 ) {
DEBUG( "read err reg 0x%x\n", MAX17042_SOCmix);
return err;
}
remcap = (uint16_t)( ((int)SOCmix * (int)fullcap0) / 25600 );
DEBUG("FullCap0=0x%04x SOCmix=0x%04x, remcap=0x%04x\n", fullcap0, SOCmix, remcap);
err = max_write_verify(MAX17042_RemCapmix, (u8*)&remcap);
if ( err != 0 ) {
return err;
}
err = max_write_verify(MAX17042_FullCap,(u8*)&save_store.val_FullCAP);
if ( err != 0 ) {
return err;
}
DEBUG("FullCAP = 0x%04x\n", save_store.val_FullCAP);
dQacc = (save_store.val_FullCAPNom / 4);
err = max_write_verify(MAX17042_dQacc, (u8*)&dQacc);
if ( err != 0 ) {
return err;
}
dPacc = 0x1900;
err = max_write_verify(MAX17042_dPacc, (u8*)&dPacc);
if ( err != 0 ) {
return err;
}
return 0;
}
static int max17042_restore_learned_para(void)
{
int err;
if ( !is_history_exist ) {
printf("%s: error: no history file exists!\n", __FUNCTION__);
return 1;
}
DEBUG("Restoring learned parameters\n");
//21. Restore Learned Parameters
err = max_write_verify( MAX17042_RCOMP0, (u8*)&save_store.val_RCOMP0 );
if ( err != 0 ) {
return err;
}
err = max_write_verify ( MAX17042_TempCo, (u8*)&save_store.val_TempCo );
if ( err != 0 ) {
return err;
}
err = max_write_verify( MAX17042_Iavg_empty, (u8*)&save_store.val_Iavg_empty);
if ( err != 0 ) {
return err;
}
err = max_write_verify( MAX17042_k_empty0, (u8*)&save_store.val_k_empty0 );
if ( err != 0 ) {
return err;
}
err = max_write_verify(MAX17042_FullCAPNom, (u8*)&save_store.val_FullCAPNom);
if ( err != 0 ) {
return err;
}
//22. delay 350ms;
udelay ( 350 *1000 );
//23. RestoreFullCap
err = max17042_restore_fullcap();
if ( err != 0 ) {
return err;
}
//24. delay 350ms;
udelay ( 350 *1000 );
//25. restore Cycles
err = max17042_set_cycles( save_store.val_Cycles );
if (err != 0 ) {
DEBUG("restoring cycles failed\n");
return err;
}
return 0;
}
static int max17042_write_custom_para(void)
{
uint16_t buf;
int err;
/*
* Note: This hardcoded values are specific to Encore as supplied
* by Maxim via email, 16/07/2010
*/
DEBUG("%s: use hardcoded values\n", __FUNCTION__);
buf = 0x0080;
err = max_write_verify( MAX17042_RCOMP0, (u8*)&buf );
if ( err != 0 ) {
return err;
}
buf = 0x3670;
err = max_write_verify ( MAX17042_TempCo, (u8*)&buf );
if ( err != 0 ) {
DEBUG( "write verify err 0x39 \n");
return err;
}
buf = 0x2F2C;
err = MAX_WRITE( MAX17042_Empty_TempCo, (u8*)&buf);
if ( err != 0 ) {
DEBUG( "write err 0x3A \n");
return err;
}
buf = 0x078F;
err = max_write_verify( MAX17042_k_empty0, (u8*)&buf );
if ( err != 0 ) {
DEBUG( "write verify err 0x3B \n");
return err;
}
// IchgTerm should map to 50 mA
buf = (uint16_t)(0.050 * 0.01 / 0.0000015625);
err = MAX_WRITE( MAX17042_ICHGTerm, (u8*)&buf );
if ( err != 0 ) {
DEBUG( "write verify err reg 0x%x\n", MAX17042_ICHGTerm);
return err;
}
DEBUG("ICHGTerm = 0x%04x\n", buf);
return 0;
}
static int max17042_update_cap_para(void)
{
int err;
uint16_t buf;
buf = type_params->init_params->Capacity;
DEBUG(" use hardcoded Capacity 0x%04x\n", buf);
err = max_write_verify( MAX17042_FullCap, (u8*)&buf);
if ( err != 0 ) {
return err;
}
err = MAX_WRITE( MAX17042_DesignCap, (u8*)&buf);
if ( err != 0 ) {
DEBUG( "write verify err reg 0x%x\n", MAX17042_DesignCap);
return err;
}
err = max_write_verify( MAX17042_FullCAPNom, (u8*)&buf);
if ( err != 0 ) {
DEBUG( "write verify err reg 0x%x\n", MAX17042_FullCAPNom);
return err;
}
return 0;
}
static int max17042_write_vfsoc(void)
{
int err = 0;
uint16_t buf;
err = MAX_READ(0xFF, (u8*)&buf);
if ( err != 0 ) {
DEBUG( "read err 0xFF\n");
return err;
}
VFSOC = buf; // used in step 16
DEBUG("VFSOC = 0x%04x\n", VFSOC);
buf = 0x0080; // unlock code
MAX_WRITE(MAX17042_VFSOC_Unlock, (u8*)&buf);
err = max_write_verify(0x48, (u8*)&VFSOC);
buf = 0x0000; // lock code
MAX_WRITE(MAX17042_VFSOC_Unlock, (u8*)&buf);
return err;
}
static int max17042_load_cap_para( void )
{
uint16_t buf, remcap, repcap, dq_acc, fullcap0;
//16.
MAX_READ(MAX17042_FullCap0, (u8*)&fullcap0);
remcap = (uint16_t)( ((int)VFSOC * (int)fullcap0) / 25600 );
DEBUG("fullcap0=0x%04x VFSOC=0x%04x remcap=0x%04x\n", fullcap0, VFSOC, remcap);
MAX_WRITE(MAX17042_RemCapmix, (u8*)&remcap);
repcap = remcap;
max_write_verify(MAX17042_RemCapREP, (u8*)&repcap);
//write dQ_acc and dP_acc to 200% of capacity
dq_acc = save_store.val_DesignCap / 4;
max_write_verify(MAX17042_dQacc, (u8*)&dq_acc);
buf = 0x3200;
max_write_verify(MAX17042_dPacc, (u8*)&buf);
max_write_verify(MAX17042_FullCap, (u8*)&save_store.val_DesignCap);
MAX_WRITE(MAX17042_DesignCap, (u8*)&save_store.val_DesignCap);
max_write_verify(MAX17042_FullCAPNom, (u8*)&save_store.val_DesignCap);
return 0;
}
static batt_type get_battery_type(int load)
{
batt_type ret = BATT_LG;
char *token = (char*) 0x81000000;
token[0] = 'L';
token[1] = 'G';
if (load) {
// Ignore the result of this command, if it fails it's LG battery...
run_command("mmcinit 1; fatload mmc 1:4 0x81000000 devconf/BatteryType 0x40", 0);
}
if(('L' == token[0] || 'l' == token[0]) &&
('G' == token[1] || 'g' == token[1]) )
{ }
else if (('M' == token[0] || 'm' == token[0]) &&
('C' == token[1] || 'c' == token[1]) &&
('N' == token[2] || 'n' == token[2]) &&
('A' == token[3] || 'a' == token[3]) &&
('I' == token[4] || 'i' == token[4]) &&
('R' == token[5] || 'r' == token[5]) )
{
ret = BATT_MCNAIR;
}
DEBUG("MAX17042+UBOOT: battery type=%s\n", (BATT_LG == ret)? "LG" : "MCNAIR");
return ret;
}
int max17042_init(int load)
{
uint16_t data;
int i;
static const uint16_t* bufp = (uint16_t*) 0x81000000;
uint16_t* savestorep;
int err, retries=2, force_por=0;
uint16_t designcap;
type_params = ¶m_table[get_battery_type(load)];
designcap = type_params->init_params->Capacity;
i2c_init(100, MAX17042_ADDR);
if ( MAX_READ(MAX17042_STATUS, (uchar*)&data) != 0)
{
DEBUG("MAX17042+UBOOT: No battery or 0V battery!\n");
return 1;
}
DEBUG("MAX17042+UBOOT: gas gauge detected (0x%04x)\n",data);
//check if we need restore registers inside
is_power_on_rst();
if ( is_power_on ) {
DEBUG("MAX17042+UBOOT:POR detected!\n");
} else {
DEBUG("MAX17042+UBOOT:WARM BOOT \n");
}
if (load) {
run_command("mmcinit 1; fatload mmc 1:5 0x81000000 max17042.bin 0x1000", 0);
}
if (*bufp != 0x1234 || !load) {
DEBUG(" No valid max17042 init data found, assume no battery history \n");
is_history_exist = 0;
} else {
DEBUG(" Valid max17042 init data is loaded into memory \n");
}
if ( is_history_exist == 1 ) {
savestorep = (uint16_t*)&save_store;
for ( i = 0; i <(sizeof(save_store) / sizeof(uint16_t)); i++) {
DEBUG (" 0x%04x\n", *bufp);
*savestorep++ = *bufp++;
}
#define MIN_CAP_AGING 25/100 // allow no less than 25% of design capacity before rejecting
#define MAX_CAP_AGING 13/10 // reject history capacity if it seems overly big
#define MIN_CAPNOM_AGING 25/100 // allow no less than 25% of nominal design capacity before rejecting
#define MAX_CAPNOM_AGING 15/10 // reject history capacity if it seems overly big
if ( (save_store.val_FullCAP < (uint16_t)(((uint32_t)designcap)*MIN_CAP_AGING)) ||
(save_store.val_FullCAP > (uint16_t)(((uint32_t)designcap)*MAX_CAP_AGING)) ||
(save_store.val_FullCAPNom < (uint16_t)(((uint32_t)designcap)*MIN_CAPNOM_AGING)) ||
(save_store.val_FullCAPNom > (uint16_t)(((uint32_t)designcap)*MAX_CAPNOM_AGING)) )
{
printf("Resetting battery defaults due to faulty CAPACITY (0x%x, 0x%x)\n",
save_store.val_FullCAP, save_store.val_FullCAPNom);
force_por = 1;
is_history_exist = 0;
}
else
{
DEBUG(" verify if mem loaded: FullcapNom was saved as %04x\n",
save_store.val_FullCAPNom );
}
// In case val_DesignCap in history data does not match battery's design capacity,
// we should throw away the history data.
if(save_store.val_DesignCap != designcap) {
printf("Resetting battery defaults because Design Capactiy(0x%04X)in history data"
" does not match battery's Design Capacity(0x%04X)\n",
save_store.val_DesignCap, designcap);
force_por = 1;
is_history_exist = 0;
}
}
save_store.val_DesignCap = designcap;
i2c_init(100, 0x36); //no need
if ( !is_power_on )
{
// when there is no history file, assume it is a POR
//if ( is_history_exist && max17042_check_init_config() == 0 )
// UPDATE: if history file doesn't exist don't do a POR,
if (!force_por && max17042_check_init_config() == 0 )
{
DEBUG("MAX17042+UBOOT: warm config is okay\n");
return 0;
}
else
{
/* when the config is bad but it's not a POR, then something
* is quite wrong.
*/
DEBUG("MAX17042+UBOOT: warm config bad. soft POR\n");
is_power_on = 1;
max17042_soft_por();
}
}
//1. Delay 500ms
udelay( 500 * 1000 );
MAX17042_DUMPREG( MAX17042_Version );
MAX17042_DUMPREG( MAX17042_DesignCap );
MAX17042_DUMPREG( MAX17042_OCV );
MAX17042_DUMPREG( MAX17042_FSTAT );
MAX17042_DUMPREG( MAX17042_SOCvf );
//2. Init Configuration
max17042_init_config();
//3. Save starting para
max17042_save_start_para();
//4. unlock model access
max17042_unlock_model();
do {
//5. write custom model
max17042_write_model();
//6. read model
//7. verify model
err = max17042_read_verify_model();
} while ( err != 0 && --retries > 0 );
if ( retries == 0 ) {
DEBUG( " writing model failed\n");
return err;
}
retries = 2;
do {
//8. lock model access
max17042_lock_model();
//9. verify model access is locked
err = max17042_verify_lock_model();
} while ( err != 0 && --retries > 0 );
if ( retries == 0 ) {
DEBUG( " locking model failed\n");
return err;
}
//10. write custom parameters
err = max17042_write_custom_para( );
if ( err != 0 ) {
DEBUG("write custom parameters failed\n");
return err;
}
//11 update full capacity parameters
err = max17042_update_cap_para( );
if ( err != 0 ) {
DEBUG("update capacity parameters failed\n");
return err;
}
//13. delay 350ms;
udelay ( 350 *1000 );
//14. write VFSOC to VFSCO0
err = max17042_write_vfsoc();
if ( err != 0 ) {
DEBUG("write vfsoc failed\n");
return err;
}
/* 15.5 Advance to Colomb-Counter Mode
* We do this all the time. In the factory the battery is fresh (close to
* design capacity, and when there is a history file we restore a known good
* capacity after this, so that case it's safe to assume we have a good estimate
* as well.
*/
err = max17042_set_cycles( 0x00A0 );
if ( err != 0 ) {
DEBUG("set cycles 0x00A0 failed\n");
return err;
}
err = max17042_load_cap_para( );
if ( err != 0 ) {
DEBUG("load capacity parameters failed\n");
return err;
}
max17042_clear_POR();
if ( is_history_exist ) {
err = max17042_restore_learned_para();
if ( err != 0 ) {
DEBUG("restore learned parameters failed\n");
return err;
}
}
is_power_on = 0;
DEBUG("Max17042 init is done\n");
return 0;
}
/*get the volage reading*/
int max17042_voltage( uint16_t* val)
{
int err;
/*reading Vcell*/
err = MAX_READ(0x09, (u8*)val);
if ( err != 0 ) {
printf( "read 0x09 Vcell err\n");
return err;
}
else
{
(*val)>>=3;
return 0;
}
}
/*get the volage reading*/
int max17042_vfocv( uint16_t* val)
{
int err;
/*reading Vcell*/
err = MAX_READ(0xFB, (u8*)val);
if ( err != 0 ) {
printf( "read 0xFB open circuit v\n");
return err;
}
else
{
(*val)>>=3;
return 0;
}
}
int max17042_soc( uint16_t* val)
{
int err;
err = MAX_READ(0x06, (u8*)val);
if ( err != 0 ) {
printf( "read 0x06 SOCREP err\n");
return err;
}
(*val) >>= 8; //upper byte is good enough
return 0;
}
//resolution 0.0039-degree, or 3900uC
int max17042_temp( uint32_t* temp)
{
int err;
uint16_t val;
err = MAX_READ(0x08, (u8*)&val);
if ( err != 0 ) {
printf( "read 0x08 reg(temperature) err!\n");
return err;
}
else {
if ( val & (1<<15) ) {
*temp = COMPLEMENT_VAL(val, TEMP_RESOLUTION, 1);
}
else {
*temp = (val & 0x7FFF) * TEMP_RESOLUTION;
}
return err;
}
}
| astarasikov/uboot-bn-nook-hd-fastboot | drivers/max17042.c | C | gpl-2.0 | 30,417 | [
30522,
1013,
1008,
1008,
2604,
1013,
18168,
9331,
21619,
17465,
1035,
10423,
1013,
4098,
16576,
2692,
20958,
1012,
1039,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
9957,
1004,
7015,
1010,
4297,
1012,
1008,
20014,
6657,
6508,
2278,
4007,
2248... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require "rails_helper"
RSpec.describe Admin::Photo, :type => :model do
it "get all photos" do
end
end
| Thadeu/kenya-oliveira-v2 | spec/models/photos_spec.rb | Ruby | mit | 108 | [
30522,
5478,
1000,
15168,
1035,
2393,
2121,
1000,
12667,
5051,
2278,
1012,
6235,
4748,
10020,
1024,
1024,
6302,
1010,
1024,
2828,
1027,
1028,
1024,
2944,
2079,
2009,
1000,
2131,
2035,
7760,
1000,
2079,
2203,
2203,
102,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package edu.rice.habanero.benchmarks.trapezoid;
import edu.rice.habanero.benchmarks.BenchmarkRunner;
import edu.rice.habanero.concurrent.executors.PriorityBlockingQueueTaskExecutor;
import edu.rice.habanero.concurrent.executors.TaskExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author <a href="http://shams.web.rice.edu/">Shams Imam</a> (shams@rice.edu)
*/
public class PriorityBlockingQueueBenchmark extends AbstractBenchmark {
public static void main(final String[] args) {
BenchmarkRunner.runBenchmark(args, new PriorityBlockingQueueBenchmark());
}
@Override
protected TaskExecutor createTaskExecutor() {
final int numThreads = BenchmarkRunner.numThreads();
final int minPriorityInc = BenchmarkRunner.minPriority();
final int maxPriorityInc = BenchmarkRunner.maxPriority();
return new PriorityBlockingQueueTaskExecutor(
numThreads, numThreads, 0L, TimeUnit.MILLISECONDS,
minPriorityInc, maxPriorityInc);
}
}
| shamsmahmood/priorityworkstealing | src/main/java/edu/rice/habanero/benchmarks/trapezoid/PriorityBlockingQueueBenchmark.java | Java | epl-1.0 | 1,019 | [
30522,
7427,
3968,
2226,
1012,
5785,
1012,
5292,
27543,
3217,
1012,
6847,
27373,
1012,
8132,
9351,
9314,
1025,
12324,
3968,
2226,
1012,
5785,
1012,
5292,
27543,
3217,
1012,
6847,
27373,
1012,
6847,
10665,
23195,
1025,
12324,
3968,
2226,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Date: Tue, 10 Dec 1996 21:21:29 GMT
Server: NCSA/1.4.2
Content-type: text/html
Last-modified: Wed, 15 May 1996 23:35:44 GMT
Content-length: 263
<html>
<title>Coffee</title>
<body bgcolor=#FFFFFF text=#000000 >
<h2>Coffee</h2>
Here is a Seattle coffee
<a href="http://www.halcyon.com/zipgun/mothercity/mothercity.html">guide</a>.
<p>
<IMG SRC="absinthe.gif">
<p>
<em>Absinthe</em> by Degas
</body>
</html>
| ML-SWAT/Web2KnowledgeBase | webkb/other/washington/http:^^www.cs.washington.edu^homes^brendan^coffee.html | HTML | mit | 408 | [
30522,
3058,
1024,
10722,
2063,
1010,
2184,
11703,
2727,
2538,
1024,
2538,
1024,
2756,
13938,
2102,
8241,
1024,
13316,
3736,
1013,
1015,
1012,
1018,
1012,
1016,
4180,
1011,
2828,
1024,
3793,
1013,
16129,
2197,
1011,
6310,
1024,
21981,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (c) 2015 Digi International Inc.,
* All rights not expressly granted are reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
* =======================================================================
*/
#include "XBee802.h"
#include "IO/IOSample802.h"
#include "Frames/802_Frames.h"
#include "FrameHandlers/FH_ModemStatus.h"
using namespace XBeeLib;
/* Class constructor */
XBee802::XBee802(PinName tx, PinName rx, PinName reset, PinName rts, PinName cts, int baud) :
XBee(tx, rx, reset, rts, cts, baud),
_nd_handler(NULL), _rx_64b_handler(NULL), _rx_16b_handler(NULL),
_io_data_64b_handler(NULL), _io_data_16b_handler(NULL)
{
}
/* Class destructor */
XBee802::~XBee802()
{
unregister_node_discovery_cb();
unregister_receive_cb();
unregister_io_sample_cb();
}
RadioStatus XBee802::init()
{
RadioStatus retval = XBee::init();
uint16_t addr16;
RadioStatus error = get_network_address(&addr16);
if (error == Success) {
digi_log(LogLevelInfo, "ADDR16: %04x\r\n", addr16);
} else {
digi_log(LogLevelInfo, "ADDR16: UNKNOWN\r\n");
}
const RadioProtocol radioProtocol = get_radio_protocol();
if (radioProtocol != Raw_802_15_4) {
digi_log(LogLevelError, "Radio protocol does not match, needed a %d got a %d\r\n", Raw_802_15_4, radioProtocol);
retval = Failure;
}
assert(radioProtocol == Raw_802_15_4);
return retval;
}
RadioStatus XBee802::set_channel(uint8_t channel)
{
AtCmdFrame::AtCmdResp cmdresp;
if (is_PRO()) {
if (channel < 0x0C || channel > 0x17) {
return Failure;
}
} else {
if (channel < 0x0B || channel > 0x1A) {
return Failure;
}
}
cmdresp = set_param("CH", channel);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
return Success;
}
RadioStatus XBee802::get_channel(uint8_t * const channel)
{
if (channel == NULL) {
return Failure;
}
AtCmdFrame::AtCmdResp cmdresp;
uint32_t var32;
cmdresp = get_param("CH", &var32);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
*channel = var32;
return Success;
}
RadioStatus XBee802::set_panid(uint16_t panid)
{
AtCmdFrame::AtCmdResp cmdresp;
cmdresp = set_param("ID", panid);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
return Success;
}
RadioStatus XBee802::get_panid(uint16_t * const panid)
{
if (panid == NULL) {
return Failure;
}
AtCmdFrame::AtCmdResp cmdresp;
uint32_t var32;
cmdresp = get_param("ID", &var32);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
*panid = var32;
return Success;
}
RadioStatus XBee802::set_network_address(uint16_t addr16)
{
AtCmdFrame::AtCmdResp cmdresp;
cmdresp = set_param("MY", addr16);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
return Success;
}
void XBee802::radio_status_update(AtCmdFrame::ModemStatus modem_status)
{
/* Update the radio status variables */
if (modem_status == AtCmdFrame::HwReset) {
_hw_reset_cnt++;
} else if (modem_status == AtCmdFrame::WdReset) {
_wd_reset_cnt++;
}
_modem_status = modem_status;
digi_log(LogLevelDebug, "\r\nUpdating radio status: %02x\r\n", modem_status);
}
TxStatus XBee802::send_data(const RemoteXBee& remote, const uint8_t *const data, uint16_t len, bool syncr)
{
if (remote.is_valid_addr64b()) {
const uint64_t remote64 = remote.get_addr64();
digi_log(LogLevelDebug, "send_data ADDR64: %08x:%08x\r\n", UINT64_HI32(remote64), UINT64_LO32(remote64));
TxFrame802 frame = TxFrame802(remote64, _tx_options, data, len);
if (syncr) {
return send_data(&frame);
} else {
frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
send_api_frame(&frame);
return TxStatusSuccess;
}
}
if (remote.is_valid_addr16b()) {
const uint16_t remote16 = remote.get_addr16();
digi_log(LogLevelDebug, "send_data ADDR16: %04x\r\n", remote16);
TxFrame802 frame = TxFrame802(remote16, _tx_options, data, len);
if (syncr) {
return send_data(&frame);
} else {
frame.set_data(0, 0); /* Set frame id to 0 so there is no answer */
send_api_frame(&frame);
return TxStatusSuccess;
}
}
return TxStatusInvalidAddr;
}
XBee802::AssocStatus XBee802::get_assoc_status(void)
{
return (AssocStatus)get_AI();
}
RemoteXBee802 XBee802::get_remote_node_by_id(const char * const node_id)
{
uint64_t addr64;
uint16_t addr16;
_get_remote_node_by_id(node_id, &addr64, &addr16);
return RemoteXBee802(addr64, addr16);
}
void XBee802::register_node_discovery_cb(node_discovery_802_cb_t function)
{
if (_nd_handler == NULL) {
_nd_handler = new FH_NodeDiscovery802();
register_frame_handler(_nd_handler);
}
_nd_handler->register_node_discovery_cb(function);
}
void XBee802::unregister_node_discovery_cb()
{
if (_nd_handler != NULL) {
_nd_handler->unregister_node_discovery_cb();
unregister_frame_handler(_nd_handler);
delete _nd_handler;
_nd_handler = NULL; /* as delete does not set to NULL */
}
}
void XBee802::register_receive_cb(receive_802_cb_t function)
{
if (_rx_64b_handler == NULL) {
_rx_64b_handler = new FH_RxPacket64b802();
register_frame_handler(_rx_64b_handler);
}
_rx_64b_handler->register_receive_cb(function);
if (_rx_16b_handler == NULL) {
_rx_16b_handler = new FH_RxPacket16b802();
register_frame_handler(_rx_16b_handler);
}
_rx_16b_handler->register_receive_cb(function);
}
void XBee802::unregister_receive_cb()
{
if (_rx_64b_handler != NULL) {
_rx_64b_handler->unregister_receive_cb();
unregister_frame_handler(_rx_64b_handler);
delete _rx_64b_handler;
_rx_64b_handler = NULL; /* as delete does not set to NULL */
}
if (_rx_16b_handler != NULL) {
_rx_16b_handler->unregister_receive_cb();
unregister_frame_handler(_rx_16b_handler);
delete _rx_16b_handler;
_rx_16b_handler = NULL; /* as delete does not set to NULL */
}
}
void XBee802::register_io_sample_cb(io_data_cb_802_t function)
{
if (_io_data_64b_handler == NULL) {
_io_data_64b_handler = new FH_IoDataSampe64b802();
register_frame_handler(_io_data_64b_handler);
}
_io_data_64b_handler->register_io_data_cb(function);
if (_io_data_16b_handler == NULL) {
_io_data_16b_handler = new FH_IoDataSampe16b802();
register_frame_handler(_io_data_16b_handler);
}
_io_data_16b_handler->register_io_data_cb(function);
}
void XBee802::unregister_io_sample_cb()
{
if (_io_data_64b_handler != NULL) {
_io_data_64b_handler->unregister_io_data_cb();
unregister_frame_handler(_io_data_64b_handler);
delete _io_data_64b_handler;
_io_data_64b_handler = NULL; /* as delete does not set to NULL */
}
if (_io_data_16b_handler != NULL) {
_io_data_16b_handler->unregister_io_data_cb();
unregister_frame_handler(_io_data_16b_handler);
delete _io_data_16b_handler;
_io_data_16b_handler = NULL; /* as delete does not set to NULL */
}
}
AtCmdFrame::AtCmdResp XBee802::get_param(const RemoteXBee& remote, const char * const param, uint32_t * const data)
{
uint16_t len = sizeof *data;
AtCmdFrame::AtCmdResp atCmdResponse;
if (remote.is_valid_addr64b()) {
const uint64_t dev_addr64 = remote.get_addr64();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr64, param);
atCmdResponse = send_at_cmd(&cmd_frame, (uint8_t *)data, &len, RadioRemote);
} else if (remote.is_valid_addr16b()) {
const uint16_t dev_addr16 = remote.get_addr16();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr16, param);
atCmdResponse = send_at_cmd(&cmd_frame, (uint8_t *)data, &len, RadioRemote);
} else {
return AtCmdFrame::AtCmdRespInvalidAddr;
}
if (atCmdResponse == AtCmdFrame::AtCmdRespOk && len > sizeof *data) {
atCmdResponse = AtCmdFrame::AtCmdRespLenMismatch;
}
return atCmdResponse;
}
AtCmdFrame::AtCmdResp XBee802::set_param(const RemoteXBee& remote, const char * const param, uint32_t data)
{
if (remote.is_valid_addr64b()) {
const uint64_t dev_addr64 = remote.get_addr64();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr64, param, data);
return send_at_cmd(&cmd_frame, NULL, NULL, RadioRemote);
}
if (remote.is_valid_addr16b()) {
const uint16_t dev_addr16 = remote.get_addr16();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr16, param, data);
return send_at_cmd(&cmd_frame, NULL, NULL, RadioRemote);
}
return AtCmdFrame::AtCmdRespInvalidAddr;
}
AtCmdFrame::AtCmdResp XBee802::set_param(const RemoteXBee& remote, const char * const param, const uint8_t * data, uint16_t len)
{
if (remote.is_valid_addr64b()) {
const uint64_t dev_addr64 = remote.get_addr64();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr64, param, data, len);
return send_at_cmd(&cmd_frame, NULL, NULL, RadioRemote);
}
if (remote.is_valid_addr16b()) {
const uint16_t dev_addr16 = remote.get_addr16();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr16, param, data, len);
return send_at_cmd(&cmd_frame, NULL, NULL, RadioRemote);
}
return AtCmdFrame::AtCmdRespInvalidAddr;
}
AtCmdFrame::AtCmdResp XBee802::get_param(const RemoteXBee& remote, const char * const param, uint8_t * const data, uint16_t * const len)
{
if (remote.is_valid_addr64b()) {
uint64_t dev_addr64 = remote.get_addr64();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr64, param);
return send_at_cmd(&cmd_frame, data, len, RadioRemote, false);
}
if (remote.is_valid_addr16b()) {
uint16_t dev_addr16 = remote.get_addr16();
AtCmdFrame cmd_frame = AtCmdFrame(dev_addr16, param);
return send_at_cmd(&cmd_frame, data, len, RadioRemote, false);
}
return AtCmdFrame::AtCmdRespInvalidAddr;
}
static void get_dio_cmd(XBee802::IoLine line, char * const iocmd)
{
if (line >= XBee802::PWM0) {
iocmd[0] = 'P';
iocmd[1] = '0' + line - XBee802::PWM0;
} else {
iocmd[0] = 'D';
iocmd[1] = '0' + line;
}
iocmd[2] = '\0';
}
RadioStatus XBee802::set_pin_config(const RemoteXBee& remote, IoLine line, IoMode mode)
{
AtCmdFrame::AtCmdResp cmdresp;
char iocmd[3];
get_dio_cmd(line, iocmd);
cmdresp = set_param(remote, iocmd, (uint8_t)mode);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
digi_log(LogLevelError, "set_pin_config: set_param returned %d\r\n", cmdresp);
return Failure;
}
return Success;
}
RadioStatus XBee802::get_pin_config(const RemoteXBee& remote, IoLine line, IoMode * const mode)
{
AtCmdFrame::AtCmdResp cmdresp;
char iocmd[3];
get_dio_cmd(line, iocmd);
uint32_t var32;
cmdresp = get_param(remote, iocmd, &var32);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
*mode = (IoMode)var32;
return Success;
}
RadioStatus XBee802::set_dio(const RemoteXBee& remote, IoLine line, DioVal val)
{
if (line > DI8) {
digi_log(LogLevelError, "set_dio: Pin %d not supported as IO\r\n", line);
return Failure;
}
if (val == Low) {
return set_pin_config(remote, line, DigitalOutLow);
} else {
return set_pin_config(remote, line, DigitalOutHigh);
}
}
RadioStatus XBee802::get_dio(const RemoteXBee& remote, IoLine line, DioVal * const val)
{
return get_iosample(remote).get_dio(line, val);
}
RadioStatus XBee802::get_adc(const RemoteXBee& remote, IoLine line, uint16_t * const val)
{
return get_iosample(remote).get_adc(line, val);
}
RadioStatus XBee802::set_pwm(const RemoteXBee& remote, IoLine line, float duty_cycle)
{
AtCmdFrame::AtCmdResp cmdresp;
char iocmd[3] = { 'M', '0', '\0' };
if (line != PWM0 && line != PWM1) {
return Failure;
}
if (line == PWM1) {
iocmd[1] = '1';
}
uint16_t pwm_val = (uint16_t)(duty_cycle * DR_PWM_MAX_VAL / 100);
cmdresp = set_param(remote, iocmd, pwm_val);
return cmdresp == AtCmdFrame::AtCmdRespOk ? Success : Failure;
}
IOSample802 XBee802::get_iosample(const RemoteXBee& remote)
{
uint8_t io_sample[MAX_IO_SAMPLE_802_LEN];
uint16_t len = sizeof io_sample;
RadioStatus resp = _get_iosample(remote, io_sample, &len);
if (resp != Success) {
digi_log(LogLevelError, "XBee802::get_iosample failed to get an IOSample\r\n");
len = 0;
}
return IOSample802(io_sample, len);
}
static uint8_t get_dio_mask(XBee802::IoLine line)
{
switch (line) {
case XBee802::DIO4_AD4:
return (1 << 0);
case XBee802::DIO3_AD3:
return (1 << 1);
case XBee802::DIO2_AD2:
return (1 << 2);
case XBee802::DIO1_AD1:
return (1 << 3);
case XBee802::DIO0_AD0:
return (1 << 4);
case XBee802::DIO6:
return (1 << 5);
case XBee802::DI8:
return (1 << 6);
default:
return 0;
}
}
RadioStatus XBee802::set_pin_pull_up(const RemoteXBee& remote, IoLine line, bool enable)
{
AtCmdFrame::AtCmdResp cmdresp;
uint32_t var32;
uint8_t pr;
cmdresp = get_param(remote, "PR", &var32);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
pr = var32;
const uint8_t dio_mask = get_dio_mask(line);
if (dio_mask == 0) {
digi_log(LogLevelError, "XBee802::set_pin_pull_up: invalid pin %d\r\n", line);
return Failure;
}
if (enable) {
pr |= dio_mask;
} else {
pr &= ~dio_mask;
}
cmdresp = set_param(remote, "PR", pr);
return cmdresp == AtCmdFrame::AtCmdRespOk ? Success : Failure;
}
static uint8_t get_dio_ic_mask(XBee802::IoLine line)
{
if (line < XBee802::DI8) {
return (1 << line);
}
return 0;
}
RadioStatus XBee802::enable_dio_change_detection(const RemoteXBee& remote, IoLine line, bool enable)
{
if (line > DIO7) {
digi_log(LogLevelError, "XBee802::enable_dio_change_detection: pin not supported (%d)\r\n", line);
return Failure;
}
AtCmdFrame::AtCmdResp cmdresp;
uint32_t var32;
uint8_t ic;
cmdresp = get_param(remote, "IC", &var32);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
ic = var32;
const uint8_t dio_mask = get_dio_ic_mask(line);
if (dio_mask == 0) {
digi_log(LogLevelError, "XBeeZB::enable_dio_change_detection: invalid pin %d\r\n", line);
return Failure;
}
if (enable) {
ic |= dio_mask;
} else {
ic &= ~dio_mask;
}
cmdresp = set_param(remote, "IC", ic);
return cmdresp == AtCmdFrame::AtCmdRespOk ? Success : Failure;
}
#ifdef GET_PWM_AVAILABLE
RadioStatus XBee802::get_pwm(const RemoteXBee& remote, IoLine line, float * const duty_cycle)
{
AtCmdFrame::AtCmdResp cmdresp;
char iocmd[3] = { 'M', '0', '\0' };
if (line != PWM0 && line != PWM1) {
return Failure;
}
if (line == PWM1) {
iocmd[1] = '1';
}
uint16_t pwm_val;
cmdresp = get_param(remote, iocmd, &pwm_val);
if (cmdresp != AtCmdFrame::AtCmdRespOk) {
return Failure;
}
*duty_cycle = (float)(pwm_val * 100 / DR_PWM_MAX_VAL);
return Success;
}
#endif
| jon-whit/AtlasQuad | src/XBeeLib/XBee802/XBee802.cpp | C++ | gpl-2.0 | 16,579 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2325,
10667,
2072,
2248,
4297,
1012,
1010,
1008,
2035,
2916,
2025,
4671,
2135,
4379,
2024,
9235,
1012,
1008,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cert file in this directory
| causefx/Organizr | plugins/theme_files/index.html | HTML | gpl-3.0 | 28 | [
30522,
8292,
5339,
5371,
1999,
2023,
14176,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "catch.hpp"
#include "JumpGame.hpp"
TEST_CASE("Jump Game") {
JumpGame s;
SECTION("Sample tests") {
vector<int> nums_1{2, 3, 1, 1, 4};
REQUIRE(s.canJump(nums_1));
vector<int> nums_2{3, 2, 1, 0, 4};
REQUIRE_FALSE(s.canJump(nums_2));
}
}
| yanzhe-chen/leetcode | tests/JumpGameTest.cpp | C++ | mit | 290 | [
30522,
1001,
2421,
1000,
4608,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
5376,
16650,
1012,
6522,
2361,
1000,
3231,
1035,
2553,
1006,
1000,
5376,
2208,
1000,
1007,
1063,
5376,
16650,
1055,
1025,
2930,
1006,
1000,
7099,
5852,
1000,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// $Id: SV_Semaphore_Simple.cpp 91287 2010-08-05 10:30:49Z johnnyw $
#include "ace/SV_Semaphore_Simple.h"
#include "ace/Log_Msg.h"
#include "ace/ACE.h"
#include "ace/os_include/sys/os_sem.h"
#if !defined (__ACE_INLINE__)
#include "ace/SV_Semaphore_Simple.inl"
#endif /* !__ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE (ACE_SV_Semaphore_Simple)
void
ACE_SV_Semaphore_Simple::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_SV_Semaphore_Simple::dump");
#endif /* ACE_HAS_DUMP */
}
int
ACE_SV_Semaphore_Simple::control (int cmd,
int value,
u_short semnum) const
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::control");
if (this->internal_id_ == -1)
return -1;
else
{
semun semctl_arg;
semctl_arg.val = value;
return ACE_OS::semctl (this->internal_id_,
semnum,
cmd,
semctl_arg);
}
}
int
ACE_SV_Semaphore_Simple::init (key_t k, int i)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::init");
this->key_ = k;
this->internal_id_ = i;
return 0;
}
// General ACE_SV_Semaphore operation. Increment or decrement by a
// specific amount (positive or negative; amount can`t be zero).
int
ACE_SV_Semaphore_Simple::op (short val, u_short n, short flags) const
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::op");
sembuf op_op;
op_op.sem_num = n;
op_op.sem_flg = flags;
if (this->internal_id_ == -1)
return -1;
else if ((op_op.sem_op = val) == 0)
return -1;
else
return ACE_OS::semop (this->internal_id_, &op_op, 1);
}
// Open or create one or more SV_Semaphores. We return 0 if all is
// OK, else -1.
int
ACE_SV_Semaphore_Simple::open (key_t k,
short flags,
int initial_value,
u_short n,
mode_t perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
union semun ivalue;
if (k == IPC_PRIVATE || k == static_cast<key_t> (ACE_INVALID_SEM_KEY))
return -1;
ivalue.val = initial_value;
this->key_ = k;
this->sem_number_ = n;
this->internal_id_ = ACE_OS::semget (this->key_, n, perms | flags);
if (this->internal_id_ == -1)
return -1;
if (ACE_BIT_ENABLED (flags, IPC_CREAT))
for (int i = 0; i < n; i++)
if (ACE_OS::semctl (this->internal_id_, i, SETVAL, ivalue) == -1)
return -1;
return 0;
}
ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (key_t k,
short flags,
int initial_value,
u_short n,
mode_t perms)
: key_ (k)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
if (this->open (k, flags, initial_value, n, perms) == -1)
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore::ACE_SV_Semaphore")));
}
// Convert name to key. This function is used internally to create keys
// for the semaphores.
//
// The method for generating names is a 32 bit CRC, but still we
// measured close to collition ratio of nearly 0.1% for
// ACE::unique_name()-like strings.
key_t
ACE_SV_Semaphore_Simple::name_2_key (const char *name)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::name_2_key");
if (name == 0)
{
errno = EINVAL;
return static_cast<key_t> (ACE_INVALID_SEM_KEY);
}
// Basically "hash" the values in the <name>. This won't
// necessarily guarantee uniqueness of all keys.
// But (IMHO) CRC32 is good enough for most purposes (Carlos)
#if defined (ACE_WIN32) && defined (_MSC_VER)
// The cast below is legit...
# pragma warning(push)
# pragma warning(disable : 4312)
#endif /* defined (ACE_WIN32) && defined (_MSC_VER) */
return (key_t) ACE::crc32 (name);
#if defined (ACE_WIN32) && defined (_MSC_VER)
# pragma warning(pop)
#endif /* defined (ACE_WIN32) && defined (_MSC_VER) */
}
// Open or create a ACE_SV_Semaphore. We return 1 if all is OK, else
// 0.
int
ACE_SV_Semaphore_Simple::open (const char *name,
short flags,
int initial_value,
u_short n,
mode_t perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
key_t key;
if (name == 0)
key = ACE_DEFAULT_SEM_KEY;
else
key = this->name_2_key (name);
return this->open (key, flags, initial_value, n, perms);
}
ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const char *name,
short flags,
int initial_value,
u_short n,
mode_t perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
if (this->open (name,
flags,
initial_value,
n,
perms) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple")));
}
#if defined (ACE_HAS_WCHAR)
ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const wchar_t *name,
short flags,
int initial_value,
u_short nsems,
mode_t perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple(wchar_t)");
if (this->open (ACE_Wide_To_Ascii (name).char_rep (),
flags,
initial_value,
nsems,
perms) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple")));
}
#endif /* ACE_HAS_WCHAR */
ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple (void)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple");
this->close ();
}
ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (void)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
this->init ();
}
// Remove all SV_Semaphores associated with a particular key. This
// call is intended to be called from a server, for example, when it
// is being shut down, as we do an IPC_RMID on the ACE_SV_Semaphore,
// regardless of whether other processes may be using it or not. Most
// other processes should use close() below.
int
ACE_SV_Semaphore_Simple::remove (void) const
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::remove");
int const result = this->control (IPC_RMID);
((ACE_SV_Semaphore_Simple *) this)->init ();
return result;
}
ACE_END_VERSIONED_NAMESPACE_DECL | hlarsen/TBCPvP | dep/acelite/ace/SV_Semaphore_Simple.cpp | C++ | gpl-2.0 | 7,149 | [
30522,
1013,
1013,
1002,
8909,
1024,
17917,
1035,
7367,
2863,
8458,
5686,
1035,
3722,
1012,
18133,
2361,
6205,
22407,
2581,
2230,
1011,
5511,
1011,
5709,
2184,
1024,
2382,
1024,
4749,
2480,
5206,
2860,
1002,
1001,
2421,
1000,
9078,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
* This file is part of the HWIOAuthBundle package.
*
* (c) Hardware.Info <opensource@hardware.info>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace HWI\Bundle\OAuthBundle\OAuth\ResourceOwner;
use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* OdnoklassnikiResourceOwner.
*
* @author Sergey Polischook <spolischook@gmail.com>
*/
class OdnoklassnikiResourceOwner extends GenericOAuth2ResourceOwner
{
/**
* {@inheritdoc}
*/
protected $paths = array(
'identifier' => 'uid',
'nickname' => 'username',
'realname' => 'name',
'email' => 'email',
'firstname' => 'first_name',
'lastname' => 'last_name',
);
/**
* {@inheritdoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$parameters = array(
'access_token' => $accessToken['access_token'],
'application_key' => $this->options['application_key'],
);
if ($this->options['fields']) {
$parameters['fields'] = $this->options['fields'];
$parameters['sig'] = md5(sprintf(
'application_key=%sfields=%smethod=users.getCurrentUser%s',
$this->options['application_key'],
$this->options['fields'],
md5($accessToken['access_token'].$this->options['client_secret'])
));
} else {
$parameters['sig'] = md5(sprintf(
'application_key=%smethod=users.getCurrentUser%s',
$this->options['application_key'],
md5($accessToken['access_token'].$this->options['client_secret'])
));
}
$url = $this->normalizeUrl($this->options['infos_url'], $parameters);
$content = $this->doGetUserInformationRequest($url)->getContent();
$response = $this->getUserResponse();
$response->setResponse($content);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
return $response;
}
/**
* {@inheritdoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array(
'authorization_url' => 'https://connect.ok.ru/oauth/authorize',
'access_token_url' => 'https://api.ok.ru/oauth/token.do',
'infos_url' => 'https://api.ok.ru/fb.do?method=users.getCurrentUser',
'application_key' => null,
'fields' => null,
));
$fieldsNormalizer = function (Options $options, $value) {
if (!$value) {
return null;
}
return is_array($value) ? implode(',', $value) : $value;
};
// Symfony <2.6 BC
if (method_exists($resolver, 'setNormalizer')) {
$resolver->setNormalizer('fields', $fieldsNormalizer);
} else {
$resolver->setNormalizers(array(
'fields' => $fieldsNormalizer,
));
}
}
}
| Tiriel/Quantified | vendor/hwi/oauth-bundle/OAuth/ResourceOwner/OdnoklassnikiResourceOwner.php | PHP | mit | 3,326 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
1044,
9148,
10441,
14317,
27265,
2571,
7427,
1012,
1008,
1008,
1006,
1039,
1007,
8051,
1012,
18558,
1026,
7480,
8162,
3401,
1030,
8051,
1012,
18558,
1028,
1008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Apache-Virtual-Hosts-Creator
A simple bash script that can automate the process of **creating a virtual host** onto your Linux distribution. Note that I have tested this only on **Debian Jessie** and I hope it will work fine on your configuration as well. You can rise an issue or contribute if you experience any trouble!
If you don't know why you want to create a virtual host, you can refer to [the official documentation of Apache](https://httpd.apache.org/docs/current/vhosts/). Basicaly, you'll need it to set up multi-domain on your server, and I think it really is a good practice.
## Manual
### Requirements
* A debian-like system (Ubuntu is fine).
* The [`sudo`](https://wiki.debian.org/sudo) package installed
* I recommend that you install first the PHP and MySQL version you want.
* An **access to a sudo user shell**.
* If you going with the automatic installation, the `sha1sum` and `wget` packages installed (which is default on Debian Jessie).
### How does it work?
The script creates a new user for each virtual host you create. It let you the possibility to have several teams working on each website you host. The DocumentRoot is put in `/home/VH_USERNAME/www/`. A user can customize its own Apache conf file with the link in its home directory, and have access to its Apache log (access and error).
It will create two scripts in the `/root/` folder - one to create, one to delete the virtual host.
You can customize :
* The configuration files directory, *default is `/etc/apache2/sites-available/` (which is Apache default)*
* The log files directory, *default is `/var/log/web/`*
* All the variable in the begining of the bash script
### Installation
If you are OK with the default value (and if you trust me ;) ), just run the following command to download and execute the setup script from a *sudo user* (an not **root**) CLI :
```shell
wget -O- https://raw.githubusercontent.com/aduh95/Apache-Virtual-Hosts-Creator/master/download.sh | sh
```
> If you want to install it as **root user** (which is not recommended), you have to download the setup file as described bellow and execute it with the following instruction: `./setup.sh root /root/ noDirectRootExecution`<
> If you prefere a manual install, just put the setup file on your server (using *git*, *scp*, *wget* or just *copy/paste it on a text editor*), modify the lines you don't like, and then run `chmod +x setup.sh && ./setup.sh`
To be sure it has been correctly installed, you can use the following commands :
```shell
source ~/.bashrc
alias
```
You should see something like :
```text
alias ls='ls --color=auto'
alias newApacheVH='sudo /root/createVirtualHost.sh'
alias delApacheVH='sudo /root/deleteVirtualHost.sh'
```
Now, you can run those aliases (`newApacheVH` and `delApacheVH`) to create or delete a virtual host.
```shell
newApacheVH
```
It will ask you some questions, then you should be started!
### What if I want to delete it?
I don't see why you would need such a thing (since my code is obviously perfect in any situation), but here are the steps to follow :
```shell
sudo rm /root/createApacheVirtualHost.sh
sudo rm /root/deleteApacheVirtualHost.sh
nano ~/.bash_aliases
```
And then delete the lines defining the two aliases for the Apache VH creator.
| aduh95/Apache-Virtual-Hosts-Creator | README.md | Markdown | mit | 3,292 | [
30522,
1001,
15895,
1011,
7484,
1011,
6184,
1011,
8543,
1037,
3722,
24234,
5896,
2008,
2064,
8285,
8585,
1996,
2832,
1997,
1008,
1008,
4526,
1037,
7484,
3677,
1008,
1008,
3031,
2115,
11603,
4353,
1012,
3602,
2008,
1045,
2031,
7718,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
This file is part of GNUnet.
(C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet 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 GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file statistics/test_statistics_api_watch.c
* @brief testcase for statistics_api.c watch functions
* @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_common.h"
#include "gnunet_getopt_lib.h"
#include "gnunet_os_lib.h"
#include "gnunet_program_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_statistics_service.h"
static int ok;
static struct GNUNET_STATISTICS_Handle *h;
static struct GNUNET_STATISTICS_Handle *h2;
static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
static void
force_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
fprintf (stderr, "Timeout, failed to receive notifications: %d\n", ok);
GNUNET_STATISTICS_destroy (h, GNUNET_NO);
GNUNET_STATISTICS_destroy (h2, GNUNET_NO);
ok = 7;
}
static void
normal_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_STATISTICS_destroy (h, GNUNET_NO);
GNUNET_STATISTICS_destroy (h2, GNUNET_NO);
}
static int
watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value,
int is_persistent)
{
GNUNET_assert (value == 42);
GNUNET_assert (0 == strcmp (name, "test-1"));
ok &= ~1;
if (0 == ok)
{
GNUNET_SCHEDULER_cancel (shutdown_task);
GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL);
}
return GNUNET_OK;
}
static int
watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value,
int is_persistent)
{
GNUNET_assert (value == 43);
GNUNET_assert (0 == strcmp (name, "test-2"));
ok &= ~2;
if (0 == ok)
{
GNUNET_SCHEDULER_cancel (shutdown_task);
GNUNET_SCHEDULER_add_now (&normal_shutdown, NULL);
}
return GNUNET_OK;
}
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
h = GNUNET_STATISTICS_create ("dummy", cfg);
GNUNET_assert (GNUNET_OK ==
GNUNET_STATISTICS_watch (h, "test-statistics-api-watch",
"test-1", &watch_1, NULL));
GNUNET_assert (GNUNET_OK ==
GNUNET_STATISTICS_watch (h, "test-statistics-api-watch",
"test-2", &watch_2, NULL));
h2 = GNUNET_STATISTICS_create ("test-statistics-api-watch", cfg);
GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO);
GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO);
shutdown_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown,
NULL);
}
int
main (int argc, char *argv_ign[])
{
char *const argv[] = { "test-statistics-api",
"-c",
"test_statistics_api_data.conf",
NULL
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_OS_Process *proc;
char *binary;
binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics");
proc =
GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL,
binary,
"gnunet-service-statistics",
"-c", "test_statistics_api_data.conf", NULL);
GNUNET_assert (NULL != proc);
ok = 3;
GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run,
NULL);
if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
GNUNET_OS_process_wait (proc);
GNUNET_OS_process_destroy (proc);
proc = NULL;
GNUNET_free (binary);
return ok;
}
/* end of test_statistics_api_watch.c */
| schanzen/gnunet-mirror | src/statistics/test_statistics_api_watch.c | C | gpl-3.0 | 4,381 | [
30522,
1013,
1008,
2023,
5371,
2003,
2112,
1997,
27004,
7159,
1012,
1006,
1039,
1007,
2268,
1010,
2249,
1010,
2262,
3017,
24665,
29288,
4246,
1006,
1998,
2060,
8020,
6048,
1007,
27004,
7159,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Implements rotations, including spherical rotations as defined in WCS Paper II
[1]_
`RotateNative2Celestial` and `RotateCelestial2Native` follow the convention in
WCS Paper II to rotate to/from a native sphere and the celestial sphere.
The implementation uses `EulerAngleRotation`. The model parameters are
three angles: the longitude (``lon``) and latitude (``lat``) of the fiducial point
in the celestial system (``CRVAL`` keywords in FITS), and the longitude of the celestial
pole in the native system (``lon_pole``). The Euler angles are ``lon+90``, ``90-lat``
and ``-(lon_pole-90)``.
References
----------
.. [1] Calabretta, M.R., Greisen, E.W., 2002, A&A, 395, 1077 (Paper II)
"""
import math
import numpy as np
from .core import Model
from .parameters import Parameter
from astropy.coordinates.matrix_utilities import rotation_matrix, matrix_product
from astropy import units as u
from .utils import _to_radian, _to_orig_unit
__all__ = ['RotateCelestial2Native', 'RotateNative2Celestial', 'Rotation2D',
'EulerAngleRotation', 'RotationSequence3D', 'SphericalRotationSequence']
def _create_matrix(angles, axes_order):
matrices = []
for angle, axis in zip(angles, axes_order):
if isinstance(angle, u.Quantity):
angle = angle.value
angle = angle.item()
matrices.append(rotation_matrix(angle, axis, unit=u.rad))
result = matrix_product(*matrices[::-1])
return result
def spherical2cartesian(alpha, delta):
alpha = np.deg2rad(alpha)
delta = np.deg2rad(delta)
x = np.cos(alpha) * np.cos(delta)
y = np.cos(delta) * np.sin(alpha)
z = np.sin(delta)
return np.array([x, y, z])
def cartesian2spherical(x, y, z):
h = np.hypot(x, y)
alpha = np.rad2deg(np.arctan2(y, x))
delta = np.rad2deg(np.arctan2(z, h))
return alpha, delta
class RotationSequence3D(Model):
"""
Perform a series of rotations about different axis in 3D space.
Positive angles represent a counter-clockwise rotation.
Parameters
----------
angles : array-like
Angles of rotation in deg in the order of axes_order.
axes_order : str
A sequence of 'x', 'y', 'z' corresponding to axis of rotation.
Examples
--------
>>> model = RotationSequence3D([1.1, 2.1, 3.1, 4.1], axes_order='xyzx')
"""
standard_broadcasting = False
_separable = False
n_inputs = 3
n_outputs = 3
angles = Parameter(default=[], getter=_to_orig_unit, setter=_to_radian)
def __init__(self, angles, axes_order, name=None):
self.axes = ['x', 'y', 'z']
unrecognized = set(axes_order).difference(self.axes)
if unrecognized:
raise ValueError("Unrecognized axis label {0}; "
"should be one of {1} ".format(unrecognized,
self.axes))
self.axes_order = axes_order
if len(angles) != len(axes_order):
raise ValueError("The number of angles {0} should match the number \
of axes {1}.".format(len(angles),
len(axes_order)))
super().__init__(angles, name=name)
self._inputs = ('x', 'y', 'z')
self._outputs = ('x', 'y', 'z')
@property
def inverse(self):
"""Inverse rotation."""
angles = self.angles.value[::-1] * -1
return self.__class__(angles, axes_order=self.axes_order[::-1])
def evaluate(self, x, y, z, angles):
"""
Apply the rotation to a set of 3D Cartesian coordinates.
"""
if x.shape != y.shape != z.shape:
raise ValueError("Expected input arrays to have the same shape")
# Note: If the original shape was () (an array scalar) convert to a
# 1-element 1-D array on output for consistency with most other models
orig_shape = x.shape or (1,)
inarr = np.array([x.flatten(), y.flatten(), z.flatten()])
result = np.dot(_create_matrix(angles[0], self.axes_order), inarr)
x, y, z = result[0], result[1], result[2]
x.shape = y.shape = z.shape = orig_shape
return x, y, z
class SphericalRotationSequence(RotationSequence3D):
"""
Perform a sequence of rotations about arbitrary number of axes
in spherical coordinates.
Parameters
----------
angles : list
A sequence of angles (in deg).
axes_order : str
A sequence of characters ('x', 'y', or 'z') corresponding to the
axis of rotation and matching the order in ``angles``.
"""
def __init__(self, angles, axes_order, name=None, **kwargs):
self._n_inputs = 2
self._n_outputs = 2
super().__init__(angles, axes_order=axes_order, name=name, **kwargs)
self._inputs = ("lon", "lat")
self._outputs = ("lon", "lat")
@property
def n_inputs(self):
return self._n_inputs
@property
def n_outputs(self):
return self._n_outputs
def evaluate(self, lon, lat, angles):
x, y, z = spherical2cartesian(lon, lat)
x1, y1, z1 = super().evaluate(x, y, z, angles)
lon, lat = cartesian2spherical(x1, y1, z1)
return lon, lat
class _EulerRotation:
"""
Base class which does the actual computation.
"""
_separable = False
def evaluate(self, alpha, delta, phi, theta, psi, axes_order):
shape = None
if isinstance(alpha, np.ndarray) and alpha.ndim == 2:
alpha = alpha.flatten()
delta = delta.flatten()
shape = alpha.shape
inp = spherical2cartesian(alpha, delta)
matrix = _create_matrix([phi, theta, psi], axes_order)
result = np.dot(matrix, inp)
a, b = cartesian2spherical(*result)
if shape is not None:
a.shape = shape
b.shape = shape
return a, b
_input_units_strict = True
_input_units_allow_dimensionless = True
@property
def input_units(self):
""" Input units. """
return {'alpha': u.deg, 'delta': u.deg}
@property
def return_units(self):
""" Output units. """
return {'alpha': u.deg, 'delta': u.deg}
class EulerAngleRotation(_EulerRotation, Model):
"""
Implements Euler angle intrinsic rotations.
Rotates one coordinate system into another (fixed) coordinate system.
All coordinate systems are right-handed. The sign of the angles is
determined by the right-hand rule..
Parameters
----------
phi, theta, psi : float or `~astropy.units.Quantity`
"proper" Euler angles in deg.
If floats, they should be in deg.
axes_order : str
A 3 character string, a combination of 'x', 'y' and 'z',
where each character denotes an axis in 3D space.
"""
n_inputs = 2
n_outputs = 2
phi = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
theta = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
psi = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
def __init__(self, phi, theta, psi, axes_order, **kwargs):
self.axes = ['x', 'y', 'z']
if len(axes_order) != 3:
raise TypeError(
"Expected axes_order to be a character sequence of length 3,"
"got {}".format(axes_order))
unrecognized = set(axes_order).difference(self.axes)
if unrecognized:
raise ValueError("Unrecognized axis label {}; "
"should be one of {} ".format(unrecognized, self.axes))
self.axes_order = axes_order
qs = [isinstance(par, u.Quantity) for par in [phi, theta, psi]]
if any(qs) and not all(qs):
raise TypeError("All parameters should be of the same type - float or Quantity.")
super().__init__(phi=phi, theta=theta, psi=psi, **kwargs)
self._inputs = ('alpha', 'delta')
self._outputs = ('alpha', 'delta')
def inverse(self):
return self.__class__(phi=-self.psi,
theta=-self.theta,
psi=-self.phi,
axes_order=self.axes_order[::-1])
def evaluate(self, alpha, delta, phi, theta, psi):
a, b = super().evaluate(alpha, delta, phi, theta, psi, self.axes_order)
return a, b
class _SkyRotation(_EulerRotation, Model):
"""
Base class for RotateNative2Celestial and RotateCelestial2Native.
"""
lon = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
lat = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
lon_pole = Parameter(default=0, getter=_to_orig_unit, setter=_to_radian)
def __init__(self, lon, lat, lon_pole, **kwargs):
qs = [isinstance(par, u.Quantity) for par in [lon, lat, lon_pole]]
if any(qs) and not all(qs):
raise TypeError("All parameters should be of the same type - float or Quantity.")
super().__init__(lon, lat, lon_pole, **kwargs)
self.axes_order = 'zxz'
def _evaluate(self, phi, theta, lon, lat, lon_pole):
alpha, delta = super().evaluate(phi, theta, lon, lat, lon_pole,
self.axes_order)
mask = alpha < 0
if isinstance(mask, np.ndarray):
alpha[mask] += 360
else:
alpha += 360
return alpha, delta
class RotateNative2Celestial(_SkyRotation):
"""
Transform from Native to Celestial Spherical Coordinates.
Parameters
----------
lon : float or or `~astropy.units.Quantity`
Celestial longitude of the fiducial point.
lat : float or or `~astropy.units.Quantity`
Celestial latitude of the fiducial point.
lon_pole : float or or `~astropy.units.Quantity`
Longitude of the celestial pole in the native system.
Notes
-----
If ``lon``, ``lat`` and ``lon_pole`` are numerical values they
should be in units of deg. Inputs are angles on the native sphere.
Outputs are angles on the celestial sphere.
"""
n_inputs = 2
n_outputs = 2
@property
def input_units(self):
""" Input units. """
return {'phi_N': u.deg, 'theta_N': u.deg}
@property
def return_units(self):
""" Output units. """
return {'alpha_C': u.deg, 'delta_C': u.deg}
def __init__(self, lon, lat, lon_pole, **kwargs):
super().__init__(lon, lat, lon_pole, **kwargs)
self.inputs = ('phi_N', 'theta_N')
self.outputs = ('alpha_C', 'delta_C')
def evaluate(self, phi_N, theta_N, lon, lat, lon_pole):
"""
Parameters
----------
phi_N, theta_N : float (deg) or `~astropy.units.Quantity`
Angles in the Native coordinate system.
lon, lat, lon_pole : float (in deg) or `~astropy.units.Quantity`
Parameter values when the model was initialized.
Returns
-------
alpha_C, delta_C : float (deg) or `~astropy.units.Quantity`
Angles on the Celestial sphere.
"""
# The values are in radians since they have already been through the setter.
if isinstance(lon, u.Quantity):
lon = lon.value
lat = lat.value
lon_pole = lon_pole.value
# Convert to Euler angles
phi = lon_pole - np.pi / 2
theta = - (np.pi / 2 - lat)
psi = -(np.pi / 2 + lon)
alpha_C, delta_C = super()._evaluate(phi_N, theta_N, phi, theta, psi)
return alpha_C, delta_C
@property
def inverse(self):
# convert to angles on the celestial sphere
return RotateCelestial2Native(self.lon, self.lat, self.lon_pole)
class RotateCelestial2Native(_SkyRotation):
"""
Transform from Celestial to Native Spherical Coordinates.
Parameters
----------
lon : float or or `~astropy.units.Quantity`
Celestial longitude of the fiducial point.
lat : float or or `~astropy.units.Quantity`
Celestial latitude of the fiducial point.
lon_pole : float or or `~astropy.units.Quantity`
Longitude of the celestial pole in the native system.
Notes
-----
If ``lon``, ``lat`` and ``lon_pole`` are numerical values they should be
in units of deg. Inputs are angles on the celestial sphere.
Outputs are angles on the native sphere.
"""
n_inputs = 2
n_outputs = 2
@property
def input_units(self):
""" Input units. """
return {'alpha_C': u.deg, 'delta_C': u.deg}
@property
def return_units(self):
""" Output units. """
return {'phi_N': u.deg, 'theta_N': u.deg}
def __init__(self, lon, lat, lon_pole, **kwargs):
super().__init__(lon, lat, lon_pole, **kwargs)
# Inputs are angles on the celestial sphere
self.inputs = ('alpha_C', 'delta_C')
# Outputs are angles on the native sphere
self.outputs = ('phi_N', 'theta_N')
def evaluate(self, alpha_C, delta_C, lon, lat, lon_pole):
"""
Parameters
----------
alpha_C, delta_C : float (deg) or `~astropy.units.Quantity`
Angles in the Celestial coordinate frame.
lon, lat, lon_pole : float (deg) or `~astropy.units.Quantity`
Parameter values when the model was initialized.
Returns
-------
phi_N, theta_N : float (deg) or `~astropy.units.Quantity`
Angles on the Native sphere.
"""
if isinstance(lon, u.Quantity):
lon = lon.value
lat = lat.value
lon_pole = lon_pole.value
# Convert to Euler angles
phi = (np.pi / 2 + lon)
theta = (np.pi / 2 - lat)
psi = -(lon_pole - np.pi / 2)
phi_N, theta_N = super()._evaluate(alpha_C, delta_C, phi, theta, psi)
return phi_N, theta_N
@property
def inverse(self):
return RotateNative2Celestial(self.lon, self.lat, self.lon_pole)
class Rotation2D(Model):
"""
Perform a 2D rotation given an angle.
Positive angles represent a counter-clockwise rotation and vice-versa.
Parameters
----------
angle : float or `~astropy.units.Quantity`
Angle of rotation (if float it should be in deg).
"""
n_inputs = 2
n_outputs = 2
_separable = False
angle = Parameter(default=0.0, getter=_to_orig_unit, setter=_to_radian)
def __init__(self, angle=angle, **kwargs):
super().__init__(angle=angle, **kwargs)
self._inputs = ("x", "y")
self._outputs = ("x", "y")
@property
def inverse(self):
"""Inverse rotation."""
return self.__class__(angle=-self.angle)
@classmethod
def evaluate(cls, x, y, angle):
"""
Rotate (x, y) about ``angle``.
Parameters
----------
x, y : ndarray-like
Input quantities
angle : float (deg) or `~astropy.units.Quantity`
Angle of rotations.
"""
if x.shape != y.shape:
raise ValueError("Expected input arrays to have the same shape")
# If one argument has units, enforce they both have units and they are compatible.
x_unit = getattr(x, 'unit', None)
y_unit = getattr(y, 'unit', None)
has_units = x_unit is not None and y_unit is not None
if x_unit != y_unit:
if has_units and y_unit.is_equivalent(x_unit):
y = y.to(x_unit)
y_unit = x_unit
else:
raise u.UnitsError("x and y must have compatible units")
# Note: If the original shape was () (an array scalar) convert to a
# 1-element 1-D array on output for consistency with most other models
orig_shape = x.shape or (1,)
inarr = np.array([x.flatten(), y.flatten()])
if isinstance(angle, u.Quantity):
angle = angle.to_value(u.rad)
result = np.dot(cls._compute_matrix(angle), inarr)
x, y = result[0], result[1]
x.shape = y.shape = orig_shape
if has_units:
return u.Quantity(x, unit=x_unit), u.Quantity(y, unit=y_unit)
else:
return x, y
@staticmethod
def _compute_matrix(angle):
return np.array([[math.cos(angle), -math.sin(angle)],
[math.sin(angle), math.cos(angle)]],
dtype=np.float64)
| MSeifert04/astropy | astropy/modeling/rotations.py | Python | bsd-3-clause | 16,505 | [
30522,
1001,
7000,
2104,
1037,
1017,
1011,
11075,
18667,
2094,
2806,
6105,
1011,
2156,
6105,
1012,
12667,
2102,
1000,
1000,
1000,
22164,
9963,
2015,
1010,
2164,
18970,
9963,
2015,
2004,
4225,
1999,
15868,
2015,
3259,
2462,
1031,
1015,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef __EXTENDED_KEYS_H__
#define __EXTENDED_KEYS_H__
enum {
PSX_FREEZE_KEY = 0xFFBE/*XK_F1*/,
PSX_NEXT_FREEZE_SLOT_KEY = 0xFFBF/*XK_F2*/,
PSX_DEFROST_KEY = 0xFFC0/*XK_F3*/,
PSX_SHOW_FREEZE_PIC_KEY = 0xFFC1/*XK_F4*/,
PSX_SIO_ALWAYS_ON_KEY = 0xFFC2/*XK_F5*/,
PSX_BW_MDEC_KEY = 0xFFC3/*XK_F6*/,
PSX_XA_AUDIO_ON_KEY = 0xFFC4/*XK_F7*/,
PSX_SNAPSHOT_KEY = 0xFFC5/*XK_F8*/,
PSX_OPEN_SHELL_KEY = 0xFFC6/*XK_F9*/,
PSX_CLOSE_SHELL_KEY = 0xFFC7/*XK_F10*/,
PSX_STOP_KEY = 0xFF1B/*XK_Escape*/,
GPU_FULLSCREEN_KEY = 0x0100,
GPU_FPS_DISPLAY_KEY = 0xFFFF,/*XK_Delete*/
// Fake HotKeys
GPU_HOTKEYS = 0x020,
GPU_FAST_FORWARD,
GPU_FRAME_LIMIT
};
#endif //__EXTENDED_KEYS_H__
| pcsxr/PCSX-Reloaded | pcsxr/macosx/plugins/PeopsXgl/macsrc/ExtendedKeys.h | C | gpl-3.0 | 700 | [
30522,
1001,
2065,
13629,
2546,
1035,
1035,
3668,
1035,
6309,
1035,
1044,
1035,
1035,
1001,
9375,
1035,
1035,
3668,
1035,
6309,
1035,
1044,
1035,
1035,
4372,
2819,
1063,
8827,
2595,
1035,
13184,
1035,
3145,
1027,
1014,
2595,
4246,
4783,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* AdminLte2 Timeline
* https://almsaeedstudio.com/themes/AdminLTE/pages/UI/timeline.html
*/
namespace LTE;
Class Timeline
{
//private $id ='';
//private $title='title';
public function __construct ()
{
//$this->id = md5(rand(0,time()));
//$this->title = $title;
//$this->body = $body;
//$this->footer = $footer;
//echo "Youpi !!";
}
public function id($str = ''){
$this->id=$str;
}
public function icon($str = ''){
$this->icon=$str;
}
public function html()
{
$HTML=[];
$HTML[]='<ul class="timeline">';
//<!-- timeline time label -->
$HTML[]='<li class="time-label">';
$HTML[]='<span class="bg-red">';
$HTML[]='10 Feb. 2014';
$HTML[]='</span>';
$HTML[]='</li>';
//<!-- /.timeline-label -->
//<!-- timeline item -->
$HTML[]='<li>';
//<!-- timeline icon -->
$HTML[]='<i class="fa fa-envelope bg-blue"></i>';
$HTML[]='<div class="timeline-item">';
$HTML[]='<span class="time"><i class="fa fa-clock-o"></i> 12:05</span>';
$HTML[]='<h3 class="timeline-header"><a href="#">Support Team</a> ...</h3>';
$HTML[]='<div class="timeline-body">';
//...
$HTML[]='Content goes here';
$HTML[]='</div>';
$HTML[]='<div class="timeline-footer">';
$HTML[]='<a class="btn btn-primary btn-xs">...</a>';
$HTML[]='</div>';
$HTML[]='</div>';
$HTML[]='</li>';
//<!-- END timeline item -->
$HTML[]='</ul>';
return implode("\n", $HTML);
}
public function __toString()
{
return $this->html();
}
}
/*
<ul class="timeline">
<!-- timeline time label -->
<li class="time-label">
<span class="bg-red">
10 Feb. 2014
</span>
</li>
<!-- /.timeline-label -->
<!-- timeline item -->
<li>
<!-- timeline icon -->
<i class="fa fa-envelope bg-blue"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 12:05</span>
<h3 class="timeline-header"><a href="#">Support Team</a> ...</h3>
<div class="timeline-body">
...
Content goes here
</div>
<div class='timeline-footer'>
<a class="btn btn-primary btn-xs">...</a>
</div>
</div>
</li>
<!-- END timeline item -->
...
</ul>
*/ | ffinstitute/dataviz.ff.institute | src/LTE/Timeline.php | PHP | gpl-3.0 | 2,783 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4748,
10020,
7096,
2063,
2475,
17060,
1008,
16770,
1024,
1013,
1013,
2632,
5244,
6679,
2098,
3367,
21041,
2080,
1012,
4012,
1013,
6991,
1013,
4748,
10020,
7096,
2063,
1013,
5530,
1013,
21318... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* Scaled Line Clipping rendering test
*/
public class ScaleClipTest {
static final boolean SAVE_IMAGE = false;
static final int SIZE = 50;
enum SCALE_MODE {
ORTHO,
NON_ORTHO,
COMPLEX
};
public static void main(String[] args) {
// First display which renderer is tested:
// JDK9 only:
System.setProperty("sun.java2d.renderer.verbose", "true");
System.out.println("Testing renderer: ");
// Other JDK:
String renderer = "undefined";
try {
renderer = sun.java2d.pipe.RenderingEngine.getInstance().getClass().getName();
System.out.println(renderer);
} catch (Throwable th) {
// may fail with JDK9 jigsaw (jake)
if (false) {
System.err.println("Unable to get RenderingEngine.getInstance()");
th.printStackTrace();
}
}
System.out.println("ScaleClipTest: size = " + SIZE);
final BufferedImage image = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
boolean fail = false;
// testNegativeScale:
for (SCALE_MODE mode : SCALE_MODE.values()) {
try {
testNegativeScale(image, mode);
} catch (IllegalStateException ise) {
System.err.println("testNegativeScale[" + mode + "] failed:");
ise.printStackTrace();
fail = true;
}
}
// testMarginScale:
for (SCALE_MODE mode : SCALE_MODE.values()) {
try {
testMarginScale(image, mode);
} catch (IllegalStateException ise) {
System.err.println("testMarginScale[" + mode + "] failed:");
ise.printStackTrace();
fail = true;
}
}
// Fail at the end:
if (fail) {
throw new RuntimeException("ScaleClipTest has failures.");
}
}
private static void testNegativeScale(final BufferedImage image, final SCALE_MODE mode) {
final Graphics2D g2d = (Graphics2D) image.getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2d.setBackground(Color.WHITE);
g2d.clearRect(0, 0, SIZE, SIZE);
g2d.setColor(Color.BLACK);
// Bug in TransformingPathConsumer2D.adjustClipScale()
// non ortho scale only
final double scale = -1.0;
final AffineTransform at;
switch (mode) {
default:
case ORTHO:
at = AffineTransform.getScaleInstance(scale, scale);
break;
case NON_ORTHO:
at = AffineTransform.getScaleInstance(scale, scale + 1e-5);
break;
case COMPLEX:
at = AffineTransform.getScaleInstance(scale, scale);
at.concatenate(AffineTransform.getShearInstance(1e-4, 1e-4));
break;
}
g2d.setTransform(at);
// Set cap/join to reduce clip margin:
g2d.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
final Path2D p = new Path2D.Double();
p.moveTo(scale * 10, scale * 10);
p.lineTo(scale * (SIZE - 10), scale * (SIZE - 10));
g2d.draw(p);
if (SAVE_IMAGE) {
try {
final File file = new File("ScaleClipTest-testNegativeScale-" + mode + ".png");
System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "PNG", file);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
// Check image:
// 25, 25 = black
checkPixel(image.getData(), 25, 25, Color.BLACK.getRGB());
} finally {
g2d.dispose();
}
}
private static void testMarginScale(final BufferedImage image, final SCALE_MODE mode) {
final Graphics2D g2d = (Graphics2D) image.getGraphics();
try {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2d.setBackground(Color.WHITE);
g2d.clearRect(0, 0, SIZE, SIZE);
g2d.setColor(Color.BLACK);
// Bug in Stroker.init()
// ortho scale only: scale used twice !
final double scale = 1e-2;
final AffineTransform at;
switch (mode) {
default:
case ORTHO:
at = AffineTransform.getScaleInstance(scale, scale);
break;
case NON_ORTHO:
at = AffineTransform.getScaleInstance(scale, scale + 1e-5);
break;
case COMPLEX:
at = AffineTransform.getScaleInstance(scale, scale);
at.concatenate(AffineTransform.getShearInstance(1e-4, 1e-4));
break;
}
g2d.setTransform(at);
final double invScale = 1.0 / scale;
// Set cap/join to reduce clip margin:
final float w = (float) (3.0 * invScale);
g2d.setStroke(new BasicStroke(w, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
final Path2D p = new Path2D.Double();
p.moveTo(invScale * -0.5, invScale * 10);
p.lineTo(invScale * -0.5, invScale * (SIZE - 10));
g2d.draw(p);
if (SAVE_IMAGE) {
try {
final File file = new File("ScaleClipTest-testMarginScale-" + mode + ".png");
System.out.println("Writing file: " + file.getAbsolutePath());
ImageIO.write(image, "PNG", file);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
// Check image:
// 0, 25 = black
checkPixel(image.getData(), 0, 25, Color.BLACK.getRGB());
} finally {
g2d.dispose();
}
}
private static void checkPixel(final Raster raster,
final int x, final int y,
final int expected) {
final int[] rgb = (int[]) raster.getDataElements(x, y, null);
if (rgb[0] != expected) {
throw new IllegalStateException("bad pixel at (" + x + ", " + y
+ ") = " + rgb[0] + " expected: " + expected);
}
}
}
| JetBrains/jdk8u_jdk | test/sun/java2d/marlin/ScaleClipTest.java | Java | gpl-2.0 | 8,526 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2760,
1010,
14721,
1998,
1013,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
2079,
2025,
11477,
2030,
6366,
9385,
14444,
2030,
2023,
5371,
20346,
1012,
1008,
1008,
2023,
3642,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';
/* eslint-env mocha */
const OptimizedImages =
require('../../../../gather/gatherers/dobetterweb/optimized-images');
const assert = require('assert');
let options;
let optimizedImages;
const fakeImageStats = {
jpeg: {base64: 100, binary: 80},
webp: {base64: 80, binary: 60},
};
const traceData = {
networkRecords: [
{
_url: 'http://google.com/image.jpg',
_mimeType: 'image/jpeg',
_resourceSize: 10000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'http://google.com/transparent.png',
_mimeType: 'image/png',
_resourceSize: 11000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'http://google.com/image.bmp',
_mimeType: 'image/bmp',
_resourceSize: 12000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'http://google.com/image.bmp',
_mimeType: 'image/bmp',
_resourceSize: 12000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'http://google.com/vector.svg',
_mimeType: 'image/svg+xml',
_resourceSize: 13000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'http://gmail.com/image.jpg',
_mimeType: 'image/jpeg',
_resourceSize: 15000,
_resourceType: {_name: 'image'},
finished: true,
},
{
_url: 'data: image/jpeg ; base64 ,SgVcAT32587935321...',
_mimeType: 'image/jpeg',
_resourceType: {_name: 'image'},
_resourceSize: 14000,
finished: true,
},
{
_url: 'http://google.com/big-image.bmp',
_mimeType: 'image/bmp',
_resourceType: {_name: 'image'},
_resourceSize: 12000,
finished: false, // ignore for not finishing
},
{
_url: 'http://google.com/not-an-image.bmp',
_mimeType: 'image/bmp',
_resourceType: {_name: 'document'}, // ignore for not really being an image
_resourceSize: 12000,
finished: true,
},
],
};
describe('Optimized images', () => {
// Reset the Gatherer before each test.
beforeEach(() => {
optimizedImages = new OptimizedImages();
options = {
url: 'http://google.com/',
driver: {
evaluateAsync: function() {
return Promise.resolve(fakeImageStats);
},
sendCommand: function() {
return Promise.reject(new Error('wasn\'t found'));
},
},
};
});
it('returns all images', () => {
return optimizedImages.afterPass(options, traceData).then(artifact => {
assert.equal(artifact.length, 4);
assert.ok(/image.jpg/.test(artifact[0].url));
assert.ok(/transparent.png/.test(artifact[1].url));
assert.ok(/image.bmp/.test(artifact[2].url));
// skip cross-origin for now
// assert.ok(/gmail.*image.jpg/.test(artifact[3].url));
assert.ok(/data: image/.test(artifact[3].url));
});
});
it('computes sizes', () => {
const checkSizes = (stat, original, webp, jpeg) => {
assert.equal(stat.originalSize, original);
assert.equal(stat.webpSize, webp);
assert.equal(stat.jpegSize, jpeg);
};
return optimizedImages.afterPass(options, traceData).then(artifact => {
assert.equal(artifact.length, 4);
checkSizes(artifact[0], 10000, 60, 80);
checkSizes(artifact[1], 11000, 60, 80);
checkSizes(artifact[2], 12000, 60, 80);
// skip cross-origin for now
// checkSizes(artifact[3], 15000, 60, 80);
checkSizes(artifact[3], 20, 80, 100); // uses base64 data
});
});
it('handles partial driver failure', () => {
let calls = 0;
options.driver.evaluateAsync = () => {
calls++;
if (calls > 2) {
return Promise.reject(new Error('whoops driver failed'));
} else {
return Promise.resolve(fakeImageStats);
}
};
return optimizedImages.afterPass(options, traceData).then(artifact => {
const failed = artifact.find(record => record.failed);
assert.equal(artifact.length, 4);
assert.ok(failed, 'passed along failure');
assert.ok(/whoops/.test(failed.err.message), 'passed along error message');
});
});
it('supports Audits.getEncodedResponse', () => {
options.driver.sendCommand = (method, params) => {
const encodedSize = params.encoding === 'webp' ? 60 : 80;
return Promise.resolve({encodedSize});
};
return optimizedImages.afterPass(options, traceData).then(artifact => {
assert.equal(artifact.length, 5);
assert.equal(artifact[0].originalSize, 10000);
assert.equal(artifact[0].webpSize, 60);
assert.equal(artifact[0].jpegSize, 80);
// supports cross-origin
assert.ok(/gmail.*image.jpg/.test(artifact[3].url));
});
});
});
| tkadlec/lighthouse | lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js | JavaScript | apache-2.0 | 5,402 | [
30522,
1013,
1008,
1008,
1008,
1030,
6105,
9385,
2418,
8224,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
2224,
2023,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#include "acresrc.h"
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME("rsutils")
u8 acpi_rs_decode_bitmask(u16 mask, u8 * list)
{
u8 i;
u8 bit_count;
ACPI_FUNCTION_ENTRY();
/* Decode the mask bits */
for (i = 0, bit_count = 0; mask; i++) {
if (mask & 0x0001) {
list[bit_count] = i;
bit_count++;
}
mask >>= 1;
}
return (bit_count);
}
u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
{
u32 i;
u16 mask;
ACPI_FUNCTION_ENTRY();
/* Encode the list into a single bitmask */
for (i = 0, mask = 0; i < count; i++) {
mask |= (0x1 << list[i]);
}
return mask;
}
void
acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
{
u32 i;
ACPI_FUNCTION_ENTRY();
/* One move per item */
for (i = 0; i < item_count; i++) {
switch (move_type) {
/*
* For the 8-bit case, we can perform the move all at once
* since there are no alignment or endian issues
*/
case ACPI_RSC_MOVE8:
ACPI_MEMCPY(destination, source, item_count);
return;
/*
* 16-, 32-, and 64-bit cases must use the move macros that perform
* endian conversion and/or accomodate hardware that cannot perform
* misaligned memory transfers
*/
case ACPI_RSC_MOVE16:
ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
&ACPI_CAST_PTR(u16, source)[i]);
break;
case ACPI_RSC_MOVE32:
ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
&ACPI_CAST_PTR(u32, source)[i]);
break;
case ACPI_RSC_MOVE64:
ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
&ACPI_CAST_PTR(u64, source)[i]);
break;
default:
return;
}
}
}
void
acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
union aml_resource *aml)
{
acpi_rs_length resource_length;
ACPI_FUNCTION_ENTRY();
/* Length is the total descriptor length minus the header length */
resource_length = (acpi_rs_length)
(total_length - acpi_ut_get_resource_header_length(aml));
/* Length is stored differently for large and small descriptors */
if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) {
/* Large descriptor -- bytes 1-2 contain the 16-bit length */
ACPI_MOVE_16_TO_16(&aml->large_header.resource_length,
&resource_length);
} else {
/* Small descriptor -- bits 2:0 of byte 0 contain the length */
aml->small_header.descriptor_type = (u8)
/* Clear any existing length, preserving descriptor type bits */
((aml->small_header.
descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
| resource_length);
}
}
void
acpi_rs_set_resource_header(u8 descriptor_type,
acpi_rsdesc_size total_length,
union aml_resource *aml)
{
ACPI_FUNCTION_ENTRY();
/* Set the Resource Type */
aml->small_header.descriptor_type = descriptor_type;
/* Set the Resource Length */
acpi_rs_set_resource_length(total_length, aml);
}
static u16 acpi_rs_strcpy(char *destination, char *source)
{
u16 i;
ACPI_FUNCTION_ENTRY();
for (i = 0; source[i]; i++) {
destination[i] = source[i];
}
destination[i] = 0;
/* Return string length including the NULL terminator */
return ((u16) (i + 1));
}
acpi_rs_length
acpi_rs_get_resource_source(acpi_rs_length resource_length,
acpi_rs_length minimum_length,
struct acpi_resource_source * resource_source,
union aml_resource * aml, char *string_ptr)
{
acpi_rsdesc_size total_length;
u8 *aml_resource_source;
ACPI_FUNCTION_ENTRY();
total_length =
resource_length + sizeof(struct aml_resource_large_header);
aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
/*
* resource_source is present if the length of the descriptor is longer than
* the minimum length.
*
* Note: Some resource descriptors will have an additional null, so
* we add 1 to the minimum length.
*/
if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) {
/* Get the resource_source_index */
resource_source->index = aml_resource_source[0];
resource_source->string_ptr = string_ptr;
if (!string_ptr) {
/*
* String destination pointer is not specified; Set the String
* pointer to the end of the current resource_source structure.
*/
resource_source->string_ptr =
ACPI_ADD_PTR(char, resource_source,
sizeof(struct acpi_resource_source));
}
/*
* In order for the Resource length to be a multiple of the native
* word, calculate the length of the string (+1 for NULL terminator)
* and expand to the next word multiple.
*
* Zero the entire area of the buffer.
*/
total_length = (u32)
ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1;
total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
/* Copy the resource_source string to the destination */
resource_source->string_length =
acpi_rs_strcpy(resource_source->string_ptr,
ACPI_CAST_PTR(char,
&aml_resource_source[1]));
return ((acpi_rs_length) total_length);
}
/* resource_source is not present */
resource_source->index = 0;
resource_source->string_length = 0;
resource_source->string_ptr = NULL;
return (0);
}
acpi_rsdesc_size
acpi_rs_set_resource_source(union aml_resource * aml,
acpi_rs_length minimum_length,
struct acpi_resource_source * resource_source)
{
u8 *aml_resource_source;
acpi_rsdesc_size descriptor_length;
ACPI_FUNCTION_ENTRY();
descriptor_length = minimum_length;
/* Non-zero string length indicates presence of a resource_source */
if (resource_source->string_length) {
/* Point to the end of the AML descriptor */
aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
/* Copy the resource_source_index */
aml_resource_source[0] = (u8) resource_source->index;
/* Copy the resource_source string */
ACPI_STRCPY(ACPI_CAST_PTR(char, &aml_resource_source[1]),
resource_source->string_ptr);
/*
* Add the length of the string (+ 1 for null terminator) to the
* final descriptor length
*/
descriptor_length +=
((acpi_rsdesc_size) resource_source->string_length + 1);
}
/* Return the new total length of the AML descriptor */
return (descriptor_length);
}
acpi_status
acpi_rs_get_prt_method_data(struct acpi_namespace_node * node,
struct acpi_buffer * ret_buffer)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE(rs_get_prt_method_data);
/* Parameters guaranteed valid by caller */
/* Execute the method, no parameters */
status = acpi_ut_evaluate_object(node, METHOD_NAME__PRT,
ACPI_BTYPE_PACKAGE, &obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Create a resource linked list from the byte stream buffer that comes
* back from the _CRS method execution.
*/
status = acpi_rs_create_pci_routing_table(obj_desc, ret_buffer);
/* On exit, we must delete the object returned by evaluate_object */
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
acpi_status
acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
struct acpi_buffer *ret_buffer)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE(rs_get_crs_method_data);
/* Parameters guaranteed valid by caller */
/* Execute the method, no parameters */
status = acpi_ut_evaluate_object(node, METHOD_NAME__CRS,
ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the _CRS method
* execution.
*/
status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
/* On exit, we must delete the object returned by evaluate_object */
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
struct acpi_buffer *ret_buffer)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE(rs_get_prs_method_data);
/* Parameters guaranteed valid by caller */
/* Execute the method, no parameters */
status = acpi_ut_evaluate_object(node, METHOD_NAME__PRS,
ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the _CRS method
* execution.
*/
status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
/* On exit, we must delete the object returned by evaluate_object */
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
#endif /* ACPI_FUTURE_USAGE */
acpi_status
acpi_rs_get_method_data(acpi_handle handle,
char *path, struct acpi_buffer *ret_buffer)
{
union acpi_operand_object *obj_desc;
acpi_status status;
ACPI_FUNCTION_TRACE(rs_get_method_data);
/* Parameters guaranteed valid by caller */
/* Execute the method, no parameters */
status =
acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Make the call to create a resource linked list from the
* byte stream buffer that comes back from the method
* execution.
*/
status = acpi_rs_create_resource_list(obj_desc, ret_buffer);
/* On exit, we must delete the object returned by evaluate_object */
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}
acpi_status
acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
struct acpi_buffer *in_buffer)
{
struct acpi_evaluate_info *info;
union acpi_operand_object *args[2];
acpi_status status;
struct acpi_buffer buffer;
ACPI_FUNCTION_TRACE(rs_set_srs_method_data);
/* Allocate and initialize the evaluation information block */
info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
if (!info) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
info->prefix_node = node;
info->pathname = METHOD_NAME__SRS;
info->parameters = args;
info->flags = ACPI_IGNORE_RETURN_VALUE;
/*
* The in_buffer parameter will point to a linked list of
* resource parameters. It needs to be formatted into a
* byte stream to be sent in as an input parameter to _SRS
*
* Convert the linked list into a byte stream
*/
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
if (ACPI_FAILURE(status)) {
goto cleanup;
}
/* Create and initialize the method parameter object */
args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
if (!args[0]) {
/*
* Must free the buffer allocated above (otherwise it is freed
* later)
*/
ACPI_FREE(buffer.pointer);
status = AE_NO_MEMORY;
goto cleanup;
}
args[0]->buffer.length = (u32) buffer.length;
args[0]->buffer.pointer = buffer.pointer;
args[0]->common.flags = AOPOBJ_DATA_VALID;
args[1] = NULL;
/* Execute the method, no return value is expected */
status = acpi_ns_evaluate(info);
/* Clean up and return the status from acpi_ns_evaluate */
acpi_ut_remove_reference(args[0]);
cleanup:
ACPI_FREE(info);
return_ACPI_STATUS(status);
}
| luckasfb/OT_903D-kernel-2.6.35.7 | kernel/drivers/acpi/acpica/rsutils.c | C | gpl-2.0 | 11,290 | [
30522,
1001,
2421,
1026,
9353,
8197,
1013,
9353,
8197,
1012,
1044,
1028,
1001,
2421,
1000,
16222,
5358,
8202,
1012,
1044,
1000,
1001,
2421,
1000,
9353,
18442,
13102,
1012,
1044,
1000,
1001,
2421,
1000,
4631,
11890,
1012,
1044,
1000,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/vid_rdcl.c,v 1.3 2003/02/21 16:51:10 alanh Exp $ */
/*
* $Workfile: vid_rdcl.c $
*
* This file contains routines to control the Redcloud display filter video overlay hardware.
*
* NSC_LIC_ALTERNATIVE_PREAMBLE
*
* Revision 1.0
*
* National Semiconductor Alternative GPL-BSD License
*
* National Semiconductor Corporation licenses this software
* ("Software"):
*
* Durango
*
* under one of the two following licenses, depending on how the
* Software is received by the Licensee.
*
* If this Software is received as part of the Linux Framebuffer or
* other GPL licensed software, then the GPL license designated
* NSC_LIC_GPL applies to this Software; in all other circumstances
* then the BSD-style license designated NSC_LIC_BSD shall apply.
*
* END_NSC_LIC_ALTERNATIVE_PREAMBLE */
/* NSC_LIC_BSD
*
* National Semiconductor Corporation Open Source License for Durango
*
* (BSD License with Export Notice)
*
* Copyright (c) 1999-2001
* National Semiconductor Corporation.
* 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 National Semiconductor Corporation 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
* NATIONAL SEMICONDUCTOR CORPORATION 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,
* INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
* YOUR JURISDICTION. It is licensee's responsibility to comply with
* any export regulations applicable in licensee's jurisdiction. Under
* CURRENT (2001) U.S. export regulations this software
* is eligible for export from the U.S. and can be downloaded by or
* otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
* destinations which include Cuba, Iraq, Libya, North Korea, Iran,
* Syria, Sudan, Afghanistan and any other country to which the U.S.
* has embargoed goods and services.
*
* END_NSC_LIC_BSD */
/* NSC_LIC_GPL
*
* National Semiconductor Corporation Gnu General Public License for Durango
*
* (GPL License with Export Notice)
*
* Copyright (c) 1999-2001
* National Semiconductor Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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
*
* In addition to the terms of the GNU General Public License, neither
* the name of the National Semiconductor Corporation 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
* NATIONAL SEMICONDUCTOR CORPORATION 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,
* INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. See the GNU General Public License for more details.
*
* EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
* YOUR JURISDICTION. It is licensee's responsibility to comply with
* any export regulations applicable in licensee's jurisdiction. Under
* CURRENT (2001) U.S. export regulations this software
* is eligible for export from the U.S. and can be downloaded by or
* otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
* destinations which include Cuba, Iraq, Libya, North Korea, Iran,
* Syria, Sudan, Afghanistan and any other country to which the U.S.
* has embargoed goods and services.
*
* You should have received a copy of the GNU General Public License
* along with this file; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* END_NSC_LIC_GPL */
/* REDCLOUD PLL TABLE */
typedef struct RCDFPLL
{
long frequency; /* 16.16 fixed point frequency */
unsigned long post_div3; /* MCP Frequency dividers and multipliers */
unsigned long pre_mul2;
unsigned long pre_div2;
unsigned long pll_value; /* MCP DotPLL Register Upper 32(0x0015) */
}
RCDFPLLENTRY;
RCDFPLLENTRY RCDF_PLLtable48MHz[] = {
{0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */
{0x001C526E, 1, 1, 0, 0x00000B1A}, /* 28.3220 */
{0x001F8000, 1, 0, 0, 0x000002D2}, /* 31.5000 */
{0x00240000, 1, 1, 0, 0x00000FE2}, /* 36.0000 */
{0x00258000, 1, 0, 0, 0x0000057A}, /* 37.5000 */
{0x00280000, 1, 0, 0, 0x0000030A}, /* 40.0000 */
{0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */
{0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */
{0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */
{0x00325999, 0, 1, 0, 0x00000037}, /* 50.3500 */
{0x00360000, 1, 1, 0, 0x00000B0D}, /* 54.0000 */
{0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */
{0x0038643F, 0, 0, 0, 0x000007F7}, /* 56.3916 */
{0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */
{0x003B0000, 0, 1, 0, 0x00000707}, /* 59.0000 */
{0x003F0000, 1, 1, 0, 0x00000B39}, /* 63.0000 */
{0x00410000, 1, 1, 0, 0x00000B45}, /* 65.0000 */
{0x00438000, 1, 1, 0, 0x00000FC1}, /* 67.5000 */
{0x0046CCCC, 1, 0, 0, 0x00000561}, /* 70.8000 */
{0x00480000, 1, 0, 0, 0x000007E1}, /* 72.0000 */
{0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */
{0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */
{0x00500000, 1, 1, 0, 0x00000709}, /* 80.0000 */
{0x0059CCCC, 0, 1, 0, 0x00000262}, /* 89.8000 */
{0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */
{0x00630000, 0, 1, 0, 0x00000B4A}, /* 99.0000 */
{0x00640000, 0, 1, 0, 0x00000036}, /* 100.0000 */
{0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */
{0x00708000, 0, 0, 0, 0x000007F6}, /* 112.5000 */
{0x00820000, 1, 1, 0, 0x00000FB0}, /* 130.0000 */
{0x00870000, 1, 1, 0, 0x00000B50}, /* 135.0000 */
{0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */
{0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */
{0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */
{0x00BD0000, 0, 0, 0, 0x000002D1}, /* 189.0000 */
{0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */
{0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */
};
RCDFPLLENTRY RCDF_PLLtable14MHz[] = {
{0x00192CCC, 0, 0, 0, 0x00000037}, /* 25.1750 */
{0x001C526E, 0, 0, 0, 0x00000B7B}, /* 28.3220 */
{0x001F8000, 0, 0, 0, 0x000004D3}, /* 31.5000 */
{0x00240000, 0, 0, 0, 0x00000BE3}, /* 36.0000 */
{0x00258000, 0, 0, 0, 0x0000074F}, /* 37.5000 */
{0x00280000, 0, 0, 0, 0x0000050B}, /* 40.0000 */
{0x002CE666, 0, 0, 0, 0x00000063}, /* 44.9000 */
{0x00318000, 0, 0, 0, 0x0000054B}, /* 49.5000 */
{0x00320000, 0, 0, 0, 0x0000026E}, /* 50.0000 */
{0x00325999, 0, 0, 0, 0x000007C3}, /* 50.3500 */
{0x00360000, 0, 0, 0, 0x000007E3}, /* 54.0000 */
{0x00384000, 0, 0, 0, 0x00000577}, /* 56.2500 */
{0x0038643F, 0, 0, 0, 0x000002FB}, /* 56.3916 */
{0x0038A4DD, 0, 0, 0, 0x0000057B}, /* 56.6444 */
{0x003B0000, 0, 0, 0, 0x0000058B}, /* 59.0000 */
{0x003F0000, 0, 0, 0, 0x0000095E}, /* 63.0000 */
{0x00410000, 0, 0, 0, 0x0000096A}, /* 65.0000 */
{0x00438000, 0, 0, 0, 0x00000BC2}, /* 67.5000 */
{0x0046CCCC, 0, 0, 0, 0x0000098A}, /* 70.8000 */
{0x00480000, 0, 0, 0, 0x00000BE2}, /* 72.0000 */
{0x004B0000, 0, 0, 0, 0x00000052}, /* 75.0000 */
{0x004EC000, 0, 0, 0, 0x00000056}, /* 78.7500 */
{0x00500000, 0, 0, 0, 0x0000050A}, /* 80.0000 */
{0x0059CCCC, 0, 0, 0, 0x0000078E}, /* 89.8000 */
{0x005E8000, 0, 0, 0, 0x000002D2}, /* 94.5000 */
{0x00630000, 0, 0, 0, 0x000011F6}, /* 99.0000 */
{0x00640000, 0, 0, 0, 0x0000054E}, /* 100.0000 */
{0x006C0000, 0, 0, 0, 0x000007E2}, /* 108.0000 */
{0x00708000, 0, 0, 0, 0x000002FA}, /* 112.5000 */
{0x00820000, 0, 0, 0, 0x00000BB1}, /* 130.0000 */
{0x00870000, 0, 0, 0, 0x00000975}, /* 135.0000 */
{0x009D8000, 0, 0, 0, 0x00000055}, /* 157.5000 */
{0x00A20000, 0, 0, 0, 0x000009C1}, /* 162.0000 */
{0x00AF8000, 0, 0, 0, 0x000002C1}, /* 175.5000 */
{0x00BD0000, 0, 0, 0, 0x00000539}, /* 189.0000 */
{0x00CA8000, 0, 0, 0, 0x00000551}, /* 202.5000 */
{0x00E58000, 0, 0, 0, 0x0000057D}, /* 229.5000 */
};
#define NUM_RCDF_FREQUENCIES sizeof(RCDF_PLLtable14MHz)/sizeof(RCDFPLLENTRY)
int redcloud_set_video_enable(int enable);
int redcloud_set_video_format(unsigned long format);
int redcloud_set_video_size(unsigned short width, unsigned short height);
int redcloud_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch);
int redcloud_set_video_offset(unsigned long offset);
int redcloud_set_video_yuv_offsets(unsigned long yoffset,
unsigned long uoffset,
unsigned long voffset);
int redcloud_set_video_window(short x, short y, unsigned short w,
unsigned short h);
int redcloud_set_video_left_crop(unsigned short x);
int redcloud_set_video_upscale(unsigned short srcw, unsigned short srch,
unsigned short dstw, unsigned short dsth);
int redcloud_set_video_scale(unsigned short srcw, unsigned short srch,
unsigned short dstw, unsigned short dsth);
int redcloud_set_video_vertical_downscale(unsigned short srch,
unsigned short dsth);
void redcloud_set_video_vertical_downscale_enable(int enable);
int redcloud_set_video_downscale_config(unsigned short type,
unsigned short m);
int redcloud_set_video_color_key(unsigned long key, unsigned long mask,
int bluescreen);
int redcloud_set_video_filter(int xfilter, int yfilter);
int redcloud_set_video_palette(unsigned long *palette);
int redcloud_set_video_palette_entry(unsigned long index,
unsigned long color);
int redcloud_set_video_downscale_coefficients(unsigned short coef1,
unsigned short coef2,
unsigned short coef3,
unsigned short coef4);
int redcloud_set_video_downscale_enable(int enable);
int redcloud_set_video_source(VideoSourceType source);
int redcloud_set_vbi_source(VbiSourceType source);
int redcloud_set_vbi_lines(unsigned long even, unsigned long odd);
int redcloud_set_vbi_total(unsigned long even, unsigned long odd);
int redcloud_set_video_interlaced(int enable);
int redcloud_set_color_space_YUV(int enable);
int redcloud_set_vertical_scaler_offset(char offset);
int redcloud_set_top_line_in_odd(int enable);
int redcloud_set_genlock_delay(unsigned long delay);
int redcloud_set_genlock_enable(int flags);
int redcloud_set_video_cursor(unsigned long key, unsigned long mask,
unsigned short select_color2,
unsigned long color1, unsigned long color2);
int redcloud_set_video_cursor_enable(int enable);
int redcloud_set_video_request(short x, short y);
int redcloud_select_alpha_region(int region);
int redcloud_set_alpha_enable(int enable);
int redcloud_set_alpha_window(short x, short y,
unsigned short width, unsigned short height);
int redcloud_set_alpha_value(unsigned char alpha, char delta);
int redcloud_set_alpha_priority(int priority);
int redcloud_set_alpha_color(unsigned long color);
int redcloud_set_alpha_color_enable(int enable);
int redcloud_set_no_ck_outside_alpha(int enable);
int redcloud_disable_softvga(void);
int redcloud_enable_softvga(void);
int redcloud_set_macrovision_enable(int enable);
void redcloud_reset_video(void);
int redcloud_set_display_control(int sync_polarities);
void redcloud_set_clock_frequency(unsigned long frequency);
int redcloud_set_crt_enable(int enable);
/* READ ROUTINES IN GFX_VID.C */
int redcloud_get_video_enable(void);
int redcloud_get_video_format(void);
unsigned long redcloud_get_video_src_size(void);
unsigned long redcloud_get_video_line_size(void);
unsigned long redcloud_get_video_xclip(void);
unsigned long redcloud_get_video_offset(void);
void redcloud_get_video_yuv_offsets(unsigned long *yoffset,
unsigned long *uoffset,
unsigned long *voffset);
void redcloud_get_video_yuv_pitch(unsigned long *ypitch,
unsigned long *uvpitch);
unsigned long redcloud_get_video_upscale(void);
unsigned long redcloud_get_video_scale(void);
unsigned long redcloud_get_video_downscale_delta(void);
int redcloud_get_video_vertical_downscale_enable(void);
int redcloud_get_video_downscale_config(unsigned short *type,
unsigned short *m);
void redcloud_get_video_downscale_coefficients(unsigned short *coef1,
unsigned short *coef2,
unsigned short *coef3,
unsigned short *coef4);
void redcloud_get_video_downscale_enable(int *enable);
unsigned long redcloud_get_video_dst_size(void);
unsigned long redcloud_get_video_position(void);
unsigned long redcloud_get_video_color_key(void);
unsigned long redcloud_get_video_color_key_mask(void);
int redcloud_get_video_palette_entry(unsigned long index,
unsigned long *palette);
int redcloud_get_video_color_key_src(void);
int redcloud_get_video_filter(void);
int redcloud_get_video_request(short *x, short *y);
int redcloud_get_video_source(VideoSourceType * source);
int redcloud_get_vbi_source(VbiSourceType * source);
unsigned long redcloud_get_vbi_lines(int odd);
unsigned long redcloud_get_vbi_total(int odd);
int redcloud_get_video_interlaced(void);
int redcloud_get_color_space_YUV(void);
int redcloud_get_vertical_scaler_offset(char *offset);
unsigned long redcloud_get_genlock_delay(void);
int redcloud_get_genlock_enable(void);
int redcloud_get_video_cursor(unsigned long *key, unsigned long *mask,
unsigned short *select_color2,
unsigned long *color1, unsigned short *color2);
unsigned long redcloud_read_crc(void);
unsigned long redcloud_read_crc32(void);
unsigned long redcloud_read_window_crc(int source, unsigned short x,
unsigned short y, unsigned short width,
unsigned short height, int crc32);
int redcloud_get_macrovision_enable(void);
void redcloud_get_alpha_enable(int *enable);
void redcloud_get_alpha_size(unsigned short *x, unsigned short *y,
unsigned short *width, unsigned short *height);
void redcloud_get_alpha_value(unsigned char *alpha, char *delta);
void redcloud_get_alpha_priority(int *priority);
void redcloud_get_alpha_color(unsigned long *color);
unsigned long redcloud_get_clock_frequency(void);
int redcloud_get_sync_polarities(void);
/*---------------------------------------------------------------------------
* gfx_reset_video (PRIVATE ROUTINE: NOT PART OF DURANGO API)
*
* This routine is used to disable all components of video overlay before
* performing a mode switch.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_reset_video(void)
#else
void
gfx_reset_video(void)
#endif
{
gfx_set_video_enable(0);
gfx_select_alpha_region(1);
gfx_set_alpha_enable(0);
gfx_select_alpha_region(2);
gfx_set_alpha_enable(0);
/* SET REGION 0 AFTER RESET */
gfx_select_alpha_region(0);
gfx_set_alpha_enable(0);
}
/*-----------------------------------------------------------------------------
* gfx_set_display_control (PRIVATE ROUTINE: NOT PART OF DURANGO API)
*
* This routine configures the display output.
*
* "sync_polarities" is used to set the polarities of the sync pulses according
* to the following mask:
*
* Bit 0: If set to 1, negative horizontal polarity is programmed,
* otherwise positive horizontal polarity is programmed.
* Bit 1: If set to 1, negative vertical polarity is programmed,
* otherwise positive vertical polarity is programmed.
*
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_display_control(int sync_polarities)
#else
int
gfx_set_display_control(int sync_polarities)
#endif
{
unsigned long power;
unsigned long dcfg;
/* CONFIGURE DISPLAY OUTPUT FROM VIDEO PROCESSOR */
dcfg = READ_VID32(RCDF_DISPLAY_CONFIG);
dcfg &= ~(RCDF_DCFG_CRT_SYNC_SKW_MASK | RCDF_DCFG_PWR_SEQ_DLY_MASK |
RCDF_DCFG_CRT_HSYNC_POL | RCDF_DCFG_CRT_VSYNC_POL |
RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN);
dcfg |= (RCDF_DCFG_CRT_SYNC_SKW_INIT |
RCDF_DCFG_PWR_SEQ_DLY_INIT | RCDF_DCFG_GV_PAL_BYP);
if (PanelEnable) {
power = READ_VID32(RCDF_POWER_MANAGEMENT);
power |= RCDF_PM_PANEL_POWER_ON;
WRITE_VID32(RCDF_POWER_MANAGEMENT, power);
}
/* SET APPROPRIATE SYNC POLARITIES */
if (sync_polarities & 0x1)
dcfg |= RCDF_DCFG_CRT_HSYNC_POL;
if (sync_polarities & 0x2)
dcfg |= RCDF_DCFG_CRT_VSYNC_POL;
WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_clock_frequency
*
* This routine sets the clock frequency, specified as a 16.16 fixed point
* value (0x00318000 = 49.5 MHz). It will set the closest frequency found
* in the lookup table.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_set_clock_frequency(unsigned long frequency)
#else
void
gfx_set_clock_frequency(unsigned long frequency)
#endif
{
Q_WORD msr_value;
unsigned int i, index = 0;
unsigned long value;
long timeout = 1000;
long min, diff;
RCDFPLLENTRY *PllTable;
/* READ PLL REFERENCE FREQUENCY */
/* The reference frequency of GX2 1.x is different from 2.x and above. */
if ((gfx_cpu_version & 0xFF00) >= 0x0200)
PllTable = RCDF_PLLtable48MHz;
else
PllTable = RCDF_PLLtable14MHz;
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
/* Search the table for the closest frequency (16.16 format). */
value = PllTable[0].pll_value;
min = (long)PllTable[0].frequency - frequency;
if (min < 0L)
min = -min;
for (i = 1; i < NUM_RCDF_FREQUENCIES; i++) {
diff = (long)PllTable[i].frequency - frequency;
if (diff < 0L)
diff = -diff;
if (diff < min) {
min = diff;
index = i;
}
}
/* PROGRAM THE SETTINGS WITH THE RESET BIT SET */
/* Clear the bypass bit to ensure that the programmed */
/* M, N and P values are being used. */
gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value);
msr_value.high = PllTable[index].pll_value;
msr_value.low |= 0x00000001;
msr_value.low &= ~MCP_DOTPLL_BYPASS;
gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value);
/* PROGRAM THE MCP DIVIDER VALUES */
gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value);
if (PllTable[index].post_div3)
msr_value.low |= MCP_DOTPOSTDIV3;
else
msr_value.low &= ~MCP_DOTPOSTDIV3;
if (PllTable[index].pre_div2)
msr_value.low |= MCP_DOTPREDIV2;
else
msr_value.low &= ~MCP_DOTPREDIV2;
if (PllTable[index].pre_mul2)
msr_value.low |= MCP_DOTPREMULT2;
else
msr_value.low &= ~MCP_DOTPREMULT2;
gfx_msr_write(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value);
/* CLEAR THE RESET BIT */
gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value);
msr_value.low &= 0xFFFFFFFE;
gfx_msr_write(RC_ID_MCP, MCP_DOTPLL, &msr_value);
/* WAIT FOR LOCK BIT */
do {
gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value);
} while (timeout-- && !(msr_value.low & MCP_DOTPLL_LOCK));
}
/*---------------------------------------------------------------------------
* gfx_set_crt_enable
*
* This routine enables or disables the CRT output from the video processor.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_crt_enable(int enable)
#else
int
gfx_set_crt_enable(int enable)
#endif
{
unsigned long config, misc;
config = READ_VID32(RCDF_DISPLAY_CONFIG);
misc = READ_VID32(RCDF_VID_MISC);
switch (enable) {
case CRT_DISABLE: /* DISABLE EVERYTHING */
WRITE_VID32(RCDF_DISPLAY_CONFIG,
config & ~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN |
RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN));
WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN);
break;
case CRT_ENABLE: /* ENABLE CRT DISPLAY, INCLUDING DISPLAY LOGIC */
WRITE_VID32(RCDF_DISPLAY_CONFIG,
config | RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN |
RCDF_DCFG_VSYNC_EN | RCDF_DCFG_DAC_BL_EN);
WRITE_VID32(RCDF_VID_MISC,
misc & ~RCDF_DAC_POWER_DOWN & ~RCDF_ANALOG_POWER_DOWN);
break;
case CRT_STANDBY: /* HSYNC:OFF VSYNC:ON */
WRITE_VID32(RCDF_DISPLAY_CONFIG,
(config &
~(RCDF_DCFG_DIS_EN | RCDF_DCFG_HSYNC_EN |
RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_VSYNC_EN);
WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN);
break;
case CRT_SUSPEND: /* HSYNC:ON VSYNC:OFF */
WRITE_VID32(RCDF_DISPLAY_CONFIG,
(config &
~(RCDF_DCFG_DIS_EN | RCDF_DCFG_VSYNC_EN |
RCDF_DCFG_DAC_BL_EN)) | RCDF_DCFG_HSYNC_EN);
WRITE_VID32(RCDF_VID_MISC, misc | RCDF_DAC_POWER_DOWN);
break;
default:
return (GFX_STATUS_BAD_PARAMETER);
}
return (GFX_STATUS_OK);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_enable
*
* This routine enables or disables the video overlay functionality.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_enable(int enable)
#else
int
gfx_set_video_enable(int enable)
#endif
{
unsigned long vcfg;
/* WAIT FOR VERTICAL BLANK TO START */
/* Otherwise a glitch can be observed. */
if (gfx_test_timing_active()) {
if (!gfx_test_vertical_active()) {
while (!gfx_test_vertical_active()) ;
}
while (gfx_test_vertical_active()) ;
}
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
if (enable) {
/* ENABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_enable(1);
/* ENABLE DISPLAY FILTER VIDEO OVERLAY */
vcfg |= RCDF_VCFG_VID_EN;
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
} else {
/* DISABLE DISPLAY FILTER VIDEO OVERLAY */
vcfg &= ~RCDF_VCFG_VID_EN;
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
/* DISABLE VIDEO OVERLAY FROM DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_enable(0);
}
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_format
*
* Sets input video format type, to one of the YUV formats or to RGB.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_format(unsigned long format)
#else
int
gfx_set_video_format(unsigned long format)
#endif
{
unsigned long ctrl, vcfg = 0;
/* SET THE DISPLAY FILTER VIDEO INPUT FORMAT */
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL);
ctrl &= ~(RCDF_VIDEO_INPUT_IS_RGB | RCDF_CSC_VIDEO_YUV_TO_RGB);
vcfg &= ~(RCDF_VCFG_VID_INP_FORMAT | RCDF_VCFG_4_2_0_MODE);
switch (format) {
case VIDEO_FORMAT_UYVY:
vcfg |= RCDF_VCFG_UYVY_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
break;
case VIDEO_FORMAT_YUYV:
vcfg |= RCDF_VCFG_YUYV_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
break;
case VIDEO_FORMAT_Y2YU:
vcfg |= RCDF_VCFG_Y2YU_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
break;
case VIDEO_FORMAT_YVYU:
vcfg |= RCDF_VCFG_YVYU_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
break;
case VIDEO_FORMAT_Y0Y1Y2Y3:
vcfg |= RCDF_VCFG_UYVY_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
vcfg |= RCDF_VCFG_4_2_0_MODE;
break;
case VIDEO_FORMAT_Y3Y2Y1Y0:
vcfg |= RCDF_VCFG_Y2YU_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
vcfg |= RCDF_VCFG_4_2_0_MODE;
break;
case VIDEO_FORMAT_Y1Y0Y3Y2:
vcfg |= RCDF_VCFG_YUYV_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
vcfg |= RCDF_VCFG_4_2_0_MODE;
break;
case VIDEO_FORMAT_Y1Y2Y3Y0:
vcfg |= RCDF_VCFG_YVYU_FORMAT;
ctrl |= RCDF_CSC_VIDEO_YUV_TO_RGB;
vcfg |= RCDF_VCFG_4_2_0_MODE;
break;
case VIDEO_FORMAT_RGB:
ctrl |= RCDF_VIDEO_INPUT_IS_RGB;
vcfg |= RCDF_VCFG_UYVY_FORMAT;
break;
case VIDEO_FORMAT_P2M_P2L_P1M_P1L:
ctrl |= RCDF_VIDEO_INPUT_IS_RGB;
vcfg |= RCDF_VCFG_Y2YU_FORMAT;
break;
case VIDEO_FORMAT_P1M_P1L_P2M_P2L:
ctrl |= RCDF_VIDEO_INPUT_IS_RGB;
vcfg |= RCDF_VCFG_YUYV_FORMAT;
break;
case VIDEO_FORMAT_P1M_P2L_P2M_P1L:
ctrl |= RCDF_VIDEO_INPUT_IS_RGB;
vcfg |= RCDF_VCFG_YVYU_FORMAT;
break;
default:
return GFX_STATUS_BAD_PARAMETER;
}
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
WRITE_VID32(RCDF_VID_ALPHA_CONTROL, ctrl);
/* SET THE VIDEO FORMAT IN THE DISPLAY CONTROLLER */
/* Use private routine to abstract display controller. */
gfx_set_display_video_format(format);
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_size
*
* This routine specifies the size of the source data. It is used only
* to determine how much data to transfer per frame, and is not used to
* calculate the scaling value (that is handled by a separate routine).
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_size(unsigned short width, unsigned short height)
#else
int
gfx_set_video_size(unsigned short width, unsigned short height)
#endif
{
unsigned long size, vcfg, vid_420, pitch;
/* SET THE DISPLAY FILTER VIDEO LINE SIZE */
/* Match the DC hardware alignment requirement. The line size must */
/* always be 32-byte aligned. However, we can manage smaller */
/* alignments by decreasing the pitch and clipping the video window. */
/* The VG will fetch extra data for each line, but the decreased */
/* pitch will ensure that it always begins fetching at the start of */
/* the video line. */
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
vid_420 = vcfg & RCDF_VCFG_4_2_0_MODE;
vcfg &= ~(RCDF_VCFG_LINE_SIZE_LOWER_MASK | RCDF_VCFG_LINE_SIZE_UPPER);
size = ((width >> 1) + 7) & 0xFFF8;
pitch = ((width << 1) + 7) & 0xFFF8;
vcfg |= (size & 0x00FF) << 8;
if (size & 0x0100)
vcfg |= RCDF_VCFG_LINE_SIZE_UPPER;
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
/* SET VIDEO BUFFER LINE SIZE IN DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_size(width, height);
/* SET VIDEO PITCH */
/* We are only maintaining legacy for 4:2:2 video formats. */
/* 4:2:0 video in previous chips was inadequate for most */
/* common video formats. */
if (!vid_420)
gfx_set_video_yuv_pitch(pitch, pitch << 1);
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_offset
*
* This routine sets the starting offset for the video buffer when only
* one offset needs to be specified.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_offset(unsigned long offset)
#else
int
gfx_set_video_offset(unsigned long offset)
#endif
{
/* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */
gfx_vid_offset = offset;
/* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_offset(offset);
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_yuv_offsets
*
* This routine sets the starting offset for the video buffer when displaying
* 4:2:0 video.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset,
unsigned long voffset)
#else
int
gfx_set_video_yuv_offsets(unsigned long yoffset, unsigned long uoffset,
unsigned long voffset)
#endif
{
/* SAVE VALUE FOR FUTURE CLIPPING OF THE TOP OF THE VIDEO WINDOW */
gfx_vid_offset = yoffset;
gfx_vid_uoffset = uoffset;
gfx_vid_voffset = voffset;
/* SET VIDEO BUFFER OFFSET IN DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_yuv_offsets(yoffset, uoffset, voffset);
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_set_video_yuv_pitch
*
* This routine sets the byte offset between consecutive scanlines of YUV video data
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch)
#else
int
gfx_set_video_yuv_pitch(unsigned long ypitch, unsigned long uvpitch)
#endif
{
/* SET VIDEO PITCH IN DISPLAY CONTROLLER */
/* Use private routine to abstract the display controller. */
gfx_set_display_video_yuv_pitch(ypitch, uvpitch);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_scale
*
* This routine sets the scale factor for the video overlay window. The
* size of the source and destination regions are specified in pixels.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_scale(unsigned short srcw, unsigned short srch,
unsigned short dstw, unsigned short dsth)
#else
int
gfx_set_video_scale(unsigned short srcw, unsigned short srch,
unsigned short dstw, unsigned short dsth)
#endif
{
unsigned long xscale, yscale;
/* SAVE PARAMETERS (unless don't-care zero destination arguments are used) */
/* These are needed for clipping the video window later. */
if (dstw != 0) {
gfx_vid_srcw = srcw;
gfx_vid_dstw = dstw;
}
if (dsth != 0) {
gfx_vid_srch = srch;
gfx_vid_dsth = dsth;
}
/* CALCULATE DISPLAY FILTER SCALE FACTORS */
/* Zero width and height indicate don't care conditions */
/* Downscaling is performed in a separate function. */
if (dstw == 0)
xscale = READ_VID32(RCDF_VIDEO_SCALE) & 0xffff; /* keep previous if don't-care argument */
else if (dstw <= srcw)
xscale = 0x2000; /* horizontal downscaling is currently done in a separate function */
else if ((srcw == 1) || (dstw == 1))
return GFX_STATUS_BAD_PARAMETER;
else
xscale = (0x2000l * (srcw - 1l)) / (dstw - 1l);
if (dsth == 0)
yscale = (READ_VID32(RCDF_VIDEO_SCALE) & 0xffff0000) >> 16; /* keep previous if don't-care argument */
else if (dsth <= srch)
yscale = 0x2000; /* vertical downscaling is handled in a separate function */
else if ((srch == 1) || (dsth == 1))
return GFX_STATUS_BAD_PARAMETER;
else
yscale = (0x2000l * (srch - 1l)) / (dsth - 1l);
WRITE_VID32(RCDF_VIDEO_SCALE, (yscale << 16) | xscale);
/* CALL ROUTINE TO UPDATE WINDOW POSITION */
/* This is required because the scale values affect the number of */
/* source data pixels that need to be clipped, as well as the */
/* amount of data that needs to be transferred. */
gfx_set_video_window(gfx_vid_xpos, gfx_vid_ypos, gfx_vid_width,
gfx_vid_height);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_vertical_downscale
*
* This routine sets the vertical downscale factor for the video overlay window.
* The height of the source and destination regions are specified in pixels.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_vertical_downscale(unsigned short srch,
unsigned short dsth)
#else
int
gfx_set_video_vertical_downscale(unsigned short srch, unsigned short dsth)
#endif
{
/* SET VIDEO SCALE IN DISPLAY CONTROLLER */
/* Use private routine to abstract hardware */
gfx_set_display_video_downscale(srch, dsth);
return 0;
}
/*---------------------------------------------------------------------------
* gfx_set_video_vertical_downscale_enable
*
* This routine sets the vertical downscale enable for the video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_set_video_vertical_downscale_enable(int enable)
#else
void
gfx_set_video_vertical_downscale_enable(int enable)
#endif
{
/* SET VIDEO SCALE IN DISPLAY CONTROLLER */
/* Use private routine to abstract hardware */
gfx_set_display_video_vertical_downscale_enable(enable);
}
/*---------------------------------------------------------------------------
* gfx_set_video_downscale_config
*
* This routine sets the downscale type and factor for the video overlay window.
* Note: No downscaling support for RGB565 and YUV420 video formats.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_downscale_config(unsigned short type, unsigned short m)
#else
int
gfx_set_video_downscale_config(unsigned short type, unsigned short m)
#endif
{
unsigned long downscale;
if ((m < 1) || (m > 16))
return GFX_STATUS_BAD_PARAMETER;
downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL);
downscale &=
~(RCDF_VIDEO_DOWNSCALE_FACTOR_MASK | RCDF_VIDEO_DOWNSCALE_TYPE_MASK);
downscale |= ((unsigned long)(m - 1) << RCDF_VIDEO_DOWNSCALE_FACTOR_POS);
switch (type) {
case VIDEO_DOWNSCALE_KEEP_1_OF:
downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_A;
break;
case VIDEO_DOWNSCALE_DROP_1_OF:
downscale |= RCDF_VIDEO_DOWNSCALE_TYPE_B;
break;
default:
return GFX_STATUS_BAD_PARAMETER;
}
WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_downscale_coefficients
*
* This routine sets the downscale filter coefficients.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_downscale_coefficients(unsigned short coef1,
unsigned short coef2,
unsigned short coef3,
unsigned short coef4)
#else
int
gfx_set_video_downscale_coefficients(unsigned short coef1,
unsigned short coef2,
unsigned short coef3,
unsigned short coef4)
#endif
{
if ((coef1 + coef2 + coef3 + coef4) != 16)
return GFX_STATUS_BAD_PARAMETER;
WRITE_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS,
((unsigned long)coef1 << RCDF_VIDEO_DOWNSCALER_COEF1_POS) |
((unsigned long)coef2 << RCDF_VIDEO_DOWNSCALER_COEF2_POS) |
((unsigned long)coef3 << RCDF_VIDEO_DOWNSCALER_COEF3_POS) |
((unsigned long)coef4 << RCDF_VIDEO_DOWNSCALER_COEF4_POS));
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_downscale_enable
*
* This routine enables or disables downscaling for the video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_downscale_enable(int enable)
#else
int
gfx_set_video_downscale_enable(int enable)
#endif
{
unsigned long downscale;
downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL);
if (enable)
downscale |= RCDF_VIDEO_DOWNSCALE_ENABLE;
else
downscale &= ~RCDF_VIDEO_DOWNSCALE_ENABLE;
WRITE_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL, downscale);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_window
*
* This routine sets the position and size of the video overlay window. The
* x and y positions are specified in screen relative coordinates, and may be negative.
* The size of destination region is specified in pixels. The line size
* indicates the number of bytes of source data per scanline.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_window(short x, short y, unsigned short w,
unsigned short h)
#else
int
gfx_set_video_window(short x, short y, unsigned short w, unsigned short h)
#endif
{
unsigned long hadjust, vadjust;
unsigned long xstart, ystart, xend, yend;
/* SAVE PARAMETERS */
/* These are needed to call this routine if the scale value changes. */
gfx_vid_xpos = x;
gfx_vid_ypos = y;
gfx_vid_width = w;
gfx_vid_height = h;
/* GET ADJUSTMENT VALUES */
/* Use routines to abstract version of display controller. */
hadjust = gfx_get_htotal() - gfx_get_hsync_end() - 14l;
vadjust = gfx_get_vtotal() - gfx_get_vsync_end() + 1l;
/* HORIZONTAL START */
xstart = (unsigned long)x + hadjust;
/* HORIZONTAL END */
/* End positions in register are non-inclusive (one more than the actual end) */
if ((x + w) < gfx_get_hactive())
xend = (unsigned long)x + (unsigned long)w + hadjust;
/* RIGHT-CLIPPING */
else
xend = (unsigned long)gfx_get_hactive() + hadjust;
/* VERTICAL START */
ystart = (unsigned long)y + vadjust;
/* VERTICAL END */
if ((y + h) < gfx_get_vactive())
yend = (unsigned long)y + (unsigned long)h + vadjust;
/* BOTTOM-CLIPPING */
else
yend = (unsigned long)gfx_get_vactive() + vadjust;
/* SET VIDEO POSITION */
WRITE_VID32(RCDF_VIDEO_X_POS, (xend << 16) | xstart);
WRITE_VID32(RCDF_VIDEO_Y_POS, (yend << 16) | ystart);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_left_crop
*
* This routine sets the number of pixels which will be cropped from the
* beginning of each video line. The video window will begin to display only
* from the pixel following the cropped pixels, and the cropped pixels
* will be ignored.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_left_crop(unsigned short x)
#else
int
gfx_set_video_left_crop(unsigned short x)
#endif
{
unsigned long vcfg, initread;
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
/* CLIPPING ON LEFT */
/* Adjust initial read for scale, checking for divide by zero. Mask the */
/* lower three bits when clipping 4:2:0 video. By masking the bits instead */
/* of rounding up we ensure that we always clip less than or equal to the */
/* desired number of pixels. This prevents visual artifacts from */
/* over-clipping. We mask three bits to meet the HW requirement that 4:2:0 */
/* clipping be 16-byte or 8-pixel aligned. */
if (gfx_vid_dstw) {
initread = (unsigned long)x *gfx_vid_srcw / gfx_vid_dstw;
if (vcfg & RCDF_VCFG_4_2_0_MODE)
initread &= 0xFFF8;
} else
initread = 0;
/* SET INITIAL READ ADDRESS */
vcfg &= ~RCDF_VCFG_INIT_READ_MASK;
vcfg |= (initread << 15) & RCDF_VCFG_INIT_READ_MASK;
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_color_key
*
* This routine specifies the color key value and mask for the video overlay
* hardware. To disable color key, the color and mask should both be set to
* zero. The hardware uses the color key in the following equation:
*
* ((source data) & (color key mask)) == ((color key) & (color key mask))
*
* If "graphics" is set to TRUE, the source data is graphics, and color key
* is an RGB value. If "graphics" is set to FALSE, the source data is the video,
* and color key is a YUV value.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_color_key(unsigned long key, unsigned long mask,
int graphics)
#else
int
gfx_set_video_color_key(unsigned long key, unsigned long mask, int graphics)
#endif
{
unsigned long dcfg = 0;
/* SET RCDF COLOR KEY VALUE */
WRITE_VID32(RCDF_VIDEO_COLOR_KEY, key);
WRITE_VID32(RCDF_VIDEO_COLOR_MASK, mask);
/* SELECT GRAPHICS OR VIDEO DATA TO COMPARE TO THE COLOR KEY */
dcfg = READ_VID32(RCDF_DISPLAY_CONFIG);
if (graphics & 0x01)
dcfg &= ~RCDF_DCFG_VG_CK;
else
dcfg |= RCDF_DCFG_VG_CK;
WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_filter
*
* This routine enables or disables the video overlay filters.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_filter(int xfilter, int yfilter)
#else
int
gfx_set_video_filter(int xfilter, int yfilter)
#endif
{
unsigned long vcfg = 0;
/* ENABLE OR DISABLE DISPLAY FILTER VIDEO OVERLAY FILTERS */
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
vcfg &= ~(RCDF_VCFG_X_FILTER_EN | RCDF_VCFG_Y_FILTER_EN);
if (xfilter)
vcfg |= RCDF_VCFG_X_FILTER_EN;
if (yfilter)
vcfg |= RCDF_VCFG_Y_FILTER_EN;
WRITE_VID32(RCDF_VIDEO_CONFIG, vcfg);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_palette
*
* This routine loads the video hardware palette. If a NULL pointer is
* specified, the palette is bypassed (for Redcloud, this means loading the
* palette with identity values).
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_palette(unsigned long *palette)
#else
int
gfx_set_video_palette(unsigned long *palette)
#endif
{
unsigned long i, entry;
/* LOAD REDCLOUD VIDEO PALETTE */
WRITE_VID32(RCDF_PALETTE_ADDRESS, 0);
for (i = 0; i < 256; i++) {
if (palette)
entry = palette[i];
else
entry = i | (i << 8) | (i << 16);
WRITE_VID32(RCDF_PALETTE_DATA, entry);
}
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_palette_entry
*
* This routine loads a single entry of the video hardware palette.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_palette_entry(unsigned long index, unsigned long palette)
#else
int
gfx_set_video_palette_entry(unsigned long index, unsigned long palette)
#endif
{
if (index > 0xFF)
return GFX_STATUS_BAD_PARAMETER;
/* SET A SINGLE ENTRY */
WRITE_VID32(RCDF_PALETTE_ADDRESS, index);
WRITE_VID32(RCDF_PALETTE_DATA, palette);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_request()
*
* This routine sets the horizontal (pixel) and vertical (line) video request
* values.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_request(short x, short y)
#else
int
gfx_set_video_request(short x, short y)
#endif
{
/* SET DISPLAY FILTER VIDEO REQUEST */
x += gfx_get_htotal() - gfx_get_hsync_end() - 2;
y += gfx_get_vtotal() - gfx_get_vsync_end() + 1;
if ((x < 0) || (x > RCDF_VIDEO_REQUEST_MASK) ||
(y < 0) || (y > RCDF_VIDEO_REQUEST_MASK))
return GFX_STATUS_BAD_PARAMETER;
WRITE_VID32(RCDF_VIDEO_REQUEST,
((unsigned long)x << RCDF_VIDEO_X_REQUEST_POS) |
((unsigned long)y << RCDF_VIDEO_Y_REQUEST_POS));
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_cursor()
*
* This routine configures the video hardware cursor.
* If the "mask"ed bits in the graphics pixel match "key", then either "color1"
* or "color2" will be used for this pixel, according to the value of bit
* number "select_color2" of the graphics pixel.
*
* key - 24 bit RGB value
* mask - 24 bit mask
* color1, color2 - RGB or YUV, depending on the current color space conversion
* select_color2 - value between 0 to 23
*
* To disable match, a "mask" and "key" value of 0xffffff should be set,
* because the graphics pixels incoming to the video processor have maximum 16
* bits set (0xF8FCF8).
*
* This feature is useful for disabling alpha blending of the cursor.
* Otherwise cursor image would be blurred (or completely invisible if video
* alpha is maximum value).
* Note: the cursor pixel replacements take place both inside and outside the
* video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_cursor(unsigned long key, unsigned long mask,
unsigned short select_color2, unsigned long color1,
unsigned long color2)
#else
int
gfx_set_video_cursor(unsigned long key, unsigned long mask,
unsigned short select_color2, unsigned long color1,
unsigned long color2)
#endif
{
if (select_color2 > RCDF_CURSOR_COLOR_BITS)
return GFX_STATUS_BAD_PARAMETER;
key = (key & RCDF_COLOR_MASK) | ((unsigned long)select_color2 <<
RCDF_CURSOR_COLOR_KEY_OFFSET_POS);
WRITE_VID32(RCDF_CURSOR_COLOR_KEY, key);
WRITE_VID32(RCDF_CURSOR_COLOR_MASK, mask);
WRITE_VID32(RCDF_CURSOR_COLOR_1, color1);
WRITE_VID32(RCDF_CURSOR_COLOR_2, color2);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_video_cursor()
*
* This routine configures the video hardware cursor.
* If the "mask"ed bits in the graphics pixel match "key", then either "color1"
* or "color2" will be used for this pixel, according to the value of bit
* number "select_color2" of the graphics pixel.
*
* key - 24 bit RGB value
* mask - 24 bit mask
* color1, color2 - RGB or YUV, depending on the current color space conversion
* select_color2 - value between 0 to 23
*
* To disable match, a "mask" and "key" value of 0xffffff should be set,
* because the graphics pixels incoming to the video processor have maximum 16
* bits set (0xF8FCF8).
*
* This feature is useful for disabling alpha blending of the cursor.
* Otherwise cursor image would be blurred (or completely invisible if video
* alpha is maximum value).
* Note: the cursor pixel replacements take place both inside and outside the
* video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_video_cursor_enable(int enable)
#else
int
gfx_set_video_cursor_enable(int enable)
#endif
{
unsigned long temp = READ_VID32(RCDF_CURSOR_COLOR_KEY);
if (enable)
temp |= RCDF_CURSOR_COLOR_KEY_ENABLE;
else
temp &= ~RCDF_CURSOR_COLOR_KEY_ENABLE;
WRITE_VID32(RCDF_CURSOR_COLOR_KEY, temp);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_enable
*
* This routine enables or disables the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_enable(int enable)
#else
int
gfx_set_alpha_enable(int enable)
#endif
{
unsigned long address = 0, value = 0;
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
address = RCDF_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 5);
value = READ_VID32(address);
if (enable)
value |= RCDF_ACTRL_WIN_ENABLE;
else
value &= ~(RCDF_ACTRL_WIN_ENABLE);
WRITE_VID32(address, value);
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_window
*
* This routine sets the size of the currently selected alpha region.
* Note: "x" and "y" are signed to enable using negative values needed for
* implementing workarounds of hardware issues.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_window(short x, short y,
unsigned short width, unsigned short height)
#else
int
gfx_set_alpha_window(short x, short y,
unsigned short width, unsigned short height)
#endif
{
unsigned long address = 0;
/* CHECK FOR CLIPPING */
if ((x + width) > gfx_get_hactive())
width = gfx_get_hactive() - x;
if ((y + height) > gfx_get_vactive())
height = gfx_get_vactive() - y;
/* ADJUST POSITIONS */
x += gfx_get_htotal() - gfx_get_hsync_end() - 2;
y += gfx_get_vtotal() - gfx_get_vsync_end() + 1;
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
address = RCDF_ALPHA_XPOS_1 + ((unsigned long)gfx_alpha_select << 5);
/* END POSITIONS IN REGISTERS ARE NON-INCLUSIVE (ONE MORE THAN ACTUAL END) */
WRITE_VID32(address, (unsigned long)x |
((unsigned long)(x + width) << 16));
WRITE_VID32(address + 8, (unsigned long)y |
((unsigned long)(y + height) << 16));
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_value
*
* This routine sets the alpha value for the currently selected alpha
* region. It also specifies an increment/decrement value for fading.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_value(unsigned char alpha, char delta)
#else
int
gfx_set_alpha_value(unsigned char alpha, char delta)
#endif
{
unsigned long address = 0, value = 0;
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
address = RCDF_ALPHA_CONTROL_1 + ((unsigned long)gfx_alpha_select << 5);
value = READ_VID32(address);
value &= RCDF_ACTRL_WIN_ENABLE; /* keep only enable bit */
value |= (unsigned long)alpha;
value |= (((unsigned long)delta) & 0xff) << 8;
value |= RCDF_ACTRL_LOAD_ALPHA;
WRITE_VID32(address, value);
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_priority
*
* This routine sets the priority of the currently selected alpha region.
* A higher value indicates a higher priority.
* Note: Priority of enabled alpha windows must be different.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_priority(int priority)
#else
int
gfx_set_alpha_priority(int priority)
#endif
{
unsigned long pos = 0, value = 0;
if (priority > 3)
return (GFX_STATUS_BAD_PARAMETER);
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
value = READ_VID32(RCDF_VID_ALPHA_CONTROL);
pos = 16 + (gfx_alpha_select << 1);
value &= ~(0x03l << pos);
value |= (unsigned long)priority << pos;
WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value);
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_color
*
* This routine sets the color to be displayed inside the currently selected
* alpha window when there is a color key match (when the alpha color
* mechanism is enabled).
* "color" is an RGB value (for RGB blending) or a YUV value (for YUV blending).
* In Interlaced YUV blending mode, Y/2 value should be used.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_color(unsigned long color)
#else
int
gfx_set_alpha_color(unsigned long color)
#endif
{
unsigned long address = 0;
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
address = RCDF_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 5);
WRITE_VID32(address, color);
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_alpha_color_enable
*
* Enable or disable the color mechanism in the alpha window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_alpha_color_enable(int enable)
#else
int
gfx_set_alpha_color_enable(int enable)
#endif
{
unsigned long color;
unsigned long address = 0;
if (gfx_alpha_select > 2)
return (GFX_STATUS_UNSUPPORTED);
address = RCDF_ALPHA_COLOR_1 + ((unsigned long)gfx_alpha_select << 5);
color = READ_VID32(address);
if (enable)
color |= RCDF_ALPHA_COLOR_ENABLE;
else
color &= ~RCDF_ALPHA_COLOR_ENABLE;
WRITE_VID32(address, color);
return (GFX_STATUS_OK);
}
/*---------------------------------------------------------------------------
* gfx_set_no_ck_outside_alpha
*
* This function affects where inside the video window color key or chroma
* key comparison is done:
* If enable is TRUE, color/chroma key comparison is performed only inside
* the enabled alpha windows. Outside the (enabled) alpha windows, only video
* is displayed if color key is used, and only graphics is displayed if chroma
* key is used.
* If enable is FALSE, color/chroma key comparison is performed in all the
* video window area.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_set_no_ck_outside_alpha(int enable)
#else
int
gfx_set_no_ck_outside_alpha(int enable)
#endif
{
unsigned long value;
value = READ_VID32(RCDF_VID_ALPHA_CONTROL);
if (enable)
WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value | RCDF_NO_CK_OUTSIDE_ALPHA);
else
WRITE_VID32(RCDF_VID_ALPHA_CONTROL, value & ~RCDF_NO_CK_OUTSIDE_ALPHA);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_get_clock_frequency
*
* This routine returns the current clock frequency in 16.16 format.
* It reads the current register value and finds the match in the table.
* If no match is found, this routine returns 0.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_clock_frequency(void)
#else
unsigned long
gfx_get_clock_frequency(void)
#endif
{
Q_WORD msr_value;
RCDFPLLENTRY *PLLTable;
unsigned int index;
unsigned long value, mask = 0x00001FFF;
unsigned long post_div3 = 0, pre_mult2 = 0;
/* READ PLL SETTING */
gfx_msr_read(RC_ID_MCP, MCP_DOTPLL, &msr_value);
value = msr_value.high & mask;
/* READ DIVISOR SETTINGS */
if ((gfx_cpu_version & 0xFF00) == 0x200) {
PLLTable = RCDF_PLLtable48MHz;
gfx_msr_read(RC_ID_MCP, MCP_SYS_RSTPLL, &msr_value);
post_div3 = (msr_value.low & MCP_DOTPOSTDIV3) ? 1 : 0;
pre_mult2 = (msr_value.low & MCP_DOTPREMULT2) ? 1 : 0;
} else
PLLTable = RCDF_PLLtable14MHz;
/* SEARCH FOR A MATCH */
for (index = 0; index < NUM_RCDF_FREQUENCIES; index++) {
if ((PLLTable[index].pll_value & mask) == value &&
post_div3 == PLLTable[index].post_div3 &&
pre_mult2 == PLLTable[index].pre_mul2)
return (PLLTable[index].frequency);
}
return (0);
}
/*************************************************************/
/* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */
/*************************************************************/
#if GFX_READ_ROUTINES
/*---------------------------------------------------------------------------
* gfx_get_sync_polarities
*
* This routine returns the polarities of the sync pulses:
* Bit 0: Set if negative horizontal polarity.
* Bit 1: Set if negative vertical polarity.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_sync_polarities(void)
#else
int
gfx_get_sync_polarities(void)
#endif
{
int polarities = 0;
if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_HSYNC_POL)
polarities |= 1;
if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_CRT_VSYNC_POL)
polarities |= 2;
return (polarities);
}
/*---------------------------------------------------------------------------
* gfx_get_video_palette_entry
*
* This routine returns a single palette entry.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_palette_entry(unsigned long index, unsigned long *palette)
#else
int
gfx_get_video_palette_entry(unsigned long index, unsigned long *palette)
#endif
{
if (index > 0xFF)
return GFX_STATUS_BAD_PARAMETER;
/* READ A SINGLE ENTRY */
WRITE_VID32(RCDF_PALETTE_ADDRESS, index);
*palette = READ_VID32(RCDF_PALETTE_DATA);
return (GFX_STATUS_OK);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_enable
*
* This routine returns the value "one" if video overlay is currently enabled,
* otherwise it returns the value "zero".
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_enable(void)
#else
int
gfx_get_video_enable(void)
#endif
{
if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_VID_EN)
return (1);
return (0);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_format
*
* This routine returns the current video overlay format.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_format(void)
#else
int
gfx_get_video_format(void)
#endif
{
unsigned long ctrl, vcfg;
ctrl = READ_VID32(RCDF_VID_ALPHA_CONTROL);
vcfg = READ_VID32(RCDF_VIDEO_CONFIG);
if (ctrl & RCDF_VIDEO_INPUT_IS_RGB) {
switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) {
case RCDF_VCFG_UYVY_FORMAT:
return VIDEO_FORMAT_RGB;
case RCDF_VCFG_Y2YU_FORMAT:
return VIDEO_FORMAT_P2M_P2L_P1M_P1L;
case RCDF_VCFG_YUYV_FORMAT:
return VIDEO_FORMAT_P1M_P1L_P2M_P2L;
case RCDF_VCFG_YVYU_FORMAT:
return VIDEO_FORMAT_P1M_P2L_P2M_P1L;
}
}
if (vcfg & RCDF_VCFG_4_2_0_MODE) {
switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) {
case RCDF_VCFG_UYVY_FORMAT:
return VIDEO_FORMAT_Y0Y1Y2Y3;
case RCDF_VCFG_Y2YU_FORMAT:
return VIDEO_FORMAT_Y3Y2Y1Y0;
case RCDF_VCFG_YUYV_FORMAT:
return VIDEO_FORMAT_Y1Y0Y3Y2;
case RCDF_VCFG_YVYU_FORMAT:
return VIDEO_FORMAT_Y1Y2Y3Y0;
}
} else {
switch (vcfg & RCDF_VCFG_VID_INP_FORMAT) {
case RCDF_VCFG_UYVY_FORMAT:
return VIDEO_FORMAT_UYVY;
case RCDF_VCFG_Y2YU_FORMAT:
return VIDEO_FORMAT_Y2YU;
case RCDF_VCFG_YUYV_FORMAT:
return VIDEO_FORMAT_YUYV;
case RCDF_VCFG_YVYU_FORMAT:
return VIDEO_FORMAT_YVYU;
}
}
return (GFX_STATUS_ERROR);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_src_size
*
* This routine returns the size of the source video overlay buffer. The
* return value is (height << 16) | width.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_src_size(void)
#else
unsigned long
gfx_get_video_src_size(void)
#endif
{
unsigned long width, height, scale, delta;
int down_enable;
/* DETERMINE SOURCE WIDTH FROM THE DISPLAY FILTER VIDEO LINE SIZE */
width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE;
if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER)
width += 512l;
/* DETERMINE SOURCE HEIGHT FROM THE DISPLAY FILTER HEIGHT AND SCALE VALUES */
/* There is no true "source buffer size" in Redcloud. Instead, the VG module */
/* provides video data as needed on a per-line basis. The source buffer size */
/* is always assumed to equal the amount of required video data. The returned */
/* height is equal to the height of the required video buffer data (before all */
/* scaling.) */
scale = (READ_VID32(RCDF_VIDEO_SCALE) >> 16) & 0x3FFF;
height = ((READ_VID32(RCDF_VIDEO_Y_POS) >> 16) & 0x7FF) -
(READ_VID32(RCDF_VIDEO_Y_POS) & 0x7FF);
delta = gfx_get_video_downscale_delta();
down_enable = gfx_get_video_vertical_downscale_enable();
/* REVERSE UPSCALING */
if (height)
height = ((scale * (height - 1l)) / 0x2000l) + 2l;
/* REVERSE DOWNSCALING */
/* Original lines = height * (0x3FFF + delta) / 0x3FFF */
/* As this may cause rounding errors, we add 1 to the */
/* returned source size. The return value of this */
/* function could thus be off by 1. */
if (down_enable && height)
height = ((height * (0x3FFFl + delta)) / 0x3FFFl) + 1;
return ((height << 16) | width);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_line_size
*
* This routine returns the line size of the source video overlay buffer, in
* pixels.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_line_size(void)
#else
unsigned long
gfx_get_video_line_size(void)
#endif
{
unsigned long width = 0;
/* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */
width = (READ_VID32(RCDF_VIDEO_CONFIG) >> 7) & 0x000001FE;
if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_LINE_SIZE_UPPER)
width += 512l;
return (width);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_xclip
*
* This routine returns the number of bytes clipped on the left side of a
* video overlay line (skipped at beginning).
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_xclip(void)
#else
unsigned long
gfx_get_video_xclip(void)
#endif
{
unsigned long clip = 0;
/* DETERMINE SOURCE WIDTH FROM THE RCDF VIDEO LINE SIZE */
clip = (READ_VID32(RCDF_VIDEO_CONFIG) >> 14) & 0x000007FC;
return (clip);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_offset
*
* This routine returns the current offset for the video overlay buffer.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_offset(void)
#else
unsigned long
gfx_get_video_offset(void)
#endif
{
return (gfx_get_display_video_offset());
}
/*-----------------------------------------------------------------------------
* gfx_get_video_yuv_offsets
*
* This routine returns the current offsets for the video overlay buffer when in 4:2:0.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_video_yuv_offsets(unsigned long *yoffset, unsigned long *uoffset,
unsigned long *voffset)
#else
void
gfx_get_video_yuv_offsets(unsigned long *yoffset, unsigned long *uoffset,
unsigned long *voffset)
#endif
{
gfx_get_display_video_yuv_offsets(yoffset, uoffset, voffset);
}
/*-----------------------------------------------------------------------------
* gfx_get_video_yuv_pitch
*
* This routine returns the current pitch values for the video overlay buffer.
*-----------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch)
#else
void
gfx_get_video_yuv_pitch(unsigned long *ypitch, unsigned long *uvpitch)
#endif
{
gfx_get_display_video_yuv_pitch(ypitch, uvpitch);
}
/*---------------------------------------------------------------------------
* gfx_get_video_scale
*
* This routine returns the scale factor for the video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_scale(void)
#else
unsigned long
gfx_get_video_scale(void)
#endif
{
return (READ_VID32(RCDF_VIDEO_SCALE));
}
/*---------------------------------------------------------------------------
* gfx_get_video_downscale_delta
*
* This routine returns the vertical downscale factor for the video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_downscale_delta(void)
#else
unsigned long
gfx_get_video_downscale_delta(void)
#endif
{
/* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */
return (gfx_get_display_video_downscale_delta());
}
/*---------------------------------------------------------------------------
* gfx_get_video_vertical_downscale_enable
*
* This routine returns the vertical downscale enable for the video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_vertical_downscale_enable(void)
#else
int
gfx_get_video_vertical_downscale_enable(void)
#endif
{
/* USE PRIVATE ROUTINE TO ABSTRACT THE DIPSLAY CONTROLLER */
return (gfx_get_display_video_downscale_enable());
}
/*---------------------------------------------------------------------------
* gfx_get_video_downscale_config
*
* This routine returns the current type and value of video downscaling.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_downscale_config(unsigned short *type, unsigned short *m)
#else
int
gfx_get_video_downscale_config(unsigned short *type, unsigned short *m)
#endif
{
unsigned long downscale;
downscale = READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL);
*m = (unsigned short)((downscale & RCDF_VIDEO_DOWNSCALE_FACTOR_MASK) >>
RCDF_VIDEO_DOWNSCALE_FACTOR_POS) + 1;
switch (downscale & RCDF_VIDEO_DOWNSCALE_TYPE_MASK) {
case RCDF_VIDEO_DOWNSCALE_TYPE_A:
*type = VIDEO_DOWNSCALE_KEEP_1_OF;
break;
case RCDF_VIDEO_DOWNSCALE_TYPE_B:
*type = VIDEO_DOWNSCALE_DROP_1_OF;
break;
default:
return GFX_STATUS_ERROR;
break;
}
return (0);
}
/*---------------------------------------------------------------------------
* gfx_get_video_downscale_coefficients
*
* This routine returns the current video downscaling coefficients.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_video_downscale_coefficients(unsigned short *coef1,
unsigned short *coef2,
unsigned short *coef3,
unsigned short *coef4)
#else
void
gfx_get_video_downscale_coefficients(unsigned short *coef1,
unsigned short *coef2,
unsigned short *coef3,
unsigned short *coef4)
#endif
{
unsigned long coef;
coef = READ_VID32(RCDF_VIDEO_DOWNSCALER_COEFFICIENTS);
*coef1 =
(unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF1_POS) &
RCDF_VIDEO_DOWNSCALER_COEF_MASK);
*coef2 =
(unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF2_POS) &
RCDF_VIDEO_DOWNSCALER_COEF_MASK);
*coef3 =
(unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF3_POS) &
RCDF_VIDEO_DOWNSCALER_COEF_MASK);
*coef4 =
(unsigned short)((coef >> RCDF_VIDEO_DOWNSCALER_COEF4_POS) &
RCDF_VIDEO_DOWNSCALER_COEF_MASK);
return;
}
/*---------------------------------------------------------------------------
* gfx_get_video_downscale_enable
*
* This routine returns 1 if video downscaling is currently enabled,
* or 0 if it is currently disabled.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_video_downscale_enable(int *enable)
#else
void
gfx_get_video_downscale_enable(int *enable)
#endif
{
if (READ_VID32(RCDF_VIDEO_DOWNSCALER_CONTROL) &
RCDF_VIDEO_DOWNSCALE_ENABLE)
*enable = 1;
else
*enable = 0;
return;
}
/*---------------------------------------------------------------------------
* gfx_get_video_dst_size
*
* This routine returns the size of the displayed video overlay window.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_dst_size(void)
#else
unsigned long
gfx_get_video_dst_size(void)
#endif
{
unsigned long xsize, ysize;
xsize = READ_VID32(RCDF_VIDEO_X_POS);
xsize = ((xsize >> 16) & 0x7FF) - (xsize & 0x7FF);
ysize = READ_VID32(RCDF_VIDEO_Y_POS);
ysize = ((ysize >> 16) & 0x7FF) - (ysize & 0x7FF);
return ((ysize << 16) | xsize);
}
/*---------------------------------------------------------------------------
* gfx_get_video_position
*
* This routine returns the position of the video overlay window. The
* return value is (ypos << 16) | xpos.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_position(void)
#else
unsigned long
gfx_get_video_position(void)
#endif
{
unsigned long hadjust, vadjust;
unsigned long xpos, ypos;
/* READ HARDWARE POSITION */
xpos = READ_VID32(RCDF_VIDEO_X_POS) & 0x000007FF;
ypos = READ_VID32(RCDF_VIDEO_Y_POS) & 0x000007FF;
/* GET ADJUSTMENT VALUES */
/* Use routines to abstract version of display controller. */
hadjust =
(unsigned long)gfx_get_htotal() -
(unsigned long)gfx_get_hsync_end() - 14l;
vadjust =
(unsigned long)gfx_get_vtotal() -
(unsigned long)gfx_get_vsync_end() + 1l;
xpos -= hadjust;
ypos -= vadjust;
return ((ypos << 16) | (xpos & 0x0000FFFF));
}
/*---------------------------------------------------------------------------
* gfx_get_video_color_key
*
* This routine returns the current video color key value.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_color_key(void)
#else
unsigned long
gfx_get_video_color_key(void)
#endif
{
return (READ_VID32(RCDF_VIDEO_COLOR_KEY));
}
/*---------------------------------------------------------------------------
* gfx_get_video_color_key_mask
*
* This routine returns the current video color mask value.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_get_video_color_key_mask(void)
#else
unsigned long
gfx_get_video_color_key_mask(void)
#endif
{
return (READ_VID32(RCDF_VIDEO_COLOR_MASK));
}
/*---------------------------------------------------------------------------
* gfx_get_video_color_key_src
*
* This routine returns 0 for video data compare, 1 for graphics data.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_color_key_src(void)
#else
int
gfx_get_video_color_key_src(void)
#endif
{
if (READ_VID32(RCDF_DISPLAY_CONFIG) & RCDF_DCFG_VG_CK)
return (0);
return (1);
}
/*---------------------------------------------------------------------------
* gfx_get_video_filter
*
* This routine returns if the filters are currently enabled.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_filter(void)
#else
int
gfx_get_video_filter(void)
#endif
{
int retval = 0;
if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_X_FILTER_EN)
retval |= 1;
if (READ_VID32(RCDF_VIDEO_CONFIG) & RCDF_VCFG_Y_FILTER_EN)
retval |= 2;
return (retval);
}
/*---------------------------------------------------------------------------
* gfx_get_video_request
*
* This routine returns the horizontal (pixel) and vertical (lines) video
* request values.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_request(short *x, short *y)
#else
int
gfx_get_video_request(short *x, short *y)
#endif
{
unsigned long request = 0;
request = (READ_VID32(RCDF_VIDEO_REQUEST));
*x = (short)((request >> RCDF_VIDEO_X_REQUEST_POS) &
RCDF_VIDEO_REQUEST_MASK);
*y = (short)((request >> RCDF_VIDEO_Y_REQUEST_POS) &
RCDF_VIDEO_REQUEST_MASK);
*x -= gfx_get_htotal() - gfx_get_hsync_end() - 2;
*y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1;
return (0);
}
/*---------------------------------------------------------------------------
* gfx_get_video_cursor()
*
* This routine configures the video hardware cursor.
* If the "mask"ed bits in the graphics pixel match "key", then either "color1"
* or "color2" will be used for this pixel, according to the value of the bit
* in offset "select_color2".
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
int
redcloud_get_video_cursor(unsigned long *key, unsigned long *mask,
unsigned short *select_color2,
unsigned long *color1, unsigned short *color2)
#else
int
gfx_get_video_cursor(unsigned long *key, unsigned long *mask,
unsigned short *select_color2, unsigned long *color1,
unsigned short *color2)
#endif
{
*select_color2 =
(unsigned short)(READ_VID32(RCDF_CURSOR_COLOR_KEY) >>
RCDF_CURSOR_COLOR_KEY_OFFSET_POS);
*key = READ_VID32(RCDF_CURSOR_COLOR_KEY) & RCDF_COLOR_MASK;
*mask = READ_VID32(RCDF_CURSOR_COLOR_MASK) & RCDF_COLOR_MASK;
*color1 = READ_VID32(RCDF_CURSOR_COLOR_1) & RCDF_COLOR_MASK;
*color2 =
(unsigned short)(READ_VID32(RCDF_CURSOR_COLOR_2) & RCDF_COLOR_MASK);
return (0);
}
/*---------------------------------------------------------------------------
* gfx_read_crc
*
* This routine returns the hardware CRC value, which is used for automated
* testing. The value is like a checksum, but will change if pixels move
* locations.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_read_crc(void)
#else
unsigned long
gfx_read_crc(void)
#endif
{
Q_WORD msr_value;
unsigned long crc = 0xFFFFFFFF;
/* DISABLE 32-BIT CRCS */
/* For GX1.x, this is a reserved bit, and is assumed to be a benign access */
gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value);
msr_value.low &= ~RCDF_DIAG_32BIT_CRC;
gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value);
if (gfx_test_timing_active()) {
/* WAIT UNTIL ACTIVE DISPLAY */
while (!gfx_test_vertical_active()) ;
/* RESET CRC DURING ACTIVE DISPLAY */
WRITE_VID32(RCDF_VID_CRC, 0);
WRITE_VID32(RCDF_VID_CRC, 1);
/* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
crc = READ_VID32(RCDF_VID_CRC) >> 8;
}
return (crc);
}
/*---------------------------------------------------------------------------
* gfx_read_crc32
*
* This routine returns the 32-bit hardware CRC value, which is used for automated
* testing. The value is like a checksum, but will change if pixels move
* locations.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_read_crc32(void)
#else
unsigned long
gfx_read_crc32(void)
#endif
{
Q_WORD msr_value;
unsigned long crc = 0xFFFFFFFF;
/* ENABLE 32-BIT CRCS */
/* For GX1.x, this is a reserved bit, and is assumed to be a benign access */
gfx_msr_read(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value);
msr_value.low |= RCDF_DIAG_32BIT_CRC;
gfx_msr_write(RC_ID_DF, RCDF_MBD_MSR_DIAG_DF, &msr_value);
if (gfx_test_timing_active()) {
/* WAIT UNTIL ACTIVE DISPLAY */
while (!gfx_test_vertical_active()) ;
/* RESET CRC DURING ACTIVE DISPLAY */
WRITE_VID32(RCDF_VID_CRC, 0);
WRITE_VID32(RCDF_VID_CRC, 1);
/* WAIT UNTIL NOT ACTIVE, THEN ACTIVE, NOT ACTIVE, THEN ACTIVE */
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
crc = READ_VID32(RCDF_VID_CRC32);
}
return (crc);
}
/*---------------------------------------------------------------------------
* gfx_read_window_crc
*
* This routine returns the hardware CRC value for a subsection of the display.
* This value is used to debug whole-screen CRC failures.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
unsigned long
redcloud_read_window_crc(int source, unsigned short x, unsigned short y,
unsigned short width, unsigned short height,
int crc32)
#else
unsigned long
gfx_read_window_crc(int source, unsigned short x, unsigned short y,
unsigned short width, unsigned short height, int crc32)
#endif
{
Q_WORD msr_value;
unsigned long xpos, ypos, crc = 0;
unsigned long old_fmt = 0;
unsigned int vsync_active_base, vsync_inactive_base, hsync_active_base;
unsigned int vsync_active_shift, vsync_inactive_shift, hsync_active_shift;
unsigned int vsync_bit, hsync_bit, sync_polarities = 0;
/* CONFIGURE DISPLAY FILTER TO LOAD DATA ONTO LOWER 32-BITS */
msr_value.high = 0;
msr_value.low =
(source == CRC_SOURCE_GFX_DATA) ? (RCDF_MBD_DIAG_EN0 | 0x0000000F)
: (RCDF_MBD_DIAG_EN0 | 0x0000000B);
gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value);
/* CONFIGURE DISPLAY FILTER FOR APPROPRIATE OUTPUT */
if (source != CRC_SOURCE_GFX_DATA) {
gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value);
old_fmt = msr_value.low;
msr_value.low &= ~(RCDF_CONFIG_FMT_MASK);
msr_value.low |= ((source == CRC_SOURCE_FP_DATA) ? RCDF_CONFIG_FMT_FP :
RCDF_CONFIG_FMT_CRT);
gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value);
}
/* CONFIGURE MCP TO LOAD REGB DATA ONTO UPPER 32-BITS */
msr_value.low = MCP_MBD_DIAG_EN1 | 0x00050000;
gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value);
/* ENABLE HW CLOCK GATING AND SET MCP CLOCK TO DOT CLOCK */
msr_value.low = 1l;
gfx_msr_write(RC_ID_MCP, MBD_MSR_PM, &msr_value);
msr_value.low = 0;
gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value);
msr_value.low = 3;
gfx_msr_write(RC_ID_MCP, MCP_DBGCLKCTL, &msr_value);
/* DISABLE MCP ACTIONS */
msr_value.high = 0x00000000;
msr_value.low = 0x00000000;
gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value);
/* SET APPROPRIATE BASE ADDRESS */
/* M-Sets use normal diag bits, while N-Sets use inverted diag bits */
/* We thus use the M-sets when polling for a high signal and the N */
/* sets when polling for a low signal. */
if (source != CRC_SOURCE_GFX_DATA) {
sync_polarities = gfx_get_sync_polarities();
vsync_bit = 29;
hsync_bit = 30;
} else {
vsync_bit = 25;
hsync_bit = 26;
}
if (sync_polarities & 1) {
hsync_active_base = MCP_SETM0CTL;
hsync_active_shift = 2;
} else {
hsync_active_base = MCP_SETN0CTL;
hsync_active_shift = 1;
}
if (sync_polarities & 2) {
vsync_active_base = MCP_SETM0CTL;
vsync_inactive_base = MCP_SETN0CTL;
vsync_active_shift = 2;
vsync_inactive_shift = 1;
} else {
vsync_active_base = MCP_SETN0CTL;
vsync_inactive_base = MCP_SETM0CTL;
vsync_active_shift = 1;
vsync_inactive_shift = 2;
}
/* SET STATE TRANSITIONS */
/* STATE 0-1 TRANSITION (SET 0) */
/* XState = 00 and VSync Inactive */
/* Note: DF VSync = Diag Bus Bit 29 */
/* VG VSync = Diag Bus Bit 25 */
msr_value.low = 0x000000A0;
msr_value.high = 0x00008000 | ((unsigned long)vsync_bit << 16) |
((unsigned long)vsync_bit << 21) | ((unsigned long)vsync_bit << 26);
gfx_msr_write(RC_ID_MCP, vsync_inactive_base, &msr_value);
/* STATE 1-2 TRANSITION (SET 4) */
/* XState = 01 and VSync Active */
msr_value.low = 0x000000C0;
gfx_msr_write(RC_ID_MCP, vsync_active_base + 4, &msr_value);
/* STATE 2-3 TRANSITION (SET 1) */
/* XState = 10 and VSync Inactive */
msr_value.low = 0x00000120;
gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 1, &msr_value);
/* HORIZONTAL COUNTER (SET 5) */
/* XState = 10 and HSync Active */
/* Notes: DF HSync = Diag Bus Bit 30 */
/* VG HSync = Diag Bus Bit 26 */
msr_value.high = 0x00008000 | ((unsigned long)hsync_bit << 16) |
((unsigned long)hsync_bit << 21) | ((unsigned long)hsync_bit << 26);
msr_value.low = 0x00000120;
gfx_msr_write(RC_ID_MCP, hsync_active_base + 5, &msr_value);
/* HORIZONTAL COUNTER RESET (SET 4) */
/* XState = 10 and H. Counter = limit */
/* Note: H. Counter is lower 16-bits of */
/* RegB. */
msr_value.high = 0x00000000;
msr_value.low = 0x00000128;
gfx_msr_write(RC_ID_MCP, vsync_inactive_base + 4, &msr_value);
/* CRC TRIGGER (SET 0) */
/* Cmp0 <= xpos < Cmp1 */
/* Cmp2 <= ypos < Cmp2 */
msr_value.high = 0x00000000;
msr_value.low = 0x10C20120;
gfx_msr_write(RC_ID_MCP, vsync_active_base, &msr_value);
/* SET COMPARATOR VALUES */
/* Note: The VG data outputs from the DF are delayed by one pixel clock. */
/* In this mode, we thus add one to horizontal comparator limits. */
/* COMPARATOR 0 */
/* Lower limit = xpos + (h_blank_pixels - 1) - 3 */
/* Notes: */
/* 1. 3 is the pipeline delay for MCP register */
/* data to access the diag bus */
/* 2. h_blank_pixels = HTOTAL - HSYNC_END */
xpos = (unsigned long)x + ((unsigned long)gfx_get_htotal() -
(unsigned long)gfx_get_hsync_end() - 1l) - 3l;
if (source == CRC_SOURCE_GFX_DATA)
xpos++;
msr_value.high = 0x00000000;
msr_value.low = xpos;
gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0, &msr_value);
/* COMPARATOR 1 */
/* Upper limit = xpos + width + (h_blank_pixels - 1) - 3 */
msr_value.low = xpos + (unsigned long)width;
gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 2, &msr_value);
/* COMPARATOR 2 */
/* Lower limit = ypos + v_blank_pixels */
/* Notes: */
/* 1. v_blank_pixels = VTOTAL - VSYNC_END */
ypos = (unsigned long)y + (unsigned long)gfx_get_vtotal() -
(unsigned long)gfx_get_vsync_end();
msr_value.low = ypos << 16;
gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 4, &msr_value);
/* COMPARATOR 3 */
/* Upper limit = ypos + height + v_blank_pixels */
msr_value.low = (ypos + (unsigned long)height) << 16;
gfx_msr_write(RC_ID_MCP, MCP_CMPVAL0 + 6, &msr_value);
/* SET COMPARATOR MASKS */
/* COMPARATORS 0 AND 1 REFER TO LOWER 16 BITS OF REGB */
msr_value.high = 0x00000000;
msr_value.low = 0x0000FFFF;
gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 2, &msr_value);
/* COMPARATORS 2 AND 3 REFER TO UPPER 16 BITS OF REGB */
msr_value.low = 0xFFFF0000;
gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 4, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_CMPMASK0 + 6, &msr_value);
/* SET REGA MASK TO CRC ONLY 24 BITS OF DATA */
msr_value.high = 0x00000000;
msr_value.low = 0x00FFFFFF;
gfx_msr_write(RC_ID_MCP, MCP_REGAMASK, &msr_value);
/* SET REGB VALUE */
/* Lower 16 bits use HTOTAL - SYNC TIME - 1 to set the counter rollover limit. */
/* Upper 16 bits use 0xFFFF to remove auto-clear behavior. */
msr_value.high = 0x00000000;
msr_value.low = 0xFFFF0000 |
((gfx_get_htotal() - (gfx_get_hsync_end() - gfx_get_hsync_start()) -
1) & 0xFFFF);
gfx_msr_write(RC_ID_MCP, MCP_REGBVAL, &msr_value);
/* PROGRAM ACTIONS */
/* GOTO STATE 01 */
msr_value.high = 0x00000000;
msr_value.low = 0x00000008 | (1l << vsync_inactive_shift);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 14, &msr_value);
/* GOTO STATE 10 */
msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16));
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 15, &msr_value);
/* GOTO STATE 11 */
msr_value.low = 0x00000080 | (1l << (vsync_inactive_shift + 4));
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 16, &msr_value);
/* CLEAR REGB (COUNTERS) */
/* RegB is cleared upon transitioning to state 10 */
/* RegA is not cleared as the initial value must be 0x00000001 */
msr_value.low = 0x00080000 | (1l << (vsync_active_shift + 16));
gfx_msr_write(RC_ID_MCP, MCP_ACTION0, &msr_value);
/* CRC INTO REGA */
/* INCREMENT H. COUNTER */
/* cmp0 <= xpos < cmp1 */
/* cmp2 <= ypos < cmp3 */
/* XState = 10 */
msr_value.low = 0x00000008 | (1l << vsync_active_shift) |
0x00800000 | (1l << (hsync_active_shift + 20));
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 1, &msr_value);
/* INCREMENT V. COUNTER */
/* V. Counter is incremented when the H. Counter */
/* rolls over. */
msr_value.low = 0x00080000 | (1l << (vsync_inactive_shift + 16));
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 2, &msr_value);
/* CLEAR ALL OTHER ACTIONS */
/* This prevents side-effects from previous accesses to the MCP */
/* debug logic. */
msr_value.low = 0x00000000;
msr_value.high = 0x00000000;
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 3, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 4, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 5, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 6, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 7, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 8, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 9, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 10, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 11, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 12, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 13, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 17, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 18, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 19, &msr_value);
gfx_msr_write(RC_ID_MCP, MCP_ACTION0 + 20, &msr_value);
/* SET REGA CRC VALUE TO 1 OR 0 */
if (!crc32)
msr_value.low = 0x00000001;
gfx_msr_write(RC_ID_MCP, MCP_REGA, &msr_value);
/* SET XSTATE TO 0 */
msr_value.low = 0;
msr_value.high = 0;
gfx_msr_write(RC_ID_MCP, MCP_XSTATE, &msr_value);
/* CONFIGURE DIAG CONTROL */
/* Set all four comparators to watch the upper diag bus. */
/* Set REGA action1 to legacy CRC or 32-bit CRC. */
/* Set REGB action1 to increment lower 16 bits and clear at limit. */
/* Set REGB action2 to increment upper 16 bits. */
/* Enable all actions. */
if (crc32)
msr_value.low = 0x9A820055;
else
msr_value.low = 0x9A840055;
msr_value.high = 0x00000000;
gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value);
/* DELAY TWO FRAMES */
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
while (gfx_test_vertical_active()) ;
while (!gfx_test_vertical_active()) ;
/* VERIFY THAT XSTATE = 11 */
gfx_msr_read(RC_ID_MCP, MCP_XSTATE, &msr_value);
if ((msr_value.low & 3) == 3) {
gfx_msr_read(RC_ID_MCP, MCP_REGA, &msr_value);
crc = msr_value.low;
if (!crc32)
crc &= 0xFFFFFF;
}
/* DISABLE MCP AND DF DIAG BUS OUTPUTS */
msr_value.low = 0x00000000;
msr_value.high = 0x00000000;
gfx_msr_write(RC_ID_DF, MBD_MSR_DIAG, &msr_value);
gfx_msr_write(RC_ID_MCP, MBD_MSR_DIAG, &msr_value);
/* DISABLE MCP ACTIONS */
msr_value.high = 0x00000000;
msr_value.low = 0x00000000;
gfx_msr_write(RC_ID_MCP, MCP_DIAGCTL, &msr_value);
/* RESTORE PREVIOUS OUTPUT FORMAT */
if (source != CRC_SOURCE_GFX_DATA) {
gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msr_value);
msr_value.low = old_fmt;
gfx_msr_write(RC_ID_DF, MBD_MSR_CONFIG, &msr_value);
}
return crc;
}
/*---------------------------------------------------------------------------
* gfx_get_alpha_enable
*
* This routine returns 1 if the selected alpha window is currently
* enabled, or 0 if it is currently disabled.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_alpha_enable(int *enable)
#else
void
gfx_get_alpha_enable(int *enable)
#endif
{
unsigned long value = 0;
*enable = 0;
if (gfx_alpha_select <= 2) {
value =
READ_VID32(RCDF_ALPHA_CONTROL_1 +
((unsigned long)gfx_alpha_select << 5));
if (value & RCDF_ACTRL_WIN_ENABLE)
*enable = 1;
}
return;
}
/*---------------------------------------------------------------------------
* gfx_get_alpha_size
*
* This routine returns the size of the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_alpha_size(unsigned short *x, unsigned short *y,
unsigned short *width, unsigned short *height)
#else
void
gfx_get_alpha_size(unsigned short *x, unsigned short *y,
unsigned short *width, unsigned short *height)
#endif
{
unsigned long value = 0;
*x = 0;
*y = 0;
*width = 0;
*height = 0;
if (gfx_alpha_select <= 2) {
value =
READ_VID32(RCDF_ALPHA_XPOS_1 +
((unsigned long)gfx_alpha_select << 5));
*x = (unsigned short)(value & 0x000007FF);
*width = (unsigned short)((value >> 16) & 0x000007FF) - *x;
value =
READ_VID32(RCDF_ALPHA_YPOS_1 +
((unsigned long)gfx_alpha_select << 5));
*y = (unsigned short)(value & 0x000007FF);
*height = (unsigned short)((value >> 16) & 0x000007FF) - *y;
}
*x -= gfx_get_htotal() - gfx_get_hsync_end() - 2;
*y -= gfx_get_vtotal() - gfx_get_vsync_end() + 1;
return;
}
/*---------------------------------------------------------------------------
* gfx_get_alpha_value
*
* This routine returns the alpha value and increment/decrement value of
* the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_alpha_value(unsigned char *alpha, char *delta)
#else
void
gfx_get_alpha_value(unsigned char *alpha, char *delta)
#endif
{
unsigned long value = 0;
*alpha = 0;
*delta = 0;
if (gfx_alpha_select <= 2) {
value =
READ_VID32(RCDF_ALPHA_CONTROL_1 +
((unsigned long)gfx_alpha_select << 5));
*alpha = (unsigned char)(value & 0x00FF);
*delta = (char)((value >> 8) & 0x00FF);
}
return;
}
/*---------------------------------------------------------------------------
* gfx_get_alpha_priority
*
* This routine returns the priority of the currently selected alpha region.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_alpha_priority(int *priority)
#else
void
gfx_get_alpha_priority(int *priority)
#endif
{
unsigned long pos = 0, value = 0;
*priority = 0;
if (gfx_alpha_select <= 2) {
value = READ_VID32(RCDF_VID_ALPHA_CONTROL);
pos = 16 + (gfx_alpha_select << 1);
*priority = (int)((value >> pos) & 3);
}
return;
}
/*---------------------------------------------------------------------------
* gfx_get_alpha_color
*
* This routine returns the color register value for the currently selected
* alpha region. Bit 24 is set if the color register is enabled.
*---------------------------------------------------------------------------
*/
#if GFX_VIDEO_DYNAMIC
void
redcloud_get_alpha_color(unsigned long *color)
#else
void
gfx_get_alpha_color(unsigned long *color)
#endif
{
*color = 0;
if (gfx_alpha_select <= 2) {
*color =
READ_VID32(RCDF_ALPHA_COLOR_1 +
((unsigned long)gfx_alpha_select << 5));
}
return;
}
#endif /* GFX_READ_ROUTINES */
/* END OF FILE */
| chriskmanx/qmole | QMOLEDEV/vnc-4_1_3-unixsrc/unix/xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/vid_rdcl.c | C | gpl-3.0 | 94,281 | [
30522,
1013,
1008,
1002,
1060,
23301,
20842,
1024,
1060,
2278,
1013,
3454,
1013,
1060,
8043,
6299,
1013,
1044,
2860,
1013,
1060,
23301,
20842,
1013,
6853,
1013,
24978,
2278,
1013,
1043,
2546,
2595,
1013,
6819,
2094,
1035,
16428,
20464,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.redshift.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.AmazonWebServiceRequest;
/**
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/redshift-2012-12-01/DeleteAuthenticationProfile"
* target="_top">AWS API Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class DeleteAuthenticationProfileRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable {
/**
* <p>
* The name of the authentication profile to delete.
* </p>
*/
private String authenticationProfileName;
/**
* <p>
* The name of the authentication profile to delete.
* </p>
*
* @param authenticationProfileName
* The name of the authentication profile to delete.
*/
public void setAuthenticationProfileName(String authenticationProfileName) {
this.authenticationProfileName = authenticationProfileName;
}
/**
* <p>
* The name of the authentication profile to delete.
* </p>
*
* @return The name of the authentication profile to delete.
*/
public String getAuthenticationProfileName() {
return this.authenticationProfileName;
}
/**
* <p>
* The name of the authentication profile to delete.
* </p>
*
* @param authenticationProfileName
* The name of the authentication profile to delete.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public DeleteAuthenticationProfileRequest withAuthenticationProfileName(String authenticationProfileName) {
setAuthenticationProfileName(authenticationProfileName);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getAuthenticationProfileName() != null)
sb.append("AuthenticationProfileName: ").append(getAuthenticationProfileName());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof DeleteAuthenticationProfileRequest == false)
return false;
DeleteAuthenticationProfileRequest other = (DeleteAuthenticationProfileRequest) obj;
if (other.getAuthenticationProfileName() == null ^ this.getAuthenticationProfileName() == null)
return false;
if (other.getAuthenticationProfileName() != null && other.getAuthenticationProfileName().equals(this.getAuthenticationProfileName()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getAuthenticationProfileName() == null) ? 0 : getAuthenticationProfileName().hashCode());
return hashCode;
}
@Override
public DeleteAuthenticationProfileRequest clone() {
return (DeleteAuthenticationProfileRequest) super.clone();
}
}
| aws/aws-sdk-java | aws-java-sdk-redshift/src/main/java/com/amazonaws/services/redshift/model/DeleteAuthenticationProfileRequest.java | Java | apache-2.0 | 4,104 | [
30522,
1013,
1008,
1008,
9385,
2418,
1011,
16798,
2475,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v9.0.3
* @link http://www.ag-grid.com/
* @license MIT
*/
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var context_1 = require("./context/context");
var LINE_SEPARATOR = '\r\n';
var XmlFactory = (function () {
function XmlFactory() {
}
XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
var _this = this;
var props = "";
if (xmlElement.properties) {
if (xmlElement.properties.prefixedAttributes) {
xmlElement.properties.prefixedAttributes.forEach(function (prefixedSet) {
Object.keys(prefixedSet.map).forEach(function (key) {
props += _this.returnAttributeIfPopulated(prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer);
});
});
}
if (xmlElement.properties.rawMap) {
Object.keys(xmlElement.properties.rawMap).forEach(function (key) {
props += _this.returnAttributeIfPopulated(key, xmlElement.properties.rawMap[key], booleanTransformer);
});
}
}
var result = "<" + xmlElement.name + props;
if (!xmlElement.children && !xmlElement.textNode) {
return result + "/>" + LINE_SEPARATOR;
}
if (xmlElement.textNode) {
return result + ">" + xmlElement.textNode + "</" + xmlElement.name + ">" + LINE_SEPARATOR;
}
result += ">" + LINE_SEPARATOR;
xmlElement.children.forEach(function (it) {
result += _this.createXml(it, booleanTransformer);
});
return result + "</" + xmlElement.name + ">" + LINE_SEPARATOR;
};
XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
if (!value) {
return "";
}
var xmlValue = value;
if ((typeof (value) === 'boolean')) {
if (booleanTransformer) {
xmlValue = booleanTransformer(value);
}
}
xmlValue = '"' + xmlValue + '"';
return " " + key + "=" + xmlValue;
};
return XmlFactory;
}());
XmlFactory = __decorate([
context_1.Bean('xmlFactory')
], XmlFactory);
exports.XmlFactory = XmlFactory;
| extend1994/cdnjs | ajax/libs/ag-grid/9.0.4/lib/xmlFactory.js | JavaScript | mit | 2,992 | [
30522,
1013,
1008,
1008,
1008,
12943,
1011,
8370,
1011,
3935,
2951,
8370,
1013,
2951,
2795,
4637,
9262,
22483,
1013,
10509,
1013,
16108,
22578,
1013,
4773,
6177,
1008,
1030,
2544,
1058,
2683,
1012,
1014,
1012,
1017,
1008,
1030,
4957,
8299,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/perl
# Meran - MERAN UNLP is a ILS (Integrated Library System) wich provides Catalog,
# Circulation and User's Management. It's written in Perl, and uses Apache2
# Web-Server, MySQL database and Sphinx 2 indexing.
# Copyright (C) 2009-2015 Grupo de desarrollo de Meran CeSPI-UNLP
# <desarrollo@cespi.unlp.edu.ar>
#
# This file is part of Meran.
#
# Meran is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Meran 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 Meran. If not, see <http://www.gnu.org/licenses/>.
use C4::AR::Nivel3;
use C4::Context;
use C4::Modelo::CatRegistroMarcN1;
use C4::Modelo::CatRegistroMarcN1::Manager;
use C4::Modelo::CatRegistroMarcN2;
use C4::Modelo::CatRegistroMarcN2::Manager;
use C4::Modelo::CatRegistroMarcN3;
use C4::Modelo::CatRegistroMarcN3::Manager;
my $ui = $ARGV[0] || "DEO";
my $tipo = $ARGV[1] || "LIB";
my $desde = $ARGV[2] || "00001";
my @head=(
'FECHA',
'INVENTARIO',
'AUTOR',
'TÍTULO',
'EDICIÓN',
'EDITOR',
'AÑO');
print join('#', @head);
print "\n";
my $ejemplares = C4::Modelo::CatRegistroMarcN3::Manager->get_cat_registro_marc_n3(
query => [
codigo_barra => { ge => $ui."-".$tipo."-".$desde },
codigo_barra => { like => $ui."-".$tipo."-%"},
],
sort_by => 'codigo_barra ASC'
);
foreach my $nivel3 (@$ejemplares){
my @ejemplar=();
$ejemplar[0] = $nivel3->getCreatedAt_format();
$ejemplar[1] = $nivel3->getCodigoBarra();
$ejemplar[2] = $nivel3->nivel1->getAutor();
$ejemplar[3] = $nivel3->nivel1->getTitulo();
$ejemplar[4] = $nivel3->nivel2->getEdicion();
$ejemplar[5] = $nivel3->nivel2->getEditor();
$ejemplar[6] = $nivel3->nivel2->getAnio_publicacion();
print join('#', @ejemplar);
print "\n";
}
1; | Javier-Acosta/meran | intranet/scripts/reporte_inventario.pl | Perl | gpl-3.0 | 2,611 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
2566,
2140,
1001,
21442,
2319,
1011,
21442,
2319,
4895,
14277,
2003,
1037,
6335,
2015,
1006,
6377,
3075,
2291,
1007,
15536,
2818,
3640,
12105,
1010,
1001,
9141,
1998,
5310,
1005,
1055,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*********************************************************************
*
* Copyright (C) 2002 Andrew Khan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***************************************************************************/
package jxl.format;
/**
* Enumeration class which contains the various patterns available within
* the standard Excel pattern palette
*/
public /*final*/ class Pattern
{
/**
* The internal numerical representation of the colour
*/
private int value;
/**
* The textual description
*/
private String string;
/**
* The list of patterns
*/
private static Pattern[] patterns = new Pattern[0];
/**
* Private constructor
*
* @param val
* @param s
*/
protected Pattern(int val, String s)
{
value = val;
string = s;
Pattern[] oldcols = patterns;
patterns = new Pattern[oldcols.length + 1];
System.arraycopy(oldcols, 0, patterns, 0, oldcols.length);
patterns[oldcols.length] = this;
}
/**
* Gets the value of this pattern. This is the value that is written to
* the generated Excel file
*
* @return the binary value
*/
public int getValue()
{
return value;
}
/**
* Gets the textual description
*
* @return the string
*/
public String getDescription()
{
return string;
}
/**
* Gets the pattern from the value
*
* @param val
* @return the pattern with that value
*/
public static Pattern getPattern(int val)
{
for (int i = 0 ; i < patterns.length ; i++)
{
if (patterns[i].getValue() == val)
{
return patterns[i];
}
}
return NONE;
}
public final static Pattern NONE = new Pattern(0x0, "None");
public final static Pattern SOLID = new Pattern(0x1, "Solid");
public final static Pattern GRAY_50 = new Pattern(0x2, "Gray 50%");
public final static Pattern GRAY_75 = new Pattern(0x3, "Gray 75%");
public final static Pattern GRAY_25 = new Pattern(0x4, "Gray 25%");
public final static Pattern PATTERN1 = new Pattern(0x5, "Pattern 1");
public final static Pattern PATTERN2 = new Pattern(0x6, "Pattern 2");
public final static Pattern PATTERN3 = new Pattern(0x7, "Pattern 3");
public final static Pattern PATTERN4 = new Pattern(0x8, "Pattern 4");
public final static Pattern PATTERN5 = new Pattern(0x9, "Pattern 5");
public final static Pattern PATTERN6 = new Pattern(0xa, "Pattern 6");
public final static Pattern PATTERN7 = new Pattern(0xb, "Pattern 7");
public final static Pattern PATTERN8 = new Pattern(0xc, "Pattern 8");
public final static Pattern PATTERN9 = new Pattern(0xd, "Pattern 9");
public final static Pattern PATTERN10 = new Pattern(0xe, "Pattern 10");
public final static Pattern PATTERN11 = new Pattern(0xf, "Pattern 11");
public final static Pattern PATTERN12 = new Pattern(0x10, "Pattern 12");
public final static Pattern PATTERN13 = new Pattern(0x11, "Pattern 13");
public final static Pattern PATTERN14 = new Pattern(0x12, "Pattern 14");
}
| miraculix0815/jexcelapi | src/jxl/format/Pattern.java | Java | lgpl-3.0 | 3,725 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
if ['production', 'staging', 'public'].include?(Rails.env)
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"],
:region => ENV["AWS_REGION"],
}
# config.cache_dir = "#{Rails.root}/tmp/uploads"
config.fog_directory = ENV["AWS_BIN_NAME"] # required
config.fog_public = false # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
config.storage = :fog
end
end
| performant-software/Annotation-Studio | config/initializers/carrierwave.rb | Ruby | gpl-2.0 | 706 | [
30522,
2065,
1031,
1005,
2537,
1005,
1010,
1005,
15308,
1005,
1010,
1005,
2270,
1005,
1033,
1012,
2421,
1029,
1006,
15168,
1012,
4372,
2615,
1007,
6839,
16535,
1012,
9530,
8873,
27390,
2063,
2079,
1064,
9530,
8873,
2290,
1064,
9530,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.instantlogic.engine.message;
import org.instantlogic.engine.presence.Presence;
import org.instantlogic.engine.presence.Traveler;
import org.instantlogic.fabric.Instance;
import org.instantlogic.interaction.Application;
import org.instantlogic.interaction.util.FlowContext;
import org.instantlogic.interaction.util.FlowEventOccurrence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StartMessage extends Message {
private static final Logger logger = LoggerFactory.getLogger(StartMessage.class);
private final String location;
public StartMessage(String location) {
this.location= location;
}
@Override
public void execute(Application application, Traveler traveler, Presence presence, Instance theCase) {
FlowEventOccurrence eventOccurrence;
FlowContext flowContext = FlowContext.create(application, location, theCase, presence.getCaseName(), traveler.getTravelerInfo());
if (location!=null) {
logger.info("Traveler {}-{} starting at {}", new Object[]{traveler.getTravelerInfo().getAuthenticatedUsername(), traveler.getTravelerInfo().getTravelerId(), location});
eventOccurrence = flowContext.getPage().enter(flowContext);
} else {
logger.info("Traveler {}-{} starting", new Object[]{traveler.getTravelerInfo().getAuthenticatedUsername(), traveler.getTravelerInfo().getTravelerId()});
if (application.getStartPlace()!=null) {
eventOccurrence = new FlowEventOccurrence(application.getStartPlace());
} else {
throw new RuntimeException("No start place was defined");
}
}
while (eventOccurrence!=null) {
eventOccurrence = flowContext.step(eventOccurrence);
}
traveler.getPresence().enter(traveler, flowContext.toPath());
}
@Override
public String toString() {
return "StartMessage [location=" + location + "]";
}
}
| johan-gorter/Instantlogic | webapps/presence/src/main/java/org/instantlogic/engine/message/StartMessage.java | Java | mit | 1,815 | [
30522,
7427,
8917,
1012,
7107,
27179,
1012,
3194,
1012,
4471,
1025,
12324,
8917,
1012,
7107,
27179,
1012,
3194,
1012,
3739,
1012,
3739,
30524,
1012,
8313,
1012,
6013,
1025,
12324,
8917,
1012,
7107,
27179,
1012,
8290,
1012,
4646,
1025,
12324... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2022 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "gl_common.h"
#include "wgl_dispatch_table.h"
#define WINDOW_CLASS_NAME L"renderdocGLclass"
class WGLPlatform : public GLPlatform
{
bool MakeContextCurrent(GLWindowingData data)
{
if(WGL.wglMakeCurrent)
return WGL.wglMakeCurrent(data.DC, data.ctx) == TRUE;
return false;
}
// pushing/popping contexts is complex on windows due to the really awful rules for DC lifetimes.
// Changing to the child context is easy, but getting back to where we started is hard. The
// 'current' DC may no longer be valid, as it may have been released in the meantime (while
// rendering is still A-OK). We check that the window behind the DC is valid, stored the 'wnd'
// member. If that window is valid then we use GetDC() to get a temporary DC and bind that,
// assuming all will be well. If the window isn't valid then we can't get a valid DC so we can't
// rebind the context exactly as it was, however we assume that rendering to that setup was broken
// (because the bound DC wasn't pointing to a valid window) so instead we just bind the old
// context but with our DC.
virtual bool PushChildContext(GLWindowingData existing, GLWindowingData newChild,
GLWindowingData *saved)
{
bool success = MakeContextCurrent(newChild);
*saved = existing;
if(existing.ctx)
{
if(::IsWindow(existing.wnd))
{
saved->DC = GetDC(existing.wnd);
}
else
{
saved->wnd = newChild.wnd;
saved->DC = newChild.DC;
}
}
return success;
}
virtual void PopChildContext(GLWindowingData existing, GLWindowingData newChild,
GLWindowingData saved)
{
// if possible we want to use the existing DC so that we have a valid DC for further work (the
// cloned one we're making is going to be destroyed). First try to rebind the existing as-is,
// and only if that fails - e.g. due to a stale DC - use our cloned one to rebind the context
if(!MakeContextCurrent(existing))
{
MakeContextCurrent(saved);
// release the DC now, if we didn't use our own because theirs was invalid
if(saved.DC != newChild.DC)
::ReleaseDC(saved.wnd, saved.DC);
}
}
GLWindowingData CloneTemporaryContext(GLWindowingData share)
{
GLWindowingData ret = share;
ret.ctx = NULL;
if(!WGL.wglCreateContextAttribsARB)
return ret;
// the reason we have to create an entire window and DC is because the share DC (and window)
// can be destroyed after we make a clone, which causes the DC (and window) we hold on to,
// to become invalid.
if(!RegisterClass())
return ret;
HWND wnd =
CreateWindowW(WINDOW_CLASS_NAME, L"", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
HDC dc = GetDC(wnd);
int pf = GetPixelFormat(share.DC);
PIXELFORMATDESCRIPTOR pfd;
DescribePixelFormat(share.DC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
SetPixelFormat(dc, pf, &pfd);
const int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB,
3,
WGL_CONTEXT_MINOR_VERSION_ARB,
2,
WGL_CONTEXT_FLAGS_ARB,
0,
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0,
0,
};
HGLRC rc = WGL.wglCreateContextAttribsARB(dc, share.ctx, attribs);
ShowWindow(wnd, SW_HIDE);
ret.wnd = wnd;
ret.DC = dc;
ret.ctx = rc;
return ret;
}
void DeleteClonedContext(GLWindowingData context)
{
if(context.ctx && WGL.wglDeleteContext)
{
WGL.wglDeleteContext(context.ctx);
::ReleaseDC(context.wnd, context.DC);
::DestroyWindow(context.wnd);
}
}
void DeleteReplayContext(GLWindowingData context)
{
if(WGL.wglMakeCurrent && WGL.wglDeleteContext)
{
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(context.ctx);
::ReleaseDC(context.wnd, context.DC);
::DestroyWindow(context.wnd);
}
}
void SwapBuffers(GLWindowingData context)
{
if(WGL.SwapBuffers)
WGL.SwapBuffers(context.DC);
}
void WindowResized(GLWindowingData context) {}
void GetOutputWindowDimensions(GLWindowingData context, int32_t &w, int32_t &h)
{
RECT rect = {0};
::GetClientRect(context.wnd, &rect);
w = rect.right - rect.left;
h = rect.bottom - rect.top;
}
bool IsOutputWindowVisible(GLWindowingData context)
{
return (IsWindowVisible(context.wnd) == TRUE);
}
GLWindowingData MakeOutputWindow(WindowingData window, bool depth, GLWindowingData share_context)
{
GLWindowingData ret = {};
if(!WGL.wglGetPixelFormatAttribivARB || !WGL.wglCreateContextAttribsARB)
return ret;
RDCASSERT(window.system == WindowingSystem::Win32 || window.system == WindowingSystem::Unknown ||
window.system == WindowingSystem::Headless,
window.system);
HWND w = NULL;
if(window.system == WindowingSystem::Win32)
w = window.win32.window;
else
w = CreateWindowEx(WS_EX_CLIENTEDGE, WINDOW_CLASS_NAME, L"", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
GetModuleHandle(NULL), NULL);
HDC DC = GetDC(w);
PIXELFORMATDESCRIPTOR pfd = {0};
int attrib = eWGL_NUMBER_PIXEL_FORMATS_ARB;
int value = 1;
WGL.wglGetPixelFormatAttribivARB(DC, 1, 0, 1, &attrib, &value);
int pf = 0;
int numpfs = value;
for(int i = 1; i <= numpfs; i++)
{
// verify that we have the properties we want
attrib = eWGL_DRAW_TO_WINDOW_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value == 0)
continue;
attrib = eWGL_ACCELERATION_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value == eWGL_NO_ACCELERATION_ARB)
continue;
attrib = eWGL_SUPPORT_OPENGL_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value == 0)
continue;
attrib = eWGL_DOUBLE_BUFFER_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value == 0)
continue;
attrib = eWGL_PIXEL_TYPE_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value != eWGL_TYPE_RGBA_ARB)
continue;
// we have an opengl-capable accelerated RGBA context.
// we use internal framebuffers to do almost all rendering, so we just need
// RGB (color bits > 24) and SRGB buffer.
attrib = eWGL_COLOR_BITS_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value < 24)
continue;
attrib = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
WGL.wglGetPixelFormatAttribivARB(DC, i, 0, 1, &attrib, &value);
if(value == 0)
continue;
// this one suits our needs, choose it
pf = i;
break;
}
if(pf == 0)
{
ReleaseDC(w, DC);
RDCERR("Couldn't choose pixel format");
return ret;
}
BOOL res = DescribePixelFormat(DC, pf, sizeof(pfd), &pfd);
if(res == FALSE)
{
ReleaseDC(w, DC);
RDCERR("Couldn't describe pixel format");
return ret;
}
res = SetPixelFormat(DC, pf, &pfd);
if(res == FALSE)
{
ReleaseDC(w, DC);
RDCERR("Couldn't set pixel format");
return ret;
}
int attribs[64] = {0};
int i = 0;
attribs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
attribs[i++] = GLCoreVersion / 10;
attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;
attribs[i++] = GLCoreVersion % 10;
attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
#if ENABLED(RDOC_DEVEL)
attribs[i++] = WGL_CONTEXT_DEBUG_BIT_ARB;
#else
attribs[i++] = 0;
#endif
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
attribs[i++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
HGLRC rc = WGL.wglCreateContextAttribsARB(DC, share_context.ctx, attribs);
if(rc == NULL)
{
ReleaseDC(w, DC);
RDCERR("Couldn't create %d.%d context - something changed since creation", GLCoreVersion / 10,
GLCoreVersion % 10);
return ret;
}
ret.DC = DC;
ret.ctx = rc;
ret.wnd = w;
return ret;
}
void *GetReplayFunction(const char *funcname)
{
// prefer wglGetProcAddress
void *ret = WGL.wglGetProcAddress(funcname);
if(ret)
return ret;
// but if it returns NULL, try looking up the dll directly
return Process::GetFunctionAddress(Process::LoadModule("opengl32.dll"), funcname);
}
bool CanCreateGLContext() { return true; }
bool CanCreateGLESContext()
{
bool success = WGL.PopulateForReplay();
// if we can't populate our functions we bail now.
if(!success)
return false;
// we need to check for the presence of EXT_create_context_es2_profile.
// Unfortunately on windows this means creating a trampoline context
success = RegisterClass();
if(!success)
return false;
HWND w = NULL;
HDC dc = NULL;
HGLRC rc = NULL;
success = CreateTrampolineContext(w, dc, rc);
if(!success)
return false;
const char *exts = NULL;
if(WGL.wglGetExtensionsStringARB)
exts = WGL.wglGetExtensionsStringARB(dc);
if(!exts && WGL.wglGetExtensionsStringEXT)
exts = WGL.wglGetExtensionsStringEXT();
if(!exts)
RDCERR("Couldn't get WGL extension string");
bool ret = (exts && strstr(exts, "EXT_create_context_es2_profile") != NULL);
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(rc);
ReleaseDC(w, dc);
DestroyWindow(w);
return ret;
}
bool PopulateForReplay() { return WGL.PopulateForReplay(); }
ReplayStatus InitialiseAPI(GLWindowingData &replayContext, RDCDriver api, bool debug)
{
// force debug in development builds
#if ENABLED(RDOC_DEVEL)
debug = true;
#endif
RDCASSERT(api == RDCDriver::OpenGL || api == RDCDriver::OpenGLES);
bool success = RegisterClass();
if(!success)
return ReplayStatus::APIInitFailed;
HWND w = NULL;
HDC dc = NULL;
HGLRC rc = NULL;
success = CreateTrampolineContext(w, dc, rc);
if(!success)
return ReplayStatus::APIInitFailed;
if(!WGL.wglCreateContextAttribsARB || !WGL.wglGetPixelFormatAttribivARB)
{
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(rc);
ReleaseDC(w, dc);
DestroyWindow(w);
RDCERR("RenderDoc requires WGL_ARB_create_context and WGL_ARB_pixel_format");
return ReplayStatus::APIHardwareUnsupported;
}
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(rc);
ReleaseDC(w, dc);
DestroyWindow(w);
// we don't use the default framebuffer (backbuffer) for anything, so we make it
// tiny and with no depth/stencil bits
PIXELFORMATDESCRIPTOR pfd = {0};
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 0;
pfd.cStencilBits = 0;
w = CreateWindowEx(WS_EX_CLIENTEDGE, WINDOW_CLASS_NAME, L"RenderDoc replay window",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 32, 32, NULL, NULL,
GetModuleHandle(NULL), NULL);
dc = GetDC(w);
int pf = ChoosePixelFormat(dc, &pfd);
if(pf == 0)
{
RDCERR("Couldn't choose pixel format");
ReleaseDC(w, dc);
DestroyWindow(w);
return ReplayStatus::APIInitFailed;
}
BOOL res = SetPixelFormat(dc, pf, &pfd);
if(res == FALSE)
{
RDCERR("Couldn't set pixel format");
ReleaseDC(w, dc);
DestroyWindow(w);
return ReplayStatus::APIInitFailed;
}
int attribs[64] = {0};
int i = 0;
attribs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
int &major = attribs[i];
attribs[i++] = 0;
attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;
int &minor = attribs[i];
attribs[i++] = 0;
attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
attribs[i++] = debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
attribs[i++] = api == RDCDriver::OpenGLES ? WGL_CONTEXT_ES2_PROFILE_BIT_EXT
: WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
rc = NULL;
rdcarray<GLVersion> versions = GetReplayVersions(api);
for(GLVersion v : versions)
{
major = v.major;
minor = v.minor;
rc = WGL.wglCreateContextAttribsARB(dc, NULL, attribs);
if(rc)
break;
}
if(rc == NULL)
{
RDCERR("Couldn't create at least 3.2 context - RenderDoc requires OpenGL 3.2 availability");
ReleaseDC(w, dc);
DestroyWindow(w);
return ReplayStatus::APIHardwareUnsupported;
}
GLCoreVersion = major * 10 + minor;
res = WGL.wglMakeCurrent(dc, rc);
if(res == FALSE)
{
RDCERR("Couldn't make 3.2 RC current");
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(rc);
ReleaseDC(w, dc);
DestroyWindow(w);
return ReplayStatus::APIInitFailed;
}
replayContext.DC = dc;
replayContext.ctx = rc;
replayContext.wnd = w;
return ReplayStatus::Succeeded;
}
bool CreateTrampolineContext(HWND &w, HDC &dc, HGLRC &rc)
{
PIXELFORMATDESCRIPTOR pfd = {0};
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 0;
pfd.cStencilBits = 0;
w = CreateWindowEx(WS_EX_CLIENTEDGE, WINDOW_CLASS_NAME, L"", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
GetModuleHandle(NULL), NULL);
dc = GetDC(w);
int pf = ::ChoosePixelFormat(dc, &pfd);
if(pf == 0)
{
ReleaseDC(w, dc);
DestroyWindow(w);
RDCERR("Couldn't choose pixel format");
return false;
}
BOOL res = ::SetPixelFormat(dc, pf, &pfd);
if(res == FALSE)
{
ReleaseDC(w, dc);
DestroyWindow(w);
RDCERR("Couldn't set pixel format");
return false;
}
rc = WGL.wglCreateContext(dc);
if(rc == NULL)
{
ReleaseDC(w, dc);
DestroyWindow(w);
RDCERR("Couldn't create trampoline context");
return false;
}
res = WGL.wglMakeCurrent(dc, rc);
if(res == FALSE)
{
WGL.wglMakeCurrent(NULL, NULL);
WGL.wglDeleteContext(rc);
ReleaseDC(w, dc);
DestroyWindow(w);
RDCERR("Couldn't make trampoline context current");
return false;
}
// now we can fetch the extension functions we need and fill out WGL
if(!WGL.wglCreateContextAttribsARB)
WGL.wglCreateContextAttribsARB =
(PFN_wglCreateContextAttribsARB)WGL.wglGetProcAddress("wglCreateContextAttribsARB");
if(!WGL.wglGetPixelFormatAttribivARB)
WGL.wglGetPixelFormatAttribivARB =
(PFN_wglGetPixelFormatAttribivARB)WGL.wglGetProcAddress("wglGetPixelFormatAttribivARB");
if(!WGL.wglGetExtensionsStringEXT)
WGL.wglGetExtensionsStringEXT =
(PFN_wglGetExtensionsStringEXT)WGL.wglGetProcAddress("wglGetExtensionsStringEXT");
if(!WGL.wglGetExtensionsStringARB)
WGL.wglGetExtensionsStringARB =
(PFN_wglGetExtensionsStringARB)WGL.wglGetProcAddress("wglGetExtensionsStringARB");
return true;
}
bool RegisterClass()
{
WNDCLASSEX wc = {};
wc.style = CS_OWNDC;
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = GetModuleHandle(NULL);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = WINDOW_CLASS_NAME;
WNDCLASSEX dummyCheck = {};
// if the class isn't already registered, then register it.
if(!GetClassInfoExW(wc.hInstance, wc.lpszClassName, &dummyCheck))
{
if(!RegisterClassEx(&wc))
{
RDCERR("Couldn't register GL window class");
return false;
}
}
return true;
}
void DrawQuads(float width, float height, const rdcarray<Vec4f> &vertices)
{
::DrawQuads(WGL, width, height, vertices);
}
} wglPlatform;
GLPlatform &GetGLPlatform()
{
return wglPlatform;
}
WGLDispatchTable WGL = {};
bool WGLDispatchTable::PopulateForReplay()
{
RDCASSERT(RenderDoc::Inst().IsReplayApp());
RDCDEBUG("Initialising WGL function pointers");
bool symbols_ok = true;
// library will be NULL for extension functions that we can't fetch yet.
#define LOAD_FUNC(library, func) \
if(CheckConstParam(sizeof(library) > 2)) \
{ \
if(!this->func) \
this->func = (CONCAT(PFN_, func))Process::GetFunctionAddress(Process::LoadModule(library), \
STRINGIZE(func)); \
\
if(!this->func) \
{ \
symbols_ok = false; \
RDCWARN("Unable to load '%s'", STRINGIZE(func)); \
} \
}
WGL_HOOKED_SYMBOLS(LOAD_FUNC);
WGL_NONHOOKED_SYMBOLS(LOAD_FUNC);
#undef LOAD_FUNC
return symbols_ok;
}
| Zorro666/renderdoc | renderdoc/driver/gl/wgl_platform.cpp | C++ | mit | 19,368 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
declare(strict_types=1);
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace ParkManager\Application\Command\User;
use Rollerworks\Component\SplitToken\SplitToken;
final class ConfirmPasswordReset
{
/**
* @param string $password The password in hashed format
*/
public function __construct(public SplitToken $token, public string $password)
{
}
}
| park-manager/park-manager | src/Application/Command/User/ConfirmPasswordReset.php | PHP | mpl-2.0 | 551 | [
30522,
1026,
1029,
25718,
13520,
1006,
9384,
1035,
4127,
1027,
1015,
1007,
1025,
1013,
1008,
1008,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1008,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.