code stringlengths 3 1.01M | repo_name stringlengths 5 116 | path stringlengths 3 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 3 1.01M |
|---|---|---|---|---|---|
package com.google.api.ads.dfp.jaxws.v201505;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
/**
*
* A {@code Creative} that is created by a Rich Media Studio.
*
*
* <p>Java class for BaseRichMediaStudioCreative complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="BaseRichMediaStudioCreative">
* <complexContent>
* <extension base="{https://www.google.com/apis/ads/publisher/v201505}Creative">
* <sequence>
* <element name="studioCreativeId" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
* <element name="creativeFormat" type="{https://www.google.com/apis/ads/publisher/v201505}RichMediaStudioCreativeFormat" minOccurs="0"/>
* <element name="artworkType" type="{https://www.google.com/apis/ads/publisher/v201505}RichMediaStudioCreativeArtworkType" minOccurs="0"/>
* <element name="totalFileSize" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
* <element name="adTagKeys" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
* <element name="customKeyValues" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
* <element name="surveyUrl" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="allImpressionsUrl" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="richMediaImpressionsUrl" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="backupImageImpressionsUrl" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="overrideCss" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="requiredFlashPluginVersion" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="duration" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
* <element name="billingAttribute" type="{https://www.google.com/apis/ads/publisher/v201505}RichMediaStudioCreativeBillingAttribute" minOccurs="0"/>
* <element name="richMediaStudioChildAssetProperties" type="{https://www.google.com/apis/ads/publisher/v201505}RichMediaStudioChildAssetProperty" maxOccurs="unbounded" minOccurs="0"/>
* <element name="sslScanResult" type="{https://www.google.com/apis/ads/publisher/v201505}SslScanResult" minOccurs="0"/>
* <element name="sslManualOverride" type="{https://www.google.com/apis/ads/publisher/v201505}SslManualOverride" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BaseRichMediaStudioCreative", propOrder = {
"studioCreativeId",
"creativeFormat",
"artworkType",
"totalFileSize",
"adTagKeys",
"customKeyValues",
"surveyUrl",
"allImpressionsUrl",
"richMediaImpressionsUrl",
"backupImageImpressionsUrl",
"overrideCss",
"requiredFlashPluginVersion",
"duration",
"billingAttribute",
"richMediaStudioChildAssetProperties",
"sslScanResult",
"sslManualOverride"
})
@XmlSeeAlso({
RichMediaStudioCreative.class
})
public abstract class BaseRichMediaStudioCreative
extends Creative
{
protected Long studioCreativeId;
@XmlSchemaType(name = "string")
protected RichMediaStudioCreativeFormat creativeFormat;
@XmlSchemaType(name = "string")
protected RichMediaStudioCreativeArtworkType artworkType;
protected Long totalFileSize;
protected List<String> adTagKeys;
protected List<String> customKeyValues;
protected String surveyUrl;
protected String allImpressionsUrl;
protected String richMediaImpressionsUrl;
protected String backupImageImpressionsUrl;
protected String overrideCss;
protected String requiredFlashPluginVersion;
protected Integer duration;
@XmlSchemaType(name = "string")
protected RichMediaStudioCreativeBillingAttribute billingAttribute;
protected List<RichMediaStudioChildAssetProperty> richMediaStudioChildAssetProperties;
@XmlSchemaType(name = "string")
protected SslScanResult sslScanResult;
@XmlSchemaType(name = "string")
protected SslManualOverride sslManualOverride;
/**
* Gets the value of the studioCreativeId property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getStudioCreativeId() {
return studioCreativeId;
}
/**
* Sets the value of the studioCreativeId property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setStudioCreativeId(Long value) {
this.studioCreativeId = value;
}
/**
* Gets the value of the creativeFormat property.
*
* @return
* possible object is
* {@link RichMediaStudioCreativeFormat }
*
*/
public RichMediaStudioCreativeFormat getCreativeFormat() {
return creativeFormat;
}
/**
* Sets the value of the creativeFormat property.
*
* @param value
* allowed object is
* {@link RichMediaStudioCreativeFormat }
*
*/
public void setCreativeFormat(RichMediaStudioCreativeFormat value) {
this.creativeFormat = value;
}
/**
* Gets the value of the artworkType property.
*
* @return
* possible object is
* {@link RichMediaStudioCreativeArtworkType }
*
*/
public RichMediaStudioCreativeArtworkType getArtworkType() {
return artworkType;
}
/**
* Sets the value of the artworkType property.
*
* @param value
* allowed object is
* {@link RichMediaStudioCreativeArtworkType }
*
*/
public void setArtworkType(RichMediaStudioCreativeArtworkType value) {
this.artworkType = value;
}
/**
* Gets the value of the totalFileSize property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getTotalFileSize() {
return totalFileSize;
}
/**
* Sets the value of the totalFileSize property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setTotalFileSize(Long value) {
this.totalFileSize = value;
}
/**
* Gets the value of the adTagKeys property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the adTagKeys property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getAdTagKeys().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getAdTagKeys() {
if (adTagKeys == null) {
adTagKeys = new ArrayList<String>();
}
return this.adTagKeys;
}
/**
* Gets the value of the customKeyValues property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the customKeyValues property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCustomKeyValues().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getCustomKeyValues() {
if (customKeyValues == null) {
customKeyValues = new ArrayList<String>();
}
return this.customKeyValues;
}
/**
* Gets the value of the surveyUrl property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSurveyUrl() {
return surveyUrl;
}
/**
* Sets the value of the surveyUrl property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSurveyUrl(String value) {
this.surveyUrl = value;
}
/**
* Gets the value of the allImpressionsUrl property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAllImpressionsUrl() {
return allImpressionsUrl;
}
/**
* Sets the value of the allImpressionsUrl property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAllImpressionsUrl(String value) {
this.allImpressionsUrl = value;
}
/**
* Gets the value of the richMediaImpressionsUrl property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRichMediaImpressionsUrl() {
return richMediaImpressionsUrl;
}
/**
* Sets the value of the richMediaImpressionsUrl property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRichMediaImpressionsUrl(String value) {
this.richMediaImpressionsUrl = value;
}
/**
* Gets the value of the backupImageImpressionsUrl property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getBackupImageImpressionsUrl() {
return backupImageImpressionsUrl;
}
/**
* Sets the value of the backupImageImpressionsUrl property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setBackupImageImpressionsUrl(String value) {
this.backupImageImpressionsUrl = value;
}
/**
* Gets the value of the overrideCss property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getOverrideCss() {
return overrideCss;
}
/**
* Sets the value of the overrideCss property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setOverrideCss(String value) {
this.overrideCss = value;
}
/**
* Gets the value of the requiredFlashPluginVersion property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRequiredFlashPluginVersion() {
return requiredFlashPluginVersion;
}
/**
* Sets the value of the requiredFlashPluginVersion property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRequiredFlashPluginVersion(String value) {
this.requiredFlashPluginVersion = value;
}
/**
* Gets the value of the duration property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getDuration() {
return duration;
}
/**
* Sets the value of the duration property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setDuration(Integer value) {
this.duration = value;
}
/**
* Gets the value of the billingAttribute property.
*
* @return
* possible object is
* {@link RichMediaStudioCreativeBillingAttribute }
*
*/
public RichMediaStudioCreativeBillingAttribute getBillingAttribute() {
return billingAttribute;
}
/**
* Sets the value of the billingAttribute property.
*
* @param value
* allowed object is
* {@link RichMediaStudioCreativeBillingAttribute }
*
*/
public void setBillingAttribute(RichMediaStudioCreativeBillingAttribute value) {
this.billingAttribute = value;
}
/**
* Gets the value of the richMediaStudioChildAssetProperties property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the richMediaStudioChildAssetProperties property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getRichMediaStudioChildAssetProperties().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link RichMediaStudioChildAssetProperty }
*
*
*/
public List<RichMediaStudioChildAssetProperty> getRichMediaStudioChildAssetProperties() {
if (richMediaStudioChildAssetProperties == null) {
richMediaStudioChildAssetProperties = new ArrayList<RichMediaStudioChildAssetProperty>();
}
return this.richMediaStudioChildAssetProperties;
}
/**
* Gets the value of the sslScanResult property.
*
* @return
* possible object is
* {@link SslScanResult }
*
*/
public SslScanResult getSslScanResult() {
return sslScanResult;
}
/**
* Sets the value of the sslScanResult property.
*
* @param value
* allowed object is
* {@link SslScanResult }
*
*/
public void setSslScanResult(SslScanResult value) {
this.sslScanResult = value;
}
/**
* Gets the value of the sslManualOverride property.
*
* @return
* possible object is
* {@link SslManualOverride }
*
*/
public SslManualOverride getSslManualOverride() {
return sslManualOverride;
}
/**
* Sets the value of the sslManualOverride property.
*
* @param value
* allowed object is
* {@link SslManualOverride }
*
*/
public void setSslManualOverride(SslManualOverride value) {
this.sslManualOverride = value;
}
}
| shyTNT/googleads-java-lib | modules/dfp_appengine/src/main/java/com/google/api/ads/dfp/jaxws/v201505/BaseRichMediaStudioCreative.java | Java | apache-2.0 | 14,985 |
project_path: /web/tools/_project.yaml
book_path: /web/tools/_book.yaml
description:让您的工作区包含适用于多设备网页的优秀编辑器、调试功能和构建工具。
{# wf_updated_on: 2015-04-13 #}
{# wf_published_on: 2015-04-13 #}
# 入门指南 {: .page-title }
让您的工作区包含适用于多设备网页的优秀编辑器、调试功能和构建工具。
时间是保持高效的重要因素。您在开发环境中花费的时间最多。通过包含强大、可扩展的编辑器以及强有力的调试与开发工具,让自己为成功做好准备。
* [设置您的编辑器](setup-editor)
* [使用 DevTools 的工作区设置持久化](setup-workflow)
* [设置 CSS 与 JS 预处理器](setup-preprocessors)
* [设置命令行快捷键](setup-shortcuts)
* [设置浏览器扩展程序](setup-extensions)
* [设置构建工具](setup-buildtools)
完成后,继续详细了解 [Chrome 开发者工具 (DevTools)](/web/tools/chrome-devtools),它是 Chrome 内置的工具,可以帮助您开发、测试和调试页面。
{# wf_devsite_translation #}
| ebidel/WebFundamentals | src/content/zh-cn/tools/setup/index.md | Markdown | apache-2.0 | 1,096 |
# 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.
"""oslo.i18n integration module.
See http://docs.openstack.org/developer/oslo.i18n/usage.html
"""
import oslo_i18n
_translators = oslo_i18n.TranslatorFactory(domain='murano')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
| olivierlemasle/murano | murano/common/i18n.py | Python | apache-2.0 | 1,149 |
/*
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.dialog.add("cellProperties",function(f){var g=f.lang.table,c=g.cell,d=f.lang.common,h=CKEDITOR.dialog.validate,j=/^(\d+(?:\.\d+)?)(px|%)$/,e={type:"html",html:" "},k="rtl"==f.lang.dir,i=f.plugins.colordialog;return{title:c.title,minWidth:CKEDITOR.env.ie&&CKEDITOR.env.quirks?450:410,minHeight:CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?230:220,contents:[{id:"info",label:c.title,accessKey:"I",elements:[{type:"hbox",widths:["40%","5%","40%"],children:[{type:"vbox",padding:0,
children:[{type:"hbox",widths:["70%","30%"],children:[{type:"text",id:"width",width:"100px",label:d.width,validate:h.number(c.invalidWidth),onLoad:function(){var a=this.getDialog().getContentElement("info","widthType").getElement(),b=this.getInputElement(),c=b.getAttribute("aria-labelledby");b.setAttribute("aria-labelledby",[c,a.$.id].join(" "))},setup:function(a){var b=parseInt(a.getAttribute("width"),10),a=parseInt(a.getStyle("width"),10);!isNaN(b)&&this.setValue(b);!isNaN(a)&&this.setValue(a)},
commit:function(a){var b=parseInt(this.getValue(),10),c=this.getDialog().getValueOf("info","widthType");isNaN(b)?a.removeStyle("width"):a.setStyle("width",b+c);a.removeAttribute("width")},"default":""},{type:"select",id:"widthType",label:f.lang.table.widthUnit,labelStyle:"visibility:hidden","default":"px",items:[[g.widthPx,"px"],[g.widthPc,"%"]],setup:function(a){(a=j.exec(a.getStyle("width")||a.getAttribute("width")))&&this.setValue(a[2])}}]},{type:"hbox",widths:["70%","30%"],children:[{type:"text",
id:"height",label:d.height,width:"100px","default":"",validate:h.number(c.invalidHeight),onLoad:function(){var a=this.getDialog().getContentElement("info","htmlHeightType").getElement(),b=this.getInputElement(),c=b.getAttribute("aria-labelledby");b.setAttribute("aria-labelledby",[c,a.$.id].join(" "))},setup:function(a){var b=parseInt(a.getAttribute("height"),10),a=parseInt(a.getStyle("height"),10);!isNaN(b)&&this.setValue(b);!isNaN(a)&&this.setValue(a)},commit:function(a){var b=parseInt(this.getValue(),
10);isNaN(b)?a.removeStyle("height"):a.setStyle("height",CKEDITOR.tools.cssLength(b));a.removeAttribute("height")}},{id:"htmlHeightType",type:"html",html:"<br />"+g.widthPx}]},e,{type:"select",id:"wordWrap",label:c.wordWrap,"default":"yes",items:[[c.yes,"yes"],[c.no,"no"]],setup:function(a){var b=a.getAttribute("noWrap");("nowrap"==a.getStyle("white-space")||b)&&this.setValue("no")},commit:function(a){"no"==this.getValue()?a.setStyle("white-space","nowrap"):a.removeStyle("white-space");a.removeAttribute("noWrap")}},
e,{type:"select",id:"hAlign",label:c.hAlign,"default":"",items:[[d.notSet,""],[d.alignLeft,"left"],[d.alignCenter,"center"],[d.alignRight,"right"]],setup:function(a){var b=a.getAttribute("align");this.setValue(a.getStyle("text-align")||b||"")},commit:function(a){var b=this.getValue();b?a.setStyle("text-align",b):a.removeStyle("text-align");a.removeAttribute("align")}},{type:"select",id:"vAlign",label:c.vAlign,"default":"",items:[[d.notSet,""],[d.alignTop,"top"],[d.alignMiddle,"middle"],[d.alignBottom,
"bottom"],[c.alignBaseline,"baseline"]],setup:function(a){var b=a.getAttribute("vAlign"),a=a.getStyle("vertical-align");switch(a){case "top":case "middle":case "bottom":case "baseline":break;default:a=""}this.setValue(a||b||"")},commit:function(a){var b=this.getValue();b?a.setStyle("vertical-align",b):a.removeStyle("vertical-align");a.removeAttribute("vAlign")}}]},e,{type:"vbox",padding:0,children:[{type:"select",id:"cellType",label:c.cellType,"default":"td",items:[[c.data,"td"],[c.header,"th"]],
setup:function(a){this.setValue(a.getName())},commit:function(a){a.renameNode(this.getValue())}},e,{type:"text",id:"rowSpan",label:c.rowSpan,"default":"",validate:h.integer(c.invalidRowSpan),setup:function(a){(a=parseInt(a.getAttribute("rowSpan"),10))&&1!=a&&this.setValue(a)},commit:function(a){var b=parseInt(this.getValue(),10);b&&1!=b?a.setAttribute("rowSpan",this.getValue()):a.removeAttribute("rowSpan")}},{type:"text",id:"colSpan",label:c.colSpan,"default":"",validate:h.integer(c.invalidColSpan),
setup:function(a){(a=parseInt(a.getAttribute("colSpan"),10))&&1!=a&&this.setValue(a)},commit:function(a){var b=parseInt(this.getValue(),10);b&&1!=b?a.setAttribute("colSpan",this.getValue()):a.removeAttribute("colSpan")}},e,{type:"hbox",padding:0,widths:["60%","40%"],children:[{type:"text",id:"bgColor",label:c.bgColor,"default":"",setup:function(a){var b=a.getAttribute("bgColor");this.setValue(a.getStyle("background-color")||b)},commit:function(a){this.getValue()?a.setStyle("background-color",this.getValue()):
a.removeStyle("background-color");a.removeAttribute("bgColor")}},i?{type:"button",id:"bgColorChoose","class":"colorChooser",label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){f.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info","bgColor").setValue(a);this.focus()},this)}}:e]},e,{type:"hbox",padding:0,widths:["60%","40%"],children:[{type:"text",id:"borderColor",label:c.borderColor,"default":"",setup:function(a){var b=
a.getAttribute("borderColor");this.setValue(a.getStyle("border-color")||b)},commit:function(a){this.getValue()?a.setStyle("border-color",this.getValue()):a.removeStyle("border-color");a.removeAttribute("borderColor")}},i?{type:"button",id:"borderColorChoose","class":"colorChooser",label:c.chooseColor,style:(k?"margin-right":"margin-left")+": 10px",onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){f.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info",
"borderColor").setValue(a);this.focus()},this)}}:e]}]}]}]}],onShow:function(){this.cells=CKEDITOR.plugins.tabletools.getSelectedCells(this._.editor.getSelection());this.setupContent(this.cells[0])},onOk:function(){for(var a=this._.editor.getSelection(),b=a.createBookmarks(),c=this.cells,d=0;d<c.length;d++)this.commitContent(c[d]);this._.editor.forceNextSelectionCheck();a.selectBookmarks(b);this._.editor.selectionChange()}}}); | Thellmann/callimachus | webapp/assets/ckeditor/plugins/tabletools/dialogs/tableCell.js | JavaScript | apache-2.0 | 6,207 |
/*
Copyright 2014 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.
*/
package config
import (
"encoding/json"
"io/ioutil"
"os"
"sort"
"strings"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
)
func ExampleManifestAndPod(id string) (v1beta1.ContainerManifest, api.BoundPod) {
manifest := v1beta1.ContainerManifest{
ID: id,
UUID: types.UID(id),
Containers: []v1beta1.Container{
{
Name: "c" + id,
Image: "foo",
TerminationMessagePath: "/somepath",
},
},
Volumes: []v1beta1.Volume{
{
Name: "host-dir",
Source: v1beta1.VolumeSource{
HostDir: &v1beta1.HostPath{"/dir/path"},
},
},
},
}
expectedPod := api.BoundPod{
ObjectMeta: api.ObjectMeta{
Name: id,
UID: types.UID(id),
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "c" + id,
Image: "foo",
},
},
Volumes: []api.Volume{
{
Name: "host-dir",
Source: api.VolumeSource{
HostPath: &api.HostPath{"/dir/path"},
},
},
},
},
}
return manifest, expectedPod
}
func TestExtractFromNonExistentFile(t *testing.T) {
ch := make(chan interface{}, 1)
c := sourceFile{"/some/fake/file", ch}
err := c.extractFromPath()
if err == nil {
t.Errorf("Expected error")
}
}
func TestUpdateOnNonExistentFile(t *testing.T) {
ch := make(chan interface{})
NewSourceFile("random_non_existent_path", time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource)
if !api.Semantic.DeepDerivative(expected, update) {
t.Fatalf("Expected %#v, Got %#v", expected, update)
}
case <-time.After(time.Second):
t.Errorf("Expected update, timeout instead")
}
}
func writeTestFile(t *testing.T, dir, name string, contents string) *os.File {
file, err := ioutil.TempFile(os.TempDir(), "test_pod_config")
if err != nil {
t.Fatalf("Unable to create test file %#v", err)
}
file.Close()
if err := ioutil.WriteFile(file.Name(), []byte(contents), 0555); err != nil {
t.Fatalf("Unable to write test file %#v", err)
}
return file
}
func TestReadFromFile(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config",
`{
"version": "v1beta1",
"uuid": "12345",
"id": "test",
"containers": [{ "image": "test/image", imagePullPolicy: "PullAlways"}]
}`)
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource, api.BoundPod{
ObjectMeta: api.ObjectMeta{
Name: "test",
UID: "12345",
Namespace: "",
SelfLink: "",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
})
// There's no way to provide namespace in ContainerManifest, so
// it will be defaulted.
if !strings.HasPrefix(update.Pods[0].ObjectMeta.Namespace, "file-") {
t.Errorf("Unexpected namespace: %s", update.Pods[0].ObjectMeta.Namespace)
}
update.Pods[0].ObjectMeta.Namespace = ""
// SelfLink depends on namespace.
if !strings.HasPrefix(update.Pods[0].ObjectMeta.SelfLink, "/api/") {
t.Errorf("Unexpected selflink: %s", update.Pods[0].ObjectMeta.SelfLink)
}
update.Pods[0].ObjectMeta.SelfLink = ""
if !api.Semantic.DeepDerivative(expected, update) {
t.Fatalf("Expected %#v, Got %#v", expected, update)
}
case <-time.After(time.Second):
t.Errorf("Expected update, timeout instead")
}
}
func TestReadFromFileWithoutID(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config",
`{
"version": "v1beta1",
"uuid": "12345",
"containers": [{ "image": "test/image", imagePullPolicy: "PullAlways"}]
}`)
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource, api.BoundPod{
ObjectMeta: api.ObjectMeta{
Name: "",
UID: "12345",
Namespace: "",
SelfLink: "",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
})
if len(update.Pods[0].ObjectMeta.Name) == 0 {
t.Errorf("Name did not get defaulted")
}
update.Pods[0].ObjectMeta.Name = ""
update.Pods[0].ObjectMeta.Namespace = ""
update.Pods[0].ObjectMeta.SelfLink = ""
if !api.Semantic.DeepDerivative(expected, update) {
t.Fatalf("Expected %#v, Got %#v", expected, update)
}
case <-time.After(time.Second):
t.Errorf("Expected update, timeout instead")
}
}
func TestReadV1Beta2FromFile(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config",
`{
"version": "v1beta2",
"uuid": "12345",
"id": "test",
"containers": [{ "image": "test/image", imagePullPolicy: "PullAlways"}]
}`)
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource, api.BoundPod{
ObjectMeta: api.ObjectMeta{
Name: "test",
UID: "12345",
Namespace: "",
SelfLink: "",
},
Spec: api.PodSpec{Containers: []api.Container{{Image: "test/image"}}},
})
update.Pods[0].ObjectMeta.Namespace = ""
update.Pods[0].ObjectMeta.SelfLink = ""
if !api.Semantic.DeepDerivative(expected, update) {
t.Fatalf("Expected %#v, Got %#v", expected, update)
}
case <-time.After(time.Second):
t.Errorf("Expected update, timeout instead")
}
}
func TestReadFromFileWithDefaults(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config",
`{
"version": "v1beta1",
"id": "test",
"containers": [{ "image": "test/image" }]
}`)
defer os.Remove(file.Name())
ch := make(chan interface{})
NewSourceFile(file.Name(), time.Millisecond, ch)
select {
case got := <-ch:
update := got.(kubelet.PodUpdate)
if update.Pods[0].ObjectMeta.UID == "" {
t.Errorf("Unexpected UID: %s", update.Pods[0].ObjectMeta.UID)
}
case <-time.After(time.Second):
t.Errorf("Expected update, timeout instead")
}
}
func TestExtractFromBadDataFile(t *testing.T) {
file := writeTestFile(t, os.TempDir(), "test_pod_config", string([]byte{1, 2, 3}))
defer os.Remove(file.Name())
ch := make(chan interface{}, 1)
c := sourceFile{file.Name(), ch}
err := c.extractFromPath()
if err == nil {
t.Fatalf("Expected error")
}
expectEmptyChannel(t, ch)
}
func TestExtractFromEmptyDir(t *testing.T) {
dirName, err := ioutil.TempDir("", "foo")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer os.RemoveAll(dirName)
ch := make(chan interface{}, 1)
c := sourceFile{dirName, ch}
err = c.extractFromPath()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
update := (<-ch).(kubelet.PodUpdate)
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource)
if !api.Semantic.DeepDerivative(expected, update) {
t.Errorf("Expected %#v, Got %#v", expected, update)
}
}
func TestExtractFromDir(t *testing.T) {
manifest, expectedPod := ExampleManifestAndPod("1")
manifest2, expectedPod2 := ExampleManifestAndPod("2")
manifests := []v1beta1.ContainerManifest{manifest, manifest2}
pods := []api.BoundPod{expectedPod, expectedPod2}
files := make([]*os.File, len(manifests))
dirName, err := ioutil.TempDir("", "foo")
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
for i, manifest := range manifests {
data, err := json.Marshal(manifest)
if err != nil {
t.Errorf("Unexpected error: %v", err)
continue
}
file, err := ioutil.TempFile(dirName, manifest.ID)
if err != nil {
t.Errorf("Unexpected error: %v", err)
continue
}
name := file.Name()
if err := file.Close(); err != nil {
t.Errorf("Unexpected error: %v", err)
continue
}
ioutil.WriteFile(name, data, 0755)
files[i] = file
}
ch := make(chan interface{}, 1)
c := sourceFile{dirName, ch}
err = c.extractFromPath()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
update := (<-ch).(kubelet.PodUpdate)
for i := range update.Pods {
update.Pods[i].Namespace = "foobar"
update.Pods[i].SelfLink = ""
}
expected := CreatePodUpdate(kubelet.SET, kubelet.FileSource, pods...)
for i := range expected.Pods {
expected.Pods[i].Namespace = "foobar"
}
sort.Sort(sortedPods(update.Pods))
sort.Sort(sortedPods(expected.Pods))
if !api.Semantic.DeepDerivative(expected, update) {
t.Fatalf("Expected %#v, Got %#v", expected, update)
}
for i := range update.Pods {
if errs := validation.ValidateBoundPod(&update.Pods[i]); len(errs) != 0 {
t.Errorf("Expected no validation errors on %#v, Got %#v", update.Pods[i], errs)
}
}
}
| vishvananda/kubernetes | pkg/kubelet/config/file_test.go | GO | apache-2.0 | 9,540 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.tracing.decorators;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AwsSnsSpanDecoratorTest {
@Test
public void testGetMessageId() {
String messageId = "abcd";
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(AwsSnsSpanDecorator.CAMEL_AWS_SNS_MESSAGE_ID)).thenReturn(messageId);
AwsSnsSpanDecorator decorator = new AwsSnsSpanDecorator();
assertEquals(messageId, decorator.getMessageId(exchange));
}
}
| adessaigne/camel | components/camel-tracing/src/test/java/org/apache/camel/tracing/decorators/AwsSnsSpanDecoratorTest.java | Java | apache-2.0 | 1,592 |
import pytest
import aiohttp
from aiohttp import web
@pytest.mark.run_loop
async def test_client_ws_async_for(loop, create_server):
items = ['q1', 'q2', 'q3']
async def handler(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
for i in items:
ws.send_str(i)
await ws.close()
return ws
app, url = await create_server(proto='ws')
app.router.add_route('GET', '/', handler)
resp = await aiohttp.ws_connect(url, loop=loop)
it = iter(items)
async for msg in resp:
assert msg.data == next(it)
with pytest.raises(StopIteration):
next(it)
assert resp.closed
@pytest.mark.run_loop
async def test_client_ws_async_with(loop, create_app_and_client):
async def handler(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
msg = await ws.receive()
ws.send_str(msg.data + '/answer')
await ws.close()
return ws
app, client = await create_app_and_client(
server_params=dict(proto='ws'))
app.router.add_route('GET', '/', handler)
async with client.ws_connect('/') as ws:
ws.send_str('request')
msg = await ws.receive()
assert msg.data == 'request/answer'
assert ws.closed
@pytest.mark.run_loop
async def test_client_ws_async_with_shortcut(loop, create_server):
async def handler(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
msg = await ws.receive()
ws.send_str(msg.data + '/answer')
await ws.close()
return ws
app, url = await create_server(proto='ws')
app.router.add_route('GET', '/', handler)
async with aiohttp.ws_connect(url, loop=loop) as ws:
ws.send_str('request')
msg = await ws.receive()
assert msg.data == 'request/answer'
assert ws.closed
| jashandeep-sohi/aiohttp | tests/test_py35/test_client_websocket_35.py | Python | apache-2.0 | 1,892 |
/*******************************************************************************
* Copyright 2010 Cees De Groot, Alex Boisvert, Jan Kotek
*
* 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 jdbm.btree;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import jdbm.RecordListener;
import jdbm.RecordManager;
import jdbm.Serializer;
import jdbm.helper.ComparableComparator;
import jdbm.helper.JdbmBase;
import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
/**
* B+Tree persistent indexing data structure. B+Trees are optimized for
* block-based, random I/O storage because they store multiple keys on
* one tree node (called <code>BPage</code>). In addition, the leaf nodes
* directly contain (inline) the values associated with the keys, allowing a
* single (or sequential) disk read of all the values on the page.
* <p>
* B+Trees are n-airy, yeilding log(N) search cost. They are self-balancing,
* preventing search performance degradation when the size of the tree grows.
* <p>
* Keys and associated values must be <code>Serializable</code> objects. The
* user is responsible to supply a serializable <code>Comparator</code> object
* to be used for the ordering of entries, which are also called <code>Tuple</code>.
* The B+Tree allows traversing the keys in forward and reverse order using a
* TupleBrowser obtained from the browse() methods.
* <p>
* This implementation does not directly support duplicate keys, but it is
* possible to handle duplicates by inlining or referencing an object collection
* as a value.
* <p>
* There is no limit on key size or value size, but it is recommended to keep
* both as small as possible to reduce disk I/O. This is especially true for
* the key size, which impacts all non-leaf <code>BPage</code> objects.
*
* @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
* @version $Id: BTree.java,v 1.6 2005/06/25 23:12:31 doomdark Exp $
*/
public class BTree<K,V>
implements Externalizable, JdbmBase<K,V>
{
private static final long serialVersionUID = 8883213742777032628L;
private static final boolean DEBUG = false;
/**
* Default page size (number of entries per node)
*/
public static final int DEFAULT_SIZE = 32;
/**
* Page manager used to persist changes in BPages
*/
protected transient RecordManager _recman;
/**
* This BTree's record ID in the PageManager.
*/
private transient long _recid;
/**
* Comparator used to index entries.
*/
protected Comparator<K> _comparator;
/**
* Serializer used to serialize index keys (optional)
*/
protected Serializer<K> keySerializer;
/**
* Serializer used to serialize index values (optional)
*/
protected Serializer<V> valueSerializer;
public Serializer<K> getKeySerializer() {
return keySerializer;
}
public void setKeySerializer(Serializer<K> keySerializer) {
this.keySerializer = keySerializer;
}
public Serializer<V> getValueSerializer() {
return valueSerializer;
}
public void setValueSerializer(Serializer<V> valueSerializer) {
this.valueSerializer = valueSerializer;
}
/**
* Height of the B+Tree. This is the number of BPages you have to traverse
* to get to a leaf BPage, starting from the root.
*/
private int _height;
/**
* Recid of the root BPage
*/
private transient long _root;
/**
* Number of entries in each BPage.
*/
protected int _pageSize;
/**
* Total number of entries in the BTree
*/
protected volatile int _entries;
/**
* Serializer used for BPages of this tree
*/
private transient BPage<K,V> _bpageSerializer;
/**
* Listeners which are notified about changes in records
*/
protected List<RecordListener<K,V>> recordListeners = new CopyOnWriteArrayList<RecordListener<K, V>>();
protected ReadWriteLock lock = new ReentrantReadWriteLock();
/**
* No-argument constructor used by serialization.
*/
public BTree()
{
// empty
}
/**
* Create a new persistent BTree, with 16 entries per node.
*
* @param recman Record manager used for persistence.
* @param comparator Comparator used to order index entries
*/
public static <K,V> BTree<K,V> createInstance( RecordManager recman,
Comparator<K> comparator)
throws IOException
{
return createInstance( recman, comparator, null, null, DEFAULT_SIZE );
}
/**
* Create a new persistent BTree, with 16 entries per node.
*
* @param recman Record manager used for persistence.
* @param comparator Comparator used to order index entries
*/
@SuppressWarnings("unchecked")
public static <K extends Comparable,V> BTree<K,V> createInstance( RecordManager recman)
throws IOException
{
BTree<K,V> ret = createInstance( recman, ComparableComparator.INSTANCE, null, null, DEFAULT_SIZE );
return ret;
}
/**
* Create a new persistent BTree, with 16 entries per node.
*
* @param recman Record manager used for persistence.
* @param keySerializer Serializer used to serialize index keys (optional)
* @param valueSerializer Serializer used to serialize index values (optional)
* @param comparator Comparator used to order index entries
*/
public static <K,V> BTree<K,V> createInstance( RecordManager recman,
Comparator<K> comparator,
Serializer<K> keySerializer,
Serializer<V> valueSerializer )
throws IOException
{
return createInstance( recman, comparator, keySerializer,
valueSerializer, DEFAULT_SIZE );
}
/**
* Create a new persistent BTree with the given number of entries per node.
*
* @param recman Record manager used for persistence.
* @param comparator Comparator used to order index entries
* @param keySerializer Serializer used to serialize index keys (optional)
* @param valueSerializer Serializer used to serialize index values (optional)
* @param pageSize Number of entries per page (must be even).
*/
public static <K,V> BTree<K,V> createInstance( RecordManager recman,
Comparator<K> comparator,
Serializer<K> keySerializer,
Serializer<V> valueSerializer,
int pageSize )
throws IOException
{
BTree<K,V> btree;
if ( recman == null ) {
throw new IllegalArgumentException( "Argument 'recman' is null" );
}
if ( comparator == null ) {
throw new IllegalArgumentException( "Argument 'comparator' is null" );
}
if ( ! ( comparator instanceof Serializable ) ) {
throw new IllegalArgumentException( "Argument 'comparator' must be serializable" );
}
// make sure there's an even number of entries per BPage
if ( ( pageSize & 1 ) != 0 ) {
throw new IllegalArgumentException( "Argument 'pageSize' must be even" );
}
btree = new BTree<K,V>();
btree._recman = recman;
btree._comparator = comparator;
btree.keySerializer = keySerializer;
btree.valueSerializer = valueSerializer;
btree._pageSize = pageSize;
btree._bpageSerializer = new BPage<K,V>();
btree._bpageSerializer._btree = btree;
btree._recid = recman.insert( btree );
return btree;
}
/**
* Load a persistent BTree.
*
* @param recman RecordManager used to store the persistent btree
* @param recid Record id of the BTree
*/
@SuppressWarnings("unchecked")
public static <K,V> BTree<K,V> load( RecordManager recman, long recid )
throws IOException
{
BTree<K,V> btree = (BTree<K,V>) recman.fetch( recid );
btree._recid = recid;
btree._recman = recman;
btree._bpageSerializer = new BPage<K,V>();
btree._bpageSerializer._btree = btree;
return btree;
}
/**
* Get the {@link ReadWriteLock} associated with this BTree.
* This should be used with browsing operations to ensure
* consistency.
* @return
*/
public ReadWriteLock getLock() {
return lock;
}
/**
* Insert an entry in the BTree.
* <p>
* The BTree cannot store duplicate entries. An existing entry can be
* replaced using the <code>replace</code> flag. If an entry with the
* same key already exists in the BTree, its value is returned.
*
* @param key Insert key
* @param value Insert value
* @param replace Set to true to replace an existing key-value pair.
* @return Existing value, if any.
*/
public V insert(final K key, final V value,
final boolean replace )
throws IOException
{
if ( key == null ) {
throw new IllegalArgumentException( "Argument 'key' is null" );
}
if ( value == null ) {
throw new IllegalArgumentException( "Argument 'value' is null" );
}
try {
lock.writeLock().lock();
BPage<K,V> rootPage = getRoot();
if ( rootPage == null ) {
// BTree is currently empty, create a new root BPage
if (DEBUG) {
System.out.println( "BTree.insert() new root BPage" );
}
rootPage = new BPage<K,V>( this, key, value );
_root = rootPage._recid;
_height = 1;
_entries = 1;
_recman.update( _recid, this );
//notifi listeners
for(RecordListener<K,V> l : recordListeners){
l.recordInserted(key, value);
}
return null;
} else {
BPage.InsertResult<K,V> insert = rootPage.insert( _height, key, value, replace );
boolean dirty = false;
if ( insert._overflow != null ) {
// current root page overflowed, we replace with a new root page
if ( DEBUG ) {
System.out.println( "BTree.insert() replace root BPage due to overflow" );
}
rootPage = new BPage<K,V>( this, rootPage, insert._overflow );
_root = rootPage._recid;
_height += 1;
dirty = true;
}
if ( insert._existing == null ) {
_entries++;
dirty = true;
}
if ( dirty ) {
_recman.update( _recid, this );
}
//notify listeners
for(RecordListener<K,V> l : recordListeners){
if(insert._existing==null)
l.recordInserted(key, value);
else
l.recordUpdated(key, insert._existing, value);
}
// insert might have returned an existing value
return insert._existing;
}
} finally {
lock.writeLock().unlock();
}
}
/**
* Remove an entry with the given key from the BTree.
*
* @param key Removal key
* @return Value associated with the key, or null if no entry with given
* key existed in the BTree.
*/
public V remove( K key )
throws IOException
{
if ( key == null ) {
throw new IllegalArgumentException( "Argument 'key' is null" );
}
try {
lock.writeLock().lock();
BPage<K,V> rootPage = getRoot();
if ( rootPage == null ) {
return null;
}
boolean dirty = false;
BPage.RemoveResult<K,V> remove = rootPage.remove( _height, key );
if ( remove._underflow && rootPage.isEmpty() ) {
_height -= 1;
dirty = true;
_recman.delete(_root);
if ( _height == 0 ) {
_root = 0;
} else {
_root = rootPage.childBPage( _pageSize-1 )._recid;
}
}
if ( remove._value != null ) {
_entries--;
dirty = true;
}
if ( dirty ) {
_recman.update( _recid, this );
}
if(remove._value!=null)
for(RecordListener<K,V> l : recordListeners)
l.recordRemoved(key,remove._value);
return remove._value;
} finally {
lock.writeLock().unlock();
}
}
/**
* Find the value associated with the given key.
*
* @param key Lookup key.
* @return Value associated with the key, or null if not found.
*/
public V find( K key )
throws IOException
{
if ( key == null ) {
throw new IllegalArgumentException( "Argument 'key' is null" );
}
try {
lock.readLock().lock();
BPage<K,V> rootPage = getRoot();
if ( rootPage == null ) {
return null;
}
return rootPage.findValue( _height, key );
} finally {
lock.readLock().unlock();
}
// Tuple<K,V> tuple = new Tuple<K,V>( null, null );
// TupleBrowser<K,V> browser = rootPage.find( _height, key );
//
// if ( browser.getNext( tuple ) ) {
// // find returns the matching key or the next ordered key, so we must
// // check if we have an exact match
// if ( _comparator.compare( key, tuple.getKey() ) != 0 ) {
// return null;
// } else {
// return tuple.getValue();
// }
// } else {
// return null;
// }
}
/**
* Find the value associated with the given key, or the entry immediately
* following this key in the ordered BTree.
*
* @param key Lookup key.
* @return Value associated with the key, or a greater entry, or null if no
* greater entry was found.
*/
public Tuple<K,V> findGreaterOrEqual( K key )
throws IOException
{
Tuple<K,V> tuple;
TupleBrowser<K,V> browser;
if ( key == null ) {
// there can't be a key greater than or equal to "null"
// because null is considered an infinite key.
return null;
}
tuple = new Tuple<K,V>( null, null );
browser = browse( key );
if ( browser.getNext( tuple ) ) {
return tuple;
} else {
return null;
}
}
/**
* Get a browser initially positioned at the beginning of the BTree.
* <p><b>
* WARNING: �If you make structural modifications to the BTree during
* browsing, you will get inconsistent browing results.
* </b>
*
* @return Browser positionned at the beginning of the BTree.
*/
@SuppressWarnings("unchecked")
public TupleBrowser<K,V> browse()
throws IOException
{
try {
lock.readLock().lock();
BPage<K,V> rootPage = getRoot();
if ( rootPage == null ) {
return EmptyBrowser.INSTANCE;
}
TupleBrowser<K,V> browser = rootPage.findFirst();
return browser;
} finally {
lock.readLock().unlock();
}
}
/**
* Get a browser initially positioned just before the given key.
* <p><b>
* WARNING: �If you make structural modifications to the BTree during
* browsing, you will get inconsistent browing results.
* </b>
*
* @param key Key used to position the browser. If null, the browser
* will be positionned after the last entry of the BTree.
* (Null is considered to be an "infinite" key)
* @return Browser positionned just before the given key.
*/
@SuppressWarnings("unchecked")
public TupleBrowser<K,V> browse( K key )
throws IOException
{
try {
lock.readLock().lock();
BPage<K,V> rootPage = getRoot();
if ( rootPage == null ) {
return EmptyBrowser.INSTANCE;
}
TupleBrowser<K,V> browser = rootPage.find( _height, key );
return browser;
} finally {
lock.readLock().unlock();
}
}
/**
* Return the number of entries (size) of the BTree.
*/
public int size()
{
return _entries;
}
/**
* Return the persistent record identifier of the BTree.
*/
public long getRecid()
{
return _recid;
}
/**
* Return the root BPage, or null if it doesn't exist.
*/
BPage<K,V> getRoot()
throws IOException
{
if ( _root == 0 ) {
return null;
}
BPage<K,V> root = (BPage<K,V>) _recman.fetch( _root, _bpageSerializer );
if (root != null) {
root._recid = _root;
root._btree = this;
}
return root;
}
/**
* Implement Externalizable interface.
*/
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException
{
_comparator = (Comparator<K>) in.readObject();
//serializer is not persistent from 2.0
// _keySerializer = (Serializer<K>) in.readObject();
// _valueSerializer = (Serializer<V>) in.readObject();
_height = in.readInt();
_root = in.readLong();
_pageSize = in.readInt();
_entries = in.readInt();
}
/**
* Implement Externalizable interface.
*/
public void writeExternal( ObjectOutput out )
throws IOException
{
out.writeObject( _comparator );
//serializer is not persistent from 2.0
// out.writeObject( _keySerializer );
// out.writeObject( _valueSerializer );
out.writeInt( _height );
out.writeLong( _root );
out.writeInt( _pageSize );
out.writeInt( _entries );
}
/*
public void assert() throws IOException {
BPage root = getRoot();
if ( root != null ) {
root.assertRecursive( _height );
}
}
*/
/*
public void dump() throws IOException {
BPage root = getRoot();
if ( root != null ) {
root.dumpRecursive( _height, 0 );
}
}
*/
/** PRIVATE INNER CLASS
* Browser returning no element.
*/
static class EmptyBrowser<K,V>
implements TupleBrowser<K,V> {
@SuppressWarnings("unchecked")
static TupleBrowser INSTANCE = new EmptyBrowser();
private EmptyBrowser(){}
public boolean getNext( Tuple<K,V> tuple )
{
return false;
}
public boolean getPrevious( Tuple<K,V> tuple )
{
return false;
}
}
public BTreeSortedMap<K,V> asMap(){
return new BTreeSortedMap<K, V>(this,false);
}
/**
* add RecordListener which is notified about record changes
* @param listener
*/
public void addRecordListener(RecordListener<K,V> listener){
recordListeners.add(listener);
}
/**
* remove RecordListener which is notified about record changes
* @param listener
*/
public void removeRecordListener(RecordListener<K,V> listener){
recordListeners.remove(listener);
}
public RecordManager getRecordManager() {
return _recman;
}
public Comparator<K> getComparator() {
return _comparator;
}
/**
* Deletes all BPages in this BTree, then deletes the tree from the record manager
*/
public void delete()
throws IOException
{
try {
lock.writeLock().lock();
BPage<K,V> rootPage = getRoot();
if (rootPage != null)
rootPage.delete();
_recman.delete(_recid);
} finally {
lock.writeLock().unlock();
}
}
/**
* Used for debugging and testing only. Populates the 'out' list with
* the recids of all child pages in the BTree.
* @param out
* @throws IOException
*/
void dumpChildPageRecIDs(List<Long> out) throws IOException{
BPage<K,V> root = getRoot();
if ( root != null ) {
out.add(root._recid);
root.dumpChildPageRecIDs( out, _height);
}
}
}
| cdemoustier/jdbm2 | src/main/jdbm/btree/BTree.java | Java | apache-2.0 | 21,647 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html >
<body style="color:lime">
<table rules="all" frame="border" ><tr><td>cell1</td><td>cell2</td></tr>
<tr><td>cell3</td><td>cell4</td></tr></table>
</body>
</html> | wilebeast/FireFox-OS | B2G/gecko/layout/reftests/bugs/229591-1.html | HTML | apache-2.0 | 306 |
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------
using System.Management.Automation;
using System.Security.Permissions;
using Microsoft.WindowsAzure.Commands.Common.Models;
using Microsoft.WindowsAzure.Commands.Utilities.Profile;
namespace Microsoft.WindowsAzure.Commands.Profile
{
/// <summary>
/// Sets a Microsoft Azure environment.
/// </summary>
[Cmdlet(VerbsCommon.Set, "AzureEnvironment"), OutputType(typeof(AzureEnvironment))]
public class SetAzureEnvironmentCommand : SubscriptionCmdletBase
{
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true)]
public string Name { get; set; }
[Parameter(Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true)]
public string PublishSettingsFileUrl { get; set; }
[Parameter(Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true)]
public string ServiceEndpoint { get; set; }
[Parameter(Position = 3, Mandatory = false, ValueFromPipelineByPropertyName = true)]
public string ManagementPortalUrl { get; set; }
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The storage endpoint")]
public string StorageEndpoint { get; set; }
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Active directory endpoint")]
[Alias("AdEndpointUrl")]
public string ActiveDirectoryEndpoint { get; set; }
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The cloud service endpoint")]
public string ResourceManagerEndpoint { get; set; }
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The public gallery endpoint")]
public string GalleryEndpoint { get; set; }
[Parameter(Position = 8, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Identifier of the target resource that is the recipient of the requested token.")]
public string ActiveDirectoryServiceEndpointResourceId { get; set; }
[Parameter(Position = 9, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "The AD Graph Endpoint.")]
public string GraphEndpoint { get; set; }
public SetAzureEnvironmentCommand() : base(true) { }
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var newEnvironment = new AzureEnvironment { Name = Name };
if (ProfileClient.Profile.Environments.ContainsKey(Name))
{
newEnvironment = ProfileClient.Profile.Environments[Name];
}
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.PublishSettingsFileUrl, PublishSettingsFileUrl);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ServiceManagement, ServiceEndpoint);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ResourceManager, ResourceManagerEndpoint);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ManagementPortalUrl, ManagementPortalUrl);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.StorageEndpointSuffix, StorageEndpoint);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectory, ActiveDirectoryEndpoint);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId, ActiveDirectoryServiceEndpointResourceId);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.Gallery, GalleryEndpoint);
SetEndpointIfProvided(newEnvironment, AzureEnvironment.Endpoint.Graph, GraphEndpoint);
ProfileClient.AddOrSetEnvironment(newEnvironment);
WriteObject(newEnvironment);
}
private void SetEndpointIfProvided(AzureEnvironment newEnvironment, AzureEnvironment.Endpoint endpoint, string property)
{
if (!string.IsNullOrEmpty(property))
{
newEnvironment.Endpoints[endpoint] = property;
}
}
private static string Value(string newValue, string existingValue)
{
return string.IsNullOrEmpty(newValue) ? existingValue : newValue;
}
}
} | amarzavery/azure-powershell | src/Common/Commands.Profile/Environment/SetAzureEnvironment.cs | C# | apache-2.0 | 5,155 |
-- start_ignore
SET gp_create_table_random_default_distribution=off;
-- end_ignore
DROP TABLE IF EXISTS ao;
CREATE TABLE ao (a INT) WITH (appendonly=true, orientation=column);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
insert into ao select generate_series(1,1000);
| CraigHarris/gpdb | src/test/tinc/tincrepo/mpp/gpdb/tests/storage/uao/uaocs_isolation/sql/insert_while_vacuum_setup.sql | SQL | apache-2.0 | 1,166 |
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_I18N_BIDI_LINE_ITERATOR_H_
#define BASE_I18N_BIDI_LINE_ITERATOR_H_
#include "base/basictypes.h"
#include "base/i18n/base_i18n_export.h"
#include "base/string16.h"
#include "third_party/icu/public/common/unicode/ubidi.h"
namespace base {
namespace i18n {
// A simple wrapper class for the bidirectional iterator of ICU.
// This class uses the bidirectional iterator of ICU to split a line of
// bidirectional texts into visual runs in its display order.
class BASE_I18N_EXPORT BiDiLineIterator {
public:
BiDiLineIterator();
~BiDiLineIterator();
// Initializes the bidirectional iterator with the specified text. Returns
// whether initialization succeeded.
bool Open(const string16& text, bool right_to_left, bool url);
// Returns the number of visual runs in the text, or zero on error.
int CountRuns();
// Gets the logical offset, length, and direction of the specified visual run.
UBiDiDirection GetVisualRun(int index, int* start, int* length);
// Given a start position, figure out where the run ends (and the BiDiLevel).
void GetLogicalRun(int start, int* end, UBiDiLevel* level);
private:
UBiDi* bidi_;
DISALLOW_COPY_AND_ASSIGN(BiDiLineIterator);
};
} // namespace i18n
} // namespace base
#endif // BASE_I18N_BIDI_LINE_ITERATOR_H_
| plxaye/chromium | src/base/i18n/bidi_line_iterator.h | C | apache-2.0 | 1,464 |
#pragma once
#include <list>
#include "envoy/init/init.h"
namespace Envoy {
namespace Server {
/**
* Implementation of Init::Manager for use during post cluster manager init / pre listening.
*/
class InitManagerImpl : public Init::Manager {
public:
void initialize(std::function<void()> callback);
// Init::Manager
void registerTarget(Init::Target& target) override;
private:
enum class State { NotInitialized, Initializing, Initialized };
void initializeTarget(Init::Target& target);
std::list<Init::Target*> targets_;
State state_{State::NotInitialized};
std::function<void()> callback_;
};
} // namespace Server
} // namespace Envoy
| rlazarus/envoy | source/server/init_manager_impl.h | C | apache-2.0 | 663 |
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <cmath>
#include <vector>
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/client/xla_client/xla_builder.h"
#include "tensorflow/compiler/xla/tests/client_library_test_base.h"
#include "tensorflow/compiler/xla/tests/literal_test_util.h"
#include "tensorflow/compiler/xla/tests/test_macros.h"
#include "tensorflow/core/platform/test.h"
namespace xla {
namespace {
class LogTest : public ClientLibraryTestBase {};
XLA_TEST_F(LogTest, LogZeroValues) {
XlaBuilder builder(TestName());
auto x = builder.ConstantR3FromArray3D<float>(Array3D<float>(3, 0, 0));
builder.Log(x);
ComputeAndCompareR3<float>(&builder, Array3D<float>(3, 0, 0), {},
ErrorSpec(0.0001));
}
TEST_F(LogTest, LogTenValues) {
std::vector<float> input = {-0.0, 1.0, 2.0, -3.0, -4.0,
5.0, 6.0, -7.0, -8.0, 9.0};
XlaBuilder builder(TestName());
auto x = builder.ConstantR1<float>(input);
builder.Log(x);
std::vector<float> expected;
expected.reserve(input.size());
for (float f : input) {
expected.push_back(std::log(f));
}
ComputeAndCompareR1<float>(&builder, expected, {}, ErrorSpec(0.0001));
}
} // namespace
} // namespace xla
| yanchen036/tensorflow | tensorflow/compiler/xla/tests/log_test.cc | C++ | apache-2.0 | 1,915 |
/**
* Copyright 2013 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
*/
package org.fusesource.camel.component.sap.model.rfc.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.fusesource.camel.component.sap.model.SAPEditPlugin;
import org.fusesource.camel.component.sap.model.rfc.RfcFactory;
import org.fusesource.camel.component.sap.model.rfc.RfcPackage;
import org.fusesource.camel.component.sap.model.rfc.ServerData;
/**
* This is the item provider adapter for a {@link org.fusesource.camel.component.sap.model.rfc.ServerData} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class ServerDataItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ServerDataItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addGwhostPropertyDescriptor(object);
addGwservPropertyDescriptor(object);
addProgidPropertyDescriptor(object);
addConnectionCountPropertyDescriptor(object);
addSaprouterPropertyDescriptor(object);
addMaxStartUpDelayPropertyDescriptor(object);
addRepositoryDestinationPropertyDescriptor(object);
addRepositoryMapPropertyDescriptor(object);
addTracePropertyDescriptor(object);
addWorkerThreadCountPropertyDescriptor(object);
addWorkerThreadMinCountPropertyDescriptor(object);
addSncModePropertyDescriptor(object);
addSncQopPropertyDescriptor(object);
addSncMynamePropertyDescriptor(object);
addSncLibPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Gwhost feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addGwhostPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_gwhost_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_gwhost_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__GWHOST,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Gwserv feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addGwservPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_gwserv_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_gwserv_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__GWSERV,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Progid feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addProgidPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_progid_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_progid_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__PROGID,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Connection Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addConnectionCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_connectionCount_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_connectionCount_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__CONNECTION_COUNT,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Saprouter feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSaprouterPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_saprouter_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_saprouter_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__SAPROUTER,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Max Start Up Delay feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addMaxStartUpDelayPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_maxStartUpDelay_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_maxStartUpDelay_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__MAX_START_UP_DELAY,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Repository Destination feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addRepositoryDestinationPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_repositoryDestination_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_repositoryDestination_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__REPOSITORY_DESTINATION,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Repository Map feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addRepositoryMapPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_repositoryMap_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_repositoryMap_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__REPOSITORY_MAP,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Trace feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addTracePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_trace_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_trace_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__TRACE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Worker Thread Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addWorkerThreadCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_workerThreadCount_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_workerThreadCount_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__WORKER_THREAD_COUNT,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Worker Thread Min Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addWorkerThreadMinCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_workerThreadMinCount_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_workerThreadMinCount_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__WORKER_THREAD_MIN_COUNT,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Snc Mode feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSncModePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_sncMode_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_sncMode_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__SNC_MODE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Snc Qop feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSncQopPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_sncQop_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_sncQop_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__SNC_QOP,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Snc Myname feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSncMynamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_sncMyname_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_sncMyname_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__SNC_MYNAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Snc Lib feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSncLibPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServerData_sncLib_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServerData_sncLib_feature", "_UI_ServerData_type"),
RfcPackage.Literals.SERVER_DATA__SNC_LIB,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(RfcPackage.Literals.SERVER_DATA__ENTRIES);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This returns ServerData.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/ServerData"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
String label = ((ServerData)object).getSncMyname();
return label == null || label.length() == 0 ?
getString("_UI_ServerData_type") :
getString("_UI_ServerData_type") + " " + label;
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(ServerData.class)) {
case RfcPackage.SERVER_DATA__GWHOST:
case RfcPackage.SERVER_DATA__GWSERV:
case RfcPackage.SERVER_DATA__PROGID:
case RfcPackage.SERVER_DATA__CONNECTION_COUNT:
case RfcPackage.SERVER_DATA__SAPROUTER:
case RfcPackage.SERVER_DATA__MAX_START_UP_DELAY:
case RfcPackage.SERVER_DATA__REPOSITORY_DESTINATION:
case RfcPackage.SERVER_DATA__REPOSITORY_MAP:
case RfcPackage.SERVER_DATA__TRACE:
case RfcPackage.SERVER_DATA__WORKER_THREAD_COUNT:
case RfcPackage.SERVER_DATA__WORKER_THREAD_MIN_COUNT:
case RfcPackage.SERVER_DATA__SNC_MODE:
case RfcPackage.SERVER_DATA__SNC_QOP:
case RfcPackage.SERVER_DATA__SNC_MYNAME:
case RfcPackage.SERVER_DATA__SNC_LIB:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case RfcPackage.SERVER_DATA__ENTRIES:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(RfcPackage.Literals.SERVER_DATA__ENTRIES,
RfcFactory.eINSTANCE.create(RfcPackage.Literals.SERVER_DATA_ENTRY)));
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return SAPEditPlugin.INSTANCE;
}
}
| DaemonSu/fuse-master | components/camel-sap/org.fusesource.camel.component.sap.model.edit/src/org/fusesource/camel/component/sap/model/rfc/provider/ServerDataItemProvider.java | Java | apache-2.0 | 17,978 |
# A Gentle Introduction to the Common Workflow Language
Hello!
This guide will introduce you to writing tool wrappers and workflows using the
Common Workflow Language (CWL). This guide describes the current stable
specification, version 1.0.
Note: This document is a work in progress. Not all features are covered, yet.
<!--ToC-->
# Introduction
CWL is a way to describe command line tools and connect them together to create
workflows. Because CWL is a specification and not a specific piece of
software, tools and workflows described using CWL are portable across a variety
of platforms that support the CWL standard.
CWL has roots in "make" and many similar tools that determine order of
execution based on dependencies between tasks. However unlike "make", CWL
tasks are isolated and you must be explicit about your inputs and outputs. The
benefit of explicitness and isolation are flexibility, portability, and
scalability: tools and workflows described with CWL can transparently leverage
technologies such as Docker, be used with CWL implementations from different
vendors, and is well suited for describing large-scale workflows in cluster,
cloud and high performance computing environments where tasks are scheduled in
parallel across many nodes.
| ohsu-computational-biology/common-workflow-language | v1.0/userguide-intro.md | Markdown | apache-2.0 | 1,268 |
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This package is generated by client-gen with arguments: --clientset-name=clientset --input=[api/v1,apps/v1beta1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,batch/v2alpha1,certificates/v1alpha1,extensions/v1beta1,policy/v1beta1,rbac/v1beta1,rbac/v1alpha1,storage/v1beta1]
// This package has the automatically generated clientset.
package clientset
| thomasschickinger/kubernetes | pkg/client/clientset_generated/clientset/doc.go | GO | apache-2.0 | 948 |
//
// connection.hpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
//
#ifndef HTTP_CONNECTION_HPP
#define HTTP_CONNECTION_HPP
#include <asio.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "reply.hpp"
#include "request.hpp"
#include "request_handler.hpp"
#include "request_parser.hpp"
namespace http {
namespace server {
class connection_manager;
/// Represents a single connection from a client.
class connection
: public boost::enable_shared_from_this<connection>,
private boost::noncopyable
{
public:
/// Construct a connection with the given io_service.
explicit connection(asio::io_service& io_service,
connection_manager& manager, request_handler& handler);
/// Get the socket associated with the connection.
asio::ip::tcp::socket& socket();
/// Start the first asynchronous operation for the connection.
void start();
/// Stop all asynchronous operations associated with the connection.
void stop();
private:
/// Handle completion of a read operation.
void handle_read(const asio::error_code& e,
std::size_t bytes_transferred);
/// Handle completion of a write operation.
void handle_write(const asio::error_code& e);
/// Socket for the connection.
asio::ip::tcp::socket socket_;
/// The manager for this connection.
connection_manager& connection_manager_;
/// The handler used to process the incoming request.
request_handler& request_handler_;
/// Buffer for incoming data.
boost::array<char, 8192> buffer_;
/// The incoming request.
request request_;
/// The parser for the incoming request.
request_parser request_parser_;
/// The reply to be sent back to the client.
reply reply_;
};
typedef boost::shared_ptr<connection> connection_ptr;
} // namespace server
} // namespace http
#endif // HTTP_CONNECTION_HPP
| letitvi/VideoGridPlayer | thirdparty/source/asio-1.11.0/src/examples/cpp03/http/server/connection.hpp | C++ | apache-2.0 | 2,126 |
/**
* Copyright 2011 The ForPlay Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package forplay.android;
import forplay.core.AbstractLayer;
import forplay.core.Canvas;
public abstract class AndroidLayer extends AbstractLayer {
abstract void paint(AndroidCanvas canvas);
void transform(Canvas canvas) {
canvas.translate(originX, originY);
canvas.transform(transform.m00(), transform.m01(), transform.m10(),
transform.m11(), transform.tx() - originX, transform.ty() - originY);
canvas.translate(-originX, -originY);
}
}
| pyricau/forplay-clone-pyricau | android/src/forplay/android/AndroidLayer.java | Java | apache-2.0 | 1,071 |
'use strict';
describe('Service: Oauth2RequestInterceptor', function () {
// load the service's module
beforeEach(module('yamaAppApp'));
// instantiate service
var Oauth2RequestInterceptor;
beforeEach(inject(function (_Oauth2RequestInterceptor_) {
Oauth2RequestInterceptor = _Oauth2RequestInterceptor_;
}));
it('should do something', function () {
expect(!!Oauth2RequestInterceptor).toBe(true);
});
});
| imamb/yama2_imam | webapp/test/spec/services/oauth2requestinterceptor.js | JavaScript | apache-2.0 | 432 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.phoenix.expression.rewrite;
import org.apache.phoenix.expression.CoerceExpression;
import org.apache.phoenix.expression.Expression;
import org.apache.phoenix.expression.RowValueConstructorExpression;
import org.apache.phoenix.schema.SortOrder;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class RowValueConstructorExpressionRewriter {
static RowValueConstructorExpressionRewriter singleton = null;
public static RowValueConstructorExpressionRewriter getSingleton() {
if (singleton == null) {
singleton = new RowValueConstructorExpressionRewriter();
}
return singleton;
}
public RowValueConstructorExpression rewriteAllChildrenAsc(
RowValueConstructorExpression rvcExpression) throws SQLException {
List<Expression> replacementChildren = new ArrayList<>(rvcExpression.getChildren().size());
for (int i = 0; i < rvcExpression.getChildren().size(); i++) {
Expression child = rvcExpression.getChildren().get(i);
if (child.getSortOrder() == SortOrder.DESC) {
//As The KeySlot visitor has not been setup for InvertFunction need to Use Coerce
child = CoerceExpression.create(child, child.getDataType(), SortOrder.ASC, null);
}
replacementChildren.add(child);
}
return rvcExpression.clone(replacementChildren);
}
}
| ohadshacham/phoenix | phoenix-core/src/main/java/org/apache/phoenix/expression/rewrite/RowValueConstructorExpressionRewriter.java | Java | apache-2.0 | 2,258 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.minifi.commons.schema;
import org.apache.nifi.minifi.commons.schema.common.BaseSchema;
import org.apache.nifi.minifi.commons.schema.common.WritableSchema;
import java.util.Map;
import static org.apache.nifi.minifi.commons.schema.common.CommonPropertyKeys.COMPONENT_STATUS_REPO_KEY;
public class ComponentStatusRepositorySchema extends BaseSchema implements WritableSchema {
public static final String BUFFER_SIZE_KEY = "buffer size";
public static final String SNAPSHOT_FREQUENCY_KEY = "snapshot frequency";
public static final int DEFAULT_BUFFER_SIZE = 1440;
public static final String DEFAULT_SNAPSHOT_FREQUENCY = "1 min";
private Number bufferSize = DEFAULT_BUFFER_SIZE;
private String snapshotFrequency = DEFAULT_SNAPSHOT_FREQUENCY;
public ComponentStatusRepositorySchema() {
}
public ComponentStatusRepositorySchema(Map map) {
bufferSize = getOptionalKeyAsType(map, BUFFER_SIZE_KEY, Number.class, COMPONENT_STATUS_REPO_KEY, DEFAULT_BUFFER_SIZE);
snapshotFrequency = getOptionalKeyAsType(map, SNAPSHOT_FREQUENCY_KEY, String.class, COMPONENT_STATUS_REPO_KEY, DEFAULT_SNAPSHOT_FREQUENCY);
}
@Override
public Map<String, Object> toMap() {
Map<String, Object> result = mapSupplier.get();
result.put(BUFFER_SIZE_KEY, bufferSize);
result.put(SNAPSHOT_FREQUENCY_KEY, snapshotFrequency);
return result;
}
public Number getBufferSize() {
return bufferSize;
}
public String getSnapshotFrequency() {
return snapshotFrequency;
}
}
| MikeThomsen/nifi | minifi/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ComponentStatusRepositorySchema.java | Java | apache-2.0 | 2,393 |
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
- This software is distributed in the hope that it will be
- useful, but with NO WARRANTY OF ANY KIND.
- No author or distributor accepts responsibility to anyone for the
- consequences of using this software, or for whether it serves any
- particular purpose or works at all, unless he or she says so in
- writing. Everyone is granted permission to copy, modify and
- redistribute this source code, for commercial or non-commercial
- purposes, with the following restrictions: (1) the origin of this
- source code must not be misrepresented; (2) modified versions must
- be plainly marked as such; and (3) this notice may not be removed
- or altered from any source or modified source distribution.
*====================================================================*/
/*
* pixabasic.c
*
* Pixa creation, destruction, copying
* PIXA *pixaCreate()
* PIXA *pixaCreateFromPix()
* PIXA *pixaCreateFromBoxa()
* PIXA *pixaSplitPix()
* void pixaDestroy()
* PIXA *pixaCopy()
*
* Pixa addition
* l_int32 pixaAddPix()
* l_int32 pixaExtendArray()
* l_int32 pixaExtendArrayToSize()
* l_int32 pixaAddBox()
*
* Pixa accessors
* l_int32 pixaGetCount()
* l_int32 pixaChangeRefcount()
* PIX *pixaGetPix()
* l_int32 pixaGetPixDimensions()
* PIX *pixaGetBoxa()
* l_int32 pixaGetBoxaCount()
* BOX *pixaGetBox()
* l_int32 pixaGetBoxGeometry()
* PIX **pixaGetPixArray()
*
* Pixa array modifiers
* l_int32 pixaReplacePix()
* l_int32 pixaInsertPix()
* l_int32 pixaRemovePix()
* l_int32 pixaInitFull()
* l_int32 pixaClear()
*
* Pixa combination
* PIXA *pixaJoin()
*
* Pixaa creation, destruction
* PIXAA *pixaaCreate()
* PIXAA *pixaaCreateFromPixa()
* void pixaaDestroy()
*
* Pixaa addition
* l_int32 pixaaAddPixa()
* l_int32 pixaaExtendArray()
* l_int32 pixaaAddBox()
*
* Pixaa accessors
* l_int32 pixaaGetCount()
* PIXA *pixaaGetPixa()
* BOXA *pixaaGetBoxa()
*
* Pixa serialized I/O (requires png support)
* PIXA *pixaRead()
* PIXA *pixaReadStream()
* l_int32 pixaWrite()
* l_int32 pixaWriteStream()
*
* Pixaa serialized I/O (requires png support)
* PIXAA *pixaaRead()
* PIXAA *pixaaReadStream()
* l_int32 pixaaWrite()
* l_int32 pixaaWriteStream()
*
*
* Important note on reference counting:
* Reference counting for the Pixa is analogous to that for the Boxa.
* See pix.h for details. pixaCopy() provides three possible modes
* of copy. The basic rule is that however a Pixa is obtained
* (e.g., from pixaCreate*(), pixaCopy(), or a Pixaa accessor),
* it is necessary to call pixaDestroy() on it.
*/
#include <string.h>
#include "allheaders.h"
static const l_int32 INITIAL_PTR_ARRAYSIZE = 20; /* n'import quoi */
/*---------------------------------------------------------------------*
* Pixa creation, destruction, copy *
*---------------------------------------------------------------------*/
/*!
* pixaCreate()
*
* Input: n (initial number of ptrs)
* Return: pixa, or null on error
*/
PIXA *
pixaCreate(l_int32 n)
{
PIXA *pixa;
PROCNAME("pixaCreate");
if (n <= 0)
n = INITIAL_PTR_ARRAYSIZE;
if ((pixa = (PIXA *)CALLOC(1, sizeof(PIXA))) == NULL)
return (PIXA *)ERROR_PTR("pixa not made", procName, NULL);
pixa->n = 0;
pixa->nalloc = n;
pixa->refcount = 1;
if ((pixa->pix = (PIX **)CALLOC(n, sizeof(PIX *))) == NULL)
return (PIXA *)ERROR_PTR("pix ptrs not made", procName, NULL);
if ((pixa->boxa = boxaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("boxa not made", procName, NULL);
return pixa;
}
/*!
* pixaCreateFromPix()
*
* Input: pixs (with individual components on a lattice)
* n (number of components)
* cellw (width of each cell)
* cellh (height of each cell)
* Return: pixa, or null on error
*
* Note: for bpp = 1, we truncate each retrieved pix to
* the ON pixels, which we assume for now start at (0,0)
*/
PIXA *
pixaCreateFromPix(PIX *pixs,
l_int32 n,
l_int32 cellw,
l_int32 cellh)
{
l_int32 w, h, d, nw, nh, i, j, index;
PIX *pix, *pixt;
PIXA *pixa;
PROCNAME("pixaCreateFromPix");
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
if (n <= 0)
return (PIXA *)ERROR_PTR("n must be > 0", procName, NULL);
if ((pixa = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixa not made", procName, NULL);
pixGetDimensions(pixs, &w, &h, &d);
if ((pixt = pixCreate(cellw, cellh, d)) == NULL)
return (PIXA *)ERROR_PTR("pixt not made", procName, NULL);
nw = (w + cellw - 1) / cellw;
nh = (h + cellh - 1) / cellh;
for (i = 0, index = 0; i < nh; i++) {
for (j = 0; j < nw && index < n; j++, index++) {
pixRasterop(pixt, 0, 0, cellw, cellh, PIX_SRC, pixs,
j * cellw, i * cellh);
if (d == 1 && !pixClipToForeground(pixt, &pix, NULL))
pixaAddPix(pixa, pix, L_INSERT);
else
pixaAddPix(pixa, pixt, L_COPY);
}
}
pixDestroy(&pixt);
return pixa;
}
/*!
* pixaCreateFromBoxa()
*
* Input: pixs
* boxa
* &cropwarn (<optional return> TRUE if the boxa extent
* is larger than pixs.
* Return: pixad, or null on error
*
* Notes:
* (1) This simply extracts from pixs the region corresponding to each
* box in the boxa.
* (2) The 3rd arg is optional. If the extent of the boxa exceeds the
* size of the pixa, so that some boxes are either clipped
* or entirely outside the pix, a warning is returned as TRUE.
* (3) pixad will have only the properly clipped elements, and
* the internal boxa will be correct.
*/
PIXA *
pixaCreateFromBoxa(PIX *pixs,
BOXA *boxa,
l_int32 *pcropwarn)
{
l_int32 i, n, w, h, wbox, hbox, cropwarn;
BOX *box, *boxc;
PIX *pixd;
PIXA *pixad;
PROCNAME("pixaCreateFromBoxa");
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
if (!boxa)
return (PIXA *)ERROR_PTR("boxa not defined", procName, NULL);
n = boxaGetCount(boxa);
if ((pixad = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixad not made", procName, NULL);
boxaGetExtent(boxa, &wbox, &hbox, NULL);
pixGetDimensions(pixs, &w, &h, NULL);
cropwarn = FALSE;
if (wbox > w || hbox > h)
cropwarn = TRUE;
if (pcropwarn)
*pcropwarn = cropwarn;
for (i = 0; i < n; i++) {
box = boxaGetBox(boxa, i, L_COPY);
if (cropwarn) { /* if box is outside pixs, pixd is NULL */
pixd = pixClipRectangle(pixs, box, &boxc); /* may be NULL */
if (pixd) {
pixaAddPix(pixad, pixd, L_INSERT);
pixaAddBox(pixad, boxc, L_INSERT);
}
boxDestroy(&box);
}
else {
pixd = pixClipRectangle(pixs, box, NULL);
pixaAddPix(pixad, pixd, L_INSERT);
pixaAddBox(pixad, box, L_INSERT);
}
}
return pixad;
}
/*!
* pixaSplitPix()
*
* Input: pixs (with individual components on a lattice)
* nx (number of mosaic cells horizontally)
* ny (number of mosaic cells vertically)
* borderwidth (of added border on all sides)
* bordercolor (in our RGBA format: 0xrrggbbaa)
* Return: pixa, or null on error
*
* Notes:
* (1) This is a variant on pixaCreateFromPix(), where we
* simply divide the image up into (approximately) equal
* subunits. If you want the subimages to have essentially
* the same aspect ratio as the input pix, use nx = ny.
* (2) If borderwidth is 0, we ignore the input bordercolor and
* redefine it to white.
* (3) The bordercolor is always used to initialize each tiled pix,
* so that if the src is clipped, the unblitted part will
* be this color. This avoids 1 pixel wide black stripes at the
* left and lower edges.
*/
PIXA *
pixaSplitPix(PIX *pixs,
l_int32 nx,
l_int32 ny,
l_int32 borderwidth,
l_uint32 bordercolor)
{
l_int32 w, h, d, cellw, cellh, i, j;
PIX *pixt;
PIXA *pixa;
PROCNAME("pixaSplitPix");
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
if (nx <= 0 || ny <= 0)
return (PIXA *)ERROR_PTR("nx and ny must be > 0", procName, NULL);
borderwidth = L_MAX(0, borderwidth);
if ((pixa = pixaCreate(nx * ny)) == NULL)
return (PIXA *)ERROR_PTR("pixa not made", procName, NULL);
pixGetDimensions(pixs, &w, &h, &d);
cellw = (w + nx - 1) / nx; /* round up */
cellh = (h + ny - 1) / ny;
for (i = 0; i < ny; i++) {
for (j = 0; j < nx; j++) {
if ((pixt = pixCreate(cellw + 2 * borderwidth,
cellh + 2 * borderwidth, d)) == NULL)
return (PIXA *)ERROR_PTR("pixt not made", procName, NULL);
pixCopyColormap(pixt, pixs);
if (borderwidth == 0) { /* initialize full image to white */
if (d == 1)
pixClearAll(pixt);
else
pixSetAll(pixt);
}
else
pixSetAllArbitrary(pixt, bordercolor);
pixRasterop(pixt, borderwidth, borderwidth, cellw, cellh,
PIX_SRC, pixs, j * cellw, i * cellh);
pixaAddPix(pixa, pixt, L_INSERT);
}
}
return pixa;
}
/*!
* pixaDestroy()
*
* Input: &pixa (<can be nulled>)
* Return: void
*
* Notes:
* (1) Decrements the ref count and, if 0, destroys the pixa.
* (2) Always nulls the input ptr.
*/
void
pixaDestroy(PIXA **ppixa)
{
l_int32 i;
PIXA *pixa;
PROCNAME("pixaDestroy");
if (ppixa == NULL) {
L_WARNING("ptr address is NULL!", procName);
return;
}
if ((pixa = *ppixa) == NULL)
return;
/* Decrement the refcount. If it is 0, destroy the pixa. */
pixaChangeRefcount(pixa, -1);
if (pixa->refcount <= 0) {
for (i = 0; i < pixa->n; i++)
pixDestroy(&pixa->pix[i]);
FREE(pixa->pix);
boxaDestroy(&pixa->boxa);
FREE(pixa);
}
*ppixa = NULL;
return;
}
/*!
* pixaCopy()
*
* Input: pixas
* copyflag:
* L_COPY makes a new pixa and copies each pix and each box
* L_CLONE gives a new ref-counted handle to the input pixa
* L_COPY_CLONE makes a new pixa and inserts clones of
* all pix and boxes
* Return: new pixa, or null on error
*
* Note: see pix.h for description of the copy types.
*/
PIXA *
pixaCopy(PIXA *pixa,
l_int32 copyflag)
{
l_int32 i;
BOX *boxc;
PIX *pixc;
PIXA *pixac;
PROCNAME("pixaCopy");
if (!pixa)
return (PIXA *)ERROR_PTR("pixa not defined", procName, NULL);
if (copyflag == L_CLONE) {
pixaChangeRefcount(pixa, 1);
return pixa;
}
if (copyflag != L_COPY && copyflag != L_COPY_CLONE)
return (PIXA *)ERROR_PTR("invalid copyflag", procName, NULL);
if ((pixac = pixaCreate(pixa->n)) == NULL)
return (PIXA *)ERROR_PTR("pixac not made", procName, NULL);
for (i = 0; i < pixa->n; i++) {
if (copyflag == L_COPY) {
pixc = pixaGetPix(pixa, i, L_COPY);
boxc = pixaGetBox(pixa, i, L_COPY);
}
else { /* copy-clone */
pixc = pixaGetPix(pixa, i, L_CLONE);
boxc = pixaGetBox(pixa, i, L_CLONE);
}
pixaAddPix(pixac, pixc, L_INSERT);
pixaAddBox(pixac, boxc, L_INSERT);
}
return pixac;
}
/*---------------------------------------------------------------------*
* Pixa addition *
*---------------------------------------------------------------------*/
/*!
* pixaAddPix()
*
* Input: pixa
* pix (to be added)
* copyflag (L_INSERT, L_COPY, L_CLONE)
* Return: 0 if OK; 1 on error
*/
l_int32
pixaAddPix(PIXA *pixa,
PIX *pix,
l_int32 copyflag)
{
l_int32 n;
PIX *pixc;
PROCNAME("pixaAddPix");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (!pix)
return ERROR_INT("pix not defined", procName, 1);
if (copyflag == L_INSERT)
pixc = pix;
else if (copyflag == L_COPY)
pixc = pixCopy(NULL, pix);
else if (copyflag == L_CLONE)
pixc = pixClone(pix);
else
return ERROR_INT("invalid copyflag", procName, 1);
if (!pixc)
return ERROR_INT("pixc not made", procName, 1);
n = pixaGetCount(pixa);
if (n >= pixa->nalloc)
pixaExtendArray(pixa);
pixa->pix[n] = pixc;
pixa->n++;
return 0;
}
/*!
* pixaExtendArray()
*
* Input: pixa
* Return: 0 if OK; 1 on error
*
* Notes:
* (1) Doubles the size of the pixa and boxa ptr arrays.
*/
l_int32
pixaExtendArray(PIXA *pixa)
{
PROCNAME("pixaExtendArray");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
return pixaExtendArrayToSize(pixa, 2 * pixa->nalloc);
}
/*!
* pixaExtendArrayToSize()
*
* Input: pixa
* Return: 0 if OK; 1 on error
*
* Notes:
* (1) If necessary, reallocs new pixa and boxa ptrs arrays to @size.
* The pixa and boxa ptr arrays must always be equal in size.
*/
l_int32
pixaExtendArrayToSize(PIXA *pixa,
l_int32 size)
{
PROCNAME("pixaExtendArrayToSize");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (size > pixa->nalloc) {
if ((pixa->pix = (PIX **)reallocNew((void **)&pixa->pix,
sizeof(PIX *) * pixa->nalloc,
size * sizeof(PIX *))) == NULL)
return ERROR_INT("new ptr array not returned", procName, 1);
pixa->nalloc = size;
}
return boxaExtendArrayToSize(pixa->boxa, size);
}
/*!
* pixaAddBox()
*
* Input: pixa
* box
* copyflag (L_INSERT, L_COPY, L_CLONE)
* Return: 0 if OK, 1 on error
*/
l_int32
pixaAddBox(PIXA *pixa,
BOX *box,
l_int32 copyflag)
{
PROCNAME("pixaAddBox");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (!box)
return ERROR_INT("box not defined", procName, 1);
if (copyflag != L_INSERT && copyflag != L_COPY && copyflag != L_CLONE)
return ERROR_INT("invalid copyflag", procName, 1);
boxaAddBox(pixa->boxa, box, copyflag);
return 0;
}
/*---------------------------------------------------------------------*
* Pixa accessors *
*---------------------------------------------------------------------*/
/*!
* pixaGetCount()
*
* Input: pixa
* Return: count, or 0 if no pixa
*/
l_int32
pixaGetCount(PIXA *pixa)
{
PROCNAME("pixaGetCount");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 0);
return pixa->n;
}
/*!
* pixaChangeRefcount()
*
* Input: pixa
* Return: 0 if OK, 1 on error
*/
l_int32
pixaChangeRefcount(PIXA *pixa,
l_int32 delta)
{
PROCNAME("pixaChangeRefcount");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
pixa->refcount += delta;
return 0;
}
/*!
* pixaGetPix()
*
* Input: pixa
* index (to the index-th pix)
* accesstype (L_COPY or L_CLONE)
* Return: pix, or null on error
*/
PIX *
pixaGetPix(PIXA *pixa,
l_int32 index,
l_int32 accesstype)
{
PROCNAME("pixaGetPix");
if (!pixa)
return (PIX *)ERROR_PTR("pixa not defined", procName, NULL);
if (index < 0 || index >= pixa->n)
return (PIX *)ERROR_PTR("index not valid", procName, NULL);
if (accesstype == L_COPY)
return pixCopy(NULL, pixa->pix[index]);
else if (accesstype == L_CLONE)
return pixClone(pixa->pix[index]);
else
return (PIX *)ERROR_PTR("invalid accesstype", procName, NULL);
}
/*!
* pixaGetPixDimensions()
*
* Input: pixa
* index (to the index-th box)
* &w, &h, &d (<optional return>; each can be null)
* Return: 0 if OK, 1 on error
*/
l_int32
pixaGetPixDimensions(PIXA *pixa,
l_int32 index,
l_int32 *pw,
l_int32 *ph,
l_int32 *pd)
{
PIX *pix;
PROCNAME("pixaGetPixDimensions");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (index < 0 || index >= pixa->n)
return ERROR_INT("index not valid", procName, 1);
if ((pix = pixaGetPix(pixa, index, L_CLONE)) == NULL)
return ERROR_INT("pix not found!", procName, 1);
pixGetDimensions(pix, pw, ph, pd);
pixDestroy(&pix);
return 0;
}
/*!
* pixaGetBoxa()
*
* Input: pixa
* accesstype (L_COPY, L_CLONE, L_COPY_CLONE)
* Return: boxa, or null on error
*/
BOXA *
pixaGetBoxa(PIXA *pixa,
l_int32 accesstype)
{
PROCNAME("pixaGetBoxa");
if (!pixa)
return (BOXA *)ERROR_PTR("pixa not defined", procName, NULL);
if (!pixa->boxa)
return (BOXA *)ERROR_PTR("boxa not defined", procName, NULL);
if (accesstype != L_COPY && accesstype != L_CLONE &&
accesstype != L_COPY_CLONE)
return (BOXA *)ERROR_PTR("invalid accesstype", procName, NULL);
return boxaCopy(pixa->boxa, accesstype);
}
/*!
* pixaGetBoxaCount()
*
* Input: pixa
* Return: count, or 0 on error
*/
l_int32
pixaGetBoxaCount(PIXA *pixa)
{
PROCNAME("pixaGetBoxaCount");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 0);
return boxaGetCount(pixa->boxa);
}
/*!
* pixaGetBox()
*
* Input: pixa
* index (to the index-th pix)
* accesstype (L_COPY or L_CLONE)
* Return: box (if null, not automatically an error), or null on error
*
* Notes:
* (1) There is always a boxa with a pixa, and it is initialized so
* that each box ptr is NULL.
* (2) In general, we expect that there is either a box associated
* with each pix, or no boxes at all in the boxa.
* (3) Having no boxes is thus not an automatic error. Whether it
* is an actual error is determined by the calling program.
* If the caller expects to get a box, it is an error; see, e.g.,
* pixaGetBoxGeometry().
*/
BOX *
pixaGetBox(PIXA *pixa,
l_int32 index,
l_int32 accesstype)
{
BOX *box;
PROCNAME("pixaGetBox");
if (!pixa)
return (BOX *)ERROR_PTR("pixa not defined", procName, NULL);
if (!pixa->boxa)
return (BOX *)ERROR_PTR("boxa not defined", procName, NULL);
if (index < 0 || index >= pixa->boxa->n)
return (BOX *)ERROR_PTR("index not valid", procName, NULL);
if (accesstype != L_COPY && accesstype != L_CLONE)
return (BOX *)ERROR_PTR("invalid accesstype", procName, NULL);
box = pixa->boxa->box[index];
if (box) {
if (accesstype == L_COPY)
return boxCopy(box);
else /* accesstype == L_CLONE */
return boxClone(box);
}
else
return NULL;
}
/*!
* pixaGetBoxGeometry()
*
* Input: pixa
* index (to the index-th box)
* &x, &y, &w, &h (<optional return>; each can be null)
* Return: 0 if OK, 1 on error
*/
l_int32
pixaGetBoxGeometry(PIXA *pixa,
l_int32 index,
l_int32 *px,
l_int32 *py,
l_int32 *pw,
l_int32 *ph)
{
BOX *box;
PROCNAME("pixaGetBoxGeometry");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (index < 0 || index >= pixa->n)
return ERROR_INT("index not valid", procName, 1);
if ((box = pixaGetBox(pixa, index, L_CLONE)) == NULL)
return ERROR_INT("box not found!", procName, 1);
boxGetGeometry(box, px, py, pw, ph);
boxDestroy(&box);
return 0;
}
/*!
* pixaGetPixArray()
*
* Input: pixa
* Return: pix array, or null on error
*
* Notes:
* (1) This returns a ptr to the actual array. The array is
* owned by the pixa, so it must not be destroyed.
* (2) The caller should always check if the return value is NULL
* before accessing any of the pix ptrs in this array!
*/
PIX **
pixaGetPixArray(PIXA *pixa)
{
PROCNAME("pixaGetPixArray");
if (!pixa)
return (PIX **)ERROR_PTR("pixa not defined", procName, NULL);
return pixa->pix;
}
/*---------------------------------------------------------------------*
* Pixa array modifiers *
*---------------------------------------------------------------------*/
/*!
* pixaReplacePix()
*
* Input: pixa
* index (to the index-th pix)
* pix (insert to replace existing one)
* box (<optional> insert to replace existing)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) In-place replacement of one pix.
* (2) The previous pix at that location is destroyed.
*/
l_int32
pixaReplacePix(PIXA *pixa,
l_int32 index,
PIX *pix,
BOX *box)
{
BOXA *boxa;
PROCNAME("pixaReplacePix");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (index < 0 || index >= pixa->n)
return ERROR_INT("index not valid", procName, 1);
if (!pix)
return ERROR_INT("pix not defined", procName, 1);
pixDestroy(&(pixa->pix[index]));
pixa->pix[index] = pix;
if (box) {
boxa = pixa->boxa;
if (index > boxa->n)
return ERROR_INT("boxa index not valid", procName, 1);
boxaReplaceBox(boxa, index, box);
}
return 0;
}
/*!
* pixaInsertPix()
*
* Input: pixa
* index (at which pix is to be inserted)
* pixs (new pix to be inserted)
* box (<optional> new box to be inserted)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This shifts pixa[i] --> pixa[i + 1] for all i >= index,
* and then inserts at pixa[index].
* (2) To insert at the beginning of the array, set index = 0.
* (3) It should not be used repeatedly on large arrays,
* because the function is O(n).
* (4) To append a pix to a pixa, it's easier to use pixaAddPix().
*/
l_int32
pixaInsertPix(PIXA *pixa,
l_int32 index,
PIX *pixs,
BOX *box)
{
l_int32 i, n;
PROCNAME("pixaInsertPix");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
n = pixaGetCount(pixa);
if (index < 0 || index > n)
return ERROR_INT("index not in {0...n}", procName, 1);
if (!pixs)
return ERROR_INT("pixs not defined", procName, 1);
if (n >= pixa->nalloc) { /* extend both ptr arrays */
pixaExtendArray(pixa);
boxaExtendArray(pixa->boxa);
}
pixa->n++;
for (i = n; i > index; i--)
pixa->pix[i] = pixa->pix[i - 1];
pixa->pix[index] = pixs;
/* Optionally, insert the box */
if (box)
boxaInsertBox(pixa->boxa, index, box);
return 0;
}
/*!
* pixaRemovePix()
*
* Input: pixa
* index (of pix to be removed)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This shifts pixa[i] --> pixa[i - 1] for all i > index.
* (2) It should not be used repeatedly on large arrays,
* because the function is O(n).
* (3) The corresponding box is removed as well, if it exists.
*/
l_int32
pixaRemovePix(PIXA *pixa,
l_int32 index)
{
l_int32 i, n, nbox;
BOXA *boxa;
PIX **array;
PROCNAME("pixaRemovePix");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
n = pixaGetCount(pixa);
if (index < 0 || index >= n)
return ERROR_INT("index not in {0...n - 1}", procName, 1);
/* Remove the pix */
array = pixa->pix;
pixDestroy(&array[index]);
for (i = index + 1; i < n; i++)
array[i - 1] = array[i];
array[n - 1] = NULL;
pixa->n--;
/* Remove the box if it exists */
boxa = pixa->boxa;
nbox = boxaGetCount(boxa);
if (index < nbox)
boxaRemoveBox(boxa, index);
return 0;
}
/*!
* pixaInitFull()
*
* Input: pixa (typically empty)
* pix (to be replicated into the entire pixa ptr array)
* box (<optional> to be replicated into the entire boxa ptr array)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This initializes a pixa by filling up the entire pix ptr array
* with copies of @pix. Any existing pix are destroyed.
* It also fills the boxa with copies of @box.
* After this oepration, the numbers of pix and boxes are equal to
* the number of allocated ptrs.
* (2) Note that we use pixaReplacePix() instead of pixaInsertPix().
* They both have the same effect when inserting into a NULL ptr
* in the pixa ptr array:
* (3) Example usage. This function is useful to prepare for a
* random insertion (or replacement) of pix into a pixa.
* To randomly insert pix into a pixa, up to some index "max":
* Pixa *pixa = pixaCreate(max);
* Pix *pix = pixCreate(1, 1, 1); // little memory
* Box *box = boxCreate(...);
* pixaInitFull(pixa, pix, box);
* An existing pixa with a smaller ptr array can also be reused:
* pixaExtendArrayToSize(pixa, max);
* Pix *pix = pixCreate(...);
* Box *box = boxCreate(...);
* pixaInitFull(pixa, pix, box);
* For these situations, the pix should be small and disposable.
* The initialization allows the pixa to always be properly
* filled, even if all pix (and boxes) are not later replaced.
*/
l_int32
pixaInitFull(PIXA *pixa,
PIX *pix,
BOX *box)
{
l_int32 i, n;
PIX *pixt;
PROCNAME("pixaInitFull");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (!pix)
return ERROR_INT("pix not defined", procName, 1);
n = pixa->nalloc;
pixa->n = n;
for (i = 0; i < n; i++) {
pixt = pixCopy(NULL, pix);
pixaReplacePix(pixa, i, pixt, NULL);
}
if (box)
boxaInitFull(pixa->boxa, box);
return 0;
}
/*!
* pixaClear()
*
* Input: pixa
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This destroys all pix in the pixa, as well as
* all boxes in the boxa. The ptrs in the pix ptr array
* are all null'd. The number of allocated pix, n, is set to 0.
*/
l_int32
pixaClear(PIXA *pixa)
{
l_int32 i, n;
PROCNAME("pixaClear");
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
n = pixaGetCount(pixa);
for (i = 0; i < n; i++)
pixDestroy(&pixa->pix[i]);
pixa->n = 0;
return boxaClear(pixa->boxa);
}
/*---------------------------------------------------------------------*
* Pixa combination *
*---------------------------------------------------------------------*/
/*!
* pixaJoin()
*
* Input: pixad (dest pixa; add to this one)
* pixas (source pixa; add from this one)
* istart (starting index in nas)
* iend (ending index in nas; use 0 to cat all)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) This appends a clone of each indicated pix in pixas to pixad
* (2) istart < 0 is taken to mean 'read from the start' (istart = 0)
* (3) iend <= 0 means 'read to the end'
*/
l_int32
pixaJoin(PIXA *pixad,
PIXA *pixas,
l_int32 istart,
l_int32 iend)
{
l_int32 ns, i;
BOXA *boxas, *boxad;
PIX *pix;
PROCNAME("pixaJoin");
if (!pixad)
return ERROR_INT("pixad not defined", procName, 1);
if (!pixas)
return ERROR_INT("pixas not defined", procName, 1);
if ((ns = pixaGetCount(pixas)) == 0) {
L_INFO("empty pixas", procName);
return 0;
}
if (istart < 0)
istart = 0;
if (istart >= ns)
return ERROR_INT("istart out of bounds", procName, 1);
if (iend <= 0)
iend = ns - 1;
if (iend >= ns)
return ERROR_INT("iend out of bounds", procName, 1);
if (istart > iend)
return ERROR_INT("istart > iend; nothing to add", procName, 1);
for (i = istart; i <= iend; i++) {
pix = pixaGetPix(pixas, i, L_CLONE);
pixaAddPix(pixad, pix, L_INSERT);
}
boxas = pixaGetBoxa(pixas, L_CLONE);
boxad = pixaGetBoxa(pixad, L_CLONE);
boxaJoin(boxad, boxas, 0, 0);
boxaDestroy(&boxas); /* just the clones */
boxaDestroy(&boxad);
return 0;
}
/*---------------------------------------------------------------------*
* Pixaa creation and destruction *
*---------------------------------------------------------------------*/
/*!
* pixaaCreate()
*
* Input: n (initial number of pixa ptrs)
* Return: pixaa, or null on error
*
* Notes:
* (1) A pixaa provides a 2-level hierarchy of images.
* A common use is for segmentation masks, which are
* inexpensive to store in png format.
* (2) For example, suppose you want a mask for each textline
* in a two-column page. The textline masks for each column
* can be represented by a pixa, of which there are 2 in the pixaa.
* The boxes for the textline mask components within a column
* can have their origin referred to the column rather than the page.
* Then the boxa field can be used to represent the two box (regions)
* for the columns, and the (x,y) components of each box can
* be used to get the absolute position of the textlines on
* the page.
*/
PIXAA *
pixaaCreate(l_int32 n)
{
PIXAA *pixaa;
PROCNAME("pixaaCreate");
if (n <= 0)
n = INITIAL_PTR_ARRAYSIZE;
if ((pixaa = (PIXAA *)CALLOC(1, sizeof(PIXAA))) == NULL)
return (PIXAA *)ERROR_PTR("pixaa not made", procName, NULL);
pixaa->n = 0;
pixaa->nalloc = n;
if ((pixaa->pixa = (PIXA **)CALLOC(n, sizeof(PIXA *))) == NULL)
return (PIXAA *)ERROR_PTR("pixa ptrs not made", procName, NULL);
pixaa->boxa = boxaCreate(n);
return pixaa;
}
/*!
* pixaaCreateFromPixa()
*
* Input: pixa
* n (number specifying subdivision of pixa)
* type (L_CHOOSE_CONSECUTIVE, L_CHOOSE_SKIP_BY)
* copyflag (L_CLONE, L_COPY)
* Return: pixaa, or null on error
*
* Notes:
* (1) This subdivides a pixa into a set of smaller pixa that
* are accumulated into a pixaa.
* (2) If type == L_CHOOSE_CONSECUTIVE, the first 'n' pix are
* put in a pixa and added to pixaa, then the next 'n', etc.
* If type == L_CHOOSE_SKIP_BY, the first pixa is made by
* aggregating pix[0], pix[n], pix[2*n], etc.
* (3) The copyflag specifies if each new pix is a copy or a clone.
*/
PIXAA *
pixaaCreateFromPixa(PIXA *pixa,
l_int32 n,
l_int32 type,
l_int32 copyflag)
{
l_int32 count, i, j, npixa;
PIX *pix;
PIXA *pixat;
PIXAA *pixaa;
PROCNAME("pixaaCreateFromPixa");
if (!pixa)
return (PIXAA *)ERROR_PTR("pixa not defined", procName, NULL);
count = pixaGetCount(pixa);
if (count == 0)
return (PIXAA *)ERROR_PTR("no pix in pixa", procName, NULL);
if (n <= 0)
return (PIXAA *)ERROR_PTR("n must be > 0", procName, NULL);
if (type != L_CHOOSE_CONSECUTIVE && type != L_CHOOSE_SKIP_BY)
return (PIXAA *)ERROR_PTR("invalid type", procName, NULL);
if (copyflag != L_CLONE && copyflag != L_COPY)
return (PIXAA *)ERROR_PTR("invalid copyflag", procName, NULL);
if (type == L_CHOOSE_CONSECUTIVE)
npixa = (count + n - 1) / n;
else /* L_CHOOSE_SKIP_BY */
npixa = L_MIN(n, count);
pixaa = pixaaCreate(npixa);
if (type == L_CHOOSE_CONSECUTIVE) {
for (i = 0; i < count; i++) {
if (i % n == 0)
pixat = pixaCreate(n);
pix = pixaGetPix(pixa, i, copyflag);
pixaAddPix(pixat, pix, L_INSERT);
if (i % n == n - 1)
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
if (i % n != 0)
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
else { /* L_CHOOSE_SKIP_BY */
for (i = 0; i < npixa; i++) {
pixat = pixaCreate(count / npixa + 1);
for (j = i; j < count; j += n) {
pix = pixaGetPix(pixa, j, copyflag);
pixaAddPix(pixat, pix, L_INSERT);
}
pixaaAddPixa(pixaa, pixat, L_INSERT);
}
}
return pixaa;
}
/*!
* pixaaDestroy()
*
* Input: &pixaa <to be nulled>
* Return: void
*/
void
pixaaDestroy(PIXAA **ppixaa)
{
l_int32 i;
PIXAA *pixaa;
PROCNAME("pixaaDestroy");
if (ppixaa == NULL) {
L_WARNING("ptr address is NULL!", procName);
return;
}
if ((pixaa = *ppixaa) == NULL)
return;
for (i = 0; i < pixaa->n; i++)
pixaDestroy(&pixaa->pixa[i]);
FREE(pixaa->pixa);
boxaDestroy(&pixaa->boxa);
FREE(pixaa);
*ppixaa = NULL;
return;
}
/*---------------------------------------------------------------------*
* Pixaa addition *
*---------------------------------------------------------------------*/
/*!
* pixaaAddPixa()
*
* Input: pixaa
* pixa (to be added)
* copyflag:
* L_INSERT inserts the pixa directly
* L_COPY makes a new pixa and copies each pix and each box
* L_CLONE gives a new handle to the input pixa
* L_COPY_CLONE makes a new pixa and inserts clones of
* all pix and boxes
* Return: 0 if OK; 1 on error
*/
l_int32
pixaaAddPixa(PIXAA *pixaa,
PIXA *pixa,
l_int32 copyflag)
{
l_int32 n;
PIXA *pixac;
PROCNAME("pixaaAddPixa");
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 1);
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if (copyflag != L_INSERT && copyflag != L_COPY &&
copyflag != L_CLONE && copyflag != L_COPY_CLONE)
return ERROR_INT("invalid copyflag", procName, 1);
if (copyflag == L_INSERT)
pixac = pixa;
else {
if ((pixac = pixaCopy(pixa, copyflag)) == NULL)
return ERROR_INT("pixac not made", procName, 1);
}
n = pixaaGetCount(pixaa);
if (n >= pixaa->nalloc)
pixaaExtendArray(pixaa);
pixaa->pixa[n] = pixac;
pixaa->n++;
return 0;
}
/*!
* pixaaExtendArray()
*
* Input: pixaa
* Return: 0 if OK; 1 on error
*/
l_int32
pixaaExtendArray(PIXAA *pixaa)
{
PROCNAME("pixaaExtendArray");
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 1);
if ((pixaa->pixa = (PIXA **)reallocNew((void **)&pixaa->pixa,
sizeof(PIXA *) * pixaa->nalloc,
2 * sizeof(PIXA *) * pixaa->nalloc)) == NULL)
return ERROR_INT("new ptr array not returned", procName, 1);
pixaa->nalloc = 2 * pixaa->nalloc;
return 0;
}
/*!
* pixaaAddBox()
*
* Input: pixaa
* box
* copyflag (L_INSERT, L_COPY, L_CLONE)
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) The box can be used, for example, to hold the support region
* of a pixa that is being added to the pixaa.
*/
l_int32
pixaaAddBox(PIXAA *pixaa,
BOX *box,
l_int32 copyflag)
{
PROCNAME("pixaaAddBox");
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 1);
if (!box)
return ERROR_INT("box not defined", procName, 1);
if (copyflag != L_INSERT && copyflag != L_COPY && copyflag != L_CLONE)
return ERROR_INT("invalid copyflag", procName, 1);
boxaAddBox(pixaa->boxa, box, copyflag);
return 0;
}
/*---------------------------------------------------------------------*
* Pixaa accessors *
*---------------------------------------------------------------------*/
/*!
* pixaaGetCount()
*
* Input: pixaa
* Return: count, or 0 if no pixaa
*/
l_int32
pixaaGetCount(PIXAA *pixaa)
{
PROCNAME("pixaaGetCount");
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 0);
return pixaa->n;
}
/*!
* pixaaGetPixa()
*
* Input: pixaa
* index (to the index-th pixa)
* accesstype (L_COPY, L_CLONE, L_COPY_CLONE)
* Return: pixa, or null on error
*
* Notes:
* (1) L_COPY makes a new pixa with a copy of every pix
* (2) L_CLONE just makes a new reference to the pixa,
* and bumps the counter. You would use this, for example,
* when you need to extract some data from a pix within a
* pixa within a pixaa.
* (3) L_COPY_CLONE makes a new pixa with a clone of every pix
* and box
* (4) In all cases, you must invoke pixaDestroy() on the returned pixa
*/
PIXA *
pixaaGetPixa(PIXAA *pixaa,
l_int32 index,
l_int32 accesstype)
{
PIXA *pixa;
PROCNAME("pixaaGetPixa");
if (!pixaa)
return (PIXA *)ERROR_PTR("pixaa not defined", procName, NULL);
if (index < 0 || index >= pixaa->n)
return (PIXA *)ERROR_PTR("index not valid", procName, NULL);
if (accesstype != L_COPY && accesstype != L_CLONE &&
accesstype != L_COPY_CLONE)
return (PIXA *)ERROR_PTR("invalid accesstype", procName, NULL);
if ((pixa = pixaa->pixa[index]) == NULL) /* shouldn't happen! */
return (PIXA *)ERROR_PTR("no pixa[index]", procName, NULL);
return pixaCopy(pixa, accesstype);
}
/*!
* pixaaGetBoxa()
*
* Input: pixaa
* accesstype (L_COPY, L_CLONE)
* Return: boxa, or null on error
*
* Notes:
* (1) L_COPY returns a copy; L_CLONE returns a new reference to the boxa.
* (2) In both cases, invoke boxaDestroy() on the returned boxa.
*/
BOXA *
pixaaGetBoxa(PIXAA *pixaa,
l_int32 accesstype)
{
PROCNAME("pixaaGetBoxa");
if (!pixaa)
return (BOXA *)ERROR_PTR("pixaa not defined", procName, NULL);
if (accesstype != L_COPY && accesstype != L_CLONE)
return (BOXA *)ERROR_PTR("invalid access type", procName, NULL);
return boxaCopy(pixaa->boxa, accesstype);
}
/*---------------------------------------------------------------------*
* Pixa serialized I/O *
*---------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif /* HAVE_CONFIG_H */
/*!
* pixaRead()
*
* Input: filename
* Return: pixa, or null on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
PIXA *
pixaRead(const char *filename)
{
FILE *fp;
PIXA *pixa;
PROCNAME("pixaRead");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return (PIXA *)ERROR_PTR("no libpng: can't read data", procName, NULL);
#endif /* !HAVE_LIBPNG */
if (!filename)
return (PIXA *)ERROR_PTR("filename not defined", procName, NULL);
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXA *)ERROR_PTR("stream not opened", procName, NULL);
if ((pixa = pixaReadStream(fp)) == NULL) {
fclose(fp);
return (PIXA *)ERROR_PTR("pixa not read", procName, NULL);
}
fclose(fp);
return pixa;
}
/*!
* pixaReadStream()
*
* Input: stream
* Return: pixa, or null on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
PIXA *
pixaReadStream(FILE *fp)
{
l_int32 n, i, xres, yres, version;
l_int32 ignore;
BOXA *boxa;
PIX *pix;
PIXA *pixa;
PROCNAME("pixaReadStream");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return (PIXA *)ERROR_PTR("no libpng: can't read data", procName, NULL);
#endif /* !HAVE_LIBPNG */
if (!fp)
return (PIXA *)ERROR_PTR("stream not defined", procName, NULL);
if (fscanf(fp, "\nPixa Version %d\n", &version) != 1)
return (PIXA *)ERROR_PTR("not a pixa file", procName, NULL);
if (version != PIXA_VERSION_NUMBER)
return (PIXA *)ERROR_PTR("invalid pixa version", procName, NULL);
if (fscanf(fp, "Number of pix = %d\n", &n) != 1)
return (PIXA *)ERROR_PTR("not a pixa file", procName, NULL);
if ((pixa = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixa not made", procName, NULL);
if ((boxa = boxaReadStream(fp)) == NULL)
return (PIXA *)ERROR_PTR("boxa not made", procName, NULL);
boxaDestroy(&pixa->boxa);
pixa->boxa = boxa;
for (i = 0; i < n; i++) {
if ((fscanf(fp, " pix[%d]: xres = %d, yres = %d\n",
&ignore, &xres, &yres)) != 3)
return (PIXA *)ERROR_PTR("res reading", procName, NULL);
if ((pix = pixReadStreamPng(fp)) == NULL) {
pixaDestroy(&pixa);
return (PIXA *)ERROR_PTR("pix not read", procName, NULL);
}
pixSetXRes(pix, xres);
pixSetYRes(pix, yres);
pixaAddPix(pixa, pix, L_INSERT);
}
return pixa;
}
/*!
* pixaWrite()
*
* Input: filename
* pixa
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
l_int32
pixaWrite(const char *filename,
PIXA *pixa)
{
FILE *fp;
PROCNAME("pixaWrite");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return ERROR_INT("no libpng: can't write data", procName, 1);
#endif /* !HAVE_LIBPNG */
if (!filename)
return ERROR_INT("filename not defined", procName, 1);
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
if ((fp = fopen(filename, "wb")) == NULL)
return ERROR_INT("stream not opened", procName, 1);
if (pixaWriteStream(fp, pixa))
return ERROR_INT("pixa not written to stream", procName, 1);
fclose(fp);
return 0;
}
/*!
* pixaWriteStream()
*
* Input: stream (opened for "wb")
* pixa
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
l_int32
pixaWriteStream(FILE *fp,
PIXA *pixa)
{
l_int32 n, i;
PIX *pix;
PROCNAME("pixaWriteStream");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return ERROR_INT("no libpng: can't write data", procName, 1);
#endif /* !HAVE_LIBPNG */
if (!fp)
return ERROR_INT("stream not defined", procName, 1);
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
n = pixaGetCount(pixa);
fprintf(fp, "\nPixa Version %d\n", PIXA_VERSION_NUMBER);
fprintf(fp, "Number of pix = %d\n", n);
boxaWriteStream(fp, pixa->boxa);
for (i = 0; i < n; i++) {
if ((pix = pixaGetPix(pixa, i, L_CLONE)) == NULL)
return ERROR_INT("pix not found", procName, 1);
fprintf(fp, " pix[%d]: xres = %d, yres = %d\n",
i, pix->xres, pix->yres);
pixWriteStreamPng(fp, pix, 0.0);
pixDestroy(&pix);
}
return 0;
}
/*---------------------------------------------------------------------*
* Pixaa serialized I/O *
*---------------------------------------------------------------------*/
/*!
* pixaaRead()
*
* Input: filename
* Return: pixaa, or null on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
PIXAA *
pixaaRead(const char *filename)
{
FILE *fp;
PIXAA *pixaa;
PROCNAME("pixaaRead");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return (PIXAA *)ERROR_PTR("no libpng: can't read data", procName, NULL);
#endif /* !HAVE_LIBPNG */
if (!filename)
return (PIXAA *)ERROR_PTR("filename not defined", procName, NULL);
if ((fp = fopenReadStream(filename)) == NULL)
return (PIXAA *)ERROR_PTR("stream not opened", procName, NULL);
if ((pixaa = pixaaReadStream(fp)) == NULL) {
fclose(fp);
return (PIXAA *)ERROR_PTR("pixaa not read", procName, NULL);
}
fclose(fp);
return pixaa;
}
/*!
* pixaaReadStream()
*
* Input: stream
* Return: pixaa, or null on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
PIXAA *
pixaaReadStream(FILE *fp)
{
l_int32 n, i, version;
l_int32 ignore;
BOXA *boxa;
PIXA *pixa;
PIXAA *pixaa;
PROCNAME("pixaaReadStream");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return (PIXAA *)ERROR_PTR("no libpng: can't read data", procName, NULL);
#endif /* !HAVE_LIBPNG */
if (!fp)
return (PIXAA *)ERROR_PTR("stream not defined", procName, NULL);
if (fscanf(fp, "\nPixaa Version %d\n", &version) != 1)
return (PIXAA *)ERROR_PTR("not a pixaa file", procName, NULL);
if (version != PIXAA_VERSION_NUMBER)
return (PIXAA *)ERROR_PTR("invalid pixaa version", procName, NULL);
if (fscanf(fp, "Number of pixa = %d\n", &n) != 1)
return (PIXAA *)ERROR_PTR("not a pixaa file", procName, NULL);
if ((pixaa = pixaaCreate(n)) == NULL)
return (PIXAA *)ERROR_PTR("pixaa not made", procName, NULL);
if ((boxa = boxaReadStream(fp)) == NULL)
return (PIXAA *)ERROR_PTR("boxa not made", procName, NULL);
boxaDestroy(&pixaa->boxa);
pixaa->boxa = boxa;
for (i = 0; i < n; i++) {
if ((fscanf(fp, "\n\n --------------- pixa[%d] ---------------\n",
&ignore)) != 1) {
return (PIXAA *)ERROR_PTR("text reading", procName, NULL);
}
if ((pixa = pixaReadStream(fp)) == NULL)
return (PIXAA *)ERROR_PTR("pixa not read", procName, NULL);
pixaaAddPixa(pixaa, pixa, L_INSERT);
}
return pixaa;
}
/*!
* pixaaWrite()
*
* Input: filename
* pixaa
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
l_int32
pixaaWrite(const char *filename,
PIXAA *pixaa)
{
FILE *fp;
PROCNAME("pixaaWrite");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return ERROR_INT("no libpng: can't read data", procName, 1);
#endif /* !HAVE_LIBPNG */
if (!filename)
return ERROR_INT("filename not defined", procName, 1);
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 1);
if ((fp = fopen(filename, "wb")) == NULL)
return ERROR_INT("stream not opened", procName, 1);
if (pixaaWriteStream(fp, pixaa))
return ERROR_INT("pixaa not written to stream", procName, 1);
fclose(fp);
return 0;
}
/*!
* pixaaWriteStream()
*
* Input: stream (opened for "wb")
* pixaa
* Return: 0 if OK, 1 on error
*
* Notes:
* (1) The pix are stored in the file as png.
* If the png library is not linked, this will fail.
*/
l_int32
pixaaWriteStream(FILE *fp,
PIXAA *pixaa)
{
l_int32 n, i;
PIXA *pixa;
PROCNAME("pixaaWriteStream");
#if !HAVE_LIBPNG /* defined in environ.h and config_auto.h */
return ERROR_INT("no libpng: can't read data", procName, 1);
#endif /* !HAVE_LIBPNG */
if (!fp)
return ERROR_INT("stream not defined", procName, 1);
if (!pixaa)
return ERROR_INT("pixaa not defined", procName, 1);
n = pixaaGetCount(pixaa);
fprintf(fp, "\nPixaa Version %d\n", PIXAA_VERSION_NUMBER);
fprintf(fp, "Number of pixa = %d\n", n);
boxaWriteStream(fp, pixaa->boxa);
for (i = 0; i < n; i++) {
if ((pixa = pixaaGetPixa(pixaa, i, L_CLONE)) == NULL)
return ERROR_INT("pixa not found", procName, 1);
fprintf(fp, "\n\n --------------- pixa[%d] ---------------\n", i);
pixaWriteStream(fp, pixa);
pixaDestroy(&pixa);
}
return 0;
}
| dominhhai/AndroidOCR | tess-two/jni/com_googlecode_leptonica_android/src/src/pixabasic.c | C | apache-2.0 | 50,383 |
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.buck.jvm.java.abi.source;
import java.lang.annotation.Annotation;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
class TreeBackedRoundEnvironment implements RoundEnvironment {
private final FrontendOnlyJavacTask task;
private final RoundEnvironment javacRoundEnvironment;
public TreeBackedRoundEnvironment(
FrontendOnlyJavacTask task, RoundEnvironment javacRoundEnvironment) {
this.task = task;
this.javacRoundEnvironment = javacRoundEnvironment;
}
@Override
public boolean processingOver() {
return javacRoundEnvironment.processingOver();
}
@Override
public boolean errorRaised() {
return javacRoundEnvironment.errorRaised();
}
@Override
public Set<? extends Element> getRootElements() {
return javacRoundEnvironment.getRootElements().stream()
.map(task.getElements()::getCanonicalElement)
.collect(toSet());
}
@Override
public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) {
return javacRoundEnvironment.getElementsAnnotatedWith(task.getElements().getJavacElement(a))
.stream()
.map(task.getElements()::getCanonicalElement)
.collect(toSet());
}
@Override
public Set<? extends Element> getElementsAnnotatedWith(Class<? extends Annotation> a) {
return javacRoundEnvironment.getElementsAnnotatedWith(a).stream()
.map(task.getElements()::getCanonicalElement)
.collect(toSet());
}
private Collector<Element, ?, Set<Element>> toSet() {
return Collectors.toCollection(LinkedHashSet::new);
}
}
| facebook/buck | src/com/facebook/buck/jvm/java/abi/source/TreeBackedRoundEnvironment.java | Java | apache-2.0 | 2,406 |
/**
* Copyright 2014 Confluent Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.confluent.kafka.schemaregistry;
import io.confluent.kafka.schemaregistry.client.rest.RestService;
import org.eclipse.jetty.server.Server;
import java.util.Properties;
import io.confluent.kafka.schemaregistry.avro.AvroCompatibilityLevel;
import io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig;
import io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication;
import io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryException;
import io.confluent.kafka.schemaregistry.storage.SchemaRegistry;
import io.confluent.kafka.schemaregistry.zookeeper.SchemaRegistryIdentity;
public class RestApp {
public final Properties prop;
public RestService restClient;
public SchemaRegistryRestApplication restApp;
public Server restServer;
public String restConnect;
public RestApp(int port, String zkConnect, String kafkaTopic) {
this(port, zkConnect, kafkaTopic, AvroCompatibilityLevel.NONE.name);
}
public RestApp(int port, String zkConnect, String kafkaTopic, String compatibilityType) {
this(port, zkConnect, kafkaTopic, compatibilityType, true);
}
public RestApp(int port, String zkConnect, String kafkaTopic,
String compatibilityType, boolean masterEligibility) {
prop = new Properties();
prop.setProperty(SchemaRegistryConfig.PORT_CONFIG, ((Integer) port).toString());
prop.setProperty(SchemaRegistryConfig.KAFKASTORE_CONNECTION_URL_CONFIG, zkConnect);
prop.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, kafkaTopic);
prop.put(SchemaRegistryConfig.COMPATIBILITY_CONFIG, compatibilityType);
prop.put(SchemaRegistryConfig.MASTER_ELIGIBILITY, masterEligibility);
}
public void start() throws Exception {
restApp = new SchemaRegistryRestApplication(prop);
restServer = restApp.createServer();
restServer.start();
restConnect = restServer.getURI().toString();
if (restConnect.endsWith("/"))
restConnect = restConnect.substring(0, restConnect.length()-1);
restClient = new RestService(restConnect);
}
public void stop() throws Exception {
restClient = null;
if (restServer != null) {
restServer.stop();
restServer.join();
}
}
public boolean isMaster() {
return restApp.schemaRegistry().isMaster();
}
public void setMaster(SchemaRegistryIdentity schemaRegistryIdentity)
throws SchemaRegistryException {
restApp.schemaRegistry().setMaster(schemaRegistryIdentity);
}
public SchemaRegistryIdentity myIdentity() {
return restApp.schemaRegistry().myIdentity();
}
public SchemaRegistryIdentity masterIdentity() {
return restApp.schemaRegistry().masterIdentity();
}
public SchemaRegistry schemaRegistry() {
return restApp.schemaRegistry();
}
}
| hkropp/schema-registry | core/src/test/java/io/confluent/kafka/schemaregistry/RestApp.java | Java | apache-2.0 | 3,359 |
/*
* Copyright 2015 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gs.collections.impl.block.procedure.primitive;
import com.gs.collections.api.block.function.primitive.IntObjectToIntFunction;
import com.gs.collections.api.block.procedure.Procedure;
public class InjectIntoIntProcedure<T> implements Procedure<T>
{
private static final long serialVersionUID = 1L;
private int result;
private final IntObjectToIntFunction<? super T> function;
public InjectIntoIntProcedure(int injectedValue, IntObjectToIntFunction<? super T> function)
{
this.result = injectedValue;
this.function = function;
}
public void value(T each)
{
this.result = this.function.intValueOf(this.result, each);
}
public int getResult()
{
return this.result;
}
}
| gabby2212/gs-collections | collections/src/main/java/com/gs/collections/impl/block/procedure/primitive/InjectIntoIntProcedure.java | Java | apache-2.0 | 1,362 |
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.rest;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JndiRegistry;
import org.junit.Test;
public class FromRestGetInterceptTest extends ContextTestSupport {
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
jndi.bind("dummy-rest", new DummyRestConsumerFactory());
return jndi;
}
@Test
public void testFromRestModel() throws Exception {
getMockEndpoint("mock:hello").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(1);
getMockEndpoint("mock:intercept").expectedMessageCount(3);
String out = template.requestBody("seda:get-say-hello", "I was here", String.class);
assertEquals("Bye World", out);
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
restConfiguration().host("localhost");
intercept().to("mock:intercept");
rest("/say/hello")
.get().route()
.to("mock:hello")
.to("mock:bar")
.transform().constant("Bye World");
}
};
}
}
| punkhorn/camel-upstream | core/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetInterceptTest.java | Java | apache-2.0 | 2,276 |
// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build mips,linux
package unix
const (
sizeofPtr = 0x4
sizeofShort = 0x2
sizeofInt = 0x4
sizeofLong = 0x4
sizeofLongLong = 0x8
PathMax = 0x1000
)
type (
_C_short int16
_C_int int32
_C_long int32
_C_long_long int64
)
type Timespec struct {
Sec int32
Nsec int32
}
type Timeval struct {
Sec int32
Usec int32
}
type Timex struct {
Modes uint32
Offset int32
Freq int32
Maxerror int32
Esterror int32
Status int32
Constant int32
Precision int32
Tolerance int32
Time Timeval
Tick int32
Ppsfreq int32
Jitter int32
Shift int32
Stabil int32
Jitcnt int32
Calcnt int32
Errcnt int32
Stbcnt int32
Tai int32
_ [44]byte
}
type Time_t int32
type Tms struct {
Utime int32
Stime int32
Cutime int32
Cstime int32
}
type Utimbuf struct {
Actime int32
Modtime int32
}
type Rusage struct {
Utime Timeval
Stime Timeval
Maxrss int32
Ixrss int32
Idrss int32
Isrss int32
Minflt int32
Majflt int32
Nswap int32
Inblock int32
Oublock int32
Msgsnd int32
Msgrcv int32
Nsignals int32
Nvcsw int32
Nivcsw int32
}
type Rlimit struct {
Cur uint64
Max uint64
}
type _Gid_t uint32
type Stat_t struct {
Dev uint32
Pad1 [3]int32
Ino uint64
Mode uint32
Nlink uint32
Uid uint32
Gid uint32
Rdev uint32
Pad2 [3]int32
Size int64
Atim Timespec
Mtim Timespec
Ctim Timespec
Blksize int32
Pad4 int32
Blocks int64
Pad5 [14]int32
}
type StatxTimestamp struct {
Sec int64
Nsec uint32
_ int32
}
type Statx_t struct {
Mask uint32
Blksize uint32
Attributes uint64
Nlink uint32
Uid uint32
Gid uint32
Mode uint16
_ [1]uint16
Ino uint64
Size uint64
Blocks uint64
Attributes_mask uint64
Atime StatxTimestamp
Btime StatxTimestamp
Ctime StatxTimestamp
Mtime StatxTimestamp
Rdev_major uint32
Rdev_minor uint32
Dev_major uint32
Dev_minor uint32
_ [14]uint64
}
type Dirent struct {
Ino uint64
Off int64
Reclen uint16
Type uint8
Name [256]int8
_ [5]byte
}
type Fsid struct {
Val [2]int32
}
type Flock_t struct {
Type int16
Whence int16
_ [4]byte
Start int64
Len int64
Pid int32
_ [4]byte
}
type FscryptPolicy struct {
Version uint8
Contents_encryption_mode uint8
Filenames_encryption_mode uint8
Flags uint8
Master_key_descriptor [8]uint8
}
type FscryptKey struct {
Mode uint32
Raw [64]uint8
Size uint32
}
type KeyctlDHParams struct {
Private int32
Prime int32
Base int32
}
const (
FADV_NORMAL = 0x0
FADV_RANDOM = 0x1
FADV_SEQUENTIAL = 0x2
FADV_WILLNEED = 0x3
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5
)
type RawSockaddrInet4 struct {
Family uint16
Port uint16
Addr [4]byte /* in_addr */
Zero [8]uint8
}
type RawSockaddrInet6 struct {
Family uint16
Port uint16
Flowinfo uint32
Addr [16]byte /* in6_addr */
Scope_id uint32
}
type RawSockaddrUnix struct {
Family uint16
Path [108]int8
}
type RawSockaddrLinklayer struct {
Family uint16
Protocol uint16
Ifindex int32
Hatype uint16
Pkttype uint8
Halen uint8
Addr [8]uint8
}
type RawSockaddrNetlink struct {
Family uint16
Pad uint16
Pid uint32
Groups uint32
}
type RawSockaddrHCI struct {
Family uint16
Dev uint16
Channel uint16
}
type RawSockaddrL2 struct {
Family uint16
Psm uint16
Bdaddr [6]uint8
Cid uint16
Bdaddr_type uint8
_ [1]byte
}
type RawSockaddrCAN struct {
Family uint16
_ [2]byte
Ifindex int32
Addr [8]byte
}
type RawSockaddrALG struct {
Family uint16
Type [14]uint8
Feat uint32
Mask uint32
Name [64]uint8
}
type RawSockaddrVM struct {
Family uint16
Reserved1 uint16
Port uint32
Cid uint32
Zero [4]uint8
}
type RawSockaddr struct {
Family uint16
Data [14]int8
}
type RawSockaddrAny struct {
Addr RawSockaddr
Pad [96]int8
}
type _Socklen uint32
type Linger struct {
Onoff int32
Linger int32
}
type Iovec struct {
Base *byte
Len uint32
}
type IPMreq struct {
Multiaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */
}
type IPMreqn struct {
Multiaddr [4]byte /* in_addr */
Address [4]byte /* in_addr */
Ifindex int32
}
type IPv6Mreq struct {
Multiaddr [16]byte /* in6_addr */
Interface uint32
}
type PacketMreq struct {
Ifindex int32
Type uint16
Alen uint16
Address [8]uint8
}
type Msghdr struct {
Name *byte
Namelen uint32
Iov *Iovec
Iovlen uint32
Control *byte
Controllen uint32
Flags int32
}
type Cmsghdr struct {
Len uint32
Level int32
Type int32
}
type Inet4Pktinfo struct {
Ifindex int32
Spec_dst [4]byte /* in_addr */
Addr [4]byte /* in_addr */
}
type Inet6Pktinfo struct {
Addr [16]byte /* in6_addr */
Ifindex uint32
}
type IPv6MTUInfo struct {
Addr RawSockaddrInet6
Mtu uint32
}
type ICMPv6Filter struct {
Data [8]uint32
}
type Ucred struct {
Pid int32
Uid uint32
Gid uint32
}
type TCPInfo struct {
State uint8
Ca_state uint8
Retransmits uint8
Probes uint8
Backoff uint8
Options uint8
_ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
Rcv_mss uint32
Unacked uint32
Sacked uint32
Lost uint32
Retrans uint32
Fackets uint32
Last_data_sent uint32
Last_ack_sent uint32
Last_data_recv uint32
Last_ack_recv uint32
Pmtu uint32
Rcv_ssthresh uint32
Rtt uint32
Rttvar uint32
Snd_ssthresh uint32
Snd_cwnd uint32
Advmss uint32
Reordering uint32
Rcv_rtt uint32
Rcv_space uint32
Total_retrans uint32
}
const (
SizeofSockaddrInet4 = 0x10
SizeofSockaddrInet6 = 0x1c
SizeofSockaddrAny = 0x70
SizeofSockaddrUnix = 0x6e
SizeofSockaddrLinklayer = 0x14
SizeofSockaddrNetlink = 0xc
SizeofSockaddrHCI = 0x6
SizeofSockaddrL2 = 0xe
SizeofSockaddrCAN = 0x10
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
SizeofIPMreqn = 0xc
SizeofIPv6Mreq = 0x14
SizeofPacketMreq = 0x10
SizeofMsghdr = 0x1c
SizeofCmsghdr = 0xc
SizeofInet4Pktinfo = 0xc
SizeofInet6Pktinfo = 0x14
SizeofIPv6MTUInfo = 0x20
SizeofICMPv6Filter = 0x20
SizeofUcred = 0xc
SizeofTCPInfo = 0x68
)
const (
IFA_UNSPEC = 0x0
IFA_ADDRESS = 0x1
IFA_LOCAL = 0x2
IFA_LABEL = 0x3
IFA_BROADCAST = 0x4
IFA_ANYCAST = 0x5
IFA_CACHEINFO = 0x6
IFA_MULTICAST = 0x7
IFLA_UNSPEC = 0x0
IFLA_ADDRESS = 0x1
IFLA_BROADCAST = 0x2
IFLA_IFNAME = 0x3
IFLA_MTU = 0x4
IFLA_LINK = 0x5
IFLA_QDISC = 0x6
IFLA_STATS = 0x7
IFLA_COST = 0x8
IFLA_PRIORITY = 0x9
IFLA_MASTER = 0xa
IFLA_WIRELESS = 0xb
IFLA_PROTINFO = 0xc
IFLA_TXQLEN = 0xd
IFLA_MAP = 0xe
IFLA_WEIGHT = 0xf
IFLA_OPERSTATE = 0x10
IFLA_LINKMODE = 0x11
IFLA_LINKINFO = 0x12
IFLA_NET_NS_PID = 0x13
IFLA_IFALIAS = 0x14
IFLA_NUM_VF = 0x15
IFLA_VFINFO_LIST = 0x16
IFLA_STATS64 = 0x17
IFLA_VF_PORTS = 0x18
IFLA_PORT_SELF = 0x19
IFLA_AF_SPEC = 0x1a
IFLA_GROUP = 0x1b
IFLA_NET_NS_FD = 0x1c
IFLA_EXT_MASK = 0x1d
IFLA_PROMISCUITY = 0x1e
IFLA_NUM_TX_QUEUES = 0x1f
IFLA_NUM_RX_QUEUES = 0x20
IFLA_CARRIER = 0x21
IFLA_PHYS_PORT_ID = 0x22
IFLA_CARRIER_CHANGES = 0x23
IFLA_PHYS_SWITCH_ID = 0x24
IFLA_LINK_NETNSID = 0x25
IFLA_PHYS_PORT_NAME = 0x26
IFLA_PROTO_DOWN = 0x27
IFLA_GSO_MAX_SEGS = 0x28
IFLA_GSO_MAX_SIZE = 0x29
IFLA_PAD = 0x2a
IFLA_XDP = 0x2b
IFLA_EVENT = 0x2c
IFLA_NEW_NETNSID = 0x2d
IFLA_IF_NETNSID = 0x2e
IFLA_MAX = 0x31
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
RT_SCOPE_HOST = 0xfe
RT_SCOPE_NOWHERE = 0xff
RT_TABLE_UNSPEC = 0x0
RT_TABLE_COMPAT = 0xfc
RT_TABLE_DEFAULT = 0xfd
RT_TABLE_MAIN = 0xfe
RT_TABLE_LOCAL = 0xff
RT_TABLE_MAX = 0xffffffff
RTA_UNSPEC = 0x0
RTA_DST = 0x1
RTA_SRC = 0x2
RTA_IIF = 0x3
RTA_OIF = 0x4
RTA_GATEWAY = 0x5
RTA_PRIORITY = 0x6
RTA_PREFSRC = 0x7
RTA_METRICS = 0x8
RTA_MULTIPATH = 0x9
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
RTN_UNSPEC = 0x0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
RTN_BROADCAST = 0x3
RTN_ANYCAST = 0x4
RTN_MULTICAST = 0x5
RTN_BLACKHOLE = 0x6
RTN_UNREACHABLE = 0x7
RTN_PROHIBIT = 0x8
RTN_THROW = 0x9
RTN_NAT = 0xa
RTN_XRESOLVE = 0xb
RTNLGRP_NONE = 0x0
RTNLGRP_LINK = 0x1
RTNLGRP_NOTIFY = 0x2
RTNLGRP_NEIGH = 0x3
RTNLGRP_TC = 0x4
RTNLGRP_IPV4_IFADDR = 0x5
RTNLGRP_IPV4_MROUTE = 0x6
RTNLGRP_IPV4_ROUTE = 0x7
RTNLGRP_IPV4_RULE = 0x8
RTNLGRP_IPV6_IFADDR = 0x9
RTNLGRP_IPV6_MROUTE = 0xa
RTNLGRP_IPV6_ROUTE = 0xb
RTNLGRP_IPV6_IFINFO = 0xc
RTNLGRP_IPV6_PREFIX = 0x12
RTNLGRP_IPV6_RULE = 0x13
RTNLGRP_ND_USEROPT = 0x14
SizeofNlMsghdr = 0x10
SizeofNlMsgerr = 0x14
SizeofRtGenmsg = 0x1
SizeofNlAttr = 0x4
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8
)
type NlMsghdr struct {
Len uint32
Type uint16
Flags uint16
Seq uint32
Pid uint32
}
type NlMsgerr struct {
Error int32
Msg NlMsghdr
}
type RtGenmsg struct {
Family uint8
}
type NlAttr struct {
Len uint16
Type uint16
}
type RtAttr struct {
Len uint16
Type uint16
}
type IfInfomsg struct {
Family uint8
_ uint8
Type uint16
Index int32
Flags uint32
Change uint32
}
type IfAddrmsg struct {
Family uint8
Prefixlen uint8
Flags uint8
Scope uint8
Index uint32
}
type RtMsg struct {
Family uint8
Dst_len uint8
Src_len uint8
Tos uint8
Table uint8
Protocol uint8
Scope uint8
Type uint8
Flags uint32
}
type RtNexthop struct {
Len uint16
Flags uint8
Hops uint8
Ifindex int32
}
const (
SizeofSockFilter = 0x8
SizeofSockFprog = 0x8
)
type SockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
type SockFprog struct {
Len uint16
_ [2]byte
Filter *SockFilter
}
type InotifyEvent struct {
Wd int32
Mask uint32
Cookie uint32
Len uint32
}
const SizeofInotifyEvent = 0x10
type PtraceRegs struct {
Regs [32]uint64
Lo uint64
Hi uint64
Epc uint64
Badvaddr uint64
Status uint64
Cause uint64
}
type FdSet struct {
Bits [32]int32
}
type Sysinfo_t struct {
Uptime int32
Loads [3]uint32
Totalram uint32
Freeram uint32
Sharedram uint32
Bufferram uint32
Totalswap uint32
Freeswap uint32
Procs uint16
Pad uint16
Totalhigh uint32
Freehigh uint32
Unit uint32
_ [8]int8
}
type Utsname struct {
Sysname [65]byte
Nodename [65]byte
Release [65]byte
Version [65]byte
Machine [65]byte
Domainname [65]byte
}
type Ustat_t struct {
Tfree int32
Tinode uint32
Fname [6]int8
Fpack [6]int8
}
type EpollEvent struct {
Events uint32
PadFd int32
Fd int32
Pad int32
}
const (
AT_EMPTY_PATH = 0x1000
AT_FDCWD = -0x64
AT_NO_AUTOMOUNT = 0x800
AT_REMOVEDIR = 0x200
AT_STATX_SYNC_AS_STAT = 0x0
AT_STATX_FORCE_SYNC = 0x2000
AT_STATX_DONT_SYNC = 0x4000
AT_SYMLINK_FOLLOW = 0x400
AT_SYMLINK_NOFOLLOW = 0x100
)
type PollFd struct {
Fd int32
Events int16
Revents int16
}
const (
POLLIN = 0x1
POLLPRI = 0x2
POLLOUT = 0x4
POLLRDHUP = 0x2000
POLLERR = 0x8
POLLHUP = 0x10
POLLNVAL = 0x20
)
type Sigset_t struct {
Val [32]uint32
}
const RNDGETENTCNT = 0x40045200
const PERF_IOC_FLAG_GROUP = 0x1
type Termios struct {
Iflag uint32
Oflag uint32
Cflag uint32
Lflag uint32
Line uint8
Cc [23]uint8
Ispeed uint32
Ospeed uint32
}
type Winsize struct {
Row uint16
Col uint16
Xpixel uint16
Ypixel uint16
}
type Taskstats struct {
Version uint16
_ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
_ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
Blkio_delay_total uint64
Swapin_count uint64
Swapin_delay_total uint64
Cpu_run_real_total uint64
Cpu_run_virtual_total uint64
Ac_comm [32]int8
Ac_sched uint8
Ac_pad [3]uint8
_ [4]byte
Ac_uid uint32
Ac_gid uint32
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
_ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
Ac_minflt uint64
Ac_majflt uint64
Coremem uint64
Virtmem uint64
Hiwater_rss uint64
Hiwater_vm uint64
Read_char uint64
Write_char uint64
Read_syscalls uint64
Write_syscalls uint64
Read_bytes uint64
Write_bytes uint64
Cancelled_write_bytes uint64
Nvcsw uint64
Nivcsw uint64
Ac_utimescaled uint64
Ac_stimescaled uint64
Cpu_scaled_run_real_total uint64
Freepages_count uint64
Freepages_delay_total uint64
}
const (
TASKSTATS_CMD_UNSPEC = 0x0
TASKSTATS_CMD_GET = 0x1
TASKSTATS_CMD_NEW = 0x2
TASKSTATS_TYPE_UNSPEC = 0x0
TASKSTATS_TYPE_PID = 0x1
TASKSTATS_TYPE_TGID = 0x2
TASKSTATS_TYPE_STATS = 0x3
TASKSTATS_TYPE_AGGR_PID = 0x4
TASKSTATS_TYPE_AGGR_TGID = 0x5
TASKSTATS_TYPE_NULL = 0x6
TASKSTATS_CMD_ATTR_UNSPEC = 0x0
TASKSTATS_CMD_ATTR_PID = 0x1
TASKSTATS_CMD_ATTR_TGID = 0x2
TASKSTATS_CMD_ATTR_REGISTER_CPUMASK = 0x3
TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK = 0x4
)
type CGroupStats struct {
Sleeping uint64
Running uint64
Stopped uint64
Uninterruptible uint64
Io_wait uint64
}
const (
CGROUPSTATS_CMD_UNSPEC = 0x3
CGROUPSTATS_CMD_GET = 0x4
CGROUPSTATS_CMD_NEW = 0x5
CGROUPSTATS_TYPE_UNSPEC = 0x0
CGROUPSTATS_TYPE_CGROUP_STATS = 0x1
CGROUPSTATS_CMD_ATTR_UNSPEC = 0x0
CGROUPSTATS_CMD_ATTR_FD = 0x1
)
type Genlmsghdr struct {
Cmd uint8
Version uint8
Reserved uint16
}
const (
CTRL_CMD_UNSPEC = 0x0
CTRL_CMD_NEWFAMILY = 0x1
CTRL_CMD_DELFAMILY = 0x2
CTRL_CMD_GETFAMILY = 0x3
CTRL_CMD_NEWOPS = 0x4
CTRL_CMD_DELOPS = 0x5
CTRL_CMD_GETOPS = 0x6
CTRL_CMD_NEWMCAST_GRP = 0x7
CTRL_CMD_DELMCAST_GRP = 0x8
CTRL_CMD_GETMCAST_GRP = 0x9
CTRL_ATTR_UNSPEC = 0x0
CTRL_ATTR_FAMILY_ID = 0x1
CTRL_ATTR_FAMILY_NAME = 0x2
CTRL_ATTR_VERSION = 0x3
CTRL_ATTR_HDRSIZE = 0x4
CTRL_ATTR_MAXATTR = 0x5
CTRL_ATTR_OPS = 0x6
CTRL_ATTR_MCAST_GROUPS = 0x7
CTRL_ATTR_OP_UNSPEC = 0x0
CTRL_ATTR_OP_ID = 0x1
CTRL_ATTR_OP_FLAGS = 0x2
CTRL_ATTR_MCAST_GRP_UNSPEC = 0x0
CTRL_ATTR_MCAST_GRP_NAME = 0x1
CTRL_ATTR_MCAST_GRP_ID = 0x2
)
type cpuMask uint32
const (
_CPU_SETSIZE = 0x400
_NCPUBITS = 0x20
)
const (
BDADDR_BREDR = 0x0
BDADDR_LE_PUBLIC = 0x1
BDADDR_LE_RANDOM = 0x2
)
type PerfEventAttr struct {
Type uint32
Size uint32
Config uint64
Sample uint64
Sample_type uint64
Read_format uint64
Bits uint64
Wakeup uint32
Bp_type uint32
Ext1 uint64
Ext2 uint64
Branch_sample_type uint64
Sample_regs_user uint64
Sample_stack_user uint32
Clockid int32
Sample_regs_intr uint64
Aux_watermark uint32
_ uint32
}
type PerfEventMmapPage struct {
Version uint32
Compat_version uint32
Lock uint32
Index uint32
Offset int64
Time_enabled uint64
Time_running uint64
Capabilities uint64
Pmc_width uint16
Time_shift uint16
Time_mult uint32
Time_offset uint64
Time_zero uint64
Size uint32
_ [948]uint8
Data_head uint64
Data_tail uint64
Data_offset uint64
Data_size uint64
Aux_head uint64
Aux_tail uint64
Aux_offset uint64
Aux_size uint64
}
const (
PerfBitDisabled uint64 = CBitFieldMaskBit0
PerfBitInherit = CBitFieldMaskBit1
PerfBitPinned = CBitFieldMaskBit2
PerfBitExclusive = CBitFieldMaskBit3
PerfBitExcludeUser = CBitFieldMaskBit4
PerfBitExcludeKernel = CBitFieldMaskBit5
PerfBitExcludeHv = CBitFieldMaskBit6
PerfBitExcludeIdle = CBitFieldMaskBit7
PerfBitMmap = CBitFieldMaskBit8
PerfBitComm = CBitFieldMaskBit9
PerfBitFreq = CBitFieldMaskBit10
PerfBitInheritStat = CBitFieldMaskBit11
PerfBitEnableOnExec = CBitFieldMaskBit12
PerfBitTask = CBitFieldMaskBit13
PerfBitWatermark = CBitFieldMaskBit14
PerfBitPreciseIPBit1 = CBitFieldMaskBit15
PerfBitPreciseIPBit2 = CBitFieldMaskBit16
PerfBitMmapData = CBitFieldMaskBit17
PerfBitSampleIDAll = CBitFieldMaskBit18
PerfBitExcludeHost = CBitFieldMaskBit19
PerfBitExcludeGuest = CBitFieldMaskBit20
PerfBitExcludeCallchainKernel = CBitFieldMaskBit21
PerfBitExcludeCallchainUser = CBitFieldMaskBit22
PerfBitMmap2 = CBitFieldMaskBit23
PerfBitCommExec = CBitFieldMaskBit24
PerfBitUseClockID = CBitFieldMaskBit25
PerfBitContextSwitch = CBitFieldMaskBit26
)
const (
PERF_TYPE_HARDWARE = 0x0
PERF_TYPE_SOFTWARE = 0x1
PERF_TYPE_TRACEPOINT = 0x2
PERF_TYPE_HW_CACHE = 0x3
PERF_TYPE_RAW = 0x4
PERF_TYPE_BREAKPOINT = 0x5
PERF_COUNT_HW_CPU_CYCLES = 0x0
PERF_COUNT_HW_INSTRUCTIONS = 0x1
PERF_COUNT_HW_CACHE_REFERENCES = 0x2
PERF_COUNT_HW_CACHE_MISSES = 0x3
PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 0x4
PERF_COUNT_HW_BRANCH_MISSES = 0x5
PERF_COUNT_HW_BUS_CYCLES = 0x6
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 0x7
PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 0x8
PERF_COUNT_HW_REF_CPU_CYCLES = 0x9
PERF_COUNT_HW_CACHE_L1D = 0x0
PERF_COUNT_HW_CACHE_L1I = 0x1
PERF_COUNT_HW_CACHE_LL = 0x2
PERF_COUNT_HW_CACHE_DTLB = 0x3
PERF_COUNT_HW_CACHE_ITLB = 0x4
PERF_COUNT_HW_CACHE_BPU = 0x5
PERF_COUNT_HW_CACHE_NODE = 0x6
PERF_COUNT_HW_CACHE_OP_READ = 0x0
PERF_COUNT_HW_CACHE_OP_WRITE = 0x1
PERF_COUNT_HW_CACHE_OP_PREFETCH = 0x2
PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0x0
PERF_COUNT_HW_CACHE_RESULT_MISS = 0x1
PERF_COUNT_SW_CPU_CLOCK = 0x0
PERF_COUNT_SW_TASK_CLOCK = 0x1
PERF_COUNT_SW_PAGE_FAULTS = 0x2
PERF_COUNT_SW_CONTEXT_SWITCHES = 0x3
PERF_COUNT_SW_CPU_MIGRATIONS = 0x4
PERF_COUNT_SW_PAGE_FAULTS_MIN = 0x5
PERF_COUNT_SW_PAGE_FAULTS_MAJ = 0x6
PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
PERF_COUNT_SW_EMULATION_FAULTS = 0x8
PERF_COUNT_SW_DUMMY = 0x9
PERF_SAMPLE_IP = 0x1
PERF_SAMPLE_TID = 0x2
PERF_SAMPLE_TIME = 0x4
PERF_SAMPLE_ADDR = 0x8
PERF_SAMPLE_READ = 0x10
PERF_SAMPLE_CALLCHAIN = 0x20
PERF_SAMPLE_ID = 0x40
PERF_SAMPLE_CPU = 0x80
PERF_SAMPLE_PERIOD = 0x100
PERF_SAMPLE_STREAM_ID = 0x200
PERF_SAMPLE_RAW = 0x400
PERF_SAMPLE_BRANCH_STACK = 0x800
PERF_SAMPLE_BRANCH_USER = 0x1
PERF_SAMPLE_BRANCH_KERNEL = 0x2
PERF_SAMPLE_BRANCH_HV = 0x4
PERF_SAMPLE_BRANCH_ANY = 0x8
PERF_SAMPLE_BRANCH_ANY_CALL = 0x10
PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
PERF_SAMPLE_BRANCH_IND_CALL = 0x40
PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
PERF_FORMAT_ID = 0x4
PERF_FORMAT_GROUP = 0x8
PERF_RECORD_MMAP = 0x1
PERF_RECORD_LOST = 0x2
PERF_RECORD_COMM = 0x3
PERF_RECORD_EXIT = 0x4
PERF_RECORD_THROTTLE = 0x5
PERF_RECORD_UNTHROTTLE = 0x6
PERF_RECORD_FORK = 0x7
PERF_RECORD_READ = 0x8
PERF_RECORD_SAMPLE = 0x9
PERF_CONTEXT_HV = -0x20
PERF_CONTEXT_KERNEL = -0x80
PERF_CONTEXT_USER = -0x200
PERF_CONTEXT_GUEST = -0x800
PERF_CONTEXT_GUEST_KERNEL = -0x880
PERF_CONTEXT_GUEST_USER = -0xa00
PERF_FLAG_FD_NO_GROUP = 0x1
PERF_FLAG_FD_OUTPUT = 0x2
PERF_FLAG_PID_CGROUP = 0x4
)
const (
CBitFieldMaskBit0 = 0x8000000000000000
CBitFieldMaskBit1 = 0x4000000000000000
CBitFieldMaskBit2 = 0x2000000000000000
CBitFieldMaskBit3 = 0x1000000000000000
CBitFieldMaskBit4 = 0x800000000000000
CBitFieldMaskBit5 = 0x400000000000000
CBitFieldMaskBit6 = 0x200000000000000
CBitFieldMaskBit7 = 0x100000000000000
CBitFieldMaskBit8 = 0x80000000000000
CBitFieldMaskBit9 = 0x40000000000000
CBitFieldMaskBit10 = 0x20000000000000
CBitFieldMaskBit11 = 0x10000000000000
CBitFieldMaskBit12 = 0x8000000000000
CBitFieldMaskBit13 = 0x4000000000000
CBitFieldMaskBit14 = 0x2000000000000
CBitFieldMaskBit15 = 0x1000000000000
CBitFieldMaskBit16 = 0x800000000000
CBitFieldMaskBit17 = 0x400000000000
CBitFieldMaskBit18 = 0x200000000000
CBitFieldMaskBit19 = 0x100000000000
CBitFieldMaskBit20 = 0x80000000000
CBitFieldMaskBit21 = 0x40000000000
CBitFieldMaskBit22 = 0x20000000000
CBitFieldMaskBit23 = 0x10000000000
CBitFieldMaskBit24 = 0x8000000000
CBitFieldMaskBit25 = 0x4000000000
CBitFieldMaskBit26 = 0x2000000000
CBitFieldMaskBit27 = 0x1000000000
CBitFieldMaskBit28 = 0x800000000
CBitFieldMaskBit29 = 0x400000000
CBitFieldMaskBit30 = 0x200000000
CBitFieldMaskBit31 = 0x100000000
CBitFieldMaskBit32 = 0x80000000
CBitFieldMaskBit33 = 0x40000000
CBitFieldMaskBit34 = 0x20000000
CBitFieldMaskBit35 = 0x10000000
CBitFieldMaskBit36 = 0x8000000
CBitFieldMaskBit37 = 0x4000000
CBitFieldMaskBit38 = 0x2000000
CBitFieldMaskBit39 = 0x1000000
CBitFieldMaskBit40 = 0x800000
CBitFieldMaskBit41 = 0x400000
CBitFieldMaskBit42 = 0x200000
CBitFieldMaskBit43 = 0x100000
CBitFieldMaskBit44 = 0x80000
CBitFieldMaskBit45 = 0x40000
CBitFieldMaskBit46 = 0x20000
CBitFieldMaskBit47 = 0x10000
CBitFieldMaskBit48 = 0x8000
CBitFieldMaskBit49 = 0x4000
CBitFieldMaskBit50 = 0x2000
CBitFieldMaskBit51 = 0x1000
CBitFieldMaskBit52 = 0x800
CBitFieldMaskBit53 = 0x400
CBitFieldMaskBit54 = 0x200
CBitFieldMaskBit55 = 0x100
CBitFieldMaskBit56 = 0x80
CBitFieldMaskBit57 = 0x40
CBitFieldMaskBit58 = 0x20
CBitFieldMaskBit59 = 0x10
CBitFieldMaskBit60 = 0x8
CBitFieldMaskBit61 = 0x4
CBitFieldMaskBit62 = 0x2
CBitFieldMaskBit63 = 0x1
)
type SockaddrStorage struct {
Family uint16
_ [122]int8
_ uint32
}
type TCPMD5Sig struct {
Addr SockaddrStorage
Flags uint8
Prefixlen uint8
Keylen uint16
_ uint32
Key [80]uint8
}
type HDDriveCmdHdr struct {
Command uint8
Number uint8
Feature uint8
Count uint8
}
type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
Start uint32
}
type HDDriveID struct {
Config uint16
Cyls uint16
Reserved2 uint16
Heads uint16
Track_bytes uint16
Sector_bytes uint16
Sectors uint16
Vendor0 uint16
Vendor1 uint16
Vendor2 uint16
Serial_no [20]uint8
Buf_type uint16
Buf_size uint16
Ecc_bytes uint16
Fw_rev [8]uint8
Model [40]uint8
Max_multsect uint8
Vendor3 uint8
Dword_io uint16
Vendor4 uint8
Capability uint8
Reserved50 uint16
Vendor5 uint8
TPIO uint8
Vendor6 uint8
TDMA uint8
Field_valid uint16
Cur_cyls uint16
Cur_heads uint16
Cur_sectors uint16
Cur_capacity0 uint16
Cur_capacity1 uint16
Multsect uint8
Multsect_valid uint8
Lba_capacity uint32
Dma_1word uint16
Dma_mword uint16
Eide_pio_modes uint16
Eide_dma_min uint16
Eide_dma_time uint16
Eide_pio uint16
Eide_pio_iordy uint16
Words69_70 [2]uint16
Words71_74 [4]uint16
Queue_depth uint16
Words76_79 [4]uint16
Major_rev_num uint16
Minor_rev_num uint16
Command_set_1 uint16
Command_set_2 uint16
Cfsse uint16
Cfs_enable_1 uint16
Cfs_enable_2 uint16
Csf_default uint16
Dma_ultra uint16
Trseuc uint16
TrsEuc uint16
CurAPMvalues uint16
Mprc uint16
Hw_config uint16
Acoustic uint16
Msrqs uint16
Sxfert uint16
Sal uint16
Spg uint32
Lba_capacity_2 uint64
Words104_125 [22]uint16
Last_lun uint16
Word127 uint16
Dlf uint16
Csfo uint16
Words130_155 [26]uint16
Word156 uint16
Words157_159 [3]uint16
Cfa_power uint16
Words161_175 [15]uint16
Words176_205 [30]uint16
Words206_254 [49]uint16
Integrity_word uint16
}
type Statfs_t struct {
Type int32
Bsize int32
Frsize int32
_ [4]byte
Blocks uint64
Bfree uint64
Files uint64
Ffree uint64
Bavail uint64
Fsid Fsid
Namelen int32
Flags int32
Spare [5]int32
_ [4]byte
}
const (
ST_MANDLOCK = 0x40
ST_NOATIME = 0x400
ST_NODEV = 0x4
ST_NODIRATIME = 0x800
ST_NOEXEC = 0x8
ST_NOSUID = 0x2
ST_RDONLY = 0x1
ST_RELATIME = 0x1000
ST_SYNCHRONOUS = 0x10
)
type TpacketHdr struct {
Status uint32
Len uint32
Snaplen uint32
Mac uint16
Net uint16
Sec uint32
Usec uint32
}
type Tpacket2Hdr struct {
Status uint32
Len uint32
Snaplen uint32
Mac uint16
Net uint16
Sec uint32
Nsec uint32
Vlan_tci uint16
Vlan_tpid uint16
_ [4]uint8
}
type Tpacket3Hdr struct {
Next_offset uint32
Sec uint32
Nsec uint32
Snaplen uint32
Len uint32
Status uint32
Mac uint16
Net uint16
Hv1 TpacketHdrVariant1
_ [8]uint8
}
type TpacketHdrVariant1 struct {
Rxhash uint32
Vlan_tci uint32
Vlan_tpid uint16
_ uint16
}
type TpacketBlockDesc struct {
Version uint32
To_priv uint32
Hdr [40]byte
}
type TpacketReq struct {
Block_size uint32
Block_nr uint32
Frame_size uint32
Frame_nr uint32
}
type TpacketReq3 struct {
Block_size uint32
Block_nr uint32
Frame_size uint32
Frame_nr uint32
Retire_blk_tov uint32
Sizeof_priv uint32
Feature_req_word uint32
}
type TpacketStats struct {
Packets uint32
Drops uint32
}
type TpacketStatsV3 struct {
Packets uint32
Drops uint32
Freeze_q_cnt uint32
}
type TpacketAuxdata struct {
Status uint32
Len uint32
Snaplen uint32
Mac uint16
Net uint16
Vlan_tci uint16
Vlan_tpid uint16
}
const (
TPACKET_V1 = 0x0
TPACKET_V2 = 0x1
TPACKET_V3 = 0x2
)
const (
SizeofTpacketHdr = 0x18
SizeofTpacket2Hdr = 0x20
SizeofTpacket3Hdr = 0x30
)
const (
NF_INET_PRE_ROUTING = 0x0
NF_INET_LOCAL_IN = 0x1
NF_INET_FORWARD = 0x2
NF_INET_LOCAL_OUT = 0x3
NF_INET_POST_ROUTING = 0x4
NF_INET_NUMHOOKS = 0x5
)
const (
NF_NETDEV_INGRESS = 0x0
NF_NETDEV_NUMHOOKS = 0x1
)
const (
NFPROTO_UNSPEC = 0x0
NFPROTO_INET = 0x1
NFPROTO_IPV4 = 0x2
NFPROTO_ARP = 0x3
NFPROTO_NETDEV = 0x5
NFPROTO_BRIDGE = 0x7
NFPROTO_IPV6 = 0xa
NFPROTO_DECNET = 0xc
NFPROTO_NUMPROTO = 0xd
)
type Nfgenmsg struct {
Nfgen_family uint8
Version uint8
Res_id uint16
}
const (
NFNL_BATCH_UNSPEC = 0x0
NFNL_BATCH_GENID = 0x1
)
const (
NFT_REG_VERDICT = 0x0
NFT_REG_1 = 0x1
NFT_REG_2 = 0x2
NFT_REG_3 = 0x3
NFT_REG_4 = 0x4
NFT_REG32_00 = 0x8
NFT_REG32_01 = 0x9
NFT_REG32_02 = 0xa
NFT_REG32_03 = 0xb
NFT_REG32_04 = 0xc
NFT_REG32_05 = 0xd
NFT_REG32_06 = 0xe
NFT_REG32_07 = 0xf
NFT_REG32_08 = 0x10
NFT_REG32_09 = 0x11
NFT_REG32_10 = 0x12
NFT_REG32_11 = 0x13
NFT_REG32_12 = 0x14
NFT_REG32_13 = 0x15
NFT_REG32_14 = 0x16
NFT_REG32_15 = 0x17
NFT_CONTINUE = -0x1
NFT_BREAK = -0x2
NFT_JUMP = -0x3
NFT_GOTO = -0x4
NFT_RETURN = -0x5
NFT_MSG_NEWTABLE = 0x0
NFT_MSG_GETTABLE = 0x1
NFT_MSG_DELTABLE = 0x2
NFT_MSG_NEWCHAIN = 0x3
NFT_MSG_GETCHAIN = 0x4
NFT_MSG_DELCHAIN = 0x5
NFT_MSG_NEWRULE = 0x6
NFT_MSG_GETRULE = 0x7
NFT_MSG_DELRULE = 0x8
NFT_MSG_NEWSET = 0x9
NFT_MSG_GETSET = 0xa
NFT_MSG_DELSET = 0xb
NFT_MSG_NEWSETELEM = 0xc
NFT_MSG_GETSETELEM = 0xd
NFT_MSG_DELSETELEM = 0xe
NFT_MSG_NEWGEN = 0xf
NFT_MSG_GETGEN = 0x10
NFT_MSG_TRACE = 0x11
NFT_MSG_NEWOBJ = 0x12
NFT_MSG_GETOBJ = 0x13
NFT_MSG_DELOBJ = 0x14
NFT_MSG_GETOBJ_RESET = 0x15
NFT_MSG_MAX = 0x19
NFTA_LIST_UNPEC = 0x0
NFTA_LIST_ELEM = 0x1
NFTA_HOOK_UNSPEC = 0x0
NFTA_HOOK_HOOKNUM = 0x1
NFTA_HOOK_PRIORITY = 0x2
NFTA_HOOK_DEV = 0x3
NFT_TABLE_F_DORMANT = 0x1
NFTA_TABLE_UNSPEC = 0x0
NFTA_TABLE_NAME = 0x1
NFTA_TABLE_FLAGS = 0x2
NFTA_TABLE_USE = 0x3
NFTA_CHAIN_UNSPEC = 0x0
NFTA_CHAIN_TABLE = 0x1
NFTA_CHAIN_HANDLE = 0x2
NFTA_CHAIN_NAME = 0x3
NFTA_CHAIN_HOOK = 0x4
NFTA_CHAIN_POLICY = 0x5
NFTA_CHAIN_USE = 0x6
NFTA_CHAIN_TYPE = 0x7
NFTA_CHAIN_COUNTERS = 0x8
NFTA_CHAIN_PAD = 0x9
NFTA_RULE_UNSPEC = 0x0
NFTA_RULE_TABLE = 0x1
NFTA_RULE_CHAIN = 0x2
NFTA_RULE_HANDLE = 0x3
NFTA_RULE_EXPRESSIONS = 0x4
NFTA_RULE_COMPAT = 0x5
NFTA_RULE_POSITION = 0x6
NFTA_RULE_USERDATA = 0x7
NFTA_RULE_PAD = 0x8
NFTA_RULE_ID = 0x9
NFT_RULE_COMPAT_F_INV = 0x2
NFT_RULE_COMPAT_F_MASK = 0x2
NFTA_RULE_COMPAT_UNSPEC = 0x0
NFTA_RULE_COMPAT_PROTO = 0x1
NFTA_RULE_COMPAT_FLAGS = 0x2
NFT_SET_ANONYMOUS = 0x1
NFT_SET_CONSTANT = 0x2
NFT_SET_INTERVAL = 0x4
NFT_SET_MAP = 0x8
NFT_SET_TIMEOUT = 0x10
NFT_SET_EVAL = 0x20
NFT_SET_OBJECT = 0x40
NFT_SET_POL_PERFORMANCE = 0x0
NFT_SET_POL_MEMORY = 0x1
NFTA_SET_DESC_UNSPEC = 0x0
NFTA_SET_DESC_SIZE = 0x1
NFTA_SET_UNSPEC = 0x0
NFTA_SET_TABLE = 0x1
NFTA_SET_NAME = 0x2
NFTA_SET_FLAGS = 0x3
NFTA_SET_KEY_TYPE = 0x4
NFTA_SET_KEY_LEN = 0x5
NFTA_SET_DATA_TYPE = 0x6
NFTA_SET_DATA_LEN = 0x7
NFTA_SET_POLICY = 0x8
NFTA_SET_DESC = 0x9
NFTA_SET_ID = 0xa
NFTA_SET_TIMEOUT = 0xb
NFTA_SET_GC_INTERVAL = 0xc
NFTA_SET_USERDATA = 0xd
NFTA_SET_PAD = 0xe
NFTA_SET_OBJ_TYPE = 0xf
NFT_SET_ELEM_INTERVAL_END = 0x1
NFTA_SET_ELEM_UNSPEC = 0x0
NFTA_SET_ELEM_KEY = 0x1
NFTA_SET_ELEM_DATA = 0x2
NFTA_SET_ELEM_FLAGS = 0x3
NFTA_SET_ELEM_TIMEOUT = 0x4
NFTA_SET_ELEM_EXPIRATION = 0x5
NFTA_SET_ELEM_USERDATA = 0x6
NFTA_SET_ELEM_EXPR = 0x7
NFTA_SET_ELEM_PAD = 0x8
NFTA_SET_ELEM_OBJREF = 0x9
NFTA_SET_ELEM_LIST_UNSPEC = 0x0
NFTA_SET_ELEM_LIST_TABLE = 0x1
NFTA_SET_ELEM_LIST_SET = 0x2
NFTA_SET_ELEM_LIST_ELEMENTS = 0x3
NFTA_SET_ELEM_LIST_SET_ID = 0x4
NFT_DATA_VALUE = 0x0
NFT_DATA_VERDICT = 0xffffff00
NFTA_DATA_UNSPEC = 0x0
NFTA_DATA_VALUE = 0x1
NFTA_DATA_VERDICT = 0x2
NFTA_VERDICT_UNSPEC = 0x0
NFTA_VERDICT_CODE = 0x1
NFTA_VERDICT_CHAIN = 0x2
NFTA_EXPR_UNSPEC = 0x0
NFTA_EXPR_NAME = 0x1
NFTA_EXPR_DATA = 0x2
NFTA_IMMEDIATE_UNSPEC = 0x0
NFTA_IMMEDIATE_DREG = 0x1
NFTA_IMMEDIATE_DATA = 0x2
NFTA_BITWISE_UNSPEC = 0x0
NFTA_BITWISE_SREG = 0x1
NFTA_BITWISE_DREG = 0x2
NFTA_BITWISE_LEN = 0x3
NFTA_BITWISE_MASK = 0x4
NFTA_BITWISE_XOR = 0x5
NFT_BYTEORDER_NTOH = 0x0
NFT_BYTEORDER_HTON = 0x1
NFTA_BYTEORDER_UNSPEC = 0x0
NFTA_BYTEORDER_SREG = 0x1
NFTA_BYTEORDER_DREG = 0x2
NFTA_BYTEORDER_OP = 0x3
NFTA_BYTEORDER_LEN = 0x4
NFTA_BYTEORDER_SIZE = 0x5
NFT_CMP_EQ = 0x0
NFT_CMP_NEQ = 0x1
NFT_CMP_LT = 0x2
NFT_CMP_LTE = 0x3
NFT_CMP_GT = 0x4
NFT_CMP_GTE = 0x5
NFTA_CMP_UNSPEC = 0x0
NFTA_CMP_SREG = 0x1
NFTA_CMP_OP = 0x2
NFTA_CMP_DATA = 0x3
NFT_RANGE_EQ = 0x0
NFT_RANGE_NEQ = 0x1
NFTA_RANGE_UNSPEC = 0x0
NFTA_RANGE_SREG = 0x1
NFTA_RANGE_OP = 0x2
NFTA_RANGE_FROM_DATA = 0x3
NFTA_RANGE_TO_DATA = 0x4
NFT_LOOKUP_F_INV = 0x1
NFTA_LOOKUP_UNSPEC = 0x0
NFTA_LOOKUP_SET = 0x1
NFTA_LOOKUP_SREG = 0x2
NFTA_LOOKUP_DREG = 0x3
NFTA_LOOKUP_SET_ID = 0x4
NFTA_LOOKUP_FLAGS = 0x5
NFT_DYNSET_OP_ADD = 0x0
NFT_DYNSET_OP_UPDATE = 0x1
NFT_DYNSET_F_INV = 0x1
NFTA_DYNSET_UNSPEC = 0x0
NFTA_DYNSET_SET_NAME = 0x1
NFTA_DYNSET_SET_ID = 0x2
NFTA_DYNSET_OP = 0x3
NFTA_DYNSET_SREG_KEY = 0x4
NFTA_DYNSET_SREG_DATA = 0x5
NFTA_DYNSET_TIMEOUT = 0x6
NFTA_DYNSET_EXPR = 0x7
NFTA_DYNSET_PAD = 0x8
NFTA_DYNSET_FLAGS = 0x9
NFT_PAYLOAD_LL_HEADER = 0x0
NFT_PAYLOAD_NETWORK_HEADER = 0x1
NFT_PAYLOAD_TRANSPORT_HEADER = 0x2
NFT_PAYLOAD_CSUM_NONE = 0x0
NFT_PAYLOAD_CSUM_INET = 0x1
NFT_PAYLOAD_L4CSUM_PSEUDOHDR = 0x1
NFTA_PAYLOAD_UNSPEC = 0x0
NFTA_PAYLOAD_DREG = 0x1
NFTA_PAYLOAD_BASE = 0x2
NFTA_PAYLOAD_OFFSET = 0x3
NFTA_PAYLOAD_LEN = 0x4
NFTA_PAYLOAD_SREG = 0x5
NFTA_PAYLOAD_CSUM_TYPE = 0x6
NFTA_PAYLOAD_CSUM_OFFSET = 0x7
NFTA_PAYLOAD_CSUM_FLAGS = 0x8
NFT_EXTHDR_F_PRESENT = 0x1
NFT_EXTHDR_OP_IPV6 = 0x0
NFT_EXTHDR_OP_TCPOPT = 0x1
NFTA_EXTHDR_UNSPEC = 0x0
NFTA_EXTHDR_DREG = 0x1
NFTA_EXTHDR_TYPE = 0x2
NFTA_EXTHDR_OFFSET = 0x3
NFTA_EXTHDR_LEN = 0x4
NFTA_EXTHDR_FLAGS = 0x5
NFTA_EXTHDR_OP = 0x6
NFTA_EXTHDR_SREG = 0x7
NFT_META_LEN = 0x0
NFT_META_PROTOCOL = 0x1
NFT_META_PRIORITY = 0x2
NFT_META_MARK = 0x3
NFT_META_IIF = 0x4
NFT_META_OIF = 0x5
NFT_META_IIFNAME = 0x6
NFT_META_OIFNAME = 0x7
NFT_META_IIFTYPE = 0x8
NFT_META_OIFTYPE = 0x9
NFT_META_SKUID = 0xa
NFT_META_SKGID = 0xb
NFT_META_NFTRACE = 0xc
NFT_META_RTCLASSID = 0xd
NFT_META_SECMARK = 0xe
NFT_META_NFPROTO = 0xf
NFT_META_L4PROTO = 0x10
NFT_META_BRI_IIFNAME = 0x11
NFT_META_BRI_OIFNAME = 0x12
NFT_META_PKTTYPE = 0x13
NFT_META_CPU = 0x14
NFT_META_IIFGROUP = 0x15
NFT_META_OIFGROUP = 0x16
NFT_META_CGROUP = 0x17
NFT_META_PRANDOM = 0x18
NFT_RT_CLASSID = 0x0
NFT_RT_NEXTHOP4 = 0x1
NFT_RT_NEXTHOP6 = 0x2
NFT_RT_TCPMSS = 0x3
NFT_HASH_JENKINS = 0x0
NFT_HASH_SYM = 0x1
NFTA_HASH_UNSPEC = 0x0
NFTA_HASH_SREG = 0x1
NFTA_HASH_DREG = 0x2
NFTA_HASH_LEN = 0x3
NFTA_HASH_MODULUS = 0x4
NFTA_HASH_SEED = 0x5
NFTA_HASH_OFFSET = 0x6
NFTA_HASH_TYPE = 0x7
NFTA_META_UNSPEC = 0x0
NFTA_META_DREG = 0x1
NFTA_META_KEY = 0x2
NFTA_META_SREG = 0x3
NFTA_RT_UNSPEC = 0x0
NFTA_RT_DREG = 0x1
NFTA_RT_KEY = 0x2
NFT_CT_STATE = 0x0
NFT_CT_DIRECTION = 0x1
NFT_CT_STATUS = 0x2
NFT_CT_MARK = 0x3
NFT_CT_SECMARK = 0x4
NFT_CT_EXPIRATION = 0x5
NFT_CT_HELPER = 0x6
NFT_CT_L3PROTOCOL = 0x7
NFT_CT_SRC = 0x8
NFT_CT_DST = 0x9
NFT_CT_PROTOCOL = 0xa
NFT_CT_PROTO_SRC = 0xb
NFT_CT_PROTO_DST = 0xc
NFT_CT_LABELS = 0xd
NFT_CT_PKTS = 0xe
NFT_CT_BYTES = 0xf
NFT_CT_AVGPKT = 0x10
NFT_CT_ZONE = 0x11
NFT_CT_EVENTMASK = 0x12
NFTA_CT_UNSPEC = 0x0
NFTA_CT_DREG = 0x1
NFTA_CT_KEY = 0x2
NFTA_CT_DIRECTION = 0x3
NFTA_CT_SREG = 0x4
NFT_LIMIT_PKTS = 0x0
NFT_LIMIT_PKT_BYTES = 0x1
NFT_LIMIT_F_INV = 0x1
NFTA_LIMIT_UNSPEC = 0x0
NFTA_LIMIT_RATE = 0x1
NFTA_LIMIT_UNIT = 0x2
NFTA_LIMIT_BURST = 0x3
NFTA_LIMIT_TYPE = 0x4
NFTA_LIMIT_FLAGS = 0x5
NFTA_LIMIT_PAD = 0x6
NFTA_COUNTER_UNSPEC = 0x0
NFTA_COUNTER_BYTES = 0x1
NFTA_COUNTER_PACKETS = 0x2
NFTA_COUNTER_PAD = 0x3
NFTA_LOG_UNSPEC = 0x0
NFTA_LOG_GROUP = 0x1
NFTA_LOG_PREFIX = 0x2
NFTA_LOG_SNAPLEN = 0x3
NFTA_LOG_QTHRESHOLD = 0x4
NFTA_LOG_LEVEL = 0x5
NFTA_LOG_FLAGS = 0x6
NFTA_QUEUE_UNSPEC = 0x0
NFTA_QUEUE_NUM = 0x1
NFTA_QUEUE_TOTAL = 0x2
NFTA_QUEUE_FLAGS = 0x3
NFTA_QUEUE_SREG_QNUM = 0x4
NFT_QUOTA_F_INV = 0x1
NFT_QUOTA_F_DEPLETED = 0x2
NFTA_QUOTA_UNSPEC = 0x0
NFTA_QUOTA_BYTES = 0x1
NFTA_QUOTA_FLAGS = 0x2
NFTA_QUOTA_PAD = 0x3
NFTA_QUOTA_CONSUMED = 0x4
NFT_REJECT_ICMP_UNREACH = 0x0
NFT_REJECT_TCP_RST = 0x1
NFT_REJECT_ICMPX_UNREACH = 0x2
NFT_REJECT_ICMPX_NO_ROUTE = 0x0
NFT_REJECT_ICMPX_PORT_UNREACH = 0x1
NFT_REJECT_ICMPX_HOST_UNREACH = 0x2
NFT_REJECT_ICMPX_ADMIN_PROHIBITED = 0x3
NFTA_REJECT_UNSPEC = 0x0
NFTA_REJECT_TYPE = 0x1
NFTA_REJECT_ICMP_CODE = 0x2
NFT_NAT_SNAT = 0x0
NFT_NAT_DNAT = 0x1
NFTA_NAT_UNSPEC = 0x0
NFTA_NAT_TYPE = 0x1
NFTA_NAT_FAMILY = 0x2
NFTA_NAT_REG_ADDR_MIN = 0x3
NFTA_NAT_REG_ADDR_MAX = 0x4
NFTA_NAT_REG_PROTO_MIN = 0x5
NFTA_NAT_REG_PROTO_MAX = 0x6
NFTA_NAT_FLAGS = 0x7
NFTA_MASQ_UNSPEC = 0x0
NFTA_MASQ_FLAGS = 0x1
NFTA_MASQ_REG_PROTO_MIN = 0x2
NFTA_MASQ_REG_PROTO_MAX = 0x3
NFTA_REDIR_UNSPEC = 0x0
NFTA_REDIR_REG_PROTO_MIN = 0x1
NFTA_REDIR_REG_PROTO_MAX = 0x2
NFTA_REDIR_FLAGS = 0x3
NFTA_DUP_UNSPEC = 0x0
NFTA_DUP_SREG_ADDR = 0x1
NFTA_DUP_SREG_DEV = 0x2
NFTA_FWD_UNSPEC = 0x0
NFTA_FWD_SREG_DEV = 0x1
NFTA_OBJREF_UNSPEC = 0x0
NFTA_OBJREF_IMM_TYPE = 0x1
NFTA_OBJREF_IMM_NAME = 0x2
NFTA_OBJREF_SET_SREG = 0x3
NFTA_OBJREF_SET_NAME = 0x4
NFTA_OBJREF_SET_ID = 0x5
NFTA_GEN_UNSPEC = 0x0
NFTA_GEN_ID = 0x1
NFTA_GEN_PROC_PID = 0x2
NFTA_GEN_PROC_NAME = 0x3
NFTA_FIB_UNSPEC = 0x0
NFTA_FIB_DREG = 0x1
NFTA_FIB_RESULT = 0x2
NFTA_FIB_FLAGS = 0x3
NFT_FIB_RESULT_UNSPEC = 0x0
NFT_FIB_RESULT_OIF = 0x1
NFT_FIB_RESULT_OIFNAME = 0x2
NFT_FIB_RESULT_ADDRTYPE = 0x3
NFTA_FIB_F_SADDR = 0x1
NFTA_FIB_F_DADDR = 0x2
NFTA_FIB_F_MARK = 0x4
NFTA_FIB_F_IIF = 0x8
NFTA_FIB_F_OIF = 0x10
NFTA_FIB_F_PRESENT = 0x20
NFTA_CT_HELPER_UNSPEC = 0x0
NFTA_CT_HELPER_NAME = 0x1
NFTA_CT_HELPER_L3PROTO = 0x2
NFTA_CT_HELPER_L4PROTO = 0x3
NFTA_OBJ_UNSPEC = 0x0
NFTA_OBJ_TABLE = 0x1
NFTA_OBJ_NAME = 0x2
NFTA_OBJ_TYPE = 0x3
NFTA_OBJ_DATA = 0x4
NFTA_OBJ_USE = 0x5
NFTA_TRACE_UNSPEC = 0x0
NFTA_TRACE_TABLE = 0x1
NFTA_TRACE_CHAIN = 0x2
NFTA_TRACE_RULE_HANDLE = 0x3
NFTA_TRACE_TYPE = 0x4
NFTA_TRACE_VERDICT = 0x5
NFTA_TRACE_ID = 0x6
NFTA_TRACE_LL_HEADER = 0x7
NFTA_TRACE_NETWORK_HEADER = 0x8
NFTA_TRACE_TRANSPORT_HEADER = 0x9
NFTA_TRACE_IIF = 0xa
NFTA_TRACE_IIFTYPE = 0xb
NFTA_TRACE_OIF = 0xc
NFTA_TRACE_OIFTYPE = 0xd
NFTA_TRACE_MARK = 0xe
NFTA_TRACE_NFPROTO = 0xf
NFTA_TRACE_POLICY = 0x10
NFTA_TRACE_PAD = 0x11
NFT_TRACETYPE_UNSPEC = 0x0
NFT_TRACETYPE_POLICY = 0x1
NFT_TRACETYPE_RETURN = 0x2
NFT_TRACETYPE_RULE = 0x3
NFTA_NG_UNSPEC = 0x0
NFTA_NG_DREG = 0x1
NFTA_NG_MODULUS = 0x2
NFTA_NG_TYPE = 0x3
NFTA_NG_OFFSET = 0x4
NFT_NG_INCREMENTAL = 0x0
NFT_NG_RANDOM = 0x1
)
type RTCTime struct {
Sec int32
Min int32
Hour int32
Mday int32
Mon int32
Year int32
Wday int32
Yday int32
Isdst int32
}
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
_ [2]byte
Time RTCTime
}
type RTCPLLInfo struct {
Ctrl int32
Value int32
Max int32
Min int32
Posmult int32
Negmult int32
Clock int32
}
| bdarnell/etcd | vendor/golang.org/x/sys/unix/ztypes_linux_mips.go | GO | apache-2.0 | 46,978 |
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.metron.enrichment.bolt;
import java.io.UnsupportedEncodingException;
import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.metron.common.Constants;
import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig;
import org.apache.metron.common.configuration.enrichment.handler.ConfigHandler;
import org.apache.metron.common.utils.MessageUtils;
import org.apache.metron.enrichment.configuration.Enrichment;
import org.apache.metron.enrichment.utils.EnrichmentUtils;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.tuple.Tuple;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnrichmentSplitterBolt extends SplitBolt<JSONObject> {
protected static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private List<Enrichment> enrichments;
protected String messageFieldName;
private transient JSONParser parser;
public EnrichmentSplitterBolt(String zookeeperUrl) {
super(zookeeperUrl);
}
public EnrichmentSplitterBolt withEnrichments(List<Enrichment> enrichments) {
this.enrichments = enrichments;
return this;
}
public EnrichmentSplitterBolt withMessageFieldName(String messageFieldName) {
this.messageFieldName = messageFieldName;
return this;
}
@Override
public void prepare(Map map, TopologyContext topologyContext) {
parser = new JSONParser();
}
@Override
public String getKey(Tuple tuple, JSONObject message) {
String key = null, guid = null;
try {
key = tuple.getStringByField("key");
guid = (String)message.get(Constants.GUID);
}
catch(Throwable t) {
//swallowing this just in case.
}
if(key != null) {
return key;
}
else if(guid != null) {
return guid;
}
else {
return UUID.randomUUID().toString();
}
}
@Override
public JSONObject generateMessage(Tuple tuple) {
JSONObject message = null;
if (messageFieldName == null) {
byte[] data = tuple.getBinary(0);
try {
message = (JSONObject) parser.parse(new String(data, "UTF8"));
message.put(getClass().getSimpleName().toLowerCase() + ".splitter.begin.ts", "" + System.currentTimeMillis());
} catch (ParseException | UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
message = (JSONObject) tuple.getValueByField(messageFieldName);
message.put(getClass().getSimpleName().toLowerCase() + ".splitter.begin.ts", "" + System.currentTimeMillis());
}
return message;
}
@Override
public Set<String> getStreamIds() {
Set<String> streamIds = new HashSet<>();
for(Enrichment enrichment: enrichments) {
streamIds.add(enrichment.getType());
}
return streamIds;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, List<JSONObject>> splitMessage(JSONObject message) {
Map<String, List<JSONObject>> streamMessageMap = new HashMap<>();
String sensorType = MessageUtils.getSensorType(message);
Map<String, Object> enrichmentFieldMap = getFieldMap(sensorType);
Map<String, ConfigHandler> fieldToHandler = getFieldToHandlerMap(sensorType);
Set<String> enrichmentTypes = new HashSet<>(enrichmentFieldMap.keySet());
enrichmentTypes.addAll(fieldToHandler.keySet());
for (String enrichmentType : enrichmentTypes) {
Object fields = enrichmentFieldMap.get(enrichmentType);
ConfigHandler retriever = fieldToHandler.get(enrichmentType);
List<JSONObject> enrichmentObject = retriever.getType()
.splitByFields( message
, fields
, field -> getKeyName(enrichmentType, field)
, retriever
);
for(JSONObject eo : enrichmentObject) {
eo.put(Constants.SENSOR_TYPE, sensorType);
}
streamMessageMap.put(enrichmentType, enrichmentObject);
}
message.put(getClass().getSimpleName().toLowerCase() + ".splitter.end.ts", "" + System.currentTimeMillis());
return streamMessageMap;
}
protected Map<String, ConfigHandler> getFieldToHandlerMap(String sensorType) {
if(sensorType != null) {
SensorEnrichmentConfig config = getConfigurations().getSensorEnrichmentConfig(sensorType);
if (config != null) {
return config.getEnrichment().getEnrichmentConfigs();
} else {
LOG.info("Unable to retrieve a sensor enrichment config of {}", sensorType);
}
} else {
LOG.error("Trying to retrieve a field map with sensor type of null");
}
return new HashMap<>();
}
protected Map<String, Object > getFieldMap(String sensorType) {
if(sensorType != null) {
SensorEnrichmentConfig config = getConfigurations().getSensorEnrichmentConfig(sensorType);
if (config != null) {
return config.getEnrichment().getFieldMap();
} else {
LOG.info("Unable to retrieve a sensor enrichment config of {}", sensorType);
}
} else {
LOG.error("Trying to retrieve a field map with sensor type of null");
}
return new HashMap<>();
}
protected String getKeyName(String type, String field) {
return EnrichmentUtils.getEnrichmentKey(type, field);
}
@Override
public void declareOther(OutputFieldsDeclarer declarer) {
}
@Override
public void emitOther(Tuple tuple, JSONObject message) {
}
}
| dlyle65535/metron | metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/bolt/EnrichmentSplitterBolt.java | Java | apache-2.0 | 6,519 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.hdfs;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.DefaultExchange;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import static org.apache.camel.component.hdfs.HdfsConstants.DEFAULT_OPENED_SUFFIX;
import static org.apache.camel.component.hdfs.HdfsConstants.DEFAULT_READ_SUFFIX;
import static org.apache.camel.component.hdfs.HdfsTestSupport.CWD;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class HdfsConsumerTest {
private HdfsEndpoint endpoint;
private Processor processor;
private HdfsConfiguration endpointConfig;
private HdfsInfoFactory hdfsInfoFactory;
private CamelContext context;
private FileSystem fileSystem;
private Configuration configuration;
private HdfsConsumer underTest;
@BeforeEach
public void setUp() throws Exception {
endpoint = mock(HdfsEndpoint.class);
processor = mock(Processor.class);
endpointConfig = mock(HdfsConfiguration.class);
hdfsInfoFactory = mock(HdfsInfoFactory.class);
HdfsInfo hdfsInfo = mock(HdfsInfo.class);
fileSystem = mock(FileSystem.class);
configuration = mock(Configuration.class);
Path path = mock(Path.class);
when(hdfsInfoFactory.newHdfsInfo(anyString())).thenReturn(hdfsInfo);
when(hdfsInfoFactory.getEndpointConfig()).thenReturn(endpointConfig);
when(hdfsInfoFactory.newHdfsInfo(anyString())).thenReturn(hdfsInfo);
when(hdfsInfo.getFileSystem()).thenReturn(fileSystem);
when(hdfsInfo.getConfiguration()).thenReturn(configuration);
when(hdfsInfo.getPath()).thenReturn(path);
when(endpointConfig.getReadSuffix()).thenReturn(DEFAULT_READ_SUFFIX);
when(endpointConfig.getOpenedSuffix()).thenReturn(DEFAULT_OPENED_SUFFIX);
context = new DefaultCamelContext();
}
@Test
public void doStartWithoutHdfsSetup() throws Exception {
// given
String hdfsPath = "hdfs://localhost/target/test/multiple-consumers";
when(endpointConfig.getFileSystemType()).thenReturn(HdfsFileSystemType.LOCAL);
when(endpointConfig.getPath()).thenReturn(hdfsPath);
when(endpointConfig.isConnectOnStartup()).thenReturn(false);
when(endpoint.getCamelContext()).thenReturn(context);
when(endpoint.getEndpointUri()).thenReturn(hdfsPath);
underTest = new HdfsConsumer(endpoint, processor, endpointConfig, hdfsInfoFactory, new StringBuilder(hdfsPath));
// when
underTest.doStart();
// then
verify(hdfsInfoFactory, times(0)).newHdfsInfo(anyString());
}
@Test
public void doStartWithHdfsSetup() throws Exception {
// given
String hdfsPath = "hdfs://localhost/target/test/multiple-consumers";
when(endpointConfig.getFileSystemType()).thenReturn(HdfsFileSystemType.LOCAL);
when(endpointConfig.getPath()).thenReturn(hdfsPath);
when(endpointConfig.isConnectOnStartup()).thenReturn(true);
when(endpointConfig.getFileSystemLabel(anyString())).thenReturn("TEST_FS_LABEL");
when(endpoint.getCamelContext()).thenReturn(context);
when(endpoint.getEndpointUri()).thenReturn(hdfsPath);
underTest = new HdfsConsumer(endpoint, processor, endpointConfig, hdfsInfoFactory, new StringBuilder(hdfsPath));
// when
underTest.doStart();
// then
verify(hdfsInfoFactory, times(1)).newHdfsInfo(hdfsPath);
}
@Test
public void doPollFromExistingLocalFile() throws Exception {
// given
String hdfsPath = "hdfs://localhost/target/test/multiple-consumers";
when(endpointConfig.getFileSystemType()).thenReturn(HdfsFileSystemType.LOCAL);
when(endpointConfig.getFileType()).thenReturn(HdfsFileType.NORMAL_FILE);
when(endpointConfig.getPath()).thenReturn(hdfsPath);
when(endpointConfig.getOwner()).thenReturn("spiderman");
when(endpointConfig.isConnectOnStartup()).thenReturn(true);
when(endpointConfig.getFileSystemLabel(anyString())).thenReturn("TEST_FS_LABEL");
when(endpointConfig.getChunkSize()).thenReturn(100 * 1000);
when(endpointConfig.getMaxMessagesPerPoll()).thenReturn(10);
when(endpoint.getCamelContext()).thenReturn(context);
when(endpoint.createExchange()).thenReturn(new DefaultExchange(context));
when(endpoint.getEndpointUri()).thenReturn(hdfsPath);
when(fileSystem.isFile(any(Path.class))).thenReturn(true);
FileStatus[] fileStatuses = new FileStatus[1];
FileStatus fileStatus = mock(FileStatus.class);
fileStatuses[0] = fileStatus;
when(fileSystem.globStatus(any(Path.class))).thenReturn(fileStatuses);
when(fileStatus.getPath()).thenReturn(new Path(hdfsPath));
when(fileStatus.isFile()).thenReturn(true);
when(fileStatus.isDirectory()).thenReturn(false);
when(fileStatus.getOwner()).thenReturn("spiderman");
String normalFile = CWD.getAbsolutePath() + "/src/test/resources/hdfs/normal_file.txt";
FSDataInputStream fsDataInputStream = new FSDataInputStream(new MockDataInputStream(normalFile));
when(fileSystem.rename(any(Path.class), any(Path.class))).thenReturn(true);
when(fileSystem.open(any(Path.class))).thenReturn(fsDataInputStream);
ArgumentCaptor<Exchange> exchangeCaptor = ArgumentCaptor.forClass(Exchange.class);
underTest = new HdfsConsumer(endpoint, processor, endpointConfig, hdfsInfoFactory, new StringBuilder(hdfsPath));
// when
int actual = underTest.doPoll();
// then
assertThat(actual, is(1));
verify(processor, times(1)).process(exchangeCaptor.capture());
Exchange exchange = exchangeCaptor.getValue();
assertThat(exchange, notNullValue());
ByteArrayOutputStream body = exchange.getIn().getBody(ByteArrayOutputStream.class);
assertThat(body, notNullValue());
assertThat(body.toString(), startsWith(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget fermentum arcu, vel dignissim ipsum."));
}
@Test
public void doPollFromExistingLocalFileWithStreamDownload() throws Exception {
// given
String hdfsPath = "hdfs://localhost/target/test/multiple-consumers";
when(endpointConfig.getFileSystemType()).thenReturn(HdfsFileSystemType.LOCAL);
when(endpointConfig.getFileType()).thenReturn(HdfsFileType.NORMAL_FILE);
when(endpointConfig.getPath()).thenReturn(hdfsPath);
when(endpointConfig.getOwner()).thenReturn("spiderman");
when(endpointConfig.isConnectOnStartup()).thenReturn(true);
when(endpointConfig.getFileSystemLabel(anyString())).thenReturn("TEST_FS_LABEL");
when(endpointConfig.getChunkSize()).thenReturn(100 * 1000);
when(endpointConfig.isStreamDownload()).thenReturn(true);
when(endpointConfig.getMaxMessagesPerPoll()).thenReturn(10);
when(endpoint.getCamelContext()).thenReturn(context);
when(endpoint.createExchange()).thenReturn(new DefaultExchange(context));
when(endpoint.getEndpointUri()).thenReturn(hdfsPath);
when(fileSystem.isFile(any(Path.class))).thenReturn(true);
FileStatus[] fileStatuses = new FileStatus[1];
FileStatus fileStatus = mock(FileStatus.class);
fileStatuses[0] = fileStatus;
when(fileSystem.globStatus(any(Path.class))).thenReturn(fileStatuses);
when(fileStatus.getPath()).thenReturn(new Path(hdfsPath));
when(fileStatus.isFile()).thenReturn(true);
when(fileStatus.isDirectory()).thenReturn(false);
when(fileStatus.getOwner()).thenReturn("spiderman");
String normalFile = CWD.getAbsolutePath() + "/src/test/resources/hdfs/normal_file.txt";
FSDataInputStream fsDataInputStream = new FSDataInputStream(new MockDataInputStream(normalFile));
when(fileSystem.rename(any(Path.class), any(Path.class))).thenReturn(true);
when(fileSystem.open(any(Path.class))).thenReturn(fsDataInputStream);
ArgumentCaptor<Exchange> exchangeCaptor = ArgumentCaptor.forClass(Exchange.class);
underTest = new HdfsConsumer(endpoint, processor, endpointConfig, hdfsInfoFactory, new StringBuilder(hdfsPath));
// when
int actual = underTest.doPoll();
// then
assertThat(actual, is(1));
verify(processor, times(1)).process(exchangeCaptor.capture());
Exchange exchange = exchangeCaptor.getValue();
assertThat(exchange, notNullValue());
InputStream body = (InputStream) exchange.getIn().getBody();
assertThat(body, notNullValue());
}
}
| gnodet/camel | components/camel-hdfs/src/test/java/org/apache/camel/component/hdfs/HdfsConsumerTest.java | Java | apache-2.0 | 10,407 |
"""Test Agent DVR integration."""
from unittest.mock import AsyncMock, patch
from agent import AgentError
from homeassistant.components.agent_dvr.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from . import CONF_DATA, create_entry
from tests.components.agent_dvr import init_integration
from tests.test_util.aiohttp import AiohttpClientMocker
async def _create_mocked_agent(available: bool = True):
mocked_agent = AsyncMock()
mocked_agent.is_available = available
return mocked_agent
def _patch_init_agent(mocked_agent):
return patch(
"homeassistant.components.agent_dvr.Agent",
return_value=mocked_agent,
)
async def test_setup_config_and_unload(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
):
"""Test setup and unload."""
entry = await init_integration(hass, aioclient_mock)
assert entry.state == ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.data == CONF_DATA
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN)
async def test_async_setup_entry_not_ready(hass: HomeAssistant):
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
entry = create_entry(hass)
with patch(
"homeassistant.components.agent_dvr.Agent.update",
side_effect=AgentError,
):
await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ConfigEntryState.SETUP_RETRY
with _patch_init_agent(await _create_mocked_agent(available=False)):
await hass.config_entries.async_reload(entry.entry_id)
assert entry.state == ConfigEntryState.SETUP_RETRY
| jawilson/home-assistant | tests/components/agent_dvr/test_init.py | Python | apache-2.0 | 1,876 |
<html lang='tw'>
<!--
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<p>Wɔawo adesamma nyinaa sɛ nnipa a wɔwɔ ahofadi. Wɔn nyinaa wɔ nidi ne kyɛfa koro. Wɔwɔ adwene ne ahonim, na ɛsɛ sɛ wobu wɔn ho wɔn ho sɛ anuanom.</p>
</html>
| googlei18n/noto-source | test/LGC/fontdiff-tw-Latn_udhr.html | HTML | apache-2.0 | 819 |
/*
* Copyright 2016-present Open Networking Laboratory
*
* 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.onosproject.xosclient.impl;
import org.onosproject.xosclient.api.XosAccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import static com.google.common.net.MediaType.JSON_UTF_8;
import static java.net.HttpURLConnection.HTTP_OK;
/**
* XOS common REST API implementation.
*/
public class XosApi {
private final Logger log = LoggerFactory.getLogger(getClass());
protected static final String EMPTY_STRING = "";
protected static final String EMPTY_JSON_STRING = "{}";
protected final String baseUrl;
protected final XosAccess access;
protected final Client client;
/**
* Default constructor.
*
* @param baseUrl base url of this api
* @param xosAccess xos access
*/
public XosApi(String baseUrl, XosAccess xosAccess) {
this.baseUrl = baseUrl;
this.access = xosAccess;
this.client = ClientBuilder.newClient();
}
/**
* Returns the access of this api.
*
* @return xos access
*/
public XosAccess access() {
return this.access;
}
/**
* Returns the base url of this api.
*
* @return base url
*/
public String baseUrl() {
return this.baseUrl;
}
/**
* Returns response of the REST get operation with a given additional path.
*
* @param path path or null
* @return response json string
*/
public String restGet(String path) {
WebTarget wt = client.target(access.endpoint() + baseUrl).path(path);
Invocation.Builder builder = wt.request(JSON_UTF_8.toString());
try {
Response response = builder.get();
if (response.getStatus() != HTTP_OK) {
log.warn("Failed to get resource {}", access.endpoint() + baseUrl + path);
return EMPTY_JSON_STRING;
}
} catch (javax.ws.rs.ProcessingException e) {
return EMPTY_JSON_STRING;
}
return builder.get(String.class);
}
}
| maheshraju-Huawei/actn | apps/xosclient/src/main/java/org/onosproject/xosclient/impl/XosApi.java | Java | apache-2.0 | 2,811 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Source code</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<div class="sourceContainer">
<pre><span class="sourceLineNo">001</span>/**<a name="line.1"></a>
<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one<a name="line.2"></a>
<span class="sourceLineNo">003</span> * or more contributor license agreements. See the NOTICE file<a name="line.3"></a>
<span class="sourceLineNo">004</span> * distributed with this work for additional information<a name="line.4"></a>
<span class="sourceLineNo">005</span> * regarding copyright ownership. The ASF licenses this file<a name="line.5"></a>
<span class="sourceLineNo">006</span> * to you under the Apache License, Version 2.0 (the<a name="line.6"></a>
<span class="sourceLineNo">007</span> * "License"); you may not use this file except in compliance<a name="line.7"></a>
<span class="sourceLineNo">008</span> * with the License. You may obtain a copy of the License at<a name="line.8"></a>
<span class="sourceLineNo">009</span> *<a name="line.9"></a>
<span class="sourceLineNo">010</span> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.10"></a>
<span class="sourceLineNo">011</span> *<a name="line.11"></a>
<span class="sourceLineNo">012</span> * Unless required by applicable law or agreed to in writing, software<a name="line.12"></a>
<span class="sourceLineNo">013</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.13"></a>
<span class="sourceLineNo">014</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.14"></a>
<span class="sourceLineNo">015</span> * See the License for the specific language governing permissions and<a name="line.15"></a>
<span class="sourceLineNo">016</span> * limitations under the License.<a name="line.16"></a>
<span class="sourceLineNo">017</span> */<a name="line.17"></a>
<span class="sourceLineNo">018</span>package org.apache.hadoop.fs;<a name="line.18"></a>
<span class="sourceLineNo">019</span><a name="line.19"></a>
<span class="sourceLineNo">020</span>import java.io.FileNotFoundException;<a name="line.20"></a>
<span class="sourceLineNo">021</span>import java.io.IOException;<a name="line.21"></a>
<span class="sourceLineNo">022</span>import java.lang.reflect.Constructor;<a name="line.22"></a>
<span class="sourceLineNo">023</span>import java.net.URI;<a name="line.23"></a>
<span class="sourceLineNo">024</span>import java.net.URISyntaxException;<a name="line.24"></a>
<span class="sourceLineNo">025</span>import java.util.ArrayList;<a name="line.25"></a>
<span class="sourceLineNo">026</span>import java.util.EnumSet;<a name="line.26"></a>
<span class="sourceLineNo">027</span>import java.util.HashMap;<a name="line.27"></a>
<span class="sourceLineNo">028</span>import java.util.List;<a name="line.28"></a>
<span class="sourceLineNo">029</span>import java.util.Map;<a name="line.29"></a>
<span class="sourceLineNo">030</span>import java.util.NoSuchElementException;<a name="line.30"></a>
<span class="sourceLineNo">031</span>import java.util.StringTokenizer;<a name="line.31"></a>
<span class="sourceLineNo">032</span>import java.util.concurrent.ConcurrentHashMap;<a name="line.32"></a>
<span class="sourceLineNo">033</span><a name="line.33"></a>
<span class="sourceLineNo">034</span>import org.apache.commons.logging.Log;<a name="line.34"></a>
<span class="sourceLineNo">035</span>import org.apache.commons.logging.LogFactory;<a name="line.35"></a>
<span class="sourceLineNo">036</span>import org.apache.hadoop.HadoopIllegalArgumentException;<a name="line.36"></a>
<span class="sourceLineNo">037</span>import org.apache.hadoop.classification.InterfaceAudience;<a name="line.37"></a>
<span class="sourceLineNo">038</span>import org.apache.hadoop.classification.InterfaceStability;<a name="line.38"></a>
<span class="sourceLineNo">039</span>import org.apache.hadoop.conf.Configuration;<a name="line.39"></a>
<span class="sourceLineNo">040</span>import org.apache.hadoop.fs.FileSystem.Statistics;<a name="line.40"></a>
<span class="sourceLineNo">041</span>import org.apache.hadoop.fs.Options.ChecksumOpt;<a name="line.41"></a>
<span class="sourceLineNo">042</span>import org.apache.hadoop.fs.Options.CreateOpts;<a name="line.42"></a>
<span class="sourceLineNo">043</span>import org.apache.hadoop.fs.Options.Rename;<a name="line.43"></a>
<span class="sourceLineNo">044</span>import org.apache.hadoop.fs.permission.AclEntry;<a name="line.44"></a>
<span class="sourceLineNo">045</span>import org.apache.hadoop.fs.permission.AclStatus;<a name="line.45"></a>
<span class="sourceLineNo">046</span>import org.apache.hadoop.fs.permission.FsAction;<a name="line.46"></a>
<span class="sourceLineNo">047</span>import org.apache.hadoop.fs.permission.FsPermission;<a name="line.47"></a>
<span class="sourceLineNo">048</span>import org.apache.hadoop.security.AccessControlException;<a name="line.48"></a>
<span class="sourceLineNo">049</span>import org.apache.hadoop.security.SecurityUtil;<a name="line.49"></a>
<span class="sourceLineNo">050</span>import org.apache.hadoop.security.token.Token;<a name="line.50"></a>
<span class="sourceLineNo">051</span>import org.apache.hadoop.util.Progressable;<a name="line.51"></a>
<span class="sourceLineNo">052</span><a name="line.52"></a>
<span class="sourceLineNo">053</span>import com.google.common.annotations.VisibleForTesting;<a name="line.53"></a>
<span class="sourceLineNo">054</span><a name="line.54"></a>
<span class="sourceLineNo">055</span>/**<a name="line.55"></a>
<span class="sourceLineNo">056</span> * This class provides an interface for implementors of a Hadoop file system<a name="line.56"></a>
<span class="sourceLineNo">057</span> * (analogous to the VFS of Unix). Applications do not access this class;<a name="line.57"></a>
<span class="sourceLineNo">058</span> * instead they access files across all file systems using {@link FileContext}.<a name="line.58"></a>
<span class="sourceLineNo">059</span> * <a name="line.59"></a>
<span class="sourceLineNo">060</span> * Pathnames passed to AbstractFileSystem can be fully qualified URI that<a name="line.60"></a>
<span class="sourceLineNo">061</span> * matches the "this" file system (ie same scheme and authority) <a name="line.61"></a>
<span class="sourceLineNo">062</span> * or a Slash-relative name that is assumed to be relative<a name="line.62"></a>
<span class="sourceLineNo">063</span> * to the root of the "this" file system .<a name="line.63"></a>
<span class="sourceLineNo">064</span> */<a name="line.64"></a>
<span class="sourceLineNo">065</span>@InterfaceAudience.Public<a name="line.65"></a>
<span class="sourceLineNo">066</span>@InterfaceStability.Evolving /*Evolving for a release,to be changed to Stable */<a name="line.66"></a>
<span class="sourceLineNo">067</span>public abstract class AbstractFileSystem {<a name="line.67"></a>
<span class="sourceLineNo">068</span> static final Log LOG = LogFactory.getLog(AbstractFileSystem.class);<a name="line.68"></a>
<span class="sourceLineNo">069</span><a name="line.69"></a>
<span class="sourceLineNo">070</span> /** Recording statistics per a file system class. */<a name="line.70"></a>
<span class="sourceLineNo">071</span> private static final Map<URI, Statistics> <a name="line.71"></a>
<span class="sourceLineNo">072</span> STATISTICS_TABLE = new HashMap<URI, Statistics>();<a name="line.72"></a>
<span class="sourceLineNo">073</span> <a name="line.73"></a>
<span class="sourceLineNo">074</span> /** Cache of constructors for each file system class. */<a name="line.74"></a>
<span class="sourceLineNo">075</span> private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = <a name="line.75"></a>
<span class="sourceLineNo">076</span> new ConcurrentHashMap<Class<?>, Constructor<?>>();<a name="line.76"></a>
<span class="sourceLineNo">077</span> <a name="line.77"></a>
<span class="sourceLineNo">078</span> private static final Class<?>[] URI_CONFIG_ARGS = <a name="line.78"></a>
<span class="sourceLineNo">079</span> new Class[]{URI.class, Configuration.class};<a name="line.79"></a>
<span class="sourceLineNo">080</span> <a name="line.80"></a>
<span class="sourceLineNo">081</span> /** The statistics for this file system. */<a name="line.81"></a>
<span class="sourceLineNo">082</span> protected Statistics statistics;<a name="line.82"></a>
<span class="sourceLineNo">083</span><a name="line.83"></a>
<span class="sourceLineNo">084</span> @VisibleForTesting<a name="line.84"></a>
<span class="sourceLineNo">085</span> static final String NO_ABSTRACT_FS_ERROR = "No AbstractFileSystem configured for scheme";<a name="line.85"></a>
<span class="sourceLineNo">086</span> <a name="line.86"></a>
<span class="sourceLineNo">087</span> private final URI myUri;<a name="line.87"></a>
<span class="sourceLineNo">088</span> <a name="line.88"></a>
<span class="sourceLineNo">089</span> public Statistics getStatistics() {<a name="line.89"></a>
<span class="sourceLineNo">090</span> return statistics;<a name="line.90"></a>
<span class="sourceLineNo">091</span> }<a name="line.91"></a>
<span class="sourceLineNo">092</span> <a name="line.92"></a>
<span class="sourceLineNo">093</span> /**<a name="line.93"></a>
<span class="sourceLineNo">094</span> * Returns true if the specified string is considered valid in the path part<a name="line.94"></a>
<span class="sourceLineNo">095</span> * of a URI by this file system. The default implementation enforces the rules<a name="line.95"></a>
<span class="sourceLineNo">096</span> * of HDFS, but subclasses may override this method to implement specific<a name="line.96"></a>
<span class="sourceLineNo">097</span> * validation rules for specific file systems.<a name="line.97"></a>
<span class="sourceLineNo">098</span> * <a name="line.98"></a>
<span class="sourceLineNo">099</span> * @param src String source filename to check, path part of the URI<a name="line.99"></a>
<span class="sourceLineNo">100</span> * @return boolean true if the specified string is considered valid<a name="line.100"></a>
<span class="sourceLineNo">101</span> */<a name="line.101"></a>
<span class="sourceLineNo">102</span> public boolean isValidName(String src) {<a name="line.102"></a>
<span class="sourceLineNo">103</span> // Prohibit ".." "." and anything containing ":"<a name="line.103"></a>
<span class="sourceLineNo">104</span> StringTokenizer tokens = new StringTokenizer(src, Path.SEPARATOR);<a name="line.104"></a>
<span class="sourceLineNo">105</span> while(tokens.hasMoreTokens()) {<a name="line.105"></a>
<span class="sourceLineNo">106</span> String element = tokens.nextToken();<a name="line.106"></a>
<span class="sourceLineNo">107</span> if (element.equals("..") ||<a name="line.107"></a>
<span class="sourceLineNo">108</span> element.equals(".") ||<a name="line.108"></a>
<span class="sourceLineNo">109</span> (element.indexOf(":") >= 0)) {<a name="line.109"></a>
<span class="sourceLineNo">110</span> return false;<a name="line.110"></a>
<span class="sourceLineNo">111</span> }<a name="line.111"></a>
<span class="sourceLineNo">112</span> }<a name="line.112"></a>
<span class="sourceLineNo">113</span> return true;<a name="line.113"></a>
<span class="sourceLineNo">114</span> }<a name="line.114"></a>
<span class="sourceLineNo">115</span> <a name="line.115"></a>
<span class="sourceLineNo">116</span> /** <a name="line.116"></a>
<span class="sourceLineNo">117</span> * Create an object for the given class and initialize it from conf.<a name="line.117"></a>
<span class="sourceLineNo">118</span> * @param theClass class of which an object is created<a name="line.118"></a>
<span class="sourceLineNo">119</span> * @param conf Configuration<a name="line.119"></a>
<span class="sourceLineNo">120</span> * @return a new object<a name="line.120"></a>
<span class="sourceLineNo">121</span> */<a name="line.121"></a>
<span class="sourceLineNo">122</span> @SuppressWarnings("unchecked")<a name="line.122"></a>
<span class="sourceLineNo">123</span> static <T> T newInstance(Class<T> theClass,<a name="line.123"></a>
<span class="sourceLineNo">124</span> URI uri, Configuration conf) {<a name="line.124"></a>
<span class="sourceLineNo">125</span> T result;<a name="line.125"></a>
<span class="sourceLineNo">126</span> try {<a name="line.126"></a>
<span class="sourceLineNo">127</span> Constructor<T> meth = (Constructor<T>) CONSTRUCTOR_CACHE.get(theClass);<a name="line.127"></a>
<span class="sourceLineNo">128</span> if (meth == null) {<a name="line.128"></a>
<span class="sourceLineNo">129</span> meth = theClass.getDeclaredConstructor(URI_CONFIG_ARGS);<a name="line.129"></a>
<span class="sourceLineNo">130</span> meth.setAccessible(true);<a name="line.130"></a>
<span class="sourceLineNo">131</span> CONSTRUCTOR_CACHE.put(theClass, meth);<a name="line.131"></a>
<span class="sourceLineNo">132</span> }<a name="line.132"></a>
<span class="sourceLineNo">133</span> result = meth.newInstance(uri, conf);<a name="line.133"></a>
<span class="sourceLineNo">134</span> } catch (Exception e) {<a name="line.134"></a>
<span class="sourceLineNo">135</span> throw new RuntimeException(e);<a name="line.135"></a>
<span class="sourceLineNo">136</span> }<a name="line.136"></a>
<span class="sourceLineNo">137</span> return result;<a name="line.137"></a>
<span class="sourceLineNo">138</span> }<a name="line.138"></a>
<span class="sourceLineNo">139</span> <a name="line.139"></a>
<span class="sourceLineNo">140</span> /**<a name="line.140"></a>
<span class="sourceLineNo">141</span> * Create a file system instance for the specified uri using the conf. The<a name="line.141"></a>
<span class="sourceLineNo">142</span> * conf is used to find the class name that implements the file system. The<a name="line.142"></a>
<span class="sourceLineNo">143</span> * conf is also passed to the file system for its configuration.<a name="line.143"></a>
<span class="sourceLineNo">144</span> *<a name="line.144"></a>
<span class="sourceLineNo">145</span> * @param uri URI of the file system<a name="line.145"></a>
<span class="sourceLineNo">146</span> * @param conf Configuration for the file system<a name="line.146"></a>
<span class="sourceLineNo">147</span> * <a name="line.147"></a>
<span class="sourceLineNo">148</span> * @return Returns the file system for the given URI<a name="line.148"></a>
<span class="sourceLineNo">149</span> *<a name="line.149"></a>
<span class="sourceLineNo">150</span> * @throws UnsupportedFileSystemException file system for <code>uri</code> is<a name="line.150"></a>
<span class="sourceLineNo">151</span> * not found<a name="line.151"></a>
<span class="sourceLineNo">152</span> */<a name="line.152"></a>
<span class="sourceLineNo">153</span> public static AbstractFileSystem createFileSystem(URI uri, Configuration conf)<a name="line.153"></a>
<span class="sourceLineNo">154</span> throws UnsupportedFileSystemException {<a name="line.154"></a>
<span class="sourceLineNo">155</span> final String fsImplConf = String.format("fs.AbstractFileSystem.%s.impl",<a name="line.155"></a>
<span class="sourceLineNo">156</span> uri.getScheme());<a name="line.156"></a>
<span class="sourceLineNo">157</span><a name="line.157"></a>
<span class="sourceLineNo">158</span> Class<?> clazz = conf.getClass(fsImplConf, null);<a name="line.158"></a>
<span class="sourceLineNo">159</span> if (clazz == null) {<a name="line.159"></a>
<span class="sourceLineNo">160</span> throw new UnsupportedFileSystemException(String.format(<a name="line.160"></a>
<span class="sourceLineNo">161</span> "%s=null: %s: %s",<a name="line.161"></a>
<span class="sourceLineNo">162</span> fsImplConf, NO_ABSTRACT_FS_ERROR, uri.getScheme()));<a name="line.162"></a>
<span class="sourceLineNo">163</span> }<a name="line.163"></a>
<span class="sourceLineNo">164</span> return (AbstractFileSystem) newInstance(clazz, uri, conf);<a name="line.164"></a>
<span class="sourceLineNo">165</span> }<a name="line.165"></a>
<span class="sourceLineNo">166</span><a name="line.166"></a>
<span class="sourceLineNo">167</span> /**<a name="line.167"></a>
<span class="sourceLineNo">168</span> * Get the statistics for a particular file system.<a name="line.168"></a>
<span class="sourceLineNo">169</span> * <a name="line.169"></a>
<span class="sourceLineNo">170</span> * @param uri<a name="line.170"></a>
<span class="sourceLineNo">171</span> * used as key to lookup STATISTICS_TABLE. Only scheme and authority<a name="line.171"></a>
<span class="sourceLineNo">172</span> * part of the uri are used.<a name="line.172"></a>
<span class="sourceLineNo">173</span> * @return a statistics object<a name="line.173"></a>
<span class="sourceLineNo">174</span> */<a name="line.174"></a>
<span class="sourceLineNo">175</span> protected static synchronized Statistics getStatistics(URI uri) {<a name="line.175"></a>
<span class="sourceLineNo">176</span> String scheme = uri.getScheme();<a name="line.176"></a>
<span class="sourceLineNo">177</span> if (scheme == null) {<a name="line.177"></a>
<span class="sourceLineNo">178</span> throw new IllegalArgumentException("Scheme not defined in the uri: "<a name="line.178"></a>
<span class="sourceLineNo">179</span> + uri);<a name="line.179"></a>
<span class="sourceLineNo">180</span> }<a name="line.180"></a>
<span class="sourceLineNo">181</span> URI baseUri = getBaseUri(uri);<a name="line.181"></a>
<span class="sourceLineNo">182</span> Statistics result = STATISTICS_TABLE.get(baseUri);<a name="line.182"></a>
<span class="sourceLineNo">183</span> if (result == null) {<a name="line.183"></a>
<span class="sourceLineNo">184</span> result = new Statistics(scheme);<a name="line.184"></a>
<span class="sourceLineNo">185</span> STATISTICS_TABLE.put(baseUri, result);<a name="line.185"></a>
<span class="sourceLineNo">186</span> }<a name="line.186"></a>
<span class="sourceLineNo">187</span> return result;<a name="line.187"></a>
<span class="sourceLineNo">188</span> }<a name="line.188"></a>
<span class="sourceLineNo">189</span> <a name="line.189"></a>
<span class="sourceLineNo">190</span> private static URI getBaseUri(URI uri) {<a name="line.190"></a>
<span class="sourceLineNo">191</span> String scheme = uri.getScheme();<a name="line.191"></a>
<span class="sourceLineNo">192</span> String authority = uri.getAuthority();<a name="line.192"></a>
<span class="sourceLineNo">193</span> String baseUriString = scheme + "://";<a name="line.193"></a>
<span class="sourceLineNo">194</span> if (authority != null) {<a name="line.194"></a>
<span class="sourceLineNo">195</span> baseUriString = baseUriString + authority;<a name="line.195"></a>
<span class="sourceLineNo">196</span> } else {<a name="line.196"></a>
<span class="sourceLineNo">197</span> baseUriString = baseUriString + "/";<a name="line.197"></a>
<span class="sourceLineNo">198</span> }<a name="line.198"></a>
<span class="sourceLineNo">199</span> return URI.create(baseUriString);<a name="line.199"></a>
<span class="sourceLineNo">200</span> }<a name="line.200"></a>
<span class="sourceLineNo">201</span> <a name="line.201"></a>
<span class="sourceLineNo">202</span> public static synchronized void clearStatistics() {<a name="line.202"></a>
<span class="sourceLineNo">203</span> for(Statistics stat: STATISTICS_TABLE.values()) {<a name="line.203"></a>
<span class="sourceLineNo">204</span> stat.reset();<a name="line.204"></a>
<span class="sourceLineNo">205</span> }<a name="line.205"></a>
<span class="sourceLineNo">206</span> }<a name="line.206"></a>
<span class="sourceLineNo">207</span><a name="line.207"></a>
<span class="sourceLineNo">208</span> /**<a name="line.208"></a>
<span class="sourceLineNo">209</span> * Prints statistics for all file systems.<a name="line.209"></a>
<span class="sourceLineNo">210</span> */<a name="line.210"></a>
<span class="sourceLineNo">211</span> public static synchronized void printStatistics() {<a name="line.211"></a>
<span class="sourceLineNo">212</span> for (Map.Entry<URI, Statistics> pair : STATISTICS_TABLE.entrySet()) {<a name="line.212"></a>
<span class="sourceLineNo">213</span> System.out.println(" FileSystem " + pair.getKey().getScheme() + "://"<a name="line.213"></a>
<span class="sourceLineNo">214</span> + pair.getKey().getAuthority() + ": " + pair.getValue());<a name="line.214"></a>
<span class="sourceLineNo">215</span> }<a name="line.215"></a>
<span class="sourceLineNo">216</span> }<a name="line.216"></a>
<span class="sourceLineNo">217</span> <a name="line.217"></a>
<span class="sourceLineNo">218</span> protected static synchronized Map<URI, Statistics> getAllStatistics() {<a name="line.218"></a>
<span class="sourceLineNo">219</span> Map<URI, Statistics> statsMap = new HashMap<URI, Statistics>(<a name="line.219"></a>
<span class="sourceLineNo">220</span> STATISTICS_TABLE.size());<a name="line.220"></a>
<span class="sourceLineNo">221</span> for (Map.Entry<URI, Statistics> pair : STATISTICS_TABLE.entrySet()) {<a name="line.221"></a>
<span class="sourceLineNo">222</span> URI key = pair.getKey();<a name="line.222"></a>
<span class="sourceLineNo">223</span> Statistics value = pair.getValue();<a name="line.223"></a>
<span class="sourceLineNo">224</span> Statistics newStatsObj = new Statistics(value);<a name="line.224"></a>
<span class="sourceLineNo">225</span> statsMap.put(URI.create(key.toString()), newStatsObj);<a name="line.225"></a>
<span class="sourceLineNo">226</span> }<a name="line.226"></a>
<span class="sourceLineNo">227</span> return statsMap;<a name="line.227"></a>
<span class="sourceLineNo">228</span> }<a name="line.228"></a>
<span class="sourceLineNo">229</span><a name="line.229"></a>
<span class="sourceLineNo">230</span> /**<a name="line.230"></a>
<span class="sourceLineNo">231</span> * The main factory method for creating a file system. Get a file system for<a name="line.231"></a>
<span class="sourceLineNo">232</span> * the URI's scheme and authority. The scheme of the <code>uri</code><a name="line.232"></a>
<span class="sourceLineNo">233</span> * determines a configuration property name,<a name="line.233"></a>
<span class="sourceLineNo">234</span> * <tt>fs.AbstractFileSystem.<i>scheme</i>.impl</tt> whose value names the<a name="line.234"></a>
<span class="sourceLineNo">235</span> * AbstractFileSystem class.<a name="line.235"></a>
<span class="sourceLineNo">236</span> * <a name="line.236"></a>
<span class="sourceLineNo">237</span> * The entire URI and conf is passed to the AbstractFileSystem factory method.<a name="line.237"></a>
<span class="sourceLineNo">238</span> * <a name="line.238"></a>
<span class="sourceLineNo">239</span> * @param uri for the file system to be created.<a name="line.239"></a>
<span class="sourceLineNo">240</span> * @param conf which is passed to the file system impl.<a name="line.240"></a>
<span class="sourceLineNo">241</span> * <a name="line.241"></a>
<span class="sourceLineNo">242</span> * @return file system for the given URI.<a name="line.242"></a>
<span class="sourceLineNo">243</span> * <a name="line.243"></a>
<span class="sourceLineNo">244</span> * @throws UnsupportedFileSystemException if the file system for<a name="line.244"></a>
<span class="sourceLineNo">245</span> * <code>uri</code> is not supported.<a name="line.245"></a>
<span class="sourceLineNo">246</span> */<a name="line.246"></a>
<span class="sourceLineNo">247</span> public static AbstractFileSystem get(final URI uri, final Configuration conf)<a name="line.247"></a>
<span class="sourceLineNo">248</span> throws UnsupportedFileSystemException {<a name="line.248"></a>
<span class="sourceLineNo">249</span> return createFileSystem(uri, conf);<a name="line.249"></a>
<span class="sourceLineNo">250</span> }<a name="line.250"></a>
<span class="sourceLineNo">251</span><a name="line.251"></a>
<span class="sourceLineNo">252</span> /**<a name="line.252"></a>
<span class="sourceLineNo">253</span> * Constructor to be called by subclasses.<a name="line.253"></a>
<span class="sourceLineNo">254</span> * <a name="line.254"></a>
<span class="sourceLineNo">255</span> * @param uri for this file system.<a name="line.255"></a>
<span class="sourceLineNo">256</span> * @param supportedScheme the scheme supported by the implementor<a name="line.256"></a>
<span class="sourceLineNo">257</span> * @param authorityNeeded if true then theURI must have authority, if false<a name="line.257"></a>
<span class="sourceLineNo">258</span> * then the URI must have null authority.<a name="line.258"></a>
<span class="sourceLineNo">259</span> *<a name="line.259"></a>
<span class="sourceLineNo">260</span> * @throws URISyntaxException <code>uri</code> has syntax error<a name="line.260"></a>
<span class="sourceLineNo">261</span> */<a name="line.261"></a>
<span class="sourceLineNo">262</span> public AbstractFileSystem(final URI uri, final String supportedScheme,<a name="line.262"></a>
<span class="sourceLineNo">263</span> final boolean authorityNeeded, final int defaultPort)<a name="line.263"></a>
<span class="sourceLineNo">264</span> throws URISyntaxException {<a name="line.264"></a>
<span class="sourceLineNo">265</span> myUri = getUri(uri, supportedScheme, authorityNeeded, defaultPort);<a name="line.265"></a>
<span class="sourceLineNo">266</span> statistics = getStatistics(uri); <a name="line.266"></a>
<span class="sourceLineNo">267</span> }<a name="line.267"></a>
<span class="sourceLineNo">268</span> <a name="line.268"></a>
<span class="sourceLineNo">269</span> /**<a name="line.269"></a>
<span class="sourceLineNo">270</span> * Check that the Uri's scheme matches<a name="line.270"></a>
<span class="sourceLineNo">271</span> * @param uri<a name="line.271"></a>
<span class="sourceLineNo">272</span> * @param supportedScheme<a name="line.272"></a>
<span class="sourceLineNo">273</span> */<a name="line.273"></a>
<span class="sourceLineNo">274</span> public void checkScheme(URI uri, String supportedScheme) {<a name="line.274"></a>
<span class="sourceLineNo">275</span> String scheme = uri.getScheme();<a name="line.275"></a>
<span class="sourceLineNo">276</span> if (scheme == null) {<a name="line.276"></a>
<span class="sourceLineNo">277</span> throw new HadoopIllegalArgumentException("Uri without scheme: " + uri);<a name="line.277"></a>
<span class="sourceLineNo">278</span> }<a name="line.278"></a>
<span class="sourceLineNo">279</span> if (!scheme.equals(supportedScheme)) {<a name="line.279"></a>
<span class="sourceLineNo">280</span> throw new HadoopIllegalArgumentException("Uri scheme " + uri<a name="line.280"></a>
<span class="sourceLineNo">281</span> + " does not match the scheme " + supportedScheme);<a name="line.281"></a>
<span class="sourceLineNo">282</span> }<a name="line.282"></a>
<span class="sourceLineNo">283</span> }<a name="line.283"></a>
<span class="sourceLineNo">284</span><a name="line.284"></a>
<span class="sourceLineNo">285</span> /**<a name="line.285"></a>
<span class="sourceLineNo">286</span> * Get the URI for the file system based on the given URI. The path, query<a name="line.286"></a>
<span class="sourceLineNo">287</span> * part of the given URI is stripped out and default file system port is used<a name="line.287"></a>
<span class="sourceLineNo">288</span> * to form the URI.<a name="line.288"></a>
<span class="sourceLineNo">289</span> * <a name="line.289"></a>
<span class="sourceLineNo">290</span> * @param uri FileSystem URI.<a name="line.290"></a>
<span class="sourceLineNo">291</span> * @param authorityNeeded if true authority cannot be null in the URI. If<a name="line.291"></a>
<span class="sourceLineNo">292</span> * false authority must be null.<a name="line.292"></a>
<span class="sourceLineNo">293</span> * @param defaultPort default port to use if port is not specified in the URI.<a name="line.293"></a>
<span class="sourceLineNo">294</span> * <a name="line.294"></a>
<span class="sourceLineNo">295</span> * @return URI of the file system<a name="line.295"></a>
<span class="sourceLineNo">296</span> * <a name="line.296"></a>
<span class="sourceLineNo">297</span> * @throws URISyntaxException <code>uri</code> has syntax error<a name="line.297"></a>
<span class="sourceLineNo">298</span> */<a name="line.298"></a>
<span class="sourceLineNo">299</span> private URI getUri(URI uri, String supportedScheme,<a name="line.299"></a>
<span class="sourceLineNo">300</span> boolean authorityNeeded, int defaultPort) throws URISyntaxException {<a name="line.300"></a>
<span class="sourceLineNo">301</span> checkScheme(uri, supportedScheme);<a name="line.301"></a>
<span class="sourceLineNo">302</span> // A file system implementation that requires authority must always<a name="line.302"></a>
<span class="sourceLineNo">303</span> // specify default port<a name="line.303"></a>
<span class="sourceLineNo">304</span> if (defaultPort < 0 && authorityNeeded) {<a name="line.304"></a>
<span class="sourceLineNo">305</span> throw new HadoopIllegalArgumentException(<a name="line.305"></a>
<span class="sourceLineNo">306</span> "FileSystem implementation error - default port " + defaultPort<a name="line.306"></a>
<span class="sourceLineNo">307</span> + " is not valid");<a name="line.307"></a>
<span class="sourceLineNo">308</span> }<a name="line.308"></a>
<span class="sourceLineNo">309</span> String authority = uri.getAuthority();<a name="line.309"></a>
<span class="sourceLineNo">310</span> if (authority == null) {<a name="line.310"></a>
<span class="sourceLineNo">311</span> if (authorityNeeded) {<a name="line.311"></a>
<span class="sourceLineNo">312</span> throw new HadoopIllegalArgumentException("Uri without authority: " + uri);<a name="line.312"></a>
<span class="sourceLineNo">313</span> } else {<a name="line.313"></a>
<span class="sourceLineNo">314</span> return new URI(supportedScheme + ":///");<a name="line.314"></a>
<span class="sourceLineNo">315</span> } <a name="line.315"></a>
<span class="sourceLineNo">316</span> }<a name="line.316"></a>
<span class="sourceLineNo">317</span> // authority is non null - AuthorityNeeded may be true or false.<a name="line.317"></a>
<span class="sourceLineNo">318</span> int port = uri.getPort();<a name="line.318"></a>
<span class="sourceLineNo">319</span> port = (port == -1 ? defaultPort : port);<a name="line.319"></a>
<span class="sourceLineNo">320</span> if (port == -1) { // no port supplied and default port is not specified<a name="line.320"></a>
<span class="sourceLineNo">321</span> return new URI(supportedScheme, authority, "/", null);<a name="line.321"></a>
<span class="sourceLineNo">322</span> }<a name="line.322"></a>
<span class="sourceLineNo">323</span> return new URI(supportedScheme + "://" + uri.getHost() + ":" + port);<a name="line.323"></a>
<span class="sourceLineNo">324</span> }<a name="line.324"></a>
<span class="sourceLineNo">325</span> <a name="line.325"></a>
<span class="sourceLineNo">326</span> /**<a name="line.326"></a>
<span class="sourceLineNo">327</span> * The default port of this file system.<a name="line.327"></a>
<span class="sourceLineNo">328</span> * <a name="line.328"></a>
<span class="sourceLineNo">329</span> * @return default port of this file system's Uri scheme<a name="line.329"></a>
<span class="sourceLineNo">330</span> * A uri with a port of -1 => default port;<a name="line.330"></a>
<span class="sourceLineNo">331</span> */<a name="line.331"></a>
<span class="sourceLineNo">332</span> public abstract int getUriDefaultPort();<a name="line.332"></a>
<span class="sourceLineNo">333</span><a name="line.333"></a>
<span class="sourceLineNo">334</span> /**<a name="line.334"></a>
<span class="sourceLineNo">335</span> * Returns a URI whose scheme and authority identify this FileSystem.<a name="line.335"></a>
<span class="sourceLineNo">336</span> * <a name="line.336"></a>
<span class="sourceLineNo">337</span> * @return the uri of this file system.<a name="line.337"></a>
<span class="sourceLineNo">338</span> */<a name="line.338"></a>
<span class="sourceLineNo">339</span> public URI getUri() {<a name="line.339"></a>
<span class="sourceLineNo">340</span> return myUri;<a name="line.340"></a>
<span class="sourceLineNo">341</span> }<a name="line.341"></a>
<span class="sourceLineNo">342</span> <a name="line.342"></a>
<span class="sourceLineNo">343</span> /**<a name="line.343"></a>
<span class="sourceLineNo">344</span> * Check that a Path belongs to this FileSystem.<a name="line.344"></a>
<span class="sourceLineNo">345</span> * <a name="line.345"></a>
<span class="sourceLineNo">346</span> * If the path is fully qualified URI, then its scheme and authority<a name="line.346"></a>
<span class="sourceLineNo">347</span> * matches that of this file system. Otherwise the path must be <a name="line.347"></a>
<span class="sourceLineNo">348</span> * slash-relative name.<a name="line.348"></a>
<span class="sourceLineNo">349</span> * <a name="line.349"></a>
<span class="sourceLineNo">350</span> * @throws InvalidPathException if the path is invalid<a name="line.350"></a>
<span class="sourceLineNo">351</span> */<a name="line.351"></a>
<span class="sourceLineNo">352</span> public void checkPath(Path path) {<a name="line.352"></a>
<span class="sourceLineNo">353</span> URI uri = path.toUri();<a name="line.353"></a>
<span class="sourceLineNo">354</span> String thatScheme = uri.getScheme();<a name="line.354"></a>
<span class="sourceLineNo">355</span> String thatAuthority = uri.getAuthority();<a name="line.355"></a>
<span class="sourceLineNo">356</span> if (thatScheme == null) {<a name="line.356"></a>
<span class="sourceLineNo">357</span> if (thatAuthority == null) {<a name="line.357"></a>
<span class="sourceLineNo">358</span> if (path.isUriPathAbsolute()) {<a name="line.358"></a>
<span class="sourceLineNo">359</span> return;<a name="line.359"></a>
<span class="sourceLineNo">360</span> }<a name="line.360"></a>
<span class="sourceLineNo">361</span> throw new InvalidPathException("relative paths not allowed:" + <a name="line.361"></a>
<span class="sourceLineNo">362</span> path);<a name="line.362"></a>
<span class="sourceLineNo">363</span> } else {<a name="line.363"></a>
<span class="sourceLineNo">364</span> throw new InvalidPathException(<a name="line.364"></a>
<span class="sourceLineNo">365</span> "Path without scheme with non-null authority:" + path);<a name="line.365"></a>
<span class="sourceLineNo">366</span> }<a name="line.366"></a>
<span class="sourceLineNo">367</span> }<a name="line.367"></a>
<span class="sourceLineNo">368</span> String thisScheme = this.getUri().getScheme();<a name="line.368"></a>
<span class="sourceLineNo">369</span> String thisHost = this.getUri().getHost();<a name="line.369"></a>
<span class="sourceLineNo">370</span> String thatHost = uri.getHost();<a name="line.370"></a>
<span class="sourceLineNo">371</span> <a name="line.371"></a>
<span class="sourceLineNo">372</span> // Schemes and hosts must match.<a name="line.372"></a>
<span class="sourceLineNo">373</span> // Allow for null Authority for file:///<a name="line.373"></a>
<span class="sourceLineNo">374</span> if (!thisScheme.equalsIgnoreCase(thatScheme) ||<a name="line.374"></a>
<span class="sourceLineNo">375</span> (thisHost != null && <a name="line.375"></a>
<span class="sourceLineNo">376</span> !thisHost.equalsIgnoreCase(thatHost)) ||<a name="line.376"></a>
<span class="sourceLineNo">377</span> (thisHost == null && thatHost != null)) {<a name="line.377"></a>
<span class="sourceLineNo">378</span> throw new InvalidPathException("Wrong FS: " + path + ", expected: "<a name="line.378"></a>
<span class="sourceLineNo">379</span> + this.getUri());<a name="line.379"></a>
<span class="sourceLineNo">380</span> }<a name="line.380"></a>
<span class="sourceLineNo">381</span> <a name="line.381"></a>
<span class="sourceLineNo">382</span> // Ports must match, unless this FS instance is using the default port, in<a name="line.382"></a>
<span class="sourceLineNo">383</span> // which case the port may be omitted from the given URI<a name="line.383"></a>
<span class="sourceLineNo">384</span> int thisPort = this.getUri().getPort();<a name="line.384"></a>
<span class="sourceLineNo">385</span> int thatPort = uri.getPort();<a name="line.385"></a>
<span class="sourceLineNo">386</span> if (thatPort == -1) { // -1 => defaultPort of Uri scheme<a name="line.386"></a>
<span class="sourceLineNo">387</span> thatPort = this.getUriDefaultPort();<a name="line.387"></a>
<span class="sourceLineNo">388</span> }<a name="line.388"></a>
<span class="sourceLineNo">389</span> if (thisPort != thatPort) {<a name="line.389"></a>
<span class="sourceLineNo">390</span> throw new InvalidPathException("Wrong FS: " + path + ", expected: "<a name="line.390"></a>
<span class="sourceLineNo">391</span> + this.getUri());<a name="line.391"></a>
<span class="sourceLineNo">392</span> }<a name="line.392"></a>
<span class="sourceLineNo">393</span> }<a name="line.393"></a>
<span class="sourceLineNo">394</span> <a name="line.394"></a>
<span class="sourceLineNo">395</span> /**<a name="line.395"></a>
<span class="sourceLineNo">396</span> * Get the path-part of a pathname. Checks that URI matches this file system<a name="line.396"></a>
<span class="sourceLineNo">397</span> * and that the path-part is a valid name.<a name="line.397"></a>
<span class="sourceLineNo">398</span> * <a name="line.398"></a>
<span class="sourceLineNo">399</span> * @param p path<a name="line.399"></a>
<span class="sourceLineNo">400</span> * <a name="line.400"></a>
<span class="sourceLineNo">401</span> * @return path-part of the Path p<a name="line.401"></a>
<span class="sourceLineNo">402</span> */<a name="line.402"></a>
<span class="sourceLineNo">403</span> public String getUriPath(final Path p) {<a name="line.403"></a>
<span class="sourceLineNo">404</span> checkPath(p);<a name="line.404"></a>
<span class="sourceLineNo">405</span> String s = p.toUri().getPath();<a name="line.405"></a>
<span class="sourceLineNo">406</span> if (!isValidName(s)) {<a name="line.406"></a>
<span class="sourceLineNo">407</span> throw new InvalidPathException("Path part " + s + " from URI " + p<a name="line.407"></a>
<span class="sourceLineNo">408</span> + " is not a valid filename.");<a name="line.408"></a>
<span class="sourceLineNo">409</span> }<a name="line.409"></a>
<span class="sourceLineNo">410</span> return s;<a name="line.410"></a>
<span class="sourceLineNo">411</span> }<a name="line.411"></a>
<span class="sourceLineNo">412</span> <a name="line.412"></a>
<span class="sourceLineNo">413</span> /**<a name="line.413"></a>
<span class="sourceLineNo">414</span> * Make the path fully qualified to this file system<a name="line.414"></a>
<span class="sourceLineNo">415</span> * @param path<a name="line.415"></a>
<span class="sourceLineNo">416</span> * @return the qualified path<a name="line.416"></a>
<span class="sourceLineNo">417</span> */<a name="line.417"></a>
<span class="sourceLineNo">418</span> public Path makeQualified(Path path) {<a name="line.418"></a>
<span class="sourceLineNo">419</span> checkPath(path);<a name="line.419"></a>
<span class="sourceLineNo">420</span> return path.makeQualified(this.getUri(), null);<a name="line.420"></a>
<span class="sourceLineNo">421</span> }<a name="line.421"></a>
<span class="sourceLineNo">422</span> <a name="line.422"></a>
<span class="sourceLineNo">423</span> /**<a name="line.423"></a>
<span class="sourceLineNo">424</span> * Some file systems like LocalFileSystem have an initial workingDir<a name="line.424"></a>
<span class="sourceLineNo">425</span> * that is used as the starting workingDir. For other file systems<a name="line.425"></a>
<span class="sourceLineNo">426</span> * like HDFS there is no built in notion of an initial workingDir.<a name="line.426"></a>
<span class="sourceLineNo">427</span> * <a name="line.427"></a>
<span class="sourceLineNo">428</span> * @return the initial workingDir if the file system has such a notion<a name="line.428"></a>
<span class="sourceLineNo">429</span> * otherwise return a null.<a name="line.429"></a>
<span class="sourceLineNo">430</span> */<a name="line.430"></a>
<span class="sourceLineNo">431</span> public Path getInitialWorkingDirectory() {<a name="line.431"></a>
<span class="sourceLineNo">432</span> return null;<a name="line.432"></a>
<span class="sourceLineNo">433</span> }<a name="line.433"></a>
<span class="sourceLineNo">434</span> <a name="line.434"></a>
<span class="sourceLineNo">435</span> /** <a name="line.435"></a>
<span class="sourceLineNo">436</span> * Return the current user's home directory in this file system.<a name="line.436"></a>
<span class="sourceLineNo">437</span> * The default implementation returns "/user/$USER/".<a name="line.437"></a>
<span class="sourceLineNo">438</span> * <a name="line.438"></a>
<span class="sourceLineNo">439</span> * @return current user's home directory.<a name="line.439"></a>
<span class="sourceLineNo">440</span> */<a name="line.440"></a>
<span class="sourceLineNo">441</span> public Path getHomeDirectory() {<a name="line.441"></a>
<span class="sourceLineNo">442</span> return new Path("/user/"+System.getProperty("user.name")).makeQualified(<a name="line.442"></a>
<span class="sourceLineNo">443</span> getUri(), null);<a name="line.443"></a>
<span class="sourceLineNo">444</span> }<a name="line.444"></a>
<span class="sourceLineNo">445</span> <a name="line.445"></a>
<span class="sourceLineNo">446</span> /**<a name="line.446"></a>
<span class="sourceLineNo">447</span> * Return a set of server default configuration values.<a name="line.447"></a>
<span class="sourceLineNo">448</span> * <a name="line.448"></a>
<span class="sourceLineNo">449</span> * @return server default configuration values<a name="line.449"></a>
<span class="sourceLineNo">450</span> * <a name="line.450"></a>
<span class="sourceLineNo">451</span> * @throws IOException an I/O error occurred<a name="line.451"></a>
<span class="sourceLineNo">452</span> */<a name="line.452"></a>
<span class="sourceLineNo">453</span> public abstract FsServerDefaults getServerDefaults() throws IOException; <a name="line.453"></a>
<span class="sourceLineNo">454</span><a name="line.454"></a>
<span class="sourceLineNo">455</span> /**<a name="line.455"></a>
<span class="sourceLineNo">456</span> * Return the fully-qualified path of path f resolving the path<a name="line.456"></a>
<span class="sourceLineNo">457</span> * through any internal symlinks or mount point<a name="line.457"></a>
<span class="sourceLineNo">458</span> * @param p path to be resolved<a name="line.458"></a>
<span class="sourceLineNo">459</span> * @return fully qualified path <a name="line.459"></a>
<span class="sourceLineNo">460</span> * @throws FileNotFoundException, AccessControlException, IOException<a name="line.460"></a>
<span class="sourceLineNo">461</span> * UnresolvedLinkException if symbolic link on path cannot be resolved<a name="line.461"></a>
<span class="sourceLineNo">462</span> * internally<a name="line.462"></a>
<span class="sourceLineNo">463</span> */<a name="line.463"></a>
<span class="sourceLineNo">464</span> public Path resolvePath(final Path p) throws FileNotFoundException,<a name="line.464"></a>
<span class="sourceLineNo">465</span> UnresolvedLinkException, AccessControlException, IOException {<a name="line.465"></a>
<span class="sourceLineNo">466</span> checkPath(p);<a name="line.466"></a>
<span class="sourceLineNo">467</span> return getFileStatus(p).getPath(); // default impl is to return the path<a name="line.467"></a>
<span class="sourceLineNo">468</span> }<a name="line.468"></a>
<span class="sourceLineNo">469</span> <a name="line.469"></a>
<span class="sourceLineNo">470</span> /**<a name="line.470"></a>
<span class="sourceLineNo">471</span> * The specification of this method matches that of<a name="line.471"></a>
<span class="sourceLineNo">472</span> * {@link FileContext#create(Path, EnumSet, Options.CreateOpts...)} except<a name="line.472"></a>
<span class="sourceLineNo">473</span> * that the Path f must be fully qualified and the permission is absolute<a name="line.473"></a>
<span class="sourceLineNo">474</span> * (i.e. umask has been applied).<a name="line.474"></a>
<span class="sourceLineNo">475</span> */<a name="line.475"></a>
<span class="sourceLineNo">476</span> public final FSDataOutputStream create(final Path f,<a name="line.476"></a>
<span class="sourceLineNo">477</span> final EnumSet<CreateFlag> createFlag, Options.CreateOpts... opts)<a name="line.477"></a>
<span class="sourceLineNo">478</span> throws AccessControlException, FileAlreadyExistsException,<a name="line.478"></a>
<span class="sourceLineNo">479</span> FileNotFoundException, ParentNotDirectoryException,<a name="line.479"></a>
<span class="sourceLineNo">480</span> UnsupportedFileSystemException, UnresolvedLinkException, IOException {<a name="line.480"></a>
<span class="sourceLineNo">481</span> checkPath(f);<a name="line.481"></a>
<span class="sourceLineNo">482</span> int bufferSize = -1;<a name="line.482"></a>
<span class="sourceLineNo">483</span> short replication = -1;<a name="line.483"></a>
<span class="sourceLineNo">484</span> long blockSize = -1;<a name="line.484"></a>
<span class="sourceLineNo">485</span> int bytesPerChecksum = -1;<a name="line.485"></a>
<span class="sourceLineNo">486</span> ChecksumOpt checksumOpt = null;<a name="line.486"></a>
<span class="sourceLineNo">487</span> FsPermission permission = null;<a name="line.487"></a>
<span class="sourceLineNo">488</span> Progressable progress = null;<a name="line.488"></a>
<span class="sourceLineNo">489</span> Boolean createParent = null;<a name="line.489"></a>
<span class="sourceLineNo">490</span> <a name="line.490"></a>
<span class="sourceLineNo">491</span> for (CreateOpts iOpt : opts) {<a name="line.491"></a>
<span class="sourceLineNo">492</span> if (CreateOpts.BlockSize.class.isInstance(iOpt)) {<a name="line.492"></a>
<span class="sourceLineNo">493</span> if (blockSize != -1) {<a name="line.493"></a>
<span class="sourceLineNo">494</span> throw new HadoopIllegalArgumentException(<a name="line.494"></a>
<span class="sourceLineNo">495</span> "BlockSize option is set multiple times");<a name="line.495"></a>
<span class="sourceLineNo">496</span> }<a name="line.496"></a>
<span class="sourceLineNo">497</span> blockSize = ((CreateOpts.BlockSize) iOpt).getValue();<a name="line.497"></a>
<span class="sourceLineNo">498</span> } else if (CreateOpts.BufferSize.class.isInstance(iOpt)) {<a name="line.498"></a>
<span class="sourceLineNo">499</span> if (bufferSize != -1) {<a name="line.499"></a>
<span class="sourceLineNo">500</span> throw new HadoopIllegalArgumentException(<a name="line.500"></a>
<span class="sourceLineNo">501</span> "BufferSize option is set multiple times");<a name="line.501"></a>
<span class="sourceLineNo">502</span> }<a name="line.502"></a>
<span class="sourceLineNo">503</span> bufferSize = ((CreateOpts.BufferSize) iOpt).getValue();<a name="line.503"></a>
<span class="sourceLineNo">504</span> } else if (CreateOpts.ReplicationFactor.class.isInstance(iOpt)) {<a name="line.504"></a>
<span class="sourceLineNo">505</span> if (replication != -1) {<a name="line.505"></a>
<span class="sourceLineNo">506</span> throw new HadoopIllegalArgumentException(<a name="line.506"></a>
<span class="sourceLineNo">507</span> "ReplicationFactor option is set multiple times");<a name="line.507"></a>
<span class="sourceLineNo">508</span> }<a name="line.508"></a>
<span class="sourceLineNo">509</span> replication = ((CreateOpts.ReplicationFactor) iOpt).getValue();<a name="line.509"></a>
<span class="sourceLineNo">510</span> } else if (CreateOpts.BytesPerChecksum.class.isInstance(iOpt)) {<a name="line.510"></a>
<span class="sourceLineNo">511</span> if (bytesPerChecksum != -1) {<a name="line.511"></a>
<span class="sourceLineNo">512</span> throw new HadoopIllegalArgumentException(<a name="line.512"></a>
<span class="sourceLineNo">513</span> "BytesPerChecksum option is set multiple times");<a name="line.513"></a>
<span class="sourceLineNo">514</span> }<a name="line.514"></a>
<span class="sourceLineNo">515</span> bytesPerChecksum = ((CreateOpts.BytesPerChecksum) iOpt).getValue();<a name="line.515"></a>
<span class="sourceLineNo">516</span> } else if (CreateOpts.ChecksumParam.class.isInstance(iOpt)) {<a name="line.516"></a>
<span class="sourceLineNo">517</span> if (checksumOpt != null) {<a name="line.517"></a>
<span class="sourceLineNo">518</span> throw new HadoopIllegalArgumentException(<a name="line.518"></a>
<span class="sourceLineNo">519</span> "CreateChecksumType option is set multiple times");<a name="line.519"></a>
<span class="sourceLineNo">520</span> }<a name="line.520"></a>
<span class="sourceLineNo">521</span> checksumOpt = ((CreateOpts.ChecksumParam) iOpt).getValue();<a name="line.521"></a>
<span class="sourceLineNo">522</span> } else if (CreateOpts.Perms.class.isInstance(iOpt)) {<a name="line.522"></a>
<span class="sourceLineNo">523</span> if (permission != null) {<a name="line.523"></a>
<span class="sourceLineNo">524</span> throw new HadoopIllegalArgumentException(<a name="line.524"></a>
<span class="sourceLineNo">525</span> "Perms option is set multiple times");<a name="line.525"></a>
<span class="sourceLineNo">526</span> }<a name="line.526"></a>
<span class="sourceLineNo">527</span> permission = ((CreateOpts.Perms) iOpt).getValue();<a name="line.527"></a>
<span class="sourceLineNo">528</span> } else if (CreateOpts.Progress.class.isInstance(iOpt)) {<a name="line.528"></a>
<span class="sourceLineNo">529</span> if (progress != null) {<a name="line.529"></a>
<span class="sourceLineNo">530</span> throw new HadoopIllegalArgumentException(<a name="line.530"></a>
<span class="sourceLineNo">531</span> "Progress option is set multiple times");<a name="line.531"></a>
<span class="sourceLineNo">532</span> }<a name="line.532"></a>
<span class="sourceLineNo">533</span> progress = ((CreateOpts.Progress) iOpt).getValue();<a name="line.533"></a>
<span class="sourceLineNo">534</span> } else if (CreateOpts.CreateParent.class.isInstance(iOpt)) {<a name="line.534"></a>
<span class="sourceLineNo">535</span> if (createParent != null) {<a name="line.535"></a>
<span class="sourceLineNo">536</span> throw new HadoopIllegalArgumentException(<a name="line.536"></a>
<span class="sourceLineNo">537</span> "CreateParent option is set multiple times");<a name="line.537"></a>
<span class="sourceLineNo">538</span> }<a name="line.538"></a>
<span class="sourceLineNo">539</span> createParent = ((CreateOpts.CreateParent) iOpt).getValue();<a name="line.539"></a>
<span class="sourceLineNo">540</span> } else {<a name="line.540"></a>
<span class="sourceLineNo">541</span> throw new HadoopIllegalArgumentException("Unkown CreateOpts of type " +<a name="line.541"></a>
<span class="sourceLineNo">542</span> iOpt.getClass().getName());<a name="line.542"></a>
<span class="sourceLineNo">543</span> }<a name="line.543"></a>
<span class="sourceLineNo">544</span> }<a name="line.544"></a>
<span class="sourceLineNo">545</span> if (permission == null) {<a name="line.545"></a>
<span class="sourceLineNo">546</span> throw new HadoopIllegalArgumentException("no permission supplied");<a name="line.546"></a>
<span class="sourceLineNo">547</span> }<a name="line.547"></a>
<span class="sourceLineNo">548</span><a name="line.548"></a>
<span class="sourceLineNo">549</span><a name="line.549"></a>
<span class="sourceLineNo">550</span> FsServerDefaults ssDef = getServerDefaults();<a name="line.550"></a>
<span class="sourceLineNo">551</span> if (ssDef.getBlockSize() % ssDef.getBytesPerChecksum() != 0) {<a name="line.551"></a>
<span class="sourceLineNo">552</span> throw new IOException("Internal error: default blockSize is" + <a name="line.552"></a>
<span class="sourceLineNo">553</span> " not a multiple of default bytesPerChecksum ");<a name="line.553"></a>
<span class="sourceLineNo">554</span> }<a name="line.554"></a>
<span class="sourceLineNo">555</span> <a name="line.555"></a>
<span class="sourceLineNo">556</span> if (blockSize == -1) {<a name="line.556"></a>
<span class="sourceLineNo">557</span> blockSize = ssDef.getBlockSize();<a name="line.557"></a>
<span class="sourceLineNo">558</span> }<a name="line.558"></a>
<span class="sourceLineNo">559</span><a name="line.559"></a>
<span class="sourceLineNo">560</span> // Create a checksum option honoring user input as much as possible.<a name="line.560"></a>
<span class="sourceLineNo">561</span> // If bytesPerChecksum is specified, it will override the one set in<a name="line.561"></a>
<span class="sourceLineNo">562</span> // checksumOpt. Any missing value will be filled in using the default.<a name="line.562"></a>
<span class="sourceLineNo">563</span> ChecksumOpt defaultOpt = new ChecksumOpt(<a name="line.563"></a>
<span class="sourceLineNo">564</span> ssDef.getChecksumType(),<a name="line.564"></a>
<span class="sourceLineNo">565</span> ssDef.getBytesPerChecksum());<a name="line.565"></a>
<span class="sourceLineNo">566</span> checksumOpt = ChecksumOpt.processChecksumOpt(defaultOpt,<a name="line.566"></a>
<span class="sourceLineNo">567</span> checksumOpt, bytesPerChecksum);<a name="line.567"></a>
<span class="sourceLineNo">568</span><a name="line.568"></a>
<span class="sourceLineNo">569</span> if (bufferSize == -1) {<a name="line.569"></a>
<span class="sourceLineNo">570</span> bufferSize = ssDef.getFileBufferSize();<a name="line.570"></a>
<span class="sourceLineNo">571</span> }<a name="line.571"></a>
<span class="sourceLineNo">572</span> if (replication == -1) {<a name="line.572"></a>
<span class="sourceLineNo">573</span> replication = ssDef.getReplication();<a name="line.573"></a>
<span class="sourceLineNo">574</span> }<a name="line.574"></a>
<span class="sourceLineNo">575</span> if (createParent == null) {<a name="line.575"></a>
<span class="sourceLineNo">576</span> createParent = false;<a name="line.576"></a>
<span class="sourceLineNo">577</span> }<a name="line.577"></a>
<span class="sourceLineNo">578</span><a name="line.578"></a>
<span class="sourceLineNo">579</span> if (blockSize % bytesPerChecksum != 0) {<a name="line.579"></a>
<span class="sourceLineNo">580</span> throw new HadoopIllegalArgumentException(<a name="line.580"></a>
<span class="sourceLineNo">581</span> "blockSize should be a multiple of checksumsize");<a name="line.581"></a>
<span class="sourceLineNo">582</span> }<a name="line.582"></a>
<span class="sourceLineNo">583</span><a name="line.583"></a>
<span class="sourceLineNo">584</span> return this.createInternal(f, createFlag, permission, bufferSize,<a name="line.584"></a>
<span class="sourceLineNo">585</span> replication, blockSize, progress, checksumOpt, createParent);<a name="line.585"></a>
<span class="sourceLineNo">586</span> }<a name="line.586"></a>
<span class="sourceLineNo">587</span><a name="line.587"></a>
<span class="sourceLineNo">588</span> /**<a name="line.588"></a>
<span class="sourceLineNo">589</span> * The specification of this method matches that of<a name="line.589"></a>
<span class="sourceLineNo">590</span> * {@link #create(Path, EnumSet, Options.CreateOpts...)} except that the opts<a name="line.590"></a>
<span class="sourceLineNo">591</span> * have been declared explicitly.<a name="line.591"></a>
<span class="sourceLineNo">592</span> */<a name="line.592"></a>
<span class="sourceLineNo">593</span> public abstract FSDataOutputStream createInternal(Path f,<a name="line.593"></a>
<span class="sourceLineNo">594</span> EnumSet<CreateFlag> flag, FsPermission absolutePermission,<a name="line.594"></a>
<span class="sourceLineNo">595</span> int bufferSize, short replication, long blockSize, Progressable progress,<a name="line.595"></a>
<span class="sourceLineNo">596</span> ChecksumOpt checksumOpt, boolean createParent)<a name="line.596"></a>
<span class="sourceLineNo">597</span> throws AccessControlException, FileAlreadyExistsException,<a name="line.597"></a>
<span class="sourceLineNo">598</span> FileNotFoundException, ParentNotDirectoryException,<a name="line.598"></a>
<span class="sourceLineNo">599</span> UnsupportedFileSystemException, UnresolvedLinkException, IOException;<a name="line.599"></a>
<span class="sourceLineNo">600</span><a name="line.600"></a>
<span class="sourceLineNo">601</span> /**<a name="line.601"></a>
<span class="sourceLineNo">602</span> * The specification of this method matches that of<a name="line.602"></a>
<span class="sourceLineNo">603</span> * {@link FileContext#mkdir(Path, FsPermission, boolean)} except that the Path<a name="line.603"></a>
<span class="sourceLineNo">604</span> * f must be fully qualified and the permission is absolute (i.e. <a name="line.604"></a>
<span class="sourceLineNo">605</span> * umask has been applied).<a name="line.605"></a>
<span class="sourceLineNo">606</span> */<a name="line.606"></a>
<span class="sourceLineNo">607</span> public abstract void mkdir(final Path dir, final FsPermission permission,<a name="line.607"></a>
<span class="sourceLineNo">608</span> final boolean createParent) throws AccessControlException,<a name="line.608"></a>
<span class="sourceLineNo">609</span> FileAlreadyExistsException, FileNotFoundException,<a name="line.609"></a>
<span class="sourceLineNo">610</span> UnresolvedLinkException, IOException;<a name="line.610"></a>
<span class="sourceLineNo">611</span><a name="line.611"></a>
<span class="sourceLineNo">612</span> /**<a name="line.612"></a>
<span class="sourceLineNo">613</span> * The specification of this method matches that of<a name="line.613"></a>
<span class="sourceLineNo">614</span> * {@link FileContext#delete(Path, boolean)} except that Path f must be for<a name="line.614"></a>
<span class="sourceLineNo">615</span> * this file system.<a name="line.615"></a>
<span class="sourceLineNo">616</span> */<a name="line.616"></a>
<span class="sourceLineNo">617</span> public abstract boolean delete(final Path f, final boolean recursive)<a name="line.617"></a>
<span class="sourceLineNo">618</span> throws AccessControlException, FileNotFoundException,<a name="line.618"></a>
<span class="sourceLineNo">619</span> UnresolvedLinkException, IOException;<a name="line.619"></a>
<span class="sourceLineNo">620</span><a name="line.620"></a>
<span class="sourceLineNo">621</span> /**<a name="line.621"></a>
<span class="sourceLineNo">622</span> * The specification of this method matches that of<a name="line.622"></a>
<span class="sourceLineNo">623</span> * {@link FileContext#open(Path)} except that Path f must be for this<a name="line.623"></a>
<span class="sourceLineNo">624</span> * file system.<a name="line.624"></a>
<span class="sourceLineNo">625</span> */<a name="line.625"></a>
<span class="sourceLineNo">626</span> public FSDataInputStream open(final Path f) throws AccessControlException,<a name="line.626"></a>
<span class="sourceLineNo">627</span> FileNotFoundException, UnresolvedLinkException, IOException {<a name="line.627"></a>
<span class="sourceLineNo">628</span> return open(f, getServerDefaults().getFileBufferSize());<a name="line.628"></a>
<span class="sourceLineNo">629</span> }<a name="line.629"></a>
<span class="sourceLineNo">630</span><a name="line.630"></a>
<span class="sourceLineNo">631</span> /**<a name="line.631"></a>
<span class="sourceLineNo">632</span> * The specification of this method matches that of<a name="line.632"></a>
<span class="sourceLineNo">633</span> * {@link FileContext#open(Path, int)} except that Path f must be for this<a name="line.633"></a>
<span class="sourceLineNo">634</span> * file system.<a name="line.634"></a>
<span class="sourceLineNo">635</span> */<a name="line.635"></a>
<span class="sourceLineNo">636</span> public abstract FSDataInputStream open(final Path f, int bufferSize)<a name="line.636"></a>
<span class="sourceLineNo">637</span> throws AccessControlException, FileNotFoundException,<a name="line.637"></a>
<span class="sourceLineNo">638</span> UnresolvedLinkException, IOException;<a name="line.638"></a>
<span class="sourceLineNo">639</span><a name="line.639"></a>
<span class="sourceLineNo">640</span> /**<a name="line.640"></a>
<span class="sourceLineNo">641</span> * The specification of this method matches that of<a name="line.641"></a>
<span class="sourceLineNo">642</span> * {@link FileContext#truncate(Path, long)} except that Path f must be for<a name="line.642"></a>
<span class="sourceLineNo">643</span> * this file system.<a name="line.643"></a>
<span class="sourceLineNo">644</span> */<a name="line.644"></a>
<span class="sourceLineNo">645</span> public boolean truncate(Path f, long newLength)<a name="line.645"></a>
<span class="sourceLineNo">646</span> throws AccessControlException, FileNotFoundException,<a name="line.646"></a>
<span class="sourceLineNo">647</span> UnresolvedLinkException, IOException {<a name="line.647"></a>
<span class="sourceLineNo">648</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.648"></a>
<span class="sourceLineNo">649</span> + " doesn't support truncate");<a name="line.649"></a>
<span class="sourceLineNo">650</span> }<a name="line.650"></a>
<span class="sourceLineNo">651</span><a name="line.651"></a>
<span class="sourceLineNo">652</span> /**<a name="line.652"></a>
<span class="sourceLineNo">653</span> * The specification of this method matches that of<a name="line.653"></a>
<span class="sourceLineNo">654</span> * {@link FileContext#setReplication(Path, short)} except that Path f must be<a name="line.654"></a>
<span class="sourceLineNo">655</span> * for this file system.<a name="line.655"></a>
<span class="sourceLineNo">656</span> */<a name="line.656"></a>
<span class="sourceLineNo">657</span> public abstract boolean setReplication(final Path f,<a name="line.657"></a>
<span class="sourceLineNo">658</span> final short replication) throws AccessControlException,<a name="line.658"></a>
<span class="sourceLineNo">659</span> FileNotFoundException, UnresolvedLinkException, IOException;<a name="line.659"></a>
<span class="sourceLineNo">660</span><a name="line.660"></a>
<span class="sourceLineNo">661</span> /**<a name="line.661"></a>
<span class="sourceLineNo">662</span> * The specification of this method matches that of<a name="line.662"></a>
<span class="sourceLineNo">663</span> * {@link FileContext#rename(Path, Path, Options.Rename...)} except that Path<a name="line.663"></a>
<span class="sourceLineNo">664</span> * f must be for this file system.<a name="line.664"></a>
<span class="sourceLineNo">665</span> */<a name="line.665"></a>
<span class="sourceLineNo">666</span> public final void rename(final Path src, final Path dst,<a name="line.666"></a>
<span class="sourceLineNo">667</span> final Options.Rename... options) throws AccessControlException,<a name="line.667"></a>
<span class="sourceLineNo">668</span> FileAlreadyExistsException, FileNotFoundException,<a name="line.668"></a>
<span class="sourceLineNo">669</span> ParentNotDirectoryException, UnresolvedLinkException, IOException {<a name="line.669"></a>
<span class="sourceLineNo">670</span> boolean overwrite = false;<a name="line.670"></a>
<span class="sourceLineNo">671</span> if (null != options) {<a name="line.671"></a>
<span class="sourceLineNo">672</span> for (Rename option : options) {<a name="line.672"></a>
<span class="sourceLineNo">673</span> if (option == Rename.OVERWRITE) {<a name="line.673"></a>
<span class="sourceLineNo">674</span> overwrite = true;<a name="line.674"></a>
<span class="sourceLineNo">675</span> }<a name="line.675"></a>
<span class="sourceLineNo">676</span> }<a name="line.676"></a>
<span class="sourceLineNo">677</span> }<a name="line.677"></a>
<span class="sourceLineNo">678</span> renameInternal(src, dst, overwrite);<a name="line.678"></a>
<span class="sourceLineNo">679</span> }<a name="line.679"></a>
<span class="sourceLineNo">680</span> <a name="line.680"></a>
<span class="sourceLineNo">681</span> /**<a name="line.681"></a>
<span class="sourceLineNo">682</span> * The specification of this method matches that of<a name="line.682"></a>
<span class="sourceLineNo">683</span> * {@link FileContext#rename(Path, Path, Options.Rename...)} except that Path<a name="line.683"></a>
<span class="sourceLineNo">684</span> * f must be for this file system and NO OVERWRITE is performed.<a name="line.684"></a>
<span class="sourceLineNo">685</span> * <a name="line.685"></a>
<span class="sourceLineNo">686</span> * File systems that do not have a built in overwrite need implement only this<a name="line.686"></a>
<span class="sourceLineNo">687</span> * method and can take advantage of the default impl of the other<a name="line.687"></a>
<span class="sourceLineNo">688</span> * {@link #renameInternal(Path, Path, boolean)}<a name="line.688"></a>
<span class="sourceLineNo">689</span> */<a name="line.689"></a>
<span class="sourceLineNo">690</span> public abstract void renameInternal(final Path src, final Path dst)<a name="line.690"></a>
<span class="sourceLineNo">691</span> throws AccessControlException, FileAlreadyExistsException,<a name="line.691"></a>
<span class="sourceLineNo">692</span> FileNotFoundException, ParentNotDirectoryException,<a name="line.692"></a>
<span class="sourceLineNo">693</span> UnresolvedLinkException, IOException;<a name="line.693"></a>
<span class="sourceLineNo">694</span> <a name="line.694"></a>
<span class="sourceLineNo">695</span> /**<a name="line.695"></a>
<span class="sourceLineNo">696</span> * The specification of this method matches that of<a name="line.696"></a>
<span class="sourceLineNo">697</span> * {@link FileContext#rename(Path, Path, Options.Rename...)} except that Path<a name="line.697"></a>
<span class="sourceLineNo">698</span> * f must be for this file system.<a name="line.698"></a>
<span class="sourceLineNo">699</span> */<a name="line.699"></a>
<span class="sourceLineNo">700</span> public void renameInternal(final Path src, final Path dst,<a name="line.700"></a>
<span class="sourceLineNo">701</span> boolean overwrite) throws AccessControlException,<a name="line.701"></a>
<span class="sourceLineNo">702</span> FileAlreadyExistsException, FileNotFoundException,<a name="line.702"></a>
<span class="sourceLineNo">703</span> ParentNotDirectoryException, UnresolvedLinkException, IOException {<a name="line.703"></a>
<span class="sourceLineNo">704</span> // Default implementation deals with overwrite in a non-atomic way<a name="line.704"></a>
<span class="sourceLineNo">705</span> final FileStatus srcStatus = getFileLinkStatus(src);<a name="line.705"></a>
<span class="sourceLineNo">706</span><a name="line.706"></a>
<span class="sourceLineNo">707</span> FileStatus dstStatus;<a name="line.707"></a>
<span class="sourceLineNo">708</span> try {<a name="line.708"></a>
<span class="sourceLineNo">709</span> dstStatus = getFileLinkStatus(dst);<a name="line.709"></a>
<span class="sourceLineNo">710</span> } catch (IOException e) {<a name="line.710"></a>
<span class="sourceLineNo">711</span> dstStatus = null;<a name="line.711"></a>
<span class="sourceLineNo">712</span> }<a name="line.712"></a>
<span class="sourceLineNo">713</span> if (dstStatus != null) {<a name="line.713"></a>
<span class="sourceLineNo">714</span> if (dst.equals(src)) {<a name="line.714"></a>
<span class="sourceLineNo">715</span> throw new FileAlreadyExistsException(<a name="line.715"></a>
<span class="sourceLineNo">716</span> "The source "+src+" and destination "+dst+" are the same");<a name="line.716"></a>
<span class="sourceLineNo">717</span> }<a name="line.717"></a>
<span class="sourceLineNo">718</span> if (srcStatus.isSymlink() && dst.equals(srcStatus.getSymlink())) {<a name="line.718"></a>
<span class="sourceLineNo">719</span> throw new FileAlreadyExistsException(<a name="line.719"></a>
<span class="sourceLineNo">720</span> "Cannot rename symlink "+src+" to its target "+dst);<a name="line.720"></a>
<span class="sourceLineNo">721</span> }<a name="line.721"></a>
<span class="sourceLineNo">722</span> // It's OK to rename a file to a symlink and vice versa<a name="line.722"></a>
<span class="sourceLineNo">723</span> if (srcStatus.isDirectory() != dstStatus.isDirectory()) {<a name="line.723"></a>
<span class="sourceLineNo">724</span> throw new IOException("Source " + src + " and destination " + dst<a name="line.724"></a>
<span class="sourceLineNo">725</span> + " must both be directories");<a name="line.725"></a>
<span class="sourceLineNo">726</span> }<a name="line.726"></a>
<span class="sourceLineNo">727</span> if (!overwrite) {<a name="line.727"></a>
<span class="sourceLineNo">728</span> throw new FileAlreadyExistsException("Rename destination " + dst<a name="line.728"></a>
<span class="sourceLineNo">729</span> + " already exists.");<a name="line.729"></a>
<span class="sourceLineNo">730</span> }<a name="line.730"></a>
<span class="sourceLineNo">731</span> // Delete the destination that is a file or an empty directory<a name="line.731"></a>
<span class="sourceLineNo">732</span> if (dstStatus.isDirectory()) {<a name="line.732"></a>
<span class="sourceLineNo">733</span> RemoteIterator<FileStatus> list = listStatusIterator(dst);<a name="line.733"></a>
<span class="sourceLineNo">734</span> if (list != null && list.hasNext()) {<a name="line.734"></a>
<span class="sourceLineNo">735</span> throw new IOException(<a name="line.735"></a>
<span class="sourceLineNo">736</span> "Rename cannot overwrite non empty destination directory " + dst);<a name="line.736"></a>
<span class="sourceLineNo">737</span> }<a name="line.737"></a>
<span class="sourceLineNo">738</span> }<a name="line.738"></a>
<span class="sourceLineNo">739</span> delete(dst, false);<a name="line.739"></a>
<span class="sourceLineNo">740</span> } else {<a name="line.740"></a>
<span class="sourceLineNo">741</span> final Path parent = dst.getParent();<a name="line.741"></a>
<span class="sourceLineNo">742</span> final FileStatus parentStatus = getFileStatus(parent);<a name="line.742"></a>
<span class="sourceLineNo">743</span> if (parentStatus.isFile()) {<a name="line.743"></a>
<span class="sourceLineNo">744</span> throw new ParentNotDirectoryException("Rename destination parent "<a name="line.744"></a>
<span class="sourceLineNo">745</span> + parent + " is a file.");<a name="line.745"></a>
<span class="sourceLineNo">746</span> }<a name="line.746"></a>
<span class="sourceLineNo">747</span> }<a name="line.747"></a>
<span class="sourceLineNo">748</span> renameInternal(src, dst);<a name="line.748"></a>
<span class="sourceLineNo">749</span> }<a name="line.749"></a>
<span class="sourceLineNo">750</span> <a name="line.750"></a>
<span class="sourceLineNo">751</span> /**<a name="line.751"></a>
<span class="sourceLineNo">752</span> * Returns true if the file system supports symlinks, false otherwise.<a name="line.752"></a>
<span class="sourceLineNo">753</span> * @return true if filesystem supports symlinks<a name="line.753"></a>
<span class="sourceLineNo">754</span> */<a name="line.754"></a>
<span class="sourceLineNo">755</span> public boolean supportsSymlinks() {<a name="line.755"></a>
<span class="sourceLineNo">756</span> return false;<a name="line.756"></a>
<span class="sourceLineNo">757</span> }<a name="line.757"></a>
<span class="sourceLineNo">758</span> <a name="line.758"></a>
<span class="sourceLineNo">759</span> /**<a name="line.759"></a>
<span class="sourceLineNo">760</span> * The specification of this method matches that of <a name="line.760"></a>
<span class="sourceLineNo">761</span> * {@link FileContext#createSymlink(Path, Path, boolean)};<a name="line.761"></a>
<span class="sourceLineNo">762</span> */<a name="line.762"></a>
<span class="sourceLineNo">763</span> public void createSymlink(final Path target, final Path link,<a name="line.763"></a>
<span class="sourceLineNo">764</span> final boolean createParent) throws IOException, UnresolvedLinkException {<a name="line.764"></a>
<span class="sourceLineNo">765</span> throw new IOException("File system does not support symlinks"); <a name="line.765"></a>
<span class="sourceLineNo">766</span> }<a name="line.766"></a>
<span class="sourceLineNo">767</span><a name="line.767"></a>
<span class="sourceLineNo">768</span> /**<a name="line.768"></a>
<span class="sourceLineNo">769</span> * Partially resolves the path. This is used during symlink resolution in<a name="line.769"></a>
<span class="sourceLineNo">770</span> * {@link FSLinkResolver}, and differs from the similarly named method<a name="line.770"></a>
<span class="sourceLineNo">771</span> * {@link FileContext#getLinkTarget(Path)}.<a name="line.771"></a>
<span class="sourceLineNo">772</span> * @throws IOException subclass implementations may throw IOException <a name="line.772"></a>
<span class="sourceLineNo">773</span> */<a name="line.773"></a>
<span class="sourceLineNo">774</span> public Path getLinkTarget(final Path f) throws IOException {<a name="line.774"></a>
<span class="sourceLineNo">775</span> throw new AssertionError("Implementation Error: " + getClass()<a name="line.775"></a>
<span class="sourceLineNo">776</span> + " that threw an UnresolvedLinkException, causing this method to be"<a name="line.776"></a>
<span class="sourceLineNo">777</span> + " called, needs to override this method.");<a name="line.777"></a>
<span class="sourceLineNo">778</span> }<a name="line.778"></a>
<span class="sourceLineNo">779</span> <a name="line.779"></a>
<span class="sourceLineNo">780</span> /**<a name="line.780"></a>
<span class="sourceLineNo">781</span> * The specification of this method matches that of<a name="line.781"></a>
<span class="sourceLineNo">782</span> * {@link FileContext#setPermission(Path, FsPermission)} except that Path f<a name="line.782"></a>
<span class="sourceLineNo">783</span> * must be for this file system.<a name="line.783"></a>
<span class="sourceLineNo">784</span> */<a name="line.784"></a>
<span class="sourceLineNo">785</span> public abstract void setPermission(final Path f,<a name="line.785"></a>
<span class="sourceLineNo">786</span> final FsPermission permission) throws AccessControlException,<a name="line.786"></a>
<span class="sourceLineNo">787</span> FileNotFoundException, UnresolvedLinkException, IOException;<a name="line.787"></a>
<span class="sourceLineNo">788</span><a name="line.788"></a>
<span class="sourceLineNo">789</span> /**<a name="line.789"></a>
<span class="sourceLineNo">790</span> * The specification of this method matches that of<a name="line.790"></a>
<span class="sourceLineNo">791</span> * {@link FileContext#setOwner(Path, String, String)} except that Path f must<a name="line.791"></a>
<span class="sourceLineNo">792</span> * be for this file system.<a name="line.792"></a>
<span class="sourceLineNo">793</span> */<a name="line.793"></a>
<span class="sourceLineNo">794</span> public abstract void setOwner(final Path f, final String username,<a name="line.794"></a>
<span class="sourceLineNo">795</span> final String groupname) throws AccessControlException,<a name="line.795"></a>
<span class="sourceLineNo">796</span> FileNotFoundException, UnresolvedLinkException, IOException;<a name="line.796"></a>
<span class="sourceLineNo">797</span><a name="line.797"></a>
<span class="sourceLineNo">798</span> /**<a name="line.798"></a>
<span class="sourceLineNo">799</span> * The specification of this method matches that of<a name="line.799"></a>
<span class="sourceLineNo">800</span> * {@link FileContext#setTimes(Path, long, long)} except that Path f must be<a name="line.800"></a>
<span class="sourceLineNo">801</span> * for this file system.<a name="line.801"></a>
<span class="sourceLineNo">802</span> */<a name="line.802"></a>
<span class="sourceLineNo">803</span> public abstract void setTimes(final Path f, final long mtime,<a name="line.803"></a>
<span class="sourceLineNo">804</span> final long atime) throws AccessControlException, FileNotFoundException,<a name="line.804"></a>
<span class="sourceLineNo">805</span> UnresolvedLinkException, IOException;<a name="line.805"></a>
<span class="sourceLineNo">806</span><a name="line.806"></a>
<span class="sourceLineNo">807</span> /**<a name="line.807"></a>
<span class="sourceLineNo">808</span> * The specification of this method matches that of<a name="line.808"></a>
<span class="sourceLineNo">809</span> * {@link FileContext#getFileChecksum(Path)} except that Path f must be for<a name="line.809"></a>
<span class="sourceLineNo">810</span> * this file system.<a name="line.810"></a>
<span class="sourceLineNo">811</span> */<a name="line.811"></a>
<span class="sourceLineNo">812</span> public abstract FileChecksum getFileChecksum(final Path f)<a name="line.812"></a>
<span class="sourceLineNo">813</span> throws AccessControlException, FileNotFoundException,<a name="line.813"></a>
<span class="sourceLineNo">814</span> UnresolvedLinkException, IOException;<a name="line.814"></a>
<span class="sourceLineNo">815</span> <a name="line.815"></a>
<span class="sourceLineNo">816</span> /**<a name="line.816"></a>
<span class="sourceLineNo">817</span> * The specification of this method matches that of<a name="line.817"></a>
<span class="sourceLineNo">818</span> * {@link FileContext#getFileStatus(Path)} <a name="line.818"></a>
<span class="sourceLineNo">819</span> * except that an UnresolvedLinkException may be thrown if a symlink is <a name="line.819"></a>
<span class="sourceLineNo">820</span> * encountered in the path.<a name="line.820"></a>
<span class="sourceLineNo">821</span> */<a name="line.821"></a>
<span class="sourceLineNo">822</span> public abstract FileStatus getFileStatus(final Path f)<a name="line.822"></a>
<span class="sourceLineNo">823</span> throws AccessControlException, FileNotFoundException,<a name="line.823"></a>
<span class="sourceLineNo">824</span> UnresolvedLinkException, IOException;<a name="line.824"></a>
<span class="sourceLineNo">825</span><a name="line.825"></a>
<span class="sourceLineNo">826</span> /**<a name="line.826"></a>
<span class="sourceLineNo">827</span> * The specification of this method matches that of<a name="line.827"></a>
<span class="sourceLineNo">828</span> * {@link FileContext#access(Path, FsAction)}<a name="line.828"></a>
<span class="sourceLineNo">829</span> * except that an UnresolvedLinkException may be thrown if a symlink is<a name="line.829"></a>
<span class="sourceLineNo">830</span> * encountered in the path.<a name="line.830"></a>
<span class="sourceLineNo">831</span> */<a name="line.831"></a>
<span class="sourceLineNo">832</span> @InterfaceAudience.LimitedPrivate({"HDFS", "Hive"})<a name="line.832"></a>
<span class="sourceLineNo">833</span> public void access(Path path, FsAction mode) throws AccessControlException,<a name="line.833"></a>
<span class="sourceLineNo">834</span> FileNotFoundException, UnresolvedLinkException, IOException {<a name="line.834"></a>
<span class="sourceLineNo">835</span> FileSystem.checkAccessPermissions(this.getFileStatus(path), mode);<a name="line.835"></a>
<span class="sourceLineNo">836</span> }<a name="line.836"></a>
<span class="sourceLineNo">837</span><a name="line.837"></a>
<span class="sourceLineNo">838</span> /**<a name="line.838"></a>
<span class="sourceLineNo">839</span> * The specification of this method matches that of<a name="line.839"></a>
<span class="sourceLineNo">840</span> * {@link FileContext#getFileLinkStatus(Path)}<a name="line.840"></a>
<span class="sourceLineNo">841</span> * except that an UnresolvedLinkException may be thrown if a symlink is <a name="line.841"></a>
<span class="sourceLineNo">842</span> * encountered in the path leading up to the final path component.<a name="line.842"></a>
<span class="sourceLineNo">843</span> * If the file system does not support symlinks then the behavior is<a name="line.843"></a>
<span class="sourceLineNo">844</span> * equivalent to {@link AbstractFileSystem#getFileStatus(Path)}.<a name="line.844"></a>
<span class="sourceLineNo">845</span> */<a name="line.845"></a>
<span class="sourceLineNo">846</span> public FileStatus getFileLinkStatus(final Path f)<a name="line.846"></a>
<span class="sourceLineNo">847</span> throws AccessControlException, FileNotFoundException,<a name="line.847"></a>
<span class="sourceLineNo">848</span> UnsupportedFileSystemException, IOException {<a name="line.848"></a>
<span class="sourceLineNo">849</span> return getFileStatus(f);<a name="line.849"></a>
<span class="sourceLineNo">850</span> }<a name="line.850"></a>
<span class="sourceLineNo">851</span><a name="line.851"></a>
<span class="sourceLineNo">852</span> /**<a name="line.852"></a>
<span class="sourceLineNo">853</span> * The specification of this method matches that of<a name="line.853"></a>
<span class="sourceLineNo">854</span> * {@link FileContext#getFileBlockLocations(Path, long, long)} except that<a name="line.854"></a>
<span class="sourceLineNo">855</span> * Path f must be for this file system.<a name="line.855"></a>
<span class="sourceLineNo">856</span> */<a name="line.856"></a>
<span class="sourceLineNo">857</span> public abstract BlockLocation[] getFileBlockLocations(final Path f,<a name="line.857"></a>
<span class="sourceLineNo">858</span> final long start, final long len) throws AccessControlException,<a name="line.858"></a>
<span class="sourceLineNo">859</span> FileNotFoundException, UnresolvedLinkException, IOException;<a name="line.859"></a>
<span class="sourceLineNo">860</span><a name="line.860"></a>
<span class="sourceLineNo">861</span> /**<a name="line.861"></a>
<span class="sourceLineNo">862</span> * The specification of this method matches that of<a name="line.862"></a>
<span class="sourceLineNo">863</span> * {@link FileContext#getFsStatus(Path)} except that Path f must be for this<a name="line.863"></a>
<span class="sourceLineNo">864</span> * file system.<a name="line.864"></a>
<span class="sourceLineNo">865</span> */<a name="line.865"></a>
<span class="sourceLineNo">866</span> public FsStatus getFsStatus(final Path f) throws AccessControlException,<a name="line.866"></a>
<span class="sourceLineNo">867</span> FileNotFoundException, UnresolvedLinkException, IOException {<a name="line.867"></a>
<span class="sourceLineNo">868</span> // default impl gets FsStatus of root<a name="line.868"></a>
<span class="sourceLineNo">869</span> return getFsStatus();<a name="line.869"></a>
<span class="sourceLineNo">870</span> }<a name="line.870"></a>
<span class="sourceLineNo">871</span> <a name="line.871"></a>
<span class="sourceLineNo">872</span> /**<a name="line.872"></a>
<span class="sourceLineNo">873</span> * The specification of this method matches that of<a name="line.873"></a>
<span class="sourceLineNo">874</span> * {@link FileContext#getFsStatus(Path)}.<a name="line.874"></a>
<span class="sourceLineNo">875</span> */<a name="line.875"></a>
<span class="sourceLineNo">876</span> public abstract FsStatus getFsStatus() throws AccessControlException,<a name="line.876"></a>
<span class="sourceLineNo">877</span> FileNotFoundException, IOException;<a name="line.877"></a>
<span class="sourceLineNo">878</span><a name="line.878"></a>
<span class="sourceLineNo">879</span> /**<a name="line.879"></a>
<span class="sourceLineNo">880</span> * The specification of this method matches that of<a name="line.880"></a>
<span class="sourceLineNo">881</span> * {@link FileContext#listStatus(Path)} except that Path f must be for this<a name="line.881"></a>
<span class="sourceLineNo">882</span> * file system.<a name="line.882"></a>
<span class="sourceLineNo">883</span> */<a name="line.883"></a>
<span class="sourceLineNo">884</span> public RemoteIterator<FileStatus> listStatusIterator(final Path f)<a name="line.884"></a>
<span class="sourceLineNo">885</span> throws AccessControlException, FileNotFoundException,<a name="line.885"></a>
<span class="sourceLineNo">886</span> UnresolvedLinkException, IOException {<a name="line.886"></a>
<span class="sourceLineNo">887</span> return new RemoteIterator<FileStatus>() {<a name="line.887"></a>
<span class="sourceLineNo">888</span> private int i = 0;<a name="line.888"></a>
<span class="sourceLineNo">889</span> private FileStatus[] statusList = listStatus(f);<a name="line.889"></a>
<span class="sourceLineNo">890</span> <a name="line.890"></a>
<span class="sourceLineNo">891</span> @Override<a name="line.891"></a>
<span class="sourceLineNo">892</span> public boolean hasNext() {<a name="line.892"></a>
<span class="sourceLineNo">893</span> return i < statusList.length;<a name="line.893"></a>
<span class="sourceLineNo">894</span> }<a name="line.894"></a>
<span class="sourceLineNo">895</span> <a name="line.895"></a>
<span class="sourceLineNo">896</span> @Override<a name="line.896"></a>
<span class="sourceLineNo">897</span> public FileStatus next() {<a name="line.897"></a>
<span class="sourceLineNo">898</span> if (!hasNext()) {<a name="line.898"></a>
<span class="sourceLineNo">899</span> throw new NoSuchElementException();<a name="line.899"></a>
<span class="sourceLineNo">900</span> }<a name="line.900"></a>
<span class="sourceLineNo">901</span> return statusList[i++];<a name="line.901"></a>
<span class="sourceLineNo">902</span> }<a name="line.902"></a>
<span class="sourceLineNo">903</span> };<a name="line.903"></a>
<span class="sourceLineNo">904</span> }<a name="line.904"></a>
<span class="sourceLineNo">905</span><a name="line.905"></a>
<span class="sourceLineNo">906</span> /**<a name="line.906"></a>
<span class="sourceLineNo">907</span> * The specification of this method matches that of<a name="line.907"></a>
<span class="sourceLineNo">908</span> * {@link FileContext#listLocatedStatus(Path)} except that Path f <a name="line.908"></a>
<span class="sourceLineNo">909</span> * must be for this file system.<a name="line.909"></a>
<span class="sourceLineNo">910</span> */<a name="line.910"></a>
<span class="sourceLineNo">911</span> public RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path f)<a name="line.911"></a>
<span class="sourceLineNo">912</span> throws AccessControlException, FileNotFoundException,<a name="line.912"></a>
<span class="sourceLineNo">913</span> UnresolvedLinkException, IOException {<a name="line.913"></a>
<span class="sourceLineNo">914</span> return new RemoteIterator<LocatedFileStatus>() {<a name="line.914"></a>
<span class="sourceLineNo">915</span> private RemoteIterator<FileStatus> itor = listStatusIterator(f);<a name="line.915"></a>
<span class="sourceLineNo">916</span> <a name="line.916"></a>
<span class="sourceLineNo">917</span> @Override<a name="line.917"></a>
<span class="sourceLineNo">918</span> public boolean hasNext() throws IOException {<a name="line.918"></a>
<span class="sourceLineNo">919</span> return itor.hasNext();<a name="line.919"></a>
<span class="sourceLineNo">920</span> }<a name="line.920"></a>
<span class="sourceLineNo">921</span> <a name="line.921"></a>
<span class="sourceLineNo">922</span> @Override<a name="line.922"></a>
<span class="sourceLineNo">923</span> public LocatedFileStatus next() throws IOException {<a name="line.923"></a>
<span class="sourceLineNo">924</span> if (!hasNext()) {<a name="line.924"></a>
<span class="sourceLineNo">925</span> throw new NoSuchElementException("No more entry in " + f);<a name="line.925"></a>
<span class="sourceLineNo">926</span> }<a name="line.926"></a>
<span class="sourceLineNo">927</span> FileStatus result = itor.next();<a name="line.927"></a>
<span class="sourceLineNo">928</span> BlockLocation[] locs = null;<a name="line.928"></a>
<span class="sourceLineNo">929</span> if (result.isFile()) {<a name="line.929"></a>
<span class="sourceLineNo">930</span> locs = getFileBlockLocations(<a name="line.930"></a>
<span class="sourceLineNo">931</span> result.getPath(), 0, result.getLen());<a name="line.931"></a>
<span class="sourceLineNo">932</span> }<a name="line.932"></a>
<span class="sourceLineNo">933</span> return new LocatedFileStatus(result, locs);<a name="line.933"></a>
<span class="sourceLineNo">934</span> }<a name="line.934"></a>
<span class="sourceLineNo">935</span> };<a name="line.935"></a>
<span class="sourceLineNo">936</span> }<a name="line.936"></a>
<span class="sourceLineNo">937</span><a name="line.937"></a>
<span class="sourceLineNo">938</span> /**<a name="line.938"></a>
<span class="sourceLineNo">939</span> * The specification of this method matches that of<a name="line.939"></a>
<span class="sourceLineNo">940</span> * {@link FileContext.Util#listStatus(Path)} except that Path f must be <a name="line.940"></a>
<span class="sourceLineNo">941</span> * for this file system.<a name="line.941"></a>
<span class="sourceLineNo">942</span> */<a name="line.942"></a>
<span class="sourceLineNo">943</span> public abstract FileStatus[] listStatus(final Path f)<a name="line.943"></a>
<span class="sourceLineNo">944</span> throws AccessControlException, FileNotFoundException,<a name="line.944"></a>
<span class="sourceLineNo">945</span> UnresolvedLinkException, IOException;<a name="line.945"></a>
<span class="sourceLineNo">946</span><a name="line.946"></a>
<span class="sourceLineNo">947</span> /**<a name="line.947"></a>
<span class="sourceLineNo">948</span> * @return an iterator over the corrupt files under the given path<a name="line.948"></a>
<span class="sourceLineNo">949</span> * (may contain duplicates if a file has more than one corrupt block)<a name="line.949"></a>
<span class="sourceLineNo">950</span> * @throws IOException<a name="line.950"></a>
<span class="sourceLineNo">951</span> */<a name="line.951"></a>
<span class="sourceLineNo">952</span> public RemoteIterator<Path> listCorruptFileBlocks(Path path)<a name="line.952"></a>
<span class="sourceLineNo">953</span> throws IOException {<a name="line.953"></a>
<span class="sourceLineNo">954</span> throw new UnsupportedOperationException(getClass().getCanonicalName() +<a name="line.954"></a>
<span class="sourceLineNo">955</span> " does not support" +<a name="line.955"></a>
<span class="sourceLineNo">956</span> " listCorruptFileBlocks");<a name="line.956"></a>
<span class="sourceLineNo">957</span> }<a name="line.957"></a>
<span class="sourceLineNo">958</span><a name="line.958"></a>
<span class="sourceLineNo">959</span> /**<a name="line.959"></a>
<span class="sourceLineNo">960</span> * The specification of this method matches that of<a name="line.960"></a>
<span class="sourceLineNo">961</span> * {@link FileContext#setVerifyChecksum(boolean, Path)} except that Path f<a name="line.961"></a>
<span class="sourceLineNo">962</span> * must be for this file system.<a name="line.962"></a>
<span class="sourceLineNo">963</span> */<a name="line.963"></a>
<span class="sourceLineNo">964</span> public abstract void setVerifyChecksum(final boolean verifyChecksum)<a name="line.964"></a>
<span class="sourceLineNo">965</span> throws AccessControlException, IOException;<a name="line.965"></a>
<span class="sourceLineNo">966</span> <a name="line.966"></a>
<span class="sourceLineNo">967</span> /**<a name="line.967"></a>
<span class="sourceLineNo">968</span> * Get a canonical name for this file system.<a name="line.968"></a>
<span class="sourceLineNo">969</span> * @return a URI string that uniquely identifies this file system<a name="line.969"></a>
<span class="sourceLineNo">970</span> */<a name="line.970"></a>
<span class="sourceLineNo">971</span> public String getCanonicalServiceName() {<a name="line.971"></a>
<span class="sourceLineNo">972</span> return SecurityUtil.buildDTServiceName(getUri(), getUriDefaultPort());<a name="line.972"></a>
<span class="sourceLineNo">973</span> }<a name="line.973"></a>
<span class="sourceLineNo">974</span> <a name="line.974"></a>
<span class="sourceLineNo">975</span> /**<a name="line.975"></a>
<span class="sourceLineNo">976</span> * Get one or more delegation tokens associated with the filesystem. Normally<a name="line.976"></a>
<span class="sourceLineNo">977</span> * a file system returns a single delegation token. A file system that manages<a name="line.977"></a>
<span class="sourceLineNo">978</span> * multiple file systems underneath, could return set of delegation tokens for<a name="line.978"></a>
<span class="sourceLineNo">979</span> * all the file systems it manages<a name="line.979"></a>
<span class="sourceLineNo">980</span> * <a name="line.980"></a>
<span class="sourceLineNo">981</span> * @param renewer the account name that is allowed to renew the token.<a name="line.981"></a>
<span class="sourceLineNo">982</span> * @return List of delegation tokens.<a name="line.982"></a>
<span class="sourceLineNo">983</span> * If delegation tokens not supported then return a list of size zero.<a name="line.983"></a>
<span class="sourceLineNo">984</span> * @throws IOException<a name="line.984"></a>
<span class="sourceLineNo">985</span> */<a name="line.985"></a>
<span class="sourceLineNo">986</span> @InterfaceAudience.LimitedPrivate( { "HDFS", "MapReduce" })<a name="line.986"></a>
<span class="sourceLineNo">987</span> public List<Token<?>> getDelegationTokens(String renewer) throws IOException {<a name="line.987"></a>
<span class="sourceLineNo">988</span> return new ArrayList<Token<?>>(0);<a name="line.988"></a>
<span class="sourceLineNo">989</span> }<a name="line.989"></a>
<span class="sourceLineNo">990</span><a name="line.990"></a>
<span class="sourceLineNo">991</span> /**<a name="line.991"></a>
<span class="sourceLineNo">992</span> * Modifies ACL entries of files and directories. This method can add new ACL<a name="line.992"></a>
<span class="sourceLineNo">993</span> * entries or modify the permissions on existing ACL entries. All existing<a name="line.993"></a>
<span class="sourceLineNo">994</span> * ACL entries that are not specified in this call are retained without<a name="line.994"></a>
<span class="sourceLineNo">995</span> * changes. (Modifications are merged into the current ACL.)<a name="line.995"></a>
<span class="sourceLineNo">996</span> *<a name="line.996"></a>
<span class="sourceLineNo">997</span> * @param path Path to modify<a name="line.997"></a>
<span class="sourceLineNo">998</span> * @param aclSpec List<AclEntry> describing modifications<a name="line.998"></a>
<span class="sourceLineNo">999</span> * @throws IOException if an ACL could not be modified<a name="line.999"></a>
<span class="sourceLineNo">1000</span> */<a name="line.1000"></a>
<span class="sourceLineNo">1001</span> public void modifyAclEntries(Path path, List<AclEntry> aclSpec)<a name="line.1001"></a>
<span class="sourceLineNo">1002</span> throws IOException {<a name="line.1002"></a>
<span class="sourceLineNo">1003</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1003"></a>
<span class="sourceLineNo">1004</span> + " doesn't support modifyAclEntries");<a name="line.1004"></a>
<span class="sourceLineNo">1005</span> }<a name="line.1005"></a>
<span class="sourceLineNo">1006</span><a name="line.1006"></a>
<span class="sourceLineNo">1007</span> /**<a name="line.1007"></a>
<span class="sourceLineNo">1008</span> * Removes ACL entries from files and directories. Other ACL entries are<a name="line.1008"></a>
<span class="sourceLineNo">1009</span> * retained.<a name="line.1009"></a>
<span class="sourceLineNo">1010</span> *<a name="line.1010"></a>
<span class="sourceLineNo">1011</span> * @param path Path to modify<a name="line.1011"></a>
<span class="sourceLineNo">1012</span> * @param aclSpec List<AclEntry> describing entries to remove<a name="line.1012"></a>
<span class="sourceLineNo">1013</span> * @throws IOException if an ACL could not be modified<a name="line.1013"></a>
<span class="sourceLineNo">1014</span> */<a name="line.1014"></a>
<span class="sourceLineNo">1015</span> public void removeAclEntries(Path path, List<AclEntry> aclSpec)<a name="line.1015"></a>
<span class="sourceLineNo">1016</span> throws IOException {<a name="line.1016"></a>
<span class="sourceLineNo">1017</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1017"></a>
<span class="sourceLineNo">1018</span> + " doesn't support removeAclEntries");<a name="line.1018"></a>
<span class="sourceLineNo">1019</span> }<a name="line.1019"></a>
<span class="sourceLineNo">1020</span><a name="line.1020"></a>
<span class="sourceLineNo">1021</span> /**<a name="line.1021"></a>
<span class="sourceLineNo">1022</span> * Removes all default ACL entries from files and directories.<a name="line.1022"></a>
<span class="sourceLineNo">1023</span> *<a name="line.1023"></a>
<span class="sourceLineNo">1024</span> * @param path Path to modify<a name="line.1024"></a>
<span class="sourceLineNo">1025</span> * @throws IOException if an ACL could not be modified<a name="line.1025"></a>
<span class="sourceLineNo">1026</span> */<a name="line.1026"></a>
<span class="sourceLineNo">1027</span> public void removeDefaultAcl(Path path)<a name="line.1027"></a>
<span class="sourceLineNo">1028</span> throws IOException {<a name="line.1028"></a>
<span class="sourceLineNo">1029</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1029"></a>
<span class="sourceLineNo">1030</span> + " doesn't support removeDefaultAcl");<a name="line.1030"></a>
<span class="sourceLineNo">1031</span> }<a name="line.1031"></a>
<span class="sourceLineNo">1032</span><a name="line.1032"></a>
<span class="sourceLineNo">1033</span> /**<a name="line.1033"></a>
<span class="sourceLineNo">1034</span> * Removes all but the base ACL entries of files and directories. The entries<a name="line.1034"></a>
<span class="sourceLineNo">1035</span> * for user, group, and others are retained for compatibility with permission<a name="line.1035"></a>
<span class="sourceLineNo">1036</span> * bits.<a name="line.1036"></a>
<span class="sourceLineNo">1037</span> *<a name="line.1037"></a>
<span class="sourceLineNo">1038</span> * @param path Path to modify<a name="line.1038"></a>
<span class="sourceLineNo">1039</span> * @throws IOException if an ACL could not be removed<a name="line.1039"></a>
<span class="sourceLineNo">1040</span> */<a name="line.1040"></a>
<span class="sourceLineNo">1041</span> public void removeAcl(Path path)<a name="line.1041"></a>
<span class="sourceLineNo">1042</span> throws IOException {<a name="line.1042"></a>
<span class="sourceLineNo">1043</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1043"></a>
<span class="sourceLineNo">1044</span> + " doesn't support removeAcl");<a name="line.1044"></a>
<span class="sourceLineNo">1045</span> }<a name="line.1045"></a>
<span class="sourceLineNo">1046</span><a name="line.1046"></a>
<span class="sourceLineNo">1047</span> /**<a name="line.1047"></a>
<span class="sourceLineNo">1048</span> * Fully replaces ACL of files and directories, discarding all existing<a name="line.1048"></a>
<span class="sourceLineNo">1049</span> * entries.<a name="line.1049"></a>
<span class="sourceLineNo">1050</span> *<a name="line.1050"></a>
<span class="sourceLineNo">1051</span> * @param path Path to modify<a name="line.1051"></a>
<span class="sourceLineNo">1052</span> * @param aclSpec List<AclEntry> describing modifications, must include entries<a name="line.1052"></a>
<span class="sourceLineNo">1053</span> * for user, group, and others for compatibility with permission bits.<a name="line.1053"></a>
<span class="sourceLineNo">1054</span> * @throws IOException if an ACL could not be modified<a name="line.1054"></a>
<span class="sourceLineNo">1055</span> */<a name="line.1055"></a>
<span class="sourceLineNo">1056</span> public void setAcl(Path path, List<AclEntry> aclSpec) throws IOException {<a name="line.1056"></a>
<span class="sourceLineNo">1057</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1057"></a>
<span class="sourceLineNo">1058</span> + " doesn't support setAcl");<a name="line.1058"></a>
<span class="sourceLineNo">1059</span> }<a name="line.1059"></a>
<span class="sourceLineNo">1060</span><a name="line.1060"></a>
<span class="sourceLineNo">1061</span> /**<a name="line.1061"></a>
<span class="sourceLineNo">1062</span> * Gets the ACLs of files and directories.<a name="line.1062"></a>
<span class="sourceLineNo">1063</span> *<a name="line.1063"></a>
<span class="sourceLineNo">1064</span> * @param path Path to get<a name="line.1064"></a>
<span class="sourceLineNo">1065</span> * @return RemoteIterator<AclStatus> which returns each AclStatus<a name="line.1065"></a>
<span class="sourceLineNo">1066</span> * @throws IOException if an ACL could not be read<a name="line.1066"></a>
<span class="sourceLineNo">1067</span> */<a name="line.1067"></a>
<span class="sourceLineNo">1068</span> public AclStatus getAclStatus(Path path) throws IOException {<a name="line.1068"></a>
<span class="sourceLineNo">1069</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1069"></a>
<span class="sourceLineNo">1070</span> + " doesn't support getAclStatus");<a name="line.1070"></a>
<span class="sourceLineNo">1071</span> }<a name="line.1071"></a>
<span class="sourceLineNo">1072</span><a name="line.1072"></a>
<span class="sourceLineNo">1073</span> /**<a name="line.1073"></a>
<span class="sourceLineNo">1074</span> * Set an xattr of a file or directory.<a name="line.1074"></a>
<span class="sourceLineNo">1075</span> * The name must be prefixed with the namespace followed by ".". For example,<a name="line.1075"></a>
<span class="sourceLineNo">1076</span> * "user.attr".<a name="line.1076"></a>
<span class="sourceLineNo">1077</span> * <p/><a name="line.1077"></a>
<span class="sourceLineNo">1078</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1078"></a>
<span class="sourceLineNo">1079</span> *<a name="line.1079"></a>
<span class="sourceLineNo">1080</span> * @param path Path to modify<a name="line.1080"></a>
<span class="sourceLineNo">1081</span> * @param name xattr name.<a name="line.1081"></a>
<span class="sourceLineNo">1082</span> * @param value xattr value.<a name="line.1082"></a>
<span class="sourceLineNo">1083</span> * @throws IOException<a name="line.1083"></a>
<span class="sourceLineNo">1084</span> */<a name="line.1084"></a>
<span class="sourceLineNo">1085</span> public void setXAttr(Path path, String name, byte[] value)<a name="line.1085"></a>
<span class="sourceLineNo">1086</span> throws IOException {<a name="line.1086"></a>
<span class="sourceLineNo">1087</span> setXAttr(path, name, value, EnumSet.of(XAttrSetFlag.CREATE,<a name="line.1087"></a>
<span class="sourceLineNo">1088</span> XAttrSetFlag.REPLACE));<a name="line.1088"></a>
<span class="sourceLineNo">1089</span> }<a name="line.1089"></a>
<span class="sourceLineNo">1090</span><a name="line.1090"></a>
<span class="sourceLineNo">1091</span> /**<a name="line.1091"></a>
<span class="sourceLineNo">1092</span> * Set an xattr of a file or directory.<a name="line.1092"></a>
<span class="sourceLineNo">1093</span> * The name must be prefixed with the namespace followed by ".". For example,<a name="line.1093"></a>
<span class="sourceLineNo">1094</span> * "user.attr".<a name="line.1094"></a>
<span class="sourceLineNo">1095</span> * <p/><a name="line.1095"></a>
<span class="sourceLineNo">1096</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1096"></a>
<span class="sourceLineNo">1097</span> *<a name="line.1097"></a>
<span class="sourceLineNo">1098</span> * @param path Path to modify<a name="line.1098"></a>
<span class="sourceLineNo">1099</span> * @param name xattr name.<a name="line.1099"></a>
<span class="sourceLineNo">1100</span> * @param value xattr value.<a name="line.1100"></a>
<span class="sourceLineNo">1101</span> * @param flag xattr set flag<a name="line.1101"></a>
<span class="sourceLineNo">1102</span> * @throws IOException<a name="line.1102"></a>
<span class="sourceLineNo">1103</span> */<a name="line.1103"></a>
<span class="sourceLineNo">1104</span> public void setXAttr(Path path, String name, byte[] value,<a name="line.1104"></a>
<span class="sourceLineNo">1105</span> EnumSet<XAttrSetFlag> flag) throws IOException {<a name="line.1105"></a>
<span class="sourceLineNo">1106</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1106"></a>
<span class="sourceLineNo">1107</span> + " doesn't support setXAttr");<a name="line.1107"></a>
<span class="sourceLineNo">1108</span> }<a name="line.1108"></a>
<span class="sourceLineNo">1109</span><a name="line.1109"></a>
<span class="sourceLineNo">1110</span> /**<a name="line.1110"></a>
<span class="sourceLineNo">1111</span> * Get an xattr for a file or directory.<a name="line.1111"></a>
<span class="sourceLineNo">1112</span> * The name must be prefixed with the namespace followed by ".". For example,<a name="line.1112"></a>
<span class="sourceLineNo">1113</span> * "user.attr".<a name="line.1113"></a>
<span class="sourceLineNo">1114</span> * <p/><a name="line.1114"></a>
<span class="sourceLineNo">1115</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1115"></a>
<span class="sourceLineNo">1116</span> *<a name="line.1116"></a>
<span class="sourceLineNo">1117</span> * @param path Path to get extended attribute<a name="line.1117"></a>
<span class="sourceLineNo">1118</span> * @param name xattr name.<a name="line.1118"></a>
<span class="sourceLineNo">1119</span> * @return byte[] xattr value.<a name="line.1119"></a>
<span class="sourceLineNo">1120</span> * @throws IOException<a name="line.1120"></a>
<span class="sourceLineNo">1121</span> */<a name="line.1121"></a>
<span class="sourceLineNo">1122</span> public byte[] getXAttr(Path path, String name) throws IOException {<a name="line.1122"></a>
<span class="sourceLineNo">1123</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1123"></a>
<span class="sourceLineNo">1124</span> + " doesn't support getXAttr");<a name="line.1124"></a>
<span class="sourceLineNo">1125</span> }<a name="line.1125"></a>
<span class="sourceLineNo">1126</span><a name="line.1126"></a>
<span class="sourceLineNo">1127</span> /**<a name="line.1127"></a>
<span class="sourceLineNo">1128</span> * Get all of the xattrs for a file or directory.<a name="line.1128"></a>
<span class="sourceLineNo">1129</span> * Only those xattrs for which the logged-in user has permissions to view<a name="line.1129"></a>
<span class="sourceLineNo">1130</span> * are returned.<a name="line.1130"></a>
<span class="sourceLineNo">1131</span> * <p/><a name="line.1131"></a>
<span class="sourceLineNo">1132</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1132"></a>
<span class="sourceLineNo">1133</span> *<a name="line.1133"></a>
<span class="sourceLineNo">1134</span> * @param path Path to get extended attributes<a name="line.1134"></a>
<span class="sourceLineNo">1135</span> * @return Map<String, byte[]> describing the XAttrs of the file or directory<a name="line.1135"></a>
<span class="sourceLineNo">1136</span> * @throws IOException<a name="line.1136"></a>
<span class="sourceLineNo">1137</span> */<a name="line.1137"></a>
<span class="sourceLineNo">1138</span> public Map<String, byte[]> getXAttrs(Path path) throws IOException {<a name="line.1138"></a>
<span class="sourceLineNo">1139</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1139"></a>
<span class="sourceLineNo">1140</span> + " doesn't support getXAttrs");<a name="line.1140"></a>
<span class="sourceLineNo">1141</span> }<a name="line.1141"></a>
<span class="sourceLineNo">1142</span><a name="line.1142"></a>
<span class="sourceLineNo">1143</span> /**<a name="line.1143"></a>
<span class="sourceLineNo">1144</span> * Get all of the xattrs for a file or directory.<a name="line.1144"></a>
<span class="sourceLineNo">1145</span> * Only those xattrs for which the logged-in user has permissions to view<a name="line.1145"></a>
<span class="sourceLineNo">1146</span> * are returned.<a name="line.1146"></a>
<span class="sourceLineNo">1147</span> * <p/><a name="line.1147"></a>
<span class="sourceLineNo">1148</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1148"></a>
<span class="sourceLineNo">1149</span> *<a name="line.1149"></a>
<span class="sourceLineNo">1150</span> * @param path Path to get extended attributes<a name="line.1150"></a>
<span class="sourceLineNo">1151</span> * @param names XAttr names.<a name="line.1151"></a>
<span class="sourceLineNo">1152</span> * @return Map<String, byte[]> describing the XAttrs of the file or directory<a name="line.1152"></a>
<span class="sourceLineNo">1153</span> * @throws IOException<a name="line.1153"></a>
<span class="sourceLineNo">1154</span> */<a name="line.1154"></a>
<span class="sourceLineNo">1155</span> public Map<String, byte[]> getXAttrs(Path path, List<String> names)<a name="line.1155"></a>
<span class="sourceLineNo">1156</span> throws IOException {<a name="line.1156"></a>
<span class="sourceLineNo">1157</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1157"></a>
<span class="sourceLineNo">1158</span> + " doesn't support getXAttrs");<a name="line.1158"></a>
<span class="sourceLineNo">1159</span> }<a name="line.1159"></a>
<span class="sourceLineNo">1160</span><a name="line.1160"></a>
<span class="sourceLineNo">1161</span> /**<a name="line.1161"></a>
<span class="sourceLineNo">1162</span> * Get all of the xattr names for a file or directory.<a name="line.1162"></a>
<span class="sourceLineNo">1163</span> * Only the xattr names for which the logged-in user has permissions to view<a name="line.1163"></a>
<span class="sourceLineNo">1164</span> * are returned.<a name="line.1164"></a>
<span class="sourceLineNo">1165</span> * <p/><a name="line.1165"></a>
<span class="sourceLineNo">1166</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1166"></a>
<span class="sourceLineNo">1167</span> *<a name="line.1167"></a>
<span class="sourceLineNo">1168</span> * @param path Path to get extended attributes<a name="line.1168"></a>
<span class="sourceLineNo">1169</span> * @return Map<String, byte[]> describing the XAttrs of the file or directory<a name="line.1169"></a>
<span class="sourceLineNo">1170</span> * @throws IOException<a name="line.1170"></a>
<span class="sourceLineNo">1171</span> */<a name="line.1171"></a>
<span class="sourceLineNo">1172</span> public List<String> listXAttrs(Path path)<a name="line.1172"></a>
<span class="sourceLineNo">1173</span> throws IOException {<a name="line.1173"></a>
<span class="sourceLineNo">1174</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1174"></a>
<span class="sourceLineNo">1175</span> + " doesn't support listXAttrs");<a name="line.1175"></a>
<span class="sourceLineNo">1176</span> }<a name="line.1176"></a>
<span class="sourceLineNo">1177</span><a name="line.1177"></a>
<span class="sourceLineNo">1178</span> /**<a name="line.1178"></a>
<span class="sourceLineNo">1179</span> * Remove an xattr of a file or directory.<a name="line.1179"></a>
<span class="sourceLineNo">1180</span> * The name must be prefixed with the namespace followed by ".". For example,<a name="line.1180"></a>
<span class="sourceLineNo">1181</span> * "user.attr".<a name="line.1181"></a>
<span class="sourceLineNo">1182</span> * <p/><a name="line.1182"></a>
<span class="sourceLineNo">1183</span> * Refer to the HDFS extended attributes user documentation for details.<a name="line.1183"></a>
<span class="sourceLineNo">1184</span> *<a name="line.1184"></a>
<span class="sourceLineNo">1185</span> * @param path Path to remove extended attribute<a name="line.1185"></a>
<span class="sourceLineNo">1186</span> * @param name xattr name<a name="line.1186"></a>
<span class="sourceLineNo">1187</span> * @throws IOException<a name="line.1187"></a>
<span class="sourceLineNo">1188</span> */<a name="line.1188"></a>
<span class="sourceLineNo">1189</span> public void removeXAttr(Path path, String name) throws IOException {<a name="line.1189"></a>
<span class="sourceLineNo">1190</span> throw new UnsupportedOperationException(getClass().getSimpleName()<a name="line.1190"></a>
<span class="sourceLineNo">1191</span> + " doesn't support removeXAttr");<a name="line.1191"></a>
<span class="sourceLineNo">1192</span> }<a name="line.1192"></a>
<span class="sourceLineNo">1193</span><a name="line.1193"></a>
<span class="sourceLineNo">1194</span> @Override //Object<a name="line.1194"></a>
<span class="sourceLineNo">1195</span> public int hashCode() {<a name="line.1195"></a>
<span class="sourceLineNo">1196</span> return myUri.hashCode();<a name="line.1196"></a>
<span class="sourceLineNo">1197</span> }<a name="line.1197"></a>
<span class="sourceLineNo">1198</span> <a name="line.1198"></a>
<span class="sourceLineNo">1199</span> @Override //Object<a name="line.1199"></a>
<span class="sourceLineNo">1200</span> public boolean equals(Object other) {<a name="line.1200"></a>
<span class="sourceLineNo">1201</span> if (other == null || !(other instanceof AbstractFileSystem)) {<a name="line.1201"></a>
<span class="sourceLineNo">1202</span> return false;<a name="line.1202"></a>
<span class="sourceLineNo">1203</span> }<a name="line.1203"></a>
<span class="sourceLineNo">1204</span> return myUri.equals(((AbstractFileSystem) other).myUri);<a name="line.1204"></a>
<span class="sourceLineNo">1205</span> }<a name="line.1205"></a>
<span class="sourceLineNo">1206</span>}<a name="line.1206"></a>
</pre>
</div>
</body>
</html>
| TK-TarunW/ecosystem | hadoop-2.7.3/share/doc/hadoop/api/src-html/org/apache/hadoop/fs/AbstractFileSystem.html | HTML | apache-2.0 | 117,501 |
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
base_dir=$(dirname $0)/../..
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx512M"
fi
exec $base_dir/bin/kafka-run-class.sh kafka.examples.KafkaExactlyOnceDemo $@
| TiVo/kafka | examples/bin/exactly-once-demo.sh | Shell | apache-2.0 | 981 |
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/platform/numbers.h"
#include <ctype.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cinttypes>
#include <cmath>
#include <locale>
#include <unordered_map>
#include "double-conversion/double-conversion.h"
#include "tensorflow/core/platform/str_util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/platform/stringprintf.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
namespace {
template <typename T>
const std::unordered_map<string, T>* GetSpecialNumsSingleton() {
static const std::unordered_map<string, T>* special_nums =
CHECK_NOTNULL((new const std::unordered_map<string, T>{
{"inf", std::numeric_limits<T>::infinity()},
{"+inf", std::numeric_limits<T>::infinity()},
{"-inf", -std::numeric_limits<T>::infinity()},
{"infinity", std::numeric_limits<T>::infinity()},
{"+infinity", std::numeric_limits<T>::infinity()},
{"-infinity", -std::numeric_limits<T>::infinity()},
{"nan", std::numeric_limits<T>::quiet_NaN()},
{"+nan", std::numeric_limits<T>::quiet_NaN()},
{"-nan", -std::numeric_limits<T>::quiet_NaN()},
}));
return special_nums;
}
template <typename T>
T locale_independent_strtonum(const char* str, const char** endptr) {
auto special_nums = GetSpecialNumsSingleton<T>();
std::stringstream s(str);
// Check if str is one of the special numbers.
string special_num_str;
s >> special_num_str;
for (int i = 0; i < special_num_str.length(); ++i) {
special_num_str[i] =
std::tolower(special_num_str[i], std::locale::classic());
}
auto entry = special_nums->find(special_num_str);
if (entry != special_nums->end()) {
*endptr = str + (s.eof() ? static_cast<std::iostream::pos_type>(strlen(str))
: s.tellg());
return entry->second;
} else {
// Perhaps it's a hex number
if (special_num_str.compare(0, 2, "0x") == 0 ||
special_num_str.compare(0, 3, "-0x") == 0) {
return strtol(str, const_cast<char**>(endptr), 16);
}
}
// Reset the stream
s.str(str);
s.clear();
// Use the "C" locale
s.imbue(std::locale::classic());
T result;
s >> result;
// Set to result to what strto{f,d} functions would have returned. If the
// number was outside the range, the stringstream sets the fail flag, but
// returns the +/-max() value, whereas strto{f,d} functions return +/-INF.
if (s.fail()) {
if (result == std::numeric_limits<T>::max() ||
result == std::numeric_limits<T>::infinity()) {
result = std::numeric_limits<T>::infinity();
s.clear(s.rdstate() & ~std::ios::failbit);
} else if (result == -std::numeric_limits<T>::max() ||
result == -std::numeric_limits<T>::infinity()) {
result = -std::numeric_limits<T>::infinity();
s.clear(s.rdstate() & ~std::ios::failbit);
}
}
if (endptr) {
*endptr =
str +
(s.fail() ? static_cast<std::iostream::pos_type>(0)
: (s.eof() ? static_cast<std::iostream::pos_type>(strlen(str))
: s.tellg()));
}
return result;
}
static inline const double_conversion::StringToDoubleConverter&
StringToFloatConverter() {
static const double_conversion::StringToDoubleConverter converter(
double_conversion::StringToDoubleConverter::ALLOW_LEADING_SPACES |
double_conversion::StringToDoubleConverter::ALLOW_HEX |
double_conversion::StringToDoubleConverter::ALLOW_TRAILING_SPACES |
double_conversion::StringToDoubleConverter::ALLOW_CASE_INSENSIBILITY,
0., 0., "inf", "nan");
return converter;
}
} // namespace
namespace strings {
size_t FastInt32ToBufferLeft(int32 i, char* buffer) {
uint32 u = i;
size_t length = 0;
if (i < 0) {
*buffer++ = '-';
++length;
// We need to do the negation in modular (i.e., "unsigned")
// arithmetic; MSVC++ apparently warns for plain "-u", so
// we write the equivalent expression "0 - u" instead.
u = 0 - u;
}
length += FastUInt32ToBufferLeft(u, buffer);
return length;
}
size_t FastUInt32ToBufferLeft(uint32 i, char* buffer) {
char* start = buffer;
do {
*buffer++ = ((i % 10) + '0');
i /= 10;
} while (i > 0);
*buffer = 0;
std::reverse(start, buffer);
return buffer - start;
}
size_t FastInt64ToBufferLeft(int64 i, char* buffer) {
uint64 u = i;
size_t length = 0;
if (i < 0) {
*buffer++ = '-';
++length;
u = 0 - u;
}
length += FastUInt64ToBufferLeft(u, buffer);
return length;
}
size_t FastUInt64ToBufferLeft(uint64 i, char* buffer) {
char* start = buffer;
do {
*buffer++ = ((i % 10) + '0');
i /= 10;
} while (i > 0);
*buffer = 0;
std::reverse(start, buffer);
return buffer - start;
}
static const double kDoublePrecisionCheckMax = DBL_MAX / 1.000000000000001;
size_t DoubleToBuffer(double value, char* buffer) {
// DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all
// platforms these days. Just in case some system exists where DBL_DIG
// is significantly larger -- and risks overflowing our buffer -- we have
// this assert.
static_assert(DBL_DIG < 20, "DBL_DIG is too big");
if (std::abs(value) <= kDoublePrecisionCheckMax) {
int snprintf_result =
snprintf(buffer, kFastToBufferSize, "%.*g", DBL_DIG, value);
// The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for.
DCHECK(snprintf_result > 0 && snprintf_result < kFastToBufferSize);
if (locale_independent_strtonum<double>(buffer, nullptr) == value) {
// Round-tripping the string to double works; we're done.
return snprintf_result;
}
// else: full precision formatting needed. Fall through.
}
int snprintf_result =
snprintf(buffer, kFastToBufferSize, "%.*g", DBL_DIG + 2, value);
// Should never overflow; see above.
DCHECK(snprintf_result > 0 && snprintf_result < kFastToBufferSize);
return snprintf_result;
}
namespace {
char SafeFirstChar(StringPiece str) {
if (str.empty()) return '\0';
return str[0];
}
void SkipSpaces(StringPiece* str) {
while (isspace(SafeFirstChar(*str))) str->remove_prefix(1);
}
} // namespace
bool safe_strto64(StringPiece str, int64* value) {
SkipSpaces(&str);
int64 vlimit = kint64max;
int sign = 1;
if (absl::ConsumePrefix(&str, "-")) {
sign = -1;
// Different limit for positive and negative integers.
vlimit = kint64min;
}
if (!isdigit(SafeFirstChar(str))) return false;
int64 result = 0;
if (sign == 1) {
do {
int digit = SafeFirstChar(str) - '0';
if ((vlimit - digit) / 10 < result) {
return false;
}
result = result * 10 + digit;
str.remove_prefix(1);
} while (isdigit(SafeFirstChar(str)));
} else {
do {
int digit = SafeFirstChar(str) - '0';
if ((vlimit + digit) / 10 > result) {
return false;
}
result = result * 10 - digit;
str.remove_prefix(1);
} while (isdigit(SafeFirstChar(str)));
}
SkipSpaces(&str);
if (!str.empty()) return false;
*value = result;
return true;
}
bool safe_strtou64(StringPiece str, uint64* value) {
SkipSpaces(&str);
if (!isdigit(SafeFirstChar(str))) return false;
uint64 result = 0;
do {
int digit = SafeFirstChar(str) - '0';
if ((kuint64max - digit) / 10 < result) {
return false;
}
result = result * 10 + digit;
str.remove_prefix(1);
} while (isdigit(SafeFirstChar(str)));
SkipSpaces(&str);
if (!str.empty()) return false;
*value = result;
return true;
}
bool safe_strto32(StringPiece str, int32* value) {
SkipSpaces(&str);
int64 vmax = kint32max;
int sign = 1;
if (absl::ConsumePrefix(&str, "-")) {
sign = -1;
// Different max for positive and negative integers.
++vmax;
}
if (!isdigit(SafeFirstChar(str))) return false;
int64 result = 0;
do {
result = result * 10 + SafeFirstChar(str) - '0';
if (result > vmax) {
return false;
}
str.remove_prefix(1);
} while (isdigit(SafeFirstChar(str)));
SkipSpaces(&str);
if (!str.empty()) return false;
*value = static_cast<int32>(result * sign);
return true;
}
bool safe_strtou32(StringPiece str, uint32* value) {
SkipSpaces(&str);
if (!isdigit(SafeFirstChar(str))) return false;
int64 result = 0;
do {
result = result * 10 + SafeFirstChar(str) - '0';
if (result > kuint32max) {
return false;
}
str.remove_prefix(1);
} while (isdigit(SafeFirstChar(str)));
SkipSpaces(&str);
if (!str.empty()) return false;
*value = static_cast<uint32>(result);
return true;
}
bool safe_strtof(StringPiece str, float* value) {
int processed_characters_count = -1;
auto len = str.size();
// If string length exceeds buffer size or int max, fail.
if (len >= kFastToBufferSize) return false;
if (len > std::numeric_limits<int>::max()) return false;
*value = StringToFloatConverter().StringToFloat(
str.data(), static_cast<int>(len), &processed_characters_count);
return processed_characters_count > 0;
}
bool safe_strtod(StringPiece str, double* value) {
int processed_characters_count = -1;
auto len = str.size();
// If string length exceeds buffer size or int max, fail.
if (len >= kFastToBufferSize) return false;
if (len > std::numeric_limits<int>::max()) return false;
*value = StringToFloatConverter().StringToDouble(
str.data(), static_cast<int>(len), &processed_characters_count);
return processed_characters_count > 0;
}
size_t FloatToBuffer(float value, char* buffer) {
// FLT_DIG is 6 for IEEE-754 floats, which are used on almost all
// platforms these days. Just in case some system exists where FLT_DIG
// is significantly larger -- and risks overflowing our buffer -- we have
// this assert.
static_assert(FLT_DIG < 10, "FLT_DIG is too big");
int snprintf_result =
snprintf(buffer, kFastToBufferSize, "%.*g", FLT_DIG, value);
// The snprintf should never overflow because the buffer is significantly
// larger than the precision we asked for.
DCHECK(snprintf_result > 0 && snprintf_result < kFastToBufferSize);
float parsed_value;
if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
snprintf_result =
snprintf(buffer, kFastToBufferSize, "%.*g", FLT_DIG + 3, value);
// Should never overflow; see above.
DCHECK(snprintf_result > 0 && snprintf_result < kFastToBufferSize);
}
return snprintf_result;
}
string FpToString(Fprint fp) {
char buf[17];
snprintf(buf, sizeof(buf), "%016llx", static_cast<uint64>(fp));
return string(buf);
}
bool StringToFp(const string& s, Fprint* fp) {
char junk;
uint64_t result;
if (sscanf(s.c_str(), "%" SCNx64 "%c", &result, &junk) == 1) {
*fp = result;
return true;
} else {
return false;
}
}
StringPiece Uint64ToHexString(uint64 v, char* buf) {
static const char* hexdigits = "0123456789abcdef";
const int num_byte = 16;
buf[num_byte] = '\0';
for (int i = num_byte - 1; i >= 0; i--) {
buf[i] = hexdigits[v & 0xf];
v >>= 4;
}
return StringPiece(buf, num_byte);
}
bool HexStringToUint64(const StringPiece& s, uint64* result) {
uint64 v = 0;
if (s.empty()) {
return false;
}
for (size_t i = 0; i < s.size(); i++) {
char c = s[i];
if (c >= '0' && c <= '9') {
v = (v << 4) + (c - '0');
} else if (c >= 'a' && c <= 'f') {
v = (v << 4) + 10 + (c - 'a');
} else if (c >= 'A' && c <= 'F') {
v = (v << 4) + 10 + (c - 'A');
} else {
return false;
}
}
*result = v;
return true;
}
string HumanReadableNum(int64 value) {
string s;
if (value < 0) {
s += "-";
value = -value;
}
if (value < 1000) {
Appendf(&s, "%lld", value);
} else if (value >= static_cast<int64>(1e15)) {
// Number bigger than 1E15; use that notation.
Appendf(&s, "%0.3G", static_cast<double>(value));
} else {
static const char units[] = "kMBT";
const char* unit = units;
while (value >= static_cast<int64>(1000000)) {
value /= static_cast<int64>(1000);
++unit;
CHECK(unit < units + TF_ARRAYSIZE(units));
}
Appendf(&s, "%.2f%c", value / 1000.0, *unit);
}
return s;
}
string HumanReadableNumBytes(int64 num_bytes) {
if (num_bytes == kint64min) {
// Special case for number with not representable negation.
return "-8E";
}
const char* neg_str = (num_bytes < 0) ? "-" : "";
if (num_bytes < 0) {
num_bytes = -num_bytes;
}
// Special case for bytes.
if (num_bytes < 1024) {
// No fractions for bytes.
char buf[8]; // Longest possible string is '-XXXXB'
snprintf(buf, sizeof(buf), "%s%lldB", neg_str,
static_cast<int64>(num_bytes));
return string(buf);
}
static const char units[] = "KMGTPE"; // int64 only goes up to E.
const char* unit = units;
while (num_bytes >= static_cast<int64>(1024) * 1024) {
num_bytes /= 1024;
++unit;
CHECK(unit < units + TF_ARRAYSIZE(units));
}
// We use SI prefixes.
char buf[16];
snprintf(buf, sizeof(buf), ((*unit == 'K') ? "%s%.1f%ciB" : "%s%.2f%ciB"),
neg_str, num_bytes / 1024.0, *unit);
return string(buf);
}
string HumanReadableElapsedTime(double seconds) {
string human_readable;
if (seconds < 0) {
human_readable = "-";
seconds = -seconds;
}
// Start with us and keep going up to years.
// The comparisons must account for rounding to prevent the format breaking
// the tested condition and returning, e.g., "1e+03 us" instead of "1 ms".
const double microseconds = seconds * 1.0e6;
if (microseconds < 999.5) {
strings::Appendf(&human_readable, "%0.3g us", microseconds);
return human_readable;
}
double milliseconds = seconds * 1e3;
if (milliseconds >= .995 && milliseconds < 1) {
// Round half to even in Appendf would convert this to 0.999 ms.
milliseconds = 1.0;
}
if (milliseconds < 999.5) {
strings::Appendf(&human_readable, "%0.3g ms", milliseconds);
return human_readable;
}
if (seconds < 60.0) {
strings::Appendf(&human_readable, "%0.3g s", seconds);
return human_readable;
}
seconds /= 60.0;
if (seconds < 60.0) {
strings::Appendf(&human_readable, "%0.3g min", seconds);
return human_readable;
}
seconds /= 60.0;
if (seconds < 24.0) {
strings::Appendf(&human_readable, "%0.3g h", seconds);
return human_readable;
}
seconds /= 24.0;
if (seconds < 30.0) {
strings::Appendf(&human_readable, "%0.3g days", seconds);
return human_readable;
}
if (seconds < 365.2425) {
strings::Appendf(&human_readable, "%0.3g months", seconds / 30.436875);
return human_readable;
}
seconds /= 365.2425;
strings::Appendf(&human_readable, "%0.3g years", seconds);
return human_readable;
}
} // namespace strings
} // namespace tensorflow
| adit-chandra/tensorflow | tensorflow/core/platform/numbers.cc | C++ | apache-2.0 | 15,715 |
'''
Copyright 2017 Dell Inc. or its subsidiaries. All Rights Reserved.
Author(s):
George Paulos
This script tests minimum payload base case of the RackHD API 2.0 OS bootstrap workflows using NFS mount or local repo method.
This routine runs OS bootstrap jobs simultaneously on multiple nodes.
For 12 tests to run, 12 nodes are required in the stack. If there are less than that, tests will be skipped.
This test takes 15-20 minutes to run.
OS bootstrap tests require the following entries in config/install_default.json.
If an entry is missing, then that test will be skipped.
The order of entries determines the priority of the test. First one runs on first available node, etc.
"os-install": [
{
"kvm": false,
"path": "/repo/esxi/5.5",
"version": "5.5",
"workflow": "Graph.InstallESXi"
},
{
"kvm": false,
"path": "/repo/esxi/6.0",
"version": "6.0",
"workflow": "Graph.InstallESXi"
},
{
"kvm": false,
"path": "/repo/centos/6.5",
"version": "6.5",
"workflow": "Graph.InstallCentOS"
},
{
"kvm": false,
"path": "/repo/centos/7.0",
"version": "7.0",
"workflow": "Graph.InstallCentOS"
},
{
"kvm": false,
"path": "/repo/rhel/7.0",
"version": "7.0",
"workflow": "Graph.InstallRHEL"
},
{
"kvm": false,
"path": "/repo/suse/42.1",
"version": "42.1",
"workflow": "Graph.InstallSUSE"
},
{
"kvm": false,
"path": "/repo/ubuntu",
"version": "trusty",
"workflow": "Graph.InstallUbuntu"
},
{
"kvm": false,
"path": "/repo/coreos",
"version": "899.17.0",
"workflow": "Graph.InstallCoreOS"
},
{
"kvm": true,
"path": "/repo/rhel/7.0",
"version": "7.0",
"workflow": "Graph.InstallRHEL"
},
{
"kvm": true,
"path": "/repo/centos/6.5",
"version": "6.5",
"workflow": "Graph.InstallCentOS"
},
{
"kvm": false,
"path": "/repo/winpe",
"productkey": "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
"smbPassword": "onrack",
"smbRepo": "\\windowsServer2012",
"smbUser": "onrack",
"version": "2012",
"workflow": "Graph.InstallWindowsServer"
}
],
The OS repos are to be installed under 'on-http/static/http' directory reflecting the paths above.
These can be files, links, or nfs mounts to remote repos in the following dirs:
on-http/static/http/windowsServer2012 -- requires Samba share on RackHD server
on-http/static/http/repo/centos/6.5
on-http/static/http/repo/centos/7.0
on-http/static/http/repo/rhel/7.0
on-http/static/http/repo/suse/42.1
on-http/static/http/repo/esxi/5.5
on-http/static/http/repo/esxi/6.0
on-http/static/http/repo/winpe
on-http/static/http/repo/coreos/899.17.0
'''
import fit_path # NOQA: unused import
from nose.plugins.attrib import attr
import fit_common
import flogging
import sys
log = flogging.get_loggers()
# This gets the list of nodes
NODECATALOG = fit_common.node_select()
# dict containing bootstrap workflow IDs and states
NODE_STATUS = {}
# global timer
START_TIME = fit_common.time.time()
# collect repo information from config files
OSLIST = fit_common.fitcfg()["install-config"]["os-install"]
# download RackHD config from host
rackhdresult = fit_common.rackhdapi('/api/2.0/config')
if rackhdresult['status'] != 200:
log.error(" Unable to contact host, exiting. ")
sys.exit(255)
rackhdconfig = rackhdresult['json']
statichost = "http://" + str(rackhdconfig['fileServerAddress']) + ":" + str(rackhdconfig['fileServerPort'])
# this routine polls a workflow task ID for completion
def wait_for_workflow_complete(taskid):
result = None
while fit_common.time.time() - START_TIME < 1800 or result is None: # limit test to 30 minutes
result = fit_common.rackhdapi("/api/2.0/workflows/" + taskid)
if result['status'] != 200:
log.error(" HTTP error: " + result['text'])
return False
if result['json']['status'] == 'running' or result['json']['status'] == 'pending':
log.info_5("{} workflow status: {}".format(result['json']['injectableName'], result['json']['status']))
fit_common.time.sleep(30)
elif result['json']['status'] == 'succeeded':
log.info_5("{} workflow status: {}".format(result['json']['injectableName'], result['json']['status']))
return True
else:
log.error(" Workflow failed: " + result['text'])
return False
log.error(" Workflow Timeout: " + result['text'])
return False
# helper routine to return the task ID associated with the running bootstrap workflow
def node_taskid(workflow, version, kvm):
for entry in NODE_STATUS:
if NODE_STATUS[entry]['workflow'] == workflow \
and str(version) in NODE_STATUS[entry]['version'] \
and NODE_STATUS[entry]['kvm'] == kvm:
return NODE_STATUS[entry]['id']
return ""
# Match up tests to node IDs to feed skip decorators
index = 0 # node index
for item in OSLIST:
if index < len(NODECATALOG):
NODE_STATUS[NODECATALOG[index]] = \
{"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], "id": "Pending"}
index += 1
# ------------------------ Tests -------------------------------------
@attr(all=False)
class api20_bootstrap_base(fit_common.unittest.TestCase):
@classmethod
def setUpClass(cls):
# run all OS install workflows first
nodeindex = 0
for item in OSLIST:
# if OS proxy entry exists in RackHD config, run bootstrap against selected node
if nodeindex < len(NODECATALOG):
# delete active workflows for specified node
fit_common.cancel_active_workflows(NODECATALOG[nodeindex])
# base payload common to all Linux
payload_data = {"options": {"defaults": {
"version": item['version'],
"kvm": item['kvm'],
"repo": statichost + item['path'],
"rootPassword": "1234567",
"hostname": "rackhdnode",
"users": [{"name": "rackhduser",
"password": "RackHDRocks!",
"uid": 1010}]}}}
# OS specific payload requirements
if item['workflow'] == "Graph.InstallUbuntu":
payload_data["options"]["defaults"]["baseUrl"] = "install/netboot/ubuntu-installer/amd64"
payload_data["options"]["defaults"]["kargs"] = {"live-installer/net-image": statichost +
item['path'] + "/ubuntu/install/filesystem.squashfs"}
if item['workflow'] == "Graph.InstallWindowsServer":
payload_data["options"]["defaults"]["productkey"] = item['productkey']
payload_data["options"]["defaults"]["smbUser"] = item['smbUser']
payload_data["options"]["defaults"]["smbPassword"] = item['smbPassword']
payload_data["options"]["defaults"]["smbRepo"] = "\\\\" + str(rackhdconfig['apiServerAddress']) + \
item['smbRepo']
payload_data["options"]["defaults"]["username"] = "rackhduser"
payload_data["options"]["defaults"]["password"] = "RackHDRocks!"
payload_data["options"]["defaults"].pop('rootPassword', None)
payload_data["options"]["defaults"].pop('users', None)
payload_data["options"]["defaults"].pop('kvm', None)
payload_data["options"]["defaults"].pop('version', None)
# run workflow
result = fit_common.rackhdapi('/api/2.0/nodes/' +
NODECATALOG[nodeindex] +
'/workflows?name=' + item['workflow'],
action='post', payload=payload_data)
if result['status'] == 201:
# this saves the task and node IDs
NODE_STATUS[NODECATALOG[nodeindex]] = \
{"workflow": item['workflow'],
"version": item['version'],
"kvm": item['kvm'],
"id": result['json']['instanceId']}
log.info_5(" TaskID: " + result['json']['instanceId'])
log.info_5(" Payload: " + fit_common.json.dumps(payload_data))
else:
# if no task ID is returned put 'failed' in ID field
NODE_STATUS[NODECATALOG[nodeindex]] = \
{"workflow": item['workflow'],
"version": item['version'],
"kvm": item['kvm'],
'id': "failed"}
log.error(" OS install " + item['workflow'] + " on node " + NODECATALOG[nodeindex] + " failed! ")
log.error(" Error text: " + result['text'])
log.error(" Payload: " + fit_common.json.dumps(payload_data))
# increment node index to run next bootstrap
nodeindex += 1
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallESXi", "5.", False) != '',
"Skipping ESXi5.5, repo not configured or node unavailable")
def test_api20_bootstrap_esxi5(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallESXi", "5.", False)), "ESXi5.5 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallESXi", "6.", False) != '',
"Skipping ESXi6.0, repo not configured or node unavailable")
def test_api20_bootstrap_esxi6(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallESXi", "6.", False)), "ESXi6.0 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallCentOS", "6.", False) != '',
"Skipping Centos 6.5, repo not configured or node unavailable")
def test_api20_bootstrap_centos6(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallCentOS", "6.", False)), "Centos 6.5 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallCentOS", "6.", True) != '',
"Skipping Centos 6.5 KVM, repo not configured or node unavailable")
def test_api20_bootstrap_centos6_kvm(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallCentOS", "6.", True)), "Centos 6.5 KVM failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallCentOS", "7.", False) != '',
"Skipping Centos 7.0, repo not configured or node unavailable")
def test_api20_bootstrap_centos7(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallCentOS", "7.", False)), "Centos 7.0 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallCentOS", "7.", True) != '',
"Skipping Centos 7.0 KVM, repo not configured or node unavailable")
def test_api20_bootstrap_centos7_kvm(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallCentOS", "7.", True)), "Centos 7.0 KVM failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallRHEL", "7.", False) != '',
"Skipping Redhat 7.0, repo not configured or node unavailable")
def test_api20_bootstrap_rhel7(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallRHEL", "7.", False)), "RHEL 7.0 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallRHEL", "7.", True) != '',
"Skipping Redhat 7.0 KVM, repo not configured or node unavailable")
def test_api20_bootstrap_rhel7_kvm(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallRHEL", "7.", True)), "RHEL 7.0 KVM failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallUbuntu", "trusty", False) != '',
"Skipping Ubuntu 14, repo not configured or node unavailable")
def test_api20_bootstrap_ubuntu14(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallUbuntu", "trusty", False)), "Ubuntu 14 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallCoreOS", "899.", False) != '',
"Skipping CoreOS 899.17.0, repo not configured or node unavailable")
def test_api20_bootstrap_coreos899(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallCoreOS", "899.", False)), "CoreOS 899.17 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallSUSE", "42.", False) != '',
"Skipping SuSe 42, repo not configured or node unavailable")
def test_api20_bootstrap_suse(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallSUSE", "42.", False)), "SuSe 42 failed.")
@fit_common.unittest.skipUnless(node_taskid("Graph.InstallWindowsServer", "2012", False) != '',
"Skipping Windows 2012, repo not configured or node unavailable")
def test_api20_bootstrap_windows(self):
self.assertTrue(wait_for_workflow_complete(node_taskid("Graph.InstallWindowsServer", "2012", False)), "Win2012 failed.")
if __name__ == '__main__':
fit_common.unittest.main()
| uppalk1/RackHD | test/tests/bootstrap/test_api20_os_bootstrap_parallel_local.py | Python | apache-2.0 | 14,582 |
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.drill.common.config;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.apache.drill.common.exceptions.DrillConfigurationException;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.common.scanner.ClassPathScanner;
import org.reflections.util.ClasspathHelper;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigRenderOptions;
public class DrillConfig extends NestedConfig {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillConfig.class);
private final ImmutableList<String> startupArguments;
public static final boolean ON_OSX = System.getProperty("os.name").contains("OS X");
@SuppressWarnings("restriction")
private static final long MAX_DIRECT_MEMORY = sun.misc.VM.maxDirectMemory();
@VisibleForTesting
public DrillConfig(Config config, boolean enableServerConfigs) {
super(config);
logger.debug("Setting up DrillConfig object.");
logger.trace("Given Config object is:\n{}",
config.root().render(ConfigRenderOptions.defaults()));
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
this.startupArguments = ImmutableList.copyOf(bean.getInputArguments());
logger.debug("DrillConfig object initialized.");
}
/**
* Get an instance of the provided interface using the configuration path provided. Construct the object based on the
* provided constructor arguments.
* @param path
* The configuration path to use.
* @param iface
* The Interface or Superclass of the instance you requested.
* @param constructorArgs
* Any arguments required for constructing the requested type.
* @return The new Object instance that implements the provided Interface
*/
@SuppressWarnings("unchecked")
public <T> T getInstance(String path, Class<T> iface, Object... constructorArgs) {
try{
String className = this.getString(path);
Class<?> clazz = Class.forName(className);
Preconditions.checkArgument(iface.isAssignableFrom(clazz));
Class<?>[] argClasses = new Class[constructorArgs.length];
for (int i = 0; i < constructorArgs.length; i++) {
argClasses[i] = constructorArgs[i].getClass();
}
Constructor<?> constructor = clazz.getConstructor(argClasses);
return (T) constructor.newInstance(constructorArgs);
}catch(Exception e){
throw UserException.unsupportedError(e)
.message("Failure while attempting to load instance of the class of type %s requested at path %s.",
iface.getName(), path).build(logger);
}
}
public List<String> getStartupArguments() {
return startupArguments;
}
/**
* Creates a DrillConfig object using the default config file name
* and with server-specific configuration options enabled.
* @return The new DrillConfig object.
*/
public static DrillConfig create() {
return create(null, true);
}
/**
* Creates a {@link DrillConfig configuration} using the default config file
* name and with server-specific configuration options disabled.
*
* @return {@link DrillConfig} instance
*/
public static DrillConfig forClient() {
return create(null, false);
}
/**
* DrillConfig loads up Drill configuration information. It does this utilizing a combination of classpath scanning
* and Configuration fallbacks provided by the TypeSafe configuration library. The order of precedence is as
* follows:
* <p>
* Configuration values are retrieved as follows:
* <ul>
* <li>Check a single copy of "drill-override.conf". If multiple copies are
* on the classpath, which copy is read is indeterminate.
* If a non-null value for overrideFileResourcePathname is provided, this
* is used instead of "{@code drill-override.conf}".</li>
* <li>Check a single copy of "drill-distrib.conf". If multiple copies are
* on the classpath, which copy is read is indeterminate. </li>
* <li>Check all copies of "{@code drill-module.conf}". Loading order is
* indeterminate.</li>
* <li>Check a single copy of "{@code drill-default.conf}". If multiple
* copies are on the classpath, which copy is read is indeterminate.</li>
* </ul>
*
* </p>
* @param overrideFileResourcePathname
* the classpath resource pathname of the file to use for
* configuration override purposes; {@code null} specifies to use the
* default pathname ({@link CommonConstants.CONFIG_OVERRIDE}) (does
* <strong>not</strong> specify to suppress trying to load an
* overrides file)
* @return A merged Config object.
*/
public static DrillConfig create(String overrideFileResourcePathname) {
return create(overrideFileResourcePathname, true);
}
/**
* <b><u>Do not use this method outside of test code.</u></b>
*/
@VisibleForTesting
public static DrillConfig create(Properties testConfigurations) {
return create(null, testConfigurations, true);
}
/**
* @param overrideFileResourcePathname
* see {@link #create(String)}'s {@code overrideFileResourcePathname}
*/
public static DrillConfig create(String overrideFileResourcePathname, boolean enableServerConfigs) {
return create(overrideFileResourcePathname, null, enableServerConfigs);
}
/**
* Creates a drill configuration using the provided config file.
* @param config custom configuration file
* @return {@link DrillConfig} instance
*/
public static DrillConfig create(Config config) {
return new DrillConfig(config.resolve(), true);
}
/**
* @param overrideFileResourcePathname
* see {@link #create(String)}'s {@code overrideFileResourcePathname}
* @param overriderProps
* optional property map for further overriding (after override file
* is assimilated
* @param enableServerConfigs
* whether to enable server-specific configuration options
* @return
*/
private static DrillConfig create(String overrideFileResourcePathname,
final Properties overriderProps,
final boolean enableServerConfigs) {
final StringBuilder logString = new StringBuilder();
final Stopwatch watch = Stopwatch.createStarted();
overrideFileResourcePathname =
overrideFileResourcePathname == null
? CommonConstants.CONFIG_OVERRIDE_RESOURCE_PATHNAME
: overrideFileResourcePathname;
// 1. Load defaults configuration file.
Config fallback = null;
final ClassLoader[] classLoaders = ClasspathHelper.classLoaders();
for (ClassLoader classLoader : classLoaders) {
final URL url =
classLoader.getResource(CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME);
if (null != url) {
logString.append("Base Configuration:\n\t- ").append(url).append("\n");
fallback =
ConfigFactory.load(classLoader,
CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME);
break;
}
}
// 2. Load per-module configuration files.
final Collection<URL> urls = ClassPathScanner.getConfigURLs();
logString.append("\nIntermediate Configuration and Plugin files, in order of precedence:\n");
for (URL url : urls) {
logString.append("\t- ").append(url).append("\n");
fallback = ConfigFactory.parseURL(url).withFallback(fallback);
}
logString.append("\n");
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// 3. Load distribution specific configuration file.
final URL distribConfigFileUrl = classLoader.getResource(CommonConstants.CONFIG_DISTRIBUTION_RESOURCE_PATHNAME);
if (null != distribConfigFileUrl ) {
logString.append("Distribution Specific Configuration File: ").append(distribConfigFileUrl).append("\n");
}
fallback =
ConfigFactory.load(CommonConstants.CONFIG_DISTRIBUTION_RESOURCE_PATHNAME).withFallback(fallback);
// 4. Load any specified overrides configuration file along with any
// overrides from JVM system properties (e.g., {-Dname=value").
// (Per ConfigFactory.load(...)'s mention of using Thread.getContextClassLoader():)
final URL overrideFileUrl = classLoader.getResource(overrideFileResourcePathname);
if (null != overrideFileUrl ) {
logString.append("Override File: ").append(overrideFileUrl).append("\n");
}
Config effectiveConfig =
ConfigFactory.load(overrideFileResourcePathname).withFallback(fallback);
// 4. Apply any overriding properties.
if (overriderProps != null) {
logString.append("Overridden Properties:\n");
for(Entry<Object, Object> entry : overriderProps.entrySet()){
logString.append("\t-").append(entry.getKey()).append(" = ").append(entry.getValue()).append("\n");
}
logString.append("\n");
effectiveConfig =
ConfigFactory.parseProperties(overriderProps).withFallback(effectiveConfig);
}
// 5. Create DrillConfig object from Config object.
logger.info("Configuration and plugin file(s) identified in {}ms.\n{}",
watch.elapsed(TimeUnit.MILLISECONDS),
logString);
return new DrillConfig(effectiveConfig.resolve(), enableServerConfigs);
}
public <T> Class<T> getClassAt(String location, Class<T> clazz) throws DrillConfigurationException {
final String className = getString(location);
if (className == null) {
throw new DrillConfigurationException(String.format(
"No class defined at location '%s'. Expected a definition of the class []",
location, clazz.getCanonicalName()));
}
try {
final Class<?> c = Class.forName(className);
if (clazz.isAssignableFrom(c)) {
@SuppressWarnings("unchecked")
final Class<T> t = (Class<T>) c;
return t;
}
throw new DrillConfigurationException(String.format("The class [%s] listed at location '%s' should be of type [%s]. It isn't.", className, location, clazz.getCanonicalName()));
} catch (Exception ex) {
if (ex instanceof DrillConfigurationException) {
throw (DrillConfigurationException) ex;
}
throw new DrillConfigurationException(String.format("Failure while initializing class [%s] described at configuration value '%s'.", className, location), ex);
}
}
public <T> T getInstanceOf(String location, Class<T> clazz) throws DrillConfigurationException{
final Class<T> c = getClassAt(location, clazz);
try {
final T t = c.newInstance();
return t;
} catch (Exception ex) {
throw new DrillConfigurationException(String.format("Failure while instantiating class [%s] located at '%s.", clazz.getCanonicalName(), location), ex);
}
}
@Override
public String toString() {
return this.root().render();
}
public static long getMaxDirectMemory() {
return MAX_DIRECT_MEMORY;
}
}
| bitblender/drill | common/src/main/java/org/apache/drill/common/config/DrillConfig.java | Java | apache-2.0 | 12,320 |
// Package gotree create and print tree.
package gotree
import (
"strings"
)
const (
newLine = "\n"
emptySpace = " "
middleItem = "├── "
continueItem = "│ "
lastItem = "└── "
)
type (
tree struct {
text string
items []Tree
}
// Tree is tree interface
Tree interface {
Add(text string) Tree
AddTree(tree Tree)
Items() []Tree
Text() string
Print() string
}
printer struct {
}
// Printer is printer interface
Printer interface {
Print(Tree) string
}
)
//New returns a new GoTree.Tree
func New(text string) Tree {
return &tree{
text: text,
items: []Tree{},
}
}
//Add adds a node to the tree
func (t *tree) Add(text string) Tree {
n := New(text)
t.items = append(t.items, n)
return n
}
//AddTree adds a tree as an item
func (t *tree) AddTree(tree Tree) {
t.items = append(t.items, tree)
}
//Text returns the node's value
func (t *tree) Text() string {
return t.text
}
//Items returns all items in the tree
func (t *tree) Items() []Tree {
return t.items
}
//Print returns an visual representation of the tree
func (t *tree) Print() string {
return newPrinter().Print(t)
}
func newPrinter() Printer {
return &printer{}
}
//Print prints a tree to a string
func (p *printer) Print(t Tree) string {
return t.Text() + newLine + p.printItems(t.Items(), []bool{})
}
func (p *printer) printText(text string, spaces []bool, last bool) string {
var result string
for _, space := range spaces {
if space {
result += emptySpace
} else {
result += continueItem
}
}
indicator := middleItem
if last {
indicator = lastItem
}
var out string
lines := strings.Split(text, "\n")
for i := range lines {
text := lines[i]
if i == 0 {
out += result + indicator + text + newLine
continue
}
if last {
indicator = emptySpace
} else {
indicator = continueItem
}
out += result + indicator + text + newLine
}
return out
}
func (p *printer) printItems(t []Tree, spaces []bool) string {
var result string
for i, f := range t {
last := i == len(t)-1
result += p.printText(f.Text(), spaces, last)
if len(f.Items()) > 0 {
spacesChild := append(spaces, last)
result += p.printItems(f.Items(), spacesChild)
}
}
return result
}
| TomSweeneyRedHat/buildah | vendor/github.com/disiqueira/gotree/v3/gotree.go | GO | apache-2.0 | 2,253 |
/*
* Copyright 2015 NEC Corporation.
*
* 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.o3project.odenos.core.component.network.flow.query;
import org.o3project.odenos.core.component.network.BasicQuery;
import org.o3project.odenos.core.component.network.flow.basic.FlowAction;
import org.o3project.odenos.core.component.network.flow.ofpflow.OFPFlowActionSetIpTtl;
import java.util.Map;
/**
* Prepares a query for OFPFlowActionSetIpTtl class.
*/
public class OFPFlowActionSetIpTtlQuery extends FlowActionQuery {
private Integer ipTtl;
/**
* Constructor.
* @param params action conditions.
*/
public OFPFlowActionSetIpTtlQuery(Map<String, String> params) {
super(params);
}
@Override
public boolean parse() {
if (!super.parse()) {
return false;
}
if (!BasicQuery.checkMapExactly(this.actions,
new String[] { "ip_ttl" })) {
return false;
}
try {
this.ipTtl = Integer.parseInt(this.actions.get("ip_ttl"));
} catch (NumberFormatException ex) {
return false;
}
return true;
}
@Override
public boolean matchExactly(FlowAction action) {
if (action == null || !action.getType().equals(
OFPFlowActionSetIpTtl.class.getSimpleName())) {
return false;
}
OFPFlowActionSetIpTtl target = (OFPFlowActionSetIpTtl) action;
if (this.ipTtl == null) {
return true;
}
if (target.getIpTtl() == null) {
return false;
}
return this.ipTtl.equals(target.getIpTtl());
}
}
| nis-sdn/odenos | src/main/java/org/o3project/odenos/core/component/network/flow/query/OFPFlowActionSetIpTtlQuery.java | Java | apache-2.0 | 2,031 |
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection.ex;
import com.intellij.codeInsight.AnnotationTargetUtil;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiClass;
import org.jdom.Element;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@State(name = "EntryPointsManager")
public class EntryPointsManagerImpl extends EntryPointsManagerBase implements PersistentStateComponent<Element> {
public EntryPointsManagerImpl(Project project) {
super(project);
}
@Override
public void configureAnnotations() {
final List<String> list = new ArrayList<>(ADDITIONAL_ANNOTATIONS);
final List<String> writeList = new ArrayList<>(myWriteAnnotations);
final JPanel listPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(list, "Mark as entry point if annotated by", true);
Condition<PsiClass> applicableToField = psiClass -> {
Set<PsiAnnotation.TargetType> annotationTargets = AnnotationTargetUtil.getAnnotationTargets(psiClass);
return annotationTargets != null && annotationTargets.contains(PsiAnnotation.TargetType.FIELD);
};
final JPanel writtenAnnotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(writeList, "Mark field as implicitly written if annotated by", false, applicableToField);
new DialogWrapper(myProject) {
{
init();
setTitle("Configure Annotations");
}
@Override
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new VerticalFlowLayout());
panel.add(listPanel);
panel.add(writtenAnnotationsPanel);
return panel;
}
@Override
protected void doOKAction() {
ADDITIONAL_ANNOTATIONS.clear();
ADDITIONAL_ANNOTATIONS.addAll(list);
myWriteAnnotations.clear();
myWriteAnnotations.addAll(writeList);
DaemonCodeAnalyzer.getInstance(myProject).restart();
super.doOKAction();
}
}.show();
}
public static JButton createConfigureAnnotationsButton() {
final JButton configureAnnotations = new JButton("Annotations...");
configureAnnotations.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations();
}
});
return configureAnnotations;
}
public static JButton createConfigureClassPatternsButton() {
final JButton configureClassPatterns = new JButton("Code patterns...");
configureClassPatterns.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Project project = ProjectUtil.guessCurrentProject(configureClassPatterns);
final EntryPointsManagerBase entryPointsManagerBase = getInstance(project);
final ArrayList<ClassPattern> list = new ArrayList<>();
for (ClassPattern pattern : entryPointsManagerBase.getPatterns()) {
list.add(new ClassPattern(pattern));
}
final ClassPatternsPanel panel = new ClassPatternsPanel(list);
new DialogWrapper(entryPointsManagerBase.myProject) {
{
init();
setTitle("Configure Code Patterns");
}
@Override
protected JComponent createCenterPanel() {
return panel;
}
@Override
protected void doOKAction() {
final String error = panel.getValidationError(project);
if (error != null) {
Messages.showErrorDialog(panel, error);
return;
}
final LinkedHashSet<ClassPattern> patterns = entryPointsManagerBase.getPatterns();
patterns.clear();
patterns.addAll(list);
DaemonCodeAnalyzer.getInstance(entryPointsManagerBase.myProject).restart();
super.doOKAction();
}
}.show();
}
});
return configureClassPatterns;
}
} | goodwinnk/intellij-community | java/java-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerImpl.java | Java | apache-2.0 | 4,780 |
/*
* Copyright 2013 The Netty Project
*
* The Netty Project 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 io.netty.handler.codec.http;
import org.junit.Assert;
import org.junit.Test;
import java.util.List;
public class HttpHeadersTest {
@Test
public void testRemoveTransferEncodingIgnoreCase() {
HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
message.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, "Chunked");
HttpHeaders.removeTransferEncodingChunked(message);
Assert.assertTrue(message.headers().isEmpty());
}
// Test for https://github.com/netty/netty/issues/1690
@Test
public void testGetOperations() {
HttpHeaders headers = new DefaultHttpHeaders();
headers.add("Foo", "1");
headers.add("Foo", "2");
Assert.assertEquals("1", headers.get("Foo"));
List<String> values = headers.getAll("Foo");
Assert.assertEquals(2, values.size());
Assert.assertEquals("1", values.get(0));
Assert.assertEquals("2", values.get(1));
}
}
| rocketballs/netty | codec-http/src/test/java/io/netty/handler/codec/http/HttpHeadersTest.java | Java | apache-2.0 | 1,638 |
// Copyright (c) 2011-2015, HL7, Inc & The MITRE 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 HL7 nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
package models
import (
"encoding/json"
"errors"
"fmt"
)
type Encounter struct {
DomainResource `bson:",inline"`
Identifier []Identifier `bson:"identifier,omitempty" json:"identifier,omitempty"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
StatusHistory []EncounterStatusHistoryComponent `bson:"statusHistory,omitempty" json:"statusHistory,omitempty"`
Class string `bson:"class,omitempty" json:"class,omitempty"`
Type []CodeableConcept `bson:"type,omitempty" json:"type,omitempty"`
Priority *CodeableConcept `bson:"priority,omitempty" json:"priority,omitempty"`
Patient *Reference `bson:"patient,omitempty" json:"patient,omitempty"`
EpisodeOfCare []Reference `bson:"episodeOfCare,omitempty" json:"episodeOfCare,omitempty"`
IncomingReferral []Reference `bson:"incomingReferral,omitempty" json:"incomingReferral,omitempty"`
Participant []EncounterParticipantComponent `bson:"participant,omitempty" json:"participant,omitempty"`
Appointment *Reference `bson:"appointment,omitempty" json:"appointment,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
Length *Quantity `bson:"length,omitempty" json:"length,omitempty"`
Reason []CodeableConcept `bson:"reason,omitempty" json:"reason,omitempty"`
Indication []Reference `bson:"indication,omitempty" json:"indication,omitempty"`
Hospitalization *EncounterHospitalizationComponent `bson:"hospitalization,omitempty" json:"hospitalization,omitempty"`
Location []EncounterLocationComponent `bson:"location,omitempty" json:"location,omitempty"`
ServiceProvider *Reference `bson:"serviceProvider,omitempty" json:"serviceProvider,omitempty"`
PartOf *Reference `bson:"partOf,omitempty" json:"partOf,omitempty"`
}
// Custom marshaller to add the resourceType property, as required by the specification
func (resource *Encounter) MarshalJSON() ([]byte, error) {
resource.ResourceType = "Encounter"
// Dereferencing the pointer to avoid infinite recursion.
// Passing in plain old x (a pointer to Encounter), would cause this same
// MarshallJSON function to be called again
return json.Marshal(*resource)
}
func (x *Encounter) GetBSON() (interface{}, error) {
x.ResourceType = "Encounter"
// See comment in MarshallJSON to see why we dereference
return *x, nil
}
// The "encounter" sub-type is needed to avoid infinite recursion in UnmarshalJSON
type encounter Encounter
// Custom unmarshaller to properly unmarshal embedded resources (represented as interface{})
func (x *Encounter) UnmarshalJSON(data []byte) (err error) {
x2 := encounter{}
if err = json.Unmarshal(data, &x2); err == nil {
if x2.Contained != nil {
for i := range x2.Contained {
x2.Contained[i] = MapToResource(x2.Contained[i], true)
}
}
*x = Encounter(x2)
return x.checkResourceType()
}
return
}
func (x *Encounter) checkResourceType() error {
if x.ResourceType == "" {
x.ResourceType = "Encounter"
} else if x.ResourceType != "Encounter" {
return errors.New(fmt.Sprintf("Expected resourceType to be Encounter, instead received %s", x.ResourceType))
}
return nil
}
type EncounterStatusHistoryComponent struct {
BackboneElement `bson:",inline"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
}
type EncounterParticipantComponent struct {
BackboneElement `bson:",inline"`
Type []CodeableConcept `bson:"type,omitempty" json:"type,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
Individual *Reference `bson:"individual,omitempty" json:"individual,omitempty"`
}
type EncounterHospitalizationComponent struct {
BackboneElement `bson:",inline"`
PreAdmissionIdentifier *Identifier `bson:"preAdmissionIdentifier,omitempty" json:"preAdmissionIdentifier,omitempty"`
Origin *Reference `bson:"origin,omitempty" json:"origin,omitempty"`
AdmitSource *CodeableConcept `bson:"admitSource,omitempty" json:"admitSource,omitempty"`
AdmittingDiagnosis []Reference `bson:"admittingDiagnosis,omitempty" json:"admittingDiagnosis,omitempty"`
ReAdmission *CodeableConcept `bson:"reAdmission,omitempty" json:"reAdmission,omitempty"`
DietPreference []CodeableConcept `bson:"dietPreference,omitempty" json:"dietPreference,omitempty"`
SpecialCourtesy []CodeableConcept `bson:"specialCourtesy,omitempty" json:"specialCourtesy,omitempty"`
SpecialArrangement []CodeableConcept `bson:"specialArrangement,omitempty" json:"specialArrangement,omitempty"`
Destination *Reference `bson:"destination,omitempty" json:"destination,omitempty"`
DischargeDisposition *CodeableConcept `bson:"dischargeDisposition,omitempty" json:"dischargeDisposition,omitempty"`
DischargeDiagnosis []Reference `bson:"dischargeDiagnosis,omitempty" json:"dischargeDiagnosis,omitempty"`
}
type EncounterLocationComponent struct {
BackboneElement `bson:",inline"`
Location *Reference `bson:"location,omitempty" json:"location,omitempty"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
Period *Period `bson:"period,omitempty" json:"period,omitempty"`
}
type EncounterPlus struct {
Encounter `bson:",inline"`
EncounterPlusRelatedResources `bson:",inline"`
}
type EncounterPlusRelatedResources struct {
IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare *[]EpisodeOfCare `bson:"_includedEpisodeOfCareResourcesReferencedByEpisodeofcare,omitempty"`
IncludedReferralRequestResourcesReferencedByIncomingreferral *[]ReferralRequest `bson:"_includedReferralRequestResourcesReferencedByIncomingreferral,omitempty"`
IncludedPractitionerResourcesReferencedByPractitioner *[]Practitioner `bson:"_includedPractitionerResourcesReferencedByPractitioner,omitempty"`
IncludedAppointmentResourcesReferencedByAppointment *[]Appointment `bson:"_includedAppointmentResourcesReferencedByAppointment,omitempty"`
IncludedEncounterResourcesReferencedByPartof *[]Encounter `bson:"_includedEncounterResourcesReferencedByPartof,omitempty"`
IncludedProcedureResourcesReferencedByProcedure *[]Procedure `bson:"_includedProcedureResourcesReferencedByProcedure,omitempty"`
IncludedPractitionerResourcesReferencedByParticipant *[]Practitioner `bson:"_includedPractitionerResourcesReferencedByParticipant,omitempty"`
IncludedRelatedPersonResourcesReferencedByParticipant *[]RelatedPerson `bson:"_includedRelatedPersonResourcesReferencedByParticipant,omitempty"`
IncludedConditionResourcesReferencedByCondition *[]Condition `bson:"_includedConditionResourcesReferencedByCondition,omitempty"`
IncludedPatientResourcesReferencedByPatient *[]Patient `bson:"_includedPatientResourcesReferencedByPatient,omitempty"`
IncludedLocationResourcesReferencedByLocation *[]Location `bson:"_includedLocationResourcesReferencedByLocation,omitempty"`
IncludedConditionResourcesReferencedByIndication *[]Condition `bson:"_includedConditionResourcesReferencedByIndication,omitempty"`
IncludedProcedureResourcesReferencedByIndication *[]Procedure `bson:"_includedProcedureResourcesReferencedByIndication,omitempty"`
RevIncludedProvenanceResourcesReferencingTarget *[]Provenance `bson:"_revIncludedProvenanceResourcesReferencingTarget,omitempty"`
RevIncludedDocumentManifestResourcesReferencingContentref *[]DocumentManifest `bson:"_revIncludedDocumentManifestResourcesReferencingContentref,omitempty"`
RevIncludedDocumentManifestResourcesReferencingRelatedref *[]DocumentManifest `bson:"_revIncludedDocumentManifestResourcesReferencingRelatedref,omitempty"`
RevIncludedProcedureResourcesReferencingEncounter *[]Procedure `bson:"_revIncludedProcedureResourcesReferencingEncounter,omitempty"`
RevIncludedListResourcesReferencingItem *[]List `bson:"_revIncludedListResourcesReferencingItem,omitempty"`
RevIncludedListResourcesReferencingEncounter *[]List `bson:"_revIncludedListResourcesReferencingEncounter,omitempty"`
RevIncludedDocumentReferenceResourcesReferencingEncounter *[]DocumentReference `bson:"_revIncludedDocumentReferenceResourcesReferencingEncounter,omitempty"`
RevIncludedDocumentReferenceResourcesReferencingRelatedref *[]DocumentReference `bson:"_revIncludedDocumentReferenceResourcesReferencingRelatedref,omitempty"`
RevIncludedOrderResourcesReferencingDetail *[]Order `bson:"_revIncludedOrderResourcesReferencingDetail,omitempty"`
RevIncludedVisionPrescriptionResourcesReferencingEncounter *[]VisionPrescription `bson:"_revIncludedVisionPrescriptionResourcesReferencingEncounter,omitempty"`
RevIncludedProcedureRequestResourcesReferencingEncounter *[]ProcedureRequest `bson:"_revIncludedProcedureRequestResourcesReferencingEncounter,omitempty"`
RevIncludedFlagResourcesReferencingEncounter *[]Flag `bson:"_revIncludedFlagResourcesReferencingEncounter,omitempty"`
RevIncludedObservationResourcesReferencingEncounter *[]Observation `bson:"_revIncludedObservationResourcesReferencingEncounter,omitempty"`
RevIncludedMedicationAdministrationResourcesReferencingEncounter *[]MedicationAdministration `bson:"_revIncludedMedicationAdministrationResourcesReferencingEncounter,omitempty"`
RevIncludedCommunicationRequestResourcesReferencingEncounter *[]CommunicationRequest `bson:"_revIncludedCommunicationRequestResourcesReferencingEncounter,omitempty"`
RevIncludedRiskAssessmentResourcesReferencingEncounter *[]RiskAssessment `bson:"_revIncludedRiskAssessmentResourcesReferencingEncounter,omitempty"`
RevIncludedBasicResourcesReferencingSubject *[]Basic `bson:"_revIncludedBasicResourcesReferencingSubject,omitempty"`
RevIncludedDiagnosticReportResourcesReferencingEncounter *[]DiagnosticReport `bson:"_revIncludedDiagnosticReportResourcesReferencingEncounter,omitempty"`
RevIncludedNutritionOrderResourcesReferencingEncounter *[]NutritionOrder `bson:"_revIncludedNutritionOrderResourcesReferencingEncounter,omitempty"`
RevIncludedEncounterResourcesReferencingPartof *[]Encounter `bson:"_revIncludedEncounterResourcesReferencingPartof,omitempty"`
RevIncludedAuditEventResourcesReferencingReference *[]AuditEvent `bson:"_revIncludedAuditEventResourcesReferencingReference,omitempty"`
RevIncludedMedicationOrderResourcesReferencingEncounter *[]MedicationOrder `bson:"_revIncludedMedicationOrderResourcesReferencingEncounter,omitempty"`
RevIncludedCommunicationResourcesReferencingEncounter *[]Communication `bson:"_revIncludedCommunicationResourcesReferencingEncounter,omitempty"`
RevIncludedConditionResourcesReferencingEncounter *[]Condition `bson:"_revIncludedConditionResourcesReferencingEncounter,omitempty"`
RevIncludedCompositionResourcesReferencingSubject *[]Composition `bson:"_revIncludedCompositionResourcesReferencingSubject,omitempty"`
RevIncludedCompositionResourcesReferencingEncounter *[]Composition `bson:"_revIncludedCompositionResourcesReferencingEncounter,omitempty"`
RevIncludedCompositionResourcesReferencingEntry *[]Composition `bson:"_revIncludedCompositionResourcesReferencingEntry,omitempty"`
RevIncludedDetectedIssueResourcesReferencingImplicated *[]DetectedIssue `bson:"_revIncludedDetectedIssueResourcesReferencingImplicated,omitempty"`
RevIncludedDiagnosticOrderResourcesReferencingEncounter *[]DiagnosticOrder `bson:"_revIncludedDiagnosticOrderResourcesReferencingEncounter,omitempty"`
RevIncludedOrderResponseResourcesReferencingFulfillment *[]OrderResponse `bson:"_revIncludedOrderResponseResourcesReferencingFulfillment,omitempty"`
RevIncludedQuestionnaireResponseResourcesReferencingSubject *[]QuestionnaireResponse `bson:"_revIncludedQuestionnaireResponseResourcesReferencingSubject,omitempty"`
RevIncludedQuestionnaireResponseResourcesReferencingEncounter *[]QuestionnaireResponse `bson:"_revIncludedQuestionnaireResponseResourcesReferencingEncounter,omitempty"`
RevIncludedProcessResponseResourcesReferencingRequest *[]ProcessResponse `bson:"_revIncludedProcessResponseResourcesReferencingRequest,omitempty"`
RevIncludedClinicalImpressionResourcesReferencingTrigger *[]ClinicalImpression `bson:"_revIncludedClinicalImpressionResourcesReferencingTrigger,omitempty"`
RevIncludedMessageHeaderResourcesReferencingData *[]MessageHeader `bson:"_revIncludedMessageHeaderResourcesReferencingData,omitempty"`
}
func (e *EncounterPlusRelatedResources) GetIncludedEpisodeOfCareResourcesReferencedByEpisodeofcare() (episodeOfCares []EpisodeOfCare, err error) {
if e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare == nil {
err = errors.New("Included episodeOfCares not requested")
} else {
episodeOfCares = *e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedReferralRequestResourcesReferencedByIncomingreferral() (referralRequests []ReferralRequest, err error) {
if e.IncludedReferralRequestResourcesReferencedByIncomingreferral == nil {
err = errors.New("Included referralRequests not requested")
} else {
referralRequests = *e.IncludedReferralRequestResourcesReferencedByIncomingreferral
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedPractitionerResourceReferencedByPractitioner() (practitioner *Practitioner, err error) {
if e.IncludedPractitionerResourcesReferencedByPractitioner == nil {
err = errors.New("Included practitioners not requested")
} else if len(*e.IncludedPractitionerResourcesReferencedByPractitioner) > 1 {
err = fmt.Errorf("Expected 0 or 1 practitioner, but found %d", len(*e.IncludedPractitionerResourcesReferencedByPractitioner))
} else if len(*e.IncludedPractitionerResourcesReferencedByPractitioner) == 1 {
practitioner = &(*e.IncludedPractitionerResourcesReferencedByPractitioner)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedAppointmentResourceReferencedByAppointment() (appointment *Appointment, err error) {
if e.IncludedAppointmentResourcesReferencedByAppointment == nil {
err = errors.New("Included appointments not requested")
} else if len(*e.IncludedAppointmentResourcesReferencedByAppointment) > 1 {
err = fmt.Errorf("Expected 0 or 1 appointment, but found %d", len(*e.IncludedAppointmentResourcesReferencedByAppointment))
} else if len(*e.IncludedAppointmentResourcesReferencedByAppointment) == 1 {
appointment = &(*e.IncludedAppointmentResourcesReferencedByAppointment)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedEncounterResourceReferencedByPartof() (encounter *Encounter, err error) {
if e.IncludedEncounterResourcesReferencedByPartof == nil {
err = errors.New("Included encounters not requested")
} else if len(*e.IncludedEncounterResourcesReferencedByPartof) > 1 {
err = fmt.Errorf("Expected 0 or 1 encounter, but found %d", len(*e.IncludedEncounterResourcesReferencedByPartof))
} else if len(*e.IncludedEncounterResourcesReferencedByPartof) == 1 {
encounter = &(*e.IncludedEncounterResourcesReferencedByPartof)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedProcedureResourcesReferencedByProcedure() (procedures []Procedure, err error) {
if e.IncludedProcedureResourcesReferencedByProcedure == nil {
err = errors.New("Included procedures not requested")
} else {
procedures = *e.IncludedProcedureResourcesReferencedByProcedure
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedPractitionerResourceReferencedByParticipant() (practitioner *Practitioner, err error) {
if e.IncludedPractitionerResourcesReferencedByParticipant == nil {
err = errors.New("Included practitioners not requested")
} else if len(*e.IncludedPractitionerResourcesReferencedByParticipant) > 1 {
err = fmt.Errorf("Expected 0 or 1 practitioner, but found %d", len(*e.IncludedPractitionerResourcesReferencedByParticipant))
} else if len(*e.IncludedPractitionerResourcesReferencedByParticipant) == 1 {
practitioner = &(*e.IncludedPractitionerResourcesReferencedByParticipant)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedRelatedPersonResourceReferencedByParticipant() (relatedPerson *RelatedPerson, err error) {
if e.IncludedRelatedPersonResourcesReferencedByParticipant == nil {
err = errors.New("Included relatedpeople not requested")
} else if len(*e.IncludedRelatedPersonResourcesReferencedByParticipant) > 1 {
err = fmt.Errorf("Expected 0 or 1 relatedPerson, but found %d", len(*e.IncludedRelatedPersonResourcesReferencedByParticipant))
} else if len(*e.IncludedRelatedPersonResourcesReferencedByParticipant) == 1 {
relatedPerson = &(*e.IncludedRelatedPersonResourcesReferencedByParticipant)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedConditionResourcesReferencedByCondition() (conditions []Condition, err error) {
if e.IncludedConditionResourcesReferencedByCondition == nil {
err = errors.New("Included conditions not requested")
} else {
conditions = *e.IncludedConditionResourcesReferencedByCondition
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedPatientResourceReferencedByPatient() (patient *Patient, err error) {
if e.IncludedPatientResourcesReferencedByPatient == nil {
err = errors.New("Included patients not requested")
} else if len(*e.IncludedPatientResourcesReferencedByPatient) > 1 {
err = fmt.Errorf("Expected 0 or 1 patient, but found %d", len(*e.IncludedPatientResourcesReferencedByPatient))
} else if len(*e.IncludedPatientResourcesReferencedByPatient) == 1 {
patient = &(*e.IncludedPatientResourcesReferencedByPatient)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedLocationResourceReferencedByLocation() (location *Location, err error) {
if e.IncludedLocationResourcesReferencedByLocation == nil {
err = errors.New("Included locations not requested")
} else if len(*e.IncludedLocationResourcesReferencedByLocation) > 1 {
err = fmt.Errorf("Expected 0 or 1 location, but found %d", len(*e.IncludedLocationResourcesReferencedByLocation))
} else if len(*e.IncludedLocationResourcesReferencedByLocation) == 1 {
location = &(*e.IncludedLocationResourcesReferencedByLocation)[0]
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedConditionResourcesReferencedByIndication() (conditions []Condition, err error) {
if e.IncludedConditionResourcesReferencedByIndication == nil {
err = errors.New("Included conditions not requested")
} else {
conditions = *e.IncludedConditionResourcesReferencedByIndication
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedProcedureResourcesReferencedByIndication() (procedures []Procedure, err error) {
if e.IncludedProcedureResourcesReferencedByIndication == nil {
err = errors.New("Included procedures not requested")
} else {
procedures = *e.IncludedProcedureResourcesReferencedByIndication
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedProvenanceResourcesReferencingTarget() (provenances []Provenance, err error) {
if e.RevIncludedProvenanceResourcesReferencingTarget == nil {
err = errors.New("RevIncluded provenances not requested")
} else {
provenances = *e.RevIncludedProvenanceResourcesReferencingTarget
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDocumentManifestResourcesReferencingContentref() (documentManifests []DocumentManifest, err error) {
if e.RevIncludedDocumentManifestResourcesReferencingContentref == nil {
err = errors.New("RevIncluded documentManifests not requested")
} else {
documentManifests = *e.RevIncludedDocumentManifestResourcesReferencingContentref
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDocumentManifestResourcesReferencingRelatedref() (documentManifests []DocumentManifest, err error) {
if e.RevIncludedDocumentManifestResourcesReferencingRelatedref == nil {
err = errors.New("RevIncluded documentManifests not requested")
} else {
documentManifests = *e.RevIncludedDocumentManifestResourcesReferencingRelatedref
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedProcedureResourcesReferencingEncounter() (procedures []Procedure, err error) {
if e.RevIncludedProcedureResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded procedures not requested")
} else {
procedures = *e.RevIncludedProcedureResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedListResourcesReferencingItem() (lists []List, err error) {
if e.RevIncludedListResourcesReferencingItem == nil {
err = errors.New("RevIncluded lists not requested")
} else {
lists = *e.RevIncludedListResourcesReferencingItem
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedListResourcesReferencingEncounter() (lists []List, err error) {
if e.RevIncludedListResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded lists not requested")
} else {
lists = *e.RevIncludedListResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDocumentReferenceResourcesReferencingEncounter() (documentReferences []DocumentReference, err error) {
if e.RevIncludedDocumentReferenceResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded documentReferences not requested")
} else {
documentReferences = *e.RevIncludedDocumentReferenceResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDocumentReferenceResourcesReferencingRelatedref() (documentReferences []DocumentReference, err error) {
if e.RevIncludedDocumentReferenceResourcesReferencingRelatedref == nil {
err = errors.New("RevIncluded documentReferences not requested")
} else {
documentReferences = *e.RevIncludedDocumentReferenceResourcesReferencingRelatedref
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedOrderResourcesReferencingDetail() (orders []Order, err error) {
if e.RevIncludedOrderResourcesReferencingDetail == nil {
err = errors.New("RevIncluded orders not requested")
} else {
orders = *e.RevIncludedOrderResourcesReferencingDetail
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedVisionPrescriptionResourcesReferencingEncounter() (visionPrescriptions []VisionPrescription, err error) {
if e.RevIncludedVisionPrescriptionResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded visionPrescriptions not requested")
} else {
visionPrescriptions = *e.RevIncludedVisionPrescriptionResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedProcedureRequestResourcesReferencingEncounter() (procedureRequests []ProcedureRequest, err error) {
if e.RevIncludedProcedureRequestResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded procedureRequests not requested")
} else {
procedureRequests = *e.RevIncludedProcedureRequestResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedFlagResourcesReferencingEncounter() (flags []Flag, err error) {
if e.RevIncludedFlagResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded flags not requested")
} else {
flags = *e.RevIncludedFlagResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedObservationResourcesReferencingEncounter() (observations []Observation, err error) {
if e.RevIncludedObservationResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded observations not requested")
} else {
observations = *e.RevIncludedObservationResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedMedicationAdministrationResourcesReferencingEncounter() (medicationAdministrations []MedicationAdministration, err error) {
if e.RevIncludedMedicationAdministrationResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded medicationAdministrations not requested")
} else {
medicationAdministrations = *e.RevIncludedMedicationAdministrationResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedCommunicationRequestResourcesReferencingEncounter() (communicationRequests []CommunicationRequest, err error) {
if e.RevIncludedCommunicationRequestResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded communicationRequests not requested")
} else {
communicationRequests = *e.RevIncludedCommunicationRequestResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedRiskAssessmentResourcesReferencingEncounter() (riskAssessments []RiskAssessment, err error) {
if e.RevIncludedRiskAssessmentResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded riskAssessments not requested")
} else {
riskAssessments = *e.RevIncludedRiskAssessmentResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedBasicResourcesReferencingSubject() (basics []Basic, err error) {
if e.RevIncludedBasicResourcesReferencingSubject == nil {
err = errors.New("RevIncluded basics not requested")
} else {
basics = *e.RevIncludedBasicResourcesReferencingSubject
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDiagnosticReportResourcesReferencingEncounter() (diagnosticReports []DiagnosticReport, err error) {
if e.RevIncludedDiagnosticReportResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded diagnosticReports not requested")
} else {
diagnosticReports = *e.RevIncludedDiagnosticReportResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedNutritionOrderResourcesReferencingEncounter() (nutritionOrders []NutritionOrder, err error) {
if e.RevIncludedNutritionOrderResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded nutritionOrders not requested")
} else {
nutritionOrders = *e.RevIncludedNutritionOrderResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedEncounterResourcesReferencingPartof() (encounters []Encounter, err error) {
if e.RevIncludedEncounterResourcesReferencingPartof == nil {
err = errors.New("RevIncluded encounters not requested")
} else {
encounters = *e.RevIncludedEncounterResourcesReferencingPartof
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedAuditEventResourcesReferencingReference() (auditEvents []AuditEvent, err error) {
if e.RevIncludedAuditEventResourcesReferencingReference == nil {
err = errors.New("RevIncluded auditEvents not requested")
} else {
auditEvents = *e.RevIncludedAuditEventResourcesReferencingReference
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedMedicationOrderResourcesReferencingEncounter() (medicationOrders []MedicationOrder, err error) {
if e.RevIncludedMedicationOrderResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded medicationOrders not requested")
} else {
medicationOrders = *e.RevIncludedMedicationOrderResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedCommunicationResourcesReferencingEncounter() (communications []Communication, err error) {
if e.RevIncludedCommunicationResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded communications not requested")
} else {
communications = *e.RevIncludedCommunicationResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedConditionResourcesReferencingEncounter() (conditions []Condition, err error) {
if e.RevIncludedConditionResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded conditions not requested")
} else {
conditions = *e.RevIncludedConditionResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedCompositionResourcesReferencingSubject() (compositions []Composition, err error) {
if e.RevIncludedCompositionResourcesReferencingSubject == nil {
err = errors.New("RevIncluded compositions not requested")
} else {
compositions = *e.RevIncludedCompositionResourcesReferencingSubject
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedCompositionResourcesReferencingEncounter() (compositions []Composition, err error) {
if e.RevIncludedCompositionResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded compositions not requested")
} else {
compositions = *e.RevIncludedCompositionResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedCompositionResourcesReferencingEntry() (compositions []Composition, err error) {
if e.RevIncludedCompositionResourcesReferencingEntry == nil {
err = errors.New("RevIncluded compositions not requested")
} else {
compositions = *e.RevIncludedCompositionResourcesReferencingEntry
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDetectedIssueResourcesReferencingImplicated() (detectedIssues []DetectedIssue, err error) {
if e.RevIncludedDetectedIssueResourcesReferencingImplicated == nil {
err = errors.New("RevIncluded detectedIssues not requested")
} else {
detectedIssues = *e.RevIncludedDetectedIssueResourcesReferencingImplicated
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedDiagnosticOrderResourcesReferencingEncounter() (diagnosticOrders []DiagnosticOrder, err error) {
if e.RevIncludedDiagnosticOrderResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded diagnosticOrders not requested")
} else {
diagnosticOrders = *e.RevIncludedDiagnosticOrderResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedOrderResponseResourcesReferencingFulfillment() (orderResponses []OrderResponse, err error) {
if e.RevIncludedOrderResponseResourcesReferencingFulfillment == nil {
err = errors.New("RevIncluded orderResponses not requested")
} else {
orderResponses = *e.RevIncludedOrderResponseResourcesReferencingFulfillment
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedQuestionnaireResponseResourcesReferencingSubject() (questionnaireResponses []QuestionnaireResponse, err error) {
if e.RevIncludedQuestionnaireResponseResourcesReferencingSubject == nil {
err = errors.New("RevIncluded questionnaireResponses not requested")
} else {
questionnaireResponses = *e.RevIncludedQuestionnaireResponseResourcesReferencingSubject
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedQuestionnaireResponseResourcesReferencingEncounter() (questionnaireResponses []QuestionnaireResponse, err error) {
if e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter == nil {
err = errors.New("RevIncluded questionnaireResponses not requested")
} else {
questionnaireResponses = *e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedProcessResponseResourcesReferencingRequest() (processResponses []ProcessResponse, err error) {
if e.RevIncludedProcessResponseResourcesReferencingRequest == nil {
err = errors.New("RevIncluded processResponses not requested")
} else {
processResponses = *e.RevIncludedProcessResponseResourcesReferencingRequest
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedClinicalImpressionResourcesReferencingTrigger() (clinicalImpressions []ClinicalImpression, err error) {
if e.RevIncludedClinicalImpressionResourcesReferencingTrigger == nil {
err = errors.New("RevIncluded clinicalImpressions not requested")
} else {
clinicalImpressions = *e.RevIncludedClinicalImpressionResourcesReferencingTrigger
}
return
}
func (e *EncounterPlusRelatedResources) GetRevIncludedMessageHeaderResourcesReferencingData() (messageHeaders []MessageHeader, err error) {
if e.RevIncludedMessageHeaderResourcesReferencingData == nil {
err = errors.New("RevIncluded messageHeaders not requested")
} else {
messageHeaders = *e.RevIncludedMessageHeaderResourcesReferencingData
}
return
}
func (e *EncounterPlusRelatedResources) GetIncludedResources() map[string]interface{} {
resourceMap := make(map[string]interface{})
if e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare != nil {
for idx := range *e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare {
rsc := (*e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedReferralRequestResourcesReferencedByIncomingreferral != nil {
for idx := range *e.IncludedReferralRequestResourcesReferencedByIncomingreferral {
rsc := (*e.IncludedReferralRequestResourcesReferencedByIncomingreferral)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPractitionerResourcesReferencedByPractitioner != nil {
for idx := range *e.IncludedPractitionerResourcesReferencedByPractitioner {
rsc := (*e.IncludedPractitionerResourcesReferencedByPractitioner)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedAppointmentResourcesReferencedByAppointment != nil {
for idx := range *e.IncludedAppointmentResourcesReferencedByAppointment {
rsc := (*e.IncludedAppointmentResourcesReferencedByAppointment)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedEncounterResourcesReferencedByPartof != nil {
for idx := range *e.IncludedEncounterResourcesReferencedByPartof {
rsc := (*e.IncludedEncounterResourcesReferencedByPartof)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedProcedureResourcesReferencedByProcedure != nil {
for idx := range *e.IncludedProcedureResourcesReferencedByProcedure {
rsc := (*e.IncludedProcedureResourcesReferencedByProcedure)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPractitionerResourcesReferencedByParticipant != nil {
for idx := range *e.IncludedPractitionerResourcesReferencedByParticipant {
rsc := (*e.IncludedPractitionerResourcesReferencedByParticipant)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedRelatedPersonResourcesReferencedByParticipant != nil {
for idx := range *e.IncludedRelatedPersonResourcesReferencedByParticipant {
rsc := (*e.IncludedRelatedPersonResourcesReferencedByParticipant)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedConditionResourcesReferencedByCondition != nil {
for idx := range *e.IncludedConditionResourcesReferencedByCondition {
rsc := (*e.IncludedConditionResourcesReferencedByCondition)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPatientResourcesReferencedByPatient != nil {
for idx := range *e.IncludedPatientResourcesReferencedByPatient {
rsc := (*e.IncludedPatientResourcesReferencedByPatient)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedLocationResourcesReferencedByLocation != nil {
for idx := range *e.IncludedLocationResourcesReferencedByLocation {
rsc := (*e.IncludedLocationResourcesReferencedByLocation)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedConditionResourcesReferencedByIndication != nil {
for idx := range *e.IncludedConditionResourcesReferencedByIndication {
rsc := (*e.IncludedConditionResourcesReferencedByIndication)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedProcedureResourcesReferencedByIndication != nil {
for idx := range *e.IncludedProcedureResourcesReferencedByIndication {
rsc := (*e.IncludedProcedureResourcesReferencedByIndication)[idx]
resourceMap[rsc.Id] = &rsc
}
}
return resourceMap
}
func (e *EncounterPlusRelatedResources) GetRevIncludedResources() map[string]interface{} {
resourceMap := make(map[string]interface{})
if e.RevIncludedProvenanceResourcesReferencingTarget != nil {
for idx := range *e.RevIncludedProvenanceResourcesReferencingTarget {
rsc := (*e.RevIncludedProvenanceResourcesReferencingTarget)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentManifestResourcesReferencingContentref != nil {
for idx := range *e.RevIncludedDocumentManifestResourcesReferencingContentref {
rsc := (*e.RevIncludedDocumentManifestResourcesReferencingContentref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentManifestResourcesReferencingRelatedref != nil {
for idx := range *e.RevIncludedDocumentManifestResourcesReferencingRelatedref {
rsc := (*e.RevIncludedDocumentManifestResourcesReferencingRelatedref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcedureResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedProcedureResourcesReferencingEncounter {
rsc := (*e.RevIncludedProcedureResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedListResourcesReferencingItem != nil {
for idx := range *e.RevIncludedListResourcesReferencingItem {
rsc := (*e.RevIncludedListResourcesReferencingItem)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedListResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedListResourcesReferencingEncounter {
rsc := (*e.RevIncludedListResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentReferenceResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDocumentReferenceResourcesReferencingEncounter {
rsc := (*e.RevIncludedDocumentReferenceResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentReferenceResourcesReferencingRelatedref != nil {
for idx := range *e.RevIncludedDocumentReferenceResourcesReferencingRelatedref {
rsc := (*e.RevIncludedDocumentReferenceResourcesReferencingRelatedref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedOrderResourcesReferencingDetail != nil {
for idx := range *e.RevIncludedOrderResourcesReferencingDetail {
rsc := (*e.RevIncludedOrderResourcesReferencingDetail)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedVisionPrescriptionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedVisionPrescriptionResourcesReferencingEncounter {
rsc := (*e.RevIncludedVisionPrescriptionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcedureRequestResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedProcedureRequestResourcesReferencingEncounter {
rsc := (*e.RevIncludedProcedureRequestResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedFlagResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedFlagResourcesReferencingEncounter {
rsc := (*e.RevIncludedFlagResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedObservationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedObservationResourcesReferencingEncounter {
rsc := (*e.RevIncludedObservationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMedicationAdministrationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedMedicationAdministrationResourcesReferencingEncounter {
rsc := (*e.RevIncludedMedicationAdministrationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCommunicationRequestResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCommunicationRequestResourcesReferencingEncounter {
rsc := (*e.RevIncludedCommunicationRequestResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedRiskAssessmentResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedRiskAssessmentResourcesReferencingEncounter {
rsc := (*e.RevIncludedRiskAssessmentResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedBasicResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedBasicResourcesReferencingSubject {
rsc := (*e.RevIncludedBasicResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDiagnosticReportResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDiagnosticReportResourcesReferencingEncounter {
rsc := (*e.RevIncludedDiagnosticReportResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedNutritionOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedNutritionOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedNutritionOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedEncounterResourcesReferencingPartof != nil {
for idx := range *e.RevIncludedEncounterResourcesReferencingPartof {
rsc := (*e.RevIncludedEncounterResourcesReferencingPartof)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedAuditEventResourcesReferencingReference != nil {
for idx := range *e.RevIncludedAuditEventResourcesReferencingReference {
rsc := (*e.RevIncludedAuditEventResourcesReferencingReference)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMedicationOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedMedicationOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedMedicationOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCommunicationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCommunicationResourcesReferencingEncounter {
rsc := (*e.RevIncludedCommunicationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedConditionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedConditionResourcesReferencingEncounter {
rsc := (*e.RevIncludedConditionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingSubject {
rsc := (*e.RevIncludedCompositionResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingEncounter {
rsc := (*e.RevIncludedCompositionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingEntry != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingEntry {
rsc := (*e.RevIncludedCompositionResourcesReferencingEntry)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDetectedIssueResourcesReferencingImplicated != nil {
for idx := range *e.RevIncludedDetectedIssueResourcesReferencingImplicated {
rsc := (*e.RevIncludedDetectedIssueResourcesReferencingImplicated)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDiagnosticOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDiagnosticOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedDiagnosticOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedOrderResponseResourcesReferencingFulfillment != nil {
for idx := range *e.RevIncludedOrderResponseResourcesReferencingFulfillment {
rsc := (*e.RevIncludedOrderResponseResourcesReferencingFulfillment)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedQuestionnaireResponseResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedQuestionnaireResponseResourcesReferencingSubject {
rsc := (*e.RevIncludedQuestionnaireResponseResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter {
rsc := (*e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcessResponseResourcesReferencingRequest != nil {
for idx := range *e.RevIncludedProcessResponseResourcesReferencingRequest {
rsc := (*e.RevIncludedProcessResponseResourcesReferencingRequest)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedClinicalImpressionResourcesReferencingTrigger != nil {
for idx := range *e.RevIncludedClinicalImpressionResourcesReferencingTrigger {
rsc := (*e.RevIncludedClinicalImpressionResourcesReferencingTrigger)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMessageHeaderResourcesReferencingData != nil {
for idx := range *e.RevIncludedMessageHeaderResourcesReferencingData {
rsc := (*e.RevIncludedMessageHeaderResourcesReferencingData)[idx]
resourceMap[rsc.Id] = &rsc
}
}
return resourceMap
}
func (e *EncounterPlusRelatedResources) GetIncludedAndRevIncludedResources() map[string]interface{} {
resourceMap := make(map[string]interface{})
if e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare != nil {
for idx := range *e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare {
rsc := (*e.IncludedEpisodeOfCareResourcesReferencedByEpisodeofcare)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedReferralRequestResourcesReferencedByIncomingreferral != nil {
for idx := range *e.IncludedReferralRequestResourcesReferencedByIncomingreferral {
rsc := (*e.IncludedReferralRequestResourcesReferencedByIncomingreferral)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPractitionerResourcesReferencedByPractitioner != nil {
for idx := range *e.IncludedPractitionerResourcesReferencedByPractitioner {
rsc := (*e.IncludedPractitionerResourcesReferencedByPractitioner)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedAppointmentResourcesReferencedByAppointment != nil {
for idx := range *e.IncludedAppointmentResourcesReferencedByAppointment {
rsc := (*e.IncludedAppointmentResourcesReferencedByAppointment)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedEncounterResourcesReferencedByPartof != nil {
for idx := range *e.IncludedEncounterResourcesReferencedByPartof {
rsc := (*e.IncludedEncounterResourcesReferencedByPartof)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedProcedureResourcesReferencedByProcedure != nil {
for idx := range *e.IncludedProcedureResourcesReferencedByProcedure {
rsc := (*e.IncludedProcedureResourcesReferencedByProcedure)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPractitionerResourcesReferencedByParticipant != nil {
for idx := range *e.IncludedPractitionerResourcesReferencedByParticipant {
rsc := (*e.IncludedPractitionerResourcesReferencedByParticipant)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedRelatedPersonResourcesReferencedByParticipant != nil {
for idx := range *e.IncludedRelatedPersonResourcesReferencedByParticipant {
rsc := (*e.IncludedRelatedPersonResourcesReferencedByParticipant)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedConditionResourcesReferencedByCondition != nil {
for idx := range *e.IncludedConditionResourcesReferencedByCondition {
rsc := (*e.IncludedConditionResourcesReferencedByCondition)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedPatientResourcesReferencedByPatient != nil {
for idx := range *e.IncludedPatientResourcesReferencedByPatient {
rsc := (*e.IncludedPatientResourcesReferencedByPatient)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedLocationResourcesReferencedByLocation != nil {
for idx := range *e.IncludedLocationResourcesReferencedByLocation {
rsc := (*e.IncludedLocationResourcesReferencedByLocation)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedConditionResourcesReferencedByIndication != nil {
for idx := range *e.IncludedConditionResourcesReferencedByIndication {
rsc := (*e.IncludedConditionResourcesReferencedByIndication)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.IncludedProcedureResourcesReferencedByIndication != nil {
for idx := range *e.IncludedProcedureResourcesReferencedByIndication {
rsc := (*e.IncludedProcedureResourcesReferencedByIndication)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProvenanceResourcesReferencingTarget != nil {
for idx := range *e.RevIncludedProvenanceResourcesReferencingTarget {
rsc := (*e.RevIncludedProvenanceResourcesReferencingTarget)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentManifestResourcesReferencingContentref != nil {
for idx := range *e.RevIncludedDocumentManifestResourcesReferencingContentref {
rsc := (*e.RevIncludedDocumentManifestResourcesReferencingContentref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentManifestResourcesReferencingRelatedref != nil {
for idx := range *e.RevIncludedDocumentManifestResourcesReferencingRelatedref {
rsc := (*e.RevIncludedDocumentManifestResourcesReferencingRelatedref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcedureResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedProcedureResourcesReferencingEncounter {
rsc := (*e.RevIncludedProcedureResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedListResourcesReferencingItem != nil {
for idx := range *e.RevIncludedListResourcesReferencingItem {
rsc := (*e.RevIncludedListResourcesReferencingItem)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedListResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedListResourcesReferencingEncounter {
rsc := (*e.RevIncludedListResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentReferenceResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDocumentReferenceResourcesReferencingEncounter {
rsc := (*e.RevIncludedDocumentReferenceResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDocumentReferenceResourcesReferencingRelatedref != nil {
for idx := range *e.RevIncludedDocumentReferenceResourcesReferencingRelatedref {
rsc := (*e.RevIncludedDocumentReferenceResourcesReferencingRelatedref)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedOrderResourcesReferencingDetail != nil {
for idx := range *e.RevIncludedOrderResourcesReferencingDetail {
rsc := (*e.RevIncludedOrderResourcesReferencingDetail)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedVisionPrescriptionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedVisionPrescriptionResourcesReferencingEncounter {
rsc := (*e.RevIncludedVisionPrescriptionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcedureRequestResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedProcedureRequestResourcesReferencingEncounter {
rsc := (*e.RevIncludedProcedureRequestResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedFlagResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedFlagResourcesReferencingEncounter {
rsc := (*e.RevIncludedFlagResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedObservationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedObservationResourcesReferencingEncounter {
rsc := (*e.RevIncludedObservationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMedicationAdministrationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedMedicationAdministrationResourcesReferencingEncounter {
rsc := (*e.RevIncludedMedicationAdministrationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCommunicationRequestResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCommunicationRequestResourcesReferencingEncounter {
rsc := (*e.RevIncludedCommunicationRequestResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedRiskAssessmentResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedRiskAssessmentResourcesReferencingEncounter {
rsc := (*e.RevIncludedRiskAssessmentResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedBasicResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedBasicResourcesReferencingSubject {
rsc := (*e.RevIncludedBasicResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDiagnosticReportResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDiagnosticReportResourcesReferencingEncounter {
rsc := (*e.RevIncludedDiagnosticReportResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedNutritionOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedNutritionOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedNutritionOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedEncounterResourcesReferencingPartof != nil {
for idx := range *e.RevIncludedEncounterResourcesReferencingPartof {
rsc := (*e.RevIncludedEncounterResourcesReferencingPartof)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedAuditEventResourcesReferencingReference != nil {
for idx := range *e.RevIncludedAuditEventResourcesReferencingReference {
rsc := (*e.RevIncludedAuditEventResourcesReferencingReference)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMedicationOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedMedicationOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedMedicationOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCommunicationResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCommunicationResourcesReferencingEncounter {
rsc := (*e.RevIncludedCommunicationResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedConditionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedConditionResourcesReferencingEncounter {
rsc := (*e.RevIncludedConditionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingSubject {
rsc := (*e.RevIncludedCompositionResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingEncounter {
rsc := (*e.RevIncludedCompositionResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedCompositionResourcesReferencingEntry != nil {
for idx := range *e.RevIncludedCompositionResourcesReferencingEntry {
rsc := (*e.RevIncludedCompositionResourcesReferencingEntry)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDetectedIssueResourcesReferencingImplicated != nil {
for idx := range *e.RevIncludedDetectedIssueResourcesReferencingImplicated {
rsc := (*e.RevIncludedDetectedIssueResourcesReferencingImplicated)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedDiagnosticOrderResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedDiagnosticOrderResourcesReferencingEncounter {
rsc := (*e.RevIncludedDiagnosticOrderResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedOrderResponseResourcesReferencingFulfillment != nil {
for idx := range *e.RevIncludedOrderResponseResourcesReferencingFulfillment {
rsc := (*e.RevIncludedOrderResponseResourcesReferencingFulfillment)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedQuestionnaireResponseResourcesReferencingSubject != nil {
for idx := range *e.RevIncludedQuestionnaireResponseResourcesReferencingSubject {
rsc := (*e.RevIncludedQuestionnaireResponseResourcesReferencingSubject)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter != nil {
for idx := range *e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter {
rsc := (*e.RevIncludedQuestionnaireResponseResourcesReferencingEncounter)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedProcessResponseResourcesReferencingRequest != nil {
for idx := range *e.RevIncludedProcessResponseResourcesReferencingRequest {
rsc := (*e.RevIncludedProcessResponseResourcesReferencingRequest)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedClinicalImpressionResourcesReferencingTrigger != nil {
for idx := range *e.RevIncludedClinicalImpressionResourcesReferencingTrigger {
rsc := (*e.RevIncludedClinicalImpressionResourcesReferencingTrigger)[idx]
resourceMap[rsc.Id] = &rsc
}
}
if e.RevIncludedMessageHeaderResourcesReferencingData != nil {
for idx := range *e.RevIncludedMessageHeaderResourcesReferencingData {
rsc := (*e.RevIncludedMessageHeaderResourcesReferencingData)[idx]
resourceMap[rsc.Id] = &rsc
}
}
return resourceMap
}
| intervention-engine/ie | vendor/github.com/intervention-engine/fhir/models/encounter.go | GO | apache-2.0 | 59,964 |
/*!
Copyright (C) 2016 Google Inc.
Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
*/
/*
* Generally useful helpers
* Primarily to support Jasmine 1.3 -> Jasmine 2
*/
// polls check function and calls done when truthy
window.waitsFor = function (check, done) {
if (!check()) {
setTimeout(function () {
waitsFor(check, done);
}, 1);
} else {
done();
}
};
// This is primarily useful for passing as the fail case for
// promises, since every item passed to it will show up in
// the jasmine output.
window.failAll = function (done) {
return function () {
can.each(arguments, function (arg) {
fail(JSON.stringify(arg));
});
if (done) {
done();
}
};
};
| andrei-karalionak/ggrc-core | src/ggrc/assets/js_specs/spec_helpers.js | JavaScript | apache-2.0 | 745 |
/*
* Copyright 2015 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hannesdorfmann.mosby.mvp;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import com.hannesdorfmann.mosby.mvp.delegate.ActivityMvpDelegate;
import com.hannesdorfmann.mosby.mvp.delegate.ActivityMvpDelegateCallback;
import com.hannesdorfmann.mosby.mvp.delegate.ActivityMvpDelegateImpl;
/**
* An Activity that uses an {@link MvpPresenter} to implement a Model-View-Presenter
* architecture.
*
* @author Hannes Dorfmann
* @since 1.0.0
*/
public abstract class MvpActivity<V extends MvpView, P extends MvpPresenter<V>>
extends AppCompatActivity implements ActivityMvpDelegateCallback<V, P>, MvpView {
protected ActivityMvpDelegate mvpDelegate;
protected P presenter;
protected boolean retainInstance;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getMvpDelegate().onCreate(savedInstanceState);
}
@Override protected void onDestroy() {
super.onDestroy();
getMvpDelegate().onDestroy();
}
@Override protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getMvpDelegate().onSaveInstanceState(outState);
}
@Override protected void onPause() {
super.onPause();
getMvpDelegate().onPause();
}
@Override protected void onResume() {
super.onResume();
getMvpDelegate().onResume();
}
@Override protected void onStart() {
super.onStart();
getMvpDelegate().onStart();
}
@Override protected void onStop() {
super.onStop();
getMvpDelegate().onStop();
}
@Override protected void onRestart() {
super.onRestart();
getMvpDelegate().onRestart();
}
@Override public void onContentChanged() {
super.onContentChanged();
getMvpDelegate().onContentChanged();
}
@Override protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getMvpDelegate().onPostCreate(savedInstanceState);
}
/**
* Instantiate a presenter instance
*
* @return The {@link MvpPresenter} for this view
*/
@NonNull public abstract P createPresenter();
/**
* Get the mvp delegate. This is internally used for creating presenter, attaching and detaching
* view from presenter.
*
* <p><b>Please note that only one instance of mvp delegate should be used per Activity
* instance</b>.
* </p>
*
* <p>
* Only override this method if you really know what you are doing.
* </p>
*
* @return {@link ActivityMvpDelegateImpl}
*/
@NonNull protected ActivityMvpDelegate<V, P> getMvpDelegate() {
if (mvpDelegate == null) {
mvpDelegate = new ActivityMvpDelegateImpl(this);
}
return mvpDelegate;
}
@NonNull @Override public P getPresenter() {
return presenter;
}
@Override public void setPresenter(@NonNull P presenter) {
this.presenter = presenter;
}
@NonNull @Override public V getMvpView() {
return (V) this;
}
@Override public boolean isRetainInstance() {
return retainInstance;
}
@Override public boolean shouldInstanceBeRetained() {
return retainInstance && isChangingConfigurations();
}
@Override public void setRetainInstance(boolean retainInstance) {
this.retainInstance = retainInstance;
}
@Override public Object onRetainNonMosbyCustomNonConfigurationInstance() {
return null;
}
/**
* Internally used by Mosby. Use {@link #onRetainNonMosbyCustomNonConfigurationInstance()} and
* {@link #getNonMosbyLastCustomNonConfigurationInstance()}
*/
@Override public final Object onRetainCustomNonConfigurationInstance() {
return getMvpDelegate().onRetainCustomNonConfigurationInstance();
}
@Override public final Object getNonMosbyLastCustomNonConfigurationInstance() {
return getMvpDelegate().getNonMosbyLastCustomNonConfigurationInstance();
}
}
| gmail-msn/mosby | mvp/src/main/java/com/hannesdorfmann/mosby/mvp/MvpActivity.java | Java | apache-2.0 | 4,501 |
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
#
# THIS IS A GENERATED DOCKERFILE.
#
# This file was assembled from multiple pieces, whose use is documented
# throughout. Please refer to the TensorFlow dockerfiles documentation
# for more information.
ARG UBUNTU_VERSION=18.04
FROM ubuntu:${UBUNTU_VERSION} as base
RUN apt-get update && apt-get install -y curl
# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8
RUN apt-get update && apt-get install -y \
python3 \
python3-pip
RUN python3 -m pip --no-cache-dir install --upgrade \
"pip<20.3" \
setuptools
# Some TF tools expect a "python" binary
RUN ln -s $(which python3) /usr/local/bin/python
# Options:
# tensorflow
# tensorflow-gpu
# tf-nightly
# tf-nightly-gpu
ARG TF_PACKAGE=tensorflow
RUN apt-get update && apt-get install -y curl libhdf5-dev wget
RUN python3 -m pip install --no-cache-dir --global-option=build_ext \
--global-option=-I/usr/include/hdf5/serial/ \
--global-option=-L/usr/lib/powerpc64le-linux-gnu/hdf5/serial \
h5py
# CACHE_STOP is used to rerun future commands, otherwise downloading the .whl will be cached and will not pull the most recent version
ARG CACHE_STOP=1
RUN if [ ${TF_PACKAGE} = tensorflow-gpu ]; then \
BASE=https://powerci.osuosl.org/job/TensorFlow_PPC64LE_GPU_Release_Build/lastSuccessfulBuild/; \
elif [ ${TF_PACKAGE} = tf-nightly-gpu ]; then \
BASE=https://powerci.osuosl.org/job/TensorFlow_PPC64LE_GPU_Nightly_Artifact/lastSuccessfulBuild/; \
elif [ ${TF_PACKAGE} = tensorflow ]; then \
BASE=https://powerci.osuosl.org/job/TensorFlow_PPC64LE_CPU_Release_Build/lastSuccessfulBuild/; \
elif [ ${TF_PACKAGE} = tf-nightly ]; then \
BASE=https://powerci.osuosl.org/job/TensorFlow_PPC64LE_CPU_Nightly_Artifact/lastSuccessfulBuild/; \
fi; \
MAJOR=`python3 -c 'import sys; print(sys.version_info[0])'`; \
MINOR=`python3 -c 'import sys; print(sys.version_info[1])'`; \
PACKAGE=$(wget -qO- ${BASE}"api/xml?xpath=//fileName&wrapper=artifacts" | grep -o "[^<>]*cp${MAJOR}${MINOR}[^<>]*.whl"); \
wget ${BASE}"artifact/tensorflow_pkg/"${PACKAGE}; \
python3 -m pip install --no-cache-dir ${PACKAGE}
COPY bashrc /etc/bash.bashrc
RUN chmod a+rwx /etc/bash.bashrc
| frreiss/tensorflow-fred | tensorflow/tools/dockerfiles/dockerfiles/ppc64le/cpu-ppc64le.Dockerfile | Dockerfile | apache-2.0 | 2,923 |
<?xml version="1.0" encoding="UTF-8"?>
<!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" lang="en-us" xml:lang="en-us">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="copyright" content="(C) Copyright 2005" />
<meta name="DC.rights.owner" content="(C) Copyright 2005" />
<meta content="public" name="security" />
<meta content="index,follow" name="Robots" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta content="reference" name="DC.Type" />
<meta name="DC.Title" content="DriverPropertyInfo array example" />
<meta name="abstract" content="The following code shows how to use a DriverPropertyInfo array." />
<meta name="description" content="The following code shows how to use a DriverPropertyInfo array." />
<meta content="getpropertyinfo, using" name="DC.subject" />
<meta content="getpropertyinfo, using" name="keywords" />
<meta scheme="URI" name="DC.Relation" content="rdevadvjdbc034.html" />
<meta content="XHTML" name="DC.Format" />
<meta content="rdevadvjdbc965" name="DC.Identifier" />
<meta content="en-us" name="DC.Language" />
<link href="commonltr.css" type="text/css" rel="stylesheet" />
<title>DriverPropertyInfo array example</title>
</head>
<body id="rdevadvjdbc965"><a name="rdevadvjdbc965"><!-- --></a>
<h1 class="topictitle1">DriverPropertyInfo array example</h1>
<div><p>The following code shows how to use a <em>DriverPropertyInfo</em>
array.</p>
<div class="example">
<pre>import java.sql.*;
import java.util.Properties;
<strong>// Start with the least amount of information
// to see the full list of choices.
// We could also enter with a URL and Properties
// provided by a user.</strong>
String url = "jdbc:derby:";
Properties info = new Properties();
Driver cDriver = DriverManager.getDriver(url);
for (;;)
{
DriverPropertyInfo[] attributes = cDriver.getPropertyInfo(
url, info);
<strong> // Zero length means a connection attempt can be made</strong>
if (attributes.length == 0)
break;
<strong> // Insert code here to process the array; for example,
// display all options in a GUI and allow the user to
// pick and then set the attributes in info or URL.</strong>
}
<strong>// Try the connection</strong>
Connection conn = DriverManager.getConnection(url, info);</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rdevadvjdbc034.html" title="When a non-zero-length array is returned by getPropertyInfo, each element is a DriverPropertyInfo object representing a connection URL attribute that has not already been specified. Only those that make sense in the current context are returned.">The DriverPropertyInfo Array</a></div>
</div>
</div>
</body>
</html>
| Kerensky256/Database | docs/html/devguide/rdevadvjdbc965.html | HTML | apache-2.0 | 3,914 |
<!--
(c) Copyright 2015 Hewlett-Packard Development Company, L.P.
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.
-->
<div ng-controller="LaunchInstanceFlavorController as selectFlavorCtrl">
<p translate>
Flavors manage the sizing for the compute, memory and storage capacity of the instance.
</p>
<transfer-table
tr-model="selectFlavorCtrl.transferTableModel"
limits="selectFlavorCtrl.allocationLimits">
<allocated ng-model="selectFlavorCtrl.allocatedFlavorFacades.length"
validate-number-min="1" name="allocated-flavor">
<select-flavor-table
items="selectFlavorCtrl.allocatedFlavorFacades"
displayed-items="selectFlavorCtrl.displayedAllocatedFlavorFacades"
metadata-defs="selectFlavorCtrl.metadataDefs">
</select-flavor-table>
</allocated>
<available>
<select-flavor-table
is-available-table="true"
items="selectFlavorCtrl.availableFlavorFacades"
displayed-items="selectFlavorCtrl.displayedAvailableFlavorFacades"
metadata-defs="selectFlavorCtrl.metadataDefs">
</select-flavor-table>
</available>
</transfer-table>
</div>
| yangleo/cloud-github | openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/flavor/flavor.html | HTML | apache-2.0 | 1,642 |
/**
******************************************************************************
* @file stm32f765xx.h
* @author MCD Application Team
* @version V1.1.0
* @date 22-April-2016
* @brief CMSIS Cortex-M7 Device Peripheral Access Layer Header File.
*
* This file contains:
* - Data structures and the address mapping for all peripherals
* - Peripheral's registers declarations and bits definition
* - Macros to access peripherals registers hardware
*
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/** @addtogroup CMSIS_Device
* @{
*/
/** @addtogroup stm32f765xx
* @{
*/
#ifndef __STM32F765xx_H
#define __STM32F765xx_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @addtogroup Configuration_section_for_CMSIS
* @{
*/
/**
* @brief STM32F7xx Interrupt Number Definition, according to the selected device
* in @ref Library_configuration_section
*/
typedef enum
{
/****** Cortex-M7 Processor Exceptions Numbers ****************************************************************/
NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
MemoryManagement_IRQn = -12, /*!< 4 Cortex-M7 Memory Management Interrupt */
BusFault_IRQn = -11, /*!< 5 Cortex-M7 Bus Fault Interrupt */
UsageFault_IRQn = -10, /*!< 6 Cortex-M7 Usage Fault Interrupt */
SVCall_IRQn = -5, /*!< 11 Cortex-M7 SV Call Interrupt */
DebugMonitor_IRQn = -4, /*!< 12 Cortex-M7 Debug Monitor Interrupt */
PendSV_IRQn = -2, /*!< 14 Cortex-M7 Pend SV Interrupt */
SysTick_IRQn = -1, /*!< 15 Cortex-M7 System Tick Interrupt */
/****** STM32 specific Interrupt Numbers **********************************************************************/
WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */
PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */
TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */
RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */
FLASH_IRQn = 4, /*!< FLASH global Interrupt */
RCC_IRQn = 5, /*!< RCC global Interrupt */
EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */
EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */
EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */
EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */
EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */
DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */
DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */
DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */
DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */
DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */
DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */
DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */
ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */
CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */
CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */
CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */
CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */
EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */
TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */
TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */
TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */
TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */
TIM2_IRQn = 28, /*!< TIM2 global Interrupt */
TIM3_IRQn = 29, /*!< TIM3 global Interrupt */
TIM4_IRQn = 30, /*!< TIM4 global Interrupt */
I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */
I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */
I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */
I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */
SPI1_IRQn = 35, /*!< SPI1 global Interrupt */
SPI2_IRQn = 36, /*!< SPI2 global Interrupt */
USART1_IRQn = 37, /*!< USART1 global Interrupt */
USART2_IRQn = 38, /*!< USART2 global Interrupt */
USART3_IRQn = 39, /*!< USART3 global Interrupt */
EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */
OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */
TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */
TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */
TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */
TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */
DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */
FMC_IRQn = 48, /*!< FMC global Interrupt */
SDMMC1_IRQn = 49, /*!< SDMMC1 global Interrupt */
TIM5_IRQn = 50, /*!< TIM5 global Interrupt */
SPI3_IRQn = 51, /*!< SPI3 global Interrupt */
UART4_IRQn = 52, /*!< UART4 global Interrupt */
UART5_IRQn = 53, /*!< UART5 global Interrupt */
TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */
TIM7_IRQn = 55, /*!< TIM7 global interrupt */
DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */
DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */
DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */
DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */
DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */
ETH_IRQn = 61, /*!< Ethernet global Interrupt */
ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */
CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */
CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */
CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */
CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */
OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */
DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */
DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */
DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */
USART6_IRQn = 71, /*!< USART6 global interrupt */
I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */
I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */
OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */
OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */
OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */
OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */
DCMI_IRQn = 78, /*!< DCMI global interrupt */
RNG_IRQn = 80, /*!< RNG global interrupt */
FPU_IRQn = 81, /*!< FPU global interrupt */
UART7_IRQn = 82, /*!< UART7 global interrupt */
UART8_IRQn = 83, /*!< UART8 global interrupt */
SPI4_IRQn = 84, /*!< SPI4 global Interrupt */
SPI5_IRQn = 85, /*!< SPI5 global Interrupt */
SPI6_IRQn = 86, /*!< SPI6 global Interrupt */
SAI1_IRQn = 87, /*!< SAI1 global Interrupt */
DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */
SAI2_IRQn = 91, /*!< SAI2 global Interrupt */
QUADSPI_IRQn = 92, /*!< Quad SPI global interrupt */
LPTIM1_IRQn = 93, /*!< LP TIM1 interrupt */
CEC_IRQn = 94, /*!< HDMI-CEC global Interrupt */
I2C4_EV_IRQn = 95, /*!< I2C4 Event Interrupt */
I2C4_ER_IRQn = 96, /*!< I2C4 Error Interrupt */
SPDIF_RX_IRQn = 97, /*!< SPDIF-RX global Interrupt */
DFSDM1_FLT0_IRQn = 99, /*!< DFSDM1 Filter 0 global Interrupt */
DFSDM1_FLT1_IRQn = 100, /*!< DFSDM1 Filter 1 global Interrupt */
DFSDM1_FLT2_IRQn = 101, /*!< DFSDM1 Filter 2 global Interrupt */
DFSDM1_FLT3_IRQn = 102, /*!< DFSDM1 Filter 3 global Interrupt */
SDMMC2_IRQn = 103, /*!< SDMMC2 global Interrupt */
CAN3_TX_IRQn = 104, /*!< CAN3 TX Interrupt */
CAN3_RX0_IRQn = 105, /*!< CAN3 RX0 Interrupt */
CAN3_RX1_IRQn = 106, /*!< CAN3 RX1 Interrupt */
CAN3_SCE_IRQn = 107, /*!< CAN3 SCE Interrupt */
MDIOS_IRQn = 109 /*!< MDIO Slave global Interrupt */
} IRQn_Type;
/**
* @}
*/
/**
* @brief Configuration of the Cortex-M7 Processor and Core Peripherals
*/
#define __CM7_REV 0x0100U /*!< Cortex-M7 revision r1p0 */
#define __MPU_PRESENT 1 /*!< CM7 provides an MPU */
#define __NVIC_PRIO_BITS 4 /*!< CM7 uses 4 Bits for the Priority Levels */
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
#define __FPU_PRESENT 1 /*!< FPU present */
#define __ICACHE_PRESENT 1 /*!< CM7 instruction cache present */
#define __DCACHE_PRESENT 1 /*!< CM7 data cache present */
#include "core_cm7.h" /*!< Cortex-M7 processor and core peripherals */
#include "system_stm32f7xx.h"
#include <stdint.h>
/** @addtogroup Peripheral_registers_structures
* @{
*/
/**
* @brief Analog to Digital Converter
*/
typedef struct
{
__IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */
__IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */
__IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */
__IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */
__IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */
__IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */
__IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */
__IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */
__IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */
__IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */
__IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */
__IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */
__IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */
__IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */
__IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/
__IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */
__IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */
__IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */
__IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */
__IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */
} ADC_TypeDef;
typedef struct
{
__IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */
__IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */
__IO uint32_t CDR; /*!< ADC common regular data register for dual
AND triple modes, Address offset: ADC1 base address + 0x308 */
} ADC_Common_TypeDef;
/**
* @brief Controller Area Network TxMailBox
*/
typedef struct
{
__IO uint32_t TIR; /*!< CAN TX mailbox identifier register */
__IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */
__IO uint32_t TDLR; /*!< CAN mailbox data low register */
__IO uint32_t TDHR; /*!< CAN mailbox data high register */
} CAN_TxMailBox_TypeDef;
/**
* @brief Controller Area Network FIFOMailBox
*/
typedef struct
{
__IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */
__IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */
__IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */
__IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */
} CAN_FIFOMailBox_TypeDef;
/**
* @brief Controller Area Network FilterRegister
*/
typedef struct
{
__IO uint32_t FR1; /*!< CAN Filter bank register 1 */
__IO uint32_t FR2; /*!< CAN Filter bank register 1 */
} CAN_FilterRegister_TypeDef;
/**
* @brief Controller Area Network
*/
typedef struct
{
__IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */
__IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */
__IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */
__IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */
__IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */
__IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */
__IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */
__IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */
uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */
CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */
CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */
uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */
__IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */
__IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */
uint32_t RESERVED2; /*!< Reserved, 0x208 */
__IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */
uint32_t RESERVED3; /*!< Reserved, 0x210 */
__IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */
uint32_t RESERVED4; /*!< Reserved, 0x218 */
__IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */
uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */
CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */
} CAN_TypeDef;
/**
* @brief HDMI-CEC
*/
typedef struct
{
__IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */
__IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */
__IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */
__IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */
__IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */
__IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */
}CEC_TypeDef;
/**
* @brief CRC calculation unit
*/
typedef struct
{
__IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */
__IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */
uint8_t RESERVED0; /*!< Reserved, 0x05 */
uint16_t RESERVED1; /*!< Reserved, 0x06 */
__IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */
uint32_t RESERVED2; /*!< Reserved, 0x0C */
__IO uint32_t INIT; /*!< Initial CRC value register, Address offset: 0x10 */
__IO uint32_t POL; /*!< CRC polynomial register, Address offset: 0x14 */
} CRC_TypeDef;
/**
* @brief Digital to Analog Converter
*/
typedef struct
{
__IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */
__IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */
__IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */
__IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */
__IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */
__IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */
__IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */
__IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */
__IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */
__IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */
__IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */
__IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */
__IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */
__IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */
} DAC_TypeDef;
/**
* @brief DFSDM module registers
*/
typedef struct
{
__IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */
__IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */
__IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */
__IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */
__IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */
__IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */
__IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */
__IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */
__IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */
__IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */
__IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */
__IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */
__IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */
__IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */
__IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */
} DFSDM_Filter_TypeDef;
/**
* @brief DFSDM channel configuration registers
*/
typedef struct
{
__IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */
__IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */
__IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and
short circuit detector register, Address offset: 0x08 */
__IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */
__IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */
} DFSDM_Channel_TypeDef;
/**
* @brief Debug MCU
*/
typedef struct
{
__IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */
__IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */
__IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */
__IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */
}DBGMCU_TypeDef;
/**
* @brief DCMI
*/
typedef struct
{
__IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */
__IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */
__IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */
__IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */
__IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */
__IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */
__IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */
__IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */
__IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */
__IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */
__IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */
} DCMI_TypeDef;
/**
* @brief DMA Controller
*/
typedef struct
{
__IO uint32_t CR; /*!< DMA stream x configuration register */
__IO uint32_t NDTR; /*!< DMA stream x number of data register */
__IO uint32_t PAR; /*!< DMA stream x peripheral address register */
__IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */
__IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */
__IO uint32_t FCR; /*!< DMA stream x FIFO control register */
} DMA_Stream_TypeDef;
typedef struct
{
__IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */
__IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */
__IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */
__IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */
} DMA_TypeDef;
/**
* @brief DMA2D Controller
*/
typedef struct
{
__IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */
__IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */
__IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */
__IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */
__IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */
__IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */
__IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */
__IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */
__IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */
__IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */
__IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */
__IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */
__IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */
__IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */
__IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */
__IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */
__IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */
__IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */
__IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */
__IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */
uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */
__IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */
__IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */
} DMA2D_TypeDef;
/**
* @brief Ethernet MAC
*/
typedef struct
{
__IO uint32_t MACCR;
__IO uint32_t MACFFR;
__IO uint32_t MACHTHR;
__IO uint32_t MACHTLR;
__IO uint32_t MACMIIAR;
__IO uint32_t MACMIIDR;
__IO uint32_t MACFCR;
__IO uint32_t MACVLANTR; /* 8 */
uint32_t RESERVED0[2];
__IO uint32_t MACRWUFFR; /* 11 */
__IO uint32_t MACPMTCSR;
uint32_t RESERVED1[2];
__IO uint32_t MACSR; /* 15 */
__IO uint32_t MACIMR;
__IO uint32_t MACA0HR;
__IO uint32_t MACA0LR;
__IO uint32_t MACA1HR;
__IO uint32_t MACA1LR;
__IO uint32_t MACA2HR;
__IO uint32_t MACA2LR;
__IO uint32_t MACA3HR;
__IO uint32_t MACA3LR; /* 24 */
uint32_t RESERVED2[40];
__IO uint32_t MMCCR; /* 65 */
__IO uint32_t MMCRIR;
__IO uint32_t MMCTIR;
__IO uint32_t MMCRIMR;
__IO uint32_t MMCTIMR; /* 69 */
uint32_t RESERVED3[14];
__IO uint32_t MMCTGFSCCR; /* 84 */
__IO uint32_t MMCTGFMSCCR;
uint32_t RESERVED4[5];
__IO uint32_t MMCTGFCR;
uint32_t RESERVED5[10];
__IO uint32_t MMCRFCECR;
__IO uint32_t MMCRFAECR;
uint32_t RESERVED6[10];
__IO uint32_t MMCRGUFCR;
uint32_t RESERVED7[334];
__IO uint32_t PTPTSCR;
__IO uint32_t PTPSSIR;
__IO uint32_t PTPTSHR;
__IO uint32_t PTPTSLR;
__IO uint32_t PTPTSHUR;
__IO uint32_t PTPTSLUR;
__IO uint32_t PTPTSAR;
__IO uint32_t PTPTTHR;
__IO uint32_t PTPTTLR;
__IO uint32_t RESERVED8;
__IO uint32_t PTPTSSR;
uint32_t RESERVED9[565];
__IO uint32_t DMABMR;
__IO uint32_t DMATPDR;
__IO uint32_t DMARPDR;
__IO uint32_t DMARDLAR;
__IO uint32_t DMATDLAR;
__IO uint32_t DMASR;
__IO uint32_t DMAOMR;
__IO uint32_t DMAIER;
__IO uint32_t DMAMFBOCR;
__IO uint32_t DMARSWTR;
uint32_t RESERVED10[8];
__IO uint32_t DMACHTDR;
__IO uint32_t DMACHRDR;
__IO uint32_t DMACHTBAR;
__IO uint32_t DMACHRBAR;
} ETH_TypeDef;
/**
* @brief External Interrupt/Event Controller
*/
typedef struct
{
__IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */
__IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */
__IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */
__IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */
__IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */
__IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */
} EXTI_TypeDef;
/**
* @brief FLASH Registers
*/
typedef struct
{
__IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */
__IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */
__IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */
__IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */
__IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */
__IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */
__IO uint32_t OPTCR1; /*!< FLASH option control register 1 , Address offset: 0x18 */
} FLASH_TypeDef;
/**
* @brief Flexible Memory Controller
*/
typedef struct
{
__IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */
} FMC_Bank1_TypeDef;
/**
* @brief Flexible Memory Controller Bank1E
*/
typedef struct
{
__IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */
} FMC_Bank1E_TypeDef;
/**
* @brief Flexible Memory Controller Bank3
*/
typedef struct
{
__IO uint32_t PCR; /*!< NAND Flash control register, Address offset: 0x80 */
__IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register, Address offset: 0x84 */
__IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register, Address offset: 0x88 */
__IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register, Address offset: 0x8C */
uint32_t RESERVED0; /*!< Reserved, 0x90 */
__IO uint32_t ECCR; /*!< NAND Flash ECC result registers, Address offset: 0x94 */
} FMC_Bank3_TypeDef;
/**
* @brief Flexible Memory Controller Bank5_6
*/
typedef struct
{
__IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */
__IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */
__IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */
__IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */
__IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */
} FMC_Bank5_6_TypeDef;
/**
* @brief General Purpose I/O
*/
typedef struct
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
__IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
__IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */
__IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
__IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */
} GPIO_TypeDef;
/**
* @brief System configuration controller
*/
typedef struct
{
__IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */
__IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */
__IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */
uint32_t RESERVED; /*!< Reserved, 0x18 */
__IO uint32_t CBR; /*!< SYSCFG Class B register, Address offset: 0x1C */
__IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */
} SYSCFG_TypeDef;
/**
* @brief Inter-integrated Circuit Interface
*/
typedef struct
{
__IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */
__IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */
__IO uint32_t OAR1; /*!< I2C Own address 1 register, Address offset: 0x08 */
__IO uint32_t OAR2; /*!< I2C Own address 2 register, Address offset: 0x0C */
__IO uint32_t TIMINGR; /*!< I2C Timing register, Address offset: 0x10 */
__IO uint32_t TIMEOUTR; /*!< I2C Timeout register, Address offset: 0x14 */
__IO uint32_t ISR; /*!< I2C Interrupt and status register, Address offset: 0x18 */
__IO uint32_t ICR; /*!< I2C Interrupt clear register, Address offset: 0x1C */
__IO uint32_t PECR; /*!< I2C PEC register, Address offset: 0x20 */
__IO uint32_t RXDR; /*!< I2C Receive data register, Address offset: 0x24 */
__IO uint32_t TXDR; /*!< I2C Transmit data register, Address offset: 0x28 */
} I2C_TypeDef;
/**
* @brief Independent WATCHDOG
*/
typedef struct
{
__IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */
__IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */
__IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */
__IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */
__IO uint32_t WINR; /*!< IWDG Window register, Address offset: 0x10 */
} IWDG_TypeDef;
/**
* @brief Power Control
*/
typedef struct
{
__IO uint32_t CR1; /*!< PWR power control register 1, Address offset: 0x00 */
__IO uint32_t CSR1; /*!< PWR power control/status register 2, Address offset: 0x04 */
__IO uint32_t CR2; /*!< PWR power control register 2, Address offset: 0x08 */
__IO uint32_t CSR2; /*!< PWR power control/status register 2, Address offset: 0x0C */
} PWR_TypeDef;
/**
* @brief Reset and Clock Control
*/
typedef struct
{
__IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */
__IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */
__IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */
__IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */
__IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */
__IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */
__IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */
uint32_t RESERVED0; /*!< Reserved, 0x1C */
__IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */
__IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */
uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */
__IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */
__IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */
__IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */
uint32_t RESERVED2; /*!< Reserved, 0x3C */
__IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */
__IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */
uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */
__IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */
__IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */
__IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */
uint32_t RESERVED4; /*!< Reserved, 0x5C */
__IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */
__IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */
uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */
__IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */
__IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */
uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */
__IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */
__IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */
__IO uint32_t PLLSAICFGR; /*!< RCC PLLSAI configuration register, Address offset: 0x88 */
__IO uint32_t DCKCFGR1; /*!< RCC Dedicated Clocks configuration register1, Address offset: 0x8C */
__IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x90 */
} RCC_TypeDef;
/**
* @brief Real-Time Clock
*/
typedef struct
{
__IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */
__IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */
__IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */
__IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */
__IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */
__IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */
uint32_t reserved; /*!< Reserved */
__IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */
__IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */
__IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */
__IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */
__IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */
__IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */
__IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */
__IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */
__IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */
__IO uint32_t TAMPCR; /*!< RTC tamper configuration register, Address offset: 0x40 */
__IO uint32_t ALRMASSR; /*!< RTC alarm A sub second register, Address offset: 0x44 */
__IO uint32_t ALRMBSSR; /*!< RTC alarm B sub second register, Address offset: 0x48 */
__IO uint32_t OR; /*!< RTC option register, Address offset: 0x4C */
__IO uint32_t BKP0R; /*!< RTC backup register 0, Address offset: 0x50 */
__IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */
__IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */
__IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */
__IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */
__IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */
__IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */
__IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */
__IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */
__IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */
__IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */
__IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */
__IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */
__IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */
__IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */
__IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */
__IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */
__IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */
__IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */
__IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */
__IO uint32_t BKP20R; /*!< RTC backup register 20, Address offset: 0xA0 */
__IO uint32_t BKP21R; /*!< RTC backup register 21, Address offset: 0xA4 */
__IO uint32_t BKP22R; /*!< RTC backup register 22, Address offset: 0xA8 */
__IO uint32_t BKP23R; /*!< RTC backup register 23, Address offset: 0xAC */
__IO uint32_t BKP24R; /*!< RTC backup register 24, Address offset: 0xB0 */
__IO uint32_t BKP25R; /*!< RTC backup register 25, Address offset: 0xB4 */
__IO uint32_t BKP26R; /*!< RTC backup register 26, Address offset: 0xB8 */
__IO uint32_t BKP27R; /*!< RTC backup register 27, Address offset: 0xBC */
__IO uint32_t BKP28R; /*!< RTC backup register 28, Address offset: 0xC0 */
__IO uint32_t BKP29R; /*!< RTC backup register 29, Address offset: 0xC4 */
__IO uint32_t BKP30R; /*!< RTC backup register 30, Address offset: 0xC8 */
__IO uint32_t BKP31R; /*!< RTC backup register 31, Address offset: 0xCC */
} RTC_TypeDef;
/**
* @brief Serial Audio Interface
*/
typedef struct
{
__IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */
} SAI_TypeDef;
typedef struct
{
__IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */
__IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */
__IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */
__IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */
__IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */
__IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */
__IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */
__IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */
} SAI_Block_TypeDef;
/**
* @brief SPDIF-RX Interface
*/
typedef struct
{
__IO uint32_t CR; /*!< Control register, Address offset: 0x00 */
__IO uint32_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */
__IO uint32_t SR; /*!< Status register, Address offset: 0x08 */
__IO uint32_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */
__IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */
__IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */
__IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */
} SPDIFRX_TypeDef;
/**
* @brief SD host Interface
*/
typedef struct
{
__IO uint32_t POWER; /*!< SDMMC power control register, Address offset: 0x00 */
__IO uint32_t CLKCR; /*!< SDMMClock control register, Address offset: 0x04 */
__IO uint32_t ARG; /*!< SDMMC argument register, Address offset: 0x08 */
__IO uint32_t CMD; /*!< SDMMC command register, Address offset: 0x0C */
__I uint32_t RESPCMD; /*!< SDMMC command response register, Address offset: 0x10 */
__I uint32_t RESP1; /*!< SDMMC response 1 register, Address offset: 0x14 */
__I uint32_t RESP2; /*!< SDMMC response 2 register, Address offset: 0x18 */
__I uint32_t RESP3; /*!< SDMMC response 3 register, Address offset: 0x1C */
__I uint32_t RESP4; /*!< SDMMC response 4 register, Address offset: 0x20 */
__IO uint32_t DTIMER; /*!< SDMMC data timer register, Address offset: 0x24 */
__IO uint32_t DLEN; /*!< SDMMC data length register, Address offset: 0x28 */
__IO uint32_t DCTRL; /*!< SDMMC data control register, Address offset: 0x2C */
__I uint32_t DCOUNT; /*!< SDMMC data counter register, Address offset: 0x30 */
__I uint32_t STA; /*!< SDMMC status register, Address offset: 0x34 */
__IO uint32_t ICR; /*!< SDMMC interrupt clear register, Address offset: 0x38 */
__IO uint32_t MASK; /*!< SDMMC mask register, Address offset: 0x3C */
uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */
__I uint32_t FIFOCNT; /*!< SDMMC FIFO counter register, Address offset: 0x48 */
uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */
__IO uint32_t FIFO; /*!< SDMMC data FIFO register, Address offset: 0x80 */
} SDMMC_TypeDef;
/**
* @brief Serial Peripheral Interface
*/
typedef struct
{
__IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */
__IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */
__IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */
__IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */
__IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */
__IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */
__IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */
__IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */
__IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */
} SPI_TypeDef;
/**
* @brief QUAD Serial Peripheral Interface
*/
typedef struct
{
__IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */
__IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */
__IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */
__IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */
__IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */
__IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */
__IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */
__IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */
__IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */
__IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */
__IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */
__IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */
__IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */
} QUADSPI_TypeDef;
/**
* @brief TIM
*/
typedef struct
{
__IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */
__IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */
__IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */
__IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */
__IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */
__IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */
__IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */
__IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */
__IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */
__IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */
__IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */
__IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */
__IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */
__IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */
__IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */
__IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */
__IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */
__IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */
__IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */
__IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */
__IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */
__IO uint32_t CCMR3; /*!< TIM capture/compare mode register 3, Address offset: 0x54 */
__IO uint32_t CCR5; /*!< TIM capture/compare mode register5, Address offset: 0x58 */
__IO uint32_t CCR6; /*!< TIM capture/compare mode register6, Address offset: 0x5C */
__IO uint32_t AF1; /*!< TIM Alternate function option register 1, Address offset: 0x60 */
__IO uint32_t AF2; /*!< TIM Alternate function option register 2, Address offset: 0x64 */
} TIM_TypeDef;
/**
* @brief LPTIMIMER
*/
typedef struct
{
__IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */
__IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */
__IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */
__IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */
__IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */
__IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */
__IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */
__IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */
} LPTIM_TypeDef;
/**
* @brief Universal Synchronous Asynchronous Receiver Transmitter
*/
typedef struct
{
__IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x00 */
__IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x04 */
__IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x08 */
__IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x0C */
__IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x10 */
__IO uint32_t RTOR; /*!< USART Receiver Time Out register, Address offset: 0x14 */
__IO uint32_t RQR; /*!< USART Request register, Address offset: 0x18 */
__IO uint32_t ISR; /*!< USART Interrupt and status register, Address offset: 0x1C */
__IO uint32_t ICR; /*!< USART Interrupt flag Clear register, Address offset: 0x20 */
__IO uint32_t RDR; /*!< USART Receive Data register, Address offset: 0x24 */
__IO uint32_t TDR; /*!< USART Transmit Data register, Address offset: 0x28 */
} USART_TypeDef;
/**
* @brief Window WATCHDOG
*/
typedef struct
{
__IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */
__IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */
__IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */
} WWDG_TypeDef;
/**
* @brief RNG
*/
typedef struct
{
__IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */
__IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */
__IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */
} RNG_TypeDef;
/**
* @}
*/
/**
* @brief USB_OTG_Core_Registers
*/
typedef struct
{
__IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */
__IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */
__IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */
__IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */
__IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */
__IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */
__IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */
__IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */
__IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */
__IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */
__IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */
__IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */
uint32_t Reserved30[2]; /*!< Reserved 030h */
__IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */
__IO uint32_t CID; /*!< User ID Register 03Ch */
uint32_t Reserved5[3]; /*!< Reserved 040h-048h */
__IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */
uint32_t Reserved6; /*!< Reserved 050h */
__IO uint32_t GLPMCFG; /*!< LPM Register 054h */
__IO uint32_t GPWRDN; /*!< Power Down Register 058h */
__IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */
__IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */
uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */
__IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */
__IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */
} USB_OTG_GlobalTypeDef;
/**
* @brief USB_OTG_device_Registers
*/
typedef struct
{
__IO uint32_t DCFG; /*!< dev Configuration Register 800h */
__IO uint32_t DCTL; /*!< dev Control Register 804h */
__IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */
uint32_t Reserved0C; /*!< Reserved 80Ch */
__IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */
__IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */
__IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */
__IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */
uint32_t Reserved20; /*!< Reserved 820h */
uint32_t Reserved9; /*!< Reserved 824h */
__IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */
__IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */
__IO uint32_t DTHRCTL; /*!< dev threshold 830h */
__IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */
__IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */
__IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */
uint32_t Reserved40; /*!< dedicated EP mask 840h */
__IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */
uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */
__IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */
} USB_OTG_DeviceTypeDef;
/**
* @brief USB_OTG_IN_Endpoint-Specific_Register
*/
typedef struct
{
__IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */
uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */
__IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */
uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */
__IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */
__IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */
__IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */
uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */
} USB_OTG_INEndpointTypeDef;
/**
* @brief USB_OTG_OUT_Endpoint-Specific_Registers
*/
typedef struct
{
__IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */
uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */
__IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */
uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */
__IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */
__IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */
uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */
} USB_OTG_OUTEndpointTypeDef;
/**
* @brief USB_OTG_Host_Mode_Register_Structures
*/
typedef struct
{
__IO uint32_t HCFG; /*!< Host Configuration Register 400h */
__IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */
__IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */
uint32_t Reserved40C; /*!< Reserved 40Ch */
__IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */
__IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */
__IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */
} USB_OTG_HostTypeDef;
/**
* @brief USB_OTG_Host_Channel_Specific_Registers
*/
typedef struct
{
__IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */
__IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */
__IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */
__IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */
__IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */
__IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */
uint32_t Reserved[2]; /*!< Reserved */
} USB_OTG_HostChannelTypeDef;
/**
* @}
*/
/**
* @brief MDIOS
*/
typedef struct
{
__IO uint32_t CR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 00h */
__IO uint32_t WRFR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 04h */
__IO uint32_t CWRFR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 08h */
__IO uint32_t RDFR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 0Ch */
__IO uint32_t CRDFR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 10h */
__IO uint32_t SR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 14h */
__IO uint32_t CLRFR; /*!< MDIOS Configuration Register (MDIOS_CR), Address offset: 18h */
uint32_t RESERVED0[57]; /* Reserved Address offset: 1Ch */
__IO uint32_t DINR0; /*!< MDIOS Input Data Register (MDIOS_DINR0), Address offset: 100h */
__IO uint32_t DINR1; /*!< MDIOS Input Data Register (MDIOS_DINR1), Address offset: 104h */
__IO uint32_t DINR2; /*!< MDIOS Input Data Register (MDIOS_DINR2), Address offset: 108h */
__IO uint32_t DINR3; /*!< MDIOS Input Data Register (MDIOS_DINR3), Address offset: 10Ch */
__IO uint32_t DINR4; /*!< MDIOS Input Data Register (MDIOS_DINR4), Address offset: 110h */
__IO uint32_t DINR5; /*!< MDIOS Input Data Register (MDIOS_DINR5), Address offset: 114h */
__IO uint32_t DINR6; /*!< MDIOS Input Data Register (MDIOS_DINR6), Address offset: 118h */
__IO uint32_t DINR7; /*!< MDIOS Input Data Register (MDIOS_DINR7), Address offset: 11Ch */
__IO uint32_t DINR8; /*!< MDIOS Input Data Register (MDIOS_DINR8), Address offset: 120h */
__IO uint32_t DINR9; /*!< MDIOS Input Data Register (MDIOS_DINR9), Address offset: 124h */
__IO uint32_t DINR10; /*!< MDIOS Input Data Register (MDIOS_DINR10), Address offset: 128h */
__IO uint32_t DINR11; /*!< MDIOS Input Data Register (MDIOS_DINR11), Address offset: 12Ch */
__IO uint32_t DINR12; /*!< MDIOS Input Data Register (MDIOS_DINR12), Address offset: 130h */
__IO uint32_t DINR13; /*!< MDIOS Input Data Register (MDIOS_DINR13), Address offset: 134h */
__IO uint32_t DINR14; /*!< MDIOS Input Data Register (MDIOS_DINR14), Address offset: 138h */
__IO uint32_t DINR15; /*!< MDIOS Input Data Register (MDIOS_DINR15), Address offset: 13Ch */
__IO uint32_t DINR16; /*!< MDIOS Input Data Register (MDIOS_DINR16), Address offset: 140h */
__IO uint32_t DINR17; /*!< MDIOS Input Data Register (MDIOS_DINR17), Address offset: 144h */
__IO uint32_t DINR18; /*!< MDIOS Input Data Register (MDIOS_DINR18), Address offset: 148h */
__IO uint32_t DINR19; /*!< MDIOS Input Data Register (MDIOS_DINR19), Address offset: 14Ch */
__IO uint32_t DINR20; /*!< MDIOS Input Data Register (MDIOS_DINR20), Address offset: 150h */
__IO uint32_t DINR21; /*!< MDIOS Input Data Register (MDIOS_DINR21), Address offset: 154h */
__IO uint32_t DINR22; /*!< MDIOS Input Data Register (MDIOS_DINR22), Address offset: 158h */
__IO uint32_t DINR23; /*!< MDIOS Input Data Register (MDIOS_DINR23), Address offset: 15Ch */
__IO uint32_t DINR24; /*!< MDIOS Input Data Register (MDIOS_DINR24), Address offset: 160h */
__IO uint32_t DINR25; /*!< MDIOS Input Data Register (MDIOS_DINR25), Address offset: 164h */
__IO uint32_t DINR26; /*!< MDIOS Input Data Register (MDIOS_DINR26), Address offset: 168h */
__IO uint32_t DINR27; /*!< MDIOS Input Data Register (MDIOS_DINR27), Address offset: 16Ch */
__IO uint32_t DINR28; /*!< MDIOS Input Data Register (MDIOS_DINR28), Address offset: 170h */
__IO uint32_t DINR29; /*!< MDIOS Input Data Register (MDIOS_DINR29), Address offset: 174h */
__IO uint32_t DINR30; /*!< MDIOS Input Data Register (MDIOS_DINR30), Address offset: 178h */
__IO uint32_t DINR31; /*!< MDIOS Input Data Register (MDIOS_DINR31), Address offset: 17Ch */
__IO uint32_t DOUTR0; /*!< MDIOS Output Data Register (MDIOS_DOUTR0), Address offset: 180h */
__IO uint32_t DOUTR1; /*!< MDIOS Output Data Register (MDIOS_DOUTR1), Address offset: 184h */
__IO uint32_t DOUTR2; /*!< MDIOS Output Data Register (MDIOS_DOUTR2), Address offset: 188h */
__IO uint32_t DOUTR3; /*!< MDIOS Output Data Register (MDIOS_DOUTR3), Address offset: 18Ch */
__IO uint32_t DOUTR4; /*!< MDIOS Output Data Register (MDIOS_DOUTR4), Address offset: 190h */
__IO uint32_t DOUTR5; /*!< MDIOS Output Data Register (MDIOS_DOUTR5), Address offset: 194h */
__IO uint32_t DOUTR6; /*!< MDIOS Output Data Register (MDIOS_DOUTR6), Address offset: 198h */
__IO uint32_t DOUTR7; /*!< MDIOS Output Data Register (MDIOS_DOUTR7), Address offset: 19Ch */
__IO uint32_t DOUTR8; /*!< MDIOS Output Data Register (MDIOS_DOUTR8), Address offset: 1A0h */
__IO uint32_t DOUTR9; /*!< MDIOS Output Data Register (MDIOS_DOUTR9), Address offset: 1A4h */
__IO uint32_t DOUTR10; /*!< MDIOS Output Data Register (MDIOS_DOUTR10), Address offset: 1A8h */
__IO uint32_t DOUTR11; /*!< MDIOS Output Data Register (MDIOS_DOUTR11), Address offset: 1ACh */
__IO uint32_t DOUTR12; /*!< MDIOS Output Data Register (MDIOS_DOUTR12), Address offset: 1B0h */
__IO uint32_t DOUTR13; /*!< MDIOS Output Data Register (MDIOS_DOUTR13), Address offset: 1B4h */
__IO uint32_t DOUTR14; /*!< MDIOS Output Data Register (MDIOS_DOUTR14), Address offset: 1B8h */
__IO uint32_t DOUTR15; /*!< MDIOS Output Data Register (MDIOS_DOUTR15), Address offset: 1BCh */
__IO uint32_t DOUTR16; /*!< MDIOS Output Data Register (MDIOS_DOUTR16), Address offset: 1C0h */
__IO uint32_t DOUTR17; /*!< MDIOS Output Data Register (MDIOS_DOUTR17), Address offset: 1C4h */
__IO uint32_t DOUTR18; /*!< MDIOS Output Data Register (MDIOS_DOUTR18), Address offset: 1C8h */
__IO uint32_t DOUTR19; /*!< MDIOS Output Data Register (MDIOS_DOUTR19), Address offset: 1CCh */
__IO uint32_t DOUTR20; /*!< MDIOS Output Data Register (MDIOS_DOUTR20), Address offset: 1D0h */
__IO uint32_t DOUTR21; /*!< MDIOS Output Data Register (MDIOS_DOUTR21), Address offset: 1D4h */
__IO uint32_t DOUTR22; /*!< MDIOS Output Data Register (MDIOS_DOUTR22), Address offset: 1D8h */
__IO uint32_t DOUTR23; /*!< MDIOS Output Data Register (MDIOS_DOUTR23), Address offset: 1DCh */
__IO uint32_t DOUTR24; /*!< MDIOS Output Data Register (MDIOS_DOUTR24), Address offset: 1E0h */
__IO uint32_t DOUTR25; /*!< MDIOS Output Data Register (MDIOS_DOUTR25), Address offset: 1E4h */
__IO uint32_t DOUTR26; /*!< MDIOS Output Data Register (MDIOS_DOUTR26), Address offset: 1E8h */
__IO uint32_t DOUTR27; /*!< MDIOS Output Data Register (MDIOS_DOUTR27), Address offset: 1ECh */
__IO uint32_t DOUTR28; /*!< MDIOS Output Data Register (MDIOS_DOUTR28), Address offset: 1F0h */
__IO uint32_t DOUTR29; /*!< MDIOS Output Data Register (MDIOS_DOUTR29), Address offset: 1F4h */
__IO uint32_t DOUTR30; /*!< MDIOS Output Data Register (MDIOS_DOUTR30), Address offset: 1F8h */
__IO uint32_t DOUTR31; /*!< MDIOS Output Data Register (MDIOS_DOUTR31), Address offset: 1FCh */
} MDIOS_TypeDef;
/** @addtogroup Peripheral_memory_map
* @{
*/
#define RAMITCM_BASE 0x00000000U /*!< Base address of : 16KB RAM reserved for CPU execution/instruction accessible over ITCM */
#define FLASHITCM_BASE 0x00200000U /*!< Base address of : (up to 2 MB) embedded FLASH memory accessible over ITCM */
#define FLASHAXI_BASE 0x08000000U /*!< Base address of : (up to 2 MB) embedded FLASH memory accessible over AXI */
#define RAMDTCM_BASE 0x20000000U /*!< Base address of : 128KB system data RAM accessible over DTCM */
#define PERIPH_BASE 0x40000000U /*!< Base address of : AHB/ABP Peripherals */
#define BKPSRAM_BASE 0x40024000U /*!< Base address of : Backup SRAM(4 KB) */
#define QSPI_BASE 0x90000000U /*!< Base address of : QSPI memories accessible over AXI */
#define FMC_R_BASE 0xA0000000U /*!< Base address of : FMC Control registers */
#define QSPI_R_BASE 0xA0001000U /*!< Base address of : QSPI Control registers */
#define SRAM1_BASE 0x20020000U /*!< Base address of : 368KB RAM1 accessible over AXI/AHB */
#define SRAM2_BASE 0x2007C000U /*!< Base address of : 16KB RAM2 accessible over AXI/AHB */
#define FLASH_END 0x081FFFFFU /*!< FLASH end address */
/* Legacy define */
#define FLASH_BASE FLASHAXI_BASE
/*!< Peripheral memory map */
#define APB1PERIPH_BASE PERIPH_BASE
#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000U)
#define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000U)
#define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000U)
/*!< APB1 peripherals */
#define TIM2_BASE (APB1PERIPH_BASE + 0x0000U)
#define TIM3_BASE (APB1PERIPH_BASE + 0x0400U)
#define TIM4_BASE (APB1PERIPH_BASE + 0x0800U)
#define TIM5_BASE (APB1PERIPH_BASE + 0x0C00U)
#define TIM6_BASE (APB1PERIPH_BASE + 0x1000U)
#define TIM7_BASE (APB1PERIPH_BASE + 0x1400U)
#define TIM12_BASE (APB1PERIPH_BASE + 0x1800U)
#define TIM13_BASE (APB1PERIPH_BASE + 0x1C00U)
#define TIM14_BASE (APB1PERIPH_BASE + 0x2000U)
#define LPTIM1_BASE (APB1PERIPH_BASE + 0x2400U)
#define RTC_BASE (APB1PERIPH_BASE + 0x2800U)
#define WWDG_BASE (APB1PERIPH_BASE + 0x2C00U)
#define IWDG_BASE (APB1PERIPH_BASE + 0x3000U)
#define CAN3_BASE (APB1PERIPH_BASE + 0x3400U)
#define SPI2_BASE (APB1PERIPH_BASE + 0x3800U)
#define SPI3_BASE (APB1PERIPH_BASE + 0x3C00U)
#define SPDIFRX_BASE (APB1PERIPH_BASE + 0x4000U)
#define USART2_BASE (APB1PERIPH_BASE + 0x4400U)
#define USART3_BASE (APB1PERIPH_BASE + 0x4800U)
#define UART4_BASE (APB1PERIPH_BASE + 0x4C00U)
#define UART5_BASE (APB1PERIPH_BASE + 0x5000U)
#define I2C1_BASE (APB1PERIPH_BASE + 0x5400U)
#define I2C2_BASE (APB1PERIPH_BASE + 0x5800U)
#define I2C3_BASE (APB1PERIPH_BASE + 0x5C00U)
#define I2C4_BASE (APB1PERIPH_BASE + 0x6000U)
#define CAN1_BASE (APB1PERIPH_BASE + 0x6400U)
#define CAN2_BASE (APB1PERIPH_BASE + 0x6800U)
#define CEC_BASE (APB1PERIPH_BASE + 0x6C00U)
#define PWR_BASE (APB1PERIPH_BASE + 0x7000U)
#define DAC_BASE (APB1PERIPH_BASE + 0x7400U)
#define UART7_BASE (APB1PERIPH_BASE + 0x7800U)
#define UART8_BASE (APB1PERIPH_BASE + 0x7C00U)
/*!< APB2 peripherals */
#define TIM1_BASE (APB2PERIPH_BASE + 0x0000U)
#define TIM8_BASE (APB2PERIPH_BASE + 0x0400U)
#define USART1_BASE (APB2PERIPH_BASE + 0x1000U)
#define USART6_BASE (APB2PERIPH_BASE + 0x1400U)
#define SDMMC2_BASE (APB2PERIPH_BASE + 0x1C00U)
#define ADC1_BASE (APB2PERIPH_BASE + 0x2000U)
#define ADC2_BASE (APB2PERIPH_BASE + 0x2100U)
#define ADC3_BASE (APB2PERIPH_BASE + 0x2200U)
#define ADC_BASE (APB2PERIPH_BASE + 0x2300U)
#define SDMMC1_BASE (APB2PERIPH_BASE + 0x2C00U)
#define SPI1_BASE (APB2PERIPH_BASE + 0x3000U)
#define SPI4_BASE (APB2PERIPH_BASE + 0x3400U)
#define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800U)
#define EXTI_BASE (APB2PERIPH_BASE + 0x3C00U)
#define TIM9_BASE (APB2PERIPH_BASE + 0x4000U)
#define TIM10_BASE (APB2PERIPH_BASE + 0x4400U)
#define TIM11_BASE (APB2PERIPH_BASE + 0x4800U)
#define SPI5_BASE (APB2PERIPH_BASE + 0x5000U)
#define SPI6_BASE (APB2PERIPH_BASE + 0x5400U)
#define SAI1_BASE (APB2PERIPH_BASE + 0x5800U)
#define SAI2_BASE (APB2PERIPH_BASE + 0x5C00U)
#define SAI1_Block_A_BASE (SAI1_BASE + 0x004U)
#define SAI1_Block_B_BASE (SAI1_BASE + 0x024U)
#define SAI2_Block_A_BASE (SAI2_BASE + 0x004U)
#define SAI2_Block_B_BASE (SAI2_BASE + 0x024U)
#define DFSDM1_BASE (APB2PERIPH_BASE + 0x7400U)
#define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00U)
#define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20U)
#define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40U)
#define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60U)
#define DFSDM1_Channel4_BASE (DFSDM1_BASE + 0x80U)
#define DFSDM1_Channel5_BASE (DFSDM1_BASE + 0xA0U)
#define DFSDM1_Channel6_BASE (DFSDM1_BASE + 0xC0U)
#define DFSDM1_Channel7_BASE (DFSDM1_BASE + 0xE0U)
#define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100U)
#define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180U)
#define DFSDM1_Filter2_BASE (DFSDM1_BASE + 0x200U)
#define DFSDM1_Filter3_BASE (DFSDM1_BASE + 0x280U)
#define MDIOS_BASE (APB2PERIPH_BASE + 0x7800U)
/*!< AHB1 peripherals */
#define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U)
#define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400U)
#define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800U)
#define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00U)
#define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000U)
#define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400U)
#define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800U)
#define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00U)
#define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000U)
#define GPIOJ_BASE (AHB1PERIPH_BASE + 0x2400U)
#define GPIOK_BASE (AHB1PERIPH_BASE + 0x2800U)
#define CRC_BASE (AHB1PERIPH_BASE + 0x3000U)
#define RCC_BASE (AHB1PERIPH_BASE + 0x3800U)
#define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00U)
#define UID_BASE 0x1FF0F420U /*!< Unique device ID register base address */
#define FLASHSIZE_BASE 0x1FF0F442U /*!< FLASH Size register base address */
#define PACKAGESIZE_BASE 0x1FFF7BF0U /*!< Package size register base address */
#define DMA1_BASE (AHB1PERIPH_BASE + 0x6000U)
#define DMA1_Stream0_BASE (DMA1_BASE + 0x010U)
#define DMA1_Stream1_BASE (DMA1_BASE + 0x028U)
#define DMA1_Stream2_BASE (DMA1_BASE + 0x040U)
#define DMA1_Stream3_BASE (DMA1_BASE + 0x058U)
#define DMA1_Stream4_BASE (DMA1_BASE + 0x070U)
#define DMA1_Stream5_BASE (DMA1_BASE + 0x088U)
#define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0U)
#define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8U)
#define DMA2_BASE (AHB1PERIPH_BASE + 0x6400U)
#define DMA2_Stream0_BASE (DMA2_BASE + 0x010U)
#define DMA2_Stream1_BASE (DMA2_BASE + 0x028U)
#define DMA2_Stream2_BASE (DMA2_BASE + 0x040U)
#define DMA2_Stream3_BASE (DMA2_BASE + 0x058U)
#define DMA2_Stream4_BASE (DMA2_BASE + 0x070U)
#define DMA2_Stream5_BASE (DMA2_BASE + 0x088U)
#define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0U)
#define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8U)
#define ETH_BASE (AHB1PERIPH_BASE + 0x8000U)
#define ETH_MAC_BASE (ETH_BASE)
#define ETH_MMC_BASE (ETH_BASE + 0x0100U)
#define ETH_PTP_BASE (ETH_BASE + 0x0700U)
#define ETH_DMA_BASE (ETH_BASE + 0x1000U)
#define DMA2D_BASE (AHB1PERIPH_BASE + 0xB000U)
/*!< AHB2 peripherals */
#define DCMI_BASE (AHB2PERIPH_BASE + 0x50000U)
#define RNG_BASE (AHB2PERIPH_BASE + 0x60800U)
/*!< FMC Bankx registers base address */
#define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000U)
#define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104U)
#define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080U)
#define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140U)
/* Debug MCU registers base address */
#define DBGMCU_BASE 0xE0042000U
/*!< USB registers base address */
#define USB_OTG_HS_PERIPH_BASE 0x40040000U
#define USB_OTG_FS_PERIPH_BASE 0x50000000U
#define USB_OTG_GLOBAL_BASE 0x000U
#define USB_OTG_DEVICE_BASE 0x800U
#define USB_OTG_IN_ENDPOINT_BASE 0x900U
#define USB_OTG_OUT_ENDPOINT_BASE 0xB00U
#define USB_OTG_EP_REG_SIZE 0x20U
#define USB_OTG_HOST_BASE 0x400U
#define USB_OTG_HOST_PORT_BASE 0x440U
#define USB_OTG_HOST_CHANNEL_BASE 0x500U
#define USB_OTG_HOST_CHANNEL_SIZE 0x20U
#define USB_OTG_PCGCCTL_BASE 0xE00U
#define USB_OTG_FIFO_BASE 0x1000U
#define USB_OTG_FIFO_SIZE 0x1000U
/**
* @}
*/
/** @addtogroup Peripheral_declaration
* @{
*/
#define TIM2 ((TIM_TypeDef *) TIM2_BASE)
#define TIM3 ((TIM_TypeDef *) TIM3_BASE)
#define TIM4 ((TIM_TypeDef *) TIM4_BASE)
#define TIM5 ((TIM_TypeDef *) TIM5_BASE)
#define TIM6 ((TIM_TypeDef *) TIM6_BASE)
#define TIM7 ((TIM_TypeDef *) TIM7_BASE)
#define TIM12 ((TIM_TypeDef *) TIM12_BASE)
#define TIM13 ((TIM_TypeDef *) TIM13_BASE)
#define TIM14 ((TIM_TypeDef *) TIM14_BASE)
#define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE)
#define RTC ((RTC_TypeDef *) RTC_BASE)
#define WWDG ((WWDG_TypeDef *) WWDG_BASE)
#define IWDG ((IWDG_TypeDef *) IWDG_BASE)
#define SPI2 ((SPI_TypeDef *) SPI2_BASE)
#define SPI3 ((SPI_TypeDef *) SPI3_BASE)
#define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE)
#define USART2 ((USART_TypeDef *) USART2_BASE)
#define USART3 ((USART_TypeDef *) USART3_BASE)
#define UART4 ((USART_TypeDef *) UART4_BASE)
#define UART5 ((USART_TypeDef *) UART5_BASE)
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
#define I2C3 ((I2C_TypeDef *) I2C3_BASE)
#define I2C4 ((I2C_TypeDef *) I2C4_BASE)
#define CAN1 ((CAN_TypeDef *) CAN1_BASE)
#define CAN2 ((CAN_TypeDef *) CAN2_BASE)
#define CEC ((CEC_TypeDef *) CEC_BASE)
#define PWR ((PWR_TypeDef *) PWR_BASE)
#define DAC ((DAC_TypeDef *) DAC_BASE)
#define UART7 ((USART_TypeDef *) UART7_BASE)
#define UART8 ((USART_TypeDef *) UART8_BASE)
#define TIM1 ((TIM_TypeDef *) TIM1_BASE)
#define TIM8 ((TIM_TypeDef *) TIM8_BASE)
#define USART1 ((USART_TypeDef *) USART1_BASE)
#define USART6 ((USART_TypeDef *) USART6_BASE)
#define ADC ((ADC_Common_TypeDef *) ADC_BASE)
#define ADC1 ((ADC_TypeDef *) ADC1_BASE)
#define ADC2 ((ADC_TypeDef *) ADC2_BASE)
#define ADC3 ((ADC_TypeDef *) ADC3_BASE)
#define SDMMC1 ((SDMMC_TypeDef *) SDMMC1_BASE)
#define SPI1 ((SPI_TypeDef *) SPI1_BASE)
#define SPI4 ((SPI_TypeDef *) SPI4_BASE)
#define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE)
#define EXTI ((EXTI_TypeDef *) EXTI_BASE)
#define TIM9 ((TIM_TypeDef *) TIM9_BASE)
#define TIM10 ((TIM_TypeDef *) TIM10_BASE)
#define TIM11 ((TIM_TypeDef *) TIM11_BASE)
#define SPI5 ((SPI_TypeDef *) SPI5_BASE)
#define SPI6 ((SPI_TypeDef *) SPI6_BASE)
#define SAI1 ((SAI_TypeDef *) SAI1_BASE)
#define SAI2 ((SAI_TypeDef *) SAI2_BASE)
#define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE)
#define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE)
#define SAI2_Block_A ((SAI_Block_TypeDef *)SAI2_Block_A_BASE)
#define SAI2_Block_B ((SAI_Block_TypeDef *)SAI2_Block_B_BASE)
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE)
#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE)
#define GPIOF ((GPIO_TypeDef *) GPIOF_BASE)
#define GPIOG ((GPIO_TypeDef *) GPIOG_BASE)
#define GPIOH ((GPIO_TypeDef *) GPIOH_BASE)
#define GPIOI ((GPIO_TypeDef *) GPIOI_BASE)
#define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE)
#define GPIOK ((GPIO_TypeDef *) GPIOK_BASE)
#define CRC ((CRC_TypeDef *) CRC_BASE)
#define RCC ((RCC_TypeDef *) RCC_BASE)
#define FLASH ((FLASH_TypeDef *) FLASH_R_BASE)
#define DMA1 ((DMA_TypeDef *) DMA1_BASE)
#define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE)
#define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE)
#define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE)
#define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE)
#define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE)
#define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE)
#define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE)
#define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE)
#define DMA2 ((DMA_TypeDef *) DMA2_BASE)
#define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE)
#define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE)
#define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE)
#define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE)
#define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE)
#define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE)
#define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE)
#define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE)
#define ETH ((ETH_TypeDef *) ETH_BASE)
#define DMA2D ((DMA2D_TypeDef *)DMA2D_BASE)
#define DCMI ((DCMI_TypeDef *) DCMI_BASE)
#define RNG ((RNG_TypeDef *) RNG_BASE)
#define FMC_Bank1 ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE)
#define FMC_Bank1E ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE)
#define FMC_Bank3 ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE)
#define FMC_Bank5_6 ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE)
#define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE)
#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE)
#define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE)
#define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE)
#define CAN3 ((CAN_TypeDef *) CAN3_BASE)
#define SDMMC2 ((SDMMC_TypeDef *) SDMMC2_BASE)
#define MDIOS ((MDIOS_TypeDef *) MDIOS_BASE)
#define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE)
#define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE)
#define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE)
#define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE)
#define DFSDM1_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel4_BASE)
#define DFSDM1_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel5_BASE)
#define DFSDM1_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel6_BASE)
#define DFSDM1_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel7_BASE)
#define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE)
#define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE)
#define DFSDM1_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter2_BASE)
#define DFSDM1_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter3_BASE)
/**
* @}
*/
/** @addtogroup Exported_constants
* @{
*/
/** @addtogroup Peripheral_Registers_Bits_Definition
* @{
*/
/******************************************************************************/
/* Peripheral Registers_Bits_Definition */
/******************************************************************************/
/******************************************************************************/
/* */
/* Analog to Digital Converter */
/* */
/******************************************************************************/
/******************** Bit definition for ADC_SR register ********************/
#define ADC_SR_AWD 0x00000001U /*!<Analog watchdog flag */
#define ADC_SR_EOC 0x00000002U /*!<End of conversion */
#define ADC_SR_JEOC 0x00000004U /*!<Injected channel end of conversion */
#define ADC_SR_JSTRT 0x00000008U /*!<Injected channel Start flag */
#define ADC_SR_STRT 0x00000010U /*!<Regular channel Start flag */
#define ADC_SR_OVR 0x00000020U /*!<Overrun flag */
/******************* Bit definition for ADC_CR1 register ********************/
#define ADC_CR1_AWDCH 0x0000001FU /*!<AWDCH[4:0] bits (Analog watchdog channel select bits) */
#define ADC_CR1_AWDCH_0 0x00000001U /*!<Bit 0 */
#define ADC_CR1_AWDCH_1 0x00000002U /*!<Bit 1 */
#define ADC_CR1_AWDCH_2 0x00000004U /*!<Bit 2 */
#define ADC_CR1_AWDCH_3 0x00000008U /*!<Bit 3 */
#define ADC_CR1_AWDCH_4 0x00000010U /*!<Bit 4 */
#define ADC_CR1_EOCIE 0x00000020U /*!<Interrupt enable for EOC */
#define ADC_CR1_AWDIE 0x00000040U /*!<AAnalog Watchdog interrupt enable */
#define ADC_CR1_JEOCIE 0x00000080U /*!<Interrupt enable for injected channels */
#define ADC_CR1_SCAN 0x00000100U /*!<Scan mode */
#define ADC_CR1_AWDSGL 0x00000200U /*!<Enable the watchdog on a single channel in scan mode */
#define ADC_CR1_JAUTO 0x00000400U /*!<Automatic injected group conversion */
#define ADC_CR1_DISCEN 0x00000800U /*!<Discontinuous mode on regular channels */
#define ADC_CR1_JDISCEN 0x00001000U /*!<Discontinuous mode on injected channels */
#define ADC_CR1_DISCNUM 0x0000E000U /*!<DISCNUM[2:0] bits (Discontinuous mode channel count) */
#define ADC_CR1_DISCNUM_0 0x00002000U /*!<Bit 0 */
#define ADC_CR1_DISCNUM_1 0x00004000U /*!<Bit 1 */
#define ADC_CR1_DISCNUM_2 0x00008000U /*!<Bit 2 */
#define ADC_CR1_JAWDEN 0x00400000U /*!<Analog watchdog enable on injected channels */
#define ADC_CR1_AWDEN 0x00800000U /*!<Analog watchdog enable on regular channels */
#define ADC_CR1_RES 0x03000000U /*!<RES[2:0] bits (Resolution) */
#define ADC_CR1_RES_0 0x01000000U /*!<Bit 0 */
#define ADC_CR1_RES_1 0x02000000U /*!<Bit 1 */
#define ADC_CR1_OVRIE 0x04000000U /*!<overrun interrupt enable */
/******************* Bit definition for ADC_CR2 register ********************/
#define ADC_CR2_ADON 0x00000001U /*!<A/D Converter ON / OFF */
#define ADC_CR2_CONT 0x00000002U /*!<Continuous Conversion */
#define ADC_CR2_DMA 0x00000100U /*!<Direct Memory access mode */
#define ADC_CR2_DDS 0x00000200U /*!<DMA disable selection (Single ADC) */
#define ADC_CR2_EOCS 0x00000400U /*!<End of conversion selection */
#define ADC_CR2_ALIGN 0x00000800U /*!<Data Alignment */
#define ADC_CR2_JEXTSEL 0x000F0000U /*!<JEXTSEL[3:0] bits (External event select for injected group) */
#define ADC_CR2_JEXTSEL_0 0x00010000U /*!<Bit 0 */
#define ADC_CR2_JEXTSEL_1 0x00020000U /*!<Bit 1 */
#define ADC_CR2_JEXTSEL_2 0x00040000U /*!<Bit 2 */
#define ADC_CR2_JEXTSEL_3 0x00080000U /*!<Bit 3 */
#define ADC_CR2_JEXTEN 0x00300000U /*!<JEXTEN[1:0] bits (External Trigger Conversion mode for injected channelsp) */
#define ADC_CR2_JEXTEN_0 0x00100000U /*!<Bit 0 */
#define ADC_CR2_JEXTEN_1 0x00200000U /*!<Bit 1 */
#define ADC_CR2_JSWSTART 0x00400000U /*!<Start Conversion of injected channels */
#define ADC_CR2_EXTSEL 0x0F000000U /*!<EXTSEL[3:0] bits (External Event Select for regular group) */
#define ADC_CR2_EXTSEL_0 0x01000000U /*!<Bit 0 */
#define ADC_CR2_EXTSEL_1 0x02000000U /*!<Bit 1 */
#define ADC_CR2_EXTSEL_2 0x04000000U /*!<Bit 2 */
#define ADC_CR2_EXTSEL_3 0x08000000U /*!<Bit 3 */
#define ADC_CR2_EXTEN 0x30000000U /*!<EXTEN[1:0] bits (External Trigger Conversion mode for regular channelsp) */
#define ADC_CR2_EXTEN_0 0x10000000U /*!<Bit 0 */
#define ADC_CR2_EXTEN_1 0x20000000U /*!<Bit 1 */
#define ADC_CR2_SWSTART 0x40000000U /*!<Start Conversion of regular channels */
/****************** Bit definition for ADC_SMPR1 register *******************/
#define ADC_SMPR1_SMP10 0x00000007U /*!<SMP10[2:0] bits (Channel 10 Sample time selection) */
#define ADC_SMPR1_SMP10_0 0x00000001U /*!<Bit 0 */
#define ADC_SMPR1_SMP10_1 0x00000002U /*!<Bit 1 */
#define ADC_SMPR1_SMP10_2 0x00000004U /*!<Bit 2 */
#define ADC_SMPR1_SMP11 0x00000038U /*!<SMP11[2:0] bits (Channel 11 Sample time selection) */
#define ADC_SMPR1_SMP11_0 0x00000008U /*!<Bit 0 */
#define ADC_SMPR1_SMP11_1 0x00000010U /*!<Bit 1 */
#define ADC_SMPR1_SMP11_2 0x00000020U /*!<Bit 2 */
#define ADC_SMPR1_SMP12 0x000001C0U /*!<SMP12[2:0] bits (Channel 12 Sample time selection) */
#define ADC_SMPR1_SMP12_0 0x00000040U /*!<Bit 0 */
#define ADC_SMPR1_SMP12_1 0x00000080U /*!<Bit 1 */
#define ADC_SMPR1_SMP12_2 0x00000100U /*!<Bit 2 */
#define ADC_SMPR1_SMP13 0x00000E00U /*!<SMP13[2:0] bits (Channel 13 Sample time selection) */
#define ADC_SMPR1_SMP13_0 0x00000200U /*!<Bit 0 */
#define ADC_SMPR1_SMP13_1 0x00000400U /*!<Bit 1 */
#define ADC_SMPR1_SMP13_2 0x00000800U /*!<Bit 2 */
#define ADC_SMPR1_SMP14 0x00007000U /*!<SMP14[2:0] bits (Channel 14 Sample time selection) */
#define ADC_SMPR1_SMP14_0 0x00001000U /*!<Bit 0 */
#define ADC_SMPR1_SMP14_1 0x00002000U /*!<Bit 1 */
#define ADC_SMPR1_SMP14_2 0x00004000U /*!<Bit 2 */
#define ADC_SMPR1_SMP15 0x00038000U /*!<SMP15[2:0] bits (Channel 15 Sample time selection) */
#define ADC_SMPR1_SMP15_0 0x00008000U /*!<Bit 0 */
#define ADC_SMPR1_SMP15_1 0x00010000U /*!<Bit 1 */
#define ADC_SMPR1_SMP15_2 0x00020000U /*!<Bit 2 */
#define ADC_SMPR1_SMP16 0x001C0000U /*!<SMP16[2:0] bits (Channel 16 Sample time selection) */
#define ADC_SMPR1_SMP16_0 0x00040000U /*!<Bit 0 */
#define ADC_SMPR1_SMP16_1 0x00080000U /*!<Bit 1 */
#define ADC_SMPR1_SMP16_2 0x00100000U /*!<Bit 2 */
#define ADC_SMPR1_SMP17 0x00E00000U /*!<SMP17[2:0] bits (Channel 17 Sample time selection) */
#define ADC_SMPR1_SMP17_0 0x00200000U /*!<Bit 0 */
#define ADC_SMPR1_SMP17_1 0x00400000U /*!<Bit 1 */
#define ADC_SMPR1_SMP17_2 0x00800000U /*!<Bit 2 */
#define ADC_SMPR1_SMP18 0x07000000U /*!<SMP18[2:0] bits (Channel 18 Sample time selection) */
#define ADC_SMPR1_SMP18_0 0x01000000U /*!<Bit 0 */
#define ADC_SMPR1_SMP18_1 0x02000000U /*!<Bit 1 */
#define ADC_SMPR1_SMP18_2 0x04000000U /*!<Bit 2 */
/****************** Bit definition for ADC_SMPR2 register *******************/
#define ADC_SMPR2_SMP0 0x00000007U /*!<SMP0[2:0] bits (Channel 0 Sample time selection) */
#define ADC_SMPR2_SMP0_0 0x00000001U /*!<Bit 0 */
#define ADC_SMPR2_SMP0_1 0x00000002U /*!<Bit 1 */
#define ADC_SMPR2_SMP0_2 0x00000004U /*!<Bit 2 */
#define ADC_SMPR2_SMP1 0x00000038U /*!<SMP1[2:0] bits (Channel 1 Sample time selection) */
#define ADC_SMPR2_SMP1_0 0x00000008U /*!<Bit 0 */
#define ADC_SMPR2_SMP1_1 0x00000010U /*!<Bit 1 */
#define ADC_SMPR2_SMP1_2 0x00000020U /*!<Bit 2 */
#define ADC_SMPR2_SMP2 0x000001C0U /*!<SMP2[2:0] bits (Channel 2 Sample time selection) */
#define ADC_SMPR2_SMP2_0 0x00000040U /*!<Bit 0 */
#define ADC_SMPR2_SMP2_1 0x00000080U /*!<Bit 1 */
#define ADC_SMPR2_SMP2_2 0x00000100U /*!<Bit 2 */
#define ADC_SMPR2_SMP3 0x00000E00U /*!<SMP3[2:0] bits (Channel 3 Sample time selection) */
#define ADC_SMPR2_SMP3_0 0x00000200U /*!<Bit 0 */
#define ADC_SMPR2_SMP3_1 0x00000400U /*!<Bit 1 */
#define ADC_SMPR2_SMP3_2 0x00000800U /*!<Bit 2 */
#define ADC_SMPR2_SMP4 0x00007000U /*!<SMP4[2:0] bits (Channel 4 Sample time selection) */
#define ADC_SMPR2_SMP4_0 0x00001000U /*!<Bit 0 */
#define ADC_SMPR2_SMP4_1 0x00002000U /*!<Bit 1 */
#define ADC_SMPR2_SMP4_2 0x00004000U /*!<Bit 2 */
#define ADC_SMPR2_SMP5 0x00038000U /*!<SMP5[2:0] bits (Channel 5 Sample time selection) */
#define ADC_SMPR2_SMP5_0 0x00008000U /*!<Bit 0 */
#define ADC_SMPR2_SMP5_1 0x00010000U /*!<Bit 1 */
#define ADC_SMPR2_SMP5_2 0x00020000U /*!<Bit 2 */
#define ADC_SMPR2_SMP6 0x001C0000U /*!<SMP6[2:0] bits (Channel 6 Sample time selection) */
#define ADC_SMPR2_SMP6_0 0x00040000U /*!<Bit 0 */
#define ADC_SMPR2_SMP6_1 0x00080000U /*!<Bit 1 */
#define ADC_SMPR2_SMP6_2 0x00100000U /*!<Bit 2 */
#define ADC_SMPR2_SMP7 0x00E00000U /*!<SMP7[2:0] bits (Channel 7 Sample time selection) */
#define ADC_SMPR2_SMP7_0 0x00200000U /*!<Bit 0 */
#define ADC_SMPR2_SMP7_1 0x00400000U /*!<Bit 1 */
#define ADC_SMPR2_SMP7_2 0x00800000U /*!<Bit 2 */
#define ADC_SMPR2_SMP8 0x07000000U /*!<SMP8[2:0] bits (Channel 8 Sample time selection) */
#define ADC_SMPR2_SMP8_0 0x01000000U /*!<Bit 0 */
#define ADC_SMPR2_SMP8_1 0x02000000U /*!<Bit 1 */
#define ADC_SMPR2_SMP8_2 0x04000000U /*!<Bit 2 */
#define ADC_SMPR2_SMP9 0x38000000U /*!<SMP9[2:0] bits (Channel 9 Sample time selection) */
#define ADC_SMPR2_SMP9_0 0x08000000U /*!<Bit 0 */
#define ADC_SMPR2_SMP9_1 0x10000000U /*!<Bit 1 */
#define ADC_SMPR2_SMP9_2 0x20000000U /*!<Bit 2 */
/****************** Bit definition for ADC_JOFR1 register *******************/
#define ADC_JOFR1_JOFFSET1 0x0FFFU /*!<Data offset for injected channel 1 */
/****************** Bit definition for ADC_JOFR2 register *******************/
#define ADC_JOFR2_JOFFSET2 0x0FFFU /*!<Data offset for injected channel 2 */
/****************** Bit definition for ADC_JOFR3 register *******************/
#define ADC_JOFR3_JOFFSET3 0x0FFFU /*!<Data offset for injected channel 3 */
/****************** Bit definition for ADC_JOFR4 register *******************/
#define ADC_JOFR4_JOFFSET4 0x0FFFU /*!<Data offset for injected channel 4 */
/******************* Bit definition for ADC_HTR register ********************/
#define ADC_HTR_HT 0x0FFFU /*!<Analog watchdog high threshold */
/******************* Bit definition for ADC_LTR register ********************/
#define ADC_LTR_LT 0x0FFFU /*!<Analog watchdog low threshold */
/******************* Bit definition for ADC_SQR1 register *******************/
#define ADC_SQR1_SQ13 0x0000001FU /*!<SQ13[4:0] bits (13th conversion in regular sequence) */
#define ADC_SQR1_SQ13_0 0x00000001U /*!<Bit 0 */
#define ADC_SQR1_SQ13_1 0x00000002U /*!<Bit 1 */
#define ADC_SQR1_SQ13_2 0x00000004U /*!<Bit 2 */
#define ADC_SQR1_SQ13_3 0x00000008U /*!<Bit 3 */
#define ADC_SQR1_SQ13_4 0x00000010U /*!<Bit 4 */
#define ADC_SQR1_SQ14 0x000003E0U /*!<SQ14[4:0] bits (14th conversion in regular sequence) */
#define ADC_SQR1_SQ14_0 0x00000020U /*!<Bit 0 */
#define ADC_SQR1_SQ14_1 0x00000040U /*!<Bit 1 */
#define ADC_SQR1_SQ14_2 0x00000080U /*!<Bit 2 */
#define ADC_SQR1_SQ14_3 0x00000100U /*!<Bit 3 */
#define ADC_SQR1_SQ14_4 0x00000200U /*!<Bit 4 */
#define ADC_SQR1_SQ15 0x00007C00U /*!<SQ15[4:0] bits (15th conversion in regular sequence) */
#define ADC_SQR1_SQ15_0 0x00000400U /*!<Bit 0 */
#define ADC_SQR1_SQ15_1 0x00000800U /*!<Bit 1 */
#define ADC_SQR1_SQ15_2 0x00001000U /*!<Bit 2 */
#define ADC_SQR1_SQ15_3 0x00002000U /*!<Bit 3 */
#define ADC_SQR1_SQ15_4 0x00004000U /*!<Bit 4 */
#define ADC_SQR1_SQ16 0x000F8000U /*!<SQ16[4:0] bits (16th conversion in regular sequence) */
#define ADC_SQR1_SQ16_0 0x00008000U /*!<Bit 0 */
#define ADC_SQR1_SQ16_1 0x00010000U /*!<Bit 1 */
#define ADC_SQR1_SQ16_2 0x00020000U /*!<Bit 2 */
#define ADC_SQR1_SQ16_3 0x00040000U /*!<Bit 3 */
#define ADC_SQR1_SQ16_4 0x00080000U /*!<Bit 4 */
#define ADC_SQR1_L 0x00F00000U /*!<L[3:0] bits (Regular channel sequence length) */
#define ADC_SQR1_L_0 0x00100000U /*!<Bit 0 */
#define ADC_SQR1_L_1 0x00200000U /*!<Bit 1 */
#define ADC_SQR1_L_2 0x00400000U /*!<Bit 2 */
#define ADC_SQR1_L_3 0x00800000U /*!<Bit 3 */
/******************* Bit definition for ADC_SQR2 register *******************/
#define ADC_SQR2_SQ7 0x0000001FU /*!<SQ7[4:0] bits (7th conversion in regular sequence) */
#define ADC_SQR2_SQ7_0 0x00000001U /*!<Bit 0 */
#define ADC_SQR2_SQ7_1 0x00000002U /*!<Bit 1 */
#define ADC_SQR2_SQ7_2 0x00000004U /*!<Bit 2 */
#define ADC_SQR2_SQ7_3 0x00000008U /*!<Bit 3 */
#define ADC_SQR2_SQ7_4 0x00000010U /*!<Bit 4 */
#define ADC_SQR2_SQ8 0x000003E0U /*!<SQ8[4:0] bits (8th conversion in regular sequence) */
#define ADC_SQR2_SQ8_0 0x00000020U /*!<Bit 0 */
#define ADC_SQR2_SQ8_1 0x00000040U /*!<Bit 1 */
#define ADC_SQR2_SQ8_2 0x00000080U /*!<Bit 2 */
#define ADC_SQR2_SQ8_3 0x00000100U /*!<Bit 3 */
#define ADC_SQR2_SQ8_4 0x00000200U /*!<Bit 4 */
#define ADC_SQR2_SQ9 0x00007C00U /*!<SQ9[4:0] bits (9th conversion in regular sequence) */
#define ADC_SQR2_SQ9_0 0x00000400U /*!<Bit 0 */
#define ADC_SQR2_SQ9_1 0x00000800U /*!<Bit 1 */
#define ADC_SQR2_SQ9_2 0x00001000U /*!<Bit 2 */
#define ADC_SQR2_SQ9_3 0x00002000U /*!<Bit 3 */
#define ADC_SQR2_SQ9_4 0x00004000U /*!<Bit 4 */
#define ADC_SQR2_SQ10 0x000F8000U /*!<SQ10[4:0] bits (10th conversion in regular sequence) */
#define ADC_SQR2_SQ10_0 0x00008000U /*!<Bit 0 */
#define ADC_SQR2_SQ10_1 0x00010000U /*!<Bit 1 */
#define ADC_SQR2_SQ10_2 0x00020000U /*!<Bit 2 */
#define ADC_SQR2_SQ10_3 0x00040000U /*!<Bit 3 */
#define ADC_SQR2_SQ10_4 0x00080000U /*!<Bit 4 */
#define ADC_SQR2_SQ11 0x01F00000U /*!<SQ11[4:0] bits (11th conversion in regular sequence) */
#define ADC_SQR2_SQ11_0 0x00100000U /*!<Bit 0 */
#define ADC_SQR2_SQ11_1 0x00200000U /*!<Bit 1 */
#define ADC_SQR2_SQ11_2 0x00400000U /*!<Bit 2 */
#define ADC_SQR2_SQ11_3 0x00800000U /*!<Bit 3 */
#define ADC_SQR2_SQ11_4 0x01000000U /*!<Bit 4 */
#define ADC_SQR2_SQ12 0x3E000000U /*!<SQ12[4:0] bits (12th conversion in regular sequence) */
#define ADC_SQR2_SQ12_0 0x02000000U /*!<Bit 0 */
#define ADC_SQR2_SQ12_1 0x04000000U /*!<Bit 1 */
#define ADC_SQR2_SQ12_2 0x08000000U /*!<Bit 2 */
#define ADC_SQR2_SQ12_3 0x10000000U /*!<Bit 3 */
#define ADC_SQR2_SQ12_4 0x20000000U /*!<Bit 4 */
/******************* Bit definition for ADC_SQR3 register *******************/
#define ADC_SQR3_SQ1 0x0000001FU /*!<SQ1[4:0] bits (1st conversion in regular sequence) */
#define ADC_SQR3_SQ1_0 0x00000001U /*!<Bit 0 */
#define ADC_SQR3_SQ1_1 0x00000002U /*!<Bit 1 */
#define ADC_SQR3_SQ1_2 0x00000004U /*!<Bit 2 */
#define ADC_SQR3_SQ1_3 0x00000008U /*!<Bit 3 */
#define ADC_SQR3_SQ1_4 0x00000010U /*!<Bit 4 */
#define ADC_SQR3_SQ2 0x000003E0U /*!<SQ2[4:0] bits (2nd conversion in regular sequence) */
#define ADC_SQR3_SQ2_0 0x00000020U /*!<Bit 0 */
#define ADC_SQR3_SQ2_1 0x00000040U /*!<Bit 1 */
#define ADC_SQR3_SQ2_2 0x00000080U /*!<Bit 2 */
#define ADC_SQR3_SQ2_3 0x00000100U /*!<Bit 3 */
#define ADC_SQR3_SQ2_4 0x00000200U /*!<Bit 4 */
#define ADC_SQR3_SQ3 0x00007C00U /*!<SQ3[4:0] bits (3rd conversion in regular sequence) */
#define ADC_SQR3_SQ3_0 0x00000400U /*!<Bit 0 */
#define ADC_SQR3_SQ3_1 0x00000800U /*!<Bit 1 */
#define ADC_SQR3_SQ3_2 0x00001000U /*!<Bit 2 */
#define ADC_SQR3_SQ3_3 0x00002000U /*!<Bit 3 */
#define ADC_SQR3_SQ3_4 0x00004000U /*!<Bit 4 */
#define ADC_SQR3_SQ4 0x000F8000U /*!<SQ4[4:0] bits (4th conversion in regular sequence) */
#define ADC_SQR3_SQ4_0 0x00008000U /*!<Bit 0 */
#define ADC_SQR3_SQ4_1 0x00010000U /*!<Bit 1 */
#define ADC_SQR3_SQ4_2 0x00020000U /*!<Bit 2 */
#define ADC_SQR3_SQ4_3 0x00040000U /*!<Bit 3 */
#define ADC_SQR3_SQ4_4 0x00080000U /*!<Bit 4 */
#define ADC_SQR3_SQ5 0x01F00000U /*!<SQ5[4:0] bits (5th conversion in regular sequence) */
#define ADC_SQR3_SQ5_0 0x00100000U /*!<Bit 0 */
#define ADC_SQR3_SQ5_1 0x00200000U /*!<Bit 1 */
#define ADC_SQR3_SQ5_2 0x00400000U /*!<Bit 2 */
#define ADC_SQR3_SQ5_3 0x00800000U /*!<Bit 3 */
#define ADC_SQR3_SQ5_4 0x01000000U /*!<Bit 4 */
#define ADC_SQR3_SQ6 0x3E000000U /*!<SQ6[4:0] bits (6th conversion in regular sequence) */
#define ADC_SQR3_SQ6_0 0x02000000U /*!<Bit 0 */
#define ADC_SQR3_SQ6_1 0x04000000U /*!<Bit 1 */
#define ADC_SQR3_SQ6_2 0x08000000U /*!<Bit 2 */
#define ADC_SQR3_SQ6_3 0x10000000U /*!<Bit 3 */
#define ADC_SQR3_SQ6_4 0x20000000U /*!<Bit 4 */
/******************* Bit definition for ADC_JSQR register *******************/
#define ADC_JSQR_JSQ1 0x0000001FU /*!<JSQ1[4:0] bits (1st conversion in injected sequence) */
#define ADC_JSQR_JSQ1_0 0x00000001U /*!<Bit 0 */
#define ADC_JSQR_JSQ1_1 0x00000002U /*!<Bit 1 */
#define ADC_JSQR_JSQ1_2 0x00000004U /*!<Bit 2 */
#define ADC_JSQR_JSQ1_3 0x00000008U /*!<Bit 3 */
#define ADC_JSQR_JSQ1_4 0x00000010U /*!<Bit 4 */
#define ADC_JSQR_JSQ2 0x000003E0U /*!<JSQ2[4:0] bits (2nd conversion in injected sequence) */
#define ADC_JSQR_JSQ2_0 0x00000020U /*!<Bit 0 */
#define ADC_JSQR_JSQ2_1 0x00000040U /*!<Bit 1 */
#define ADC_JSQR_JSQ2_2 0x00000080U /*!<Bit 2 */
#define ADC_JSQR_JSQ2_3 0x00000100U /*!<Bit 3 */
#define ADC_JSQR_JSQ2_4 0x00000200U /*!<Bit 4 */
#define ADC_JSQR_JSQ3 0x00007C00U /*!<JSQ3[4:0] bits (3rd conversion in injected sequence) */
#define ADC_JSQR_JSQ3_0 0x00000400U /*!<Bit 0 */
#define ADC_JSQR_JSQ3_1 0x00000800U /*!<Bit 1 */
#define ADC_JSQR_JSQ3_2 0x00001000U /*!<Bit 2 */
#define ADC_JSQR_JSQ3_3 0x00002000U /*!<Bit 3 */
#define ADC_JSQR_JSQ3_4 0x00004000U /*!<Bit 4 */
#define ADC_JSQR_JSQ4 0x000F8000U /*!<JSQ4[4:0] bits (4th conversion in injected sequence) */
#define ADC_JSQR_JSQ4_0 0x00008000U /*!<Bit 0 */
#define ADC_JSQR_JSQ4_1 0x00010000U /*!<Bit 1 */
#define ADC_JSQR_JSQ4_2 0x00020000U /*!<Bit 2 */
#define ADC_JSQR_JSQ4_3 0x00040000U /*!<Bit 3 */
#define ADC_JSQR_JSQ4_4 0x00080000U /*!<Bit 4 */
#define ADC_JSQR_JL 0x00300000U /*!<JL[1:0] bits (Injected Sequence length) */
#define ADC_JSQR_JL_0 0x00100000U /*!<Bit 0 */
#define ADC_JSQR_JL_1 0x00200000U /*!<Bit 1 */
/******************* Bit definition for ADC_JDR1 register *******************/
#define ADC_JDR1_JDATA ((uint16_t)0xFFFFU) /*!<Injected data */
/******************* Bit definition for ADC_JDR2 register *******************/
#define ADC_JDR2_JDATA ((uint16_t)0xFFFFU) /*!<Injected data */
/******************* Bit definition for ADC_JDR3 register *******************/
#define ADC_JDR3_JDATA ((uint16_t)0xFFFFU) /*!<Injected data */
/******************* Bit definition for ADC_JDR4 register *******************/
#define ADC_JDR4_JDATA ((uint16_t)0xFFFFU) /*!<Injected data */
/******************** Bit definition for ADC_DR register ********************/
#define ADC_DR_DATA 0x0000FFFFU /*!<Regular data */
#define ADC_DR_ADC2DATA 0xFFFF0000U /*!<ADC2 data */
/******************* Bit definition for ADC_CSR register ********************/
#define ADC_CSR_AWD1 0x00000001U /*!<ADC1 Analog watchdog flag */
#define ADC_CSR_EOC1 0x00000002U /*!<ADC1 End of conversion */
#define ADC_CSR_JEOC1 0x00000004U /*!<ADC1 Injected channel end of conversion */
#define ADC_CSR_JSTRT1 0x00000008U /*!<ADC1 Injected channel Start flag */
#define ADC_CSR_STRT1 0x00000010U /*!<ADC1 Regular channel Start flag */
#define ADC_CSR_OVR1 0x00000020U /*!<ADC1 Overrun flag */
#define ADC_CSR_AWD2 0x00000100U /*!<ADC2 Analog watchdog flag */
#define ADC_CSR_EOC2 0x00000200U /*!<ADC2 End of conversion */
#define ADC_CSR_JEOC2 0x00000400U /*!<ADC2 Injected channel end of conversion */
#define ADC_CSR_JSTRT2 0x00000800U /*!<ADC2 Injected channel Start flag */
#define ADC_CSR_STRT2 0x00001000U /*!<ADC2 Regular channel Start flag */
#define ADC_CSR_OVR2 0x00002000U /*!<ADC2 Overrun flag */
#define ADC_CSR_AWD3 0x00010000U /*!<ADC3 Analog watchdog flag */
#define ADC_CSR_EOC3 0x00020000U /*!<ADC3 End of conversion */
#define ADC_CSR_JEOC3 0x00040000U /*!<ADC3 Injected channel end of conversion */
#define ADC_CSR_JSTRT3 0x00080000U /*!<ADC3 Injected channel Start flag */
#define ADC_CSR_STRT3 0x00100000U /*!<ADC3 Regular channel Start flag */
#define ADC_CSR_OVR3 0x00200000U /*!<ADC3 Overrun flag */
/* Legacy defines */
#define ADC_CSR_DOVR1 ADC_CSR_OVR1
#define ADC_CSR_DOVR2 ADC_CSR_OVR2
#define ADC_CSR_DOVR3 ADC_CSR_OVR3
/******************* Bit definition for ADC_CCR register ********************/
#define ADC_CCR_MULTI 0x0000001FU /*!<MULTI[4:0] bits (Multi-ADC mode selection) */
#define ADC_CCR_MULTI_0 0x00000001U /*!<Bit 0 */
#define ADC_CCR_MULTI_1 0x00000002U /*!<Bit 1 */
#define ADC_CCR_MULTI_2 0x00000004U /*!<Bit 2 */
#define ADC_CCR_MULTI_3 0x00000008U /*!<Bit 3 */
#define ADC_CCR_MULTI_4 0x00000010U /*!<Bit 4 */
#define ADC_CCR_DELAY 0x00000F00U /*!<DELAY[3:0] bits (Delay between 2 sampling phases) */
#define ADC_CCR_DELAY_0 0x00000100U /*!<Bit 0 */
#define ADC_CCR_DELAY_1 0x00000200U /*!<Bit 1 */
#define ADC_CCR_DELAY_2 0x00000400U /*!<Bit 2 */
#define ADC_CCR_DELAY_3 0x00000800U /*!<Bit 3 */
#define ADC_CCR_DDS 0x00002000U /*!<DMA disable selection (Multi-ADC mode) */
#define ADC_CCR_DMA 0x0000C000U /*!<DMA[1:0] bits (Direct Memory Access mode for multimode) */
#define ADC_CCR_DMA_0 0x00004000U /*!<Bit 0 */
#define ADC_CCR_DMA_1 0x00008000U /*!<Bit 1 */
#define ADC_CCR_ADCPRE 0x00030000U /*!<ADCPRE[1:0] bits (ADC prescaler) */
#define ADC_CCR_ADCPRE_0 0x00010000U /*!<Bit 0 */
#define ADC_CCR_ADCPRE_1 0x00020000U /*!<Bit 1 */
#define ADC_CCR_VBATE 0x00400000U /*!<VBAT Enable */
#define ADC_CCR_TSVREFE 0x00800000U /*!<Temperature Sensor and VREFINT Enable */
/******************* Bit definition for ADC_CDR register ********************/
#define ADC_CDR_DATA1 0x0000FFFFU /*!<1st data of a pair of regular conversions */
#define ADC_CDR_DATA2 0xFFFF0000U /*!<2nd data of a pair of regular conversions */
/******************************************************************************/
/* */
/* Controller Area Network */
/* */
/******************************************************************************/
/*!<CAN control and status registers */
/******************* Bit definition for CAN_MCR register ********************/
#define CAN_MCR_INRQ 0x00000001U /*!<Initialization Request */
#define CAN_MCR_SLEEP 0x00000002U /*!<Sleep Mode Request */
#define CAN_MCR_TXFP 0x00000004U /*!<Transmit FIFO Priority */
#define CAN_MCR_RFLM 0x00000008U /*!<Receive FIFO Locked Mode */
#define CAN_MCR_NART 0x00000010U /*!<No Automatic Retransmission */
#define CAN_MCR_AWUM 0x00000020U /*!<Automatic Wakeup Mode */
#define CAN_MCR_ABOM 0x00000040U /*!<Automatic Bus-Off Management */
#define CAN_MCR_TTCM 0x00000080U /*!<Time Triggered Communication Mode */
#define CAN_MCR_RESET 0x00008000U /*!<bxCAN software master reset */
/******************* Bit definition for CAN_MSR register ********************/
#define CAN_MSR_INAK 0x00000001U /*!<Initialization Acknowledge */
#define CAN_MSR_SLAK 0x00000002U /*!<Sleep Acknowledge */
#define CAN_MSR_ERRI 0x00000004U /*!<Error Interrupt */
#define CAN_MSR_WKUI 0x00000008U /*!<Wakeup Interrupt */
#define CAN_MSR_SLAKI 0x00000010U /*!<Sleep Acknowledge Interrupt */
#define CAN_MSR_TXM 0x00000100U /*!<Transmit Mode */
#define CAN_MSR_RXM 0x00000200U /*!<Receive Mode */
#define CAN_MSR_SAMP 0x00000400U /*!<Last Sample Point */
#define CAN_MSR_RX 0x00000800U /*!<CAN Rx Signal */
/******************* Bit definition for CAN_TSR register ********************/
#define CAN_TSR_RQCP0 0x00000001U /*!<Request Completed Mailbox0 */
#define CAN_TSR_TXOK0 0x00000002U /*!<Transmission OK of Mailbox0 */
#define CAN_TSR_ALST0 0x00000004U /*!<Arbitration Lost for Mailbox0 */
#define CAN_TSR_TERR0 0x00000008U /*!<Transmission Error of Mailbox0 */
#define CAN_TSR_ABRQ0 0x00000080U /*!<Abort Request for Mailbox0 */
#define CAN_TSR_RQCP1 0x00000100U /*!<Request Completed Mailbox1 */
#define CAN_TSR_TXOK1 0x00000200U /*!<Transmission OK of Mailbox1 */
#define CAN_TSR_ALST1 0x00000400U /*!<Arbitration Lost for Mailbox1 */
#define CAN_TSR_TERR1 0x00000800U /*!<Transmission Error of Mailbox1 */
#define CAN_TSR_ABRQ1 0x00008000U /*!<Abort Request for Mailbox 1 */
#define CAN_TSR_RQCP2 0x00010000U /*!<Request Completed Mailbox2 */
#define CAN_TSR_TXOK2 0x00020000U /*!<Transmission OK of Mailbox 2 */
#define CAN_TSR_ALST2 0x00040000U /*!<Arbitration Lost for mailbox 2 */
#define CAN_TSR_TERR2 0x00080000U /*!<Transmission Error of Mailbox 2 */
#define CAN_TSR_ABRQ2 0x00800000U /*!<Abort Request for Mailbox 2 */
#define CAN_TSR_CODE 0x03000000U /*!<Mailbox Code */
#define CAN_TSR_TME 0x1C000000U /*!<TME[2:0] bits */
#define CAN_TSR_TME0 0x04000000U /*!<Transmit Mailbox 0 Empty */
#define CAN_TSR_TME1 0x08000000U /*!<Transmit Mailbox 1 Empty */
#define CAN_TSR_TME2 0x10000000U /*!<Transmit Mailbox 2 Empty */
#define CAN_TSR_LOW 0xE0000000U /*!<LOW[2:0] bits */
#define CAN_TSR_LOW0 0x20000000U /*!<Lowest Priority Flag for Mailbox 0 */
#define CAN_TSR_LOW1 0x40000000U /*!<Lowest Priority Flag for Mailbox 1 */
#define CAN_TSR_LOW2 0x80000000U /*!<Lowest Priority Flag for Mailbox 2 */
/******************* Bit definition for CAN_RF0R register *******************/
#define CAN_RF0R_FMP0 0x00000003U /*!<FIFO 0 Message Pending */
#define CAN_RF0R_FULL0 0x00000008U /*!<FIFO 0 Full */
#define CAN_RF0R_FOVR0 0x00000010U /*!<FIFO 0 Overrun */
#define CAN_RF0R_RFOM0 0x00000020U /*!<Release FIFO 0 Output Mailbox */
/******************* Bit definition for CAN_RF1R register *******************/
#define CAN_RF1R_FMP1 0x00000003U /*!<FIFO 1 Message Pending */
#define CAN_RF1R_FULL1 0x00000008U /*!<FIFO 1 Full */
#define CAN_RF1R_FOVR1 0x00000010U /*!<FIFO 1 Overrun */
#define CAN_RF1R_RFOM1 0x00000020U /*!<Release FIFO 1 Output Mailbox */
/******************** Bit definition for CAN_IER register *******************/
#define CAN_IER_TMEIE 0x00000001U /*!<Transmit Mailbox Empty Interrupt Enable */
#define CAN_IER_FMPIE0 0x00000002U /*!<FIFO Message Pending Interrupt Enable */
#define CAN_IER_FFIE0 0x00000004U /*!<FIFO Full Interrupt Enable */
#define CAN_IER_FOVIE0 0x00000008U /*!<FIFO Overrun Interrupt Enable */
#define CAN_IER_FMPIE1 0x00000010U /*!<FIFO Message Pending Interrupt Enable */
#define CAN_IER_FFIE1 0x00000020U /*!<FIFO Full Interrupt Enable */
#define CAN_IER_FOVIE1 0x00000040U /*!<FIFO Overrun Interrupt Enable */
#define CAN_IER_EWGIE 0x00000100U /*!<Error Warning Interrupt Enable */
#define CAN_IER_EPVIE 0x00000200U /*!<Error Passive Interrupt Enable */
#define CAN_IER_BOFIE 0x00000400U /*!<Bus-Off Interrupt Enable */
#define CAN_IER_LECIE 0x00000800U /*!<Last Error Code Interrupt Enable */
#define CAN_IER_ERRIE 0x00008000U /*!<Error Interrupt Enable */
#define CAN_IER_WKUIE 0x00010000U /*!<Wakeup Interrupt Enable */
#define CAN_IER_SLKIE 0x00020000U /*!<Sleep Interrupt Enable */
/******************** Bit definition for CAN_ESR register *******************/
#define CAN_ESR_EWGF 0x00000001U /*!<Error Warning Flag */
#define CAN_ESR_EPVF 0x00000002U /*!<Error Passive Flag */
#define CAN_ESR_BOFF 0x00000004U /*!<Bus-Off Flag */
#define CAN_ESR_LEC 0x00000070U /*!<LEC[2:0] bits (Last Error Code) */
#define CAN_ESR_LEC_0 0x00000010U /*!<Bit 0 */
#define CAN_ESR_LEC_1 0x00000020U /*!<Bit 1 */
#define CAN_ESR_LEC_2 0x00000040U /*!<Bit 2 */
#define CAN_ESR_TEC 0x00FF0000U /*!<Least significant byte of the 9-bit Transmit Error Counter */
#define CAN_ESR_REC 0xFF000000U /*!<Receive Error Counter */
/******************* Bit definition for CAN_BTR register ********************/
#define CAN_BTR_BRP 0x000003FFU /*!<Baud Rate Prescaler */
#define CAN_BTR_TS1 0x000F0000U /*!<Time Segment 1 */
#define CAN_BTR_TS1_0 0x00010000U /*!<Bit 0 */
#define CAN_BTR_TS1_1 0x00020000U /*!<Bit 1 */
#define CAN_BTR_TS1_2 0x00040000U /*!<Bit 2 */
#define CAN_BTR_TS1_3 0x00080000U /*!<Bit 3 */
#define CAN_BTR_TS2 0x00700000U /*!<Time Segment 2 */
#define CAN_BTR_TS2_0 0x00100000U /*!<Bit 0 */
#define CAN_BTR_TS2_1 0x00200000U /*!<Bit 1 */
#define CAN_BTR_TS2_2 0x00400000U /*!<Bit 2 */
#define CAN_BTR_SJW 0x03000000U /*!<Resynchronization Jump Width */
#define CAN_BTR_SJW_0 0x01000000U /*!<Bit 0 */
#define CAN_BTR_SJW_1 0x02000000U /*!<Bit 1 */
#define CAN_BTR_LBKM 0x40000000U /*!<Loop Back Mode (Debug) */
#define CAN_BTR_SILM 0x80000000U /*!<Silent Mode */
/*!<Mailbox registers */
/****************** Bit definition for CAN_TI0R register ********************/
#define CAN_TI0R_TXRQ 0x00000001U /*!<Transmit Mailbox Request */
#define CAN_TI0R_RTR 0x00000002U /*!<Remote Transmission Request */
#define CAN_TI0R_IDE 0x00000004U /*!<Identifier Extension */
#define CAN_TI0R_EXID 0x001FFFF8U /*!<Extended Identifier */
#define CAN_TI0R_STID 0xFFE00000U /*!<Standard Identifier or Extended Identifier */
/****************** Bit definition for CAN_TDT0R register *******************/
#define CAN_TDT0R_DLC 0x0000000FU /*!<Data Length Code */
#define CAN_TDT0R_TGT 0x00000100U /*!<Transmit Global Time */
#define CAN_TDT0R_TIME 0xFFFF0000U /*!<Message Time Stamp */
/****************** Bit definition for CAN_TDL0R register *******************/
#define CAN_TDL0R_DATA0 0x000000FFU /*!<Data byte 0 */
#define CAN_TDL0R_DATA1 0x0000FF00U /*!<Data byte 1 */
#define CAN_TDL0R_DATA2 0x00FF0000U /*!<Data byte 2 */
#define CAN_TDL0R_DATA3 0xFF000000U /*!<Data byte 3 */
/****************** Bit definition for CAN_TDH0R register *******************/
#define CAN_TDH0R_DATA4 0x000000FFU /*!<Data byte 4 */
#define CAN_TDH0R_DATA5 0x0000FF00U /*!<Data byte 5 */
#define CAN_TDH0R_DATA6 0x00FF0000U /*!<Data byte 6 */
#define CAN_TDH0R_DATA7 0xFF000000U /*!<Data byte 7 */
/******************* Bit definition for CAN_TI1R register *******************/
#define CAN_TI1R_TXRQ 0x00000001U /*!<Transmit Mailbox Request */
#define CAN_TI1R_RTR 0x00000002U /*!<Remote Transmission Request */
#define CAN_TI1R_IDE 0x00000004U /*!<Identifier Extension */
#define CAN_TI1R_EXID 0x001FFFF8U /*!<Extended Identifier */
#define CAN_TI1R_STID 0xFFE00000U /*!<Standard Identifier or Extended Identifier */
/******************* Bit definition for CAN_TDT1R register ******************/
#define CAN_TDT1R_DLC 0x0000000FU /*!<Data Length Code */
#define CAN_TDT1R_TGT 0x00000100U /*!<Transmit Global Time */
#define CAN_TDT1R_TIME 0xFFFF0000U /*!<Message Time Stamp */
/******************* Bit definition for CAN_TDL1R register ******************/
#define CAN_TDL1R_DATA0 0x000000FFU /*!<Data byte 0 */
#define CAN_TDL1R_DATA1 0x0000FF00U /*!<Data byte 1 */
#define CAN_TDL1R_DATA2 0x00FF0000U /*!<Data byte 2 */
#define CAN_TDL1R_DATA3 0xFF000000U /*!<Data byte 3 */
/******************* Bit definition for CAN_TDH1R register ******************/
#define CAN_TDH1R_DATA4 0x000000FFU /*!<Data byte 4 */
#define CAN_TDH1R_DATA5 0x0000FF00U /*!<Data byte 5 */
#define CAN_TDH1R_DATA6 0x00FF0000U /*!<Data byte 6 */
#define CAN_TDH1R_DATA7 0xFF000000U /*!<Data byte 7 */
/******************* Bit definition for CAN_TI2R register *******************/
#define CAN_TI2R_TXRQ 0x00000001U /*!<Transmit Mailbox Request */
#define CAN_TI2R_RTR 0x00000002U /*!<Remote Transmission Request */
#define CAN_TI2R_IDE 0x00000004U /*!<Identifier Extension */
#define CAN_TI2R_EXID 0x001FFFF8U /*!<Extended identifier */
#define CAN_TI2R_STID 0xFFE00000U /*!<Standard Identifier or Extended Identifier */
/******************* Bit definition for CAN_TDT2R register ******************/
#define CAN_TDT2R_DLC 0x0000000FU /*!<Data Length Code */
#define CAN_TDT2R_TGT 0x00000100U /*!<Transmit Global Time */
#define CAN_TDT2R_TIME 0xFFFF0000U /*!<Message Time Stamp */
/******************* Bit definition for CAN_TDL2R register ******************/
#define CAN_TDL2R_DATA0 0x000000FFU /*!<Data byte 0 */
#define CAN_TDL2R_DATA1 0x0000FF00U /*!<Data byte 1 */
#define CAN_TDL2R_DATA2 0x00FF0000U /*!<Data byte 2 */
#define CAN_TDL2R_DATA3 0xFF000000U /*!<Data byte 3 */
/******************* Bit definition for CAN_TDH2R register ******************/
#define CAN_TDH2R_DATA4 0x000000FFU /*!<Data byte 4 */
#define CAN_TDH2R_DATA5 0x0000FF00U /*!<Data byte 5 */
#define CAN_TDH2R_DATA6 0x00FF0000U /*!<Data byte 6 */
#define CAN_TDH2R_DATA7 0xFF000000U /*!<Data byte 7 */
/******************* Bit definition for CAN_RI0R register *******************/
#define CAN_RI0R_RTR 0x00000002U /*!<Remote Transmission Request */
#define CAN_RI0R_IDE 0x00000004U /*!<Identifier Extension */
#define CAN_RI0R_EXID 0x001FFFF8U /*!<Extended Identifier */
#define CAN_RI0R_STID 0xFFE00000U /*!<Standard Identifier or Extended Identifier */
/******************* Bit definition for CAN_RDT0R register ******************/
#define CAN_RDT0R_DLC 0x0000000FU /*!<Data Length Code */
#define CAN_RDT0R_FMI 0x0000FF00U /*!<Filter Match Index */
#define CAN_RDT0R_TIME 0xFFFF0000U /*!<Message Time Stamp */
/******************* Bit definition for CAN_RDL0R register ******************/
#define CAN_RDL0R_DATA0 0x000000FFU /*!<Data byte 0 */
#define CAN_RDL0R_DATA1 0x0000FF00U /*!<Data byte 1 */
#define CAN_RDL0R_DATA2 0x00FF0000U /*!<Data byte 2 */
#define CAN_RDL0R_DATA3 0xFF000000U /*!<Data byte 3 */
/******************* Bit definition for CAN_RDH0R register ******************/
#define CAN_RDH0R_DATA4 0x000000FFU /*!<Data byte 4 */
#define CAN_RDH0R_DATA5 0x0000FF00U /*!<Data byte 5 */
#define CAN_RDH0R_DATA6 0x00FF0000U /*!<Data byte 6 */
#define CAN_RDH0R_DATA7 0xFF000000U /*!<Data byte 7 */
/******************* Bit definition for CAN_RI1R register *******************/
#define CAN_RI1R_RTR 0x00000002U /*!<Remote Transmission Request */
#define CAN_RI1R_IDE 0x00000004U /*!<Identifier Extension */
#define CAN_RI1R_EXID 0x001FFFF8U /*!<Extended identifier */
#define CAN_RI1R_STID 0xFFE00000U /*!<Standard Identifier or Extended Identifier */
/******************* Bit definition for CAN_RDT1R register ******************/
#define CAN_RDT1R_DLC 0x0000000FU /*!<Data Length Code */
#define CAN_RDT1R_FMI 0x0000FF00U /*!<Filter Match Index */
#define CAN_RDT1R_TIME 0xFFFF0000U /*!<Message Time Stamp */
/******************* Bit definition for CAN_RDL1R register ******************/
#define CAN_RDL1R_DATA0 0x000000FFU /*!<Data byte 0 */
#define CAN_RDL1R_DATA1 0x0000FF00U /*!<Data byte 1 */
#define CAN_RDL1R_DATA2 0x00FF0000U /*!<Data byte 2 */
#define CAN_RDL1R_DATA3 0xFF000000U /*!<Data byte 3 */
/******************* Bit definition for CAN_RDH1R register ******************/
#define CAN_RDH1R_DATA4 0x000000FFU /*!<Data byte 4 */
#define CAN_RDH1R_DATA5 0x0000FF00U /*!<Data byte 5 */
#define CAN_RDH1R_DATA6 0x00FF0000U /*!<Data byte 6 */
#define CAN_RDH1R_DATA7 0xFF000000U /*!<Data byte 7 */
/*!<CAN filter registers */
/******************* Bit definition for CAN_FMR register ********************/
#define CAN_FMR_FINIT ((uint8_t)0x01U) /*!<Filter Init Mode */
#define CAN_FMR_CAN2SB 0x00003F00U /*!<CAN2 start bank */
/******************* Bit definition for CAN_FM1R register *******************/
#define CAN_FM1R_FBM 0x3FFFU /*!<Filter Mode */
#define CAN_FM1R_FBM0 0x0001U /*!<Filter Init Mode bit 0 */
#define CAN_FM1R_FBM1 0x0002U /*!<Filter Init Mode bit 1 */
#define CAN_FM1R_FBM2 0x0004U /*!<Filter Init Mode bit 2 */
#define CAN_FM1R_FBM3 0x0008U /*!<Filter Init Mode bit 3 */
#define CAN_FM1R_FBM4 0x0010U /*!<Filter Init Mode bit 4 */
#define CAN_FM1R_FBM5 0x0020U /*!<Filter Init Mode bit 5 */
#define CAN_FM1R_FBM6 0x0040U /*!<Filter Init Mode bit 6 */
#define CAN_FM1R_FBM7 0x0080U /*!<Filter Init Mode bit 7 */
#define CAN_FM1R_FBM8 0x0100U /*!<Filter Init Mode bit 8 */
#define CAN_FM1R_FBM9 0x0200U /*!<Filter Init Mode bit 9 */
#define CAN_FM1R_FBM10 0x0400U /*!<Filter Init Mode bit 10 */
#define CAN_FM1R_FBM11 0x0800U /*!<Filter Init Mode bit 11 */
#define CAN_FM1R_FBM12 0x1000U /*!<Filter Init Mode bit 12 */
#define CAN_FM1R_FBM13 0x2000U /*!<Filter Init Mode bit 13 */
/******************* Bit definition for CAN_FS1R register *******************/
#define CAN_FS1R_FSC 0x00003FFFU /*!<Filter Scale Configuration */
#define CAN_FS1R_FSC0 0x00000001U /*!<Filter Scale Configuration bit 0 */
#define CAN_FS1R_FSC1 0x00000002U /*!<Filter Scale Configuration bit 1 */
#define CAN_FS1R_FSC2 0x00000004U /*!<Filter Scale Configuration bit 2 */
#define CAN_FS1R_FSC3 0x00000008U /*!<Filter Scale Configuration bit 3 */
#define CAN_FS1R_FSC4 0x00000010U /*!<Filter Scale Configuration bit 4 */
#define CAN_FS1R_FSC5 0x00000020U /*!<Filter Scale Configuration bit 5 */
#define CAN_FS1R_FSC6 0x00000040U /*!<Filter Scale Configuration bit 6 */
#define CAN_FS1R_FSC7 0x00000080U /*!<Filter Scale Configuration bit 7 */
#define CAN_FS1R_FSC8 0x00000100U /*!<Filter Scale Configuration bit 8 */
#define CAN_FS1R_FSC9 0x00000200U /*!<Filter Scale Configuration bit 9 */
#define CAN_FS1R_FSC10 0x00000400U /*!<Filter Scale Configuration bit 10 */
#define CAN_FS1R_FSC11 0x00000800U /*!<Filter Scale Configuration bit 11 */
#define CAN_FS1R_FSC12 0x00001000U /*!<Filter Scale Configuration bit 12 */
#define CAN_FS1R_FSC13 0x00002000U /*!<Filter Scale Configuration bit 13 */
/****************** Bit definition for CAN_FFA1R register *******************/
#define CAN_FFA1R_FFA 0x00003FFFU /*!<Filter FIFO Assignment */
#define CAN_FFA1R_FFA0 0x00000001U /*!<Filter FIFO Assignment for Filter 0 */
#define CAN_FFA1R_FFA1 0x00000002U /*!<Filter FIFO Assignment for Filter 1 */
#define CAN_FFA1R_FFA2 0x00000004U /*!<Filter FIFO Assignment for Filter 2 */
#define CAN_FFA1R_FFA3 0x00000008U /*!<Filter FIFO Assignment for Filter 3 */
#define CAN_FFA1R_FFA4 0x00000010U /*!<Filter FIFO Assignment for Filter 4 */
#define CAN_FFA1R_FFA5 0x00000020U /*!<Filter FIFO Assignment for Filter 5 */
#define CAN_FFA1R_FFA6 0x00000040U /*!<Filter FIFO Assignment for Filter 6 */
#define CAN_FFA1R_FFA7 0x00000080U /*!<Filter FIFO Assignment for Filter 7 */
#define CAN_FFA1R_FFA8 0x00000100U /*!<Filter FIFO Assignment for Filter 8 */
#define CAN_FFA1R_FFA9 0x00000200U /*!<Filter FIFO Assignment for Filter 9 */
#define CAN_FFA1R_FFA10 0x00000400U /*!<Filter FIFO Assignment for Filter 10 */
#define CAN_FFA1R_FFA11 0x00000800U /*!<Filter FIFO Assignment for Filter 11 */
#define CAN_FFA1R_FFA12 0x00001000U /*!<Filter FIFO Assignment for Filter 12 */
#define CAN_FFA1R_FFA13 0x00002000U /*!<Filter FIFO Assignment for Filter 13 */
/******************* Bit definition for CAN_FA1R register *******************/
#define CAN_FA1R_FACT 0x00003FFFU /*!<Filter Active */
#define CAN_FA1R_FACT0 0x00000001U /*!<Filter 0 Active */
#define CAN_FA1R_FACT1 0x00000002U /*!<Filter 1 Active */
#define CAN_FA1R_FACT2 0x00000004U /*!<Filter 2 Active */
#define CAN_FA1R_FACT3 0x00000008U /*!<Filter 3 Active */
#define CAN_FA1R_FACT4 0x00000010U /*!<Filter 4 Active */
#define CAN_FA1R_FACT5 0x00000020U /*!<Filter 5 Active */
#define CAN_FA1R_FACT6 0x00000040U /*!<Filter 6 Active */
#define CAN_FA1R_FACT7 0x00000080U /*!<Filter 7 Active */
#define CAN_FA1R_FACT8 0x00000100U /*!<Filter 8 Active */
#define CAN_FA1R_FACT9 0x00000200U /*!<Filter 9 Active */
#define CAN_FA1R_FACT10 0x00000400U /*!<Filter 10 Active */
#define CAN_FA1R_FACT11 0x00000800U /*!<Filter 11 Active */
#define CAN_FA1R_FACT12 0x00001000U /*!<Filter 12 Active */
#define CAN_FA1R_FACT13 0x00002000U /*!<Filter 13 Active */
/******************* Bit definition for CAN_F0R1 register *******************/
#define CAN_F0R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F0R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F0R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F0R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F0R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F0R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F0R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F0R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F0R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F0R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F0R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F0R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F0R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F0R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F0R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F0R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F0R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F0R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F0R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F0R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F0R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F0R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F0R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F0R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F0R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F0R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F0R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F0R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F0R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F0R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F0R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F0R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F1R1 register *******************/
#define CAN_F1R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F1R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F1R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F1R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F1R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F1R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F1R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F1R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F1R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F1R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F1R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F1R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F1R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F1R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F1R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F1R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F1R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F1R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F1R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F1R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F1R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F1R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F1R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F1R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F1R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F1R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F1R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F1R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F1R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F1R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F1R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F1R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F2R1 register *******************/
#define CAN_F2R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F2R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F2R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F2R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F2R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F2R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F2R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F2R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F2R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F2R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F2R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F2R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F2R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F2R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F2R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F2R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F2R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F2R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F2R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F2R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F2R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F2R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F2R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F2R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F2R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F2R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F2R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F2R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F2R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F2R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F2R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F2R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F3R1 register *******************/
#define CAN_F3R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F3R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F3R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F3R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F3R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F3R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F3R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F3R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F3R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F3R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F3R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F3R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F3R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F3R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F3R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F3R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F3R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F3R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F3R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F3R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F3R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F3R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F3R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F3R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F3R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F3R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F3R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F3R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F3R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F3R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F3R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F3R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F4R1 register *******************/
#define CAN_F4R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F4R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F4R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F4R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F4R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F4R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F4R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F4R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F4R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F4R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F4R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F4R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F4R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F4R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F4R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F4R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F4R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F4R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F4R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F4R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F4R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F4R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F4R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F4R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F4R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F4R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F4R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F4R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F4R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F4R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F4R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F4R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F5R1 register *******************/
#define CAN_F5R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F5R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F5R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F5R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F5R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F5R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F5R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F5R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F5R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F5R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F5R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F5R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F5R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F5R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F5R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F5R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F5R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F5R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F5R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F5R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F5R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F5R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F5R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F5R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F5R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F5R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F5R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F5R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F5R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F5R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F5R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F5R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F6R1 register *******************/
#define CAN_F6R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F6R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F6R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F6R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F6R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F6R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F6R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F6R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F6R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F6R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F6R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F6R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F6R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F6R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F6R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F6R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F6R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F6R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F6R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F6R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F6R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F6R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F6R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F6R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F6R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F6R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F6R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F6R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F6R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F6R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F6R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F6R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F7R1 register *******************/
#define CAN_F7R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F7R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F7R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F7R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F7R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F7R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F7R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F7R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F7R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F7R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F7R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F7R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F7R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F7R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F7R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F7R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F7R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F7R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F7R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F7R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F7R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F7R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F7R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F7R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F7R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F7R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F7R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F7R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F7R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F7R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F7R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F7R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F8R1 register *******************/
#define CAN_F8R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F8R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F8R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F8R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F8R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F8R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F8R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F8R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F8R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F8R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F8R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F8R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F8R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F8R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F8R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F8R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F8R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F8R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F8R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F8R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F8R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F8R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F8R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F8R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F8R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F8R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F8R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F8R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F8R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F8R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F8R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F8R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F9R1 register *******************/
#define CAN_F9R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F9R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F9R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F9R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F9R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F9R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F9R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F9R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F9R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F9R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F9R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F9R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F9R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F9R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F9R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F9R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F9R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F9R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F9R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F9R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F9R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F9R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F9R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F9R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F9R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F9R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F9R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F9R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F9R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F9R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F9R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F9R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F10R1 register ******************/
#define CAN_F10R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F10R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F10R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F10R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F10R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F10R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F10R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F10R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F10R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F10R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F10R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F10R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F10R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F10R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F10R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F10R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F10R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F10R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F10R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F10R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F10R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F10R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F10R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F10R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F10R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F10R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F10R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F10R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F10R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F10R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F10R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F10R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F11R1 register ******************/
#define CAN_F11R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F11R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F11R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F11R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F11R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F11R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F11R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F11R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F11R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F11R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F11R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F11R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F11R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F11R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F11R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F11R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F11R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F11R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F11R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F11R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F11R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F11R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F11R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F11R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F11R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F11R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F11R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F11R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F11R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F11R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F11R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F11R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F12R1 register ******************/
#define CAN_F12R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F12R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F12R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F12R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F12R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F12R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F12R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F12R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F12R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F12R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F12R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F12R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F12R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F12R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F12R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F12R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F12R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F12R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F12R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F12R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F12R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F12R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F12R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F12R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F12R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F12R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F12R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F12R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F12R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F12R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F12R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F12R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F13R1 register ******************/
#define CAN_F13R1_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F13R1_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F13R1_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F13R1_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F13R1_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F13R1_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F13R1_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F13R1_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F13R1_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F13R1_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F13R1_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F13R1_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F13R1_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F13R1_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F13R1_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F13R1_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F13R1_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F13R1_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F13R1_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F13R1_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F13R1_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F13R1_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F13R1_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F13R1_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F13R1_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F13R1_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F13R1_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F13R1_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F13R1_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F13R1_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F13R1_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F13R1_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F0R2 register *******************/
#define CAN_F0R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F0R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F0R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F0R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F0R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F0R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F0R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F0R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F0R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F0R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F0R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F0R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F0R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F0R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F0R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F0R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F0R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F0R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F0R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F0R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F0R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F0R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F0R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F0R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F0R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F0R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F0R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F0R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F0R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F0R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F0R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F0R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F1R2 register *******************/
#define CAN_F1R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F1R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F1R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F1R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F1R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F1R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F1R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F1R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F1R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F1R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F1R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F1R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F1R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F1R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F1R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F1R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F1R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F1R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F1R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F1R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F1R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F1R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F1R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F1R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F1R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F1R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F1R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F1R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F1R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F1R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F1R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F1R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F2R2 register *******************/
#define CAN_F2R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F2R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F2R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F2R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F2R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F2R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F2R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F2R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F2R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F2R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F2R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F2R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F2R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F2R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F2R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F2R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F2R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F2R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F2R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F2R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F2R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F2R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F2R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F2R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F2R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F2R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F2R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F2R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F2R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F2R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F2R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F2R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F3R2 register *******************/
#define CAN_F3R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F3R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F3R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F3R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F3R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F3R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F3R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F3R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F3R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F3R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F3R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F3R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F3R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F3R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F3R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F3R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F3R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F3R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F3R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F3R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F3R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F3R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F3R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F3R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F3R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F3R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F3R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F3R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F3R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F3R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F3R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F3R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F4R2 register *******************/
#define CAN_F4R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F4R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F4R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F4R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F4R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F4R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F4R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F4R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F4R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F4R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F4R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F4R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F4R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F4R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F4R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F4R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F4R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F4R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F4R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F4R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F4R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F4R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F4R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F4R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F4R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F4R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F4R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F4R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F4R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F4R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F4R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F4R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F5R2 register *******************/
#define CAN_F5R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F5R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F5R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F5R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F5R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F5R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F5R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F5R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F5R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F5R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F5R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F5R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F5R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F5R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F5R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F5R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F5R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F5R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F5R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F5R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F5R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F5R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F5R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F5R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F5R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F5R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F5R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F5R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F5R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F5R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F5R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F5R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F6R2 register *******************/
#define CAN_F6R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F6R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F6R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F6R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F6R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F6R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F6R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F6R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F6R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F6R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F6R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F6R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F6R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F6R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F6R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F6R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F6R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F6R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F6R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F6R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F6R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F6R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F6R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F6R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F6R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F6R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F6R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F6R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F6R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F6R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F6R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F6R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F7R2 register *******************/
#define CAN_F7R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F7R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F7R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F7R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F7R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F7R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F7R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F7R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F7R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F7R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F7R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F7R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F7R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F7R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F7R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F7R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F7R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F7R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F7R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F7R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F7R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F7R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F7R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F7R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F7R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F7R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F7R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F7R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F7R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F7R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F7R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F7R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F8R2 register *******************/
#define CAN_F8R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F8R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F8R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F8R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F8R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F8R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F8R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F8R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F8R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F8R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F8R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F8R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F8R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F8R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F8R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F8R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F8R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F8R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F8R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F8R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F8R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F8R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F8R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F8R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F8R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F8R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F8R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F8R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F8R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F8R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F8R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F8R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F9R2 register *******************/
#define CAN_F9R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F9R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F9R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F9R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F9R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F9R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F9R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F9R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F9R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F9R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F9R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F9R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F9R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F9R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F9R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F9R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F9R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F9R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F9R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F9R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F9R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F9R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F9R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F9R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F9R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F9R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F9R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F9R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F9R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F9R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F9R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F9R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F10R2 register ******************/
#define CAN_F10R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F10R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F10R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F10R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F10R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F10R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F10R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F10R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F10R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F10R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F10R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F10R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F10R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F10R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F10R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F10R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F10R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F10R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F10R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F10R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F10R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F10R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F10R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F10R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F10R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F10R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F10R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F10R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F10R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F10R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F10R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F10R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F11R2 register ******************/
#define CAN_F11R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F11R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F11R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F11R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F11R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F11R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F11R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F11R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F11R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F11R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F11R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F11R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F11R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F11R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F11R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F11R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F11R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F11R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F11R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F11R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F11R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F11R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F11R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F11R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F11R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F11R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F11R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F11R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F11R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F11R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F11R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F11R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F12R2 register ******************/
#define CAN_F12R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F12R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F12R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F12R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F12R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F12R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F12R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F12R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F12R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F12R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F12R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F12R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F12R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F12R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F12R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F12R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F12R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F12R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F12R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F12R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F12R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F12R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F12R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F12R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F12R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F12R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F12R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F12R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F12R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F12R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F12R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F12R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************* Bit definition for CAN_F13R2 register ******************/
#define CAN_F13R2_FB0 0x00000001U /*!<Filter bit 0 */
#define CAN_F13R2_FB1 0x00000002U /*!<Filter bit 1 */
#define CAN_F13R2_FB2 0x00000004U /*!<Filter bit 2 */
#define CAN_F13R2_FB3 0x00000008U /*!<Filter bit 3 */
#define CAN_F13R2_FB4 0x00000010U /*!<Filter bit 4 */
#define CAN_F13R2_FB5 0x00000020U /*!<Filter bit 5 */
#define CAN_F13R2_FB6 0x00000040U /*!<Filter bit 6 */
#define CAN_F13R2_FB7 0x00000080U /*!<Filter bit 7 */
#define CAN_F13R2_FB8 0x00000100U /*!<Filter bit 8 */
#define CAN_F13R2_FB9 0x00000200U /*!<Filter bit 9 */
#define CAN_F13R2_FB10 0x00000400U /*!<Filter bit 10 */
#define CAN_F13R2_FB11 0x00000800U /*!<Filter bit 11 */
#define CAN_F13R2_FB12 0x00001000U /*!<Filter bit 12 */
#define CAN_F13R2_FB13 0x00002000U /*!<Filter bit 13 */
#define CAN_F13R2_FB14 0x00004000U /*!<Filter bit 14 */
#define CAN_F13R2_FB15 0x00008000U /*!<Filter bit 15 */
#define CAN_F13R2_FB16 0x00010000U /*!<Filter bit 16 */
#define CAN_F13R2_FB17 0x00020000U /*!<Filter bit 17 */
#define CAN_F13R2_FB18 0x00040000U /*!<Filter bit 18 */
#define CAN_F13R2_FB19 0x00080000U /*!<Filter bit 19 */
#define CAN_F13R2_FB20 0x00100000U /*!<Filter bit 20 */
#define CAN_F13R2_FB21 0x00200000U /*!<Filter bit 21 */
#define CAN_F13R2_FB22 0x00400000U /*!<Filter bit 22 */
#define CAN_F13R2_FB23 0x00800000U /*!<Filter bit 23 */
#define CAN_F13R2_FB24 0x01000000U /*!<Filter bit 24 */
#define CAN_F13R2_FB25 0x02000000U /*!<Filter bit 25 */
#define CAN_F13R2_FB26 0x04000000U /*!<Filter bit 26 */
#define CAN_F13R2_FB27 0x08000000U /*!<Filter bit 27 */
#define CAN_F13R2_FB28 0x10000000U /*!<Filter bit 28 */
#define CAN_F13R2_FB29 0x20000000U /*!<Filter bit 29 */
#define CAN_F13R2_FB30 0x40000000U /*!<Filter bit 30 */
#define CAN_F13R2_FB31 0x80000000U /*!<Filter bit 31 */
/******************************************************************************/
/* */
/* HDMI-CEC (CEC) */
/* */
/******************************************************************************/
/******************* Bit definition for CEC_CR register *********************/
#define CEC_CR_CECEN 0x00000001U /*!< CEC Enable */
#define CEC_CR_TXSOM 0x00000002U /*!< CEC Tx Start Of Message */
#define CEC_CR_TXEOM 0x00000004U /*!< CEC Tx End Of Message */
/******************* Bit definition for CEC_CFGR register *******************/
#define CEC_CFGR_SFT 0x00000007U /*!< CEC Signal Free Time */
#define CEC_CFGR_RXTOL 0x00000008U /*!< CEC Tolerance */
#define CEC_CFGR_BRESTP 0x00000010U /*!< CEC Rx Stop */
#define CEC_CFGR_BREGEN 0x00000020U /*!< CEC Bit Rising Error generation */
#define CEC_CFGR_LBPEGEN 0x00000040U /*!< CEC Long Period Error generation */
#define CEC_CFGR_BRDNOGEN 0x00000080U /*!< CEC Broadcast no Error generation */
#define CEC_CFGR_SFTOPT 0x00000100U /*!< CEC Signal Free Time optional */
#define CEC_CFGR_OAR 0x7FFF0000U /*!< CEC Own Address */
#define CEC_CFGR_LSTN 0x80000000U /*!< CEC Listen mode */
/******************* Bit definition for CEC_TXDR register *******************/
#define CEC_TXDR_TXD 0x000000FFU /*!< CEC Tx Data */
/******************* Bit definition for CEC_RXDR register *******************/
#define CEC_TXDR_RXD 0x000000FFU /*!< CEC Rx Data */
/******************* Bit definition for CEC_ISR register ********************/
#define CEC_ISR_RXBR 0x00000001U /*!< CEC Rx-Byte Received */
#define CEC_ISR_RXEND 0x00000002U /*!< CEC End Of Reception */
#define CEC_ISR_RXOVR 0x00000004U /*!< CEC Rx-Overrun */
#define CEC_ISR_BRE 0x00000008U /*!< CEC Rx Bit Rising Error */
#define CEC_ISR_SBPE 0x00000010U /*!< CEC Rx Short Bit period Error */
#define CEC_ISR_LBPE 0x00000020U /*!< CEC Rx Long Bit period Error */
#define CEC_ISR_RXACKE 0x00000040U /*!< CEC Rx Missing Acknowledge */
#define CEC_ISR_ARBLST 0x00000080U /*!< CEC Arbitration Lost */
#define CEC_ISR_TXBR 0x00000100U /*!< CEC Tx Byte Request */
#define CEC_ISR_TXEND 0x00000200U /*!< CEC End of Transmission */
#define CEC_ISR_TXUDR 0x00000400U /*!< CEC Tx-Buffer Underrun */
#define CEC_ISR_TXERR 0x00000800U /*!< CEC Tx-Error */
#define CEC_ISR_TXACKE 0x00001000U /*!< CEC Tx Missing Acknowledge */
/******************* Bit definition for CEC_IER register ********************/
#define CEC_IER_RXBRIE 0x00000001U /*!< CEC Rx-Byte Received IT Enable */
#define CEC_IER_RXENDIE 0x00000002U /*!< CEC End Of Reception IT Enable */
#define CEC_IER_RXOVRIE 0x00000004U /*!< CEC Rx-Overrun IT Enable */
#define CEC_IER_BREIE 0x00000008U /*!< CEC Rx Bit Rising Error IT Enable */
#define CEC_IER_SBPEIE 0x00000010U /*!< CEC Rx Short Bit period Error IT Enable*/
#define CEC_IER_LBPEIE 0x00000020U /*!< CEC Rx Long Bit period Error IT Enable */
#define CEC_IER_RXACKEIE 0x00000040U /*!< CEC Rx Missing Acknowledge IT Enable */
#define CEC_IER_ARBLSTIE 0x00000080U /*!< CEC Arbitration Lost IT Enable */
#define CEC_IER_TXBRIE 0x00000100U /*!< CEC Tx Byte Request IT Enable */
#define CEC_IER_TXENDIE 0x00000200U /*!< CEC End of Transmission IT Enable */
#define CEC_IER_TXUDRIE 0x00000400U /*!< CEC Tx-Buffer Underrun IT Enable */
#define CEC_IER_TXERRIE 0x00000800U /*!< CEC Tx-Error IT Enable */
#define CEC_IER_TXACKEIE 0x00001000U /*!< CEC Tx Missing Acknowledge IT Enable */
/******************************************************************************/
/* */
/* CRC calculation unit */
/* */
/******************************************************************************/
/******************* Bit definition for CRC_DR register *********************/
#define CRC_DR_DR 0xFFFFFFFFU /*!< Data register bits */
/******************* Bit definition for CRC_IDR register ********************/
#define CRC_IDR_IDR 0x000000FFU /*!< General-purpose 8-bit data register bits */
/******************** Bit definition for CRC_CR register ********************/
#define CRC_CR_RESET 0x00000001U /*!< RESET the CRC computation unit bit */
#define CRC_CR_POLYSIZE 0x00000018U /*!< Polynomial size bits */
#define CRC_CR_POLYSIZE_0 0x00000008U /*!< Polynomial size bit 0 */
#define CRC_CR_POLYSIZE_1 0x00000010U /*!< Polynomial size bit 1 */
#define CRC_CR_REV_IN 0x00000060U /*!< REV_IN Reverse Input Data bits */
#define CRC_CR_REV_IN_0 0x00000020U /*!< Bit 0 */
#define CRC_CR_REV_IN_1 0x00000040U /*!< Bit 1 */
#define CRC_CR_REV_OUT 0x00000080U /*!< REV_OUT Reverse Output Data bits */
/******************* Bit definition for CRC_INIT register *******************/
#define CRC_INIT_INIT 0xFFFFFFFFU /*!< Initial CRC value bits */
/******************* Bit definition for CRC_POL register ********************/
#define CRC_POL_POL 0xFFFFFFFFU /*!< Coefficients of the polynomial */
/******************************************************************************/
/* */
/* Digital to Analog Converter */
/* */
/******************************************************************************/
/******************** Bit definition for DAC_CR register ********************/
#define DAC_CR_EN1 0x00000001U /*!<DAC channel1 enable */
#define DAC_CR_BOFF1 0x00000002U /*!<DAC channel1 output buffer disable */
#define DAC_CR_TEN1 0x00000004U /*!<DAC channel1 Trigger enable */
#define DAC_CR_TSEL1 0x00000038U /*!<TSEL1[2:0] (DAC channel1 Trigger selection) */
#define DAC_CR_TSEL1_0 0x00000008U /*!<Bit 0 */
#define DAC_CR_TSEL1_1 0x00000010U /*!<Bit 1 */
#define DAC_CR_TSEL1_2 0x00000020U /*!<Bit 2 */
#define DAC_CR_WAVE1 0x000000C0U /*!<WAVE1[1:0] (DAC channel1 noise/triangle wave generation enablEU) */
#define DAC_CR_WAVE1_0 0x00000040U /*!<Bit 0 */
#define DAC_CR_WAVE1_1 0x00000080U /*!<Bit 1 */
#define DAC_CR_MAMP1 0x00000F00U /*!<MAMP1[3:0] (DAC channel1 Mask/Amplitude selector) */
#define DAC_CR_MAMP1_0 0x00000100U /*!<Bit 0 */
#define DAC_CR_MAMP1_1 0x00000200U /*!<Bit 1 */
#define DAC_CR_MAMP1_2 0x00000400U /*!<Bit 2 */
#define DAC_CR_MAMP1_3 0x00000800U /*!<Bit 3 */
#define DAC_CR_DMAEN1 0x00001000U /*!<DAC channel1 DMA enable */
#define DAC_CR_DMAUDRIE1 0x00002000U /*!<DAC channel1 DMA underrun interrupt enable */
#define DAC_CR_EN2 0x00010000U /*!<DAC channel2 enable */
#define DAC_CR_BOFF2 0x00020000U /*!<DAC channel2 output buffer disable */
#define DAC_CR_TEN2 0x00040000U /*!<DAC channel2 Trigger enable */
#define DAC_CR_TSEL2 0x00380000U /*!<TSEL2[2:0] (DAC channel2 Trigger selection) */
#define DAC_CR_TSEL2_0 0x00080000U /*!<Bit 0 */
#define DAC_CR_TSEL2_1 0x00100000U /*!<Bit 1 */
#define DAC_CR_TSEL2_2 0x00200000U /*!<Bit 2 */
#define DAC_CR_WAVE2 0x00C00000U /*!<WAVE2[1:0] (DAC channel2 noise/triangle wave generation enable) */
#define DAC_CR_WAVE2_0 0x00400000U /*!<Bit 0 */
#define DAC_CR_WAVE2_1 0x00800000U /*!<Bit 1 */
#define DAC_CR_MAMP2 0x0F000000U /*!<MAMP2[3:0] (DAC channel2 Mask/Amplitude selector) */
#define DAC_CR_MAMP2_0 0x01000000U /*!<Bit 0 */
#define DAC_CR_MAMP2_1 0x02000000U /*!<Bit 1 */
#define DAC_CR_MAMP2_2 0x04000000U /*!<Bit 2 */
#define DAC_CR_MAMP2_3 0x08000000U /*!<Bit 3 */
#define DAC_CR_DMAEN2 0x10000000U /*!<DAC channel2 DMA enable */
#define DAC_CR_DMAUDRIE2 0x20000000U /*!<DAC channel2 DMA underrun interrupt enable */
/***************** Bit definition for DAC_SWTRIGR register ******************/
#define DAC_SWTRIGR_SWTRIG1 0x01U /*!<DAC channel1 software trigger */
#define DAC_SWTRIGR_SWTRIG2 0x02U /*!<DAC channel2 software trigger */
/***************** Bit definition for DAC_DHR12R1 register ******************/
#define DAC_DHR12R1_DACC1DHR 0x0FFFU /*!<DAC channel1 12-bit Right aligned data */
/***************** Bit definition for DAC_DHR12L1 register ******************/
#define DAC_DHR12L1_DACC1DHR 0xFFF0U /*!<DAC channel1 12-bit Left aligned data */
/****************** Bit definition for DAC_DHR8R1 register ******************/
#define DAC_DHR8R1_DACC1DHR 0xFFU /*!<DAC channel1 8-bit Right aligned data */
/***************** Bit definition for DAC_DHR12R2 register ******************/
#define DAC_DHR12R2_DACC2DHR 0x0FFFU /*!<DAC channel2 12-bit Right aligned data */
/***************** Bit definition for DAC_DHR12L2 register ******************/
#define DAC_DHR12L2_DACC2DHR 0xFFF0U /*!<DAC channel2 12-bit Left aligned data */
/****************** Bit definition for DAC_DHR8R2 register ******************/
#define DAC_DHR8R2_DACC2DHR 0xFFU /*!<DAC channel2 8-bit Right aligned data */
/***************** Bit definition for DAC_DHR12RD register ******************/
#define DAC_DHR12RD_DACC1DHR 0x00000FFFU /*!<DAC channel1 12-bit Right aligned data */
#define DAC_DHR12RD_DACC2DHR 0x0FFF0000U /*!<DAC channel2 12-bit Right aligned data */
/***************** Bit definition for DAC_DHR12LD register ******************/
#define DAC_DHR12LD_DACC1DHR 0x0000FFF0U /*!<DAC channel1 12-bit Left aligned data */
#define DAC_DHR12LD_DACC2DHR 0xFFF00000U /*!<DAC channel2 12-bit Left aligned data */
/****************** Bit definition for DAC_DHR8RD register ******************/
#define DAC_DHR8RD_DACC1DHR 0x00FFU /*!<DAC channel1 8-bit Right aligned data */
#define DAC_DHR8RD_DACC2DHR 0xFF00U /*!<DAC channel2 8-bit Right aligned data */
/******************* Bit definition for DAC_DOR1 register *******************/
#define DAC_DOR1_DACC1DOR 0x0FFFU /*!<DAC channel1 data output */
/******************* Bit definition for DAC_DOR2 register *******************/
#define DAC_DOR2_DACC2DOR 0x0FFFU /*!<DAC channel2 data output */
/******************** Bit definition for DAC_SR register ********************/
#define DAC_SR_DMAUDR1 0x00002000U /*!<DAC channel1 DMA underrun flag */
#define DAC_SR_DMAUDR2 0x20000000U /*!<DAC channel2 DMA underrun flag */
/******************************************************************************/
/* */
/* Digital Filter for Sigma Delta Modulators */
/* */
/******************************************************************************/
/**************** DFSDM channel configuration registers ********************/
/*************** Bit definition for DFSDM_CHCFGR1 register ******************/
#define DFSDM_CHCFGR1_DFSDMEN 0x80000000U /*!< Global enable for DFSDM interface */
#define DFSDM_CHCFGR1_CKOUTSRC 0x40000000U /*!< Output serial clock source selection */
#define DFSDM_CHCFGR1_CKOUTDIV 0x00FF0000U /*!< CKOUTDIV[7:0] output serial clock divider */
#define DFSDM_CHCFGR1_DATPACK 0x0000C000U /*!< DATPACK[1:0] Data packing mode */
#define DFSDM_CHCFGR1_DATPACK_1 0x00008000U /*!< Data packing mode, Bit 1 */
#define DFSDM_CHCFGR1_DATPACK_0 0x00004000U /*!< Data packing mode, Bit 0 */
#define DFSDM_CHCFGR1_DATMPX 0x00003000U /*!< DATMPX[1:0] Input data multiplexer for channel y */
#define DFSDM_CHCFGR1_DATMPX_1 0x00002000U /*!< Input data multiplexer for channel y, Bit 1 */
#define DFSDM_CHCFGR1_DATMPX_0 0x00001000U /*!< Input data multiplexer for channel y, Bit 0 */
#define DFSDM_CHCFGR1_CHINSEL 0x00000100U /*!< Serial inputs selection for channel y */
#define DFSDM_CHCFGR1_CHEN 0x00000080U /*!< Channel y enable */
#define DFSDM_CHCFGR1_CKABEN 0x00000040U /*!< Clock absence detector enable on channel y */
#define DFSDM_CHCFGR1_SCDEN 0x00000020U /*!< Short circuit detector enable on channel y */
#define DFSDM_CHCFGR1_SPICKSEL 0x0000000CU /*!< SPICKSEL[1:0] SPI clock select for channel y */
#define DFSDM_CHCFGR1_SPICKSEL_1 0x00000008U /*!< SPI clock select for channel y, Bit 1 */
#define DFSDM_CHCFGR1_SPICKSEL_0 0x00000004U /*!< SPI clock select for channel y, Bit 0 */
#define DFSDM_CHCFGR1_SITP 0x00000003U /*!< SITP[1:0] Serial interface type for channel y */
#define DFSDM_CHCFGR1_SITP_1 0x00000002U /*!< Serial interface type for channel y, Bit 1 */
#define DFSDM_CHCFGR1_SITP_0 0x00000001U /*!< Serial interface type for channel y, Bit 0 */
/*************** Bit definition for DFSDM_CHCFGR2 register ******************/
#define DFSDM_CHCFGR2_OFFSET 0xFFFFFF00U /*!< OFFSET[23:0] 24-bit calibration offset for channel y */
#define DFSDM_CHCFGR2_DTRBS 0x000000F8U /*!< DTRBS[4:0] Data right bit-shift for channel y */
/****************** Bit definition for DFSDM_CHAWSCDR register *****************/
#define DFSDM_CHAWSCDR_AWFORD 0x00C00000U /*!< AWFORD[1:0] Analog watchdog Sinc filter order on channel y */
#define DFSDM_CHAWSCDR_AWFORD_1 0x00800000U /*!< Analog watchdog Sinc filter order on channel y, Bit 1 */
#define DFSDM_CHAWSCDR_AWFORD_0 0x00400000U /*!< Analog watchdog Sinc filter order on channel y, Bit 0 */
#define DFSDM_CHAWSCDR_AWFOSR 0x001F0000U /*!< AWFOSR[4:0] Analog watchdog filter oversampling ratio on channel y */
#define DFSDM_CHAWSCDR_BKSCD 0x0000F000U /*!< BKSCD[3:0] Break signal assignment for short circuit detector on channel y */
#define DFSDM_CHAWSCDR_SCDT 0x000000FFU /*!< SCDT[7:0] Short circuit detector threshold for channel y */
/**************** Bit definition for DFSDM_CHWDATR register *******************/
#define DFSDM_CHWDATR_WDATA 0x0000FFFFU /*!< WDATA[15:0] Input channel y watchdog data */
/**************** Bit definition for DFSDM_CHDATINR register *****************/
#define DFSDM_CHDATINR_INDAT0 0x0000FFFFU /*!< INDAT0[31:16] Input data for channel y or channel (y+1) */
#define DFSDM_CHDATINR_INDAT1 0xFFFF0000U /*!< INDAT0[15:0] Input data for channel y */
/************************ DFSDM module registers ****************************/
/******************** Bit definition for DFSDM_FLTCR1 register *******************/
#define DFSDM_FLTCR1_AWFSEL 0x40000000U /*!< Analog watchdog fast mode select */
#define DFSDM_FLTCR1_FAST 0x20000000U /*!< Fast conversion mode selection */
#define DFSDM_FLTCR1_RCH 0x07000000U /*!< RCH[2:0] Regular channel selection */
#define DFSDM_FLTCR1_RDMAEN 0x00200000U /*!< DMA channel enabled to read data for the regular conversion */
#define DFSDM_FLTCR1_RSYNC 0x00080000U /*!< Launch regular conversion synchronously with DFSDMx */
#define DFSDM_FLTCR1_RCONT 0x00040000U /*!< Continuous mode selection for regular conversions */
#define DFSDM_FLTCR1_RSWSTART 0x00020000U /*!< Software start of a conversion on the regular channel */
#define DFSDM_FLTCR1_JEXTEN 0x00006000U /*!< JEXTEN[1:0] Trigger enable and trigger edge selection for injected conversions */
#define DFSDM_FLTCR1_JEXTEN_1 0x00004000U /*!< Trigger enable and trigger edge selection for injected conversions, Bit 1 */
#define DFSDM_FLTCR1_JEXTEN_0 0x00002000U /*!< Trigger enable and trigger edge selection for injected conversions, Bit 0 */
#define DFSDM_FLTCR1_JEXTSEL 0x00001F00U /*!< JEXTSEL[4:0]Trigger signal selection for launching injected conversions */
#define DFSDM_FLTCR1_JEXTSEL_0 0x00000100U /*!< Trigger signal selection for launching injected conversions, Bit 0 */
#define DFSDM_FLTCR1_JEXTSEL_1 0x00000200U /*!< Trigger signal selection for launching injected conversions, Bit 1 */
#define DFSDM_FLTCR1_JEXTSEL_2 0x00000400U /*!< Trigger signal selection for launching injected conversions, Bit 2 */
#define DFSDM_FLTCR1_JEXTSEL_3 0x00000800U /*!< Trigger signal selection for launching injected conversions, Bit 3 */
#define DFSDM_FLTCR1_JEXTSEL_4 0x00001000U /*!< Trigger signal selection for launching injected conversions, Bit 4 */
#define DFSDM_FLTCR1_JDMAEN 0x00000020U /*!< DMA channel enabled to read data for the injected channel group */
#define DFSDM_FLTCR1_JSCAN 0x00000010U /*!< Scanning conversion in continuous mode selection for injected conversions */
#define DFSDM_FLTCR1_JSYNC 0x00000008U /*!< Launch an injected conversion synchronously with DFSDMx JSWSTART trigger */
#define DFSDM_FLTCR1_JSWSTART 0x00000002U /*!< Start the conversion of the injected group of channels */
#define DFSDM_FLTCR1_DFEN 0x00000001U /*!< DFSDM enable */
/******************** Bit definition for DFSDM_FLTCR2 register *******************/
#define DFSDM_FLTCR2_AWDCH 0x00FF0000U /*!< AWDCH[7:0] Analog watchdog channel selection */
#define DFSDM_FLTCR2_EXCH 0x0000FF00U /*!< EXCH[7:0] Extreme detector channel selection */
#define DFSDM_FLTCR2_CKABIE 0x00000040U /*!< Clock absence interrupt enable */
#define DFSDM_FLTCR2_SCDIE 0x00000020U /*!< Short circuit detector interrupt enable */
#define DFSDM_FLTCR2_AWDIE 0x00000010U /*!< Analog watchdog interrupt enable */
#define DFSDM_FLTCR2_ROVRIE 0x00000008U /*!< Regular data overrun interrupt enable */
#define DFSDM_FLTCR2_JOVRIE 0x00000004U /*!< Injected data overrun interrupt enable */
#define DFSDM_FLTCR2_REOCIE 0x00000002U /*!< Regular end of conversion interrupt enable */
#define DFSDM_FLTCR2_JEOCIE 0x00000001U /*!< Injected end of conversion interrupt enable */
/******************** Bit definition for DFSDM_FLTISR register *******************/
#define DFSDM_FLTISR_SCDF 0xFF000000U /*!< SCDF[7:0] Short circuit detector flag */
#define DFSDM_FLTISR_CKABF 0x00FF0000U /*!< CKABF[7:0] Clock absence flag */
#define DFSDM_FLTISR_RCIP 0x00004000U /*!< Regular conversion in progress status */
#define DFSDM_FLTISR_JCIP 0x00002000U /*!< Injected conversion in progress status */
#define DFSDM_FLTISR_AWDF 0x00000010U /*!< Analog watchdog */
#define DFSDM_FLTISR_ROVRF 0x00000008U /*!< Regular conversion overrun flag */
#define DFSDM_FLTISR_JOVRF 0x00000004U /*!< Injected conversion overrun flag */
#define DFSDM_FLTISR_REOCF 0x00000002U /*!< End of regular conversion flag */
#define DFSDM_FLTISR_JEOCF 0x00000001U /*!< End of injected conversion flag */
/******************** Bit definition for DFSDM_FLTICR register *******************/
#define DFSDM_FLTICR_CLRSCSDF 0xFF000000U /*!< CLRSCSDF[7:0] Clear the short circuit detector flag */
#define DFSDM_FLTICR_CLRCKABF 0x00FF0000U /*!< CLRCKABF[7:0] Clear the clock absence flag */
#define DFSDM_FLTICR_CLRROVRF 0x00000008U /*!< Clear the regular conversion overrun flag */
#define DFSDM_FLTICR_CLRJOVRF 0x00000004U /*!< Clear the injected conversion overrun flag */
/******************* Bit definition for DFSDM_FLTJCHGR register ******************/
#define DFSDM_FLTJCHGR_JCHG 0x000000FFU /*!< JCHG[7:0] Injected channel group selection */
/******************** Bit definition for DFSDM_FLTFCR register *******************/
#define DFSDM_FLTFCR_FORD 0xE0000000U /*!< FORD[2:0] Sinc filter order */
#define DFSDM_FLTFCR_FORD_2 0x80000000U /*!< Sinc filter order, Bit 2 */
#define DFSDM_FLTFCR_FORD_1 0x40000000U /*!< Sinc filter order, Bit 1 */
#define DFSDM_FLTFCR_FORD_0 0x20000000U /*!< Sinc filter order, Bit 0 */
#define DFSDM_FLTFCR_FOSR 0x03FF0000U /*!< FOSR[9:0] Sinc filter oversampling ratio (decimation rate) */
#define DFSDM_FLTFCR_IOSR 0x000000FFU /*!< IOSR[7:0] Integrator oversampling ratio (averaging length) */
/****************** Bit definition for DFSDM_FLTJDATAR register *****************/
#define DFSDM_FLTJDATAR_JDATA 0xFFFFFF00U /*!< JDATA[23:0] Injected group conversion data */
#define DFSDM_FLTJDATAR_JDATACH 0x00000007U /*!< JDATACH[2:0] Injected channel most recently converted */
/****************** Bit definition for DFSDM_FLTRDATAR register *****************/
#define DFSDM_FLTRDATAR_RDATA 0xFFFFFF00U /*!< RDATA[23:0] Regular channel conversion data */
#define DFSDM_FLTRDATAR_RPEND 0x00000010U /*!< RPEND Regular channel pending data */
#define DFSDM_FLTRDATAR_RDATACH 0x00000007U /*!< RDATACH[2:0] Regular channel most recently converted */
/****************** Bit definition for DFSDM_FLTAWHTR register ******************/
#define DFSDM_FLTAWHTR_AWHT 0xFFFFFF00U /*!< AWHT[23:0] Analog watchdog high threshold */
#define DFSDM_FLTAWHTR_BKAWH 0x0000000FU /*!< BKAWH[3:0] Break signal assignment to analog watchdog high threshold event */
/****************** Bit definition for DFSDM_FLTAWLTR register ******************/
#define DFSDM_FLTAWLTR_AWLT 0xFFFFFF00U /*!< AWLT[23:0] Analog watchdog low threshold */
#define DFSDM_FLTAWLTR_BKAWL 0x0000000FU /*!< BKAWL[3:0] Break signal assignment to analog watchdog low threshold event */
/****************** Bit definition for DFSDM_FLTAWSR register ******************/
#define DFSDM_FLTAWSR_AWHTF 0x0000FF00U /*!< AWHTF[15:8] Analog watchdog high threshold error on given channels */
#define DFSDM_FLTAWSR_AWLTF 0x000000FFU /*!< AWLTF[7:0] Analog watchdog low threshold error on given channels */
/****************** Bit definition for DFSDM_FLTAWCFR register *****************/
#define DFSDM_FLTAWCFR_CLRAWHTF 0x0000FF00U /*!< CLRAWHTF[15:8] Clear the Analog watchdog high threshold flag */
#define DFSDM_FLTAWCFR_CLRAWLTF 0x000000FFU /*!< CLRAWLTF[7:0] Clear the Analog watchdog low threshold flag */
/****************** Bit definition for DFSDM_FLTEXMAX register ******************/
#define DFSDM_FLTEXMAX_EXMAX 0xFFFFFF00U /*!< EXMAX[23:0] Extreme detector maximum value */
#define DFSDM_FLTEXMAX_EXMAXCH 0x00000007U /*!< EXMAXCH[2:0] Extreme detector maximum data channel */
/****************** Bit definition for DFSDM_FLTEXMIN register ******************/
#define DFSDM_FLTEXMIN_EXMIN 0xFFFFFF00U /*!< EXMIN[23:0] Extreme detector minimum value */
#define DFSDM_FLTEXMIN_EXMINCH 0x00000007U /*!< EXMINCH[2:0] Extreme detector minimum data channel */
/****************** Bit definition for DFSDM_FLTCNVTIMR register ******************/
#define DFSDM_FLTCNVTIMR_CNVCNT 0xFFFFFFF0U /*!< CNVCNT[27:0]: 28-bit timer counting conversion time */
/******************************************************************************/
/* */
/* Debug MCU */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/* DCMI */
/* */
/******************************************************************************/
/******************** Bits definition for DCMI_CR register ******************/
#define DCMI_CR_CAPTURE 0x00000001U
#define DCMI_CR_CM 0x00000002U
#define DCMI_CR_CROP 0x00000004U
#define DCMI_CR_JPEG 0x00000008U
#define DCMI_CR_ESS 0x00000010U
#define DCMI_CR_PCKPOL 0x00000020U
#define DCMI_CR_HSPOL 0x00000040U
#define DCMI_CR_VSPOL 0x00000080U
#define DCMI_CR_FCRC_0 0x00000100U
#define DCMI_CR_FCRC_1 0x00000200U
#define DCMI_CR_EDM_0 0x00000400U
#define DCMI_CR_EDM_1 0x00000800U
#define DCMI_CR_CRE 0x00001000U
#define DCMI_CR_ENABLE 0x00004000U
#define DCMI_CR_BSM 0x00030000U
#define DCMI_CR_BSM_0 0x00010000U
#define DCMI_CR_BSM_1 0x00020000U
#define DCMI_CR_OEBS 0x00040000U
#define DCMI_CR_LSM 0x00080000U
#define DCMI_CR_OELS 0x00100000U
/******************** Bits definition for DCMI_SR register ******************/
#define DCMI_SR_HSYNC 0x00000001U
#define DCMI_SR_VSYNC 0x00000002U
#define DCMI_SR_FNE 0x00000004U
/******************** Bits definition for DCMI_RIS register ****************/
#define DCMI_RIS_FRAME_RIS 0x00000001U
#define DCMI_RIS_OVR_RIS 0x00000002U
#define DCMI_RIS_ERR_RIS 0x00000004U
#define DCMI_RIS_VSYNC_RIS 0x00000008U
#define DCMI_RIS_LINE_RIS 0x00000010U
/* Legacy defines */
#define DCMI_RISR_FRAME_RIS DCMI_RIS_FRAME_RIS
#define DCMI_RISR_OVF_RIS DCMI_RIS_OVR_RIS
#define DCMI_RISR_ERR_RIS DCMI_RIS_ERR_RIS
#define DCMI_RISR_VSYNC_RIS DCMI_RIS_VSYNC_RIS
#define DCMI_RISR_LINE_RIS DCMI_RIS_LINE_RIS
/******************** Bits definition for DCMI_IER register *****************/
#define DCMI_IER_FRAME_IE 0x00000001U
#define DCMI_IER_OVR_IE 0x00000002U
#define DCMI_IER_ERR_IE 0x00000004U
#define DCMI_IER_VSYNC_IE 0x00000008U
#define DCMI_IER_LINE_IE 0x00000010U
/******************** Bits definition for DCMI_MIS register *****************/
#define DCMI_MIS_FRAME_MIS 0x00000001U
#define DCMI_MIS_OVR_MIS 0x00000002U
#define DCMI_MIS_ERR_MIS 0x00000004U
#define DCMI_MIS_VSYNC_MIS 0x00000008U
#define DCMI_MIS_LINE_MIS 0x00000010U
/******************** Bits definition for DCMI_ICR register *****************/
#define DCMI_ICR_FRAME_ISC 0x00000001U
#define DCMI_ICR_OVR_ISC 0x00000002U
#define DCMI_ICR_ERR_ISC 0x00000004U
#define DCMI_ICR_VSYNC_ISC 0x00000008U
#define DCMI_ICR_LINE_ISC 0x00000010U
/******************** Bits definition for DCMI_ESCR register ******************/
#define DCMI_ESCR_FSC 0x000000FFU
#define DCMI_ESCR_LSC 0x0000FF00U
#define DCMI_ESCR_LEC 0x00FF0000U
#define DCMI_ESCR_FEC 0xFF000000U
/******************** Bits definition for DCMI_ESUR register ******************/
#define DCMI_ESUR_FSU 0x000000FFU
#define DCMI_ESUR_LSU 0x0000FF00U
#define DCMI_ESUR_LEU 0x00FF0000U
#define DCMI_ESUR_FEU 0xFF000000U
/******************** Bits definition for DCMI_CWSTRT register ******************/
#define DCMI_CWSTRT_HOFFCNT 0x00003FFFU
#define DCMI_CWSTRT_VST 0x1FFF0000U
/******************** Bits definition for DCMI_CWSIZE register ******************/
#define DCMI_CWSIZE_CAPCNT 0x00003FFFU
#define DCMI_CWSIZE_VLINE 0x3FFF0000U
/******************** Bits definition for DCMI_DR register ******************/
#define DCMI_DR_BYTE0 0x000000FFU
#define DCMI_DR_BYTE1 0x0000FF00U
#define DCMI_DR_BYTE2 0x00FF0000U
#define DCMI_DR_BYTE3 0xFF000000U
/******************************************************************************/
/* */
/* DMA Controller */
/* */
/******************************************************************************/
/******************** Bits definition for DMA_SxCR register *****************/
#define DMA_SxCR_CHSEL 0x1E000000U
#define DMA_SxCR_CHSEL_0 0x02000000U
#define DMA_SxCR_CHSEL_1 0x04000000U
#define DMA_SxCR_CHSEL_2 0x08000000U
#define DMA_SxCR_CHSEL_3 0x10000000U
#define DMA_SxCR_MBURST 0x01800000U
#define DMA_SxCR_MBURST_0 0x00800000U
#define DMA_SxCR_MBURST_1 0x01000000U
#define DMA_SxCR_PBURST 0x00600000U
#define DMA_SxCR_PBURST_0 0x00200000U
#define DMA_SxCR_PBURST_1 0x00400000U
#define DMA_SxCR_CT 0x00080000U
#define DMA_SxCR_DBM 0x00040000U
#define DMA_SxCR_PL 0x00030000U
#define DMA_SxCR_PL_0 0x00010000U
#define DMA_SxCR_PL_1 0x00020000U
#define DMA_SxCR_PINCOS 0x00008000U
#define DMA_SxCR_MSIZE 0x00006000U
#define DMA_SxCR_MSIZE_0 0x00002000U
#define DMA_SxCR_MSIZE_1 0x00004000U
#define DMA_SxCR_PSIZE 0x00001800U
#define DMA_SxCR_PSIZE_0 0x00000800U
#define DMA_SxCR_PSIZE_1 0x00001000U
#define DMA_SxCR_MINC 0x00000400U
#define DMA_SxCR_PINC 0x00000200U
#define DMA_SxCR_CIRC 0x00000100U
#define DMA_SxCR_DIR 0x000000C0U
#define DMA_SxCR_DIR_0 0x00000040U
#define DMA_SxCR_DIR_1 0x00000080U
#define DMA_SxCR_PFCTRL 0x00000020U
#define DMA_SxCR_TCIE 0x00000010U
#define DMA_SxCR_HTIE 0x00000008U
#define DMA_SxCR_TEIE 0x00000004U
#define DMA_SxCR_DMEIE 0x00000002U
#define DMA_SxCR_EN 0x00000001U
/******************** Bits definition for DMA_SxCNDTR register **************/
#define DMA_SxNDT 0x0000FFFFU
#define DMA_SxNDT_0 0x00000001U
#define DMA_SxNDT_1 0x00000002U
#define DMA_SxNDT_2 0x00000004U
#define DMA_SxNDT_3 0x00000008U
#define DMA_SxNDT_4 0x00000010U
#define DMA_SxNDT_5 0x00000020U
#define DMA_SxNDT_6 0x00000040U
#define DMA_SxNDT_7 0x00000080U
#define DMA_SxNDT_8 0x00000100U
#define DMA_SxNDT_9 0x00000200U
#define DMA_SxNDT_10 0x00000400U
#define DMA_SxNDT_11 0x00000800U
#define DMA_SxNDT_12 0x00001000U
#define DMA_SxNDT_13 0x00002000U
#define DMA_SxNDT_14 0x00004000U
#define DMA_SxNDT_15 0x00008000U
/******************** Bits definition for DMA_SxFCR register ****************/
#define DMA_SxFCR_FEIE 0x00000080U
#define DMA_SxFCR_FS 0x00000038U
#define DMA_SxFCR_FS_0 0x00000008U
#define DMA_SxFCR_FS_1 0x00000010U
#define DMA_SxFCR_FS_2 0x00000020U
#define DMA_SxFCR_DMDIS 0x00000004U
#define DMA_SxFCR_FTH 0x00000003U
#define DMA_SxFCR_FTH_0 0x00000001U
#define DMA_SxFCR_FTH_1 0x00000002U
/******************** Bits definition for DMA_LISR register *****************/
#define DMA_LISR_TCIF3 0x08000000U
#define DMA_LISR_HTIF3 0x04000000U
#define DMA_LISR_TEIF3 0x02000000U
#define DMA_LISR_DMEIF3 0x01000000U
#define DMA_LISR_FEIF3 0x00400000U
#define DMA_LISR_TCIF2 0x00200000U
#define DMA_LISR_HTIF2 0x00100000U
#define DMA_LISR_TEIF2 0x00080000U
#define DMA_LISR_DMEIF2 0x00040000U
#define DMA_LISR_FEIF2 0x00010000U
#define DMA_LISR_TCIF1 0x00000800U
#define DMA_LISR_HTIF1 0x00000400U
#define DMA_LISR_TEIF1 0x00000200U
#define DMA_LISR_DMEIF1 0x00000100U
#define DMA_LISR_FEIF1 0x00000040U
#define DMA_LISR_TCIF0 0x00000020U
#define DMA_LISR_HTIF0 0x00000010U
#define DMA_LISR_TEIF0 0x00000008U
#define DMA_LISR_DMEIF0 0x00000004U
#define DMA_LISR_FEIF0 0x00000001U
/******************** Bits definition for DMA_HISR register *****************/
#define DMA_HISR_TCIF7 0x08000000U
#define DMA_HISR_HTIF7 0x04000000U
#define DMA_HISR_TEIF7 0x02000000U
#define DMA_HISR_DMEIF7 0x01000000U
#define DMA_HISR_FEIF7 0x00400000U
#define DMA_HISR_TCIF6 0x00200000U
#define DMA_HISR_HTIF6 0x00100000U
#define DMA_HISR_TEIF6 0x00080000U
#define DMA_HISR_DMEIF6 0x00040000U
#define DMA_HISR_FEIF6 0x00010000U
#define DMA_HISR_TCIF5 0x00000800U
#define DMA_HISR_HTIF5 0x00000400U
#define DMA_HISR_TEIF5 0x00000200U
#define DMA_HISR_DMEIF5 0x00000100U
#define DMA_HISR_FEIF5 0x00000040U
#define DMA_HISR_TCIF4 0x00000020U
#define DMA_HISR_HTIF4 0x00000010U
#define DMA_HISR_TEIF4 0x00000008U
#define DMA_HISR_DMEIF4 0x00000004U
#define DMA_HISR_FEIF4 0x00000001U
/******************** Bits definition for DMA_LIFCR register ****************/
#define DMA_LIFCR_CTCIF3 0x08000000U
#define DMA_LIFCR_CHTIF3 0x04000000U
#define DMA_LIFCR_CTEIF3 0x02000000U
#define DMA_LIFCR_CDMEIF3 0x01000000U
#define DMA_LIFCR_CFEIF3 0x00400000U
#define DMA_LIFCR_CTCIF2 0x00200000U
#define DMA_LIFCR_CHTIF2 0x00100000U
#define DMA_LIFCR_CTEIF2 0x00080000U
#define DMA_LIFCR_CDMEIF2 0x00040000U
#define DMA_LIFCR_CFEIF2 0x00010000U
#define DMA_LIFCR_CTCIF1 0x00000800U
#define DMA_LIFCR_CHTIF1 0x00000400U
#define DMA_LIFCR_CTEIF1 0x00000200U
#define DMA_LIFCR_CDMEIF1 0x00000100U
#define DMA_LIFCR_CFEIF1 0x00000040U
#define DMA_LIFCR_CTCIF0 0x00000020U
#define DMA_LIFCR_CHTIF0 0x00000010U
#define DMA_LIFCR_CTEIF0 0x00000008U
#define DMA_LIFCR_CDMEIF0 0x00000004U
#define DMA_LIFCR_CFEIF0 0x00000001U
/******************** Bits definition for DMA_HIFCR register ****************/
#define DMA_HIFCR_CTCIF7 0x08000000U
#define DMA_HIFCR_CHTIF7 0x04000000U
#define DMA_HIFCR_CTEIF7 0x02000000U
#define DMA_HIFCR_CDMEIF7 0x01000000U
#define DMA_HIFCR_CFEIF7 0x00400000U
#define DMA_HIFCR_CTCIF6 0x00200000U
#define DMA_HIFCR_CHTIF6 0x00100000U
#define DMA_HIFCR_CTEIF6 0x00080000U
#define DMA_HIFCR_CDMEIF6 0x00040000U
#define DMA_HIFCR_CFEIF6 0x00010000U
#define DMA_HIFCR_CTCIF5 0x00000800U
#define DMA_HIFCR_CHTIF5 0x00000400U
#define DMA_HIFCR_CTEIF5 0x00000200U
#define DMA_HIFCR_CDMEIF5 0x00000100U
#define DMA_HIFCR_CFEIF5 0x00000040U
#define DMA_HIFCR_CTCIF4 0x00000020U
#define DMA_HIFCR_CHTIF4 0x00000010U
#define DMA_HIFCR_CTEIF4 0x00000008U
#define DMA_HIFCR_CDMEIF4 0x00000004U
#define DMA_HIFCR_CFEIF4 0x00000001U
/******************************************************************************/
/* */
/* AHB Master DMA2D Controller (DMA2D) */
/* */
/******************************************************************************/
/******************** Bit definition for DMA2D_CR register ******************/
#define DMA2D_CR_START 0x00000001U /*!< Start transfer */
#define DMA2D_CR_SUSP 0x00000002U /*!< Suspend transfer */
#define DMA2D_CR_ABORT 0x00000004U /*!< Abort transfer */
#define DMA2D_CR_TEIE 0x00000100U /*!< Transfer Error Interrupt Enable */
#define DMA2D_CR_TCIE 0x00000200U /*!< Transfer Complete Interrupt Enable */
#define DMA2D_CR_TWIE 0x00000400U /*!< Transfer Watermark Interrupt Enable */
#define DMA2D_CR_CAEIE 0x00000800U /*!< CLUT Access Error Interrupt Enable */
#define DMA2D_CR_CTCIE 0x00001000U /*!< CLUT Transfer Complete Interrupt Enable */
#define DMA2D_CR_CEIE 0x00002000U /*!< Configuration Error Interrupt Enable */
#define DMA2D_CR_MODE 0x00030000U /*!< DMA2D Mode[1:0] */
#define DMA2D_CR_MODE_0 0x00010000U /*!< DMA2D Mode bit 0 */
#define DMA2D_CR_MODE_1 0x00020000U /*!< DMA2D Mode bit 1 */
/******************** Bit definition for DMA2D_ISR register *****************/
#define DMA2D_ISR_TEIF 0x00000001U /*!< Transfer Error Interrupt Flag */
#define DMA2D_ISR_TCIF 0x00000002U /*!< Transfer Complete Interrupt Flag */
#define DMA2D_ISR_TWIF 0x00000004U /*!< Transfer Watermark Interrupt Flag */
#define DMA2D_ISR_CAEIF 0x00000008U /*!< CLUT Access Error Interrupt Flag */
#define DMA2D_ISR_CTCIF 0x00000010U /*!< CLUT Transfer Complete Interrupt Flag */
#define DMA2D_ISR_CEIF 0x00000020U /*!< Configuration Error Interrupt Flag */
/******************** Bit definition for DMA2D_IFCR register ****************/
#define DMA2D_IFCR_CTEIF 0x00000001U /*!< Clears Transfer Error Interrupt Flag */
#define DMA2D_IFCR_CTCIF 0x00000002U /*!< Clears Transfer Complete Interrupt Flag */
#define DMA2D_IFCR_CTWIF 0x00000004U /*!< Clears Transfer Watermark Interrupt Flag */
#define DMA2D_IFCR_CAECIF 0x00000008U /*!< Clears CLUT Access Error Interrupt Flag */
#define DMA2D_IFCR_CCTCIF 0x00000010U /*!< Clears CLUT Transfer Complete Interrupt Flag */
#define DMA2D_IFCR_CCEIF 0x00000020U /*!< Clears Configuration Error Interrupt Flag */
/* Legacy defines */
#define DMA2D_IFSR_CTEIF DMA2D_IFCR_CTEIF /*!< Clears Transfer Error Interrupt Flag */
#define DMA2D_IFSR_CTCIF DMA2D_IFCR_CTCIF /*!< Clears Transfer Complete Interrupt Flag */
#define DMA2D_IFSR_CTWIF DMA2D_IFCR_CTWIF /*!< Clears Transfer Watermark Interrupt Flag */
#define DMA2D_IFSR_CCAEIF DMA2D_IFCR_CAECIF /*!< Clears CLUT Access Error Interrupt Flag */
#define DMA2D_IFSR_CCTCIF DMA2D_IFCR_CCTCIF /*!< Clears CLUT Transfer Complete Interrupt Flag */
#define DMA2D_IFSR_CCEIF DMA2D_IFCR_CCEIF /*!< Clears Configuration Error Interrupt Flag */
/******************** Bit definition for DMA2D_FGMAR register ***************/
#define DMA2D_FGMAR_MA 0xFFFFFFFFU /*!< Memory Address */
/******************** Bit definition for DMA2D_FGOR register ****************/
#define DMA2D_FGOR_LO 0x00003FFFU /*!< Line Offset */
/******************** Bit definition for DMA2D_BGMAR register ***************/
#define DMA2D_BGMAR_MA 0xFFFFFFFFU /*!< Memory Address */
/******************** Bit definition for DMA2D_BGOR register ****************/
#define DMA2D_BGOR_LO 0x00003FFFU /*!< Line Offset */
/******************** Bit definition for DMA2D_FGPFCCR register *************/
#define DMA2D_FGPFCCR_CM 0x0000000FU /*!< Input color mode CM[3:0] */
#define DMA2D_FGPFCCR_CM_0 0x00000001U /*!< Input color mode CM bit 0 */
#define DMA2D_FGPFCCR_CM_1 0x00000002U /*!< Input color mode CM bit 1 */
#define DMA2D_FGPFCCR_CM_2 0x00000004U /*!< Input color mode CM bit 2 */
#define DMA2D_FGPFCCR_CM_3 0x00000008U /*!< Input color mode CM bit 3 */
#define DMA2D_FGPFCCR_CCM 0x00000010U /*!< CLUT Color mode */
#define DMA2D_FGPFCCR_START 0x00000020U /*!< Start */
#define DMA2D_FGPFCCR_CS 0x0000FF00U /*!< CLUT size */
#define DMA2D_FGPFCCR_AM 0x00030000U /*!< Alpha mode AM[1:0] */
#define DMA2D_FGPFCCR_AM_0 0x00010000U /*!< Alpha mode AM bit 0 */
#define DMA2D_FGPFCCR_AM_1 0x00020000U /*!< Alpha mode AM bit 1 */
#define DMA2D_FGPFCCR_AI 0x00100000U /*!< Foreground Input Alpha Inverted */
#define DMA2D_FGPFCCR_RBS 0x00200000U /*!< Foreground Input Red Blue Swap */
#define DMA2D_FGPFCCR_ALPHA 0xFF000000U /*!< Alpha value */
/******************** Bit definition for DMA2D_FGCOLR register **************/
#define DMA2D_FGCOLR_BLUE 0x000000FFU /*!< Blue Value */
#define DMA2D_FGCOLR_GREEN 0x0000FF00U /*!< Green Value */
#define DMA2D_FGCOLR_RED 0x00FF0000U /*!< Red Value */
/******************** Bit definition for DMA2D_BGPFCCR register *************/
#define DMA2D_BGPFCCR_CM 0x0000000FU /*!< Input color mode CM[3:0] */
#define DMA2D_BGPFCCR_CM_0 0x00000001U /*!< Input color mode CM bit 0 */
#define DMA2D_BGPFCCR_CM_1 0x00000002U /*!< Input color mode CM bit 1 */
#define DMA2D_BGPFCCR_CM_2 0x00000004U /*!< Input color mode CM bit 2 */
#define DMA2D_FGPFCCR_CM_3 0x00000008U /*!< Input color mode CM bit 3 */
#define DMA2D_BGPFCCR_CCM 0x00000010U /*!< CLUT Color mode */
#define DMA2D_BGPFCCR_START 0x00000020U /*!< Start */
#define DMA2D_BGPFCCR_CS 0x0000FF00U /*!< CLUT size */
#define DMA2D_BGPFCCR_AM 0x00030000U /*!< Alpha mode AM[1:0] */
#define DMA2D_BGPFCCR_AM_0 0x00010000U /*!< Alpha mode AM bit 0 */
#define DMA2D_BGPFCCR_AM_1 0x00020000U /*!< Alpha mode AM bit 1 */
#define DMA2D_BGPFCCR_AI 0x00100000U /*!< background Input Alpha Inverted */
#define DMA2D_BGPFCCR_RBS 0x00200000U /*!< Background Input Red Blue Swap */
#define DMA2D_BGPFCCR_ALPHA 0xFF000000U /*!< background Input Alpha value */
/******************** Bit definition for DMA2D_BGCOLR register **************/
#define DMA2D_BGCOLR_BLUE 0x000000FFU /*!< Blue Value */
#define DMA2D_BGCOLR_GREEN 0x0000FF00U /*!< Green Value */
#define DMA2D_BGCOLR_RED 0x00FF0000U /*!< Red Value */
/******************** Bit definition for DMA2D_FGCMAR register **************/
#define DMA2D_FGCMAR_MA 0xFFFFFFFFU /*!< Memory Address */
/******************** Bit definition for DMA2D_BGCMAR register **************/
#define DMA2D_BGCMAR_MA 0xFFFFFFFFU /*!< Memory Address */
/******************** Bit definition for DMA2D_OPFCCR register **************/
#define DMA2D_OPFCCR_CM 0x00000007U /*!< Color mode CM[2:0] */
#define DMA2D_OPFCCR_CM_0 0x00000001U /*!< Color mode CM bit 0 */
#define DMA2D_OPFCCR_CM_1 0x00000002U /*!< Color mode CM bit 1 */
#define DMA2D_OPFCCR_CM_2 0x00000004U /*!< Color mode CM bit 2 */
#define DMA2D_OPFCCR_AI 0x00100000U /*!< Output Alpha Inverted */
#define DMA2D_OPFCCR_RBS 0x00200000U /*!< Output Red Blue Swap */
/******************** Bit definition for DMA2D_OCOLR register ***************/
/*!<Mode_ARGB8888/RGB888 */
#define DMA2D_OCOLR_BLUE_1 0x000000FFU /*!< BLUE Value */
#define DMA2D_OCOLR_GREEN_1 0x0000FF00U /*!< GREEN Value */
#define DMA2D_OCOLR_RED_1 0x00FF0000U /*!< Red Value */
#define DMA2D_OCOLR_ALPHA_1 0xFF000000U /*!< Alpha Channel Value */
/*!<Mode_RGB565 */
#define DMA2D_OCOLR_BLUE_2 0x0000001FU /*!< BLUE Value */
#define DMA2D_OCOLR_GREEN_2 0x000007E0U /*!< GREEN Value */
#define DMA2D_OCOLR_RED_2 0x0000F800U /*!< Red Value */
/*!<Mode_ARGB1555 */
#define DMA2D_OCOLR_BLUE_3 0x0000001FU /*!< BLUE Value */
#define DMA2D_OCOLR_GREEN_3 0x000003E0U /*!< GREEN Value */
#define DMA2D_OCOLR_RED_3 0x00007C00U /*!< Red Value */
#define DMA2D_OCOLR_ALPHA_3 0x00008000U /*!< Alpha Channel Value */
/*!<Mode_ARGB4444 */
#define DMA2D_OCOLR_BLUE_4 0x0000000FU /*!< BLUE Value */
#define DMA2D_OCOLR_GREEN_4 0x000000F0U /*!< GREEN Value */
#define DMA2D_OCOLR_RED_4 0x00000F00U /*!< Red Value */
#define DMA2D_OCOLR_ALPHA_4 0x0000F000U /*!< Alpha Channel Value */
/******************** Bit definition for DMA2D_OMAR register ****************/
#define DMA2D_OMAR_MA 0xFFFFFFFFU /*!< Memory Address */
/******************** Bit definition for DMA2D_OOR register *****************/
#define DMA2D_OOR_LO 0x00003FFFU /*!< Line Offset */
/******************** Bit definition for DMA2D_NLR register *****************/
#define DMA2D_NLR_NL 0x0000FFFFU /*!< Number of Lines */
#define DMA2D_NLR_PL 0x3FFF0000U /*!< Pixel per Lines */
/******************** Bit definition for DMA2D_LWR register *****************/
#define DMA2D_LWR_LW 0x0000FFFFU /*!< Line Watermark */
/******************** Bit definition for DMA2D_AMTCR register ***************/
#define DMA2D_AMTCR_EN 0x00000001U /*!< Enable */
#define DMA2D_AMTCR_DT 0x0000FF00U /*!< Dead Time */
/******************** Bit definition for DMA2D_FGCLUT register **************/
/******************** Bit definition for DMA2D_BGCLUT register **************/
/******************************************************************************/
/* */
/* External Interrupt/Event Controller */
/* */
/******************************************************************************/
/******************* Bit definition for EXTI_IMR register *******************/
#define EXTI_IMR_MR0 0x00000001U /*!< Interrupt Mask on line 0 */
#define EXTI_IMR_MR1 0x00000002U /*!< Interrupt Mask on line 1 */
#define EXTI_IMR_MR2 0x00000004U /*!< Interrupt Mask on line 2 */
#define EXTI_IMR_MR3 0x00000008U /*!< Interrupt Mask on line 3 */
#define EXTI_IMR_MR4 0x00000010U /*!< Interrupt Mask on line 4 */
#define EXTI_IMR_MR5 0x00000020U /*!< Interrupt Mask on line 5 */
#define EXTI_IMR_MR6 0x00000040U /*!< Interrupt Mask on line 6 */
#define EXTI_IMR_MR7 0x00000080U /*!< Interrupt Mask on line 7 */
#define EXTI_IMR_MR8 0x00000100U /*!< Interrupt Mask on line 8 */
#define EXTI_IMR_MR9 0x00000200U /*!< Interrupt Mask on line 9 */
#define EXTI_IMR_MR10 0x00000400U /*!< Interrupt Mask on line 10 */
#define EXTI_IMR_MR11 0x00000800U /*!< Interrupt Mask on line 11 */
#define EXTI_IMR_MR12 0x00001000U /*!< Interrupt Mask on line 12 */
#define EXTI_IMR_MR13 0x00002000U /*!< Interrupt Mask on line 13 */
#define EXTI_IMR_MR14 0x00004000U /*!< Interrupt Mask on line 14 */
#define EXTI_IMR_MR15 0x00008000U /*!< Interrupt Mask on line 15 */
#define EXTI_IMR_MR16 0x00010000U /*!< Interrupt Mask on line 16 */
#define EXTI_IMR_MR17 0x00020000U /*!< Interrupt Mask on line 17 */
#define EXTI_IMR_MR18 0x00040000U /*!< Interrupt Mask on line 18 */
#define EXTI_IMR_MR19 0x00080000U /*!< Interrupt Mask on line 19 */
#define EXTI_IMR_MR20 0x00100000U /*!< Interrupt Mask on line 20 */
#define EXTI_IMR_MR21 0x00200000U /*!< Interrupt Mask on line 21 */
#define EXTI_IMR_MR22 0x00400000U /*!< Interrupt Mask on line 22 */
#define EXTI_IMR_MR23 0x00800000U /*!< Interrupt Mask on line 23 */
#define EXTI_IMR_MR24 0x01000000U /*!< Interrupt Mask on line 24 */
/* Reference Defines */
#define EXTI_IMR_IM0 EXTI_IMR_MR0
#define EXTI_IMR_IM1 EXTI_IMR_MR1
#define EXTI_IMR_IM2 EXTI_IMR_MR2
#define EXTI_IMR_IM3 EXTI_IMR_MR3
#define EXTI_IMR_IM4 EXTI_IMR_MR4
#define EXTI_IMR_IM5 EXTI_IMR_MR5
#define EXTI_IMR_IM6 EXTI_IMR_MR6
#define EXTI_IMR_IM7 EXTI_IMR_MR7
#define EXTI_IMR_IM8 EXTI_IMR_MR8
#define EXTI_IMR_IM9 EXTI_IMR_MR9
#define EXTI_IMR_IM10 EXTI_IMR_MR10
#define EXTI_IMR_IM11 EXTI_IMR_MR11
#define EXTI_IMR_IM12 EXTI_IMR_MR12
#define EXTI_IMR_IM13 EXTI_IMR_MR13
#define EXTI_IMR_IM14 EXTI_IMR_MR14
#define EXTI_IMR_IM15 EXTI_IMR_MR15
#define EXTI_IMR_IM16 EXTI_IMR_MR16
#define EXTI_IMR_IM17 EXTI_IMR_MR17
#define EXTI_IMR_IM18 EXTI_IMR_MR18
#define EXTI_IMR_IM19 EXTI_IMR_MR19
#define EXTI_IMR_IM20 EXTI_IMR_MR20
#define EXTI_IMR_IM21 EXTI_IMR_MR21
#define EXTI_IMR_IM22 EXTI_IMR_MR22
#define EXTI_IMR_IM23 EXTI_IMR_MR23
#define EXTI_IMR_IM24 EXTI_IMR_MR24
#define EXTI_IMR_IM 0x01FFFFFFU /*!< Interrupt Mask All */
/******************* Bit definition for EXTI_EMR register *******************/
#define EXTI_EMR_MR0 0x00000001U /*!< Event Mask on line 0 */
#define EXTI_EMR_MR1 0x00000002U /*!< Event Mask on line 1 */
#define EXTI_EMR_MR2 0x00000004U /*!< Event Mask on line 2 */
#define EXTI_EMR_MR3 0x00000008U /*!< Event Mask on line 3 */
#define EXTI_EMR_MR4 0x00000010U /*!< Event Mask on line 4 */
#define EXTI_EMR_MR5 0x00000020U /*!< Event Mask on line 5 */
#define EXTI_EMR_MR6 0x00000040U /*!< Event Mask on line 6 */
#define EXTI_EMR_MR7 0x00000080U /*!< Event Mask on line 7 */
#define EXTI_EMR_MR8 0x00000100U /*!< Event Mask on line 8 */
#define EXTI_EMR_MR9 0x00000200U /*!< Event Mask on line 9 */
#define EXTI_EMR_MR10 0x00000400U /*!< Event Mask on line 10 */
#define EXTI_EMR_MR11 0x00000800U /*!< Event Mask on line 11 */
#define EXTI_EMR_MR12 0x00001000U /*!< Event Mask on line 12 */
#define EXTI_EMR_MR13 0x00002000U /*!< Event Mask on line 13 */
#define EXTI_EMR_MR14 0x00004000U /*!< Event Mask on line 14 */
#define EXTI_EMR_MR15 0x00008000U /*!< Event Mask on line 15 */
#define EXTI_EMR_MR16 0x00010000U /*!< Event Mask on line 16 */
#define EXTI_EMR_MR17 0x00020000U /*!< Event Mask on line 17 */
#define EXTI_EMR_MR18 0x00040000U /*!< Event Mask on line 18 */
#define EXTI_EMR_MR19 0x00080000U /*!< Event Mask on line 19 */
#define EXTI_EMR_MR20 0x00100000U /*!< Event Mask on line 20 */
#define EXTI_EMR_MR21 0x00200000U /*!< Event Mask on line 21 */
#define EXTI_EMR_MR22 0x00400000U /*!< Event Mask on line 22 */
#define EXTI_EMR_MR23 0x00800000U /*!< Event Mask on line 23 */
#define EXTI_EMR_MR24 0x01000000U /*!< Event Mask on line 24 */
/* Reference Defines */
#define EXTI_EMR_EM0 EXTI_EMR_MR0
#define EXTI_EMR_EM1 EXTI_EMR_MR1
#define EXTI_EMR_EM2 EXTI_EMR_MR2
#define EXTI_EMR_EM3 EXTI_EMR_MR3
#define EXTI_EMR_EM4 EXTI_EMR_MR4
#define EXTI_EMR_EM5 EXTI_EMR_MR5
#define EXTI_EMR_EM6 EXTI_EMR_MR6
#define EXTI_EMR_EM7 EXTI_EMR_MR7
#define EXTI_EMR_EM8 EXTI_EMR_MR8
#define EXTI_EMR_EM9 EXTI_EMR_MR9
#define EXTI_EMR_EM10 EXTI_EMR_MR10
#define EXTI_EMR_EM11 EXTI_EMR_MR11
#define EXTI_EMR_EM12 EXTI_EMR_MR12
#define EXTI_EMR_EM13 EXTI_EMR_MR13
#define EXTI_EMR_EM14 EXTI_EMR_MR14
#define EXTI_EMR_EM15 EXTI_EMR_MR15
#define EXTI_EMR_EM16 EXTI_EMR_MR16
#define EXTI_EMR_EM17 EXTI_EMR_MR17
#define EXTI_EMR_EM18 EXTI_EMR_MR18
#define EXTI_EMR_EM19 EXTI_EMR_MR19
#define EXTI_EMR_EM20 EXTI_EMR_MR20
#define EXTI_EMR_EM21 EXTI_EMR_MR21
#define EXTI_EMR_EM22 EXTI_EMR_MR22
#define EXTI_EMR_EM23 EXTI_EMR_MR23
#define EXTI_EMR_EM24 EXTI_EMR_MR24
/****************** Bit definition for EXTI_RTSR register *******************/
#define EXTI_RTSR_TR0 0x00000001U /*!< Rising trigger event configuration bit of line 0 */
#define EXTI_RTSR_TR1 0x00000002U /*!< Rising trigger event configuration bit of line 1 */
#define EXTI_RTSR_TR2 0x00000004U /*!< Rising trigger event configuration bit of line 2 */
#define EXTI_RTSR_TR3 0x00000008U /*!< Rising trigger event configuration bit of line 3 */
#define EXTI_RTSR_TR4 0x00000010U /*!< Rising trigger event configuration bit of line 4 */
#define EXTI_RTSR_TR5 0x00000020U /*!< Rising trigger event configuration bit of line 5 */
#define EXTI_RTSR_TR6 0x00000040U /*!< Rising trigger event configuration bit of line 6 */
#define EXTI_RTSR_TR7 0x00000080U /*!< Rising trigger event configuration bit of line 7 */
#define EXTI_RTSR_TR8 0x00000100U /*!< Rising trigger event configuration bit of line 8 */
#define EXTI_RTSR_TR9 0x00000200U /*!< Rising trigger event configuration bit of line 9 */
#define EXTI_RTSR_TR10 0x00000400U /*!< Rising trigger event configuration bit of line 10 */
#define EXTI_RTSR_TR11 0x00000800U /*!< Rising trigger event configuration bit of line 11 */
#define EXTI_RTSR_TR12 0x00001000U /*!< Rising trigger event configuration bit of line 12 */
#define EXTI_RTSR_TR13 0x00002000U /*!< Rising trigger event configuration bit of line 13 */
#define EXTI_RTSR_TR14 0x00004000U /*!< Rising trigger event configuration bit of line 14 */
#define EXTI_RTSR_TR15 0x00008000U /*!< Rising trigger event configuration bit of line 15 */
#define EXTI_RTSR_TR16 0x00010000U /*!< Rising trigger event configuration bit of line 16 */
#define EXTI_RTSR_TR17 0x00020000U /*!< Rising trigger event configuration bit of line 17 */
#define EXTI_RTSR_TR18 0x00040000U /*!< Rising trigger event configuration bit of line 18 */
#define EXTI_RTSR_TR19 0x00080000U /*!< Rising trigger event configuration bit of line 19 */
#define EXTI_RTSR_TR20 0x00100000U /*!< Rising trigger event configuration bit of line 20 */
#define EXTI_RTSR_TR21 0x00200000U /*!< Rising trigger event configuration bit of line 21 */
#define EXTI_RTSR_TR22 0x00400000U /*!< Rising trigger event configuration bit of line 22 */
#define EXTI_RTSR_TR23 0x00800000U /*!< Rising trigger event configuration bit of line 23 */
#define EXTI_RTSR_TR24 0x01000000U /*!< Rising trigger event configuration bit of line 24 */
/****************** Bit definition for EXTI_FTSR register *******************/
#define EXTI_FTSR_TR0 0x00000001U /*!< Falling trigger event configuration bit of line 0 */
#define EXTI_FTSR_TR1 0x00000002U /*!< Falling trigger event configuration bit of line 1 */
#define EXTI_FTSR_TR2 0x00000004U /*!< Falling trigger event configuration bit of line 2 */
#define EXTI_FTSR_TR3 0x00000008U /*!< Falling trigger event configuration bit of line 3 */
#define EXTI_FTSR_TR4 0x00000010U /*!< Falling trigger event configuration bit of line 4 */
#define EXTI_FTSR_TR5 0x00000020U /*!< Falling trigger event configuration bit of line 5 */
#define EXTI_FTSR_TR6 0x00000040U /*!< Falling trigger event configuration bit of line 6 */
#define EXTI_FTSR_TR7 0x00000080U /*!< Falling trigger event configuration bit of line 7 */
#define EXTI_FTSR_TR8 0x00000100U /*!< Falling trigger event configuration bit of line 8 */
#define EXTI_FTSR_TR9 0x00000200U /*!< Falling trigger event configuration bit of line 9 */
#define EXTI_FTSR_TR10 0x00000400U /*!< Falling trigger event configuration bit of line 10 */
#define EXTI_FTSR_TR11 0x00000800U /*!< Falling trigger event configuration bit of line 11 */
#define EXTI_FTSR_TR12 0x00001000U /*!< Falling trigger event configuration bit of line 12 */
#define EXTI_FTSR_TR13 0x00002000U /*!< Falling trigger event configuration bit of line 13 */
#define EXTI_FTSR_TR14 0x00004000U /*!< Falling trigger event configuration bit of line 14 */
#define EXTI_FTSR_TR15 0x00008000U /*!< Falling trigger event configuration bit of line 15 */
#define EXTI_FTSR_TR16 0x00010000U /*!< Falling trigger event configuration bit of line 16 */
#define EXTI_FTSR_TR17 0x00020000U /*!< Falling trigger event configuration bit of line 17 */
#define EXTI_FTSR_TR18 0x00040000U /*!< Falling trigger event configuration bit of line 18 */
#define EXTI_FTSR_TR19 0x00080000U /*!< Falling trigger event configuration bit of line 19 */
#define EXTI_FTSR_TR20 0x00100000U /*!< Falling trigger event configuration bit of line 20 */
#define EXTI_FTSR_TR21 0x00200000U /*!< Falling trigger event configuration bit of line 21 */
#define EXTI_FTSR_TR22 0x00400000U /*!< Falling trigger event configuration bit of line 22 */
#define EXTI_FTSR_TR23 0x00800000U /*!< Falling trigger event configuration bit of line 23 */
#define EXTI_FTSR_TR24 0x01000000U /*!< Falling trigger event configuration bit of line 24 */
/****************** Bit definition for EXTI_SWIER register ******************/
#define EXTI_SWIER_SWIER0 0x00000001U /*!< Software Interrupt on line 0 */
#define EXTI_SWIER_SWIER1 0x00000002U /*!< Software Interrupt on line 1 */
#define EXTI_SWIER_SWIER2 0x00000004U /*!< Software Interrupt on line 2 */
#define EXTI_SWIER_SWIER3 0x00000008U /*!< Software Interrupt on line 3 */
#define EXTI_SWIER_SWIER4 0x00000010U /*!< Software Interrupt on line 4 */
#define EXTI_SWIER_SWIER5 0x00000020U /*!< Software Interrupt on line 5 */
#define EXTI_SWIER_SWIER6 0x00000040U /*!< Software Interrupt on line 6 */
#define EXTI_SWIER_SWIER7 0x00000080U /*!< Software Interrupt on line 7 */
#define EXTI_SWIER_SWIER8 0x00000100U /*!< Software Interrupt on line 8 */
#define EXTI_SWIER_SWIER9 0x00000200U /*!< Software Interrupt on line 9 */
#define EXTI_SWIER_SWIER10 0x00000400U /*!< Software Interrupt on line 10 */
#define EXTI_SWIER_SWIER11 0x00000800U /*!< Software Interrupt on line 11 */
#define EXTI_SWIER_SWIER12 0x00001000U /*!< Software Interrupt on line 12 */
#define EXTI_SWIER_SWIER13 0x00002000U /*!< Software Interrupt on line 13 */
#define EXTI_SWIER_SWIER14 0x00004000U /*!< Software Interrupt on line 14 */
#define EXTI_SWIER_SWIER15 0x00008000U /*!< Software Interrupt on line 15 */
#define EXTI_SWIER_SWIER16 0x00010000U /*!< Software Interrupt on line 16 */
#define EXTI_SWIER_SWIER17 0x00020000U /*!< Software Interrupt on line 17 */
#define EXTI_SWIER_SWIER18 0x00040000U /*!< Software Interrupt on line 18 */
#define EXTI_SWIER_SWIER19 0x00080000U /*!< Software Interrupt on line 19 */
#define EXTI_SWIER_SWIER20 0x00100000U /*!< Software Interrupt on line 20 */
#define EXTI_SWIER_SWIER21 0x00200000U /*!< Software Interrupt on line 21 */
#define EXTI_SWIER_SWIER22 0x00400000U /*!< Software Interrupt on line 22 */
#define EXTI_SWIER_SWIER23 0x00800000U /*!< Software Interrupt on line 23 */
#define EXTI_SWIER_SWIER24 0x01000000U /*!< Software Interrupt on line 24 */
/******************* Bit definition for EXTI_PR register ********************/
#define EXTI_PR_PR0 0x00000001U /*!< Pending bit for line 0 */
#define EXTI_PR_PR1 0x00000002U /*!< Pending bit for line 1 */
#define EXTI_PR_PR2 0x00000004U /*!< Pending bit for line 2 */
#define EXTI_PR_PR3 0x00000008U /*!< Pending bit for line 3 */
#define EXTI_PR_PR4 0x00000010U /*!< Pending bit for line 4 */
#define EXTI_PR_PR5 0x00000020U /*!< Pending bit for line 5 */
#define EXTI_PR_PR6 0x00000040U /*!< Pending bit for line 6 */
#define EXTI_PR_PR7 0x00000080U /*!< Pending bit for line 7 */
#define EXTI_PR_PR8 0x00000100U /*!< Pending bit for line 8 */
#define EXTI_PR_PR9 0x00000200U /*!< Pending bit for line 9 */
#define EXTI_PR_PR10 0x00000400U /*!< Pending bit for line 10 */
#define EXTI_PR_PR11 0x00000800U /*!< Pending bit for line 11 */
#define EXTI_PR_PR12 0x00001000U /*!< Pending bit for line 12 */
#define EXTI_PR_PR13 0x00002000U /*!< Pending bit for line 13 */
#define EXTI_PR_PR14 0x00004000U /*!< Pending bit for line 14 */
#define EXTI_PR_PR15 0x00008000U /*!< Pending bit for line 15 */
#define EXTI_PR_PR16 0x00010000U /*!< Pending bit for line 16 */
#define EXTI_PR_PR17 0x00020000U /*!< Pending bit for line 17 */
#define EXTI_PR_PR18 0x00040000U /*!< Pending bit for line 18 */
#define EXTI_PR_PR19 0x00080000U /*!< Pending bit for line 19 */
#define EXTI_PR_PR20 0x00100000U /*!< Pending bit for line 20 */
#define EXTI_PR_PR21 0x00200000U /*!< Pending bit for line 21 */
#define EXTI_PR_PR22 0x00400000U /*!< Pending bit for line 22 */
#define EXTI_PR_PR23 0x00800000U /*!< Pending bit for line 23 */
#define EXTI_PR_PR24 0x01000000U /*!< Pending bit for line 24 */
/******************************************************************************/
/* */
/* FLASH */
/* */
/******************************************************************************/
/*
* @brief FLASH Total Sectors Number
*/
#define FLASH_SECTOR_TOTAL 24
/******************* Bits definition for FLASH_ACR register *****************/
#define FLASH_ACR_LATENCY 0x0000000FU
#define FLASH_ACR_LATENCY_0WS 0x00000000U
#define FLASH_ACR_LATENCY_1WS 0x00000001U
#define FLASH_ACR_LATENCY_2WS 0x00000002U
#define FLASH_ACR_LATENCY_3WS 0x00000003U
#define FLASH_ACR_LATENCY_4WS 0x00000004U
#define FLASH_ACR_LATENCY_5WS 0x00000005U
#define FLASH_ACR_LATENCY_6WS 0x00000006U
#define FLASH_ACR_LATENCY_7WS 0x00000007U
#define FLASH_ACR_LATENCY_8WS 0x00000008U
#define FLASH_ACR_LATENCY_9WS 0x00000009U
#define FLASH_ACR_LATENCY_10WS 0x0000000AU
#define FLASH_ACR_LATENCY_11WS 0x0000000BU
#define FLASH_ACR_LATENCY_12WS 0x0000000CU
#define FLASH_ACR_LATENCY_13WS 0x0000000DU
#define FLASH_ACR_LATENCY_14WS 0x0000000EU
#define FLASH_ACR_LATENCY_15WS 0x0000000FU
#define FLASH_ACR_PRFTEN 0x00000100U
#define FLASH_ACR_ARTEN 0x00000200U
#define FLASH_ACR_ARTRST 0x00000800U
/******************* Bits definition for FLASH_SR register ******************/
#define FLASH_SR_EOP 0x00000001U
#define FLASH_SR_OPERR 0x00000002U
#define FLASH_SR_WRPERR 0x00000010U
#define FLASH_SR_PGAERR 0x00000020U
#define FLASH_SR_PGPERR 0x00000040U
#define FLASH_SR_ERSERR 0x00000080U
#define FLASH_SR_BSY 0x00010000U
/******************* Bits definition for FLASH_CR register ******************/
#define FLASH_CR_PG 0x00000001U
#define FLASH_CR_SER 0x00000002U
#define FLASH_CR_MER 0x00000004U
#define FLASH_CR_MER1 FLASH_CR_MER
#define FLASH_CR_SNB 0x000000F8U
#define FLASH_CR_SNB_0 0x00000008U
#define FLASH_CR_SNB_1 0x00000010U
#define FLASH_CR_SNB_2 0x00000020U
#define FLASH_CR_SNB_3 0x00000040U
#define FLASH_CR_SNB_4 0x00000080U
#define FLASH_CR_PSIZE 0x00000300U
#define FLASH_CR_PSIZE_0 0x00000100U
#define FLASH_CR_PSIZE_1 0x00000200U
#define FLASH_CR_MER2 0x00008000U
#define FLASH_CR_STRT 0x00010000U
#define FLASH_CR_EOPIE 0x01000000U
#define FLASH_CR_ERRIE 0x02000000U
#define FLASH_CR_LOCK 0x80000000U
/******************* Bits definition for FLASH_OPTCR register ***************/
#define FLASH_OPTCR_OPTLOCK 0x00000001U
#define FLASH_OPTCR_OPTSTRT 0x00000002U
#define FLASH_OPTCR_BOR_LEV 0x0000000CU
#define FLASH_OPTCR_BOR_LEV_0 0x00000004U
#define FLASH_OPTCR_BOR_LEV_1 0x00000008U
#define FLASH_OPTCR_WWDG_SW 0x00000010U
#define FLASH_OPTCR_IWDG_SW 0x00000020U
#define FLASH_OPTCR_nRST_STOP 0x00000040U
#define FLASH_OPTCR_nRST_STDBY 0x00000080U
#define FLASH_OPTCR_RDP 0x0000FF00U
#define FLASH_OPTCR_RDP_0 0x00000100U
#define FLASH_OPTCR_RDP_1 0x00000200U
#define FLASH_OPTCR_RDP_2 0x00000400U
#define FLASH_OPTCR_RDP_3 0x00000800U
#define FLASH_OPTCR_RDP_4 0x00001000U
#define FLASH_OPTCR_RDP_5 0x00002000U
#define FLASH_OPTCR_RDP_6 0x00004000U
#define FLASH_OPTCR_RDP_7 0x00008000U
#define FLASH_OPTCR_nWRP 0x0FFF0000U
#define FLASH_OPTCR_nWRP_0 0x00010000U
#define FLASH_OPTCR_nWRP_1 0x00020000U
#define FLASH_OPTCR_nWRP_2 0x00040000U
#define FLASH_OPTCR_nWRP_3 0x00080000U
#define FLASH_OPTCR_nWRP_4 0x00100000U
#define FLASH_OPTCR_nWRP_5 0x00200000U
#define FLASH_OPTCR_nWRP_6 0x00400000U
#define FLASH_OPTCR_nWRP_7 0x00800000U
#define FLASH_OPTCR_nWRP_8 0x01000000U
#define FLASH_OPTCR_nWRP_9 0x02000000U
#define FLASH_OPTCR_nWRP_10 0x04000000U
#define FLASH_OPTCR_nWRP_11 0x08000000U
#define FLASH_OPTCR_nDBOOT 0x10000000U
#define FLASH_OPTCR_nDBANK 0x20000000U
#define FLASH_OPTCR_IWDG_STDBY 0x40000000U
#define FLASH_OPTCR_IWDG_STOP 0x80000000U
/******************* Bits definition for FLASH_OPTCR1 register ***************/
#define FLASH_OPTCR1_BOOT_ADD0 0x0000FFFFU
#define FLASH_OPTCR1_BOOT_ADD1 0xFFFF0000U
/******************************************************************************/
/* */
/* Flexible Memory Controller */
/* */
/******************************************************************************/
/****************** Bit definition for FMC_BCR1 register *******************/
#define FMC_BCR1_MBKEN 0x00000001U /*!<Memory bank enable bit */
#define FMC_BCR1_MUXEN 0x00000002U /*!<Address/data multiplexing enable bit */
#define FMC_BCR1_MTYP 0x0000000CU /*!<MTYP[1:0] bits (Memory type) */
#define FMC_BCR1_MTYP_0 0x00000004U /*!<Bit 0 */
#define FMC_BCR1_MTYP_1 0x00000008U /*!<Bit 1 */
#define FMC_BCR1_MWID 0x00000030U /*!<MWID[1:0] bits (Memory data bus width) */
#define FMC_BCR1_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_BCR1_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_BCR1_FACCEN 0x00000040U /*!<Flash access enable */
#define FMC_BCR1_BURSTEN 0x00000100U /*!<Burst enable bit */
#define FMC_BCR1_WAITPOL 0x00000200U /*!<Wait signal polarity bit */
#define FMC_BCR1_WRAPMOD 0x00000400U /*!<Wrapped burst mode support */
#define FMC_BCR1_WAITCFG 0x00000800U /*!<Wait timing configuration */
#define FMC_BCR1_WREN 0x00001000U /*!<Write enable bit */
#define FMC_BCR1_WAITEN 0x00002000U /*!<Wait enable bit */
#define FMC_BCR1_EXTMOD 0x00004000U /*!<Extended mode enable */
#define FMC_BCR1_ASYNCWAIT 0x00008000U /*!<Asynchronous wait */
#define FMC_BCR1_CPSIZE 0x00070000U /*!<CRAM page size */
#define FMC_BCR1_CPSIZE_0 0x00010000U /*!<Bit 0 */
#define FMC_BCR1_CPSIZE_1 0x00020000U /*!<Bit 1 */
#define FMC_BCR1_CPSIZE_2 0x00040000U /*!<Bit 2 */
#define FMC_BCR1_CBURSTRW 0x00080000U /*!<Write burst enable */
#define FMC_BCR1_CCLKEN 0x00100000U /*!<Continous clock enable */
#define FMC_BCR1_WFDIS 0x00200000U /*!<Write FIFO Disable */
/****************** Bit definition for FMC_BCR2 register *******************/
#define FMC_BCR2_MBKEN 0x00000001U /*!<Memory bank enable bit */
#define FMC_BCR2_MUXEN 0x00000002U /*!<Address/data multiplexing enable bit */
#define FMC_BCR2_MTYP 0x0000000CU /*!<MTYP[1:0] bits (Memory type) */
#define FMC_BCR2_MTYP_0 0x00000004U /*!<Bit 0 */
#define FMC_BCR2_MTYP_1 0x00000008U /*!<Bit 1 */
#define FMC_BCR2_MWID 0x00000030U /*!<MWID[1:0] bits (Memory data bus width) */
#define FMC_BCR2_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_BCR2_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_BCR2_FACCEN 0x00000040U /*!<Flash access enable */
#define FMC_BCR2_BURSTEN 0x00000100U /*!<Burst enable bit */
#define FMC_BCR2_WAITPOL 0x00000200U /*!<Wait signal polarity bit */
#define FMC_BCR2_WRAPMOD 0x00000400U /*!<Wrapped burst mode support */
#define FMC_BCR2_WAITCFG 0x00000800U /*!<Wait timing configuration */
#define FMC_BCR2_WREN 0x00001000U /*!<Write enable bit */
#define FMC_BCR2_WAITEN 0x00002000U /*!<Wait enable bit */
#define FMC_BCR2_EXTMOD 0x00004000U /*!<Extended mode enable */
#define FMC_BCR2_ASYNCWAIT 0x00008000U /*!<Asynchronous wait */
#define FMC_BCR2_CPSIZE 0x00070000U /*!<CRAM page size */
#define FMC_BCR2_CPSIZE_0 0x00010000U /*!<Bit 0 */
#define FMC_BCR2_CPSIZE_1 0x00020000U /*!<Bit 1 */
#define FMC_BCR2_CPSIZE_2 0x00040000U /*!<Bit 2 */
#define FMC_BCR2_CBURSTRW 0x00080000U /*!<Write burst enable */
/****************** Bit definition for FMC_BCR3 register *******************/
#define FMC_BCR3_MBKEN 0x00000001U /*!<Memory bank enable bit */
#define FMC_BCR3_MUXEN 0x00000002U /*!<Address/data multiplexing enable bit */
#define FMC_BCR3_MTYP 0x0000000CU /*!<MTYP[1:0] bits (Memory type) */
#define FMC_BCR3_MTYP_0 0x00000004U /*!<Bit 0 */
#define FMC_BCR3_MTYP_1 0x00000008U /*!<Bit 1 */
#define FMC_BCR3_MWID 0x00000030U /*!<MWID[1:0] bits (Memory data bus width) */
#define FMC_BCR3_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_BCR3_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_BCR3_FACCEN 0x00000040U /*!<Flash access enable */
#define FMC_BCR3_BURSTEN 0x00000100U /*!<Burst enable bit */
#define FMC_BCR3_WAITPOL 0x00000200U /*!<Wait signal polarity bit */
#define FMC_BCR3_WRAPMOD 0x00000400U /*!<Wrapped burst mode support */
#define FMC_BCR3_WAITCFG 0x00000800U /*!<Wait timing configuration */
#define FMC_BCR3_WREN 0x00001000U /*!<Write enable bit */
#define FMC_BCR3_WAITEN 0x00002000U /*!<Wait enable bit */
#define FMC_BCR3_EXTMOD 0x00004000U /*!<Extended mode enable */
#define FMC_BCR3_ASYNCWAIT 0x00008000U /*!<Asynchronous wait */
#define FMC_BCR3_CPSIZE 0x00070000U /*!<CRAM page size */
#define FMC_BCR3_CPSIZE_0 0x00010000U /*!<Bit 0 */
#define FMC_BCR3_CPSIZE_1 0x00020000U /*!<Bit 1 */
#define FMC_BCR3_CPSIZE_2 0x00040000U /*!<Bit 2 */
#define FMC_BCR3_CBURSTRW 0x00080000U /*!<Write burst enable */
/****************** Bit definition for FMC_BCR4 register *******************/
#define FMC_BCR4_MBKEN 0x00000001U /*!<Memory bank enable bit */
#define FMC_BCR4_MUXEN 0x00000002U /*!<Address/data multiplexing enable bit */
#define FMC_BCR4_MTYP 0x0000000CU /*!<MTYP[1:0] bits (Memory type) */
#define FMC_BCR4_MTYP_0 0x00000004U /*!<Bit 0 */
#define FMC_BCR4_MTYP_1 0x00000008U /*!<Bit 1 */
#define FMC_BCR4_MWID 0x00000030U /*!<MWID[1:0] bits (Memory data bus width) */
#define FMC_BCR4_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_BCR4_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_BCR4_FACCEN 0x00000040U /*!<Flash access enable */
#define FMC_BCR4_BURSTEN 0x00000100U /*!<Burst enable bit */
#define FMC_BCR4_WAITPOL 0x00000200U /*!<Wait signal polarity bit */
#define FMC_BCR4_WRAPMOD 0x00000400U /*!<Wrapped burst mode support */
#define FMC_BCR4_WAITCFG 0x00000800U /*!<Wait timing configuration */
#define FMC_BCR4_WREN 0x00001000U /*!<Write enable bit */
#define FMC_BCR4_WAITEN 0x00002000U /*!<Wait enable bit */
#define FMC_BCR4_EXTMOD 0x00004000U /*!<Extended mode enable */
#define FMC_BCR4_ASYNCWAIT 0x00008000U /*!<Asynchronous wait */
#define FMC_BCR4_CPSIZE 0x00070000U /*!<CRAM page size */
#define FMC_BCR4_CPSIZE_0 0x00010000U /*!<Bit 0 */
#define FMC_BCR4_CPSIZE_1 0x00020000U /*!<Bit 1 */
#define FMC_BCR4_CPSIZE_2 0x00040000U /*!<Bit 2 */
#define FMC_BCR4_CBURSTRW 0x00080000U /*!<Write burst enable */
/****************** Bit definition for FMC_BTR1 register ******************/
#define FMC_BTR1_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BTR1_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BTR1_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BTR1_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BTR1_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BTR1_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BTR1_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BTR1_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BTR1_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BTR1_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BTR1_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BTR1_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BTR1_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BTR1_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BTR1_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BTR1_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BTR1_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BTR1_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BTR1_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BTR1_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BTR1_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BTR1_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BTR1_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BTR1_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BTR1_CLKDIV 0x00F00000U /*!<CLKDIV[3:0] bits (Clock divide ratio) */
#define FMC_BTR1_CLKDIV_0 0x00100000U /*!<Bit 0 */
#define FMC_BTR1_CLKDIV_1 0x00200000U /*!<Bit 1 */
#define FMC_BTR1_CLKDIV_2 0x00400000U /*!<Bit 2 */
#define FMC_BTR1_CLKDIV_3 0x00800000U /*!<Bit 3 */
#define FMC_BTR1_DATLAT 0x0F000000U /*!<DATLA[3:0] bits (Data latency) */
#define FMC_BTR1_DATLAT_0 0x01000000U /*!<Bit 0 */
#define FMC_BTR1_DATLAT_1 0x02000000U /*!<Bit 1 */
#define FMC_BTR1_DATLAT_2 0x04000000U /*!<Bit 2 */
#define FMC_BTR1_DATLAT_3 0x08000000U /*!<Bit 3 */
#define FMC_BTR1_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BTR1_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BTR1_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BTR2 register *******************/
#define FMC_BTR2_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BTR2_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BTR2_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BTR2_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BTR2_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BTR2_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BTR2_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BTR2_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BTR2_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BTR2_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BTR2_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BTR2_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BTR2_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BTR2_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BTR2_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BTR2_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BTR2_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BTR2_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BTR2_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BTR2_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BTR2_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BTR2_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BTR2_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BTR2_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BTR2_CLKDIV 0x00F00000U /*!<CLKDIV[3:0] bits (Clock divide ratio) */
#define FMC_BTR2_CLKDIV_0 0x00100000U /*!<Bit 0 */
#define FMC_BTR2_CLKDIV_1 0x00200000U /*!<Bit 1 */
#define FMC_BTR2_CLKDIV_2 0x00400000U /*!<Bit 2 */
#define FMC_BTR2_CLKDIV_3 0x00800000U /*!<Bit 3 */
#define FMC_BTR2_DATLAT 0x0F000000U /*!<DATLA[3:0] bits (Data latency) */
#define FMC_BTR2_DATLAT_0 0x01000000U /*!<Bit 0 */
#define FMC_BTR2_DATLAT_1 0x02000000U /*!<Bit 1 */
#define FMC_BTR2_DATLAT_2 0x04000000U /*!<Bit 2 */
#define FMC_BTR2_DATLAT_3 0x08000000U /*!<Bit 3 */
#define FMC_BTR2_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BTR2_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BTR2_ACCMOD_1 0x20000000U /*!<Bit 1 */
/******************* Bit definition for FMC_BTR3 register *******************/
#define FMC_BTR3_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BTR3_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BTR3_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BTR3_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BTR3_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BTR3_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BTR3_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BTR3_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BTR3_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BTR3_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BTR3_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BTR3_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BTR3_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BTR3_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BTR3_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BTR3_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BTR3_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BTR3_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BTR3_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BTR3_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BTR3_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BTR3_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BTR3_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BTR3_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BTR3_CLKDIV 0x00F00000U /*!<CLKDIV[3:0] bits (Clock divide ratio) */
#define FMC_BTR3_CLKDIV_0 0x00100000U /*!<Bit 0 */
#define FMC_BTR3_CLKDIV_1 0x00200000U /*!<Bit 1 */
#define FMC_BTR3_CLKDIV_2 0x00400000U /*!<Bit 2 */
#define FMC_BTR3_CLKDIV_3 0x00800000U /*!<Bit 3 */
#define FMC_BTR3_DATLAT 0x0F000000U /*!<DATLA[3:0] bits (Data latency) */
#define FMC_BTR3_DATLAT_0 0x01000000U /*!<Bit 0 */
#define FMC_BTR3_DATLAT_1 0x02000000U /*!<Bit 1 */
#define FMC_BTR3_DATLAT_2 0x04000000U /*!<Bit 2 */
#define FMC_BTR3_DATLAT_3 0x08000000U /*!<Bit 3 */
#define FMC_BTR3_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BTR3_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BTR3_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BTR4 register *******************/
#define FMC_BTR4_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BTR4_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BTR4_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BTR4_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BTR4_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BTR4_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BTR4_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BTR4_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BTR4_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BTR4_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BTR4_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BTR4_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BTR4_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BTR4_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BTR4_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BTR4_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BTR4_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BTR4_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BTR4_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BTR4_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BTR4_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BTR4_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BTR4_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BTR4_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BTR4_CLKDIV 0x00F00000U /*!<CLKDIV[3:0] bits (Clock divide ratio) */
#define FMC_BTR4_CLKDIV_0 0x00100000U /*!<Bit 0 */
#define FMC_BTR4_CLKDIV_1 0x00200000U /*!<Bit 1 */
#define FMC_BTR4_CLKDIV_2 0x00400000U /*!<Bit 2 */
#define FMC_BTR4_CLKDIV_3 0x00800000U /*!<Bit 3 */
#define FMC_BTR4_DATLAT 0x0F000000U /*!<DATLA[3:0] bits (Data latency) */
#define FMC_BTR4_DATLAT_0 0x01000000U /*!<Bit 0 */
#define FMC_BTR4_DATLAT_1 0x02000000U /*!<Bit 1 */
#define FMC_BTR4_DATLAT_2 0x04000000U /*!<Bit 2 */
#define FMC_BTR4_DATLAT_3 0x08000000U /*!<Bit 3 */
#define FMC_BTR4_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BTR4_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BTR4_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BWTR1 register ******************/
#define FMC_BWTR1_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BWTR1_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BWTR1_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BWTR1_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BWTR1_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BWTR1_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BWTR1_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BWTR1_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BWTR1_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BWTR1_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BWTR1_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BWTR1_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BWTR1_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BWTR1_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BWTR1_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BWTR1_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BWTR1_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BWTR1_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BWTR1_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BWTR1_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BWTR1_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BWTR1_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BWTR1_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BWTR1_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BWTR1_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BWTR1_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BWTR1_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BWTR2 register ******************/
#define FMC_BWTR2_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BWTR2_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BWTR2_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BWTR2_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BWTR2_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BWTR2_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BWTR2_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BWTR2_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BWTR2_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BWTR2_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BWTR2_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BWTR2_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BWTR2_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BWTR2_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BWTR2_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BWTR2_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BWTR2_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BWTR2_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BWTR2_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BWTR2_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BWTR2_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BWTR2_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BWTR2_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BWTR2_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BWTR2_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BWTR2_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BWTR2_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BWTR3 register ******************/
#define FMC_BWTR3_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BWTR3_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BWTR3_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BWTR3_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BWTR3_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BWTR3_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BWTR3_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BWTR3_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BWTR3_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BWTR3_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BWTR3_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BWTR3_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BWTR3_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BWTR3_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BWTR3_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BWTR3_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BWTR3_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BWTR3_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BWTR3_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BWTR3_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BWTR3_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BWTR3_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BWTR3_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BWTR3_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BWTR3_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BWTR3_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BWTR3_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_BWTR4 register ******************/
#define FMC_BWTR4_ADDSET 0x0000000FU /*!<ADDSET[3:0] bits (Address setup phase duration) */
#define FMC_BWTR4_ADDSET_0 0x00000001U /*!<Bit 0 */
#define FMC_BWTR4_ADDSET_1 0x00000002U /*!<Bit 1 */
#define FMC_BWTR4_ADDSET_2 0x00000004U /*!<Bit 2 */
#define FMC_BWTR4_ADDSET_3 0x00000008U /*!<Bit 3 */
#define FMC_BWTR4_ADDHLD 0x000000F0U /*!<ADDHLD[3:0] bits (Address-hold phase duration) */
#define FMC_BWTR4_ADDHLD_0 0x00000010U /*!<Bit 0 */
#define FMC_BWTR4_ADDHLD_1 0x00000020U /*!<Bit 1 */
#define FMC_BWTR4_ADDHLD_2 0x00000040U /*!<Bit 2 */
#define FMC_BWTR4_ADDHLD_3 0x00000080U /*!<Bit 3 */
#define FMC_BWTR4_DATAST 0x0000FF00U /*!<DATAST [3:0] bits (Data-phase duration) */
#define FMC_BWTR4_DATAST_0 0x00000100U /*!<Bit 0 */
#define FMC_BWTR4_DATAST_1 0x00000200U /*!<Bit 1 */
#define FMC_BWTR4_DATAST_2 0x00000400U /*!<Bit 2 */
#define FMC_BWTR4_DATAST_3 0x00000800U /*!<Bit 3 */
#define FMC_BWTR4_DATAST_4 0x00001000U /*!<Bit 4 */
#define FMC_BWTR4_DATAST_5 0x00002000U /*!<Bit 5 */
#define FMC_BWTR4_DATAST_6 0x00004000U /*!<Bit 6 */
#define FMC_BWTR4_DATAST_7 0x00008000U /*!<Bit 7 */
#define FMC_BWTR4_BUSTURN 0x000F0000U /*!<BUSTURN[3:0] bits (Bus turnaround phase duration) */
#define FMC_BWTR4_BUSTURN_0 0x00010000U /*!<Bit 0 */
#define FMC_BWTR4_BUSTURN_1 0x00020000U /*!<Bit 1 */
#define FMC_BWTR4_BUSTURN_2 0x00040000U /*!<Bit 2 */
#define FMC_BWTR4_BUSTURN_3 0x00080000U /*!<Bit 3 */
#define FMC_BWTR4_ACCMOD 0x30000000U /*!<ACCMOD[1:0] bits (Access mode) */
#define FMC_BWTR4_ACCMOD_0 0x10000000U /*!<Bit 0 */
#define FMC_BWTR4_ACCMOD_1 0x20000000U /*!<Bit 1 */
/****************** Bit definition for FMC_PCR register *******************/
#define FMC_PCR_PWAITEN 0x00000002U /*!<Wait feature enable bit */
#define FMC_PCR_PBKEN 0x00000004U /*!<PC Card/NAND Flash memory bank enable bit */
#define FMC_PCR_PTYP 0x00000008U /*!<Memory type */
#define FMC_PCR_PWID 0x00000030U /*!<PWID[1:0] bits (NAND Flash databus width) */
#define FMC_PCR_PWID_0 0x00000010U /*!<Bit 0 */
#define FMC_PCR_PWID_1 0x00000020U /*!<Bit 1 */
#define FMC_PCR_ECCEN 0x00000040U /*!<ECC computation logic enable bit */
#define FMC_PCR_TCLR 0x00001E00U /*!<TCLR[3:0] bits (CLE to RE delay) */
#define FMC_PCR_TCLR_0 0x00000200U /*!<Bit 0 */
#define FMC_PCR_TCLR_1 0x00000400U /*!<Bit 1 */
#define FMC_PCR_TCLR_2 0x00000800U /*!<Bit 2 */
#define FMC_PCR_TCLR_3 0x00001000U /*!<Bit 3 */
#define FMC_PCR_TAR 0x0001E000U /*!<TAR[3:0] bits (ALE to RE delay) */
#define FMC_PCR_TAR_0 0x00002000U /*!<Bit 0 */
#define FMC_PCR_TAR_1 0x00004000U /*!<Bit 1 */
#define FMC_PCR_TAR_2 0x00008000U /*!<Bit 2 */
#define FMC_PCR_TAR_3 0x00010000U /*!<Bit 3 */
#define FMC_PCR_ECCPS 0x000E0000U /*!<ECCPS[2:0] bits (ECC page size) */
#define FMC_PCR_ECCPS_0 0x00020000U /*!<Bit 0 */
#define FMC_PCR_ECCPS_1 0x00040000U /*!<Bit 1 */
#define FMC_PCR_ECCPS_2 0x00080000U /*!<Bit 2 */
/******************* Bit definition for FMC_SR register *******************/
#define FMC_SR_IRS 0x01U /*!<Interrupt Rising Edge status */
#define FMC_SR_ILS 0x02U /*!<Interrupt Level status */
#define FMC_SR_IFS 0x04U /*!<Interrupt Falling Edge status */
#define FMC_SR_IREN 0x08U /*!<Interrupt Rising Edge detection Enable bit */
#define FMC_SR_ILEN 0x10U /*!<Interrupt Level detection Enable bit */
#define FMC_SR_IFEN 0x20U /*!<Interrupt Falling Edge detection Enable bit */
#define FMC_SR_FEMPT 0x40U /*!<FIFO empty */
/****************** Bit definition for FMC_PMEM register ******************/
#define FMC_PMEM_MEMSET3 0x000000FFU /*!<MEMSET3[7:0] bits (Common memory 3 setup time) */
#define FMC_PMEM_MEMSET3_0 0x00000001U /*!<Bit 0 */
#define FMC_PMEM_MEMSET3_1 0x00000002U /*!<Bit 1 */
#define FMC_PMEM_MEMSET3_2 0x00000004U /*!<Bit 2 */
#define FMC_PMEM_MEMSET3_3 0x00000008U /*!<Bit 3 */
#define FMC_PMEM_MEMSET3_4 0x00000010U /*!<Bit 4 */
#define FMC_PMEM_MEMSET3_5 0x00000020U /*!<Bit 5 */
#define FMC_PMEM_MEMSET3_6 0x00000040U /*!<Bit 6 */
#define FMC_PMEM_MEMSET3_7 0x00000080U /*!<Bit 7 */
#define FMC_PMEM_MEMWAIT3 0x0000FF00U /*!<MEMWAIT3[7:0] bits (Common memory 3 wait time) */
#define FMC_PMEM_MEMWAIT3_0 0x00000100U /*!<Bit 0 */
#define FMC_PMEM_MEMWAIT3_1 0x00000200U /*!<Bit 1 */
#define FMC_PMEM_MEMWAIT3_2 0x00000400U /*!<Bit 2 */
#define FMC_PMEM_MEMWAIT3_3 0x00000800U /*!<Bit 3 */
#define FMC_PMEM_MEMWAIT3_4 0x00001000U /*!<Bit 4 */
#define FMC_PMEM_MEMWAIT3_5 0x00002000U /*!<Bit 5 */
#define FMC_PMEM_MEMWAIT3_6 0x00004000U /*!<Bit 6 */
#define FMC_PMEM_MEMWAIT3_7 0x00008000U /*!<Bit 7 */
#define FMC_PMEM_MEMHOLD3 0x00FF0000U /*!<MEMHOLD3[7:0] bits (Common memory 3 hold time) */
#define FMC_PMEM_MEMHOLD3_0 0x00010000U /*!<Bit 0 */
#define FMC_PMEM_MEMHOLD3_1 0x00020000U /*!<Bit 1 */
#define FMC_PMEM_MEMHOLD3_2 0x00040000U /*!<Bit 2 */
#define FMC_PMEM_MEMHOLD3_3 0x00080000U /*!<Bit 3 */
#define FMC_PMEM_MEMHOLD3_4 0x00100000U /*!<Bit 4 */
#define FMC_PMEM_MEMHOLD3_5 0x00200000U /*!<Bit 5 */
#define FMC_PMEM_MEMHOLD3_6 0x00400000U /*!<Bit 6 */
#define FMC_PMEM_MEMHOLD3_7 0x00800000U /*!<Bit 7 */
#define FMC_PMEM_MEMHIZ3 0xFF000000U /*!<MEMHIZ3[7:0] bits (Common memory 3 databus HiZ time) */
#define FMC_PMEM_MEMHIZ3_0 0x01000000U /*!<Bit 0 */
#define FMC_PMEM_MEMHIZ3_1 0x02000000U /*!<Bit 1 */
#define FMC_PMEM_MEMHIZ3_2 0x04000000U /*!<Bit 2 */
#define FMC_PMEM_MEMHIZ3_3 0x08000000U /*!<Bit 3 */
#define FMC_PMEM_MEMHIZ3_4 0x10000000U /*!<Bit 4 */
#define FMC_PMEM_MEMHIZ3_5 0x20000000U /*!<Bit 5 */
#define FMC_PMEM_MEMHIZ3_6 0x40000000U /*!<Bit 6 */
#define FMC_PMEM_MEMHIZ3_7 0x80000000U /*!<Bit 7 */
/****************** Bit definition for FMC_PATT register ******************/
#define FMC_PATT_ATTSET3 0x000000FFU /*!<ATTSET3[7:0] bits (Attribute memory 3 setup time) */
#define FMC_PATT_ATTSET3_0 0x00000001U /*!<Bit 0 */
#define FMC_PATT_ATTSET3_1 0x00000002U /*!<Bit 1 */
#define FMC_PATT_ATTSET3_2 0x00000004U /*!<Bit 2 */
#define FMC_PATT_ATTSET3_3 0x00000008U /*!<Bit 3 */
#define FMC_PATT_ATTSET3_4 0x00000010U /*!<Bit 4 */
#define FMC_PATT_ATTSET3_5 0x00000020U /*!<Bit 5 */
#define FMC_PATT_ATTSET3_6 0x00000040U /*!<Bit 6 */
#define FMC_PATT_ATTSET3_7 0x00000080U /*!<Bit 7 */
#define FMC_PATT_ATTWAIT3 0x0000FF00U /*!<ATTWAIT3[7:0] bits (Attribute memory 3 wait time) */
#define FMC_PATT_ATTWAIT3_0 0x00000100U /*!<Bit 0 */
#define FMC_PATT_ATTWAIT3_1 0x00000200U /*!<Bit 1 */
#define FMC_PATT_ATTWAIT3_2 0x00000400U /*!<Bit 2 */
#define FMC_PATT_ATTWAIT3_3 0x00000800U /*!<Bit 3 */
#define FMC_PATT_ATTWAIT3_4 0x00001000U /*!<Bit 4 */
#define FMC_PATT_ATTWAIT3_5 0x00002000U /*!<Bit 5 */
#define FMC_PATT_ATTWAIT3_6 0x00004000U /*!<Bit 6 */
#define FMC_PATT_ATTWAIT3_7 0x00008000U /*!<Bit 7 */
#define FMC_PATT_ATTHOLD3 0x00FF0000U /*!<ATTHOLD3[7:0] bits (Attribute memory 3 hold time) */
#define FMC_PATT_ATTHOLD3_0 0x00010000U /*!<Bit 0 */
#define FMC_PATT_ATTHOLD3_1 0x00020000U /*!<Bit 1 */
#define FMC_PATT_ATTHOLD3_2 0x00040000U /*!<Bit 2 */
#define FMC_PATT_ATTHOLD3_3 0x00080000U /*!<Bit 3 */
#define FMC_PATT_ATTHOLD3_4 0x00100000U /*!<Bit 4 */
#define FMC_PATT_ATTHOLD3_5 0x00200000U /*!<Bit 5 */
#define FMC_PATT_ATTHOLD3_6 0x00400000U /*!<Bit 6 */
#define FMC_PATT_ATTHOLD3_7 0x00800000U /*!<Bit 7 */
#define FMC_PATT_ATTHIZ3 0xFF000000U /*!<ATTHIZ3[7:0] bits (Attribute memory 3 databus HiZ time) */
#define FMC_PATT_ATTHIZ3_0 0x01000000U /*!<Bit 0 */
#define FMC_PATT_ATTHIZ3_1 0x02000000U /*!<Bit 1 */
#define FMC_PATT_ATTHIZ3_2 0x04000000U /*!<Bit 2 */
#define FMC_PATT_ATTHIZ3_3 0x08000000U /*!<Bit 3 */
#define FMC_PATT_ATTHIZ3_4 0x10000000U /*!<Bit 4 */
#define FMC_PATT_ATTHIZ3_5 0x20000000U /*!<Bit 5 */
#define FMC_PATT_ATTHIZ3_6 0x40000000U /*!<Bit 6 */
#define FMC_PATT_ATTHIZ3_7 0x80000000U /*!<Bit 7 */
/****************** Bit definition for FMC_ECCR register ******************/
#define FMC_ECCR_ECC3 0xFFFFFFFFU /*!<ECC result */
/****************** Bit definition for FMC_SDCR1 register ******************/
#define FMC_SDCR1_NC 0x00000003U /*!<NC[1:0] bits (Number of column bits) */
#define FMC_SDCR1_NC_0 0x00000001U /*!<Bit 0 */
#define FMC_SDCR1_NC_1 0x00000002U /*!<Bit 1 */
#define FMC_SDCR1_NR 0x0000000CU /*!<NR[1:0] bits (Number of row bits) */
#define FMC_SDCR1_NR_0 0x00000004U /*!<Bit 0 */
#define FMC_SDCR1_NR_1 0x00000008U /*!<Bit 1 */
#define FMC_SDCR1_MWID 0x00000030U /*!<NR[1:0] bits (Number of row bits) */
#define FMC_SDCR1_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_SDCR1_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_SDCR1_NB 0x00000040U /*!<Number of internal bank */
#define FMC_SDCR1_CAS 0x00000180U /*!<CAS[1:0] bits (CAS latency) */
#define FMC_SDCR1_CAS_0 0x00000080U /*!<Bit 0 */
#define FMC_SDCR1_CAS_1 0x00000100U /*!<Bit 1 */
#define FMC_SDCR1_WP 0x00000200U /*!<Write protection */
#define FMC_SDCR1_SDCLK 0x00000C00U /*!<SDRAM clock configuration */
#define FMC_SDCR1_SDCLK_0 0x00000400U /*!<Bit 0 */
#define FMC_SDCR1_SDCLK_1 0x00000800U /*!<Bit 1 */
#define FMC_SDCR1_RBURST 0x00001000U /*!<Read burst */
#define FMC_SDCR1_RPIPE 0x00006000U /*!<Write protection */
#define FMC_SDCR1_RPIPE_0 0x00002000U /*!<Bit 0 */
#define FMC_SDCR1_RPIPE_1 0x00004000U /*!<Bit 1 */
/****************** Bit definition for FMC_SDCR2 register ******************/
#define FMC_SDCR2_NC 0x00000003U /*!<NC[1:0] bits (Number of column bits) */
#define FMC_SDCR2_NC_0 0x00000001U /*!<Bit 0 */
#define FMC_SDCR2_NC_1 0x00000002U /*!<Bit 1 */
#define FMC_SDCR2_NR 0x0000000CU /*!<NR[1:0] bits (Number of row bits) */
#define FMC_SDCR2_NR_0 0x00000004U /*!<Bit 0 */
#define FMC_SDCR2_NR_1 0x00000008U /*!<Bit 1 */
#define FMC_SDCR2_MWID 0x00000030U /*!<NR[1:0] bits (Number of row bits) */
#define FMC_SDCR2_MWID_0 0x00000010U /*!<Bit 0 */
#define FMC_SDCR2_MWID_1 0x00000020U /*!<Bit 1 */
#define FMC_SDCR2_NB 0x00000040U /*!<Number of internal bank */
#define FMC_SDCR2_CAS 0x00000180U /*!<CAS[1:0] bits (CAS latency) */
#define FMC_SDCR2_CAS_0 0x00000080U /*!<Bit 0 */
#define FMC_SDCR2_CAS_1 0x00000100U /*!<Bit 1 */
#define FMC_SDCR2_WP 0x00000200U /*!<Write protection */
#define FMC_SDCR2_SDCLK 0x00000C00U /*!<SDCLK[1:0] (SDRAM clock configuration) */
#define FMC_SDCR2_SDCLK_0 0x00000400U /*!<Bit 0 */
#define FMC_SDCR2_SDCLK_1 0x00000800U /*!<Bit 1 */
#define FMC_SDCR2_RBURST 0x00001000U /*!<Read burst */
#define FMC_SDCR2_RPIPE 0x00006000U /*!<RPIPE[1:0](Read pipe) */
#define FMC_SDCR2_RPIPE_0 0x00002000U /*!<Bit 0 */
#define FMC_SDCR2_RPIPE_1 0x00004000U /*!<Bit 1 */
/****************** Bit definition for FMC_SDTR1 register ******************/
#define FMC_SDTR1_TMRD 0x0000000FU /*!<TMRD[3:0] bits (Load mode register to active) */
#define FMC_SDTR1_TMRD_0 0x00000001U /*!<Bit 0 */
#define FMC_SDTR1_TMRD_1 0x00000002U /*!<Bit 1 */
#define FMC_SDTR1_TMRD_2 0x00000004U /*!<Bit 2 */
#define FMC_SDTR1_TMRD_3 0x00000008U /*!<Bit 3 */
#define FMC_SDTR1_TXSR 0x000000F0U /*!<TXSR[3:0] bits (Exit self refresh) */
#define FMC_SDTR1_TXSR_0 0x00000010U /*!<Bit 0 */
#define FMC_SDTR1_TXSR_1 0x00000020U /*!<Bit 1 */
#define FMC_SDTR1_TXSR_2 0x00000040U /*!<Bit 2 */
#define FMC_SDTR1_TXSR_3 0x00000080U /*!<Bit 3 */
#define FMC_SDTR1_TRAS 0x00000F00U /*!<TRAS[3:0] bits (Self refresh time) */
#define FMC_SDTR1_TRAS_0 0x00000100U /*!<Bit 0 */
#define FMC_SDTR1_TRAS_1 0x00000200U /*!<Bit 1 */
#define FMC_SDTR1_TRAS_2 0x00000400U /*!<Bit 2 */
#define FMC_SDTR1_TRAS_3 0x00000800U /*!<Bit 3 */
#define FMC_SDTR1_TRC 0x0000F000U /*!<TRC[2:0] bits (Row cycle delay) */
#define FMC_SDTR1_TRC_0 0x00001000U /*!<Bit 0 */
#define FMC_SDTR1_TRC_1 0x00002000U /*!<Bit 1 */
#define FMC_SDTR1_TRC_2 0x00004000U /*!<Bit 2 */
#define FMC_SDTR1_TWR 0x000F0000U /*!<TRC[2:0] bits (Write recovery delay) */
#define FMC_SDTR1_TWR_0 0x00010000U /*!<Bit 0 */
#define FMC_SDTR1_TWR_1 0x00020000U /*!<Bit 1 */
#define FMC_SDTR1_TWR_2 0x00040000U /*!<Bit 2 */
#define FMC_SDTR1_TRP 0x00F00000U /*!<TRP[2:0] bits (Row precharge delay) */
#define FMC_SDTR1_TRP_0 0x00100000U /*!<Bit 0 */
#define FMC_SDTR1_TRP_1 0x00200000U /*!<Bit 1 */
#define FMC_SDTR1_TRP_2 0x00400000U /*!<Bit 2 */
#define FMC_SDTR1_TRCD 0x0F000000U /*!<TRP[2:0] bits (Row to column delay) */
#define FMC_SDTR1_TRCD_0 0x01000000U /*!<Bit 0 */
#define FMC_SDTR1_TRCD_1 0x02000000U /*!<Bit 1 */
#define FMC_SDTR1_TRCD_2 0x04000000U /*!<Bit 2 */
/****************** Bit definition for FMC_SDTR2 register ******************/
#define FMC_SDTR2_TMRD 0x0000000FU /*!<TMRD[3:0] bits (Load mode register to active) */
#define FMC_SDTR2_TMRD_0 0x00000001U /*!<Bit 0 */
#define FMC_SDTR2_TMRD_1 0x00000002U /*!<Bit 1 */
#define FMC_SDTR2_TMRD_2 0x00000004U /*!<Bit 2 */
#define FMC_SDTR2_TMRD_3 0x00000008U /*!<Bit 3 */
#define FMC_SDTR2_TXSR 0x000000F0U /*!<TXSR[3:0] bits (Exit self refresh) */
#define FMC_SDTR2_TXSR_0 0x00000010U /*!<Bit 0 */
#define FMC_SDTR2_TXSR_1 0x00000020U /*!<Bit 1 */
#define FMC_SDTR2_TXSR_2 0x00000040U /*!<Bit 2 */
#define FMC_SDTR2_TXSR_3 0x00000080U /*!<Bit 3 */
#define FMC_SDTR2_TRAS 0x00000F00U /*!<TRAS[3:0] bits (Self refresh time) */
#define FMC_SDTR2_TRAS_0 0x00000100U /*!<Bit 0 */
#define FMC_SDTR2_TRAS_1 0x00000200U /*!<Bit 1 */
#define FMC_SDTR2_TRAS_2 0x00000400U /*!<Bit 2 */
#define FMC_SDTR2_TRAS_3 0x00000800U /*!<Bit 3 */
#define FMC_SDTR2_TRC 0x0000F000U /*!<TRC[2:0] bits (Row cycle delay) */
#define FMC_SDTR2_TRC_0 0x00001000U /*!<Bit 0 */
#define FMC_SDTR2_TRC_1 0x00002000U /*!<Bit 1 */
#define FMC_SDTR2_TRC_2 0x00004000U /*!<Bit 2 */
#define FMC_SDTR2_TWR 0x000F0000U /*!<TRC[2:0] bits (Write recovery delay) */
#define FMC_SDTR2_TWR_0 0x00010000U /*!<Bit 0 */
#define FMC_SDTR2_TWR_1 0x00020000U /*!<Bit 1 */
#define FMC_SDTR2_TWR_2 0x00040000U /*!<Bit 2 */
#define FMC_SDTR2_TRP 0x00F00000U /*!<TRP[2:0] bits (Row precharge delay) */
#define FMC_SDTR2_TRP_0 0x00100000U /*!<Bit 0 */
#define FMC_SDTR2_TRP_1 0x00200000U /*!<Bit 1 */
#define FMC_SDTR2_TRP_2 0x00400000U /*!<Bit 2 */
#define FMC_SDTR2_TRCD 0x0F000000U /*!<TRP[2:0] bits (Row to column delay) */
#define FMC_SDTR2_TRCD_0 0x01000000U /*!<Bit 0 */
#define FMC_SDTR2_TRCD_1 0x02000000U /*!<Bit 1 */
#define FMC_SDTR2_TRCD_2 0x04000000U /*!<Bit 2 */
/****************** Bit definition for FMC_SDCMR register ******************/
#define FMC_SDCMR_MODE 0x00000007U /*!<MODE[2:0] bits (Command mode) */
#define FMC_SDCMR_MODE_0 0x00000001U /*!<Bit 0 */
#define FMC_SDCMR_MODE_1 0x00000002U /*!<Bit 1 */
#define FMC_SDCMR_MODE_2 0x00000003U /*!<Bit 2 */
#define FMC_SDCMR_CTB2 0x00000008U /*!<Command target 2 */
#define FMC_SDCMR_CTB1 0x00000010U /*!<Command target 1 */
#define FMC_SDCMR_NRFS 0x000001E0U /*!<NRFS[3:0] bits (Number of auto-refresh) */
#define FMC_SDCMR_NRFS_0 0x00000020U /*!<Bit 0 */
#define FMC_SDCMR_NRFS_1 0x00000040U /*!<Bit 1 */
#define FMC_SDCMR_NRFS_2 0x00000080U /*!<Bit 2 */
#define FMC_SDCMR_NRFS_3 0x00000100U /*!<Bit 3 */
#define FMC_SDCMR_MRD 0x003FFE00U /*!<MRD[12:0] bits (Mode register definition) */
/****************** Bit definition for FMC_SDRTR register ******************/
#define FMC_SDRTR_CRE 0x00000001U /*!<Clear refresh error flag */
#define FMC_SDRTR_COUNT 0x00003FFEU /*!<COUNT[12:0] bits (Refresh timer count) */
#define FMC_SDRTR_REIE 0x00004000U /*!<RES interupt enable */
/****************** Bit definition for FMC_SDSR register ******************/
#define FMC_SDSR_RE 0x00000001U /*!<Refresh error flag */
#define FMC_SDSR_MODES1 0x00000006U /*!<MODES1[1:0]bits (Status mode for bank 1) */
#define FMC_SDSR_MODES1_0 0x00000002U /*!<Bit 0 */
#define FMC_SDSR_MODES1_1 0x00000004U /*!<Bit 1 */
#define FMC_SDSR_MODES2 0x00000018U /*!<MODES2[1:0]bits (Status mode for bank 2) */
#define FMC_SDSR_MODES2_0 0x00000008U /*!<Bit 0 */
#define FMC_SDSR_MODES2_1 0x00000010U /*!<Bit 1 */
#define FMC_SDSR_BUSY 0x00000020U /*!<Busy status */
/******************************************************************************/
/* */
/* General Purpose I/O */
/* */
/******************************************************************************/
/****************** Bits definition for GPIO_MODER register *****************/
#define GPIO_MODER_MODER0 0x00000003U
#define GPIO_MODER_MODER0_0 0x00000001U
#define GPIO_MODER_MODER0_1 0x00000002U
#define GPIO_MODER_MODER1 0x0000000CU
#define GPIO_MODER_MODER1_0 0x00000004U
#define GPIO_MODER_MODER1_1 0x00000008U
#define GPIO_MODER_MODER2 0x00000030U
#define GPIO_MODER_MODER2_0 0x00000010U
#define GPIO_MODER_MODER2_1 0x00000020U
#define GPIO_MODER_MODER3 0x000000C0U
#define GPIO_MODER_MODER3_0 0x00000040U
#define GPIO_MODER_MODER3_1 0x00000080U
#define GPIO_MODER_MODER4 0x00000300U
#define GPIO_MODER_MODER4_0 0x00000100U
#define GPIO_MODER_MODER4_1 0x00000200U
#define GPIO_MODER_MODER5 0x00000C00U
#define GPIO_MODER_MODER5_0 0x00000400U
#define GPIO_MODER_MODER5_1 0x00000800U
#define GPIO_MODER_MODER6 0x00003000U
#define GPIO_MODER_MODER6_0 0x00001000U
#define GPIO_MODER_MODER6_1 0x00002000U
#define GPIO_MODER_MODER7 0x0000C000U
#define GPIO_MODER_MODER7_0 0x00004000U
#define GPIO_MODER_MODER7_1 0x00008000U
#define GPIO_MODER_MODER8 0x00030000U
#define GPIO_MODER_MODER8_0 0x00010000U
#define GPIO_MODER_MODER8_1 0x00020000U
#define GPIO_MODER_MODER9 0x000C0000U
#define GPIO_MODER_MODER9_0 0x00040000U
#define GPIO_MODER_MODER9_1 0x00080000U
#define GPIO_MODER_MODER10 0x00300000U
#define GPIO_MODER_MODER10_0 0x00100000U
#define GPIO_MODER_MODER10_1 0x00200000U
#define GPIO_MODER_MODER11 0x00C00000U
#define GPIO_MODER_MODER11_0 0x00400000U
#define GPIO_MODER_MODER11_1 0x00800000U
#define GPIO_MODER_MODER12 0x03000000U
#define GPIO_MODER_MODER12_0 0x01000000U
#define GPIO_MODER_MODER12_1 0x02000000U
#define GPIO_MODER_MODER13 0x0C000000U
#define GPIO_MODER_MODER13_0 0x04000000U
#define GPIO_MODER_MODER13_1 0x08000000U
#define GPIO_MODER_MODER14 0x30000000U
#define GPIO_MODER_MODER14_0 0x10000000U
#define GPIO_MODER_MODER14_1 0x20000000U
#define GPIO_MODER_MODER15 0xC0000000U
#define GPIO_MODER_MODER15_0 0x40000000U
#define GPIO_MODER_MODER15_1 0x80000000U
/****************** Bits definition for GPIO_OTYPER register ****************/
#define GPIO_OTYPER_OT_0 0x00000001U
#define GPIO_OTYPER_OT_1 0x00000002U
#define GPIO_OTYPER_OT_2 0x00000004U
#define GPIO_OTYPER_OT_3 0x00000008U
#define GPIO_OTYPER_OT_4 0x00000010U
#define GPIO_OTYPER_OT_5 0x00000020U
#define GPIO_OTYPER_OT_6 0x00000040U
#define GPIO_OTYPER_OT_7 0x00000080U
#define GPIO_OTYPER_OT_8 0x00000100U
#define GPIO_OTYPER_OT_9 0x00000200U
#define GPIO_OTYPER_OT_10 0x00000400U
#define GPIO_OTYPER_OT_11 0x00000800U
#define GPIO_OTYPER_OT_12 0x00001000U
#define GPIO_OTYPER_OT_13 0x00002000U
#define GPIO_OTYPER_OT_14 0x00004000U
#define GPIO_OTYPER_OT_15 0x00008000U
/****************** Bits definition for GPIO_OSPEEDR register ***************/
#define GPIO_OSPEEDER_OSPEEDR0 0x00000003U
#define GPIO_OSPEEDER_OSPEEDR0_0 0x00000001U
#define GPIO_OSPEEDER_OSPEEDR0_1 0x00000002U
#define GPIO_OSPEEDER_OSPEEDR1 0x0000000CU
#define GPIO_OSPEEDER_OSPEEDR1_0 0x00000004U
#define GPIO_OSPEEDER_OSPEEDR1_1 0x00000008U
#define GPIO_OSPEEDER_OSPEEDR2 0x00000030U
#define GPIO_OSPEEDER_OSPEEDR2_0 0x00000010U
#define GPIO_OSPEEDER_OSPEEDR2_1 0x00000020U
#define GPIO_OSPEEDER_OSPEEDR3 0x000000C0U
#define GPIO_OSPEEDER_OSPEEDR3_0 0x00000040U
#define GPIO_OSPEEDER_OSPEEDR3_1 0x00000080U
#define GPIO_OSPEEDER_OSPEEDR4 0x00000300U
#define GPIO_OSPEEDER_OSPEEDR4_0 0x00000100U
#define GPIO_OSPEEDER_OSPEEDR4_1 0x00000200U
#define GPIO_OSPEEDER_OSPEEDR5 0x00000C00U
#define GPIO_OSPEEDER_OSPEEDR5_0 0x00000400U
#define GPIO_OSPEEDER_OSPEEDR5_1 0x00000800U
#define GPIO_OSPEEDER_OSPEEDR6 0x00003000U
#define GPIO_OSPEEDER_OSPEEDR6_0 0x00001000U
#define GPIO_OSPEEDER_OSPEEDR6_1 0x00002000U
#define GPIO_OSPEEDER_OSPEEDR7 0x0000C000U
#define GPIO_OSPEEDER_OSPEEDR7_0 0x00004000U
#define GPIO_OSPEEDER_OSPEEDR7_1 0x00008000U
#define GPIO_OSPEEDER_OSPEEDR8 0x00030000U
#define GPIO_OSPEEDER_OSPEEDR8_0 0x00010000U
#define GPIO_OSPEEDER_OSPEEDR8_1 0x00020000U
#define GPIO_OSPEEDER_OSPEEDR9 0x000C0000U
#define GPIO_OSPEEDER_OSPEEDR9_0 0x00040000U
#define GPIO_OSPEEDER_OSPEEDR9_1 0x00080000U
#define GPIO_OSPEEDER_OSPEEDR10 0x00300000U
#define GPIO_OSPEEDER_OSPEEDR10_0 0x00100000U
#define GPIO_OSPEEDER_OSPEEDR10_1 0x00200000U
#define GPIO_OSPEEDER_OSPEEDR11 0x00C00000U
#define GPIO_OSPEEDER_OSPEEDR11_0 0x00400000U
#define GPIO_OSPEEDER_OSPEEDR11_1 0x00800000U
#define GPIO_OSPEEDER_OSPEEDR12 0x03000000U
#define GPIO_OSPEEDER_OSPEEDR12_0 0x01000000U
#define GPIO_OSPEEDER_OSPEEDR12_1 0x02000000U
#define GPIO_OSPEEDER_OSPEEDR13 0x0C000000U
#define GPIO_OSPEEDER_OSPEEDR13_0 0x04000000U
#define GPIO_OSPEEDER_OSPEEDR13_1 0x08000000U
#define GPIO_OSPEEDER_OSPEEDR14 0x30000000U
#define GPIO_OSPEEDER_OSPEEDR14_0 0x10000000U
#define GPIO_OSPEEDER_OSPEEDR14_1 0x20000000U
#define GPIO_OSPEEDER_OSPEEDR15 0xC0000000U
#define GPIO_OSPEEDER_OSPEEDR15_0 0x40000000U
#define GPIO_OSPEEDER_OSPEEDR15_1 0x80000000U
/****************** Bits definition for GPIO_PUPDR register *****************/
#define GPIO_PUPDR_PUPDR0 0x00000003U
#define GPIO_PUPDR_PUPDR0_0 0x00000001U
#define GPIO_PUPDR_PUPDR0_1 0x00000002U
#define GPIO_PUPDR_PUPDR1 0x0000000CU
#define GPIO_PUPDR_PUPDR1_0 0x00000004U
#define GPIO_PUPDR_PUPDR1_1 0x00000008U
#define GPIO_PUPDR_PUPDR2 0x00000030U
#define GPIO_PUPDR_PUPDR2_0 0x00000010U
#define GPIO_PUPDR_PUPDR2_1 0x00000020U
#define GPIO_PUPDR_PUPDR3 0x000000C0U
#define GPIO_PUPDR_PUPDR3_0 0x00000040U
#define GPIO_PUPDR_PUPDR3_1 0x00000080U
#define GPIO_PUPDR_PUPDR4 0x00000300U
#define GPIO_PUPDR_PUPDR4_0 0x00000100U
#define GPIO_PUPDR_PUPDR4_1 0x00000200U
#define GPIO_PUPDR_PUPDR5 0x00000C00U
#define GPIO_PUPDR_PUPDR5_0 0x00000400U
#define GPIO_PUPDR_PUPDR5_1 0x00000800U
#define GPIO_PUPDR_PUPDR6 0x00003000U
#define GPIO_PUPDR_PUPDR6_0 0x00001000U
#define GPIO_PUPDR_PUPDR6_1 0x00002000U
#define GPIO_PUPDR_PUPDR7 0x0000C000U
#define GPIO_PUPDR_PUPDR7_0 0x00004000U
#define GPIO_PUPDR_PUPDR7_1 0x00008000U
#define GPIO_PUPDR_PUPDR8 0x00030000U
#define GPIO_PUPDR_PUPDR8_0 0x00010000U
#define GPIO_PUPDR_PUPDR8_1 0x00020000U
#define GPIO_PUPDR_PUPDR9 0x000C0000U
#define GPIO_PUPDR_PUPDR9_0 0x00040000U
#define GPIO_PUPDR_PUPDR9_1 0x00080000U
#define GPIO_PUPDR_PUPDR10 0x00300000U
#define GPIO_PUPDR_PUPDR10_0 0x00100000U
#define GPIO_PUPDR_PUPDR10_1 0x00200000U
#define GPIO_PUPDR_PUPDR11 0x00C00000U
#define GPIO_PUPDR_PUPDR11_0 0x00400000U
#define GPIO_PUPDR_PUPDR11_1 0x00800000U
#define GPIO_PUPDR_PUPDR12 0x03000000U
#define GPIO_PUPDR_PUPDR12_0 0x01000000U
#define GPIO_PUPDR_PUPDR12_1 0x02000000U
#define GPIO_PUPDR_PUPDR13 0x0C000000U
#define GPIO_PUPDR_PUPDR13_0 0x04000000U
#define GPIO_PUPDR_PUPDR13_1 0x08000000U
#define GPIO_PUPDR_PUPDR14 0x30000000U
#define GPIO_PUPDR_PUPDR14_0 0x10000000U
#define GPIO_PUPDR_PUPDR14_1 0x20000000U
#define GPIO_PUPDR_PUPDR15 0xC0000000U
#define GPIO_PUPDR_PUPDR15_0 0x40000000U
#define GPIO_PUPDR_PUPDR15_1 0x80000000U
/****************** Bits definition for GPIO_IDR register *******************/
#define GPIO_IDR_IDR_0 0x00000001U
#define GPIO_IDR_IDR_1 0x00000002U
#define GPIO_IDR_IDR_2 0x00000004U
#define GPIO_IDR_IDR_3 0x00000008U
#define GPIO_IDR_IDR_4 0x00000010U
#define GPIO_IDR_IDR_5 0x00000020U
#define GPIO_IDR_IDR_6 0x00000040U
#define GPIO_IDR_IDR_7 0x00000080U
#define GPIO_IDR_IDR_8 0x00000100U
#define GPIO_IDR_IDR_9 0x00000200U
#define GPIO_IDR_IDR_10 0x00000400U
#define GPIO_IDR_IDR_11 0x00000800U
#define GPIO_IDR_IDR_12 0x00001000U
#define GPIO_IDR_IDR_13 0x00002000U
#define GPIO_IDR_IDR_14 0x00004000U
#define GPIO_IDR_IDR_15 0x00008000U
/****************** Bits definition for GPIO_ODR register *******************/
#define GPIO_ODR_ODR_0 0x00000001U
#define GPIO_ODR_ODR_1 0x00000002U
#define GPIO_ODR_ODR_2 0x00000004U
#define GPIO_ODR_ODR_3 0x00000008U
#define GPIO_ODR_ODR_4 0x00000010U
#define GPIO_ODR_ODR_5 0x00000020U
#define GPIO_ODR_ODR_6 0x00000040U
#define GPIO_ODR_ODR_7 0x00000080U
#define GPIO_ODR_ODR_8 0x00000100U
#define GPIO_ODR_ODR_9 0x00000200U
#define GPIO_ODR_ODR_10 0x00000400U
#define GPIO_ODR_ODR_11 0x00000800U
#define GPIO_ODR_ODR_12 0x00001000U
#define GPIO_ODR_ODR_13 0x00002000U
#define GPIO_ODR_ODR_14 0x00004000U
#define GPIO_ODR_ODR_15 0x00008000U
/****************** Bits definition for GPIO_BSRR register ******************/
#define GPIO_BSRR_BS_0 0x00000001U
#define GPIO_BSRR_BS_1 0x00000002U
#define GPIO_BSRR_BS_2 0x00000004U
#define GPIO_BSRR_BS_3 0x00000008U
#define GPIO_BSRR_BS_4 0x00000010U
#define GPIO_BSRR_BS_5 0x00000020U
#define GPIO_BSRR_BS_6 0x00000040U
#define GPIO_BSRR_BS_7 0x00000080U
#define GPIO_BSRR_BS_8 0x00000100U
#define GPIO_BSRR_BS_9 0x00000200U
#define GPIO_BSRR_BS_10 0x00000400U
#define GPIO_BSRR_BS_11 0x00000800U
#define GPIO_BSRR_BS_12 0x00001000U
#define GPIO_BSRR_BS_13 0x00002000U
#define GPIO_BSRR_BS_14 0x00004000U
#define GPIO_BSRR_BS_15 0x00008000U
#define GPIO_BSRR_BR_0 0x00010000U
#define GPIO_BSRR_BR_1 0x00020000U
#define GPIO_BSRR_BR_2 0x00040000U
#define GPIO_BSRR_BR_3 0x00080000U
#define GPIO_BSRR_BR_4 0x00100000U
#define GPIO_BSRR_BR_5 0x00200000U
#define GPIO_BSRR_BR_6 0x00400000U
#define GPIO_BSRR_BR_7 0x00800000U
#define GPIO_BSRR_BR_8 0x01000000U
#define GPIO_BSRR_BR_9 0x02000000U
#define GPIO_BSRR_BR_10 0x04000000U
#define GPIO_BSRR_BR_11 0x08000000U
#define GPIO_BSRR_BR_12 0x10000000U
#define GPIO_BSRR_BR_13 0x20000000U
#define GPIO_BSRR_BR_14 0x40000000U
#define GPIO_BSRR_BR_15 0x80000000U
/****************** Bit definition for GPIO_LCKR register *********************/
#define GPIO_LCKR_LCK0 0x00000001U
#define GPIO_LCKR_LCK1 0x00000002U
#define GPIO_LCKR_LCK2 0x00000004U
#define GPIO_LCKR_LCK3 0x00000008U
#define GPIO_LCKR_LCK4 0x00000010U
#define GPIO_LCKR_LCK5 0x00000020U
#define GPIO_LCKR_LCK6 0x00000040U
#define GPIO_LCKR_LCK7 0x00000080U
#define GPIO_LCKR_LCK8 0x00000100U
#define GPIO_LCKR_LCK9 0x00000200U
#define GPIO_LCKR_LCK10 0x00000400U
#define GPIO_LCKR_LCK11 0x00000800U
#define GPIO_LCKR_LCK12 0x00001000U
#define GPIO_LCKR_LCK13 0x00002000U
#define GPIO_LCKR_LCK14 0x00004000U
#define GPIO_LCKR_LCK15 0x00008000U
#define GPIO_LCKR_LCKK 0x00010000U
/******************************************************************************/
/* */
/* Inter-integrated Circuit Interface (I2C) */
/* */
/******************************************************************************/
/******************* Bit definition for I2C_CR1 register *******************/
#define I2C_CR1_PE 0x00000001U /*!< Peripheral enable */
#define I2C_CR1_TXIE 0x00000002U /*!< TX interrupt enable */
#define I2C_CR1_RXIE 0x00000004U /*!< RX interrupt enable */
#define I2C_CR1_ADDRIE 0x00000008U /*!< Address match interrupt enable */
#define I2C_CR1_NACKIE 0x00000010U /*!< NACK received interrupt enable */
#define I2C_CR1_STOPIE 0x00000020U /*!< STOP detection interrupt enable */
#define I2C_CR1_TCIE 0x00000040U /*!< Transfer complete interrupt enable */
#define I2C_CR1_ERRIE 0x00000080U /*!< Errors interrupt enable */
#define I2C_CR1_DNF 0x00000F00U /*!< Digital noise filter */
#define I2C_CR1_ANFOFF 0x00001000U /*!< Analog noise filter OFF */
#define I2C_CR1_TXDMAEN 0x00004000U /*!< DMA transmission requests enable */
#define I2C_CR1_RXDMAEN 0x00008000U /*!< DMA reception requests enable */
#define I2C_CR1_SBC 0x00010000U /*!< Slave byte control */
#define I2C_CR1_NOSTRETCH 0x00020000U /*!< Clock stretching disable */
#define I2C_CR1_GCEN 0x00080000U /*!< General call enable */
#define I2C_CR1_SMBHEN 0x00100000U /*!< SMBus host address enable */
#define I2C_CR1_SMBDEN 0x00200000U /*!< SMBus device default address enable */
#define I2C_CR1_ALERTEN 0x00400000U /*!< SMBus alert enable */
#define I2C_CR1_PECEN 0x00800000U /*!< PEC enable */
/****************** Bit definition for I2C_CR2 register ********************/
#define I2C_CR2_SADD 0x000003FFU /*!< Slave address (master mode) */
#define I2C_CR2_RD_WRN 0x00000400U /*!< Transfer direction (master mode) */
#define I2C_CR2_ADD10 0x00000800U /*!< 10-bit addressing mode (master mode) */
#define I2C_CR2_HEAD10R 0x00001000U /*!< 10-bit address header only read direction (master mode) */
#define I2C_CR2_START 0x00002000U /*!< START generation */
#define I2C_CR2_STOP 0x00004000U /*!< STOP generation (master mode) */
#define I2C_CR2_NACK 0x00008000U /*!< NACK generation (slave mode) */
#define I2C_CR2_NBYTES 0x00FF0000U /*!< Number of bytes */
#define I2C_CR2_RELOAD 0x01000000U /*!< NBYTES reload mode */
#define I2C_CR2_AUTOEND 0x02000000U /*!< Automatic end mode (master mode) */
#define I2C_CR2_PECBYTE 0x04000000U /*!< Packet error checking byte */
/******************* Bit definition for I2C_OAR1 register ******************/
#define I2C_OAR1_OA1 0x000003FFU /*!< Interface own address 1 */
#define I2C_OAR1_OA1MODE 0x00000400U /*!< Own address 1 10-bit mode */
#define I2C_OAR1_OA1EN 0x00008000U /*!< Own address 1 enable */
/******************* Bit definition for I2C_OAR2 register ******************/
#define I2C_OAR2_OA2 0x000000FEU /*!< Interface own address 2 */
#define I2C_OAR2_OA2MSK 0x00000700U /*!< Own address 2 masks */
#define I2C_OAR2_OA2NOMASK 0x00000000U /*!< No mask */
#define I2C_OAR2_OA2MASK01 0x00000100U /*!< OA2[1] is masked, Only OA2[7:2] are compared */
#define I2C_OAR2_OA2MASK02 0x00000200U /*!< OA2[2:1] is masked, Only OA2[7:3] are compared */
#define I2C_OAR2_OA2MASK03 0x00000300U /*!< OA2[3:1] is masked, Only OA2[7:4] are compared */
#define I2C_OAR2_OA2MASK04 0x00000400U /*!< OA2[4:1] is masked, Only OA2[7:5] are compared */
#define I2C_OAR2_OA2MASK05 0x00000500U /*!< OA2[5:1] is masked, Only OA2[7:6] are compared */
#define I2C_OAR2_OA2MASK06 0x00000600U /*!< OA2[6:1] is masked, Only OA2[7] are compared */
#define I2C_OAR2_OA2MASK07 0x00000700U /*!< OA2[7:1] is masked, No comparison is done */
#define I2C_OAR2_OA2EN 0x00008000U /*!< Own address 2 enable */
/******************* Bit definition for I2C_TIMINGR register *******************/
#define I2C_TIMINGR_SCLL 0x000000FFU /*!< SCL low period (master mode) */
#define I2C_TIMINGR_SCLH 0x0000FF00U /*!< SCL high period (master mode) */
#define I2C_TIMINGR_SDADEL 0x000F0000U /*!< Data hold time */
#define I2C_TIMINGR_SCLDEL 0x00F00000U /*!< Data setup time */
#define I2C_TIMINGR_PRESC 0xF0000000U /*!< Timings prescaler */
/******************* Bit definition for I2C_TIMEOUTR register *******************/
#define I2C_TIMEOUTR_TIMEOUTA 0x00000FFFU /*!< Bus timeout A */
#define I2C_TIMEOUTR_TIDLE 0x00001000U /*!< Idle clock timeout detection */
#define I2C_TIMEOUTR_TIMOUTEN 0x00008000U /*!< Clock timeout enable */
#define I2C_TIMEOUTR_TIMEOUTB 0x0FFF0000U /*!< Bus timeout B */
#define I2C_TIMEOUTR_TEXTEN 0x80000000U /*!< Extended clock timeout enable */
/****************** Bit definition for I2C_ISR register *********************/
#define I2C_ISR_TXE 0x00000001U /*!< Transmit data register empty */
#define I2C_ISR_TXIS 0x00000002U /*!< Transmit interrupt status */
#define I2C_ISR_RXNE 0x00000004U /*!< Receive data register not empty */
#define I2C_ISR_ADDR 0x00000008U /*!< Address matched (slave mode) */
#define I2C_ISR_NACKF 0x00000010U /*!< NACK received flag */
#define I2C_ISR_STOPF 0x00000020U /*!< STOP detection flag */
#define I2C_ISR_TC 0x00000040U /*!< Transfer complete (master mode) */
#define I2C_ISR_TCR 0x00000080U /*!< Transfer complete reload */
#define I2C_ISR_BERR 0x00000100U /*!< Bus error */
#define I2C_ISR_ARLO 0x00000200U /*!< Arbitration lost */
#define I2C_ISR_OVR 0x00000400U /*!< Overrun/Underrun */
#define I2C_ISR_PECERR 0x00000800U /*!< PEC error in reception */
#define I2C_ISR_TIMEOUT 0x00001000U /*!< Timeout or Tlow detection flag */
#define I2C_ISR_ALERT 0x00002000U /*!< SMBus alert */
#define I2C_ISR_BUSY 0x00008000U /*!< Bus busy */
#define I2C_ISR_DIR 0x00010000U /*!< Transfer direction (slave mode) */
#define I2C_ISR_ADDCODE 0x00FE0000U /*!< Address match code (slave mode) */
/****************** Bit definition for I2C_ICR register *********************/
#define I2C_ICR_ADDRCF 0x00000008U /*!< Address matched clear flag */
#define I2C_ICR_NACKCF 0x00000010U /*!< NACK clear flag */
#define I2C_ICR_STOPCF 0x00000020U /*!< STOP detection clear flag */
#define I2C_ICR_BERRCF 0x00000100U /*!< Bus error clear flag */
#define I2C_ICR_ARLOCF 0x00000200U /*!< Arbitration lost clear flag */
#define I2C_ICR_OVRCF 0x00000400U /*!< Overrun/Underrun clear flag */
#define I2C_ICR_PECCF 0x00000800U /*!< PAC error clear flag */
#define I2C_ICR_TIMOUTCF 0x00001000U /*!< Timeout clear flag */
#define I2C_ICR_ALERTCF 0x00002000U /*!< Alert clear flag */
/****************** Bit definition for I2C_PECR register *********************/
#define I2C_PECR_PEC 0x000000FFU /*!< PEC register */
/****************** Bit definition for I2C_RXDR register *********************/
#define I2C_RXDR_RXDATA 0x000000FFU /*!< 8-bit receive data */
/****************** Bit definition for I2C_TXDR register *********************/
#define I2C_TXDR_TXDATA 0x000000FFU /*!< 8-bit transmit data */
/******************************************************************************/
/* */
/* Independent WATCHDOG */
/* */
/******************************************************************************/
/******************* Bit definition for IWDG_KR register ********************/
#define IWDG_KR_KEY 0xFFFFU /*!<Key value (write only, read 0000h) */
/******************* Bit definition for IWDG_PR register ********************/
#define IWDG_PR_PR 0x07U /*!<PR[2:0] (Prescaler divider) */
#define IWDG_PR_PR_0 0x01U /*!<Bit 0 */
#define IWDG_PR_PR_1 0x02U /*!<Bit 1 */
#define IWDG_PR_PR_2 0x04U /*!<Bit 2 */
/******************* Bit definition for IWDG_RLR register *******************/
#define IWDG_RLR_RL 0x0FFFU /*!<Watchdog counter reload value */
/******************* Bit definition for IWDG_SR register ********************/
#define IWDG_SR_PVU 0x01U /*!< Watchdog prescaler value update */
#define IWDG_SR_RVU 0x02U /*!< Watchdog counter reload value update */
#define IWDG_SR_WVU 0x04U /*!< Watchdog counter window value update */
/******************* Bit definition for IWDG_KR register ********************/
#define IWDG_WINR_WIN 0x0FFFU /*!< Watchdog counter window value */
/******************************************************************************/
/* */
/* Power Control */
/* */
/******************************************************************************/
/******************** Bit definition for PWR_CR1 register ********************/
#define PWR_CR1_LPDS 0x00000001U /*!< Low-Power Deepsleep */
#define PWR_CR1_PDDS 0x00000002U /*!< Power Down Deepsleep */
#define PWR_CR1_CSBF 0x00000008U /*!< Clear Standby Flag */
#define PWR_CR1_PVDE 0x00000010U /*!< Power Voltage Detector Enable */
#define PWR_CR1_PLS 0x000000E0U /*!< PLS[2:0] bits (PVD Level Selection) */
#define PWR_CR1_PLS_0 0x00000020U /*!< Bit 0 */
#define PWR_CR1_PLS_1 0x00000040U /*!< Bit 1 */
#define PWR_CR1_PLS_2 0x00000080U /*!< Bit 2 */
/*!< PVD level configuration */
#define PWR_CR1_PLS_LEV0 0x00000000U /*!< PVD level 0 */
#define PWR_CR1_PLS_LEV1 0x00000020U /*!< PVD level 1 */
#define PWR_CR1_PLS_LEV2 0x00000040U /*!< PVD level 2 */
#define PWR_CR1_PLS_LEV3 0x00000060U /*!< PVD level 3 */
#define PWR_CR1_PLS_LEV4 0x00000080U /*!< PVD level 4 */
#define PWR_CR1_PLS_LEV5 0x000000A0U /*!< PVD level 5 */
#define PWR_CR1_PLS_LEV6 0x000000C0U /*!< PVD level 6 */
#define PWR_CR1_PLS_LEV7 0x000000E0U /*!< PVD level 7 */
#define PWR_CR1_DBP 0x00000100U /*!< Disable Backup Domain write protection */
#define PWR_CR1_FPDS 0x00000200U /*!< Flash power down in Stop mode */
#define PWR_CR1_LPUDS 0x00000400U /*!< Low-power regulator in deepsleep under-drive mode */
#define PWR_CR1_MRUDS 0x00000800U /*!< Main regulator in deepsleep under-drive mode */
#define PWR_CR1_ADCDC1 0x00002000U /*!< Refer to AN4073 on how to use this bit */
#define PWR_CR1_VOS 0x0000C000U /*!< VOS[1:0] bits (Regulator voltage scaling output selection) */
#define PWR_CR1_VOS_0 0x00004000U /*!< Bit 0 */
#define PWR_CR1_VOS_1 0x00008000U /*!< Bit 1 */
#define PWR_CR1_ODEN 0x00010000U /*!< Over Drive enable */
#define PWR_CR1_ODSWEN 0x00020000U /*!< Over Drive switch enabled */
#define PWR_CR1_UDEN 0x000C0000U /*!< Under Drive enable in stop mode */
#define PWR_CR1_UDEN_0 0x00040000U /*!< Bit 0 */
#define PWR_CR1_UDEN_1 0x00080000U /*!< Bit 1 */
/******************* Bit definition for PWR_CSR1 register ********************/
#define PWR_CSR1_WUIF 0x00000001U /*!< Wake up internal Flag */
#define PWR_CSR1_SBF 0x00000002U /*!< Standby Flag */
#define PWR_CSR1_PVDO 0x00000004U /*!< PVD Output */
#define PWR_CSR1_BRR 0x00000008U /*!< Backup regulator ready */
#define PWR_CSR1_EIWUP 0x00000100U /*!< Enable internal wakeup */
#define PWR_CSR1_BRE 0x00000200U /*!< Backup regulator enable */
#define PWR_CSR1_VOSRDY 0x00004000U /*!< Regulator voltage scaling output selection ready */
#define PWR_CSR1_ODRDY 0x00010000U /*!< Over Drive generator ready */
#define PWR_CSR1_ODSWRDY 0x00020000U /*!< Over Drive Switch ready */
#define PWR_CSR1_UDRDY 0x000C0000U /*!< Under Drive ready */
/******************** Bit definition for PWR_CR2 register ********************/
#define PWR_CR2_CWUPF1 0x00000001U /*!< Clear Wakeup Pin Flag for PA0 */
#define PWR_CR2_CWUPF2 0x00000002U /*!< Clear Wakeup Pin Flag for PA2 */
#define PWR_CR2_CWUPF3 0x00000004U /*!< Clear Wakeup Pin Flag for PC1 */
#define PWR_CR2_CWUPF4 0x00000008U /*!< Clear Wakeup Pin Flag for PC13 */
#define PWR_CR2_CWUPF5 0x00000010U /*!< Clear Wakeup Pin Flag for PI8 */
#define PWR_CR2_CWUPF6 0x00000020U /*!< Clear Wakeup Pin Flag for PI11 */
#define PWR_CR2_WUPP1 0x00000100U /*!< Wakeup Pin Polarity bit for PA0 */
#define PWR_CR2_WUPP2 0x00000200U /*!< Wakeup Pin Polarity bit for PA2 */
#define PWR_CR2_WUPP3 0x00000400U /*!< Wakeup Pin Polarity bit for PC1 */
#define PWR_CR2_WUPP4 0x00000800U /*!< Wakeup Pin Polarity bit for PC13 */
#define PWR_CR2_WUPP5 0x00001000U /*!< Wakeup Pin Polarity bit for PI8 */
#define PWR_CR2_WUPP6 0x00002000U /*!< Wakeup Pin Polarity bit for PI11 */
/******************* Bit definition for PWR_CSR2 register ********************/
#define PWR_CSR2_WUPF1 0x00000001U /*!< Wakeup Pin Flag for PA0 */
#define PWR_CSR2_WUPF2 0x00000002U /*!< Wakeup Pin Flag for PA2 */
#define PWR_CSR2_WUPF3 0x00000004U /*!< Wakeup Pin Flag for PC1 */
#define PWR_CSR2_WUPF4 0x00000008U /*!< Wakeup Pin Flag for PC13 */
#define PWR_CSR2_WUPF5 0x00000010U /*!< Wakeup Pin Flag for PI8 */
#define PWR_CSR2_WUPF6 0x00000020U /*!< Wakeup Pin Flag for PI11 */
#define PWR_CSR2_EWUP1 0x00000100U /*!< Enable Wakeup Pin PA0 */
#define PWR_CSR2_EWUP2 0x00000200U /*!< Enable Wakeup Pin PA2 */
#define PWR_CSR2_EWUP3 0x00000400U /*!< Enable Wakeup Pin PC1 */
#define PWR_CSR2_EWUP4 0x00000800U /*!< Enable Wakeup Pin PC13 */
#define PWR_CSR2_EWUP5 0x00001000U /*!< Enable Wakeup Pin PI8 */
#define PWR_CSR2_EWUP6 0x00002000U /*!< Enable Wakeup Pin PI11 */
/******************************************************************************/
/* */
/* QUADSPI */
/* */
/******************************************************************************/
/***************** Bit definition for QUADSPI_CR register *******************/
#define QUADSPI_CR_EN 0x00000001U /*!< Enable */
#define QUADSPI_CR_ABORT 0x00000002U /*!< Abort request */
#define QUADSPI_CR_DMAEN 0x00000004U /*!< DMA Enable */
#define QUADSPI_CR_TCEN 0x00000008U /*!< Timeout Counter Enable */
#define QUADSPI_CR_SSHIFT 0x00000010U /*!< Sample Shift */
#define QUADSPI_CR_DFM 0x00000040U /*!< Dual Flash Mode */
#define QUADSPI_CR_FSEL 0x00000080U /*!< Flash Select */
#define QUADSPI_CR_FTHRES 0x00001F00U /*!< FTHRES[4:0] FIFO Level */
#define QUADSPI_CR_FTHRES_0 0x00000100U /*!< Bit 0 */
#define QUADSPI_CR_FTHRES_1 0x00000200U /*!< Bit 1 */
#define QUADSPI_CR_FTHRES_2 0x00000400U /*!< Bit 2 */
#define QUADSPI_CR_FTHRES_3 0x00000800U /*!< Bit 3 */
#define QUADSPI_CR_FTHRES_4 0x00001000U /*!< Bit 4 */
#define QUADSPI_CR_TEIE 0x00010000U /*!< Transfer Error Interrupt Enable */
#define QUADSPI_CR_TCIE 0x00020000U /*!< Transfer Complete Interrupt Enable */
#define QUADSPI_CR_FTIE 0x00040000U /*!< FIFO Threshold Interrupt Enable */
#define QUADSPI_CR_SMIE 0x00080000U /*!< Status Match Interrupt Enable */
#define QUADSPI_CR_TOIE 0x00100000U /*!< TimeOut Interrupt Enable */
#define QUADSPI_CR_APMS 0x00400000U /*!< Bit 1 */
#define QUADSPI_CR_PMM 0x00800000U /*!< Polling Match Mode */
#define QUADSPI_CR_PRESCALER 0xFF000000U /*!< PRESCALER[7:0] Clock prescaler */
#define QUADSPI_CR_PRESCALER_0 0x01000000U /*!< Bit 0 */
#define QUADSPI_CR_PRESCALER_1 0x02000000U /*!< Bit 1 */
#define QUADSPI_CR_PRESCALER_2 0x04000000U /*!< Bit 2 */
#define QUADSPI_CR_PRESCALER_3 0x08000000U /*!< Bit 3 */
#define QUADSPI_CR_PRESCALER_4 0x10000000U /*!< Bit 4 */
#define QUADSPI_CR_PRESCALER_5 0x20000000U /*!< Bit 5 */
#define QUADSPI_CR_PRESCALER_6 0x40000000U /*!< Bit 6 */
#define QUADSPI_CR_PRESCALER_7 0x80000000U /*!< Bit 7 */
/***************** Bit definition for QUADSPI_DCR register ******************/
#define QUADSPI_DCR_CKMODE 0x00000001U /*!< Mode 0 / Mode 3 */
#define QUADSPI_DCR_CSHT 0x00000700U /*!< CSHT[2:0]: ChipSelect High Time */
#define QUADSPI_DCR_CSHT_0 0x00000100U /*!< Bit 0 */
#define QUADSPI_DCR_CSHT_1 0x00000200U /*!< Bit 1 */
#define QUADSPI_DCR_CSHT_2 0x00000400U /*!< Bit 2 */
#define QUADSPI_DCR_FSIZE 0x001F0000U /*!< FSIZE[4:0]: Flash Size */
#define QUADSPI_DCR_FSIZE_0 0x00010000U /*!< Bit 0 */
#define QUADSPI_DCR_FSIZE_1 0x00020000U /*!< Bit 1 */
#define QUADSPI_DCR_FSIZE_2 0x00040000U /*!< Bit 2 */
#define QUADSPI_DCR_FSIZE_3 0x00080000U /*!< Bit 3 */
#define QUADSPI_DCR_FSIZE_4 0x00100000U /*!< Bit 4 */
/****************** Bit definition for QUADSPI_SR register *******************/
#define QUADSPI_SR_TEF 0x00000001U /*!< Transfer Error Flag */
#define QUADSPI_SR_TCF 0x00000002U /*!< Transfer Complete Flag */
#define QUADSPI_SR_FTF 0x00000004U /*!< FIFO Threshlod Flag */
#define QUADSPI_SR_SMF 0x00000008U /*!< Status Match Flag */
#define QUADSPI_SR_TOF 0x00000010U /*!< Timeout Flag */
#define QUADSPI_SR_BUSY 0x00000020U /*!< Busy */
#define QUADSPI_SR_FLEVEL 0x00001F00U /*!< FIFO Threshlod Flag */
#define QUADSPI_SR_FLEVEL_0 0x00000100U /*!< Bit 0 */
#define QUADSPI_SR_FLEVEL_1 0x00000200U /*!< Bit 1 */
#define QUADSPI_SR_FLEVEL_2 0x00000400U /*!< Bit 2 */
#define QUADSPI_SR_FLEVEL_3 0x00000800U /*!< Bit 3 */
#define QUADSPI_SR_FLEVEL_4 0x00001000U /*!< Bit 4 */
/****************** Bit definition for QUADSPI_FCR register ******************/
#define QUADSPI_FCR_CTEF 0x00000001U /*!< Clear Transfer Error Flag */
#define QUADSPI_FCR_CTCF 0x00000002U /*!< Clear Transfer Complete Flag */
#define QUADSPI_FCR_CSMF 0x00000008U /*!< Clear Status Match Flag */
#define QUADSPI_FCR_CTOF 0x00000010U /*!< Clear Timeout Flag */
/****************** Bit definition for QUADSPI_DLR register ******************/
#define QUADSPI_DLR_DL 0xFFFFFFFFU /*!< DL[31:0]: Data Length */
/****************** Bit definition for QUADSPI_CCR register ******************/
#define QUADSPI_CCR_INSTRUCTION 0x000000FFU /*!< INSTRUCTION[7:0]: Instruction */
#define QUADSPI_CCR_INSTRUCTION_0 0x00000001U /*!< Bit 0 */
#define QUADSPI_CCR_INSTRUCTION_1 0x00000002U /*!< Bit 1 */
#define QUADSPI_CCR_INSTRUCTION_2 0x00000004U /*!< Bit 2 */
#define QUADSPI_CCR_INSTRUCTION_3 0x00000008U /*!< Bit 3 */
#define QUADSPI_CCR_INSTRUCTION_4 0x00000010U /*!< Bit 4 */
#define QUADSPI_CCR_INSTRUCTION_5 0x00000020U /*!< Bit 5 */
#define QUADSPI_CCR_INSTRUCTION_6 0x00000040U /*!< Bit 6 */
#define QUADSPI_CCR_INSTRUCTION_7 0x00000080U /*!< Bit 7 */
#define QUADSPI_CCR_IMODE 0x00000300U /*!< IMODE[1:0]: Instruction Mode */
#define QUADSPI_CCR_IMODE_0 0x00000100U /*!< Bit 0 */
#define QUADSPI_CCR_IMODE_1 0x00000200U /*!< Bit 1 */
#define QUADSPI_CCR_ADMODE 0x00000C00U /*!< ADMODE[1:0]: Address Mode */
#define QUADSPI_CCR_ADMODE_0 0x00000400U /*!< Bit 0 */
#define QUADSPI_CCR_ADMODE_1 0x00000800U /*!< Bit 1 */
#define QUADSPI_CCR_ADSIZE 0x00003000U /*!< ADSIZE[1:0]: Address Size */
#define QUADSPI_CCR_ADSIZE_0 0x00001000U /*!< Bit 0 */
#define QUADSPI_CCR_ADSIZE_1 0x00002000U /*!< Bit 1 */
#define QUADSPI_CCR_ABMODE 0x0000C000U /*!< ABMODE[1:0]: Alternate Bytes Mode */
#define QUADSPI_CCR_ABMODE_0 0x00004000U /*!< Bit 0 */
#define QUADSPI_CCR_ABMODE_1 0x00008000U /*!< Bit 1 */
#define QUADSPI_CCR_ABSIZE 0x00030000U /*!< ABSIZE[1:0]: Instruction Mode */
#define QUADSPI_CCR_ABSIZE_0 0x00010000U /*!< Bit 0 */
#define QUADSPI_CCR_ABSIZE_1 0x00020000U /*!< Bit 1 */
#define QUADSPI_CCR_DCYC 0x007C0000U /*!< DCYC[4:0]: Dummy Cycles */
#define QUADSPI_CCR_DCYC_0 0x00040000U /*!< Bit 0 */
#define QUADSPI_CCR_DCYC_1 0x00080000U /*!< Bit 1 */
#define QUADSPI_CCR_DCYC_2 0x00100000U /*!< Bit 2 */
#define QUADSPI_CCR_DCYC_3 0x00200000U /*!< Bit 3 */
#define QUADSPI_CCR_DCYC_4 0x00400000U /*!< Bit 4 */
#define QUADSPI_CCR_DMODE 0x03000000U /*!< DMODE[1:0]: Data Mode */
#define QUADSPI_CCR_DMODE_0 0x01000000U /*!< Bit 0 */
#define QUADSPI_CCR_DMODE_1 0x02000000U /*!< Bit 1 */
#define QUADSPI_CCR_FMODE 0x0C000000U /*!< FMODE[1:0]: Functional Mode */
#define QUADSPI_CCR_FMODE_0 0x04000000U /*!< Bit 0 */
#define QUADSPI_CCR_FMODE_1 0x08000000U /*!< Bit 1 */
#define QUADSPI_CCR_SIOO 0x10000000U /*!< SIOO: Send Instruction Only Once Mode */
#define QUADSPI_CCR_DHHC 0x40000000U /*!< DHHC: Delay Half Hclk Cycle */
#define QUADSPI_CCR_DDRM 0x80000000U /*!< DDRM: Double Data Rate Mode */
/****************** Bit definition for QUADSPI_AR register *******************/
#define QUADSPI_AR_ADDRESS 0xFFFFFFFFU /*!< ADDRESS[31:0]: Address */
/****************** Bit definition for QUADSPI_ABR register ******************/
#define QUADSPI_ABR_ALTERNATE 0xFFFFFFFFU /*!< ALTERNATE[31:0]: Alternate Bytes */
/****************** Bit definition for QUADSPI_DR register *******************/
#define QUADSPI_DR_DATA 0xFFFFFFFFU /*!< DATA[31:0]: Data */
/****************** Bit definition for QUADSPI_PSMKR register ****************/
#define QUADSPI_PSMKR_MASK 0xFFFFFFFFU /*!< MASK[31:0]: Status Mask */
/****************** Bit definition for QUADSPI_PSMAR register ****************/
#define QUADSPI_PSMAR_MATCH 0xFFFFFFFFU /*!< MATCH[31:0]: Status Match */
/****************** Bit definition for QUADSPI_PIR register *****************/
#define QUADSPI_PIR_INTERVAL 0x0000FFFFU /*!< INTERVAL[15:0]: Polling Interval */
/****************** Bit definition for QUADSPI_LPTR register *****************/
#define QUADSPI_LPTR_TIMEOUT 0x0000FFFFU /*!< TIMEOUT[15:0]: Timeout period */
/******************************************************************************/
/* */
/* Reset and Clock Control */
/* */
/******************************************************************************/
/******************** Bit definition for RCC_CR register ********************/
#define RCC_CR_HSION 0x00000001U
#define RCC_CR_HSIRDY 0x00000002U
#define RCC_CR_HSITRIM 0x000000F8U
#define RCC_CR_HSITRIM_0 0x00000008U /*!<Bit 0 */
#define RCC_CR_HSITRIM_1 0x00000010U /*!<Bit 1 */
#define RCC_CR_HSITRIM_2 0x00000020U /*!<Bit 2 */
#define RCC_CR_HSITRIM_3 0x00000040U /*!<Bit 3 */
#define RCC_CR_HSITRIM_4 0x00000080U /*!<Bit 4 */
#define RCC_CR_HSICAL 0x0000FF00U
#define RCC_CR_HSICAL_0 0x00000100U /*!<Bit 0 */
#define RCC_CR_HSICAL_1 0x00000200U /*!<Bit 1 */
#define RCC_CR_HSICAL_2 0x00000400U /*!<Bit 2 */
#define RCC_CR_HSICAL_3 0x00000800U /*!<Bit 3 */
#define RCC_CR_HSICAL_4 0x00001000U /*!<Bit 4 */
#define RCC_CR_HSICAL_5 0x00002000U /*!<Bit 5 */
#define RCC_CR_HSICAL_6 0x00004000U /*!<Bit 6 */
#define RCC_CR_HSICAL_7 0x00008000U /*!<Bit 7 */
#define RCC_CR_HSEON 0x00010000U
#define RCC_CR_HSERDY 0x00020000U
#define RCC_CR_HSEBYP 0x00040000U
#define RCC_CR_CSSON 0x00080000U
#define RCC_CR_PLLON 0x01000000U
#define RCC_CR_PLLRDY 0x02000000U
#define RCC_CR_PLLI2SON 0x04000000U
#define RCC_CR_PLLI2SRDY 0x08000000U
#define RCC_CR_PLLSAION 0x10000000U
#define RCC_CR_PLLSAIRDY 0x20000000U
/******************** Bit definition for RCC_PLLCFGR register ***************/
#define RCC_PLLCFGR_PLLM 0x0000003FU
#define RCC_PLLCFGR_PLLM_0 0x00000001U
#define RCC_PLLCFGR_PLLM_1 0x00000002U
#define RCC_PLLCFGR_PLLM_2 0x00000004U
#define RCC_PLLCFGR_PLLM_3 0x00000008U
#define RCC_PLLCFGR_PLLM_4 0x00000010U
#define RCC_PLLCFGR_PLLM_5 0x00000020U
#define RCC_PLLCFGR_PLLN 0x00007FC0U
#define RCC_PLLCFGR_PLLN_0 0x00000040U
#define RCC_PLLCFGR_PLLN_1 0x00000080U
#define RCC_PLLCFGR_PLLN_2 0x00000100U
#define RCC_PLLCFGR_PLLN_3 0x00000200U
#define RCC_PLLCFGR_PLLN_4 0x00000400U
#define RCC_PLLCFGR_PLLN_5 0x00000800U
#define RCC_PLLCFGR_PLLN_6 0x00001000U
#define RCC_PLLCFGR_PLLN_7 0x00002000U
#define RCC_PLLCFGR_PLLN_8 0x00004000U
#define RCC_PLLCFGR_PLLP 0x00030000U
#define RCC_PLLCFGR_PLLP_0 0x00010000U
#define RCC_PLLCFGR_PLLP_1 0x00020000U
#define RCC_PLLCFGR_PLLSRC 0x00400000U
#define RCC_PLLCFGR_PLLSRC_HSE 0x00400000U
#define RCC_PLLCFGR_PLLSRC_HSI 0x00000000U
#define RCC_PLLCFGR_PLLQ 0x0F000000U
#define RCC_PLLCFGR_PLLQ_0 0x01000000U
#define RCC_PLLCFGR_PLLQ_1 0x02000000U
#define RCC_PLLCFGR_PLLQ_2 0x04000000U
#define RCC_PLLCFGR_PLLQ_3 0x08000000U
#define RCC_PLLCFGR_PLLR 0x70000000U
#define RCC_PLLCFGR_PLLR_0 0x10000000U
#define RCC_PLLCFGR_PLLR_1 0x20000000U
#define RCC_PLLCFGR_PLLR_2 0x40000000U
/******************** Bit definition for RCC_CFGR register ******************/
/*!< SW configuration */
#define RCC_CFGR_SW 0x00000003U /*!< SW[1:0] bits (System clock Switch) */
#define RCC_CFGR_SW_0 0x00000001U /*!< Bit 0 */
#define RCC_CFGR_SW_1 0x00000002U /*!< Bit 1 */
#define RCC_CFGR_SW_HSI 0x00000000U /*!< HSI selected as system clock */
#define RCC_CFGR_SW_HSE 0x00000001U /*!< HSE selected as system clock */
#define RCC_CFGR_SW_PLL 0x00000002U /*!< PLL selected as system clock */
/*!< SWS configuration */
#define RCC_CFGR_SWS 0x0000000CU /*!< SWS[1:0] bits (System Clock Switch Status) */
#define RCC_CFGR_SWS_0 0x00000004U /*!< Bit 0 */
#define RCC_CFGR_SWS_1 0x00000008U /*!< Bit 1 */
#define RCC_CFGR_SWS_HSI 0x00000000U /*!< HSI oscillator used as system clock */
#define RCC_CFGR_SWS_HSE 0x00000004U /*!< HSE oscillator used as system clock */
#define RCC_CFGR_SWS_PLL 0x00000008U /*!< PLL used as system clock */
/*!< HPRE configuration */
#define RCC_CFGR_HPRE 0x000000F0U /*!< HPRE[3:0] bits (AHB prescaler) */
#define RCC_CFGR_HPRE_0 0x00000010U /*!< Bit 0 */
#define RCC_CFGR_HPRE_1 0x00000020U /*!< Bit 1 */
#define RCC_CFGR_HPRE_2 0x00000040U /*!< Bit 2 */
#define RCC_CFGR_HPRE_3 0x00000080U /*!< Bit 3 */
#define RCC_CFGR_HPRE_DIV1 0x00000000U /*!< SYSCLK not divided */
#define RCC_CFGR_HPRE_DIV2 0x00000080U /*!< SYSCLK divided by 2 */
#define RCC_CFGR_HPRE_DIV4 0x00000090U /*!< SYSCLK divided by 4 */
#define RCC_CFGR_HPRE_DIV8 0x000000A0U /*!< SYSCLK divided by 8 */
#define RCC_CFGR_HPRE_DIV16 0x000000B0U /*!< SYSCLK divided by 16 */
#define RCC_CFGR_HPRE_DIV64 0x000000C0U /*!< SYSCLK divided by 64 */
#define RCC_CFGR_HPRE_DIV128 0x000000D0U /*!< SYSCLK divided by 128 */
#define RCC_CFGR_HPRE_DIV256 0x000000E0U /*!< SYSCLK divided by 256 */
#define RCC_CFGR_HPRE_DIV512 0x000000F0U /*!< SYSCLK divided by 512 */
/*!< PPRE1 configuration */
#define RCC_CFGR_PPRE1 0x00001C00U /*!< PRE1[2:0] bits (APB1 prescaler) */
#define RCC_CFGR_PPRE1_0 0x00000400U /*!< Bit 0 */
#define RCC_CFGR_PPRE1_1 0x00000800U /*!< Bit 1 */
#define RCC_CFGR_PPRE1_2 0x00001000U /*!< Bit 2 */
#define RCC_CFGR_PPRE1_DIV1 0x00000000U /*!< HCLK not divided */
#define RCC_CFGR_PPRE1_DIV2 0x00001000U /*!< HCLK divided by 2 */
#define RCC_CFGR_PPRE1_DIV4 0x00001400U /*!< HCLK divided by 4 */
#define RCC_CFGR_PPRE1_DIV8 0x00001800U /*!< HCLK divided by 8 */
#define RCC_CFGR_PPRE1_DIV16 0x00001C00U /*!< HCLK divided by 16 */
/*!< PPRE2 configuration */
#define RCC_CFGR_PPRE2 0x0000E000U /*!< PRE2[2:0] bits (APB2 prescaler) */
#define RCC_CFGR_PPRE2_0 0x00002000U /*!< Bit 0 */
#define RCC_CFGR_PPRE2_1 0x00004000U /*!< Bit 1 */
#define RCC_CFGR_PPRE2_2 0x00008000U /*!< Bit 2 */
#define RCC_CFGR_PPRE2_DIV1 0x00000000U /*!< HCLK not divided */
#define RCC_CFGR_PPRE2_DIV2 0x00008000U /*!< HCLK divided by 2 */
#define RCC_CFGR_PPRE2_DIV4 0x0000A000U /*!< HCLK divided by 4 */
#define RCC_CFGR_PPRE2_DIV8 0x0000C000U /*!< HCLK divided by 8 */
#define RCC_CFGR_PPRE2_DIV16 0x0000E000U /*!< HCLK divided by 16 */
/*!< RTCPRE configuration */
#define RCC_CFGR_RTCPRE 0x001F0000U
#define RCC_CFGR_RTCPRE_0 0x00010000U
#define RCC_CFGR_RTCPRE_1 0x00020000U
#define RCC_CFGR_RTCPRE_2 0x00040000U
#define RCC_CFGR_RTCPRE_3 0x00080000U
#define RCC_CFGR_RTCPRE_4 0x00100000U
/*!< MCO1 configuration */
#define RCC_CFGR_MCO1 0x00600000U
#define RCC_CFGR_MCO1_0 0x00200000U
#define RCC_CFGR_MCO1_1 0x00400000U
#define RCC_CFGR_I2SSRC 0x00800000U
#define RCC_CFGR_MCO1PRE 0x07000000U
#define RCC_CFGR_MCO1PRE_0 0x01000000U
#define RCC_CFGR_MCO1PRE_1 0x02000000U
#define RCC_CFGR_MCO1PRE_2 0x04000000U
#define RCC_CFGR_MCO2PRE 0x38000000U
#define RCC_CFGR_MCO2PRE_0 0x08000000U
#define RCC_CFGR_MCO2PRE_1 0x10000000U
#define RCC_CFGR_MCO2PRE_2 0x20000000U
#define RCC_CFGR_MCO2 0xC0000000U
#define RCC_CFGR_MCO2_0 0x40000000U
#define RCC_CFGR_MCO2_1 0x80000000U
/******************** Bit definition for RCC_CIR register *******************/
#define RCC_CIR_LSIRDYF 0x00000001U
#define RCC_CIR_LSERDYF 0x00000002U
#define RCC_CIR_HSIRDYF 0x00000004U
#define RCC_CIR_HSERDYF 0x00000008U
#define RCC_CIR_PLLRDYF 0x00000010U
#define RCC_CIR_PLLI2SRDYF 0x00000020U
#define RCC_CIR_PLLSAIRDYF 0x00000040U
#define RCC_CIR_CSSF 0x00000080U
#define RCC_CIR_LSIRDYIE 0x00000100U
#define RCC_CIR_LSERDYIE 0x00000200U
#define RCC_CIR_HSIRDYIE 0x00000400U
#define RCC_CIR_HSERDYIE 0x00000800U
#define RCC_CIR_PLLRDYIE 0x00001000U
#define RCC_CIR_PLLI2SRDYIE 0x00002000U
#define RCC_CIR_PLLSAIRDYIE 0x00004000U
#define RCC_CIR_LSIRDYC 0x00010000U
#define RCC_CIR_LSERDYC 0x00020000U
#define RCC_CIR_HSIRDYC 0x00040000U
#define RCC_CIR_HSERDYC 0x00080000U
#define RCC_CIR_PLLRDYC 0x00100000U
#define RCC_CIR_PLLI2SRDYC 0x00200000U
#define RCC_CIR_PLLSAIRDYC 0x00400000U
#define RCC_CIR_CSSC 0x00800000U
/******************** Bit definition for RCC_AHB1RSTR register **************/
#define RCC_AHB1RSTR_GPIOARST 0x00000001U
#define RCC_AHB1RSTR_GPIOBRST 0x00000002U
#define RCC_AHB1RSTR_GPIOCRST 0x00000004U
#define RCC_AHB1RSTR_GPIODRST 0x00000008U
#define RCC_AHB1RSTR_GPIOERST 0x00000010U
#define RCC_AHB1RSTR_GPIOFRST 0x00000020U
#define RCC_AHB1RSTR_GPIOGRST 0x00000040U
#define RCC_AHB1RSTR_GPIOHRST 0x00000080U
#define RCC_AHB1RSTR_GPIOIRST 0x00000100U
#define RCC_AHB1RSTR_GPIOJRST 0x00000200U
#define RCC_AHB1RSTR_GPIOKRST 0x00000400U
#define RCC_AHB1RSTR_CRCRST 0x00001000U
#define RCC_AHB1RSTR_DMA1RST 0x00200000U
#define RCC_AHB1RSTR_DMA2RST 0x00400000U
#define RCC_AHB1RSTR_DMA2DRST 0x00800000U
#define RCC_AHB1RSTR_ETHMACRST 0x02000000U
#define RCC_AHB1RSTR_OTGHRST 0x20000000U
/******************** Bit definition for RCC_AHB2RSTR register **************/
#define RCC_AHB2RSTR_DCMIRST 0x00000001U
#define RCC_AHB2RSTR_RNGRST 0x00000040U
#define RCC_AHB2RSTR_OTGFSRST 0x00000080U
/******************** Bit definition for RCC_AHB3RSTR register **************/
#define RCC_AHB3RSTR_FMCRST 0x00000001U
#define RCC_AHB3RSTR_QSPIRST 0x00000002U
/******************** Bit definition for RCC_APB1RSTR register **************/
#define RCC_APB1RSTR_TIM2RST 0x00000001U
#define RCC_APB1RSTR_TIM3RST 0x00000002U
#define RCC_APB1RSTR_TIM4RST 0x00000004U
#define RCC_APB1RSTR_TIM5RST 0x00000008U
#define RCC_APB1RSTR_TIM6RST 0x00000010U
#define RCC_APB1RSTR_TIM7RST 0x00000020U
#define RCC_APB1RSTR_TIM12RST 0x00000040U
#define RCC_APB1RSTR_TIM13RST 0x00000080U
#define RCC_APB1RSTR_TIM14RST 0x00000100U
#define RCC_APB1RSTR_LPTIM1RST 0x00000200U
#define RCC_APB1RSTR_WWDGRST 0x00000800U
#define RCC_APB1RSTR_CAN3RST 0x00002000U
#define RCC_APB1RSTR_SPI2RST 0x00004000U
#define RCC_APB1RSTR_SPI3RST 0x00008000U
#define RCC_APB1RSTR_SPDIFRXRST 0x00010000U
#define RCC_APB1RSTR_USART2RST 0x00020000U
#define RCC_APB1RSTR_USART3RST 0x00040000U
#define RCC_APB1RSTR_UART4RST 0x00080000U
#define RCC_APB1RSTR_UART5RST 0x00100000U
#define RCC_APB1RSTR_I2C1RST 0x00200000U
#define RCC_APB1RSTR_I2C2RST 0x00400000U
#define RCC_APB1RSTR_I2C3RST 0x00800000U
#define RCC_APB1RSTR_I2C4RST 0x01000000U
#define RCC_APB1RSTR_CAN1RST 0x02000000U
#define RCC_APB1RSTR_CAN2RST 0x04000000U
#define RCC_APB1RSTR_CECRST 0x08000000U
#define RCC_APB1RSTR_PWRRST 0x10000000U
#define RCC_APB1RSTR_DACRST 0x20000000U
#define RCC_APB1RSTR_UART7RST 0x40000000U
#define RCC_APB1RSTR_UART8RST 0x80000000U
/******************** Bit definition for RCC_APB2RSTR register **************/
#define RCC_APB2RSTR_TIM1RST 0x00000001U
#define RCC_APB2RSTR_TIM8RST 0x00000002U
#define RCC_APB2RSTR_USART1RST 0x00000010U
#define RCC_APB2RSTR_USART6RST 0x00000020U
#define RCC_APB2RSTR_SDMMC2RST 0x00000080U
#define RCC_APB2RSTR_ADCRST 0x00000100U
#define RCC_APB2RSTR_SDMMC1RST 0x00000800U
#define RCC_APB2RSTR_SPI1RST 0x00001000U
#define RCC_APB2RSTR_SPI4RST 0x00002000U
#define RCC_APB2RSTR_SYSCFGRST 0x00004000U
#define RCC_APB2RSTR_TIM9RST 0x00010000U
#define RCC_APB2RSTR_TIM10RST 0x00020000U
#define RCC_APB2RSTR_TIM11RST 0x00040000U
#define RCC_APB2RSTR_SPI5RST 0x00100000U
#define RCC_APB2RSTR_SPI6RST 0x00200000U
#define RCC_APB2RSTR_SAI1RST 0x00400000U
#define RCC_APB2RSTR_SAI2RST 0x00800000U
#define RCC_APB2RSTR_DFSDM1RST 0x20000000U
#define RCC_APB2RSTR_MDIORST 0x40000000U
/******************** Bit definition for RCC_AHB1ENR register ***************/
#define RCC_AHB1ENR_GPIOAEN 0x00000001U
#define RCC_AHB1ENR_GPIOBEN 0x00000002U
#define RCC_AHB1ENR_GPIOCEN 0x00000004U
#define RCC_AHB1ENR_GPIODEN 0x00000008U
#define RCC_AHB1ENR_GPIOEEN 0x00000010U
#define RCC_AHB1ENR_GPIOFEN 0x00000020U
#define RCC_AHB1ENR_GPIOGEN 0x00000040U
#define RCC_AHB1ENR_GPIOHEN 0x00000080U
#define RCC_AHB1ENR_GPIOIEN 0x00000100U
#define RCC_AHB1ENR_GPIOJEN 0x00000200U
#define RCC_AHB1ENR_GPIOKEN 0x00000400U
#define RCC_AHB1ENR_CRCEN 0x00001000U
#define RCC_AHB1ENR_BKPSRAMEN 0x00040000U
#define RCC_AHB1ENR_DTCMRAMEN 0x00100000U
#define RCC_AHB1ENR_DMA1EN 0x00200000U
#define RCC_AHB1ENR_DMA2EN 0x00400000U
#define RCC_AHB1ENR_DMA2DEN 0x00800000U
#define RCC_AHB1ENR_ETHMACEN 0x02000000U
#define RCC_AHB1ENR_ETHMACTXEN 0x04000000U
#define RCC_AHB1ENR_ETHMACRXEN 0x08000000U
#define RCC_AHB1ENR_ETHMACPTPEN 0x10000000U
#define RCC_AHB1ENR_OTGHSEN 0x20000000U
#define RCC_AHB1ENR_OTGHSULPIEN 0x40000000U
/******************** Bit definition for RCC_AHB2ENR register ***************/
#define RCC_AHB2ENR_DCMIEN 0x00000001U
#define RCC_AHB2ENR_RNGEN 0x00000040U
#define RCC_AHB2ENR_OTGFSEN 0x00000080U
/******************** Bit definition for RCC_AHB3ENR register ***************/
#define RCC_AHB3ENR_FMCEN 0x00000001U
#define RCC_AHB3ENR_QSPIEN 0x00000002U
/******************** Bit definition for RCC_APB1ENR register ***************/
#define RCC_APB1ENR_TIM2EN 0x00000001U
#define RCC_APB1ENR_TIM3EN 0x00000002U
#define RCC_APB1ENR_TIM4EN 0x00000004U
#define RCC_APB1ENR_TIM5EN 0x00000008U
#define RCC_APB1ENR_TIM6EN 0x00000010U
#define RCC_APB1ENR_TIM7EN 0x00000020U
#define RCC_APB1ENR_TIM12EN 0x00000040U
#define RCC_APB1ENR_TIM13EN 0x00000080U
#define RCC_APB1ENR_TIM14EN 0x00000100U
#define RCC_APB1ENR_LPTIM1EN 0x00000200U
#define RCC_APB1ENR_RTCEN 0x00000400U
#define RCC_APB1ENR_WWDGEN 0x00000800U
#define RCC_APB1ENR_CAN3EN 0x00002000U
#define RCC_APB1ENR_SPI2EN 0x00004000U
#define RCC_APB1ENR_SPI3EN 0x00008000U
#define RCC_APB1ENR_SPDIFRXEN 0x00010000U
#define RCC_APB1ENR_USART2EN 0x00020000U
#define RCC_APB1ENR_USART3EN 0x00040000U
#define RCC_APB1ENR_UART4EN 0x00080000U
#define RCC_APB1ENR_UART5EN 0x00100000U
#define RCC_APB1ENR_I2C1EN 0x00200000U
#define RCC_APB1ENR_I2C2EN 0x00400000U
#define RCC_APB1ENR_I2C3EN 0x00800000U
#define RCC_APB1ENR_I2C4EN 0x01000000U
#define RCC_APB1ENR_CAN1EN 0x02000000U
#define RCC_APB1ENR_CAN2EN 0x04000000U
#define RCC_APB1ENR_CECEN 0x08000000U
#define RCC_APB1ENR_PWREN 0x10000000U
#define RCC_APB1ENR_DACEN 0x20000000U
#define RCC_APB1ENR_UART7EN 0x40000000U
#define RCC_APB1ENR_UART8EN 0x80000000U
/******************** Bit definition for RCC_APB2ENR register ***************/
#define RCC_APB2ENR_TIM1EN 0x00000001U
#define RCC_APB2ENR_TIM8EN 0x00000002U
#define RCC_APB2ENR_USART1EN 0x00000010U
#define RCC_APB2ENR_USART6EN 0x00000020U
#define RCC_APB2ENR_SDMMC2EN 0x00000080U
#define RCC_APB2ENR_ADC1EN 0x00000100U
#define RCC_APB2ENR_ADC2EN 0x00000200U
#define RCC_APB2ENR_ADC3EN 0x00000400U
#define RCC_APB2ENR_SDMMC1EN 0x00000800U
#define RCC_APB2ENR_SPI1EN 0x00001000U
#define RCC_APB2ENR_SPI4EN 0x00002000U
#define RCC_APB2ENR_SYSCFGEN 0x00004000U
#define RCC_APB2ENR_TIM9EN 0x00010000U
#define RCC_APB2ENR_TIM10EN 0x00020000U
#define RCC_APB2ENR_TIM11EN 0x00040000U
#define RCC_APB2ENR_SPI5EN 0x00100000U
#define RCC_APB2ENR_SPI6EN 0x00200000U
#define RCC_APB2ENR_SAI1EN 0x00400000U
#define RCC_APB2ENR_SAI2EN 0x00800000U
#define RCC_APB2ENR_DFSDM1EN 0x20000000U
#define RCC_APB2ENR_MDIOEN 0x40000000U
/******************** Bit definition for RCC_AHB1LPENR register *************/
#define RCC_AHB1LPENR_GPIOALPEN 0x00000001U
#define RCC_AHB1LPENR_GPIOBLPEN 0x00000002U
#define RCC_AHB1LPENR_GPIOCLPEN 0x00000004U
#define RCC_AHB1LPENR_GPIODLPEN 0x00000008U
#define RCC_AHB1LPENR_GPIOELPEN 0x00000010U
#define RCC_AHB1LPENR_GPIOFLPEN 0x00000020U
#define RCC_AHB1LPENR_GPIOGLPEN 0x00000040U
#define RCC_AHB1LPENR_GPIOHLPEN 0x00000080U
#define RCC_AHB1LPENR_GPIOILPEN 0x00000100U
#define RCC_AHB1LPENR_GPIOJLPEN 0x00000200U
#define RCC_AHB1LPENR_GPIOKLPEN 0x00000400U
#define RCC_AHB1LPENR_CRCLPEN 0x00001000U
#define RCC_AHB1LPENR_AXILPEN 0x00002000U
#define RCC_AHB1LPENR_FLITFLPEN 0x00008000U
#define RCC_AHB1LPENR_SRAM1LPEN 0x00010000U
#define RCC_AHB1LPENR_SRAM2LPEN 0x00020000U
#define RCC_AHB1LPENR_BKPSRAMLPEN 0x00040000U
#define RCC_AHB1LPENR_DTCMLPEN 0x00100000U
#define RCC_AHB1LPENR_DMA1LPEN 0x00200000U
#define RCC_AHB1LPENR_DMA2LPEN 0x00400000U
#define RCC_AHB1LPENR_DMA2DLPEN 0x00800000U
#define RCC_AHB1LPENR_ETHMACLPEN 0x02000000U
#define RCC_AHB1LPENR_ETHMACTXLPEN 0x04000000U
#define RCC_AHB1LPENR_ETHMACRXLPEN 0x08000000U
#define RCC_AHB1LPENR_ETHMACPTPLPEN 0x10000000U
#define RCC_AHB1LPENR_OTGHSLPEN 0x20000000U
#define RCC_AHB1LPENR_OTGHSULPILPEN 0x40000000U
/******************** Bit definition for RCC_AHB2LPENR register *************/
#define RCC_AHB2LPENR_DCMILPEN 0x00000001U
#define RCC_AHB2LPENR_RNGLPEN 0x00000040U
#define RCC_AHB2LPENR_OTGFSLPEN 0x00000080U
/******************** Bit definition for RCC_AHB3LPENR register *************/
#define RCC_AHB3LPENR_FMCLPEN 0x00000001U
#define RCC_AHB3LPENR_QSPILPEN 0x00000002U
/******************** Bit definition for RCC_APB1LPENR register *************/
#define RCC_APB1LPENR_TIM2LPEN 0x00000001U
#define RCC_APB1LPENR_TIM3LPEN 0x00000002U
#define RCC_APB1LPENR_TIM4LPEN 0x00000004U
#define RCC_APB1LPENR_TIM5LPEN 0x00000008U
#define RCC_APB1LPENR_TIM6LPEN 0x00000010U
#define RCC_APB1LPENR_TIM7LPEN 0x00000020U
#define RCC_APB1LPENR_TIM12LPEN 0x00000040U
#define RCC_APB1LPENR_TIM13LPEN 0x00000080U
#define RCC_APB1LPENR_TIM14LPEN 0x00000100U
#define RCC_APB1LPENR_LPTIM1LPEN 0x00000200U
#define RCC_APB1LPENR_RTCLPEN 0x00000400U
#define RCC_APB1LPENR_WWDGLPEN 0x00000800U
#define RCC_APB1LPENR_CAN3LPEN 0x00002000U
#define RCC_APB1LPENR_SPI2LPEN 0x00004000U
#define RCC_APB1LPENR_SPI3LPEN 0x00008000U
#define RCC_APB1LPENR_SPDIFRXLPEN 0x00010000U
#define RCC_APB1LPENR_USART2LPEN 0x00020000U
#define RCC_APB1LPENR_USART3LPEN 0x00040000U
#define RCC_APB1LPENR_UART4LPEN 0x00080000U
#define RCC_APB1LPENR_UART5LPEN 0x00100000U
#define RCC_APB1LPENR_I2C1LPEN 0x00200000U
#define RCC_APB1LPENR_I2C2LPEN 0x00400000U
#define RCC_APB1LPENR_I2C3LPEN 0x00800000U
#define RCC_APB1LPENR_I2C4LPEN 0x01000000U
#define RCC_APB1LPENR_CAN1LPEN 0x02000000U
#define RCC_APB1LPENR_CAN2LPEN 0x04000000U
#define RCC_APB1LPENR_CECLPEN 0x08000000U
#define RCC_APB1LPENR_PWRLPEN 0x10000000U
#define RCC_APB1LPENR_DACLPEN 0x20000000U
#define RCC_APB1LPENR_UART7LPEN 0x40000000U
#define RCC_APB1LPENR_UART8LPEN 0x80000000U
/******************** Bit definition for RCC_APB2LPENR register *************/
#define RCC_APB2LPENR_TIM1LPEN 0x00000001U
#define RCC_APB2LPENR_TIM8LPEN 0x00000002U
#define RCC_APB2LPENR_USART1LPEN 0x00000010U
#define RCC_APB2LPENR_USART6LPEN 0x00000020U
#define RCC_APB2LPENR_SDMMC2LPEN 0x00000080U
#define RCC_APB2LPENR_ADC1LPEN 0x00000100U
#define RCC_APB2LPENR_ADC2LPEN 0x00000200U
#define RCC_APB2LPENR_ADC3LPEN 0x00000400U
#define RCC_APB2LPENR_SDMMC1LPEN 0x00000800U
#define RCC_APB2LPENR_SPI1LPEN 0x00001000U
#define RCC_APB2LPENR_SPI4LPEN 0x00002000U
#define RCC_APB2LPENR_SYSCFGLPEN 0x00004000U
#define RCC_APB2LPENR_TIM9LPEN 0x00010000U
#define RCC_APB2LPENR_TIM10LPEN 0x00020000U
#define RCC_APB2LPENR_TIM11LPEN 0x00040000U
#define RCC_APB2LPENR_SPI5LPEN 0x00100000U
#define RCC_APB2LPENR_SPI6LPEN 0x00200000U
#define RCC_APB2LPENR_SAI1LPEN 0x00400000U
#define RCC_APB2LPENR_SAI2LPEN 0x00800000U
#define RCC_APB2LPENR_DFSDM1LPEN 0x20000000U
#define RCC_APB2LPENR_MDIOLPEN 0x40000000U
/******************** Bit definition for RCC_BDCR register ******************/
#define RCC_BDCR_LSEON 0x00000001U
#define RCC_BDCR_LSERDY 0x00000002U
#define RCC_BDCR_LSEBYP 0x00000004U
#define RCC_BDCR_LSEDRV 0x00000018U
#define RCC_BDCR_LSEDRV_0 0x00000008U
#define RCC_BDCR_LSEDRV_1 0x00000010U
#define RCC_BDCR_RTCSEL 0x00000300U
#define RCC_BDCR_RTCSEL_0 0x00000100U
#define RCC_BDCR_RTCSEL_1 0x00000200U
#define RCC_BDCR_RTCEN 0x00008000U
#define RCC_BDCR_BDRST 0x00010000U
/******************** Bit definition for RCC_CSR register *******************/
#define RCC_CSR_LSION 0x00000001U
#define RCC_CSR_LSIRDY 0x00000002U
#define RCC_CSR_RMVF 0x01000000U
#define RCC_CSR_BORRSTF 0x02000000U
#define RCC_CSR_PINRSTF 0x04000000U
#define RCC_CSR_PORRSTF 0x08000000U
#define RCC_CSR_SFTRSTF 0x10000000U
#define RCC_CSR_IWDGRSTF 0x20000000U
#define RCC_CSR_WWDGRSTF 0x40000000U
#define RCC_CSR_LPWRRSTF 0x80000000U
/******************** Bit definition for RCC_SSCGR register *****************/
#define RCC_SSCGR_MODPER 0x00001FFFU
#define RCC_SSCGR_INCSTEP 0x0FFFE000U
#define RCC_SSCGR_SPREADSEL 0x40000000U
#define RCC_SSCGR_SSCGEN 0x80000000U
/******************** Bit definition for RCC_PLLI2SCFGR register ************/
#define RCC_PLLI2SCFGR_PLLI2SN 0x00007FC0U
#define RCC_PLLI2SCFGR_PLLI2SN_0 0x00000040U
#define RCC_PLLI2SCFGR_PLLI2SN_1 0x00000080U
#define RCC_PLLI2SCFGR_PLLI2SN_2 0x00000100U
#define RCC_PLLI2SCFGR_PLLI2SN_3 0x00000200U
#define RCC_PLLI2SCFGR_PLLI2SN_4 0x00000400U
#define RCC_PLLI2SCFGR_PLLI2SN_5 0x00000800U
#define RCC_PLLI2SCFGR_PLLI2SN_6 0x00001000U
#define RCC_PLLI2SCFGR_PLLI2SN_7 0x00002000U
#define RCC_PLLI2SCFGR_PLLI2SN_8 0x00004000U
#define RCC_PLLI2SCFGR_PLLI2SP 0x00030000U
#define RCC_PLLI2SCFGR_PLLI2SP_0 0x00010000U
#define RCC_PLLI2SCFGR_PLLI2SP_1 0x00020000U
#define RCC_PLLI2SCFGR_PLLI2SQ 0x0F000000U
#define RCC_PLLI2SCFGR_PLLI2SQ_0 0x01000000U
#define RCC_PLLI2SCFGR_PLLI2SQ_1 0x02000000U
#define RCC_PLLI2SCFGR_PLLI2SQ_2 0x04000000U
#define RCC_PLLI2SCFGR_PLLI2SQ_3 0x08000000U
#define RCC_PLLI2SCFGR_PLLI2SR 0x70000000U
#define RCC_PLLI2SCFGR_PLLI2SR_0 0x10000000U
#define RCC_PLLI2SCFGR_PLLI2SR_1 0x20000000U
#define RCC_PLLI2SCFGR_PLLI2SR_2 0x40000000U
/******************** Bit definition for RCC_PLLSAICFGR register ************/
#define RCC_PLLSAICFGR_PLLSAIN 0x00007FC0U
#define RCC_PLLSAICFGR_PLLSAIN_0 0x00000040U
#define RCC_PLLSAICFGR_PLLSAIN_1 0x00000080U
#define RCC_PLLSAICFGR_PLLSAIN_2 0x00000100U
#define RCC_PLLSAICFGR_PLLSAIN_3 0x00000200U
#define RCC_PLLSAICFGR_PLLSAIN_4 0x00000400U
#define RCC_PLLSAICFGR_PLLSAIN_5 0x00000800U
#define RCC_PLLSAICFGR_PLLSAIN_6 0x00001000U
#define RCC_PLLSAICFGR_PLLSAIN_7 0x00002000U
#define RCC_PLLSAICFGR_PLLSAIN_8 0x00004000U
#define RCC_PLLSAICFGR_PLLSAIP 0x00030000U
#define RCC_PLLSAICFGR_PLLSAIP_0 0x00010000U
#define RCC_PLLSAICFGR_PLLSAIP_1 0x00020000U
#define RCC_PLLSAICFGR_PLLSAIQ 0x0F000000U
#define RCC_PLLSAICFGR_PLLSAIQ_0 0x01000000U
#define RCC_PLLSAICFGR_PLLSAIQ_1 0x02000000U
#define RCC_PLLSAICFGR_PLLSAIQ_2 0x04000000U
#define RCC_PLLSAICFGR_PLLSAIQ_3 0x08000000U
#define RCC_PLLSAICFGR_PLLSAIR 0x70000000U
#define RCC_PLLSAICFGR_PLLSAIR_0 0x10000000U
#define RCC_PLLSAICFGR_PLLSAIR_1 0x20000000U
#define RCC_PLLSAICFGR_PLLSAIR_2 0x40000000U
/******************** Bit definition for RCC_DCKCFGR1 register ***************/
#define RCC_DCKCFGR1_PLLI2SDIVQ 0x0000001FU
#define RCC_DCKCFGR1_PLLI2SDIVQ_0 0x00000001U
#define RCC_DCKCFGR1_PLLI2SDIVQ_1 0x00000002U
#define RCC_DCKCFGR1_PLLI2SDIVQ_2 0x00000004U
#define RCC_DCKCFGR1_PLLI2SDIVQ_3 0x00000008U
#define RCC_DCKCFGR1_PLLI2SDIVQ_4 0x00000010U
#define RCC_DCKCFGR1_PLLSAIDIVQ 0x00001F00U
#define RCC_DCKCFGR1_PLLSAIDIVQ_0 0x00000100U
#define RCC_DCKCFGR1_PLLSAIDIVQ_1 0x00000200U
#define RCC_DCKCFGR1_PLLSAIDIVQ_2 0x00000400U
#define RCC_DCKCFGR1_PLLSAIDIVQ_3 0x00000800U
#define RCC_DCKCFGR1_PLLSAIDIVQ_4 0x00001000U
#define RCC_DCKCFGR1_PLLSAIDIVR 0x00030000U
#define RCC_DCKCFGR1_PLLSAIDIVR_0 0x00010000U
#define RCC_DCKCFGR1_PLLSAIDIVR_1 0x00020000U
#define RCC_DCKCFGR1_SAI1SEL 0x00300000U
#define RCC_DCKCFGR1_SAI1SEL_0 0x00100000U
#define RCC_DCKCFGR1_SAI1SEL_1 0x00200000U
#define RCC_DCKCFGR1_SAI2SEL 0x00C00000U
#define RCC_DCKCFGR1_SAI2SEL_0 0x00400000U
#define RCC_DCKCFGR1_SAI2SEL_1 0x00800000U
#define RCC_DCKCFGR1_TIMPRE 0x01000000U
#define RCC_DCKCFGR1_DFSDM1SEL 0x02000000U
#define RCC_DCKCFGR1_ADFSDM1SEL 0x04000000U
/******************** Bit definition for RCC_DCKCFGR2 register ***************/
#define RCC_DCKCFGR2_USART1SEL 0x00000003U
#define RCC_DCKCFGR2_USART1SEL_0 0x00000001U
#define RCC_DCKCFGR2_USART1SEL_1 0x00000002U
#define RCC_DCKCFGR2_USART2SEL 0x0000000CU
#define RCC_DCKCFGR2_USART2SEL_0 0x00000004U
#define RCC_DCKCFGR2_USART2SEL_1 0x00000008U
#define RCC_DCKCFGR2_USART3SEL 0x00000030U
#define RCC_DCKCFGR2_USART3SEL_0 0x00000010U
#define RCC_DCKCFGR2_USART3SEL_1 0x00000020U
#define RCC_DCKCFGR2_UART4SEL 0x000000C0U
#define RCC_DCKCFGR2_UART4SEL_0 0x00000040U
#define RCC_DCKCFGR2_UART4SEL_1 0x00000080U
#define RCC_DCKCFGR2_UART5SEL 0x00000300U
#define RCC_DCKCFGR2_UART5SEL_0 0x00000100U
#define RCC_DCKCFGR2_UART5SEL_1 0x00000200U
#define RCC_DCKCFGR2_USART6SEL 0x00000C00U
#define RCC_DCKCFGR2_USART6SEL_0 0x00000400U
#define RCC_DCKCFGR2_USART6SEL_1 0x00000800U
#define RCC_DCKCFGR2_UART7SEL 0x00003000U
#define RCC_DCKCFGR2_UART7SEL_0 0x00001000U
#define RCC_DCKCFGR2_UART7SEL_1 0x00002000U
#define RCC_DCKCFGR2_UART8SEL 0x0000C000U
#define RCC_DCKCFGR2_UART8SEL_0 0x00004000U
#define RCC_DCKCFGR2_UART8SEL_1 0x00008000U
#define RCC_DCKCFGR2_I2C1SEL 0x00030000U
#define RCC_DCKCFGR2_I2C1SEL_0 0x00010000U
#define RCC_DCKCFGR2_I2C1SEL_1 0x00020000U
#define RCC_DCKCFGR2_I2C2SEL 0x000C0000U
#define RCC_DCKCFGR2_I2C2SEL_0 0x00040000U
#define RCC_DCKCFGR2_I2C2SEL_1 0x00080000U
#define RCC_DCKCFGR2_I2C3SEL 0x00300000U
#define RCC_DCKCFGR2_I2C3SEL_0 0x00100000U
#define RCC_DCKCFGR2_I2C3SEL_1 0x00200000U
#define RCC_DCKCFGR2_I2C4SEL 0x00C00000U
#define RCC_DCKCFGR2_I2C4SEL_0 0x00400000U
#define RCC_DCKCFGR2_I2C4SEL_1 0x00800000U
#define RCC_DCKCFGR2_LPTIM1SEL 0x03000000U
#define RCC_DCKCFGR2_LPTIM1SEL_0 0x01000000U
#define RCC_DCKCFGR2_LPTIM1SEL_1 0x02000000U
#define RCC_DCKCFGR2_CECSEL 0x04000000U
#define RCC_DCKCFGR2_CK48MSEL 0x08000000U
#define RCC_DCKCFGR2_SDMMC1SEL 0x10000000U
#define RCC_DCKCFGR2_SDMMC2SEL 0x20000000U
/******************************************************************************/
/* */
/* RNG */
/* */
/******************************************************************************/
/******************** Bits definition for RNG_CR register *******************/
#define RNG_CR_RNGEN 0x00000004U
#define RNG_CR_IE 0x00000008U
/******************** Bits definition for RNG_SR register *******************/
#define RNG_SR_DRDY 0x00000001U
#define RNG_SR_CECS 0x00000002U
#define RNG_SR_SECS 0x00000004U
#define RNG_SR_CEIS 0x00000020U
#define RNG_SR_SEIS 0x00000040U
/******************************************************************************/
/* */
/* Real-Time Clock (RTC) */
/* */
/******************************************************************************/
/******************** Bits definition for RTC_TR register *******************/
#define RTC_TR_PM 0x00400000U
#define RTC_TR_HT 0x00300000U
#define RTC_TR_HT_0 0x00100000U
#define RTC_TR_HT_1 0x00200000U
#define RTC_TR_HU 0x000F0000U
#define RTC_TR_HU_0 0x00010000U
#define RTC_TR_HU_1 0x00020000U
#define RTC_TR_HU_2 0x00040000U
#define RTC_TR_HU_3 0x00080000U
#define RTC_TR_MNT 0x00007000U
#define RTC_TR_MNT_0 0x00001000U
#define RTC_TR_MNT_1 0x00002000U
#define RTC_TR_MNT_2 0x00004000U
#define RTC_TR_MNU 0x00000F00U
#define RTC_TR_MNU_0 0x00000100U
#define RTC_TR_MNU_1 0x00000200U
#define RTC_TR_MNU_2 0x00000400U
#define RTC_TR_MNU_3 0x00000800U
#define RTC_TR_ST 0x00000070U
#define RTC_TR_ST_0 0x00000010U
#define RTC_TR_ST_1 0x00000020U
#define RTC_TR_ST_2 0x00000040U
#define RTC_TR_SU 0x0000000FU
#define RTC_TR_SU_0 0x00000001U
#define RTC_TR_SU_1 0x00000002U
#define RTC_TR_SU_2 0x00000004U
#define RTC_TR_SU_3 0x00000008U
/******************** Bits definition for RTC_DR register *******************/
#define RTC_DR_YT 0x00F00000U
#define RTC_DR_YT_0 0x00100000U
#define RTC_DR_YT_1 0x00200000U
#define RTC_DR_YT_2 0x00400000U
#define RTC_DR_YT_3 0x00800000U
#define RTC_DR_YU 0x000F0000U
#define RTC_DR_YU_0 0x00010000U
#define RTC_DR_YU_1 0x00020000U
#define RTC_DR_YU_2 0x00040000U
#define RTC_DR_YU_3 0x00080000U
#define RTC_DR_WDU 0x0000E000U
#define RTC_DR_WDU_0 0x00002000U
#define RTC_DR_WDU_1 0x00004000U
#define RTC_DR_WDU_2 0x00008000U
#define RTC_DR_MT 0x00001000U
#define RTC_DR_MU 0x00000F00U
#define RTC_DR_MU_0 0x00000100U
#define RTC_DR_MU_1 0x00000200U
#define RTC_DR_MU_2 0x00000400U
#define RTC_DR_MU_3 0x00000800U
#define RTC_DR_DT 0x00000030U
#define RTC_DR_DT_0 0x00000010U
#define RTC_DR_DT_1 0x00000020U
#define RTC_DR_DU 0x0000000FU
#define RTC_DR_DU_0 0x00000001U
#define RTC_DR_DU_1 0x00000002U
#define RTC_DR_DU_2 0x00000004U
#define RTC_DR_DU_3 0x00000008U
/******************** Bits definition for RTC_CR register *******************/
#define RTC_CR_ITSE 0x01000000U
#define RTC_CR_COE 0x00800000U
#define RTC_CR_OSEL 0x00600000U
#define RTC_CR_OSEL_0 0x00200000U
#define RTC_CR_OSEL_1 0x00400000U
#define RTC_CR_POL 0x00100000U
#define RTC_CR_COSEL 0x00080000U
#define RTC_CR_BCK 0x00040000U
#define RTC_CR_SUB1H 0x00020000U
#define RTC_CR_ADD1H 0x00010000U
#define RTC_CR_TSIE 0x00008000U
#define RTC_CR_WUTIE 0x00004000U
#define RTC_CR_ALRBIE 0x00002000U
#define RTC_CR_ALRAIE 0x00001000U
#define RTC_CR_TSE 0x00000800U
#define RTC_CR_WUTE 0x00000400U
#define RTC_CR_ALRBE 0x00000200U
#define RTC_CR_ALRAE 0x00000100U
#define RTC_CR_FMT 0x00000040U
#define RTC_CR_BYPSHAD 0x00000020U
#define RTC_CR_REFCKON 0x00000010U
#define RTC_CR_TSEDGE 0x00000008U
#define RTC_CR_WUCKSEL 0x00000007U
#define RTC_CR_WUCKSEL_0 0x00000001U
#define RTC_CR_WUCKSEL_1 0x00000002U
#define RTC_CR_WUCKSEL_2 0x00000004U
/******************** Bits definition for RTC_ISR register ******************/
#define RTC_ISR_ITSF 0x00020000U
#define RTC_ISR_RECALPF 0x00010000U
#define RTC_ISR_TAMP3F 0x00008000U
#define RTC_ISR_TAMP2F 0x00004000U
#define RTC_ISR_TAMP1F 0x00002000U
#define RTC_ISR_TSOVF 0x00001000U
#define RTC_ISR_TSF 0x00000800U
#define RTC_ISR_WUTF 0x00000400U
#define RTC_ISR_ALRBF 0x00000200U
#define RTC_ISR_ALRAF 0x00000100U
#define RTC_ISR_INIT 0x00000080U
#define RTC_ISR_INITF 0x00000040U
#define RTC_ISR_RSF 0x00000020U
#define RTC_ISR_INITS 0x00000010U
#define RTC_ISR_SHPF 0x00000008U
#define RTC_ISR_WUTWF 0x00000004U
#define RTC_ISR_ALRBWF 0x00000002U
#define RTC_ISR_ALRAWF 0x00000001U
/******************** Bits definition for RTC_PRER register *****************/
#define RTC_PRER_PREDIV_A 0x007F0000U
#define RTC_PRER_PREDIV_S 0x00007FFFU
/******************** Bits definition for RTC_WUTR register *****************/
#define RTC_WUTR_WUT 0x0000FFFFU
/******************** Bits definition for RTC_ALRMAR register ***************/
#define RTC_ALRMAR_MSK4 0x80000000U
#define RTC_ALRMAR_WDSEL 0x40000000U
#define RTC_ALRMAR_DT 0x30000000U
#define RTC_ALRMAR_DT_0 0x10000000U
#define RTC_ALRMAR_DT_1 0x20000000U
#define RTC_ALRMAR_DU 0x0F000000U
#define RTC_ALRMAR_DU_0 0x01000000U
#define RTC_ALRMAR_DU_1 0x02000000U
#define RTC_ALRMAR_DU_2 0x04000000U
#define RTC_ALRMAR_DU_3 0x08000000U
#define RTC_ALRMAR_MSK3 0x00800000U
#define RTC_ALRMAR_PM 0x00400000U
#define RTC_ALRMAR_HT 0x00300000U
#define RTC_ALRMAR_HT_0 0x00100000U
#define RTC_ALRMAR_HT_1 0x00200000U
#define RTC_ALRMAR_HU 0x000F0000U
#define RTC_ALRMAR_HU_0 0x00010000U
#define RTC_ALRMAR_HU_1 0x00020000U
#define RTC_ALRMAR_HU_2 0x00040000U
#define RTC_ALRMAR_HU_3 0x00080000U
#define RTC_ALRMAR_MSK2 0x00008000U
#define RTC_ALRMAR_MNT 0x00007000U
#define RTC_ALRMAR_MNT_0 0x00001000U
#define RTC_ALRMAR_MNT_1 0x00002000U
#define RTC_ALRMAR_MNT_2 0x00004000U
#define RTC_ALRMAR_MNU 0x00000F00U
#define RTC_ALRMAR_MNU_0 0x00000100U
#define RTC_ALRMAR_MNU_1 0x00000200U
#define RTC_ALRMAR_MNU_2 0x00000400U
#define RTC_ALRMAR_MNU_3 0x00000800U
#define RTC_ALRMAR_MSK1 0x00000080U
#define RTC_ALRMAR_ST 0x00000070U
#define RTC_ALRMAR_ST_0 0x00000010U
#define RTC_ALRMAR_ST_1 0x00000020U
#define RTC_ALRMAR_ST_2 0x00000040U
#define RTC_ALRMAR_SU 0x0000000FU
#define RTC_ALRMAR_SU_0 0x00000001U
#define RTC_ALRMAR_SU_1 0x00000002U
#define RTC_ALRMAR_SU_2 0x00000004U
#define RTC_ALRMAR_SU_3 0x00000008U
/******************** Bits definition for RTC_ALRMBR register ***************/
#define RTC_ALRMBR_MSK4 0x80000000U
#define RTC_ALRMBR_WDSEL 0x40000000U
#define RTC_ALRMBR_DT 0x30000000U
#define RTC_ALRMBR_DT_0 0x10000000U
#define RTC_ALRMBR_DT_1 0x20000000U
#define RTC_ALRMBR_DU 0x0F000000U
#define RTC_ALRMBR_DU_0 0x01000000U
#define RTC_ALRMBR_DU_1 0x02000000U
#define RTC_ALRMBR_DU_2 0x04000000U
#define RTC_ALRMBR_DU_3 0x08000000U
#define RTC_ALRMBR_MSK3 0x00800000U
#define RTC_ALRMBR_PM 0x00400000U
#define RTC_ALRMBR_HT 0x00300000U
#define RTC_ALRMBR_HT_0 0x00100000U
#define RTC_ALRMBR_HT_1 0x00200000U
#define RTC_ALRMBR_HU 0x000F0000U
#define RTC_ALRMBR_HU_0 0x00010000U
#define RTC_ALRMBR_HU_1 0x00020000U
#define RTC_ALRMBR_HU_2 0x00040000U
#define RTC_ALRMBR_HU_3 0x00080000U
#define RTC_ALRMBR_MSK2 0x00008000U
#define RTC_ALRMBR_MNT 0x00007000U
#define RTC_ALRMBR_MNT_0 0x00001000U
#define RTC_ALRMBR_MNT_1 0x00002000U
#define RTC_ALRMBR_MNT_2 0x00004000U
#define RTC_ALRMBR_MNU 0x00000F00U
#define RTC_ALRMBR_MNU_0 0x00000100U
#define RTC_ALRMBR_MNU_1 0x00000200U
#define RTC_ALRMBR_MNU_2 0x00000400U
#define RTC_ALRMBR_MNU_3 0x00000800U
#define RTC_ALRMBR_MSK1 0x00000080U
#define RTC_ALRMBR_ST 0x00000070U
#define RTC_ALRMBR_ST_0 0x00000010U
#define RTC_ALRMBR_ST_1 0x00000020U
#define RTC_ALRMBR_ST_2 0x00000040U
#define RTC_ALRMBR_SU 0x0000000FU
#define RTC_ALRMBR_SU_0 0x00000001U
#define RTC_ALRMBR_SU_1 0x00000002U
#define RTC_ALRMBR_SU_2 0x00000004U
#define RTC_ALRMBR_SU_3 0x00000008U
/******************** Bits definition for RTC_WPR register ******************/
#define RTC_WPR_KEY 0x000000FFU
/******************** Bits definition for RTC_SSR register ******************/
#define RTC_SSR_SS 0x0000FFFFU
/******************** Bits definition for RTC_SHIFTR register ***************/
#define RTC_SHIFTR_SUBFS 0x00007FFFU
#define RTC_SHIFTR_ADD1S 0x80000000U
/******************** Bits definition for RTC_TSTR register *****************/
#define RTC_TSTR_PM 0x00400000U
#define RTC_TSTR_HT 0x00300000U
#define RTC_TSTR_HT_0 0x00100000U
#define RTC_TSTR_HT_1 0x00200000U
#define RTC_TSTR_HU 0x000F0000U
#define RTC_TSTR_HU_0 0x00010000U
#define RTC_TSTR_HU_1 0x00020000U
#define RTC_TSTR_HU_2 0x00040000U
#define RTC_TSTR_HU_3 0x00080000U
#define RTC_TSTR_MNT 0x00007000U
#define RTC_TSTR_MNT_0 0x00001000U
#define RTC_TSTR_MNT_1 0x00002000U
#define RTC_TSTR_MNT_2 0x00004000U
#define RTC_TSTR_MNU 0x00000F00U
#define RTC_TSTR_MNU_0 0x00000100U
#define RTC_TSTR_MNU_1 0x00000200U
#define RTC_TSTR_MNU_2 0x00000400U
#define RTC_TSTR_MNU_3 0x00000800U
#define RTC_TSTR_ST 0x00000070U
#define RTC_TSTR_ST_0 0x00000010U
#define RTC_TSTR_ST_1 0x00000020U
#define RTC_TSTR_ST_2 0x00000040U
#define RTC_TSTR_SU 0x0000000FU
#define RTC_TSTR_SU_0 0x00000001U
#define RTC_TSTR_SU_1 0x00000002U
#define RTC_TSTR_SU_2 0x00000004U
#define RTC_TSTR_SU_3 0x00000008U
/******************** Bits definition for RTC_TSDR register *****************/
#define RTC_TSDR_WDU 0x0000E000U
#define RTC_TSDR_WDU_0 0x00002000U
#define RTC_TSDR_WDU_1 0x00004000U
#define RTC_TSDR_WDU_2 0x00008000U
#define RTC_TSDR_MT 0x00001000U
#define RTC_TSDR_MU 0x00000F00U
#define RTC_TSDR_MU_0 0x00000100U
#define RTC_TSDR_MU_1 0x00000200U
#define RTC_TSDR_MU_2 0x00000400U
#define RTC_TSDR_MU_3 0x00000800U
#define RTC_TSDR_DT 0x00000030U
#define RTC_TSDR_DT_0 0x00000010U
#define RTC_TSDR_DT_1 0x00000020U
#define RTC_TSDR_DU 0x0000000FU
#define RTC_TSDR_DU_0 0x00000001U
#define RTC_TSDR_DU_1 0x00000002U
#define RTC_TSDR_DU_2 0x00000004U
#define RTC_TSDR_DU_3 0x00000008U
/******************** Bits definition for RTC_TSSSR register ****************/
#define RTC_TSSSR_SS 0x0000FFFFU
/******************** Bits definition for RTC_CAL register *****************/
#define RTC_CALR_CALP 0x00008000U
#define RTC_CALR_CALW8 0x00004000U
#define RTC_CALR_CALW16 0x00002000U
#define RTC_CALR_CALM 0x000001FFU
#define RTC_CALR_CALM_0 0x00000001U
#define RTC_CALR_CALM_1 0x00000002U
#define RTC_CALR_CALM_2 0x00000004U
#define RTC_CALR_CALM_3 0x00000008U
#define RTC_CALR_CALM_4 0x00000010U
#define RTC_CALR_CALM_5 0x00000020U
#define RTC_CALR_CALM_6 0x00000040U
#define RTC_CALR_CALM_7 0x00000080U
#define RTC_CALR_CALM_8 0x00000100U
/******************** Bits definition for RTC_TAMPCR register ****************/
#define RTC_TAMPCR_TAMP3MF 0x01000000U
#define RTC_TAMPCR_TAMP3NOERASE 0x00800000U
#define RTC_TAMPCR_TAMP3IE 0x00400000U
#define RTC_TAMPCR_TAMP2MF 0x00200000U
#define RTC_TAMPCR_TAMP2NOERASE 0x00100000U
#define RTC_TAMPCR_TAMP2IE 0x00080000U
#define RTC_TAMPCR_TAMP1MF 0x00040000U
#define RTC_TAMPCR_TAMP1NOERASE 0x00020000U
#define RTC_TAMPCR_TAMP1IE 0x00010000U
#define RTC_TAMPCR_TAMPPUDIS 0x00008000U
#define RTC_TAMPCR_TAMPPRCH 0x00006000U
#define RTC_TAMPCR_TAMPPRCH_0 0x00002000U
#define RTC_TAMPCR_TAMPPRCH_1 0x00004000U
#define RTC_TAMPCR_TAMPFLT 0x00001800U
#define RTC_TAMPCR_TAMPFLT_0 0x00000800U
#define RTC_TAMPCR_TAMPFLT_1 0x00001000U
#define RTC_TAMPCR_TAMPFREQ 0x00000700U
#define RTC_TAMPCR_TAMPFREQ_0 0x00000100U
#define RTC_TAMPCR_TAMPFREQ_1 0x00000200U
#define RTC_TAMPCR_TAMPFREQ_2 0x00000400U
#define RTC_TAMPCR_TAMPTS 0x00000080U
#define RTC_TAMPCR_TAMP3TRG 0x00000040U
#define RTC_TAMPCR_TAMP3E 0x00000020U
#define RTC_TAMPCR_TAMP2TRG 0x00000010U
#define RTC_TAMPCR_TAMP2E 0x00000008U
#define RTC_TAMPCR_TAMPIE 0x00000004U
#define RTC_TAMPCR_TAMP1TRG 0x00000002U
#define RTC_TAMPCR_TAMP1E 0x00000001U
/******************** Bits definition for RTC_ALRMASSR register *************/
#define RTC_ALRMASSR_MASKSS 0x0F000000U
#define RTC_ALRMASSR_MASKSS_0 0x01000000U
#define RTC_ALRMASSR_MASKSS_1 0x02000000U
#define RTC_ALRMASSR_MASKSS_2 0x04000000U
#define RTC_ALRMASSR_MASKSS_3 0x08000000U
#define RTC_ALRMASSR_SS 0x00007FFFU
/******************** Bits definition for RTC_ALRMBSSR register *************/
#define RTC_ALRMBSSR_MASKSS 0x0F000000U
#define RTC_ALRMBSSR_MASKSS_0 0x01000000U
#define RTC_ALRMBSSR_MASKSS_1 0x02000000U
#define RTC_ALRMBSSR_MASKSS_2 0x04000000U
#define RTC_ALRMBSSR_MASKSS_3 0x08000000U
#define RTC_ALRMBSSR_SS 0x00007FFFU
/******************** Bits definition for RTC_OR register ****************/
#define RTC_OR_TSINSEL 0x00000006U
#define RTC_OR_TSINSEL_0 0x00000002U
#define RTC_OR_TSINSEL_1 0x00000004U
#define RTC_OR_ALARMTYPE 0x00000008U
/******************** Bits definition for RTC_BKP0R register ****************/
#define RTC_BKP0R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP1R register ****************/
#define RTC_BKP1R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP2R register ****************/
#define RTC_BKP2R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP3R register ****************/
#define RTC_BKP3R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP4R register ****************/
#define RTC_BKP4R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP5R register ****************/
#define RTC_BKP5R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP6R register ****************/
#define RTC_BKP6R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP7R register ****************/
#define RTC_BKP7R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP8R register ****************/
#define RTC_BKP8R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP9R register ****************/
#define RTC_BKP9R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP10R register ***************/
#define RTC_BKP10R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP11R register ***************/
#define RTC_BKP11R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP12R register ***************/
#define RTC_BKP12R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP13R register ***************/
#define RTC_BKP13R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP14R register ***************/
#define RTC_BKP14R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP15R register ***************/
#define RTC_BKP15R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP16R register ***************/
#define RTC_BKP16R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP17R register ***************/
#define RTC_BKP17R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP18R register ***************/
#define RTC_BKP18R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP19R register ***************/
#define RTC_BKP19R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP20R register ***************/
#define RTC_BKP20R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP21R register ***************/
#define RTC_BKP21R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP22R register ***************/
#define RTC_BKP22R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP23R register ***************/
#define RTC_BKP23R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP24R register ***************/
#define RTC_BKP24R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP25R register ***************/
#define RTC_BKP25R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP26R register ***************/
#define RTC_BKP26R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP27R register ***************/
#define RTC_BKP27R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP28R register ***************/
#define RTC_BKP28R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP29R register ***************/
#define RTC_BKP29R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP30R register ***************/
#define RTC_BKP30R 0xFFFFFFFFU
/******************** Bits definition for RTC_BKP31R register ***************/
#define RTC_BKP31R 0xFFFFFFFFU
/******************** Number of backup registers ******************************/
#define RTC_BKP_NUMBER 0x00000020U
/******************************************************************************/
/* */
/* Serial Audio Interface */
/* */
/******************************************************************************/
/******************** Bit definition for SAI_GCR register *******************/
#define SAI_GCR_SYNCIN 0x00000003U /*!<SYNCIN[1:0] bits (Synchronization Inputs) */
#define SAI_GCR_SYNCIN_0 0x00000001U /*!<Bit 0 */
#define SAI_GCR_SYNCIN_1 0x00000002U /*!<Bit 1 */
#define SAI_GCR_SYNCOUT 0x00000030U /*!<SYNCOUT[1:0] bits (Synchronization Outputs) */
#define SAI_GCR_SYNCOUT_0 0x00000010U /*!<Bit 0 */
#define SAI_GCR_SYNCOUT_1 0x00000020U /*!<Bit 1 */
/******************* Bit definition for SAI_xCR1 register *******************/
#define SAI_xCR1_MODE 0x00000003U /*!<MODE[1:0] bits (Audio Block Mode) */
#define SAI_xCR1_MODE_0 0x00000001U /*!<Bit 0 */
#define SAI_xCR1_MODE_1 0x00000002U /*!<Bit 1 */
#define SAI_xCR1_PRTCFG 0x0000000CU /*!<PRTCFG[1:0] bits (Protocol Configuration) */
#define SAI_xCR1_PRTCFG_0 0x00000004U /*!<Bit 0 */
#define SAI_xCR1_PRTCFG_1 0x00000008U /*!<Bit 1 */
#define SAI_xCR1_DS 0x000000E0U /*!<DS[1:0] bits (Data Size) */
#define SAI_xCR1_DS_0 0x00000020U /*!<Bit 0 */
#define SAI_xCR1_DS_1 0x00000040U /*!<Bit 1 */
#define SAI_xCR1_DS_2 0x00000080U /*!<Bit 2 */
#define SAI_xCR1_LSBFIRST 0x00000100U /*!<LSB First Configuration */
#define SAI_xCR1_CKSTR 0x00000200U /*!<ClocK STRobing edge */
#define SAI_xCR1_SYNCEN 0x00000C00U /*!<SYNCEN[1:0](SYNChronization ENable) */
#define SAI_xCR1_SYNCEN_0 0x00000400U /*!<Bit 0 */
#define SAI_xCR1_SYNCEN_1 0x00000800U /*!<Bit 1 */
#define SAI_xCR1_MONO 0x00001000U /*!<Mono mode */
#define SAI_xCR1_OUTDRIV 0x00002000U /*!<Output Drive */
#define SAI_xCR1_SAIEN 0x00010000U /*!<Audio Block enable */
#define SAI_xCR1_DMAEN 0x00020000U /*!<DMA enable */
#define SAI_xCR1_NODIV 0x00080000U /*!<No Divider Configuration */
#define SAI_xCR1_MCKDIV 0x00F00000U /*!<MCKDIV[3:0] (Master ClocK Divider) */
#define SAI_xCR1_MCKDIV_0 0x00100000U /*!<Bit 0 */
#define SAI_xCR1_MCKDIV_1 0x00200000U /*!<Bit 1 */
#define SAI_xCR1_MCKDIV_2 0x00400000U /*!<Bit 2 */
#define SAI_xCR1_MCKDIV_3 0x00800000U /*!<Bit 3 */
/******************* Bit definition for SAI_xCR2 register *******************/
#define SAI_xCR2_FTH 0x00000007U /*!<FTH[2:0](Fifo THreshold) */
#define SAI_xCR2_FTH_0 0x00000001U /*!<Bit 0 */
#define SAI_xCR2_FTH_1 0x00000002U /*!<Bit 1 */
#define SAI_xCR2_FTH_2 0x00000004U /*!<Bit 2 */
#define SAI_xCR2_FFLUSH 0x00000008U /*!<Fifo FLUSH */
#define SAI_xCR2_TRIS 0x00000010U /*!<TRIState Management on data line */
#define SAI_xCR2_MUTE 0x00000020U /*!<Mute mode */
#define SAI_xCR2_MUTEVAL 0x00000040U /*!<Muate value */
#define SAI_xCR2_MUTECNT 0x00001F80U /*!<MUTECNT[5:0] (MUTE counter) */
#define SAI_xCR2_MUTECNT_0 0x00000080U /*!<Bit 0 */
#define SAI_xCR2_MUTECNT_1 0x00000100U /*!<Bit 1 */
#define SAI_xCR2_MUTECNT_2 0x00000200U /*!<Bit 2 */
#define SAI_xCR2_MUTECNT_3 0x00000400U /*!<Bit 3 */
#define SAI_xCR2_MUTECNT_4 0x00000800U /*!<Bit 4 */
#define SAI_xCR2_MUTECNT_5 0x00001000U /*!<Bit 5 */
#define SAI_xCR2_CPL 0x00002000U /*!< Complement Bit */
#define SAI_xCR2_COMP 0x0000C000U /*!<COMP[1:0] (Companding mode) */
#define SAI_xCR2_COMP_0 0x00004000U /*!<Bit 0 */
#define SAI_xCR2_COMP_1 0x00008000U /*!<Bit 1 */
/****************** Bit definition for SAI_xFRCR register *******************/
#define SAI_xFRCR_FRL 0x000000FFU /*!<FRL[1:0](Frame length) */
#define SAI_xFRCR_FRL_0 0x00000001U /*!<Bit 0 */
#define SAI_xFRCR_FRL_1 0x00000002U /*!<Bit 1 */
#define SAI_xFRCR_FRL_2 0x00000004U /*!<Bit 2 */
#define SAI_xFRCR_FRL_3 0x00000008U /*!<Bit 3 */
#define SAI_xFRCR_FRL_4 0x00000010U /*!<Bit 4 */
#define SAI_xFRCR_FRL_5 0x00000020U /*!<Bit 5 */
#define SAI_xFRCR_FRL_6 0x00000040U /*!<Bit 6 */
#define SAI_xFRCR_FRL_7 0x00000080U /*!<Bit 7 */
#define SAI_xFRCR_FSALL 0x00007F00U /*!<FRL[1:0] (Frame synchronization active level length) */
#define SAI_xFRCR_FSALL_0 0x00000100U /*!<Bit 0 */
#define SAI_xFRCR_FSALL_1 0x00000200U /*!<Bit 1 */
#define SAI_xFRCR_FSALL_2 0x00000400U /*!<Bit 2 */
#define SAI_xFRCR_FSALL_3 0x00000800U /*!<Bit 3 */
#define SAI_xFRCR_FSALL_4 0x00001000U /*!<Bit 4 */
#define SAI_xFRCR_FSALL_5 0x00002000U /*!<Bit 5 */
#define SAI_xFRCR_FSALL_6 0x00004000U /*!<Bit 6 */
#define SAI_xFRCR_FSDEF 0x00010000U /*!<Frame Synchronization Definition */
#define SAI_xFRCR_FSPOL 0x00020000U /*!<Frame Synchronization POLarity */
#define SAI_xFRCR_FSOFF 0x00040000U /*!<Frame Synchronization OFFset */
/* Legacy define */
#define SAI_xFRCR_FSPO SAI_xFRCR_FSPOL
/****************** Bit definition for SAI_xSLOTR register *******************/
#define SAI_xSLOTR_FBOFF 0x0000001FU /*!<FRL[4:0](First Bit Offset) */
#define SAI_xSLOTR_FBOFF_0 0x00000001U /*!<Bit 0 */
#define SAI_xSLOTR_FBOFF_1 0x00000002U /*!<Bit 1 */
#define SAI_xSLOTR_FBOFF_2 0x00000004U /*!<Bit 2 */
#define SAI_xSLOTR_FBOFF_3 0x00000008U /*!<Bit 3 */
#define SAI_xSLOTR_FBOFF_4 0x00000010U /*!<Bit 4 */
#define SAI_xSLOTR_SLOTSZ 0x000000C0U /*!<SLOTSZ[1:0] (Slot size) */
#define SAI_xSLOTR_SLOTSZ_0 0x00000040U /*!<Bit 0 */
#define SAI_xSLOTR_SLOTSZ_1 0x00000080U /*!<Bit 1 */
#define SAI_xSLOTR_NBSLOT 0x00000F00U /*!<NBSLOT[3:0] (Number of Slot in audio Frame) */
#define SAI_xSLOTR_NBSLOT_0 0x00000100U /*!<Bit 0 */
#define SAI_xSLOTR_NBSLOT_1 0x00000200U /*!<Bit 1 */
#define SAI_xSLOTR_NBSLOT_2 0x00000400U /*!<Bit 2 */
#define SAI_xSLOTR_NBSLOT_3 0x00000800U /*!<Bit 3 */
#define SAI_xSLOTR_SLOTEN 0xFFFF0000U /*!<SLOTEN[15:0] (Slot Enable) */
/******************* Bit definition for SAI_xIMR register *******************/
#define SAI_xIMR_OVRUDRIE 0x00000001U /*!<Overrun underrun interrupt enable */
#define SAI_xIMR_MUTEDETIE 0x00000002U /*!<Mute detection interrupt enable */
#define SAI_xIMR_WCKCFGIE 0x00000004U /*!<Wrong Clock Configuration interrupt enable */
#define SAI_xIMR_FREQIE 0x00000008U /*!<FIFO request interrupt enable */
#define SAI_xIMR_CNRDYIE 0x00000010U /*!<Codec not ready interrupt enable */
#define SAI_xIMR_AFSDETIE 0x00000020U /*!<Anticipated frame synchronization detection interrupt enable */
#define SAI_xIMR_LFSDETIE 0x00000040U /*!<Late frame synchronization detection interrupt enable */
/******************** Bit definition for SAI_xSR register *******************/
#define SAI_xSR_OVRUDR 0x00000001U /*!<Overrun underrun */
#define SAI_xSR_MUTEDET 0x00000002U /*!<Mute detection */
#define SAI_xSR_WCKCFG 0x00000004U /*!<Wrong Clock Configuration */
#define SAI_xSR_FREQ 0x00000008U /*!<FIFO request */
#define SAI_xSR_CNRDY 0x00000010U /*!<Codec not ready */
#define SAI_xSR_AFSDET 0x00000020U /*!<Anticipated frame synchronization detection */
#define SAI_xSR_LFSDET 0x00000040U /*!<Late frame synchronization detection */
#define SAI_xSR_FLVL 0x00070000U /*!<FLVL[2:0] (FIFO Level Threshold) */
#define SAI_xSR_FLVL_0 0x00010000U /*!<Bit 0 */
#define SAI_xSR_FLVL_1 0x00020000U /*!<Bit 1 */
#define SAI_xSR_FLVL_2 0x00040000U /*!<Bit 2 */
/****************** Bit definition for SAI_xCLRFR register ******************/
#define SAI_xCLRFR_COVRUDR 0x00000001U /*!<Clear Overrun underrun */
#define SAI_xCLRFR_CMUTEDET 0x00000002U /*!<Clear Mute detection */
#define SAI_xCLRFR_CWCKCFG 0x00000004U /*!<Clear Wrong Clock Configuration */
#define SAI_xCLRFR_CFREQ 0x00000008U /*!<Clear FIFO request */
#define SAI_xCLRFR_CCNRDY 0x00000010U /*!<Clear Codec not ready */
#define SAI_xCLRFR_CAFSDET 0x00000020U /*!<Clear Anticipated frame synchronization detection */
#define SAI_xCLRFR_CLFSDET 0x00000040U /*!<Clear Late frame synchronization detection */
/****************** Bit definition for SAI_xDR register *********************/
#define SAI_xDR_DATA 0xFFFFFFFFU
/******************************************************************************/
/* */
/* SPDIF-RX Interface */
/* */
/******************************************************************************/
/******************** Bit definition for SPDIF_CR register *******************/
#define SPDIFRX_CR_SPDIFEN 0x00000003U /*!<Peripheral Block Enable */
#define SPDIFRX_CR_RXDMAEN 0x00000004U /*!<Receiver DMA Enable for data flow */
#define SPDIFRX_CR_RXSTEO 0x00000008U /*!<Stereo Mode */
#define SPDIFRX_CR_DRFMT 0x00000030U /*!<RX Data format */
#define SPDIFRX_CR_PMSK 0x00000040U /*!<Mask Parity error bit */
#define SPDIFRX_CR_VMSK 0x00000080U /*!<Mask of Validity bit */
#define SPDIFRX_CR_CUMSK 0x00000100U /*!<Mask of channel status and user bits */
#define SPDIFRX_CR_PTMSK 0x00000200U /*!<Mask of Preamble Type bits */
#define SPDIFRX_CR_CBDMAEN 0x00000400U /*!<Control Buffer DMA ENable for control flow */
#define SPDIFRX_CR_CHSEL 0x00000800U /*!<Channel Selection */
#define SPDIFRX_CR_NBTR 0x00003000U /*!<Maximum allowed re-tries during synchronization phase */
#define SPDIFRX_CR_WFA 0x00004000U /*!<Wait For Activity */
#define SPDIFRX_CR_INSEL 0x00070000U /*!<SPDIF input selection */
/******************* Bit definition for SPDIFRX_IMR register *******************/
#define SPDIFRX_IMR_RXNEIE 0x00000001U /*!<RXNE interrupt enable */
#define SPDIFRX_IMR_CSRNEIE 0x00000002U /*!<Control Buffer Ready Interrupt Enable */
#define SPDIFRX_IMR_PERRIE 0x00000004U /*!<Parity error interrupt enable */
#define SPDIFRX_IMR_OVRIE 0x00000008U /*!<Overrun error Interrupt Enable */
#define SPDIFRX_IMR_SBLKIE 0x00000010U /*!<Synchronization Block Detected Interrupt Enable */
#define SPDIFRX_IMR_SYNCDIE 0x00000020U /*!<Synchronization Done */
#define SPDIFRX_IMR_IFEIE 0x00000040U /*!<Serial Interface Error Interrupt Enable */
/******************* Bit definition for SPDIFRX_SR register *******************/
#define SPDIFRX_SR_RXNE 0x00000001U /*!<Read data register not empty */
#define SPDIFRX_SR_CSRNE 0x00000002U /*!<The Control Buffer register is not empty */
#define SPDIFRX_SR_PERR 0x00000004U /*!<Parity error */
#define SPDIFRX_SR_OVR 0x00000008U /*!<Overrun error */
#define SPDIFRX_SR_SBD 0x00000010U /*!<Synchronization Block Detected */
#define SPDIFRX_SR_SYNCD 0x00000020U /*!<Synchronization Done */
#define SPDIFRX_SR_FERR 0x00000040U /*!<Framing error */
#define SPDIFRX_SR_SERR 0x00000080U /*!<Synchronization error */
#define SPDIFRX_SR_TERR 0x00000100U /*!<Time-out error */
#define SPDIFRX_SR_WIDTH5 0x7FFF0000U /*!<Duration of 5 symbols counted with spdif_clk */
/******************* Bit definition for SPDIFRX_IFCR register *******************/
#define SPDIFRX_IFCR_PERRCF 0x00000004U /*!<Clears the Parity error flag */
#define SPDIFRX_IFCR_OVRCF 0x00000008U /*!<Clears the Overrun error flag */
#define SPDIFRX_IFCR_SBDCF 0x00000010U /*!<Clears the Synchronization Block Detected flag */
#define SPDIFRX_IFCR_SYNCDCF 0x00000020U /*!<Clears the Synchronization Done flag */
/******************* Bit definition for SPDIFRX_DR register (DRFMT = 0b00 case) *******************/
#define SPDIFRX_DR0_DR 0x00FFFFFFU /*!<Data value */
#define SPDIFRX_DR0_PE 0x01000000U /*!<Parity Error bit */
#define SPDIFRX_DR0_V 0x02000000U /*!<Validity bit */
#define SPDIFRX_DR0_U 0x04000000U /*!<User bit */
#define SPDIFRX_DR0_C 0x08000000U /*!<Channel Status bit */
#define SPDIFRX_DR0_PT 0x30000000U /*!<Preamble Type */
/******************* Bit definition for SPDIFRX_DR register (DRFMT = 0b01 case) *******************/
#define SPDIFRX_DR1_DR 0xFFFFFF00U /*!<Data value */
#define SPDIFRX_DR1_PT 0x00000030U /*!<Preamble Type */
#define SPDIFRX_DR1_C 0x00000008U /*!<Channel Status bit */
#define SPDIFRX_DR1_U 0x00000004U /*!<User bit */
#define SPDIFRX_DR1_V 0x00000002U /*!<Validity bit */
#define SPDIFRX_DR1_PE 0x00000001U /*!<Parity Error bit */
/******************* Bit definition for SPDIFRX_DR register (DRFMT = 0b10 case) *******************/
#define SPDIFRX_DR1_DRNL1 0xFFFF0000U /*!<Data value Channel B */
#define SPDIFRX_DR1_DRNL2 0x0000FFFFU /*!<Data value Channel A */
/******************* Bit definition for SPDIFRX_CSR register *******************/
#define SPDIFRX_CSR_USR 0x0000FFFFU /*!<User data information */
#define SPDIFRX_CSR_CS 0x00FF0000U /*!<Channel A status information */
#define SPDIFRX_CSR_SOB 0x01000000U /*!<Start Of Block */
/******************* Bit definition for SPDIFRX_DIR register *******************/
#define SPDIFRX_DIR_THI 0x000013FFU /*!<Threshold LOW */
#define SPDIFRX_DIR_TLO 0x1FFF0000U /*!<Threshold HIGH */
/******************************************************************************/
/* */
/* SD host Interface */
/* */
/******************************************************************************/
/****************** Bit definition for SDMMC_POWER register ******************/
#define SDMMC_POWER_PWRCTRL 0x03U /*!<PWRCTRL[1:0] bits (Power supply control bits) */
#define SDMMC_POWER_PWRCTRL_0 0x01U /*!<Bit 0 */
#define SDMMC_POWER_PWRCTRL_1 0x02U /*!<Bit 1 */
/****************** Bit definition for SDMMC_CLKCR register ******************/
#define SDMMC_CLKCR_CLKDIV 0x00FFU /*!<Clock divide factor */
#define SDMMC_CLKCR_CLKEN 0x0100U /*!<Clock enable bit */
#define SDMMC_CLKCR_PWRSAV 0x0200U /*!<Power saving configuration bit */
#define SDMMC_CLKCR_BYPASS 0x0400U /*!<Clock divider bypass enable bit */
#define SDMMC_CLKCR_WIDBUS 0x1800U /*!<WIDBUS[1:0] bits (Wide bus mode enable bit) */
#define SDMMC_CLKCR_WIDBUS_0 0x0800U /*!<Bit 0 */
#define SDMMC_CLKCR_WIDBUS_1 0x1000U /*!<Bit 1 */
#define SDMMC_CLKCR_NEGEDGE 0x2000U /*!<SDMMC_CK dephasing selection bit */
#define SDMMC_CLKCR_HWFC_EN 0x4000U /*!<HW Flow Control enable */
/******************* Bit definition for SDMMC_ARG register *******************/
#define SDMMC_ARG_CMDARG 0xFFFFFFFFU /*!<Command argument */
/******************* Bit definition for SDMMC_CMD register *******************/
#define SDMMC_CMD_CMDINDEX 0x003FU /*!<Command Index */
#define SDMMC_CMD_WAITRESP 0x00C0U /*!<WAITRESP[1:0] bits (Wait for response bits) */
#define SDMMC_CMD_WAITRESP_0 0x0040U /*!< Bit 0 */
#define SDMMC_CMD_WAITRESP_1 0x0080U /*!< Bit 1 */
#define SDMMC_CMD_WAITINT 0x0100U /*!<CPSM Waits for Interrupt Request */
#define SDMMC_CMD_WAITPEND 0x0200U /*!<CPSM Waits for ends of data transfer (CmdPend internal signal) */
#define SDMMC_CMD_CPSMEN 0x0400U /*!<Command path state machine (CPSM) Enable bit */
#define SDMMC_CMD_SDIOSUSPEND 0x0800U /*!<SD I/O suspend command */
/***************** Bit definition for SDMMC_RESPCMD register *****************/
#define SDMMC_RESPCMD_RESPCMD 0x3FU /*!<Response command index */
/****************** Bit definition for SDMMC_RESP0 register ******************/
#define SDMMC_RESP0_CARDSTATUS0 0xFFFFFFFFU /*!<Card Status */
/****************** Bit definition for SDMMC_RESP1 register ******************/
#define SDMMC_RESP1_CARDSTATUS1 0xFFFFFFFFU /*!<Card Status */
/****************** Bit definition for SDMMC_RESP2 register ******************/
#define SDMMC_RESP2_CARDSTATUS2 0xFFFFFFFFU /*!<Card Status */
/****************** Bit definition for SDMMC_RESP3 register ******************/
#define SDMMC_RESP3_CARDSTATUS3 0xFFFFFFFFU /*!<Card Status */
/****************** Bit definition for SDMMC_RESP4 register ******************/
#define SDMMC_RESP4_CARDSTATUS4 0xFFFFFFFFU /*!<Card Status */
/****************** Bit definition for SDMMC_DTIMER register *****************/
#define SDMMC_DTIMER_DATATIME 0xFFFFFFFFU /*!<Data timeout period. */
/****************** Bit definition for SDMMC_DLEN register *******************/
#define SDMMC_DLEN_DATALENGTH 0x01FFFFFFU /*!<Data length value */
/****************** Bit definition for SDMMC_DCTRL register ******************/
#define SDMMC_DCTRL_DTEN 0x0001U /*!<Data transfer enabled bit */
#define SDMMC_DCTRL_DTDIR 0x0002U /*!<Data transfer direction selection */
#define SDMMC_DCTRL_DTMODE 0x0004U /*!<Data transfer mode selection */
#define SDMMC_DCTRL_DMAEN 0x0008U /*!<DMA enabled bit */
#define SDMMC_DCTRL_DBLOCKSIZE 0x00F0U /*!<DBLOCKSIZE[3:0] bits (Data block size) */
#define SDMMC_DCTRL_DBLOCKSIZE_0 0x0010U /*!<Bit 0 */
#define SDMMC_DCTRL_DBLOCKSIZE_1 0x0020U /*!<Bit 1 */
#define SDMMC_DCTRL_DBLOCKSIZE_2 0x0040U /*!<Bit 2 */
#define SDMMC_DCTRL_DBLOCKSIZE_3 0x0080U /*!<Bit 3 */
#define SDMMC_DCTRL_RWSTART 0x0100U /*!<Read wait start */
#define SDMMC_DCTRL_RWSTOP 0x0200U /*!<Read wait stop */
#define SDMMC_DCTRL_RWMOD 0x0400U /*!<Read wait mode */
#define SDMMC_DCTRL_SDIOEN 0x0800U /*!<SD I/O enable functions */
/****************** Bit definition for SDMMC_DCOUNT register *****************/
#define SDMMC_DCOUNT_DATACOUNT 0x01FFFFFFU /*!<Data count value */
/****************** Bit definition for SDMMC_STA registe ********************/
#define SDMMC_STA_CCRCFAIL 0x00000001U /*!<Command response received (CRC check failed) */
#define SDMMC_STA_DCRCFAIL 0x00000002U /*!<Data block sent/received (CRC check failed) */
#define SDMMC_STA_CTIMEOUT 0x00000004U /*!<Command response timeout */
#define SDMMC_STA_DTIMEOUT 0x00000008U /*!<Data timeout */
#define SDMMC_STA_TXUNDERR 0x00000010U /*!<Transmit FIFO underrun error */
#define SDMMC_STA_RXOVERR 0x00000020U /*!<Received FIFO overrun error */
#define SDMMC_STA_CMDREND 0x00000040U /*!<Command response received (CRC check passed) */
#define SDMMC_STA_CMDSENT 0x00000080U /*!<Command sent (no response required) */
#define SDMMC_STA_DATAEND 0x00000100U /*!<Data end (data counter, SDIDCOUNT, is zero) */
#define SDMMC_STA_DBCKEND 0x00000400U /*!<Data block sent/received (CRC check passed) */
#define SDMMC_STA_CMDACT 0x00000800U /*!<Command transfer in progress */
#define SDMMC_STA_TXACT 0x00001000U /*!<Data transmit in progress */
#define SDMMC_STA_RXACT 0x00002000U /*!<Data receive in progress */
#define SDMMC_STA_TXFIFOHE 0x00004000U /*!<Transmit FIFO Half Empty: at least 8 words can be written into the FIFO */
#define SDMMC_STA_RXFIFOHF 0x00008000U /*!<Receive FIFO Half Full: there are at least 8 words in the FIFO */
#define SDMMC_STA_TXFIFOF 0x00010000U /*!<Transmit FIFO full */
#define SDMMC_STA_RXFIFOF 0x00020000U /*!<Receive FIFO full */
#define SDMMC_STA_TXFIFOE 0x00040000U /*!<Transmit FIFO empty */
#define SDMMC_STA_RXFIFOE 0x00080000U /*!<Receive FIFO empty */
#define SDMMC_STA_TXDAVL 0x00100000U /*!<Data available in transmit FIFO */
#define SDMMC_STA_RXDAVL 0x00200000U /*!<Data available in receive FIFO */
#define SDMMC_STA_SDIOIT 0x00400000U /*!<SDMMC interrupt received */
/******************* Bit definition for SDMMC_ICR register *******************/
#define SDMMC_ICR_CCRCFAILC 0x00000001U /*!<CCRCFAIL flag clear bit */
#define SDMMC_ICR_DCRCFAILC 0x00000002U /*!<DCRCFAIL flag clear bit */
#define SDMMC_ICR_CTIMEOUTC 0x00000004U /*!<CTIMEOUT flag clear bit */
#define SDMMC_ICR_DTIMEOUTC 0x00000008U /*!<DTIMEOUT flag clear bit */
#define SDMMC_ICR_TXUNDERRC 0x00000010U /*!<TXUNDERR flag clear bit */
#define SDMMC_ICR_RXOVERRC 0x00000020U /*!<RXOVERR flag clear bit */
#define SDMMC_ICR_CMDRENDC 0x00000040U /*!<CMDREND flag clear bit */
#define SDMMC_ICR_CMDSENTC 0x00000080U /*!<CMDSENT flag clear bit */
#define SDMMC_ICR_DATAENDC 0x00000100U /*!<DATAEND flag clear bit */
#define SDMMC_ICR_DBCKENDC 0x00000400U /*!<DBCKEND flag clear bit */
#define SDMMC_ICR_SDIOITC 0x00400000U /*!<SDMMCIT flag clear bit */
/****************** Bit definition for SDMMC_MASK register *******************/
#define SDMMC_MASK_CCRCFAILIE 0x00000001U /*!<Command CRC Fail Interrupt Enable */
#define SDMMC_MASK_DCRCFAILIE 0x00000002U /*!<Data CRC Fail Interrupt Enable */
#define SDMMC_MASK_CTIMEOUTIE 0x00000004U /*!<Command TimeOut Interrupt Enable */
#define SDMMC_MASK_DTIMEOUTIE 0x00000008U /*!<Data TimeOut Interrupt Enable */
#define SDMMC_MASK_TXUNDERRIE 0x00000010U /*!<Tx FIFO UnderRun Error Interrupt Enable */
#define SDMMC_MASK_RXOVERRIE 0x00000020U /*!<Rx FIFO OverRun Error Interrupt Enable */
#define SDMMC_MASK_CMDRENDIE 0x00000040U /*!<Command Response Received Interrupt Enable */
#define SDMMC_MASK_CMDSENTIE 0x00000080U /*!<Command Sent Interrupt Enable */
#define SDMMC_MASK_DATAENDIE 0x00000100U /*!<Data End Interrupt Enable */
#define SDMMC_MASK_DBCKENDIE 0x00000400U /*!<Data Block End Interrupt Enable */
#define SDMMC_MASK_CMDACTIE 0x00000800U /*!<CCommand Acting Interrupt Enable */
#define SDMMC_MASK_TXACTIE 0x00001000U /*!<Data Transmit Acting Interrupt Enable */
#define SDMMC_MASK_RXACTIE 0x00002000U /*!<Data receive acting interrupt enabled */
#define SDMMC_MASK_TXFIFOHEIE 0x00004000U /*!<Tx FIFO Half Empty interrupt Enable */
#define SDMMC_MASK_RXFIFOHFIE 0x00008000U /*!<Rx FIFO Half Full interrupt Enable */
#define SDMMC_MASK_TXFIFOFIE 0x00010000U /*!<Tx FIFO Full interrupt Enable */
#define SDMMC_MASK_RXFIFOFIE 0x00020000U /*!<Rx FIFO Full interrupt Enable */
#define SDMMC_MASK_TXFIFOEIE 0x00040000U /*!<Tx FIFO Empty interrupt Enable */
#define SDMMC_MASK_RXFIFOEIE 0x00080000U /*!<Rx FIFO Empty interrupt Enable */
#define SDMMC_MASK_TXDAVLIE 0x00100000U /*!<Data available in Tx FIFO interrupt Enable */
#define SDMMC_MASK_RXDAVLIE 0x00200000U /*!<Data available in Rx FIFO interrupt Enable */
#define SDMMC_MASK_SDIOITIE 0x00400000U /*!<SDMMC Mode Interrupt Received interrupt Enable */
/***************** Bit definition for SDMMC_FIFOCNT register *****************/
#define SDMMC_FIFOCNT_FIFOCOUNT 0x00FFFFFFU /*!<Remaining number of words to be written to or read from the FIFO */
/****************** Bit definition for SDMMC_FIFO register *******************/
#define SDMMC_FIFO_FIFODATA 0xFFFFFFFFU /*!<Receive and transmit FIFO data */
/******************************************************************************/
/* */
/* Serial Peripheral Interface (SPI) */
/* */
/******************************************************************************/
/******************* Bit definition for SPI_CR1 register ********************/
#define SPI_CR1_CPHA 0x00000001U /*!< Clock Phase */
#define SPI_CR1_CPOL 0x00000002U /*!< Clock Polarity */
#define SPI_CR1_MSTR 0x00000004U /*!< Master Selection */
#define SPI_CR1_BR 0x00000038U /*!< BR[2:0] bits (Baud Rate Control) */
#define SPI_CR1_BR_0 0x00000008U /*!< Bit 0 */
#define SPI_CR1_BR_1 0x00000010U /*!< Bit 1 */
#define SPI_CR1_BR_2 0x00000020U /*!< Bit 2 */
#define SPI_CR1_SPE 0x00000040U /*!< SPI Enable */
#define SPI_CR1_LSBFIRST 0x00000080U /*!< Frame Format */
#define SPI_CR1_SSI 0x00000100U /*!< Internal slave select */
#define SPI_CR1_SSM 0x00000200U /*!< Software slave management */
#define SPI_CR1_RXONLY 0x00000400U /*!< Receive only */
#define SPI_CR1_CRCL 0x00000800U /*!< CRC Length */
#define SPI_CR1_CRCNEXT 0x00001000U /*!< Transmit CRC next */
#define SPI_CR1_CRCEN 0x00002000U /*!< Hardware CRC calculation enable */
#define SPI_CR1_BIDIOE 0x00004000U /*!< Output enable in bidirectional mode */
#define SPI_CR1_BIDIMODE 0x00008000U /*!< Bidirectional data mode enable */
/******************* Bit definition for SPI_CR2 register ********************/
#define SPI_CR2_RXDMAEN 0x00000001U /*!< Rx Buffer DMA Enable */
#define SPI_CR2_TXDMAEN 0x00000002U /*!< Tx Buffer DMA Enable */
#define SPI_CR2_SSOE 0x00000004U /*!< SS Output Enable */
#define SPI_CR2_NSSP 0x00000008U /*!< NSS pulse management Enable */
#define SPI_CR2_FRF 0x00000010U /*!< Frame Format Enable */
#define SPI_CR2_ERRIE 0x00000020U /*!< Error Interrupt Enable */
#define SPI_CR2_RXNEIE 0x00000040U /*!< RX buffer Not Empty Interrupt Enable */
#define SPI_CR2_TXEIE 0x00000080U /*!< Tx buffer Empty Interrupt Enable */
#define SPI_CR2_DS 0x00000F00U /*!< DS[3:0] Data Size */
#define SPI_CR2_DS_0 0x00000100U /*!< Bit 0 */
#define SPI_CR2_DS_1 0x00000200U /*!< Bit 1 */
#define SPI_CR2_DS_2 0x00000400U /*!< Bit 2 */
#define SPI_CR2_DS_3 0x00000800U /*!< Bit 3 */
#define SPI_CR2_FRXTH 0x00001000U /*!< FIFO reception Threshold */
#define SPI_CR2_LDMARX 0x00002000U /*!< Last DMA transfer for reception */
#define SPI_CR2_LDMATX 0x00004000U /*!< Last DMA transfer for transmission */
/******************** Bit definition for SPI_SR register ********************/
#define SPI_SR_RXNE 0x00000001U /*!< Receive buffer Not Empty */
#define SPI_SR_TXE 0x00000002U /*!< Transmit buffer Empty */
#define SPI_SR_CHSIDE 0x00000004U /*!< Channel side */
#define SPI_SR_UDR 0x00000008U /*!< Underrun flag */
#define SPI_SR_CRCERR 0x00000010U /*!< CRC Error flag */
#define SPI_SR_MODF 0x00000020U /*!< Mode fault */
#define SPI_SR_OVR 0x00000040U /*!< Overrun flag */
#define SPI_SR_BSY 0x00000080U /*!< Busy flag */
#define SPI_SR_FRE 0x00000100U /*!< TI frame format error */
#define SPI_SR_FRLVL 0x00000600U /*!< FIFO Reception Level */
#define SPI_SR_FRLVL_0 0x00000200U /*!< Bit 0 */
#define SPI_SR_FRLVL_1 0x00000400U /*!< Bit 1 */
#define SPI_SR_FTLVL 0x00001800U /*!< FIFO Transmission Level */
#define SPI_SR_FTLVL_0 0x00000800U /*!< Bit 0 */
#define SPI_SR_FTLVL_1 0x00001000U /*!< Bit 1 */
/******************** Bit definition for SPI_DR register ********************/
#define SPI_DR_DR 0xFFFFU /*!< Data Register */
/******************* Bit definition for SPI_CRCPR register ******************/
#define SPI_CRCPR_CRCPOLY 0xFFFFU /*!< CRC polynomial register */
/****************** Bit definition for SPI_RXCRCR register ******************/
#define SPI_RXCRCR_RXCRC 0xFFFFU /*!< Rx CRC Register */
/****************** Bit definition for SPI_TXCRCR register ******************/
#define SPI_TXCRCR_TXCRC 0xFFFFU /*!< Tx CRC Register */
/****************** Bit definition for SPI_I2SCFGR register *****************/
#define SPI_I2SCFGR_CHLEN 0x00000001U /*!<Channel length (number of bits per audio channel) */
#define SPI_I2SCFGR_DATLEN 0x00000006U /*!<DATLEN[1:0] bits (Data length to be transferred) */
#define SPI_I2SCFGR_DATLEN_0 0x00000002U /*!<Bit 0 */
#define SPI_I2SCFGR_DATLEN_1 0x00000004U /*!<Bit 1 */
#define SPI_I2SCFGR_CKPOL 0x00000008U /*!<steady state clock polarity */
#define SPI_I2SCFGR_I2SSTD 0x00000030U /*!<I2SSTD[1:0] bits (I2S standard selection) */
#define SPI_I2SCFGR_I2SSTD_0 0x00000010U /*!<Bit 0 */
#define SPI_I2SCFGR_I2SSTD_1 0x00000020U /*!<Bit 1 */
#define SPI_I2SCFGR_PCMSYNC 0x00000080U /*!<PCM frame synchronization */
#define SPI_I2SCFGR_I2SCFG 0x00000300U /*!<I2SCFG[1:0] bits (I2S configuration mode) */
#define SPI_I2SCFGR_I2SCFG_0 0x00000100U /*!<Bit 0 */
#define SPI_I2SCFGR_I2SCFG_1 0x00000200U /*!<Bit 1 */
#define SPI_I2SCFGR_I2SE 0x00000400U /*!<I2S Enable */
#define SPI_I2SCFGR_I2SMOD 0x00000800U /*!<I2S mode selection */
#define SPI_I2SCFGR_ASTRTEN 0x00001000U /*!<Asynchronous start enable */
/****************** Bit definition for SPI_I2SPR register *******************/
#define SPI_I2SPR_I2SDIV 0x00FFU /*!<I2S Linear prescaler */
#define SPI_I2SPR_ODD 0x0100U /*!<Odd factor for the prescaler */
#define SPI_I2SPR_MCKOE 0x0200U /*!<Master Clock Output Enable */
/******************************************************************************/
/* */
/* SYSCFG */
/* */
/******************************************************************************/
/****************** Bit definition for SYSCFG_MEMRMP register ***************/
#define SYSCFG_MEMRMP_MEM_BOOT 0x00000001U /*!< Boot information after Reset */
#define SYSCFG_MEMRMP_SWP_FB 0x00000100U /*!< User Flash Bank swap */
#define SYSCFG_MEMRMP_SWP_FMC 0x00000C00U /*!< FMC Memory Mapping swapping */
#define SYSCFG_MEMRMP_SWP_FMC_0 0x00000400U
#define SYSCFG_MEMRMP_SWP_FMC_1 0x00000800U
/****************** Bit definition for SYSCFG_PMC register ******************/
#define SYSCFG_PMC_I2C1_FMP 0x00000001U /*!< I2C1_FMP I2C1 Fast Mode + Enable */
#define SYSCFG_PMC_I2C2_FMP 0x00000002U /*!< I2C2_FMP I2C2 Fast Mode + Enable */
#define SYSCFG_PMC_I2C3_FMP 0x00000004U /*!< I2C3_FMP I2C3 Fast Mode + Enable */
#define SYSCFG_PMC_I2C4_FMP 0x00000008U /*!< I2C4_FMP I2C4 Fast Mode + Enable */
#define SYSCFG_PMC_I2C_PB6_FMP 0x00000010U /*!< PB6_FMP Fast Mode + Enable */
#define SYSCFG_PMC_I2C_PB7_FMP 0x00000020U /*!< PB7_FMP Fast Mode + Enable */
#define SYSCFG_PMC_I2C_PB8_FMP 0x00000040U /*!< PB8_FMP Fast Mode + Enable */
#define SYSCFG_PMC_I2C_PB9_FMP 0x00000080U /*!< PB9_FMP Fast Mode + Enable */
#define SYSCFG_PMC_ADCxDC2 0x00070000U /*!< Refer to AN4073 on how to use this bit */
#define SYSCFG_PMC_ADC1DC2 0x00010000U /*!< Refer to AN4073 on how to use this bit */
#define SYSCFG_PMC_ADC2DC2 0x00020000U /*!< Refer to AN4073 on how to use this bit */
#define SYSCFG_PMC_ADC3DC2 0x00040000U /*!< Refer to AN4073 on how to use this bit */
#define SYSCFG_PMC_MII_RMII_SEL 0x00800000U /*!<Ethernet PHY interface selection */
/***************** Bit definition for SYSCFG_EXTICR1 register ***************/
#define SYSCFG_EXTICR1_EXTI0 0x000FU /*!<EXTI 0 configuration */
#define SYSCFG_EXTICR1_EXTI1 0x00F0U /*!<EXTI 1 configuration */
#define SYSCFG_EXTICR1_EXTI2 0x0F00U /*!<EXTI 2 configuration */
#define SYSCFG_EXTICR1_EXTI3 0xF000U /*!<EXTI 3 configuration */
/**
* @brief EXTI0 configuration
*/
#define SYSCFG_EXTICR1_EXTI0_PA 0x0000U /*!<PA[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PB 0x0001U /*!<PB[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PC 0x0002U /*!<PC[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PD 0x0003U /*!<PD[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PE 0x0004U /*!<PE[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PF 0x0005U /*!<PF[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PG 0x0006U /*!<PG[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PH 0x0007U /*!<PH[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PI 0x0008U /*!<PI[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PJ 0x0009U /*!<PJ[0] pin */
#define SYSCFG_EXTICR1_EXTI0_PK 0x000AU /*!<PK[0] pin */
/**
* @brief EXTI1 configuration
*/
#define SYSCFG_EXTICR1_EXTI1_PA 0x0000U /*!<PA[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PB 0x0010U /*!<PB[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PC 0x0020U /*!<PC[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PD 0x0030U /*!<PD[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PE 0x0040U /*!<PE[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PF 0x0050U /*!<PF[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PG 0x0060U /*!<PG[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PH 0x0070U /*!<PH[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PI 0x0080U /*!<PI[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PJ 0x0090U /*!<PJ[1] pin */
#define SYSCFG_EXTICR1_EXTI1_PK 0x00A0U /*!<PK[1] pin */
/**
* @brief EXTI2 configuration
*/
#define SYSCFG_EXTICR1_EXTI2_PA 0x0000U /*!<PA[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PB 0x0100U /*!<PB[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PC 0x0200U /*!<PC[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PD 0x0300U /*!<PD[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PE 0x0400U /*!<PE[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PF 0x0500U /*!<PF[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PG 0x0600U /*!<PG[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PH 0x0700U /*!<PH[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PI 0x0800U /*!<PI[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PJ 0x0900U /*!<PJ[2] pin */
#define SYSCFG_EXTICR1_EXTI2_PK 0x0A00U /*!<PK[2] pin */
/**
* @brief EXTI3 configuration
*/
#define SYSCFG_EXTICR1_EXTI3_PA 0x0000U /*!<PA[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PB 0x1000U /*!<PB[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PC 0x2000U /*!<PC[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PD 0x3000U /*!<PD[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PE 0x4000U /*!<PE[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PF 0x5000U /*!<PF[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PG 0x6000U /*!<PG[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PH 0x7000U /*!<PH[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PI 0x8000U /*!<PI[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PJ 0x9000U /*!<PJ[3] pin */
#define SYSCFG_EXTICR1_EXTI3_PK 0xA000U /*!<PK[3] pin */
/***************** Bit definition for SYSCFG_EXTICR2 register ***************/
#define SYSCFG_EXTICR2_EXTI4 0x000FU /*!<EXTI 4 configuration */
#define SYSCFG_EXTICR2_EXTI5 0x00F0U /*!<EXTI 5 configuration */
#define SYSCFG_EXTICR2_EXTI6 0x0F00U /*!<EXTI 6 configuration */
#define SYSCFG_EXTICR2_EXTI7 0xF000U /*!<EXTI 7 configuration */
/**
* @brief EXTI4 configuration
*/
#define SYSCFG_EXTICR2_EXTI4_PA 0x0000U /*!<PA[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PB 0x0001U /*!<PB[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PC 0x0002U /*!<PC[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PD 0x0003U /*!<PD[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PE 0x0004U /*!<PE[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PF 0x0005U /*!<PF[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PG 0x0006U /*!<PG[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PH 0x0007U /*!<PH[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PI 0x0008U /*!<PI[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PJ 0x0009U /*!<PJ[4] pin */
#define SYSCFG_EXTICR2_EXTI4_PK 0x000AU /*!<PK[4] pin */
/**
* @brief EXTI5 configuration
*/
#define SYSCFG_EXTICR2_EXTI5_PA 0x0000U /*!<PA[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PB 0x0010U /*!<PB[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PC 0x0020U /*!<PC[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PD 0x0030U /*!<PD[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PE 0x0040U /*!<PE[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PF 0x0050U /*!<PF[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PG 0x0060U /*!<PG[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PH 0x0070U /*!<PH[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PI 0x0080U /*!<PI[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PJ 0x0090U /*!<PJ[5] pin */
#define SYSCFG_EXTICR2_EXTI5_PK 0x00A0U /*!<PK[5] pin */
/**
* @brief EXTI6 configuration
*/
#define SYSCFG_EXTICR2_EXTI6_PA 0x0000U /*!<PA[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PB 0x0100U /*!<PB[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PC 0x0200U /*!<PC[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PD 0x0300U /*!<PD[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PE 0x0400U /*!<PE[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PF 0x0500U /*!<PF[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PG 0x0600U /*!<PG[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PH 0x0700U /*!<PH[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PI 0x0800U /*!<PI[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PJ 0x0900U /*!<PJ[6] pin */
#define SYSCFG_EXTICR2_EXTI6_PK 0x0A00U /*!<PK[6] pin */
/**
* @brief EXTI7 configuration
*/
#define SYSCFG_EXTICR2_EXTI7_PA 0x0000U /*!<PA[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PB 0x1000U /*!<PB[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PC 0x2000U /*!<PC[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PD 0x3000U /*!<PD[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PE 0x4000U /*!<PE[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PF 0x5000U /*!<PF[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PG 0x6000U /*!<PG[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PH 0x7000U /*!<PH[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PI 0x8000U /*!<PI[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PJ 0x9000U /*!<PJ[7] pin */
#define SYSCFG_EXTICR2_EXTI7_PK 0xA000U /*!<PK[7] pin */
/***************** Bit definition for SYSCFG_EXTICR3 register ***************/
#define SYSCFG_EXTICR3_EXTI8 0x000FU /*!<EXTI 8 configuration */
#define SYSCFG_EXTICR3_EXTI9 0x00F0U /*!<EXTI 9 configuration */
#define SYSCFG_EXTICR3_EXTI10 0x0F00U /*!<EXTI 10 configuration */
#define SYSCFG_EXTICR3_EXTI11 0xF000U /*!<EXTI 11 configuration */
/**
* @brief EXTI8 configuration
*/
#define SYSCFG_EXTICR3_EXTI8_PA 0x0000U /*!<PA[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PB 0x0001U /*!<PB[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PC 0x0002U /*!<PC[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PD 0x0003U /*!<PD[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PE 0x0004U /*!<PE[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PF 0x0005U /*!<PF[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PG 0x0006U /*!<PG[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PH 0x0007U /*!<PH[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PI 0x0008U /*!<PI[8] pin */
#define SYSCFG_EXTICR3_EXTI8_PJ 0x0009U /*!<PJ[8] pin */
/**
* @brief EXTI9 configuration
*/
#define SYSCFG_EXTICR3_EXTI9_PA 0x0000U /*!<PA[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PB 0x0010U /*!<PB[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PC 0x0020U /*!<PC[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PD 0x0030U /*!<PD[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PE 0x0040U /*!<PE[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PF 0x0050U /*!<PF[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PG 0x0060U /*!<PG[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PH 0x0070U /*!<PH[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PI 0x0080U /*!<PI[9] pin */
#define SYSCFG_EXTICR3_EXTI9_PJ 0x0090U /*!<PJ[9] pin */
/**
* @brief EXTI10 configuration
*/
#define SYSCFG_EXTICR3_EXTI10_PA 0x0000U /*!<PA[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PB 0x0100U /*!<PB[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PC 0x0200U /*!<PC[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PD 0x0300U /*!<PD[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PE 0x0400U /*!<PE[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PF 0x0500U /*!<PF[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PG 0x0600U /*!<PG[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PH 0x0700U /*!<PH[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PI 0x0800U /*!<PI[10] pin */
#define SYSCFG_EXTICR3_EXTI10_PJ 0x0900U /*!<PJ[10] pin */
/**
* @brief EXTI11 configuration
*/
#define SYSCFG_EXTICR3_EXTI11_PA 0x0000U /*!<PA[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PB 0x1000U /*!<PB[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PC 0x2000U /*!<PC[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PD 0x3000U /*!<PD[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PE 0x4000U /*!<PE[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PF 0x5000U /*!<PF[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PG 0x6000U /*!<PG[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PH 0x7000U /*!<PH[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PI 0x8000U /*!<PI[11] pin */
#define SYSCFG_EXTICR3_EXTI11_PJ 0x9000U /*!<PJ[11] pin */
/***************** Bit definition for SYSCFG_EXTICR4 register ***************/
#define SYSCFG_EXTICR4_EXTI12 0x000FU /*!<EXTI 12 configuration */
#define SYSCFG_EXTICR4_EXTI13 0x00F0U /*!<EXTI 13 configuration */
#define SYSCFG_EXTICR4_EXTI14 0x0F00U /*!<EXTI 14 configuration */
#define SYSCFG_EXTICR4_EXTI15 0xF000U /*!<EXTI 15 configuration */
/**
* @brief EXTI12 configuration
*/
#define SYSCFG_EXTICR4_EXTI12_PA 0x0000U /*!<PA[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PB 0x0001U /*!<PB[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PC 0x0002U /*!<PC[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PD 0x0003U /*!<PD[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PE 0x0004U /*!<PE[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PF 0x0005U /*!<PF[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PG 0x0006U /*!<PG[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PH 0x0007U /*!<PH[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PI 0x0008U /*!<PI[12] pin */
#define SYSCFG_EXTICR4_EXTI12_PJ 0x0009U /*!<PJ[12] pin */
/**
* @brief EXTI13 configuration
*/
#define SYSCFG_EXTICR4_EXTI13_PA 0x0000U /*!<PA[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PB 0x0010U /*!<PB[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PC 0x0020U /*!<PC[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PD 0x0030U /*!<PD[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PE 0x0040U /*!<PE[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PF 0x0050U /*!<PF[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PG 0x0060U /*!<PG[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PH 0x0070U /*!<PH[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PI 0x0080U /*!<PI[13] pin */
#define SYSCFG_EXTICR4_EXTI13_PJ 0x0090U /*!<PJ[13] pin */
/**
* @brief EXTI14 configuration
*/
#define SYSCFG_EXTICR4_EXTI14_PA 0x0000U /*!<PA[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PB 0x0100U /*!<PB[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PC 0x0200U /*!<PC[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PD 0x0300U /*!<PD[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PE 0x0400U /*!<PE[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PF 0x0500U /*!<PF[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PG 0x0600U /*!<PG[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PH 0x0700U /*!<PH[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PI 0x0800U /*!<PI[14] pin */
#define SYSCFG_EXTICR4_EXTI14_PJ 0x0900U /*!<PJ[14] pin */
/**
* @brief EXTI15 configuration
*/
#define SYSCFG_EXTICR4_EXTI15_PA 0x0000U /*!<PA[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PB 0x1000U /*!<PB[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PC 0x2000U /*!<PC[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PD 0x3000U /*!<PD[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PE 0x4000U /*!<PE[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PF 0x5000U /*!<PF[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PG 0x6000U /*!<PG[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PH 0x7000U /*!<PH[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PI 0x8000U /*!<PI[15] pin */
#define SYSCFG_EXTICR4_EXTI15_PJ 0x9000U /*!<PJ[15] pin */
/****************** Bit definition for SYSCFG_CBR register ******************/
#define SYSCFG_CBR_CLL 0x00000001U /*!<Core Lockup Lock */
#define SYSCFG_CBR_PVDL 0x00000004U /*!<PVD Lock */
/****************** Bit definition for SYSCFG_CMPCR register ****************/
#define SYSCFG_CMPCR_CMP_PD 0x00000001U /*!<Compensation cell power-down */
#define SYSCFG_CMPCR_READY 0x00000100U /*!<Compensation cell ready flag */
/******************************************************************************/
/* */
/* TIM */
/* */
/******************************************************************************/
/******************* Bit definition for TIM_CR1 register ********************/
#define TIM_CR1_CEN 0x0001U /*!<Counter enable */
#define TIM_CR1_UDIS 0x0002U /*!<Update disable */
#define TIM_CR1_URS 0x0004U /*!<Update request source */
#define TIM_CR1_OPM 0x0008U /*!<One pulse mode */
#define TIM_CR1_DIR 0x0010U /*!<Direction */
#define TIM_CR1_CMS 0x0060U /*!<CMS[1:0] bits (Center-aligned mode selection) */
#define TIM_CR1_CMS_0 0x0020U /*!<Bit 0 */
#define TIM_CR1_CMS_1 0x0040U /*!<Bit 1 */
#define TIM_CR1_ARPE 0x0080U /*!<Auto-reload preload enable */
#define TIM_CR1_CKD 0x0300U /*!<CKD[1:0] bits (clock division) */
#define TIM_CR1_CKD_0 0x0100U /*!<Bit 0 */
#define TIM_CR1_CKD_1 0x0200U /*!<Bit 1 */
#define TIM_CR1_UIFREMAP 0x0800U /*!<UIF status bit */
/******************* Bit definition for TIM_CR2 register ********************/
#define TIM_CR2_CCPC 0x00000001U /*!<Capture/Compare Preloaded Control */
#define TIM_CR2_CCUS 0x00000004U /*!<Capture/Compare Control Update Selection */
#define TIM_CR2_CCDS 0x00000008U /*!<Capture/Compare DMA Selection */
#define TIM_CR2_OIS5 0x00010000U /*!<Output Idle state 4 (OC4 output) */
#define TIM_CR2_OIS6 0x00040000U /*!<Output Idle state 4 (OC4 output) */
#define TIM_CR2_MMS 0x0070U /*!<MMS[2:0] bits (Master Mode Selection) */
#define TIM_CR2_MMS_0 0x0010U /*!<Bit 0 */
#define TIM_CR2_MMS_1 0x0020U /*!<Bit 1 */
#define TIM_CR2_MMS_2 0x0040U /*!<Bit 2 */
#define TIM_CR2_MMS2 0x00F00000U /*!<MMS[2:0] bits (Master Mode Selection) */
#define TIM_CR2_MMS2_0 0x00100000U /*!<Bit 0 */
#define TIM_CR2_MMS2_1 0x00200000U /*!<Bit 1 */
#define TIM_CR2_MMS2_2 0x00400000U /*!<Bit 2 */
#define TIM_CR2_MMS2_3 0x00800000U /*!<Bit 2 */
#define TIM_CR2_TI1S 0x0080U /*!<TI1 Selection */
#define TIM_CR2_OIS1 0x0100U /*!<Output Idle state 1 (OC1 output) */
#define TIM_CR2_OIS1N 0x0200U /*!<Output Idle state 1 (OC1N output) */
#define TIM_CR2_OIS2 0x0400U /*!<Output Idle state 2 (OC2 output) */
#define TIM_CR2_OIS2N 0x0800U /*!<Output Idle state 2 (OC2N output) */
#define TIM_CR2_OIS3 0x1000U /*!<Output Idle state 3 (OC3 output) */
#define TIM_CR2_OIS3N 0x2000U /*!<Output Idle state 3 (OC3N output) */
#define TIM_CR2_OIS4 0x4000U /*!<Output Idle state 4 (OC4 output) */
/******************* Bit definition for TIM_SMCR register *******************/
#define TIM_SMCR_SMS 0x00010007U /*!<SMS[2:0] bits (Slave mode selection) */
#define TIM_SMCR_SMS_0 0x00000001U /*!<Bit 0 */
#define TIM_SMCR_SMS_1 0x00000002U /*!<Bit 1 */
#define TIM_SMCR_SMS_2 0x00000004U /*!<Bit 2 */
#define TIM_SMCR_SMS_3 0x00010000U /*!<Bit 3 */
#define TIM_SMCR_OCCS 0x00000008U /*!< OCREF clear selection */
#define TIM_SMCR_TS 0x0070U /*!<TS[2:0] bits (Trigger selection) */
#define TIM_SMCR_TS_0 0x0010U /*!<Bit 0 */
#define TIM_SMCR_TS_1 0x0020U /*!<Bit 1 */
#define TIM_SMCR_TS_2 0x0040U /*!<Bit 2 */
#define TIM_SMCR_MSM 0x0080U /*!<Master/slave mode */
#define TIM_SMCR_ETF 0x0F00U /*!<ETF[3:0] bits (External trigger filter) */
#define TIM_SMCR_ETF_0 0x0100U /*!<Bit 0 */
#define TIM_SMCR_ETF_1 0x0200U /*!<Bit 1 */
#define TIM_SMCR_ETF_2 0x0400U /*!<Bit 2 */
#define TIM_SMCR_ETF_3 0x0800U /*!<Bit 3 */
#define TIM_SMCR_ETPS 0x3000U /*!<ETPS[1:0] bits (External trigger prescaler) */
#define TIM_SMCR_ETPS_0 0x1000U /*!<Bit 0 */
#define TIM_SMCR_ETPS_1 0x2000U /*!<Bit 1 */
#define TIM_SMCR_ECE 0x4000U /*!<External clock enable */
#define TIM_SMCR_ETP 0x8000U /*!<External trigger polarity */
/******************* Bit definition for TIM_DIER register *******************/
#define TIM_DIER_UIE 0x0001U /*!<Update interrupt enable */
#define TIM_DIER_CC1IE 0x0002U /*!<Capture/Compare 1 interrupt enable */
#define TIM_DIER_CC2IE 0x0004U /*!<Capture/Compare 2 interrupt enable */
#define TIM_DIER_CC3IE 0x0008U /*!<Capture/Compare 3 interrupt enable */
#define TIM_DIER_CC4IE 0x0010U /*!<Capture/Compare 4 interrupt enable */
#define TIM_DIER_COMIE 0x0020U /*!<COM interrupt enable */
#define TIM_DIER_TIE 0x0040U /*!<Trigger interrupt enable */
#define TIM_DIER_BIE 0x0080U /*!<Break interrupt enable */
#define TIM_DIER_UDE 0x0100U /*!<Update DMA request enable */
#define TIM_DIER_CC1DE 0x0200U /*!<Capture/Compare 1 DMA request enable */
#define TIM_DIER_CC2DE 0x0400U /*!<Capture/Compare 2 DMA request enable */
#define TIM_DIER_CC3DE 0x0800U /*!<Capture/Compare 3 DMA request enable */
#define TIM_DIER_CC4DE 0x1000U /*!<Capture/Compare 4 DMA request enable */
#define TIM_DIER_COMDE 0x2000U /*!<COM DMA request enable */
#define TIM_DIER_TDE 0x4000U /*!<Trigger DMA request enable */
/******************** Bit definition for TIM_SR register ********************/
#define TIM_SR_UIF 0x0001U /*!<Update interrupt Flag */
#define TIM_SR_CC1IF 0x0002U /*!<Capture/Compare 1 interrupt Flag */
#define TIM_SR_CC2IF 0x0004U /*!<Capture/Compare 2 interrupt Flag */
#define TIM_SR_CC3IF 0x0008U /*!<Capture/Compare 3 interrupt Flag */
#define TIM_SR_CC4IF 0x0010U /*!<Capture/Compare 4 interrupt Flag */
#define TIM_SR_COMIF 0x0020U /*!<COM interrupt Flag */
#define TIM_SR_TIF 0x0040U /*!<Trigger interrupt Flag */
#define TIM_SR_BIF 0x0080U /*!<Break interrupt Flag */
#define TIM_SR_B2IF 0x0100U /*!<Break2 interrupt Flag */
#define TIM_SR_CC1OF 0x0200U /*!<Capture/Compare 1 Overcapture Flag */
#define TIM_SR_CC2OF 0x0400U /*!<Capture/Compare 2 Overcapture Flag */
#define TIM_SR_CC3OF 0x0800U /*!<Capture/Compare 3 Overcapture Flag */
#define TIM_SR_CC4OF 0x1000U /*!<Capture/Compare 4 Overcapture Flag */
/******************* Bit definition for TIM_EGR register ********************/
#define TIM_EGR_UG 0x00000001U /*!<Update Generation */
#define TIM_EGR_CC1G 0x00000002U /*!<Capture/Compare 1 Generation */
#define TIM_EGR_CC2G 0x00000004U /*!<Capture/Compare 2 Generation */
#define TIM_EGR_CC3G 0x00000008U /*!<Capture/Compare 3 Generation */
#define TIM_EGR_CC4G 0x00000010U /*!<Capture/Compare 4 Generation */
#define TIM_EGR_COMG 0x00000020U /*!<Capture/Compare Control Update Generation */
#define TIM_EGR_TG 0x00000040U /*!<Trigger Generation */
#define TIM_EGR_BG 0x00000080U /*!<Break Generation */
#define TIM_EGR_B2G 0x00000100U /*!<Break2 Generation */
/****************** Bit definition for TIM_CCMR1 register *******************/
#define TIM_CCMR1_CC1S 0x00000003U /*!<CC1S[1:0] bits (Capture/Compare 1 Selection) */
#define TIM_CCMR1_CC1S_0 0x00000001U /*!<Bit 0 */
#define TIM_CCMR1_CC1S_1 0x00000002U /*!<Bit 1 */
#define TIM_CCMR1_OC1FE 0x00000004U /*!<Output Compare 1 Fast enable */
#define TIM_CCMR1_OC1PE 0x00000008U /*!<Output Compare 1 Preload enable */
#define TIM_CCMR1_OC1M 0x00010070U /*!<OC1M[2:0] bits (Output Compare 1 Mode) */
#define TIM_CCMR1_OC1M_0 0x00000010U /*!<Bit 0 */
#define TIM_CCMR1_OC1M_1 0x00000020U /*!<Bit 1 */
#define TIM_CCMR1_OC1M_2 0x00000040U /*!<Bit 2 */
#define TIM_CCMR1_OC1M_3 0x00010000U /*!<Bit 3 */
#define TIM_CCMR1_OC1CE 0x00000080U /*!<Output Compare 1Clear Enable */
#define TIM_CCMR1_CC2S 0x00000300U /*!<CC2S[1:0] bits (Capture/Compare 2 Selection) */
#define TIM_CCMR1_CC2S_0 0x00000100U /*!<Bit 0 */
#define TIM_CCMR1_CC2S_1 0x00000200U /*!<Bit 1 */
#define TIM_CCMR1_OC2FE 0x00000400U /*!<Output Compare 2 Fast enable */
#define TIM_CCMR1_OC2PE 0x00000800U /*!<Output Compare 2 Preload enable */
#define TIM_CCMR1_OC2M 0x01007000U /*!<OC2M[2:0] bits (Output Compare 2 Mode) */
#define TIM_CCMR1_OC2M_0 0x00001000U /*!<Bit 0 */
#define TIM_CCMR1_OC2M_1 0x00002000U /*!<Bit 1 */
#define TIM_CCMR1_OC2M_2 0x00004000U /*!<Bit 2 */
#define TIM_CCMR1_OC2M_3 0x01000000U /*!<Bit 3 */
#define TIM_CCMR1_OC2CE 0x00008000U /*!<Output Compare 2 Clear Enable */
/*----------------------------------------------------------------------------*/
#define TIM_CCMR1_IC1PSC 0x000CU /*!<IC1PSC[1:0] bits (Input Capture 1 Prescaler) */
#define TIM_CCMR1_IC1PSC_0 0x0004U /*!<Bit 0 */
#define TIM_CCMR1_IC1PSC_1 0x0008U /*!<Bit 1 */
#define TIM_CCMR1_IC1F 0x00F0U /*!<IC1F[3:0] bits (Input Capture 1 Filter) */
#define TIM_CCMR1_IC1F_0 0x0010U /*!<Bit 0 */
#define TIM_CCMR1_IC1F_1 0x0020U /*!<Bit 1 */
#define TIM_CCMR1_IC1F_2 0x0040U /*!<Bit 2 */
#define TIM_CCMR1_IC1F_3 0x0080U /*!<Bit 3 */
#define TIM_CCMR1_IC2PSC 0x0C00U /*!<IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
#define TIM_CCMR1_IC2PSC_0 0x0400U /*!<Bit 0 */
#define TIM_CCMR1_IC2PSC_1 0x0800U /*!<Bit 1 */
#define TIM_CCMR1_IC2F 0xF000U /*!<IC2F[3:0] bits (Input Capture 2 Filter) */
#define TIM_CCMR1_IC2F_0 0x1000U /*!<Bit 0 */
#define TIM_CCMR1_IC2F_1 0x2000U /*!<Bit 1 */
#define TIM_CCMR1_IC2F_2 0x4000U /*!<Bit 2 */
#define TIM_CCMR1_IC2F_3 0x8000U /*!<Bit 3 */
/****************** Bit definition for TIM_CCMR2 register *******************/
#define TIM_CCMR2_CC3S 0x00000003U /*!<CC3S[1:0] bits (Capture/Compare 3 Selection) */
#define TIM_CCMR2_CC3S_0 0x00000001U /*!<Bit 0 */
#define TIM_CCMR2_CC3S_1 0x00000002U /*!<Bit 1 */
#define TIM_CCMR2_OC3FE 0x00000004U /*!<Output Compare 3 Fast enable */
#define TIM_CCMR2_OC3PE 0x00000008U /*!<Output Compare 3 Preload enable */
#define TIM_CCMR2_OC3M 0x00010070U /*!<OC3M[2:0] bits (Output Compare 3 Mode) */
#define TIM_CCMR2_OC3M_0 0x00000010U /*!<Bit 0 */
#define TIM_CCMR2_OC3M_1 0x00000020U /*!<Bit 1 */
#define TIM_CCMR2_OC3M_2 0x00000040U /*!<Bit 2 */
#define TIM_CCMR2_OC3M_3 0x00010000U /*!<Bit 3 */
#define TIM_CCMR2_OC3CE 0x00000080U /*!<Output Compare 3 Clear Enable */
#define TIM_CCMR2_CC4S 0x00000300U /*!<CC4S[1:0] bits (Capture/Compare 4 Selection) */
#define TIM_CCMR2_CC4S_0 0x00000100U /*!<Bit 0 */
#define TIM_CCMR2_CC4S_1 0x00000200U /*!<Bit 1 */
#define TIM_CCMR2_OC4FE 0x00000400U /*!<Output Compare 4 Fast enable */
#define TIM_CCMR2_OC4PE 0x00000800U /*!<Output Compare 4 Preload enable */
#define TIM_CCMR2_OC4M 0x01007000U /*!<OC4M[2:0] bits (Output Compare 4 Mode) */
#define TIM_CCMR2_OC4M_0 0x00001000U /*!<Bit 0 */
#define TIM_CCMR2_OC4M_1 0x00002000U /*!<Bit 1 */
#define TIM_CCMR2_OC4M_2 0x00004000U /*!<Bit 2 */
#define TIM_CCMR2_OC4M_3 0x01000000U /*!<Bit 3 */
#define TIM_CCMR2_OC4CE 0x8000U /*!<Output Compare 4 Clear Enable */
/*----------------------------------------------------------------------------*/
#define TIM_CCMR2_IC3PSC 0x000CU /*!<IC3PSC[1:0] bits (Input Capture 3 Prescaler) */
#define TIM_CCMR2_IC3PSC_0 0x0004U /*!<Bit 0 */
#define TIM_CCMR2_IC3PSC_1 0x0008U /*!<Bit 1 */
#define TIM_CCMR2_IC3F 0x00F0U /*!<IC3F[3:0] bits (Input Capture 3 Filter) */
#define TIM_CCMR2_IC3F_0 0x0010U /*!<Bit 0 */
#define TIM_CCMR2_IC3F_1 0x0020U /*!<Bit 1 */
#define TIM_CCMR2_IC3F_2 0x0040U /*!<Bit 2 */
#define TIM_CCMR2_IC3F_3 0x0080U /*!<Bit 3 */
#define TIM_CCMR2_IC4PSC 0x0C00U /*!<IC4PSC[1:0] bits (Input Capture 4 Prescaler) */
#define TIM_CCMR2_IC4PSC_0 0x0400U /*!<Bit 0 */
#define TIM_CCMR2_IC4PSC_1 0x0800U /*!<Bit 1 */
#define TIM_CCMR2_IC4F 0xF000U /*!<IC4F[3:0] bits (Input Capture 4 Filter) */
#define TIM_CCMR2_IC4F_0 0x1000U /*!<Bit 0 */
#define TIM_CCMR2_IC4F_1 0x2000U /*!<Bit 1 */
#define TIM_CCMR2_IC4F_2 0x4000U /*!<Bit 2 */
#define TIM_CCMR2_IC4F_3 0x8000U /*!<Bit 3 */
/******************* Bit definition for TIM_CCER register *******************/
#define TIM_CCER_CC1E 0x00000001U /*!<Capture/Compare 1 output enable */
#define TIM_CCER_CC1P 0x00000002U /*!<Capture/Compare 1 output Polarity */
#define TIM_CCER_CC1NE 0x00000004U /*!<Capture/Compare 1 Complementary output enable */
#define TIM_CCER_CC1NP 0x00000008U /*!<Capture/Compare 1 Complementary output Polarity */
#define TIM_CCER_CC2E 0x00000010U /*!<Capture/Compare 2 output enable */
#define TIM_CCER_CC2P 0x00000020U /*!<Capture/Compare 2 output Polarity */
#define TIM_CCER_CC2NE 0x00000040U /*!<Capture/Compare 2 Complementary output enable */
#define TIM_CCER_CC2NP 0x00000080U /*!<Capture/Compare 2 Complementary output Polarity */
#define TIM_CCER_CC3E 0x00000100U /*!<Capture/Compare 3 output enable */
#define TIM_CCER_CC3P 0x00000200U /*!<Capture/Compare 3 output Polarity */
#define TIM_CCER_CC3NE 0x00000400U /*!<Capture/Compare 3 Complementary output enable */
#define TIM_CCER_CC3NP 0x00000800U /*!<Capture/Compare 3 Complementary output Polarity */
#define TIM_CCER_CC4E 0x00001000U /*!<Capture/Compare 4 output enable */
#define TIM_CCER_CC4P 0x00002000U /*!<Capture/Compare 4 output Polarity */
#define TIM_CCER_CC4NP 0x00008000U /*!<Capture/Compare 4 Complementary output Polarity */
#define TIM_CCER_CC5E 0x00010000U /*!<Capture/Compare 5 output enable */
#define TIM_CCER_CC5P 0x00020000U /*!<Capture/Compare 5 output Polarity */
#define TIM_CCER_CC6E 0x00100000U /*!<Capture/Compare 6 output enable */
#define TIM_CCER_CC6P 0x00200000U /*!<Capture/Compare 6 output Polarity */
/******************* Bit definition for TIM_CNT register ********************/
#define TIM_CNT_CNT 0xFFFFU /*!<Counter Value */
/******************* Bit definition for TIM_PSC register ********************/
#define TIM_PSC_PSC 0xFFFFU /*!<Prescaler Value */
/******************* Bit definition for TIM_ARR register ********************/
#define TIM_ARR_ARR 0xFFFFU /*!<actual auto-reload Value */
/******************* Bit definition for TIM_RCR register ********************/
#define TIM_RCR_REP ((uint8_t)0xFFU) /*!<Repetition Counter Value */
/******************* Bit definition for TIM_CCR1 register *******************/
#define TIM_CCR1_CCR1 0xFFFFU /*!<Capture/Compare 1 Value */
/******************* Bit definition for TIM_CCR2 register *******************/
#define TIM_CCR2_CCR2 0xFFFFU /*!<Capture/Compare 2 Value */
/******************* Bit definition for TIM_CCR3 register *******************/
#define TIM_CCR3_CCR3 0xFFFFU /*!<Capture/Compare 3 Value */
/******************* Bit definition for TIM_CCR4 register *******************/
#define TIM_CCR4_CCR4 0xFFFFU /*!<Capture/Compare 4 Value */
/******************* Bit definition for TIM_BDTR register *******************/
#define TIM_BDTR_DTG 0x000000FFU /*!<DTG[0:7] bits (Dead-Time Generator set-up) */
#define TIM_BDTR_DTG_0 0x00000001U /*!<Bit 0 */
#define TIM_BDTR_DTG_1 0x00000002U /*!<Bit 1 */
#define TIM_BDTR_DTG_2 0x00000004U /*!<Bit 2 */
#define TIM_BDTR_DTG_3 0x00000008U /*!<Bit 3 */
#define TIM_BDTR_DTG_4 0x00000010U /*!<Bit 4 */
#define TIM_BDTR_DTG_5 0x00000020U /*!<Bit 5 */
#define TIM_BDTR_DTG_6 0x00000040U /*!<Bit 6 */
#define TIM_BDTR_DTG_7 0x00000080U /*!<Bit 7 */
#define TIM_BDTR_LOCK 0x00000300U /*!<LOCK[1:0] bits (Lock Configuration) */
#define TIM_BDTR_LOCK_0 0x00000100U /*!<Bit 0 */
#define TIM_BDTR_LOCK_1 0x00000200U /*!<Bit 1 */
#define TIM_BDTR_OSSI 0x00000400U /*!<Off-State Selection for Idle mode */
#define TIM_BDTR_OSSR 0x00000800U /*!<Off-State Selection for Run mode */
#define TIM_BDTR_BKE 0x00001000U /*!<Break enable */
#define TIM_BDTR_BKP 0x00002000U /*!<Break Polarity */
#define TIM_BDTR_AOE 0x00004000U /*!<Automatic Output enable */
#define TIM_BDTR_MOE 0x00008000U /*!<Main Output enable */
#define TIM_BDTR_BKF 0x000F0000U /*!<Break Filter for Break1 */
#define TIM_BDTR_BK2F 0x00F00000U /*!<Break Filter for Break2 */
#define TIM_BDTR_BK2E 0x01000000U /*!<Break enable for Break2 */
#define TIM_BDTR_BK2P 0x02000000U /*!<Break Polarity for Break2 */
/******************* Bit definition for TIM_DCR register ********************/
#define TIM_DCR_DBA 0x001FU /*!<DBA[4:0] bits (DMA Base Address) */
#define TIM_DCR_DBA_0 0x0001U /*!<Bit 0 */
#define TIM_DCR_DBA_1 0x0002U /*!<Bit 1 */
#define TIM_DCR_DBA_2 0x0004U /*!<Bit 2 */
#define TIM_DCR_DBA_3 0x0008U /*!<Bit 3 */
#define TIM_DCR_DBA_4 0x0010U /*!<Bit 4 */
#define TIM_DCR_DBL 0x1F00U /*!<DBL[4:0] bits (DMA Burst Length) */
#define TIM_DCR_DBL_0 0x0100U /*!<Bit 0 */
#define TIM_DCR_DBL_1 0x0200U /*!<Bit 1 */
#define TIM_DCR_DBL_2 0x0400U /*!<Bit 2 */
#define TIM_DCR_DBL_3 0x0800U /*!<Bit 3 */
#define TIM_DCR_DBL_4 0x1000U /*!<Bit 4 */
/******************* Bit definition for TIM_DMAR register *******************/
#define TIM_DMAR_DMAB 0xFFFFU /*!<DMA register for burst accesses */
/******************* Bit definition for TIM_OR regiter *********************/
#define TIM_OR_TI4_RMP 0x00C0U /*!<TI4_RMP[1:0] bits (TIM5 Input 4 remap) */
#define TIM_OR_TI4_RMP_0 0x0040U /*!<Bit 0 */
#define TIM_OR_TI4_RMP_1 0x0080U /*!<Bit 1 */
#define TIM_OR_ITR1_RMP 0x0C00U /*!<ITR1_RMP[1:0] bits (TIM2 Internal trigger 1 remap) */
#define TIM_OR_ITR1_RMP_0 0x0400U /*!<Bit 0 */
#define TIM_OR_ITR1_RMP_1 0x0800U /*!<Bit 1 */
/****************** Bit definition for TIM_CCMR3 register *******************/
#define TIM_CCMR3_OC5FE 0x00000004U /*!<Output Compare 5 Fast enable */
#define TIM_CCMR3_OC5PE 0x00000008U /*!<Output Compare 5 Preload enable */
#define TIM_CCMR3_OC5M 0x00010070U /*!<OC5M[2:0] bits (Output Compare 5 Mode) */
#define TIM_CCMR3_OC5M_0 0x00000010U /*!<Bit 0 */
#define TIM_CCMR3_OC5M_1 0x00000020U /*!<Bit 1 */
#define TIM_CCMR3_OC5M_2 0x00000040U /*!<Bit 2 */
#define TIM_CCMR3_OC5M_3 0x00010000U /*!<Bit 3 */
#define TIM_CCMR3_OC5CE 0x00000080U /*!<Output Compare 5 Clear Enable */
#define TIM_CCMR3_OC6FE 0x00000400U /*!<Output Compare 4 Fast enable */
#define TIM_CCMR3_OC6PE 0x00000800U /*!<Output Compare 4 Preload enable */
#define TIM_CCMR3_OC6M 0x01007000U /*!<OC4M[2:0] bits (Output Compare 4 Mode) */
#define TIM_CCMR3_OC6M_0 0x00001000U /*!<Bit 0 */
#define TIM_CCMR3_OC6M_1 0x00002000U /*!<Bit 1 */
#define TIM_CCMR3_OC6M_2 0x00004000U /*!<Bit 2 */
#define TIM_CCMR3_OC6M_3 0x01000000U /*!<Bit 3 */
#define TIM_CCMR3_OC6CE 0x00008000U /*!<Output Compare 4 Clear Enable */
/******************* Bit definition for TIM_CCR5 register *******************/
#define TIM_CCR5_CCR5 0xFFFFFFFFU /*!<Capture/Compare 5 Value */
#define TIM_CCR5_GC5C1 0x20000000U /*!<Group Channel 5 and Channel 1 */
#define TIM_CCR5_GC5C2 0x40000000U /*!<Group Channel 5 and Channel 2 */
#define TIM_CCR5_GC5C3 0x80000000U /*!<Group Channel 5 and Channel 3 */
/******************* Bit definition for TIM_CCR6 register *******************/
#define TIM_CCR6_CCR6 ((uint16_t)0xFFFFU) /*!<Capture/Compare 6 Value */
/******************* Bit definition for TIM1_AF1 register *******************/
#define TIM1_AF1_BKINE 0x00000001U /*!<BRK BKIN input enable */
#define TIM1_AF1_BKDF1BKE 0x00000100U /*!<BRK DFSDM1_BREAK enable */
/******************* Bit definition for TIM1_AF2 register *******************/
#define TIM1_AF2_BK2INE 0x00000001U /*!<BRK2 BKIN input enable */
#define TIM1_AF2_BK2DF1BKE 0x00000100U /*!<BRK2 DFSDM1_BREAK enable */
/******************* Bit definition for TIM8_AF1 register *******************/
#define TIM8_AF1_BKINE 0x00000001U /*!<BRK BKIN input enable */
#define TIM8_AF1_BKDF1BKE 0x00000100U /*!<BRK DFSDM1_BREAK enable */
/******************* Bit definition for TIM8_AF2 register *******************/
#define TIM8_AF2_BK2INE 0x00000001U /*!<BRK2 BKIN2 input enable */
#define TIM8_AF2_BK2DF1BKE 0x00000100U /*!<BRK2 DFSDM1_BREAK enable */
/******************************************************************************/
/* */
/* Low Power Timer (LPTIM) */
/* */
/******************************************************************************/
/****************** Bit definition for LPTIM_ISR register *******************/
#define LPTIM_ISR_CMPM 0x00000001U /*!< Compare match */
#define LPTIM_ISR_ARRM 0x00000002U /*!< Autoreload match */
#define LPTIM_ISR_EXTTRIG 0x00000004U /*!< External trigger edge event */
#define LPTIM_ISR_CMPOK 0x00000008U /*!< Compare register update OK */
#define LPTIM_ISR_ARROK 0x00000010U /*!< Autoreload register update OK */
#define LPTIM_ISR_UP 0x00000020U /*!< Counter direction change down to up */
#define LPTIM_ISR_DOWN 0x00000040U /*!< Counter direction change up to down */
/****************** Bit definition for LPTIM_ICR register *******************/
#define LPTIM_ICR_CMPMCF 0x00000001U /*!< Compare match Clear Flag */
#define LPTIM_ICR_ARRMCF 0x00000002U /*!< Autoreload match Clear Flag */
#define LPTIM_ICR_EXTTRIGCF 0x00000004U /*!< External trigger edge event Clear Flag */
#define LPTIM_ICR_CMPOKCF 0x00000008U /*!< Compare register update OK Clear Flag */
#define LPTIM_ICR_ARROKCF 0x00000010U /*!< Autoreload register update OK Clear Flag */
#define LPTIM_ICR_UPCF 0x00000020U /*!< Counter direction change down to up Clear Flag */
#define LPTIM_ICR_DOWNCF 0x00000040U /*!< Counter direction change up to down Clear Flag */
/****************** Bit definition for LPTIM_IER register *******************/
#define LPTIM_IER_CMPMIE 0x00000001U /*!< Compare match Interrupt Enable */
#define LPTIM_IER_ARRMIE 0x00000002U /*!< Autoreload match Interrupt Enable */
#define LPTIM_IER_EXTTRIGIE 0x00000004U /*!< External trigger edge event Interrupt Enable */
#define LPTIM_IER_CMPOKIE 0x00000008U /*!< Compare register update OK Interrupt Enable */
#define LPTIM_IER_ARROKIE 0x00000010U /*!< Autoreload register update OK Interrupt Enable */
#define LPTIM_IER_UPIE 0x00000020U /*!< Counter direction change down to up Interrupt Enable */
#define LPTIM_IER_DOWNIE 0x00000040U /*!< Counter direction change up to down Interrupt Enable */
/****************** Bit definition for LPTIM_CFGR register*******************/
#define LPTIM_CFGR_CKSEL 0x00000001U /*!< Clock selector */
#define LPTIM_CFGR_CKPOL 0x00000006U /*!< CKPOL[1:0] bits (Clock polarity) */
#define LPTIM_CFGR_CKPOL_0 0x00000002U /*!< Bit 0 */
#define LPTIM_CFGR_CKPOL_1 0x00000004U /*!< Bit 1 */
#define LPTIM_CFGR_CKFLT 0x00000018U /*!< CKFLT[1:0] bits (Configurable digital filter for external clock) */
#define LPTIM_CFGR_CKFLT_0 0x00000008U /*!< Bit 0 */
#define LPTIM_CFGR_CKFLT_1 0x00000010U /*!< Bit 1 */
#define LPTIM_CFGR_TRGFLT 0x000000C0U /*!< TRGFLT[1:0] bits (Configurable digital filter for trigger) */
#define LPTIM_CFGR_TRGFLT_0 0x00000040U /*!< Bit 0 */
#define LPTIM_CFGR_TRGFLT_1 0x00000080U /*!< Bit 1 */
#define LPTIM_CFGR_PRESC 0x00000E00U /*!< PRESC[2:0] bits (Clock prescaler) */
#define LPTIM_CFGR_PRESC_0 0x00000200U /*!< Bit 0 */
#define LPTIM_CFGR_PRESC_1 0x00000400U /*!< Bit 1 */
#define LPTIM_CFGR_PRESC_2 0x00000800U /*!< Bit 2 */
#define LPTIM_CFGR_TRIGSEL 0x0000E000U /*!< TRIGSEL[2:0]] bits (Trigger selector) */
#define LPTIM_CFGR_TRIGSEL_0 0x00002000U /*!< Bit 0 */
#define LPTIM_CFGR_TRIGSEL_1 0x00004000U /*!< Bit 1 */
#define LPTIM_CFGR_TRIGSEL_2 0x00008000U /*!< Bit 2 */
#define LPTIM_CFGR_TRIGEN 0x00060000U /*!< TRIGEN[1:0] bits (Trigger enable and polarity) */
#define LPTIM_CFGR_TRIGEN_0 0x00020000U /*!< Bit 0 */
#define LPTIM_CFGR_TRIGEN_1 0x00040000U /*!< Bit 1 */
#define LPTIM_CFGR_TIMOUT 0x00080000U /*!< Timout enable */
#define LPTIM_CFGR_WAVE 0x00100000U /*!< Waveform shape */
#define LPTIM_CFGR_WAVPOL 0x00200000U /*!< Waveform shape polarity */
#define LPTIM_CFGR_PRELOAD 0x00400000U /*!< Reg update mode */
#define LPTIM_CFGR_COUNTMODE 0x00800000U /*!< Counter mode enable */
#define LPTIM_CFGR_ENC 0x01000000U /*!< Encoder mode enable */
/****************** Bit definition for LPTIM_CR register ********************/
#define LPTIM_CR_ENABLE 0x00000001U /*!< LPTIMer enable */
#define LPTIM_CR_SNGSTRT 0x00000002U /*!< Timer start in single mode */
#define LPTIM_CR_CNTSTRT 0x00000004U /*!< Timer start in continuous mode */
/****************** Bit definition for LPTIM_CMP register *******************/
#define LPTIM_CMP_CMP 0x0000FFFFU /*!< Compare register */
/****************** Bit definition for LPTIM_ARR register *******************/
#define LPTIM_ARR_ARR 0x0000FFFFU /*!< Auto reload register */
/****************** Bit definition for LPTIM_CNT register *******************/
#define LPTIM_CNT_CNT 0x0000FFFFU /*!< Counter register */
/******************************************************************************/
/* */
/* Universal Synchronous Asynchronous Receiver Transmitter (USART) */
/* */
/******************************************************************************/
/****************** Bit definition for USART_CR1 register *******************/
#define USART_CR1_UE 0x00000001U /*!< USART Enable */
#define USART_CR1_RE 0x00000004U /*!< Receiver Enable */
#define USART_CR1_TE 0x00000008U /*!< Transmitter Enable */
#define USART_CR1_IDLEIE 0x00000010U /*!< IDLE Interrupt Enable */
#define USART_CR1_RXNEIE 0x00000020U /*!< RXNE Interrupt Enable */
#define USART_CR1_TCIE 0x00000040U /*!< Transmission Complete Interrupt Enable */
#define USART_CR1_TXEIE 0x00000080U /*!< TXE Interrupt Enable */
#define USART_CR1_PEIE 0x00000100U /*!< PE Interrupt Enable */
#define USART_CR1_PS 0x00000200U /*!< Parity Selection */
#define USART_CR1_PCE 0x00000400U /*!< Parity Control Enable */
#define USART_CR1_WAKE 0x00000800U /*!< Receiver Wakeup method */
#define USART_CR1_M 0x10001000U /*!< Word length */
#define USART_CR1_M_0 0x00001000U /*!< Word length - Bit 0 */
#define USART_CR1_MME 0x00002000U /*!< Mute Mode Enable */
#define USART_CR1_CMIE 0x00004000U /*!< Character match interrupt enable */
#define USART_CR1_OVER8 0x00008000U /*!< Oversampling by 8-bit or 16-bit mode */
#define USART_CR1_DEDT 0x001F0000U /*!< DEDT[4:0] bits (Driver Enable Deassertion Time) */
#define USART_CR1_DEDT_0 0x00010000U /*!< Bit 0 */
#define USART_CR1_DEDT_1 0x00020000U /*!< Bit 1 */
#define USART_CR1_DEDT_2 0x00040000U /*!< Bit 2 */
#define USART_CR1_DEDT_3 0x00080000U /*!< Bit 3 */
#define USART_CR1_DEDT_4 0x00100000U /*!< Bit 4 */
#define USART_CR1_DEAT 0x03E00000U /*!< DEAT[4:0] bits (Driver Enable Assertion Time) */
#define USART_CR1_DEAT_0 0x00200000U /*!< Bit 0 */
#define USART_CR1_DEAT_1 0x00400000U /*!< Bit 1 */
#define USART_CR1_DEAT_2 0x00800000U /*!< Bit 2 */
#define USART_CR1_DEAT_3 0x01000000U /*!< Bit 3 */
#define USART_CR1_DEAT_4 0x02000000U /*!< Bit 4 */
#define USART_CR1_RTOIE 0x04000000U /*!< Receive Time Out interrupt enable */
#define USART_CR1_EOBIE 0x08000000U /*!< End of Block interrupt enable */
#define USART_CR1_M_1 0x10000000U /*!< Word length - Bit 1 */
/****************** Bit definition for USART_CR2 register *******************/
#define USART_CR2_ADDM7 0x00000010U /*!< 7-bit or 4-bit Address Detection */
#define USART_CR2_LBDL 0x00000020U /*!< LIN Break Detection Length */
#define USART_CR2_LBDIE 0x00000040U /*!< LIN Break Detection Interrupt Enable */
#define USART_CR2_LBCL 0x00000100U /*!< Last Bit Clock pulse */
#define USART_CR2_CPHA 0x00000200U /*!< Clock Phase */
#define USART_CR2_CPOL 0x00000400U /*!< Clock Polarity */
#define USART_CR2_CLKEN 0x00000800U /*!< Clock Enable */
#define USART_CR2_STOP 0x00003000U /*!< STOP[1:0] bits (STOP bits) */
#define USART_CR2_STOP_0 0x00001000U /*!< Bit 0 */
#define USART_CR2_STOP_1 0x00002000U /*!< Bit 1 */
#define USART_CR2_LINEN 0x00004000U /*!< LIN mode enable */
#define USART_CR2_SWAP 0x00008000U /*!< SWAP TX/RX pins */
#define USART_CR2_RXINV 0x00010000U /*!< RX pin active level inversion */
#define USART_CR2_TXINV 0x00020000U /*!< TX pin active level inversion */
#define USART_CR2_DATAINV 0x00040000U /*!< Binary data inversion */
#define USART_CR2_MSBFIRST 0x00080000U /*!< Most Significant Bit First */
#define USART_CR2_ABREN 0x00100000U /*!< Auto Baud-Rate Enable */
#define USART_CR2_ABRMODE 0x00600000U /*!< ABRMOD[1:0] bits (Auto Baud-Rate Mode) */
#define USART_CR2_ABRMODE_0 0x00200000U /*!< Bit 0 */
#define USART_CR2_ABRMODE_1 0x00400000U /*!< Bit 1 */
#define USART_CR2_RTOEN 0x00800000U /*!< Receiver Time-Out enable */
#define USART_CR2_ADD 0xFF000000U /*!< Address of the USART node */
/****************** Bit definition for USART_CR3 register *******************/
#define USART_CR3_EIE 0x00000001U /*!< Error Interrupt Enable */
#define USART_CR3_IREN 0x00000002U /*!< IrDA mode Enable */
#define USART_CR3_IRLP 0x00000004U /*!< IrDA Low-Power */
#define USART_CR3_HDSEL 0x00000008U /*!< Half-Duplex Selection */
#define USART_CR3_NACK 0x00000010U /*!< SmartCard NACK enable */
#define USART_CR3_SCEN 0x00000020U /*!< SmartCard mode enable */
#define USART_CR3_DMAR 0x00000040U /*!< DMA Enable Receiver */
#define USART_CR3_DMAT 0x00000080U /*!< DMA Enable Transmitter */
#define USART_CR3_RTSE 0x00000100U /*!< RTS Enable */
#define USART_CR3_CTSE 0x00000200U /*!< CTS Enable */
#define USART_CR3_CTSIE 0x00000400U /*!< CTS Interrupt Enable */
#define USART_CR3_ONEBIT 0x00000800U /*!< One sample bit method enable */
#define USART_CR3_OVRDIS 0x00001000U /*!< Overrun Disable */
#define USART_CR3_DDRE 0x00002000U /*!< DMA Disable on Reception Error */
#define USART_CR3_DEM 0x00004000U /*!< Driver Enable Mode */
#define USART_CR3_DEP 0x00008000U /*!< Driver Enable Polarity Selection */
#define USART_CR3_SCARCNT 0x000E0000U /*!< SCARCNT[2:0] bits (SmartCard Auto-Retry Count) */
#define USART_CR3_SCARCNT_0 0x00020000U /*!< Bit 0 */
#define USART_CR3_SCARCNT_1 0x00040000U /*!< Bit 1 */
#define USART_CR3_SCARCNT_2 0x00080000U /*!< Bit 2 */
/****************** Bit definition for USART_BRR register *******************/
#define USART_BRR_DIV_FRACTION 0x000FU /*!< Fraction of USARTDIV */
#define USART_BRR_DIV_MANTISSA 0xFFF0U /*!< Mantissa of USARTDIV */
/****************** Bit definition for USART_GTPR register ******************/
#define USART_GTPR_PSC 0x00FFU /*!< PSC[7:0] bits (Prescaler value) */
#define USART_GTPR_GT 0xFF00U /*!< GT[7:0] bits (Guard time value) */
/******************* Bit definition for USART_RTOR register *****************/
#define USART_RTOR_RTO 0x00FFFFFFU /*!< Receiver Time Out Value */
#define USART_RTOR_BLEN 0xFF000000U /*!< Block Length */
/******************* Bit definition for USART_RQR register ******************/
#define USART_RQR_ABRRQ 0x0001U /*!< Auto-Baud Rate Request */
#define USART_RQR_SBKRQ 0x0002U /*!< Send Break Request */
#define USART_RQR_MMRQ 0x0004U /*!< Mute Mode Request */
#define USART_RQR_RXFRQ 0x0008U /*!< Receive Data flush Request */
#define USART_RQR_TXFRQ 0x0010U /*!< Transmit data flush Request */
/******************* Bit definition for USART_ISR register ******************/
#define USART_ISR_PE 0x00000001U /*!< Parity Error */
#define USART_ISR_FE 0x00000002U /*!< Framing Error */
#define USART_ISR_NE 0x00000004U /*!< Noise detected Flag */
#define USART_ISR_ORE 0x00000008U /*!< OverRun Error */
#define USART_ISR_IDLE 0x00000010U /*!< IDLE line detected */
#define USART_ISR_RXNE 0x00000020U /*!< Read Data Register Not Empty */
#define USART_ISR_TC 0x00000040U /*!< Transmission Complete */
#define USART_ISR_TXE 0x00000080U /*!< Transmit Data Register Empty */
#define USART_ISR_LBDF 0x00000100U /*!< LIN Break Detection Flag */
#define USART_ISR_CTSIF 0x00000200U /*!< CTS interrupt flag */
#define USART_ISR_CTS 0x00000400U /*!< CTS flag */
#define USART_ISR_RTOF 0x00000800U /*!< Receiver Time Out */
#define USART_ISR_EOBF 0x00001000U /*!< End Of Block Flag */
#define USART_ISR_ABRE 0x00004000U /*!< Auto-Baud Rate Error */
#define USART_ISR_ABRF 0x00008000U /*!< Auto-Baud Rate Flag */
#define USART_ISR_BUSY 0x00010000U /*!< Busy Flag */
#define USART_ISR_CMF 0x00020000U /*!< Character Match Flag */
#define USART_ISR_SBKF 0x00040000U /*!< Send Break Flag */
#define USART_ISR_RWU 0x00080000U /*!< Receive Wake Up from mute mode Flag */
#define USART_ISR_WUF 0x00100000U /*!< Wake Up from stop mode Flag */
#define USART_ISR_TEACK 0x00200000U /*!< Transmit Enable Acknowledge Flag */
#define USART_ISR_REACK 0x00400000U /*!< Receive Enable Acknowledge Flag */
/******************* Bit definition for USART_ICR register ******************/
#define USART_ICR_PECF 0x00000001U /*!< Parity Error Clear Flag */
#define USART_ICR_FECF 0x00000002U /*!< Framing Error Clear Flag */
#define USART_ICR_NCF 0x00000004U /*!< Noise detected Clear Flag */
#define USART_ICR_ORECF 0x00000008U /*!< OverRun Error Clear Flag */
#define USART_ICR_IDLECF 0x00000010U /*!< IDLE line detected Clear Flag */
#define USART_ICR_TCCF 0x00000040U /*!< Transmission Complete Clear Flag */
#define USART_ICR_LBDCF 0x00000100U /*!< LIN Break Detection Clear Flag */
#define USART_ICR_CTSCF 0x00000200U /*!< CTS Interrupt Clear Flag */
#define USART_ICR_RTOCF 0x00000800U /*!< Receiver Time Out Clear Flag */
#define USART_ICR_EOBCF 0x00001000U /*!< End Of Block Clear Flag */
#define USART_ICR_CMCF 0x00020000U /*!< Character Match Clear Flag */
#define USART_ICR_WUCF 0x00100000U /*!< Wake Up from stop mode Clear Flag */
/******************* Bit definition for USART_RDR register ******************/
#define USART_RDR_RDR 0x01FFU /*!< RDR[8:0] bits (Receive Data value) */
/******************* Bit definition for USART_TDR register ******************/
#define USART_TDR_TDR 0x01FFU /*!< TDR[8:0] bits (Transmit Data value) */
/******************************************************************************/
/* */
/* Window WATCHDOG */
/* */
/******************************************************************************/
/******************* Bit definition for WWDG_CR register ********************/
#define WWDG_CR_T 0x7FU /*!<T[6:0] bits (7-Bit counter (MSB to LSB)) */
#define WWDG_CR_T_0 0x01U /*!<Bit 0 */
#define WWDG_CR_T_1 0x02U /*!<Bit 1 */
#define WWDG_CR_T_2 0x04U /*!<Bit 2 */
#define WWDG_CR_T_3 0x08U /*!<Bit 3 */
#define WWDG_CR_T_4 0x10U /*!<Bit 4 */
#define WWDG_CR_T_5 0x20U /*!<Bit 5 */
#define WWDG_CR_T_6 0x40U /*!<Bit 6 */
#define WWDG_CR_WDGA 0x80U /*!<Activation bit */
/******************* Bit definition for WWDG_CFR register *******************/
#define WWDG_CFR_W 0x007FU /*!<W[6:0] bits (7-bit window value) */
#define WWDG_CFR_W_0 0x0001U /*!<Bit 0 */
#define WWDG_CFR_W_1 0x0002U /*!<Bit 1 */
#define WWDG_CFR_W_2 0x0004U /*!<Bit 2 */
#define WWDG_CFR_W_3 0x0008U /*!<Bit 3 */
#define WWDG_CFR_W_4 0x0010U /*!<Bit 4 */
#define WWDG_CFR_W_5 0x0020U /*!<Bit 5 */
#define WWDG_CFR_W_6 0x0040U /*!<Bit 6 */
#define WWDG_CFR_WDGTB 0x0180U /*!<WDGTB[1:0] bits (Timer Base) */
#define WWDG_CFR_WDGTB_0 0x0080U /*!<Bit 0 */
#define WWDG_CFR_WDGTB_1 0x0100U /*!<Bit 1 */
#define WWDG_CFR_EWI 0x0200U /*!<Early Wakeup Interrupt */
/******************* Bit definition for WWDG_SR register ********************/
#define WWDG_SR_EWIF 0x01U /*!<Early Wakeup Interrupt Flag */
/******************************************************************************/
/* */
/* DBG */
/* */
/******************************************************************************/
/******************** Bit definition for DBGMCU_IDCODE register *************/
#define DBGMCU_IDCODE_DEV_ID 0x00000FFFU
#define DBGMCU_IDCODE_REV_ID 0xFFFF0000U
/******************** Bit definition for DBGMCU_CR register *****************/
#define DBGMCU_CR_DBG_SLEEP 0x00000001U
#define DBGMCU_CR_DBG_STOP 0x00000002U
#define DBGMCU_CR_DBG_STANDBY 0x00000004U
#define DBGMCU_CR_TRACE_IOEN 0x00000020U
#define DBGMCU_CR_TRACE_MODE 0x000000C0U
#define DBGMCU_CR_TRACE_MODE_0 0x00000040U /*!<Bit 0 */
#define DBGMCU_CR_TRACE_MODE_1 0x00000080U /*!<Bit 1 */
/******************** Bit definition for DBGMCU_APB1_FZ register ************/
#define DBGMCU_APB1_FZ_DBG_TIM2_STOP 0x00000001U
#define DBGMCU_APB1_FZ_DBG_TIM3_STOP 0x00000002U
#define DBGMCU_APB1_FZ_DBG_TIM4_STOP 0x00000004U
#define DBGMCU_APB1_FZ_DBG_TIM5_STOP 0x00000008U
#define DBGMCU_APB1_FZ_DBG_TIM6_STOP 0x00000010U
#define DBGMCU_APB1_FZ_DBG_TIM7_STOP 0x00000020U
#define DBGMCU_APB1_FZ_DBG_TIM12_STOP 0x00000040U
#define DBGMCU_APB1_FZ_DBG_TIM13_STOP 0x00000080U
#define DBGMCU_APB1_FZ_DBG_TIM14_STOP 0x00000100U
#define DBGMCU_APB1_FZ_DBG_RTC_STOP 0x00000400U
#define DBGMCU_APB1_FZ_DBG_WWDG_STOP 0x00000800U
#define DBGMCU_APB1_FZ_DBG_IWDG_STOP 0x00001000U
#define DBGMCU_APB1_FZ_DBG_CAN3_STOP 0x00002000U
#define DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT 0x00200000U
#define DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT 0x00400000U
#define DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT 0x00800000U
#define DBGMCU_APB1_FZ_DBG_CAN1_STOP 0x02000000U
#define DBGMCU_APB1_FZ_DBG_CAN2_STOP 0x04000000U
/******************** Bit definition for DBGMCU_APB2_FZ register ************/
#define DBGMCU_APB2_FZ_DBG_TIM1_STOP 0x00000001U
#define DBGMCU_APB2_FZ_DBG_TIM8_STOP 0x00000002U
#define DBGMCU_APB2_FZ_DBG_TIM9_STOP 0x00010000U
#define DBGMCU_APB2_FZ_DBG_TIM10_STOP 0x00020000U
#define DBGMCU_APB2_FZ_DBG_TIM11_STOP 0x00040000U
/******************************************************************************/
/* */
/* Ethernet MAC Registers bits definitions */
/* */
/******************************************************************************/
/* Bit definition for Ethernet MAC Control Register register */
#define ETH_MACCR_WD 0x00800000U /* Watchdog disable */
#define ETH_MACCR_JD 0x00400000U /* Jabber disable */
#define ETH_MACCR_IFG 0x000E0000U /* Inter-frame gap */
#define ETH_MACCR_IFG_96Bit 0x00000000U /* Minimum IFG between frames during transmission is 96Bit */
#define ETH_MACCR_IFG_88Bit 0x00020000U /* Minimum IFG between frames during transmission is 88Bit */
#define ETH_MACCR_IFG_80Bit 0x00040000U /* Minimum IFG between frames during transmission is 80Bit */
#define ETH_MACCR_IFG_72Bit 0x00060000U /* Minimum IFG between frames during transmission is 72Bit */
#define ETH_MACCR_IFG_64Bit 0x00080000U /* Minimum IFG between frames during transmission is 64Bit */
#define ETH_MACCR_IFG_56Bit 0x000A0000U /* Minimum IFG between frames during transmission is 56Bit */
#define ETH_MACCR_IFG_48Bit 0x000C0000U /* Minimum IFG between frames during transmission is 48Bit */
#define ETH_MACCR_IFG_40Bit 0x000E0000U /* Minimum IFG between frames during transmission is 40Bit */
#define ETH_MACCR_CSD 0x00010000U /* Carrier sense disable (during transmission) */
#define ETH_MACCR_FES 0x00004000U /* Fast ethernet speed */
#define ETH_MACCR_ROD 0x00002000U /* Receive own disable */
#define ETH_MACCR_LM 0x00001000U /* loopback mode */
#define ETH_MACCR_DM 0x00000800U /* Duplex mode */
#define ETH_MACCR_IPCO 0x00000400U /* IP Checksum offload */
#define ETH_MACCR_RD 0x00000200U /* Retry disable */
#define ETH_MACCR_APCS 0x00000080U /* Automatic Pad/CRC stripping */
#define ETH_MACCR_BL 0x00000060U /* Back-off limit: random integer number (r) of slot time delays before rescheduling
a transmission attempt during retries after a collision: 0 =< r <2^k */
#define ETH_MACCR_BL_10 0x00000000U /* k = min (n, 10) */
#define ETH_MACCR_BL_8 0x00000020U /* k = min (n, 8) */
#define ETH_MACCR_BL_4 0x00000040U /* k = min (n, 4) */
#define ETH_MACCR_BL_1 0x00000060U /* k = min (n, 1) */
#define ETH_MACCR_DC 0x00000010U /* Defferal check */
#define ETH_MACCR_TE 0x00000008U /* Transmitter enable */
#define ETH_MACCR_RE 0x00000004U /* Receiver enable */
/* Bit definition for Ethernet MAC Frame Filter Register */
#define ETH_MACFFR_RA 0x80000000U /* Receive all */
#define ETH_MACFFR_HPF 0x00000400U /* Hash or perfect filter */
#define ETH_MACFFR_SAF 0x00000200U /* Source address filter enable */
#define ETH_MACFFR_SAIF 0x00000100U /* SA inverse filtering */
#define ETH_MACFFR_PCF 0x000000C0U /* Pass control frames: 3 cases */
#define ETH_MACFFR_PCF_BlockAll 0x00000040U /* MAC filters all control frames from reaching the application */
#define ETH_MACFFR_PCF_ForwardAll 0x00000080U /* MAC forwards all control frames to application even if they fail the Address Filter */
#define ETH_MACFFR_PCF_ForwardPassedAddrFilter 0x000000C0U /* MAC forwards control frames that pass the Address Filter. */
#define ETH_MACFFR_BFD 0x00000020U /* Broadcast frame disable */
#define ETH_MACFFR_PAM 0x00000010U /* Pass all mutlicast */
#define ETH_MACFFR_DAIF 0x00000008U /* DA Inverse filtering */
#define ETH_MACFFR_HM 0x00000004U /* Hash multicast */
#define ETH_MACFFR_HU 0x00000002U /* Hash unicast */
#define ETH_MACFFR_PM 0x00000001U /* Promiscuous mode */
/* Bit definition for Ethernet MAC Hash Table High Register */
#define ETH_MACHTHR_HTH 0xFFFFFFFFU /* Hash table high */
/* Bit definition for Ethernet MAC Hash Table Low Register */
#define ETH_MACHTLR_HTL 0xFFFFFFFFU /* Hash table low */
/* Bit definition for Ethernet MAC MII Address Register */
#define ETH_MACMIIAR_PA 0x0000F800U /* Physical layer address */
#define ETH_MACMIIAR_MR 0x000007C0U /* MII register in the selected PHY */
#define ETH_MACMIIAR_CR 0x0000001CU /* CR clock range: 6 cases */
#define ETH_MACMIIAR_CR_Div42 0x00000000U /* HCLK:60-100 MHz; MDC clock= HCLK/42 */
#define ETH_MACMIIAR_CR_Div62 0x00000004U /* HCLK:100-150 MHz; MDC clock= HCLK/62 */
#define ETH_MACMIIAR_CR_Div16 0x00000008U /* HCLK:20-35 MHz; MDC clock= HCLK/16 */
#define ETH_MACMIIAR_CR_Div26 0x0000000CU /* HCLK:35-60 MHz; MDC clock= HCLK/26 */
#define ETH_MACMIIAR_CR_Div102 0x00000010U /* HCLK:150-168 MHz; MDC clock= HCLK/102 */
#define ETH_MACMIIAR_MW 0x00000002U /* MII write */
#define ETH_MACMIIAR_MB 0x00000001U /* MII busy */
/* Bit definition for Ethernet MAC MII Data Register */
#define ETH_MACMIIDR_MD 0x0000FFFFU /* MII data: read/write data from/to PHY */
/* Bit definition for Ethernet MAC Flow Control Register */
#define ETH_MACFCR_PT 0xFFFF0000U /* Pause time */
#define ETH_MACFCR_ZQPD 0x00000080U /* Zero-quanta pause disable */
#define ETH_MACFCR_PLT 0x00000030U /* Pause low threshold: 4 cases */
#define ETH_MACFCR_PLT_Minus4 0x00000000U /* Pause time minus 4 slot times */
#define ETH_MACFCR_PLT_Minus28 0x00000010U /* Pause time minus 28 slot times */
#define ETH_MACFCR_PLT_Minus144 0x00000020U /* Pause time minus 144 slot times */
#define ETH_MACFCR_PLT_Minus256 0x00000030U /* Pause time minus 256 slot times */
#define ETH_MACFCR_UPFD 0x00000008U /* Unicast pause frame detect */
#define ETH_MACFCR_RFCE 0x00000004U /* Receive flow control enable */
#define ETH_MACFCR_TFCE 0x00000002U /* Transmit flow control enable */
#define ETH_MACFCR_FCBBPA 0x00000001U /* Flow control busy/backpressure activate */
/* Bit definition for Ethernet MAC VLAN Tag Register */
#define ETH_MACVLANTR_VLANTC 0x00010000U /* 12-bit VLAN tag comparison */
#define ETH_MACVLANTR_VLANTI 0x0000FFFFU /* VLAN tag identifier (for receive frames) */
/* Bit definition for Ethernet MAC Remote Wake-UpFrame Filter Register */
#define ETH_MACRWUFFR_D 0xFFFFFFFFU /* Wake-up frame filter register data */
/* Eight sequential Writes to this address (offset 0x28) will write all Wake-UpFrame Filter Registers.
Eight sequential Reads from this address (offset 0x28) will read all Wake-UpFrame Filter Registers. */
/* Wake-UpFrame Filter Reg0 : Filter 0 Byte Mask
Wake-UpFrame Filter Reg1 : Filter 1 Byte Mask
Wake-UpFrame Filter Reg2 : Filter 2 Byte Mask
Wake-UpFrame Filter Reg3 : Filter 3 Byte Mask
Wake-UpFrame Filter Reg4 : RSVD - Filter3 Command - RSVD - Filter2 Command -
RSVD - Filter1 Command - RSVD - Filter0 Command
Wake-UpFrame Filter Re5 : Filter3 Offset - Filter2 Offset - Filter1 Offset - Filter0 Offset
Wake-UpFrame Filter Re6 : Filter1 CRC16 - Filter0 CRC16
Wake-UpFrame Filter Re7 : Filter3 CRC16 - Filter2 CRC16 */
/* Bit definition for Ethernet MAC PMT Control and Status Register */
#define ETH_MACPMTCSR_WFFRPR 0x80000000U /* Wake-Up Frame Filter Register Pointer Reset */
#define ETH_MACPMTCSR_GU 0x00000200U /* Global Unicast */
#define ETH_MACPMTCSR_WFR 0x00000040U /* Wake-Up Frame Received */
#define ETH_MACPMTCSR_MPR 0x00000020U /* Magic Packet Received */
#define ETH_MACPMTCSR_WFE 0x00000004U /* Wake-Up Frame Enable */
#define ETH_MACPMTCSR_MPE 0x00000002U /* Magic Packet Enable */
#define ETH_MACPMTCSR_PD 0x00000001U /* Power Down */
/* Bit definition for Ethernet MAC Status Register */
#define ETH_MACSR_TSTS 0x00000200U /* Time stamp trigger status */
#define ETH_MACSR_MMCTS 0x00000040U /* MMC transmit status */
#define ETH_MACSR_MMMCRS 0x00000020U /* MMC receive status */
#define ETH_MACSR_MMCS 0x00000010U /* MMC status */
#define ETH_MACSR_PMTS 0x00000008U /* PMT status */
/* Bit definition for Ethernet MAC Interrupt Mask Register */
#define ETH_MACIMR_TSTIM 0x00000200U /* Time stamp trigger interrupt mask */
#define ETH_MACIMR_PMTIM 0x00000008U /* PMT interrupt mask */
/* Bit definition for Ethernet MAC Address0 High Register */
#define ETH_MACA0HR_MACA0H 0x0000FFFFU /* MAC address0 high */
/* Bit definition for Ethernet MAC Address0 Low Register */
#define ETH_MACA0LR_MACA0L 0xFFFFFFFFU /* MAC address0 low */
/* Bit definition for Ethernet MAC Address1 High Register */
#define ETH_MACA1HR_AE 0x80000000U /* Address enable */
#define ETH_MACA1HR_SA 0x40000000U /* Source address */
#define ETH_MACA1HR_MBC 0x3F000000U /* Mask byte control: bits to mask for comparison of the MAC Address bytes */
#define ETH_MACA1HR_MBC_HBits15_8 0x20000000U /* Mask MAC Address high reg bits [15:8] */
#define ETH_MACA1HR_MBC_HBits7_0 0x10000000U /* Mask MAC Address high reg bits [7:0] */
#define ETH_MACA1HR_MBC_LBits31_24 0x08000000U /* Mask MAC Address low reg bits [31:24] */
#define ETH_MACA1HR_MBC_LBits23_16 0x04000000U /* Mask MAC Address low reg bits [23:16] */
#define ETH_MACA1HR_MBC_LBits15_8 0x02000000U /* Mask MAC Address low reg bits [15:8] */
#define ETH_MACA1HR_MBC_LBits7_0 0x01000000U /* Mask MAC Address low reg bits [7:0] */
#define ETH_MACA1HR_MACA1H 0x0000FFFFU /* MAC address1 high */
/* Bit definition for Ethernet MAC Address1 Low Register */
#define ETH_MACA1LR_MACA1L 0xFFFFFFFFU /* MAC address1 low */
/* Bit definition for Ethernet MAC Address2 High Register */
#define ETH_MACA2HR_AE 0x80000000U /* Address enable */
#define ETH_MACA2HR_SA 0x40000000U /* Source address */
#define ETH_MACA2HR_MBC 0x3F000000U /* Mask byte control */
#define ETH_MACA2HR_MBC_HBits15_8 0x20000000U /* Mask MAC Address high reg bits [15:8] */
#define ETH_MACA2HR_MBC_HBits7_0 0x10000000U /* Mask MAC Address high reg bits [7:0] */
#define ETH_MACA2HR_MBC_LBits31_24 0x08000000U /* Mask MAC Address low reg bits [31:24] */
#define ETH_MACA2HR_MBC_LBits23_16 0x04000000U /* Mask MAC Address low reg bits [23:16] */
#define ETH_MACA2HR_MBC_LBits15_8 0x02000000U /* Mask MAC Address low reg bits [15:8] */
#define ETH_MACA2HR_MBC_LBits7_0 0x01000000U /* Mask MAC Address low reg bits [70] */
#define ETH_MACA2HR_MACA2H 0x0000FFFFU /* MAC address1 high */
/* Bit definition for Ethernet MAC Address2 Low Register */
#define ETH_MACA2LR_MACA2L 0xFFFFFFFFU /* MAC address2 low */
/* Bit definition for Ethernet MAC Address3 High Register */
#define ETH_MACA3HR_AE 0x80000000U /* Address enable */
#define ETH_MACA3HR_SA 0x40000000U /* Source address */
#define ETH_MACA3HR_MBC 0x3F000000U /* Mask byte control */
#define ETH_MACA3HR_MBC_HBits15_8 0x20000000U /* Mask MAC Address high reg bits [15:8] */
#define ETH_MACA3HR_MBC_HBits7_0 0x10000000U /* Mask MAC Address high reg bits [7:0] */
#define ETH_MACA3HR_MBC_LBits31_24 0x08000000U /* Mask MAC Address low reg bits [31:24] */
#define ETH_MACA3HR_MBC_LBits23_16 0x04000000U /* Mask MAC Address low reg bits [23:16] */
#define ETH_MACA3HR_MBC_LBits15_8 0x02000000U /* Mask MAC Address low reg bits [15:8] */
#define ETH_MACA3HR_MBC_LBits7_0 0x01000000U /* Mask MAC Address low reg bits [70] */
#define ETH_MACA3HR_MACA3H 0x0000FFFFU /* MAC address3 high */
/* Bit definition for Ethernet MAC Address3 Low Register */
#define ETH_MACA3LR_MACA3L 0xFFFFFFFFU /* MAC address3 low */
/******************************************************************************/
/* Ethernet MMC Registers bits definition */
/******************************************************************************/
/* Bit definition for Ethernet MMC Contol Register */
#define ETH_MMCCR_MCFHP 0x00000020U /* MMC counter Full-Half preset */
#define ETH_MMCCR_MCP 0x00000010U /* MMC counter preset */
#define ETH_MMCCR_MCF 0x00000008U /* MMC Counter Freeze */
#define ETH_MMCCR_ROR 0x00000004U /* Reset on Read */
#define ETH_MMCCR_CSR 0x00000002U /* Counter Stop Rollover */
#define ETH_MMCCR_CR 0x00000001U /* Counters Reset */
/* Bit definition for Ethernet MMC Receive Interrupt Register */
#define ETH_MMCRIR_RGUFS 0x00020000U /* Set when Rx good unicast frames counter reaches half the maximum value */
#define ETH_MMCRIR_RFAES 0x00000040U /* Set when Rx alignment error counter reaches half the maximum value */
#define ETH_MMCRIR_RFCES 0x00000020U /* Set when Rx crc error counter reaches half the maximum value */
/* Bit definition for Ethernet MMC Transmit Interrupt Register */
#define ETH_MMCTIR_TGFS 0x00200000U /* Set when Tx good frame count counter reaches half the maximum value */
#define ETH_MMCTIR_TGFMSCS 0x00008000U /* Set when Tx good multi col counter reaches half the maximum value */
#define ETH_MMCTIR_TGFSCS 0x00004000U /* Set when Tx good single col counter reaches half the maximum value */
/* Bit definition for Ethernet MMC Receive Interrupt Mask Register */
#define ETH_MMCRIMR_RGUFM 0x00020000U /* Mask the interrupt when Rx good unicast frames counter reaches half the maximum value */
#define ETH_MMCRIMR_RFAEM 0x00000040U /* Mask the interrupt when when Rx alignment error counter reaches half the maximum value */
#define ETH_MMCRIMR_RFCEM 0x00000020U /* Mask the interrupt when Rx crc error counter reaches half the maximum value */
/* Bit definition for Ethernet MMC Transmit Interrupt Mask Register */
#define ETH_MMCTIMR_TGFM 0x00200000U /* Mask the interrupt when Tx good frame count counter reaches half the maximum value */
#define ETH_MMCTIMR_TGFMSCM 0x00008000U /* Mask the interrupt when Tx good multi col counter reaches half the maximum value */
#define ETH_MMCTIMR_TGFSCM 0x00004000U /* Mask the interrupt when Tx good single col counter reaches half the maximum value */
/* Bit definition for Ethernet MMC Transmitted Good Frames after Single Collision Counter Register */
#define ETH_MMCTGFSCCR_TGFSCC 0xFFFFFFFFU /* Number of successfully transmitted frames after a single collision in Half-duplex mode. */
/* Bit definition for Ethernet MMC Transmitted Good Frames after More than a Single Collision Counter Register */
#define ETH_MMCTGFMSCCR_TGFMSCC 0xFFFFFFFFU /* Number of successfully transmitted frames after more than a single collision in Half-duplex mode. */
/* Bit definition for Ethernet MMC Transmitted Good Frames Counter Register */
#define ETH_MMCTGFCR_TGFC 0xFFFFFFFFU /* Number of good frames transmitted. */
/* Bit definition for Ethernet MMC Received Frames with CRC Error Counter Register */
#define ETH_MMCRFCECR_RFCEC 0xFFFFFFFFU /* Number of frames received with CRC error. */
/* Bit definition for Ethernet MMC Received Frames with Alignement Error Counter Register */
#define ETH_MMCRFAECR_RFAEC 0xFFFFFFFFU /* Number of frames received with alignment (dribble) error */
/* Bit definition for Ethernet MMC Received Good Unicast Frames Counter Register */
#define ETH_MMCRGUFCR_RGUFC 0xFFFFFFFFU /* Number of good unicast frames received. */
/******************************************************************************/
/* Ethernet PTP Registers bits definition */
/******************************************************************************/
/* Bit definition for Ethernet PTP Time Stamp Contol Register */
#define ETH_PTPTSCR_TSCNT 0x00030000U /* Time stamp clock node type */
#define ETH_PTPTSSR_TSSMRME 0x00008000U /* Time stamp snapshot for message relevant to master enable */
#define ETH_PTPTSSR_TSSEME 0x00004000U /* Time stamp snapshot for event message enable */
#define ETH_PTPTSSR_TSSIPV4FE 0x00002000U /* Time stamp snapshot for IPv4 frames enable */
#define ETH_PTPTSSR_TSSIPV6FE 0x00001000U /* Time stamp snapshot for IPv6 frames enable */
#define ETH_PTPTSSR_TSSPTPOEFE 0x00000800U /* Time stamp snapshot for PTP over ethernet frames enable */
#define ETH_PTPTSSR_TSPTPPSV2E 0x00000400U /* Time stamp PTP packet snooping for version2 format enable */
#define ETH_PTPTSSR_TSSSR 0x00000200U /* Time stamp Sub-seconds rollover */
#define ETH_PTPTSSR_TSSARFE 0x00000100U /* Time stamp snapshot for all received frames enable */
#define ETH_PTPTSCR_TSARU 0x00000020U /* Addend register update */
#define ETH_PTPTSCR_TSITE 0x00000010U /* Time stamp interrupt trigger enable */
#define ETH_PTPTSCR_TSSTU 0x00000008U /* Time stamp update */
#define ETH_PTPTSCR_TSSTI 0x00000004U /* Time stamp initialize */
#define ETH_PTPTSCR_TSFCU 0x00000002U /* Time stamp fine or coarse update */
#define ETH_PTPTSCR_TSE 0x00000001U /* Time stamp enable */
/* Bit definition for Ethernet PTP Sub-Second Increment Register */
#define ETH_PTPSSIR_STSSI 0x000000FFU /* System time Sub-second increment value */
/* Bit definition for Ethernet PTP Time Stamp High Register */
#define ETH_PTPTSHR_STS 0xFFFFFFFFU /* System Time second */
/* Bit definition for Ethernet PTP Time Stamp Low Register */
#define ETH_PTPTSLR_STPNS 0x80000000U /* System Time Positive or negative time */
#define ETH_PTPTSLR_STSS 0x7FFFFFFFU /* System Time sub-seconds */
/* Bit definition for Ethernet PTP Time Stamp High Update Register */
#define ETH_PTPTSHUR_TSUS 0xFFFFFFFFU /* Time stamp update seconds */
/* Bit definition for Ethernet PTP Time Stamp Low Update Register */
#define ETH_PTPTSLUR_TSUPNS 0x80000000U /* Time stamp update Positive or negative time */
#define ETH_PTPTSLUR_TSUSS 0x7FFFFFFFU /* Time stamp update sub-seconds */
/* Bit definition for Ethernet PTP Time Stamp Addend Register */
#define ETH_PTPTSAR_TSA 0xFFFFFFFFU /* Time stamp addend */
/* Bit definition for Ethernet PTP Target Time High Register */
#define ETH_PTPTTHR_TTSH 0xFFFFFFFFU /* Target time stamp high */
/* Bit definition for Ethernet PTP Target Time Low Register */
#define ETH_PTPTTLR_TTSL 0xFFFFFFFFU /* Target time stamp low */
/* Bit definition for Ethernet PTP Time Stamp Status Register */
#define ETH_PTPTSSR_TSTTR 0x00000020U /* Time stamp target time reached */
#define ETH_PTPTSSR_TSSO 0x00000010U /* Time stamp seconds overflow */
/******************************************************************************/
/* Ethernet DMA Registers bits definition */
/******************************************************************************/
/* Bit definition for Ethernet DMA Bus Mode Register */
#define ETH_DMABMR_AAB 0x02000000U /* Address-Aligned beats */
#define ETH_DMABMR_FPM 0x01000000U /* 4xPBL mode */
#define ETH_DMABMR_USP 0x00800000U /* Use separate PBL */
#define ETH_DMABMR_RDP 0x007E0000U /* RxDMA PBL */
#define ETH_DMABMR_RDP_1Beat 0x00020000U /* maximum number of beats to be transferred in one RxDMA transaction is 1 */
#define ETH_DMABMR_RDP_2Beat 0x00040000U /* maximum number of beats to be transferred in one RxDMA transaction is 2 */
#define ETH_DMABMR_RDP_4Beat 0x00080000U /* maximum number of beats to be transferred in one RxDMA transaction is 4 */
#define ETH_DMABMR_RDP_8Beat 0x00100000U /* maximum number of beats to be transferred in one RxDMA transaction is 8 */
#define ETH_DMABMR_RDP_16Beat 0x00200000U /* maximum number of beats to be transferred in one RxDMA transaction is 16 */
#define ETH_DMABMR_RDP_32Beat 0x00400000U /* maximum number of beats to be transferred in one RxDMA transaction is 32 */
#define ETH_DMABMR_RDP_4xPBL_4Beat 0x01020000U /* maximum number of beats to be transferred in one RxDMA transaction is 4 */
#define ETH_DMABMR_RDP_4xPBL_8Beat 0x01040000U /* maximum number of beats to be transferred in one RxDMA transaction is 8 */
#define ETH_DMABMR_RDP_4xPBL_16Beat 0x01080000U /* maximum number of beats to be transferred in one RxDMA transaction is 16 */
#define ETH_DMABMR_RDP_4xPBL_32Beat 0x01100000U /* maximum number of beats to be transferred in one RxDMA transaction is 32 */
#define ETH_DMABMR_RDP_4xPBL_64Beat 0x01200000U /* maximum number of beats to be transferred in one RxDMA transaction is 64 */
#define ETH_DMABMR_RDP_4xPBL_128Beat 0x01400000U /* maximum number of beats to be transferred in one RxDMA transaction is 128 */
#define ETH_DMABMR_FB 0x00010000U /* Fixed Burst */
#define ETH_DMABMR_RTPR 0x0000C000U /* Rx Tx priority ratio */
#define ETH_DMABMR_RTPR_1_1 0x00000000U /* Rx Tx priority ratio */
#define ETH_DMABMR_RTPR_2_1 0x00004000U /* Rx Tx priority ratio */
#define ETH_DMABMR_RTPR_3_1 0x00008000U /* Rx Tx priority ratio */
#define ETH_DMABMR_RTPR_4_1 0x0000C000U /* Rx Tx priority ratio */
#define ETH_DMABMR_PBL 0x00003F00U /* Programmable burst length */
#define ETH_DMABMR_PBL_1Beat 0x00000100U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */
#define ETH_DMABMR_PBL_2Beat 0x00000200U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */
#define ETH_DMABMR_PBL_4Beat 0x00000400U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
#define ETH_DMABMR_PBL_8Beat 0x00000800U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
#define ETH_DMABMR_PBL_16Beat 0x00001000U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
#define ETH_DMABMR_PBL_32Beat 0x00002000U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */
#define ETH_DMABMR_PBL_4xPBL_4Beat 0x01000100U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
#define ETH_DMABMR_PBL_4xPBL_8Beat 0x01000200U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
#define ETH_DMABMR_PBL_4xPBL_16Beat 0x01000400U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
#define ETH_DMABMR_PBL_4xPBL_32Beat 0x01000800U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */
#define ETH_DMABMR_PBL_4xPBL_64Beat 0x01001000U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */
#define ETH_DMABMR_PBL_4xPBL_128Beat 0x01002000U /* maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */
#define ETH_DMABMR_EDE 0x00000080U /* Enhanced Descriptor Enable */
#define ETH_DMABMR_DSL 0x0000007CU /* Descriptor Skip Length */
#define ETH_DMABMR_DA 0x00000002U /* DMA arbitration scheme */
#define ETH_DMABMR_SR 0x00000001U /* Software reset */
/* Bit definition for Ethernet DMA Transmit Poll Demand Register */
#define ETH_DMATPDR_TPD 0xFFFFFFFFU /* Transmit poll demand */
/* Bit definition for Ethernet DMA Receive Poll Demand Register */
#define ETH_DMARPDR_RPD 0xFFFFFFFFU /* Receive poll demand */
/* Bit definition for Ethernet DMA Receive Descriptor List Address Register */
#define ETH_DMARDLAR_SRL 0xFFFFFFFFU /* Start of receive list */
/* Bit definition for Ethernet DMA Transmit Descriptor List Address Register */
#define ETH_DMATDLAR_STL 0xFFFFFFFFU /* Start of transmit list */
/* Bit definition for Ethernet DMA Status Register */
#define ETH_DMASR_TSTS 0x20000000U /* Time-stamp trigger status */
#define ETH_DMASR_PMTS 0x10000000U /* PMT status */
#define ETH_DMASR_MMCS 0x08000000U /* MMC status */
#define ETH_DMASR_EBS 0x03800000U /* Error bits status */
/* combination with EBS[2:0] for GetFlagStatus function */
#define ETH_DMASR_EBS_DescAccess 0x02000000U /* Error bits 0-data buffer, 1-desc. access */
#define ETH_DMASR_EBS_ReadTransf 0x01000000U /* Error bits 0-write trnsf, 1-read transfr */
#define ETH_DMASR_EBS_DataTransfTx 0x00800000U /* Error bits 0-Rx DMA, 1-Tx DMA */
#define ETH_DMASR_TPS 0x00700000U /* Transmit process state */
#define ETH_DMASR_TPS_Stopped 0x00000000U /* Stopped - Reset or Stop Tx Command issued */
#define ETH_DMASR_TPS_Fetching 0x00100000U /* Running - fetching the Tx descriptor */
#define ETH_DMASR_TPS_Waiting 0x00200000U /* Running - waiting for status */
#define ETH_DMASR_TPS_Reading 0x00300000U /* Running - reading the data from host memory */
#define ETH_DMASR_TPS_Suspended 0x00600000U /* Suspended - Tx Descriptor unavailabe */
#define ETH_DMASR_TPS_Closing 0x00700000U /* Running - closing Rx descriptor */
#define ETH_DMASR_RPS 0x000E0000U /* Receive process state */
#define ETH_DMASR_RPS_Stopped 0x00000000U /* Stopped - Reset or Stop Rx Command issued */
#define ETH_DMASR_RPS_Fetching 0x00020000U /* Running - fetching the Rx descriptor */
#define ETH_DMASR_RPS_Waiting 0x00060000U /* Running - waiting for packet */
#define ETH_DMASR_RPS_Suspended 0x00080000U /* Suspended - Rx Descriptor unavailable */
#define ETH_DMASR_RPS_Closing 0x000A0000U /* Running - closing descriptor */
#define ETH_DMASR_RPS_Queuing 0x000E0000U /* Running - queuing the recieve frame into host memory */
#define ETH_DMASR_NIS 0x00010000U /* Normal interrupt summary */
#define ETH_DMASR_AIS 0x00008000U /* Abnormal interrupt summary */
#define ETH_DMASR_ERS 0x00004000U /* Early receive status */
#define ETH_DMASR_FBES 0x00002000U /* Fatal bus error status */
#define ETH_DMASR_ETS 0x00000400U /* Early transmit status */
#define ETH_DMASR_RWTS 0x00000200U /* Receive watchdog timeout status */
#define ETH_DMASR_RPSS 0x00000100U /* Receive process stopped status */
#define ETH_DMASR_RBUS 0x00000080U /* Receive buffer unavailable status */
#define ETH_DMASR_RS 0x00000040U /* Receive status */
#define ETH_DMASR_TUS 0x00000020U /* Transmit underflow status */
#define ETH_DMASR_ROS 0x00000010U /* Receive overflow status */
#define ETH_DMASR_TJTS 0x00000008U /* Transmit jabber timeout status */
#define ETH_DMASR_TBUS 0x00000004U /* Transmit buffer unavailable status */
#define ETH_DMASR_TPSS 0x00000002U /* Transmit process stopped status */
#define ETH_DMASR_TS 0x00000001U /* Transmit status */
/* Bit definition for Ethernet DMA Operation Mode Register */
#define ETH_DMAOMR_DTCEFD 0x04000000U /* Disable Dropping of TCP/IP checksum error frames */
#define ETH_DMAOMR_RSF 0x02000000U /* Receive store and forward */
#define ETH_DMAOMR_DFRF 0x01000000U /* Disable flushing of received frames */
#define ETH_DMAOMR_TSF 0x00200000U /* Transmit store and forward */
#define ETH_DMAOMR_FTF 0x00100000U /* Flush transmit FIFO */
#define ETH_DMAOMR_TTC 0x0001C000U /* Transmit threshold control */
#define ETH_DMAOMR_TTC_64Bytes 0x00000000U /* threshold level of the MTL Transmit FIFO is 64 Bytes */
#define ETH_DMAOMR_TTC_128Bytes 0x00004000U /* threshold level of the MTL Transmit FIFO is 128 Bytes */
#define ETH_DMAOMR_TTC_192Bytes 0x00008000U /* threshold level of the MTL Transmit FIFO is 192 Bytes */
#define ETH_DMAOMR_TTC_256Bytes 0x0000C000U /* threshold level of the MTL Transmit FIFO is 256 Bytes */
#define ETH_DMAOMR_TTC_40Bytes 0x00010000U /* threshold level of the MTL Transmit FIFO is 40 Bytes */
#define ETH_DMAOMR_TTC_32Bytes 0x00014000U /* threshold level of the MTL Transmit FIFO is 32 Bytes */
#define ETH_DMAOMR_TTC_24Bytes 0x00018000U /* threshold level of the MTL Transmit FIFO is 24 Bytes */
#define ETH_DMAOMR_TTC_16Bytes 0x0001C000U /* threshold level of the MTL Transmit FIFO is 16 Bytes */
#define ETH_DMAOMR_ST 0x00002000U /* Start/stop transmission command */
#define ETH_DMAOMR_FEF 0x00000080U /* Forward error frames */
#define ETH_DMAOMR_FUGF 0x00000040U /* Forward undersized good frames */
#define ETH_DMAOMR_RTC 0x00000018U /* receive threshold control */
#define ETH_DMAOMR_RTC_64Bytes 0x00000000U /* threshold level of the MTL Receive FIFO is 64 Bytes */
#define ETH_DMAOMR_RTC_32Bytes 0x00000008U /* threshold level of the MTL Receive FIFO is 32 Bytes */
#define ETH_DMAOMR_RTC_96Bytes 0x00000010U /* threshold level of the MTL Receive FIFO is 96 Bytes */
#define ETH_DMAOMR_RTC_128Bytes 0x00000018U /* threshold level of the MTL Receive FIFO is 128 Bytes */
#define ETH_DMAOMR_OSF 0x00000004U /* operate on second frame */
#define ETH_DMAOMR_SR 0x00000002U /* Start/stop receive */
/* Bit definition for Ethernet DMA Interrupt Enable Register */
#define ETH_DMAIER_NISE 0x00010000U /* Normal interrupt summary enable */
#define ETH_DMAIER_AISE 0x00008000U /* Abnormal interrupt summary enable */
#define ETH_DMAIER_ERIE 0x00004000U /* Early receive interrupt enable */
#define ETH_DMAIER_FBEIE 0x00002000U /* Fatal bus error interrupt enable */
#define ETH_DMAIER_ETIE 0x00000400U /* Early transmit interrupt enable */
#define ETH_DMAIER_RWTIE 0x00000200U /* Receive watchdog timeout interrupt enable */
#define ETH_DMAIER_RPSIE 0x00000100U /* Receive process stopped interrupt enable */
#define ETH_DMAIER_RBUIE 0x00000080U /* Receive buffer unavailable interrupt enable */
#define ETH_DMAIER_RIE 0x00000040U /* Receive interrupt enable */
#define ETH_DMAIER_TUIE 0x00000020U /* Transmit Underflow interrupt enable */
#define ETH_DMAIER_ROIE 0x00000010U /* Receive Overflow interrupt enable */
#define ETH_DMAIER_TJTIE 0x00000008U /* Transmit jabber timeout interrupt enable */
#define ETH_DMAIER_TBUIE 0x00000004U /* Transmit buffer unavailable interrupt enable */
#define ETH_DMAIER_TPSIE 0x00000002U /* Transmit process stopped interrupt enable */
#define ETH_DMAIER_TIE 0x00000001U /* Transmit interrupt enable */
/* Bit definition for Ethernet DMA Missed Frame and Buffer Overflow Counter Register */
#define ETH_DMAMFBOCR_OFOC 0x10000000U /* Overflow bit for FIFO overflow counter */
#define ETH_DMAMFBOCR_MFA 0x0FFE0000U /* Number of frames missed by the application */
#define ETH_DMAMFBOCR_OMFC 0x00010000U /* Overflow bit for missed frame counter */
#define ETH_DMAMFBOCR_MFC 0x0000FFFFU /* Number of frames missed by the controller */
/* Bit definition for Ethernet DMA Current Host Transmit Descriptor Register */
#define ETH_DMACHTDR_HTDAP 0xFFFFFFFFU /* Host transmit descriptor address pointer */
/* Bit definition for Ethernet DMA Current Host Receive Descriptor Register */
#define ETH_DMACHRDR_HRDAP 0xFFFFFFFFU /* Host receive descriptor address pointer */
/* Bit definition for Ethernet DMA Current Host Transmit Buffer Address Register */
#define ETH_DMACHTBAR_HTBAP 0xFFFFFFFFU /* Host transmit buffer address pointer */
/* Bit definition for Ethernet DMA Current Host Receive Buffer Address Register */
#define ETH_DMACHRBAR_HRBAP 0xFFFFFFFFU /* Host receive buffer address pointer */
/******************************************************************************/
/* */
/* USB_OTG */
/* */
/******************************************************************************/
/******************** Bit definition for USB_OTG_GOTGCTL register ********************/
#define USB_OTG_GOTGCTL_SRQSCS 0x00000001U /*!< Session request success */
#define USB_OTG_GOTGCTL_SRQ 0x00000002U /*!< Session request */
#define USB_OTG_GOTGCTL_VBVALOEN 0x00000004U /*!< VBUS valid override enable */
#define USB_OTG_GOTGCTL_VBVALOVAL 0x00000008U /*!< VBUS valid override value */
#define USB_OTG_GOTGCTL_AVALOEN 0x00000010U /*!< A-peripheral session valid override enable */
#define USB_OTG_GOTGCTL_AVALOVAL 0x00000020U /*!< A-peripheral session valid override value */
#define USB_OTG_GOTGCTL_BVALOEN 0x00000040U /*!< B-peripheral session valid override enable */
#define USB_OTG_GOTGCTL_BVALOVAL 0x00000080U /*!< B-peripheral session valid override value */
#define USB_OTG_GOTGCTL_HNGSCS 0x00000100U /*!< Host set HNP enable */
#define USB_OTG_GOTGCTL_HNPRQ 0x00000200U /*!< HNP request */
#define USB_OTG_GOTGCTL_HSHNPEN 0x00000400U /*!< Host set HNP enable */
#define USB_OTG_GOTGCTL_DHNPEN 0x00000800U /*!< Device HNP enabled */
#define USB_OTG_GOTGCTL_EHEN 0x00001000U /*!< Embedded host enable */
#define USB_OTG_GOTGCTL_CIDSTS 0x00010000U /*!< Connector ID status */
#define USB_OTG_GOTGCTL_DBCT 0x00020000U /*!< Long/short debounce time */
#define USB_OTG_GOTGCTL_ASVLD 0x00040000U /*!< A-session valid */
#define USB_OTG_GOTGCTL_BSESVLD 0x00080000U /*!< B-session valid */
#define USB_OTG_GOTGCTL_OTGVER 0x00100000U /*!< OTG version */
/******************** Bit definition for USB_OTG_HCFG register ********************/
#define USB_OTG_HCFG_FSLSPCS 0x00000003U /*!< FS/LS PHY clock select */
#define USB_OTG_HCFG_FSLSPCS_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_HCFG_FSLSPCS_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_HCFG_FSLSS 0x00000004U /*!< FS- and LS-only support */
/******************** Bit definition for USB_OTG_DCFG register ********************/
#define USB_OTG_DCFG_DSPD 0x00000003U /*!< Device speed */
#define USB_OTG_DCFG_DSPD_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_DCFG_DSPD_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_DCFG_NZLSOHSK 0x00000004U /*!< Nonzero-length status OUT handshake */
#define USB_OTG_DCFG_DAD 0x000007F0U /*!< Device address */
#define USB_OTG_DCFG_DAD_0 0x00000010U /*!<Bit 0 */
#define USB_OTG_DCFG_DAD_1 0x00000020U /*!<Bit 1 */
#define USB_OTG_DCFG_DAD_2 0x00000040U /*!<Bit 2 */
#define USB_OTG_DCFG_DAD_3 0x00000080U /*!<Bit 3 */
#define USB_OTG_DCFG_DAD_4 0x00000100U /*!<Bit 4 */
#define USB_OTG_DCFG_DAD_5 0x00000200U /*!<Bit 5 */
#define USB_OTG_DCFG_DAD_6 0x00000400U /*!<Bit 6 */
#define USB_OTG_DCFG_PFIVL 0x00001800U /*!< Periodic (micro)frame interval */
#define USB_OTG_DCFG_PFIVL_0 0x00000800U /*!<Bit 0 */
#define USB_OTG_DCFG_PFIVL_1 0x00001000U /*!<Bit 1 */
#define USB_OTG_DCFG_PERSCHIVL 0x03000000U /*!< Periodic scheduling interval */
#define USB_OTG_DCFG_PERSCHIVL_0 0x01000000U /*!<Bit 0 */
#define USB_OTG_DCFG_PERSCHIVL_1 0x02000000U /*!<Bit 1 */
/******************** Bit definition for USB_OTG_PCGCR register ********************/
#define USB_OTG_PCGCR_STPPCLK 0x00000001U /*!< Stop PHY clock */
#define USB_OTG_PCGCR_GATEHCLK 0x00000002U /*!< Gate HCLK */
#define USB_OTG_PCGCR_PHYSUSP 0x00000010U /*!< PHY suspended */
/******************** Bit definition for USB_OTG_GOTGINT register ********************/
#define USB_OTG_GOTGINT_SEDET 0x00000004U /*!< Session end detected */
#define USB_OTG_GOTGINT_SRSSCHG 0x00000100U /*!< Session request success status change */
#define USB_OTG_GOTGINT_HNSSCHG 0x00000200U /*!< Host negotiation success status change */
#define USB_OTG_GOTGINT_HNGDET 0x00020000U /*!< Host negotiation detected */
#define USB_OTG_GOTGINT_ADTOCHG 0x00040000U /*!< A-device timeout change */
#define USB_OTG_GOTGINT_DBCDNE 0x00080000U /*!< Debounce done */
#define USB_OTG_GOTGINT_IDCHNG 0x00100000U /*!< Change in ID pin input value */
/******************** Bit definition for USB_OTG_DCTL register ********************/
#define USB_OTG_DCTL_RWUSIG 0x00000001U /*!< Remote wakeup signaling */
#define USB_OTG_DCTL_SDIS 0x00000002U /*!< Soft disconnect */
#define USB_OTG_DCTL_GINSTS 0x00000004U /*!< Global IN NAK status */
#define USB_OTG_DCTL_GONSTS 0x00000008U /*!< Global OUT NAK status */
#define USB_OTG_DCTL_TCTL 0x00000070U /*!< Test control */
#define USB_OTG_DCTL_TCTL_0 0x00000010U /*!<Bit 0 */
#define USB_OTG_DCTL_TCTL_1 0x00000020U /*!<Bit 1 */
#define USB_OTG_DCTL_TCTL_2 0x00000040U /*!<Bit 2 */
#define USB_OTG_DCTL_SGINAK 0x00000080U /*!< Set global IN NAK */
#define USB_OTG_DCTL_CGINAK 0x00000100U /*!< Clear global IN NAK */
#define USB_OTG_DCTL_SGONAK 0x00000200U /*!< Set global OUT NAK */
#define USB_OTG_DCTL_CGONAK 0x00000400U /*!< Clear global OUT NAK */
#define USB_OTG_DCTL_POPRGDNE 0x00000800U /*!< Power-on programming done */
/******************** Bit definition for USB_OTG_HFIR register ********************/
#define USB_OTG_HFIR_FRIVL 0x0000FFFFU /*!< Frame interval */
/******************** Bit definition for USB_OTG_HFNUM register ********************/
#define USB_OTG_HFNUM_FRNUM 0x0000FFFFU /*!< Frame number */
#define USB_OTG_HFNUM_FTREM 0xFFFF0000U /*!< Frame time remaining */
/******************** Bit definition for USB_OTG_DSTS register ********************/
#define USB_OTG_DSTS_SUSPSTS 0x00000001U /*!< Suspend status */
#define USB_OTG_DSTS_ENUMSPD 0x00000006U /*!< Enumerated speed */
#define USB_OTG_DSTS_ENUMSPD_0 0x00000002U /*!<Bit 0 */
#define USB_OTG_DSTS_ENUMSPD_1 0x00000004U /*!<Bit 1 */
#define USB_OTG_DSTS_EERR 0x00000008U /*!< Erratic error */
#define USB_OTG_DSTS_FNSOF 0x003FFF00U /*!< Frame number of the received SOF */
/******************** Bit definition for USB_OTG_GAHBCFG register ********************/
#define USB_OTG_GAHBCFG_GINT 0x00000001U /*!< Global interrupt mask */
#define USB_OTG_GAHBCFG_HBSTLEN 0x0000001EU /*!< Burst length/type */
#define USB_OTG_GAHBCFG_HBSTLEN_0 0x00000002U /*!<Bit 0 */
#define USB_OTG_GAHBCFG_HBSTLEN_1 0x00000004U /*!<Bit 1 */
#define USB_OTG_GAHBCFG_HBSTLEN_2 0x00000008U /*!<Bit 2 */
#define USB_OTG_GAHBCFG_HBSTLEN_3 0x00000010U /*!<Bit 3 */
#define USB_OTG_GAHBCFG_DMAEN 0x00000020U /*!< DMA enable */
#define USB_OTG_GAHBCFG_TXFELVL 0x00000080U /*!< TxFIFO empty level */
#define USB_OTG_GAHBCFG_PTXFELVL 0x00000100U /*!< Periodic TxFIFO empty level */
/******************** Bit definition for USB_OTG_GUSBCFG register ********************/
#define USB_OTG_GUSBCFG_TOCAL 0x00000007U /*!< FS timeout calibration */
#define USB_OTG_GUSBCFG_TOCAL_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_GUSBCFG_TOCAL_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_GUSBCFG_TOCAL_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_GUSBCFG_PHYSEL 0x00000040U /*!< USB 2.0 high-speed ULPI PHY or USB 1.1 full-speed serial transceiver select */
#define USB_OTG_GUSBCFG_SRPCAP 0x00000100U /*!< SRP-capable */
#define USB_OTG_GUSBCFG_HNPCAP 0x00000200U /*!< HNP-capable */
#define USB_OTG_GUSBCFG_TRDT 0x00003C00U /*!< USB turnaround time */
#define USB_OTG_GUSBCFG_TRDT_0 0x00000400U /*!<Bit 0 */
#define USB_OTG_GUSBCFG_TRDT_1 0x00000800U /*!<Bit 1 */
#define USB_OTG_GUSBCFG_TRDT_2 0x00001000U /*!<Bit 2 */
#define USB_OTG_GUSBCFG_TRDT_3 0x00002000U /*!<Bit 3 */
#define USB_OTG_GUSBCFG_PHYLPCS 0x00008000U /*!< PHY Low-power clock select */
#define USB_OTG_GUSBCFG_ULPIFSLS 0x00020000U /*!< ULPI FS/LS select */
#define USB_OTG_GUSBCFG_ULPIAR 0x00040000U /*!< ULPI Auto-resume */
#define USB_OTG_GUSBCFG_ULPICSM 0x00080000U /*!< ULPI Clock SuspendM */
#define USB_OTG_GUSBCFG_ULPIEVBUSD 0x00100000U /*!< ULPI External VBUS Drive */
#define USB_OTG_GUSBCFG_ULPIEVBUSI 0x00200000U /*!< ULPI external VBUS indicator */
#define USB_OTG_GUSBCFG_TSDPS 0x00400000U /*!< TermSel DLine pulsing selection */
#define USB_OTG_GUSBCFG_PCCI 0x00800000U /*!< Indicator complement */
#define USB_OTG_GUSBCFG_PTCI 0x01000000U /*!< Indicator pass through */
#define USB_OTG_GUSBCFG_ULPIIPD 0x02000000U /*!< ULPI interface protect disable */
#define USB_OTG_GUSBCFG_FHMOD 0x20000000U /*!< Forced host mode */
#define USB_OTG_GUSBCFG_FDMOD 0x40000000U /*!< Forced peripheral mode */
#define USB_OTG_GUSBCFG_CTXPKT 0x80000000U /*!< Corrupt Tx packet */
/******************** Bit definition for USB_OTG_GRSTCTL register ********************/
#define USB_OTG_GRSTCTL_CSRST 0x00000001U /*!< Core soft reset */
#define USB_OTG_GRSTCTL_HSRST 0x00000002U /*!< HCLK soft reset */
#define USB_OTG_GRSTCTL_FCRST 0x00000004U /*!< Host frame counter reset */
#define USB_OTG_GRSTCTL_RXFFLSH 0x00000010U /*!< RxFIFO flush */
#define USB_OTG_GRSTCTL_TXFFLSH 0x00000020U /*!< TxFIFO flush */
#define USB_OTG_GRSTCTL_TXFNUM 0x000007C0U /*!< TxFIFO number */
#define USB_OTG_GRSTCTL_TXFNUM_0 0x00000040U /*!<Bit 0 */
#define USB_OTG_GRSTCTL_TXFNUM_1 0x00000080U /*!<Bit 1 */
#define USB_OTG_GRSTCTL_TXFNUM_2 0x00000100U /*!<Bit 2 */
#define USB_OTG_GRSTCTL_TXFNUM_3 0x00000200U /*!<Bit 3 */
#define USB_OTG_GRSTCTL_TXFNUM_4 0x00000400U /*!<Bit 4 */
#define USB_OTG_GRSTCTL_DMAREQ 0x40000000U /*!< DMA request signal */
#define USB_OTG_GRSTCTL_AHBIDL 0x80000000U /*!< AHB master idle */
/******************** Bit definition for USB_OTG_DIEPMSK register ********************/
#define USB_OTG_DIEPMSK_XFRCM 0x00000001U /*!< Transfer completed interrupt mask */
#define USB_OTG_DIEPMSK_EPDM 0x00000002U /*!< Endpoint disabled interrupt mask */
#define USB_OTG_DIEPMSK_TOM 0x00000008U /*!< Timeout condition mask (nonisochronous endpoints) */
#define USB_OTG_DIEPMSK_ITTXFEMSK 0x00000010U /*!< IN token received when TxFIFO empty mask */
#define USB_OTG_DIEPMSK_INEPNMM 0x00000020U /*!< IN token received with EP mismatch mask */
#define USB_OTG_DIEPMSK_INEPNEM 0x00000040U /*!< IN endpoint NAK effective mask */
#define USB_OTG_DIEPMSK_TXFURM 0x00000100U /*!< FIFO underrun mask */
#define USB_OTG_DIEPMSK_BIM 0x00000200U /*!< BNA interrupt mask */
/******************** Bit definition for USB_OTG_HPTXSTS register ********************/
#define USB_OTG_HPTXSTS_PTXFSAVL 0x0000FFFFU /*!< Periodic transmit data FIFO space available */
#define USB_OTG_HPTXSTS_PTXQSAV 0x00FF0000U /*!< Periodic transmit request queue space available */
#define USB_OTG_HPTXSTS_PTXQSAV_0 0x00010000U /*!<Bit 0 */
#define USB_OTG_HPTXSTS_PTXQSAV_1 0x00020000U /*!<Bit 1 */
#define USB_OTG_HPTXSTS_PTXQSAV_2 0x00040000U /*!<Bit 2 */
#define USB_OTG_HPTXSTS_PTXQSAV_3 0x00080000U /*!<Bit 3 */
#define USB_OTG_HPTXSTS_PTXQSAV_4 0x00100000U /*!<Bit 4 */
#define USB_OTG_HPTXSTS_PTXQSAV_5 0x00200000U /*!<Bit 5 */
#define USB_OTG_HPTXSTS_PTXQSAV_6 0x00400000U /*!<Bit 6 */
#define USB_OTG_HPTXSTS_PTXQSAV_7 0x00800000U /*!<Bit 7 */
#define USB_OTG_HPTXSTS_PTXQTOP 0xFF000000U /*!< Top of the periodic transmit request queue */
#define USB_OTG_HPTXSTS_PTXQTOP_0 0x01000000U /*!<Bit 0 */
#define USB_OTG_HPTXSTS_PTXQTOP_1 0x02000000U /*!<Bit 1 */
#define USB_OTG_HPTXSTS_PTXQTOP_2 0x04000000U /*!<Bit 2 */
#define USB_OTG_HPTXSTS_PTXQTOP_3 0x08000000U /*!<Bit 3 */
#define USB_OTG_HPTXSTS_PTXQTOP_4 0x10000000U /*!<Bit 4 */
#define USB_OTG_HPTXSTS_PTXQTOP_5 0x20000000U /*!<Bit 5 */
#define USB_OTG_HPTXSTS_PTXQTOP_6 0x40000000U /*!<Bit 6 */
#define USB_OTG_HPTXSTS_PTXQTOP_7 0x80000000U /*!<Bit 7 */
/******************** Bit definition for USB_OTG_HAINT register ********************/
#define USB_OTG_HAINT_HAINT 0x0000FFFFU /*!< Channel interrupts */
/******************** Bit definition for USB_OTG_DOEPMSK register ********************/
#define USB_OTG_DOEPMSK_XFRCM 0x00000001U /*!< Transfer completed interrupt mask */
#define USB_OTG_DOEPMSK_EPDM 0x00000002U /*!< Endpoint disabled interrupt mask */
#define USB_OTG_DOEPMSK_STUPM 0x00000008U /*!< SETUP phase done mask */
#define USB_OTG_DOEPMSK_OTEPDM 0x00000010U /*!< OUT token received when endpoint disabled mask */
#define USB_OTG_DOEPMSK_OTEPSPRM 0x00000020U /*!< Status Phase Received mask */
#define USB_OTG_DOEPMSK_B2BSTUP 0x00000040U /*!< Back-to-back SETUP packets received mask */
#define USB_OTG_DOEPMSK_OPEM 0x00000100U /*!< OUT packet error mask */
#define USB_OTG_DOEPMSK_BOIM 0x00000200U /*!< BNA interrupt mask */
/******************** Bit definition for USB_OTG_GINTSTS register ********************/
#define USB_OTG_GINTSTS_CMOD 0x00000001U /*!< Current mode of operation */
#define USB_OTG_GINTSTS_MMIS 0x00000002U /*!< Mode mismatch interrupt */
#define USB_OTG_GINTSTS_OTGINT 0x00000004U /*!< OTG interrupt */
#define USB_OTG_GINTSTS_SOF 0x00000008U /*!< Start of frame */
#define USB_OTG_GINTSTS_RXFLVL 0x00000010U /*!< RxFIFO nonempty */
#define USB_OTG_GINTSTS_NPTXFE 0x00000020U /*!< Nonperiodic TxFIFO empty */
#define USB_OTG_GINTSTS_GINAKEFF 0x00000040U /*!< Global IN nonperiodic NAK effective */
#define USB_OTG_GINTSTS_BOUTNAKEFF 0x00000080U /*!< Global OUT NAK effective */
#define USB_OTG_GINTSTS_ESUSP 0x00000400U /*!< Early suspend */
#define USB_OTG_GINTSTS_USBSUSP 0x00000800U /*!< USB suspend */
#define USB_OTG_GINTSTS_USBRST 0x00001000U /*!< USB reset */
#define USB_OTG_GINTSTS_ENUMDNE 0x00002000U /*!< Enumeration done */
#define USB_OTG_GINTSTS_ISOODRP 0x00004000U /*!< Isochronous OUT packet dropped interrupt */
#define USB_OTG_GINTSTS_EOPF 0x00008000U /*!< End of periodic frame interrupt */
#define USB_OTG_GINTSTS_IEPINT 0x00040000U /*!< IN endpoint interrupt */
#define USB_OTG_GINTSTS_OEPINT 0x00080000U /*!< OUT endpoint interrupt */
#define USB_OTG_GINTSTS_IISOIXFR 0x00100000U /*!< Incomplete isochronous IN transfer */
#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT 0x00200000U /*!< Incomplete periodic transfer */
#define USB_OTG_GINTSTS_DATAFSUSP 0x00400000U /*!< Data fetch suspended */
#define USB_OTG_GINTSTS_RSTDET 0x00800000U /*!< Reset detected interrupt */
#define USB_OTG_GINTSTS_HPRTINT 0x01000000U /*!< Host port interrupt */
#define USB_OTG_GINTSTS_HCINT 0x02000000U /*!< Host channels interrupt */
#define USB_OTG_GINTSTS_PTXFE 0x04000000U /*!< Periodic TxFIFO empty */
#define USB_OTG_GINTSTS_LPMINT 0x08000000U /*!< LPM interrupt */
#define USB_OTG_GINTSTS_CIDSCHG 0x10000000U /*!< Connector ID status change */
#define USB_OTG_GINTSTS_DISCINT 0x20000000U /*!< Disconnect detected interrupt */
#define USB_OTG_GINTSTS_SRQINT 0x40000000U /*!< Session request/new session detected interrupt */
#define USB_OTG_GINTSTS_WKUINT 0x80000000U /*!< Resume/remote wakeup detected interrupt */
/******************** Bit definition for USB_OTG_GINTMSK register ********************/
#define USB_OTG_GINTMSK_MMISM 0x00000002U /*!< Mode mismatch interrupt mask */
#define USB_OTG_GINTMSK_OTGINT 0x00000004U /*!< OTG interrupt mask */
#define USB_OTG_GINTMSK_SOFM 0x00000008U /*!< Start of frame mask */
#define USB_OTG_GINTMSK_RXFLVLM 0x00000010U /*!< Receive FIFO nonempty mask */
#define USB_OTG_GINTMSK_NPTXFEM 0x00000020U /*!< Nonperiodic TxFIFO empty mask */
#define USB_OTG_GINTMSK_GINAKEFFM 0x00000040U /*!< Global nonperiodic IN NAK effective mask */
#define USB_OTG_GINTMSK_GONAKEFFM 0x00000080U /*!< Global OUT NAK effective mask */
#define USB_OTG_GINTMSK_ESUSPM 0x00000400U /*!< Early suspend mask */
#define USB_OTG_GINTMSK_USBSUSPM 0x00000800U /*!< USB suspend mask */
#define USB_OTG_GINTMSK_USBRST 0x00001000U /*!< USB reset mask */
#define USB_OTG_GINTMSK_ENUMDNEM 0x00002000U /*!< Enumeration done mask */
#define USB_OTG_GINTMSK_ISOODRPM 0x00004000U /*!< Isochronous OUT packet dropped interrupt mask */
#define USB_OTG_GINTMSK_EOPFM 0x00008000U /*!< End of periodic frame interrupt mask */
#define USB_OTG_GINTMSK_EPMISM 0x00020000U /*!< Endpoint mismatch interrupt mask */
#define USB_OTG_GINTMSK_IEPINT 0x00040000U /*!< IN endpoints interrupt mask */
#define USB_OTG_GINTMSK_OEPINT 0x00080000U /*!< OUT endpoints interrupt mask */
#define USB_OTG_GINTMSK_IISOIXFRM 0x00100000U /*!< Incomplete isochronous IN transfer mask */
#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM 0x00200000U /*!< Incomplete periodic transfer mask */
#define USB_OTG_GINTMSK_FSUSPM 0x00400000U /*!< Data fetch suspended mask */
#define USB_OTG_GINTMSK_RSTDEM 0x00800000U /*!< Reset detected interrupt mask */
#define USB_OTG_GINTMSK_PRTIM 0x01000000U /*!< Host port interrupt mask */
#define USB_OTG_GINTMSK_HCIM 0x02000000U /*!< Host channels interrupt mask */
#define USB_OTG_GINTMSK_PTXFEM 0x04000000U /*!< Periodic TxFIFO empty mask */
#define USB_OTG_GINTMSK_LPMINTM 0x08000000U /*!< LPM interrupt Mask */
#define USB_OTG_GINTMSK_CIDSCHGM 0x10000000U /*!< Connector ID status change mask */
#define USB_OTG_GINTMSK_DISCINT 0x20000000U /*!< Disconnect detected interrupt mask */
#define USB_OTG_GINTMSK_SRQIM 0x40000000U /*!< Session request/new session detected interrupt mask */
#define USB_OTG_GINTMSK_WUIM 0x80000000U /*!< Resume/remote wakeup detected interrupt mask */
/******************** Bit definition for USB_OTG_DAINT register ********************/
#define USB_OTG_DAINT_IEPINT 0x0000FFFFU /*!< IN endpoint interrupt bits */
#define USB_OTG_DAINT_OEPINT 0xFFFF0000U /*!< OUT endpoint interrupt bits */
/******************** Bit definition for USB_OTG_HAINTMSK register ********************/
#define USB_OTG_HAINTMSK_HAINTM 0x0000FFFFU /*!< Channel interrupt mask */
/******************** Bit definition for USB_OTG_GRXSTSP register ********************/
#define USB_OTG_GRXSTSP_EPNUM 0x0000000FU /*!< IN EP interrupt mask bits */
#define USB_OTG_GRXSTSP_BCNT 0x00007FF0U /*!< OUT EP interrupt mask bits */
#define USB_OTG_GRXSTSP_DPID 0x00018000U /*!< OUT EP interrupt mask bits */
#define USB_OTG_GRXSTSP_PKTSTS 0x001E0000U /*!< OUT EP interrupt mask bits */
/******************** Bit definition for USB_OTG_DAINTMSK register ********************/
#define USB_OTG_DAINTMSK_IEPM 0x0000FFFFU /*!< IN EP interrupt mask bits */
#define USB_OTG_DAINTMSK_OEPM 0xFFFF0000U /*!< OUT EP interrupt mask bits */
/******************** Bit definition for OTG register ********************/
#define USB_OTG_CHNUM 0x0000000FU /*!< Channel number */
#define USB_OTG_CHNUM_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_CHNUM_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_CHNUM_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_CHNUM_3 0x00000008U /*!<Bit 3 */
#define USB_OTG_BCNT 0x00007FF0U /*!< Byte count */
#define USB_OTG_DPID 0x00018000U /*!< Data PID */
#define USB_OTG_DPID_0 0x00008000U /*!<Bit 0 */
#define USB_OTG_DPID_1 0x00010000U /*!<Bit 1 */
#define USB_OTG_PKTSTS 0x001E0000U /*!< Packet status */
#define USB_OTG_PKTSTS_0 0x00020000U /*!<Bit 0 */
#define USB_OTG_PKTSTS_1 0x00040000U /*!<Bit 1 */
#define USB_OTG_PKTSTS_2 0x00080000U /*!<Bit 2 */
#define USB_OTG_PKTSTS_3 0x00100000U /*!<Bit 3 */
#define USB_OTG_EPNUM 0x0000000FU /*!< Endpoint number */
#define USB_OTG_EPNUM_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_EPNUM_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_EPNUM_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_EPNUM_3 0x00000008U /*!<Bit 3 */
#define USB_OTG_FRMNUM 0x01E00000U /*!< Frame number */
#define USB_OTG_FRMNUM_0 0x00200000U /*!<Bit 0 */
#define USB_OTG_FRMNUM_1 0x00400000U /*!<Bit 1 */
#define USB_OTG_FRMNUM_2 0x00800000U /*!<Bit 2 */
#define USB_OTG_FRMNUM_3 0x01000000U /*!<Bit 3 */
/******************** Bit definition for OTG register ********************/
#define USB_OTG_CHNUM 0x0000000FU /*!< Channel number */
#define USB_OTG_CHNUM_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_CHNUM_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_CHNUM_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_CHNUM_3 0x00000008U /*!<Bit 3 */
#define USB_OTG_BCNT 0x00007FF0U /*!< Byte count */
#define USB_OTG_DPID 0x00018000U /*!< Data PID */
#define USB_OTG_DPID_0 0x00008000U /*!<Bit 0 */
#define USB_OTG_DPID_1 0x00010000U /*!<Bit 1 */
#define USB_OTG_PKTSTS 0x001E0000U /*!< Packet status */
#define USB_OTG_PKTSTS_0 0x00020000U /*!<Bit 0 */
#define USB_OTG_PKTSTS_1 0x00040000U /*!<Bit 1 */
#define USB_OTG_PKTSTS_2 0x00080000U /*!<Bit 2 */
#define USB_OTG_PKTSTS_3 0x00100000U /*!<Bit 3 */
#define USB_OTG_EPNUM 0x0000000FU /*!< Endpoint number */
#define USB_OTG_EPNUM_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_EPNUM_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_EPNUM_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_EPNUM_3 0x00000008U /*!<Bit 3 */
#define USB_OTG_FRMNUM 0x01E00000U /*!< Frame number */
#define USB_OTG_FRMNUM_0 0x00200000U /*!<Bit 0 */
#define USB_OTG_FRMNUM_1 0x00400000U /*!<Bit 1 */
#define USB_OTG_FRMNUM_2 0x00800000U /*!<Bit 2 */
#define USB_OTG_FRMNUM_3 0x01000000U /*!<Bit 3 */
/******************** Bit definition for USB_OTG_GRXFSIZ register ********************/
#define USB_OTG_GRXFSIZ_RXFD 0x0000FFFFU /*!< RxFIFO depth */
/******************** Bit definition for USB_OTG_DVBUSDIS register ********************/
#define USB_OTG_DVBUSDIS_VBUSDT 0x0000FFFFU /*!< Device VBUS discharge time */
/******************** Bit definition for OTG register ********************/
#define USB_OTG_NPTXFSA 0x0000FFFFU /*!< Nonperiodic transmit RAM start address */
#define USB_OTG_NPTXFD 0xFFFF0000U /*!< Nonperiodic TxFIFO depth */
#define USB_OTG_TX0FSA 0x0000FFFFU /*!< Endpoint 0 transmit RAM start address */
#define USB_OTG_TX0FD 0xFFFF0000U /*!< Endpoint 0 TxFIFO depth */
/******************** Bit definition for USB_OTG_DVBUSPULSE register ********************/
#define USB_OTG_DVBUSPULSE_DVBUSP 0x00000FFFU /*!< Device VBUS pulsing time */
/******************** Bit definition for USB_OTG_GNPTXSTS register ********************/
#define USB_OTG_GNPTXSTS_NPTXFSAV 0x0000FFFFU /*!< Nonperiodic TxFIFO space available */
#define USB_OTG_GNPTXSTS_NPTQXSAV 0x00FF0000U /*!< Nonperiodic transmit request queue space available */
#define USB_OTG_GNPTXSTS_NPTQXSAV_0 0x00010000U /*!<Bit 0 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_1 0x00020000U /*!<Bit 1 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_2 0x00040000U /*!<Bit 2 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_3 0x00080000U /*!<Bit 3 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_4 0x00100000U /*!<Bit 4 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_5 0x00200000U /*!<Bit 5 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_6 0x00400000U /*!<Bit 6 */
#define USB_OTG_GNPTXSTS_NPTQXSAV_7 0x00800000U /*!<Bit 7 */
#define USB_OTG_GNPTXSTS_NPTXQTOP 0x7F000000U /*!< Top of the nonperiodic transmit request queue */
#define USB_OTG_GNPTXSTS_NPTXQTOP_0 0x01000000U /*!<Bit 0 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_1 0x02000000U /*!<Bit 1 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_2 0x04000000U /*!<Bit 2 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_3 0x08000000U /*!<Bit 3 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_4 0x10000000U /*!<Bit 4 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_5 0x20000000U /*!<Bit 5 */
#define USB_OTG_GNPTXSTS_NPTXQTOP_6 0x40000000U /*!<Bit 6 */
/******************** Bit definition for USB_OTG_DTHRCTL register ********************/
#define USB_OTG_DTHRCTL_NONISOTHREN 0x00000001U /*!< Nonisochronous IN endpoints threshold enable */
#define USB_OTG_DTHRCTL_ISOTHREN 0x00000002U /*!< ISO IN endpoint threshold enable */
#define USB_OTG_DTHRCTL_TXTHRLEN 0x000007FCU /*!< Transmit threshold length */
#define USB_OTG_DTHRCTL_TXTHRLEN_0 0x00000004U /*!<Bit 0 */
#define USB_OTG_DTHRCTL_TXTHRLEN_1 0x00000008U /*!<Bit 1 */
#define USB_OTG_DTHRCTL_TXTHRLEN_2 0x00000010U /*!<Bit 2 */
#define USB_OTG_DTHRCTL_TXTHRLEN_3 0x00000020U /*!<Bit 3 */
#define USB_OTG_DTHRCTL_TXTHRLEN_4 0x00000040U /*!<Bit 4 */
#define USB_OTG_DTHRCTL_TXTHRLEN_5 0x00000080U /*!<Bit 5 */
#define USB_OTG_DTHRCTL_TXTHRLEN_6 0x00000100U /*!<Bit 6 */
#define USB_OTG_DTHRCTL_TXTHRLEN_7 0x00000200U /*!<Bit 7 */
#define USB_OTG_DTHRCTL_TXTHRLEN_8 0x00000400U /*!<Bit 8 */
#define USB_OTG_DTHRCTL_RXTHREN 0x00010000U /*!< Receive threshold enable */
#define USB_OTG_DTHRCTL_RXTHRLEN 0x03FE0000U /*!< Receive threshold length */
#define USB_OTG_DTHRCTL_RXTHRLEN_0 0x00020000U /*!<Bit 0 */
#define USB_OTG_DTHRCTL_RXTHRLEN_1 0x00040000U /*!<Bit 1 */
#define USB_OTG_DTHRCTL_RXTHRLEN_2 0x00080000U /*!<Bit 2 */
#define USB_OTG_DTHRCTL_RXTHRLEN_3 0x00100000U /*!<Bit 3 */
#define USB_OTG_DTHRCTL_RXTHRLEN_4 0x00200000U /*!<Bit 4 */
#define USB_OTG_DTHRCTL_RXTHRLEN_5 0x00400000U /*!<Bit 5 */
#define USB_OTG_DTHRCTL_RXTHRLEN_6 0x00800000U /*!<Bit 6 */
#define USB_OTG_DTHRCTL_RXTHRLEN_7 0x01000000U /*!<Bit 7 */
#define USB_OTG_DTHRCTL_RXTHRLEN_8 0x02000000U /*!<Bit 8 */
#define USB_OTG_DTHRCTL_ARPEN 0x08000000U /*!< Arbiter parking enable */
/******************** Bit definition for USB_OTG_DIEPEMPMSK register ********************/
#define USB_OTG_DIEPEMPMSK_INEPTXFEM 0x0000FFFFU /*!< IN EP Tx FIFO empty interrupt mask bits */
/******************** Bit definition for USB_OTG_DEACHINT register ********************/
#define USB_OTG_DEACHINT_IEP1INT 0x00000002U /*!< IN endpoint 1interrupt bit */
#define USB_OTG_DEACHINT_OEP1INT 0x00020000U /*!< OUT endpoint 1 interrupt bit */
/******************** Bit definition for USB_OTG_GCCFG register ********************/
#define USB_OTG_GCCFG_PWRDWN 0x00010000U /*!< Power down */
#define USB_OTG_GCCFG_VBDEN 0x00200000U /*!< USB VBUS Detection Enable */
/******************** Bit definition for USB_OTG_GPWRDN) register ********************/
#define USB_OTG_GPWRDN_ADPMEN 0x00000001U /*!< ADP module enable */
#define USB_OTG_GPWRDN_ADPIF 0x00800000U /*!< ADP Interrupt flag */
/******************** Bit definition for USB_OTG_DEACHINTMSK register ********************/
#define USB_OTG_DEACHINTMSK_IEP1INTM 0x00000002U /*!< IN Endpoint 1 interrupt mask bit */
#define USB_OTG_DEACHINTMSK_OEP1INTM 0x00020000U /*!< OUT Endpoint 1 interrupt mask bit */
/******************** Bit definition for USB_OTG_CID register ********************/
#define USB_OTG_CID_PRODUCT_ID 0xFFFFFFFFU /*!< Product ID field */
/******************** Bit definition for USB_OTG_GLPMCFG register ********************/
#define USB_OTG_GLPMCFG_LPMEN 0x00000001U /*!< LPM support enable */
#define USB_OTG_GLPMCFG_LPMACK 0x00000002U /*!< LPM Token acknowledge enable */
#define USB_OTG_GLPMCFG_BESL 0x0000003CU /*!< BESL value received with last ACKed LPM Token */
#define USB_OTG_GLPMCFG_REMWAKE 0x00000040U /*!< bRemoteWake value received with last ACKed LPM Token */
#define USB_OTG_GLPMCFG_L1SSEN 0x00000080U /*!< L1 shallow sleep enable */
#define USB_OTG_GLPMCFG_BESLTHRS 0x00000F00U /*!< BESL threshold */
#define USB_OTG_GLPMCFG_L1DSEN 0x00001000U /*!< L1 deep sleep enable */
#define USB_OTG_GLPMCFG_LPMRSP 0x00006000U /*!< LPM response */
#define USB_OTG_GLPMCFG_SLPSTS 0x00008000U /*!< Port sleep status */
#define USB_OTG_GLPMCFG_L1RSMOK 0x00010000U /*!< Sleep State Resume OK */
#define USB_OTG_GLPMCFG_LPMCHIDX 0x001E0000U /*!< LPM Channel Index */
#define USB_OTG_GLPMCFG_LPMRCNT 0x00E00000U /*!< LPM retry count */
#define USB_OTG_GLPMCFG_SNDLPM 0x01000000U /*!< Send LPM transaction */
#define USB_OTG_GLPMCFG_LPMRCNTSTS 0x0E000000U /*!< LPM retry count status */
#define USB_OTG_GLPMCFG_ENBESL 0x10000000U /*!< Enable best effort service latency */
/******************** Bit definition for USB_OTG_DIEPEACHMSK1 register ********************/
#define USB_OTG_DIEPEACHMSK1_XFRCM 0x00000001U /*!< Transfer completed interrupt mask */
#define USB_OTG_DIEPEACHMSK1_EPDM 0x00000002U /*!< Endpoint disabled interrupt mask */
#define USB_OTG_DIEPEACHMSK1_TOM 0x00000008U /*!< Timeout condition mask (nonisochronous endpoints) */
#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK 0x00000010U /*!< IN token received when TxFIFO empty mask */
#define USB_OTG_DIEPEACHMSK1_INEPNMM 0x00000020U /*!< IN token received with EP mismatch mask */
#define USB_OTG_DIEPEACHMSK1_INEPNEM 0x00000040U /*!< IN endpoint NAK effective mask */
#define USB_OTG_DIEPEACHMSK1_TXFURM 0x00000100U /*!< FIFO underrun mask */
#define USB_OTG_DIEPEACHMSK1_BIM 0x00000200U /*!< BNA interrupt mask */
#define USB_OTG_DIEPEACHMSK1_NAKM 0x00002000U /*!< NAK interrupt mask */
/******************** Bit definition for USB_OTG_HPRT register ********************/
#define USB_OTG_HPRT_PCSTS 0x00000001U /*!< Port connect status */
#define USB_OTG_HPRT_PCDET 0x00000002U /*!< Port connect detected */
#define USB_OTG_HPRT_PENA 0x00000004U /*!< Port enable */
#define USB_OTG_HPRT_PENCHNG 0x00000008U /*!< Port enable/disable change */
#define USB_OTG_HPRT_POCA 0x00000010U /*!< Port overcurrent active */
#define USB_OTG_HPRT_POCCHNG 0x00000020U /*!< Port overcurrent change */
#define USB_OTG_HPRT_PRES 0x00000040U /*!< Port resume */
#define USB_OTG_HPRT_PSUSP 0x00000080U /*!< Port suspend */
#define USB_OTG_HPRT_PRST 0x00000100U /*!< Port reset */
#define USB_OTG_HPRT_PLSTS 0x00000C00U /*!< Port line status */
#define USB_OTG_HPRT_PLSTS_0 0x00000400U /*!<Bit 0 */
#define USB_OTG_HPRT_PLSTS_1 0x00000800U /*!<Bit 1 */
#define USB_OTG_HPRT_PPWR 0x00001000U /*!< Port power */
#define USB_OTG_HPRT_PTCTL 0x0001E000U /*!< Port test control */
#define USB_OTG_HPRT_PTCTL_0 0x00002000U /*!<Bit 0 */
#define USB_OTG_HPRT_PTCTL_1 0x00004000U /*!<Bit 1 */
#define USB_OTG_HPRT_PTCTL_2 0x00008000U /*!<Bit 2 */
#define USB_OTG_HPRT_PTCTL_3 0x00010000U /*!<Bit 3 */
#define USB_OTG_HPRT_PSPD 0x00060000U /*!< Port speed */
#define USB_OTG_HPRT_PSPD_0 0x00020000U /*!<Bit 0 */
#define USB_OTG_HPRT_PSPD_1 0x00040000U /*!<Bit 1 */
/******************** Bit definition for USB_OTG_DOEPEACHMSK1 register ********************/
#define USB_OTG_DOEPEACHMSK1_XFRCM 0x00000001U /*!< Transfer completed interrupt mask */
#define USB_OTG_DOEPEACHMSK1_EPDM 0x00000002U /*!< Endpoint disabled interrupt mask */
#define USB_OTG_DOEPEACHMSK1_TOM 0x00000008U /*!< Timeout condition mask */
#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK 0x00000010U /*!< IN token received when TxFIFO empty mask */
#define USB_OTG_DOEPEACHMSK1_INEPNMM 0x00000020U /*!< IN token received with EP mismatch mask */
#define USB_OTG_DOEPEACHMSK1_INEPNEM 0x00000040U /*!< IN endpoint NAK effective mask */
#define USB_OTG_DOEPEACHMSK1_TXFURM 0x00000100U /*!< OUT packet error mask */
#define USB_OTG_DOEPEACHMSK1_BIM 0x00000200U /*!< BNA interrupt mask */
#define USB_OTG_DOEPEACHMSK1_BERRM 0x00001000U /*!< Bubble error interrupt mask */
#define USB_OTG_DOEPEACHMSK1_NAKM 0x00002000U /*!< NAK interrupt mask */
#define USB_OTG_DOEPEACHMSK1_NYETM 0x00004000U /*!< NYET interrupt mask */
/******************** Bit definition for USB_OTG_HPTXFSIZ register ********************/
#define USB_OTG_HPTXFSIZ_PTXSA 0x0000FFFFU /*!< Host periodic TxFIFO start address */
#define USB_OTG_HPTXFSIZ_PTXFD 0xFFFF0000U /*!< Host periodic TxFIFO depth */
/******************** Bit definition for USB_OTG_DIEPCTL register ********************/
#define USB_OTG_DIEPCTL_MPSIZ 0x000007FFU /*!< Maximum packet size */
#define USB_OTG_DIEPCTL_USBAEP 0x00008000U /*!< USB active endpoint */
#define USB_OTG_DIEPCTL_EONUM_DPID 0x00010000U /*!< Even/odd frame */
#define USB_OTG_DIEPCTL_NAKSTS 0x00020000U /*!< NAK status */
#define USB_OTG_DIEPCTL_EPTYP 0x000C0000U /*!< Endpoint type */
#define USB_OTG_DIEPCTL_EPTYP_0 0x00040000U /*!<Bit 0 */
#define USB_OTG_DIEPCTL_EPTYP_1 0x00080000U /*!<Bit 1 */
#define USB_OTG_DIEPCTL_STALL 0x00200000U /*!< STALL handshake */
#define USB_OTG_DIEPCTL_TXFNUM 0x03C00000U /*!< TxFIFO number */
#define USB_OTG_DIEPCTL_TXFNUM_0 0x00400000U /*!<Bit 0 */
#define USB_OTG_DIEPCTL_TXFNUM_1 0x00800000U /*!<Bit 1 */
#define USB_OTG_DIEPCTL_TXFNUM_2 0x01000000U /*!<Bit 2 */
#define USB_OTG_DIEPCTL_TXFNUM_3 0x02000000U /*!<Bit 3 */
#define USB_OTG_DIEPCTL_CNAK 0x04000000U /*!< Clear NAK */
#define USB_OTG_DIEPCTL_SNAK 0x08000000U /*!< Set NAK */
#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM 0x10000000U /*!< Set DATA0 PID */
#define USB_OTG_DIEPCTL_SODDFRM 0x20000000U /*!< Set odd frame */
#define USB_OTG_DIEPCTL_EPDIS 0x40000000U /*!< Endpoint disable */
#define USB_OTG_DIEPCTL_EPENA 0x80000000U /*!< Endpoint enable */
/******************** Bit definition for USB_OTG_HCCHAR register ********************/
#define USB_OTG_HCCHAR_MPSIZ 0x000007FFU /*!< Maximum packet size */
#define USB_OTG_HCCHAR_EPNUM 0x00007800U /*!< Endpoint number */
#define USB_OTG_HCCHAR_EPNUM_0 0x00000800U /*!<Bit 0 */
#define USB_OTG_HCCHAR_EPNUM_1 0x00001000U /*!<Bit 1 */
#define USB_OTG_HCCHAR_EPNUM_2 0x00002000U /*!<Bit 2 */
#define USB_OTG_HCCHAR_EPNUM_3 0x00004000U /*!<Bit 3 */
#define USB_OTG_HCCHAR_EPDIR 0x00008000U /*!< Endpoint direction */
#define USB_OTG_HCCHAR_LSDEV 0x00020000U /*!< Low-speed device */
#define USB_OTG_HCCHAR_EPTYP 0x000C0000U /*!< Endpoint type */
#define USB_OTG_HCCHAR_EPTYP_0 0x00040000U /*!<Bit 0 */
#define USB_OTG_HCCHAR_EPTYP_1 0x00080000U /*!<Bit 1 */
#define USB_OTG_HCCHAR_MC 0x00300000U /*!< Multi Count (MC) / Error Count (EC) */
#define USB_OTG_HCCHAR_MC_0 0x00100000U /*!<Bit 0 */
#define USB_OTG_HCCHAR_MC_1 0x00200000U /*!<Bit 1 */
#define USB_OTG_HCCHAR_DAD 0x1FC00000U /*!< Device address */
#define USB_OTG_HCCHAR_DAD_0 0x00400000U /*!<Bit 0 */
#define USB_OTG_HCCHAR_DAD_1 0x00800000U /*!<Bit 1 */
#define USB_OTG_HCCHAR_DAD_2 0x01000000U /*!<Bit 2 */
#define USB_OTG_HCCHAR_DAD_3 0x02000000U /*!<Bit 3 */
#define USB_OTG_HCCHAR_DAD_4 0x04000000U /*!<Bit 4 */
#define USB_OTG_HCCHAR_DAD_5 0x08000000U /*!<Bit 5 */
#define USB_OTG_HCCHAR_DAD_6 0x10000000U /*!<Bit 6 */
#define USB_OTG_HCCHAR_ODDFRM 0x20000000U /*!< Odd frame */
#define USB_OTG_HCCHAR_CHDIS 0x40000000U /*!< Channel disable */
#define USB_OTG_HCCHAR_CHENA 0x80000000U /*!< Channel enable */
/******************** Bit definition for USB_OTG_HCSPLT register ********************/
#define USB_OTG_HCSPLT_PRTADDR 0x0000007FU /*!< Port address */
#define USB_OTG_HCSPLT_PRTADDR_0 0x00000001U /*!<Bit 0 */
#define USB_OTG_HCSPLT_PRTADDR_1 0x00000002U /*!<Bit 1 */
#define USB_OTG_HCSPLT_PRTADDR_2 0x00000004U /*!<Bit 2 */
#define USB_OTG_HCSPLT_PRTADDR_3 0x00000008U /*!<Bit 3 */
#define USB_OTG_HCSPLT_PRTADDR_4 0x00000010U /*!<Bit 4 */
#define USB_OTG_HCSPLT_PRTADDR_5 0x00000020U /*!<Bit 5 */
#define USB_OTG_HCSPLT_PRTADDR_6 0x00000040U /*!<Bit 6 */
#define USB_OTG_HCSPLT_HUBADDR 0x00003F80U /*!< Hub address */
#define USB_OTG_HCSPLT_HUBADDR_0 0x00000080U /*!<Bit 0 */
#define USB_OTG_HCSPLT_HUBADDR_1 0x00000100U /*!<Bit 1 */
#define USB_OTG_HCSPLT_HUBADDR_2 0x00000200U /*!<Bit 2 */
#define USB_OTG_HCSPLT_HUBADDR_3 0x00000400U /*!<Bit 3 */
#define USB_OTG_HCSPLT_HUBADDR_4 0x00000800U /*!<Bit 4 */
#define USB_OTG_HCSPLT_HUBADDR_5 0x00001000U /*!<Bit 5 */
#define USB_OTG_HCSPLT_HUBADDR_6 0x00002000U /*!<Bit 6 */
#define USB_OTG_HCSPLT_XACTPOS 0x0000C000U /*!< XACTPOS */
#define USB_OTG_HCSPLT_XACTPOS_0 0x00004000U /*!<Bit 0 */
#define USB_OTG_HCSPLT_XACTPOS_1 0x00008000U /*!<Bit 1 */
#define USB_OTG_HCSPLT_COMPLSPLT 0x00010000U /*!< Do complete split */
#define USB_OTG_HCSPLT_SPLITEN 0x80000000U /*!< Split enable */
/******************** Bit definition for USB_OTG_HCINT register ********************/
#define USB_OTG_HCINT_XFRC 0x00000001U /*!< Transfer completed */
#define USB_OTG_HCINT_CHH 0x00000002U /*!< Channel halted */
#define USB_OTG_HCINT_AHBERR 0x00000004U /*!< AHB error */
#define USB_OTG_HCINT_STALL 0x00000008U /*!< STALL response received interrupt */
#define USB_OTG_HCINT_NAK 0x00000010U /*!< NAK response received interrupt */
#define USB_OTG_HCINT_ACK 0x00000020U /*!< ACK response received/transmitted interrupt */
#define USB_OTG_HCINT_NYET 0x00000040U /*!< Response received interrupt */
#define USB_OTG_HCINT_TXERR 0x00000080U /*!< Transaction error */
#define USB_OTG_HCINT_BBERR 0x00000100U /*!< Babble error */
#define USB_OTG_HCINT_FRMOR 0x00000200U /*!< Frame overrun */
#define USB_OTG_HCINT_DTERR 0x00000400U /*!< Data toggle error */
/******************** Bit definition for USB_OTG_DIEPINT register ********************/
#define USB_OTG_DIEPINT_XFRC 0x00000001U /*!< Transfer completed interrupt */
#define USB_OTG_DIEPINT_EPDISD 0x00000002U /*!< Endpoint disabled interrupt */
#define USB_OTG_DIEPINT_TOC 0x00000008U /*!< Timeout condition */
#define USB_OTG_DIEPINT_ITTXFE 0x00000010U /*!< IN token received when TxFIFO is empty */
#define USB_OTG_DIEPINT_INEPNE 0x00000040U /*!< IN endpoint NAK effective */
#define USB_OTG_DIEPINT_TXFE 0x00000080U /*!< Transmit FIFO empty */
#define USB_OTG_DIEPINT_TXFIFOUDRN 0x00000100U /*!< Transmit Fifo Underrun */
#define USB_OTG_DIEPINT_BNA 0x00000200U /*!< Buffer not available interrupt */
#define USB_OTG_DIEPINT_PKTDRPSTS 0x00000800U /*!< Packet dropped status */
#define USB_OTG_DIEPINT_BERR 0x00001000U /*!< Babble error interrupt */
#define USB_OTG_DIEPINT_NAK 0x00002000U /*!< NAK interrupt */
/******************** Bit definition for USB_OTG_HCINTMSK register ********************/
#define USB_OTG_HCINTMSK_XFRCM 0x00000001U /*!< Transfer completed mask */
#define USB_OTG_HCINTMSK_CHHM 0x00000002U /*!< Channel halted mask */
#define USB_OTG_HCINTMSK_AHBERR 0x00000004U /*!< AHB error */
#define USB_OTG_HCINTMSK_STALLM 0x00000008U /*!< STALL response received interrupt mask */
#define USB_OTG_HCINTMSK_NAKM 0x00000010U /*!< NAK response received interrupt mask */
#define USB_OTG_HCINTMSK_ACKM 0x00000020U /*!< ACK response received/transmitted interrupt mask */
#define USB_OTG_HCINTMSK_NYET 0x00000040U /*!< response received interrupt mask */
#define USB_OTG_HCINTMSK_TXERRM 0x00000080U /*!< Transaction error mask */
#define USB_OTG_HCINTMSK_BBERRM 0x00000100U /*!< Babble error mask */
#define USB_OTG_HCINTMSK_FRMORM 0x00000200U /*!< Frame overrun mask */
#define USB_OTG_HCINTMSK_DTERRM 0x00000400U /*!< Data toggle error mask */
/******************** Bit definition for USB_OTG_DIEPTSIZ register ********************/
#define USB_OTG_DIEPTSIZ_XFRSIZ 0x0007FFFFU /*!< Transfer size */
#define USB_OTG_DIEPTSIZ_PKTCNT 0x1FF80000U /*!< Packet count */
#define USB_OTG_DIEPTSIZ_MULCNT 0x60000000U /*!< Packet count */
/******************** Bit definition for USB_OTG_HCTSIZ register ********************/
#define USB_OTG_HCTSIZ_XFRSIZ 0x0007FFFFU /*!< Transfer size */
#define USB_OTG_HCTSIZ_PKTCNT 0x1FF80000U /*!< Packet count */
#define USB_OTG_HCTSIZ_DOPING 0x80000000U /*!< Do PING */
#define USB_OTG_HCTSIZ_DPID 0x60000000U /*!< Data PID */
#define USB_OTG_HCTSIZ_DPID_0 0x20000000U /*!<Bit 0 */
#define USB_OTG_HCTSIZ_DPID_1 0x40000000U /*!<Bit 1 */
/******************** Bit definition for USB_OTG_DIEPDMA register ********************/
#define USB_OTG_DIEPDMA_DMAADDR 0xFFFFFFFFU /*!< DMA address */
/******************** Bit definition for USB_OTG_HCDMA register ********************/
#define USB_OTG_HCDMA_DMAADDR 0xFFFFFFFFU /*!< DMA address */
/******************** Bit definition for USB_OTG_DTXFSTS register ********************/
#define USB_OTG_DTXFSTS_INEPTFSAV 0x0000FFFFU /*!< IN endpoint TxFIFO space available */
/******************** Bit definition for USB_OTG_DIEPTXF register ********************/
#define USB_OTG_DIEPTXF_INEPTXSA 0x0000FFFFU /*!< IN endpoint FIFOx transmit RAM start address */
#define USB_OTG_DIEPTXF_INEPTXFD 0xFFFF0000U /*!< IN endpoint TxFIFO depth */
/******************** Bit definition for USB_OTG_DOEPCTL register ********************/
#define USB_OTG_DOEPCTL_MPSIZ 0x000007FFU /*!< Maximum packet size */ /*!<Bit 1 */
#define USB_OTG_DOEPCTL_USBAEP 0x00008000U /*!< USB active endpoint */
#define USB_OTG_DOEPCTL_NAKSTS 0x00020000U /*!< NAK status */
#define USB_OTG_DOEPCTL_SD0PID_SEVNFRM 0x10000000U /*!< Set DATA0 PID */
#define USB_OTG_DOEPCTL_SODDFRM 0x20000000U /*!< Set odd frame */
#define USB_OTG_DOEPCTL_EPTYP 0x000C0000U /*!< Endpoint type */
#define USB_OTG_DOEPCTL_EPTYP_0 0x00040000U /*!<Bit 0 */
#define USB_OTG_DOEPCTL_EPTYP_1 0x00080000U /*!<Bit 1 */
#define USB_OTG_DOEPCTL_SNPM 0x00100000U /*!< Snoop mode */
#define USB_OTG_DOEPCTL_STALL 0x00200000U /*!< STALL handshake */
#define USB_OTG_DOEPCTL_CNAK 0x04000000U /*!< Clear NAK */
#define USB_OTG_DOEPCTL_SNAK 0x08000000U /*!< Set NAK */
#define USB_OTG_DOEPCTL_EPDIS 0x40000000U /*!< Endpoint disable */
#define USB_OTG_DOEPCTL_EPENA 0x80000000U /*!< Endpoint enable */
/******************** Bit definition for USB_OTG_DOEPINT register ********************/
#define USB_OTG_DOEPINT_XFRC 0x00000001U /*!< Transfer completed interrupt */
#define USB_OTG_DOEPINT_EPDISD 0x00000002U /*!< Endpoint disabled interrupt */
#define USB_OTG_DOEPINT_STUP 0x00000008U /*!< SETUP phase done */
#define USB_OTG_DOEPINT_OTEPDIS 0x00000010U /*!< OUT token received when endpoint disabled */
#define USB_OTG_DOEPINT_OTEPSPR 0x00000020U /*!< Status Phase Received For Control Write */
#define USB_OTG_DOEPINT_B2BSTUP 0x00000040U /*!< Back-to-back SETUP packets received */
#define USB_OTG_DOEPINT_NYET 0x00004000U /*!< NYET interrupt */
/******************** Bit definition for USB_OTG_DOEPTSIZ register ********************/
#define USB_OTG_DOEPTSIZ_XFRSIZ 0x0007FFFFU /*!< Transfer size */
#define USB_OTG_DOEPTSIZ_PKTCNT 0x1FF80000U /*!< Packet count */
#define USB_OTG_DOEPTSIZ_STUPCNT 0x60000000U /*!< SETUP packet count */
#define USB_OTG_DOEPTSIZ_STUPCNT_0 0x20000000U /*!<Bit 0 */
#define USB_OTG_DOEPTSIZ_STUPCNT_1 0x40000000U /*!<Bit 1 */
/******************** Bit definition for PCGCCTL register ********************/
#define USB_OTG_PCGCCTL_STOPCLK 0x00000001U /*!< SETUP packet count */
#define USB_OTG_PCGCCTL_GATECLK 0x00000002U /*!<Bit 0 */
#define USB_OTG_PCGCCTL_PHYSUSP 0x00000010U /*!<Bit 1 */
/******************************************************************************/
/* */
/* MDIOS */
/* */
/******************************************************************************/
/******************** Bit definition for MDIOS_CR register *******************/
#define MDIOS_CR_EN 0x00000001U /*!<Peripheral enable */
#define MDIOS_CR_WRIE 0x00000002U /*!<Register write interrupt enable */
#define MDIOS_CR_RDIE 0x00000004U /*!<Register Read Interrupt Enable */
#define MDIOS_CR_EIE 0x00000008U /*!<Error interrupt enable */
#define MDIOS_CR_DPC 0x00000080U /*!<Disable Preamble Check */
#define MDIOS_CR_PORT_ADDRESS 0x00001F00U /*!<PORT_ADDRESS[4:0] bits */
#define MDIOS_CR_PORT_ADDRESS_0 0x00000100U /*!<Bit 0 */
#define MDIOS_CR_PORT_ADDRESS_1 0x00000200U /*!<Bit 1 */
#define MDIOS_CR_PORT_ADDRESS_2 0x00000400U /*!<Bit 2 */
#define MDIOS_CR_PORT_ADDRESS_3 0x00000800U /*!<Bit 3 */
#define MDIOS_CR_PORT_ADDRESS_4 0x00001000U /*!<Bit 4 */
/******************** Bit definition for MDIOS_WRFR register *******************/
#define MDIOS_WRFR_WRF 0xFFFFFFFFU /*!<WRF[31:0] bits (Write flags for MDIO register 0 to 31) */
/******************** Bit definition for MDIOS_CWRFR register *******************/
#define MDIOS_CWRFR_CWRF 0xFFFFFFFFU /*!<CWRF[31:0] bits (Clear the write flag for MDIO register 0 to 31) */
/******************** Bit definition for MDIOS_RDFR register *******************/
#define MDIOS_RDFR_RDF 0xFFFFFFFFU /*!<RDF[31:0] bits (Read flags for MDIO registers 0 to 31) */
/******************** Bit definition for MDIOS_CRDFR register *******************/
#define MDIOS_CRDFR_CRDF 0xFFFFFFFFU /*!<CRDF[31:0] bits (Clear the read flag for MDIO registers 0 to 31) */
/******************** Bit definition for MDIOS_SR register *******************/
#define MDIOS_SR_PERF 0x00000001U /*!< Preamble error flag */
#define MDIOS_SR_SERF 0x00000002U /*!< Start error flag */
#define MDIOS_SR_TERF 0x00000004U /*!< Turnaround error flag */
/******************** Bit definition for MDIOS_CLRFR register *******************/
#define MDIOS_CLRFR_CPERF 0x00000001U /*!< Clear the preamble error flag */
#define MDIOS_CLRFR_CSERF 0x00000002U /*!< Clear the start error flag */
#define MDIOS_CLRFR_CTERF 0x00000004U /*!< Clear the turnaround error flag */
/**
* @}
*/
/**
* @}
*/
/** @addtogroup Exported_macros
* @{
*/
/******************************* ADC Instances ********************************/
#define IS_ADC_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == ADC1) || \
((__INSTANCE__) == ADC2) || \
((__INSTANCE__) == ADC3))
/******************************* CAN Instances ********************************/
#define IS_CAN_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == CAN1) || \
((__INSTANCE__) == CAN2) || \
((__INSTANCE__) == CAN3))
/******************************* CRC Instances ********************************/
#define IS_CRC_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == CRC)
/******************************* DAC Instances ********************************/
#define IS_DAC_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == DAC)
/******************************* DCMI Instances *******************************/
#define IS_DCMI_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == DCMI)
/****************************** DFSDM Instances *******************************/
#define IS_DFSDM_FILTER_ALL_INSTANCE(INSTANCE) (((INSTANCE) == DFSDM1_Filter0) || \
((INSTANCE) == DFSDM1_Filter1) || \
((INSTANCE) == DFSDM1_Filter2) || \
((INSTANCE) == DFSDM1_Filter3))
#define IS_DFSDM_CHANNEL_ALL_INSTANCE(INSTANCE) (((INSTANCE) == DFSDM1_Channel0) || \
((INSTANCE) == DFSDM1_Channel1) || \
((INSTANCE) == DFSDM1_Channel2) || \
((INSTANCE) == DFSDM1_Channel3) || \
((INSTANCE) == DFSDM1_Channel4) || \
((INSTANCE) == DFSDM1_Channel5) || \
((INSTANCE) == DFSDM1_Channel6) || \
((INSTANCE) == DFSDM1_Channel7))
/******************************* DMA2D Instances *******************************/
#define IS_DMA2D_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == DMA2D)
/******************************** DMA Instances *******************************/
#define IS_DMA_STREAM_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == DMA1_Stream0) || \
((__INSTANCE__) == DMA1_Stream1) || \
((__INSTANCE__) == DMA1_Stream2) || \
((__INSTANCE__) == DMA1_Stream3) || \
((__INSTANCE__) == DMA1_Stream4) || \
((__INSTANCE__) == DMA1_Stream5) || \
((__INSTANCE__) == DMA1_Stream6) || \
((__INSTANCE__) == DMA1_Stream7) || \
((__INSTANCE__) == DMA2_Stream0) || \
((__INSTANCE__) == DMA2_Stream1) || \
((__INSTANCE__) == DMA2_Stream2) || \
((__INSTANCE__) == DMA2_Stream3) || \
((__INSTANCE__) == DMA2_Stream4) || \
((__INSTANCE__) == DMA2_Stream5) || \
((__INSTANCE__) == DMA2_Stream6) || \
((__INSTANCE__) == DMA2_Stream7))
/******************************* GPIO Instances *******************************/
#define IS_GPIO_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == GPIOA) || \
((__INSTANCE__) == GPIOB) || \
((__INSTANCE__) == GPIOC) || \
((__INSTANCE__) == GPIOD) || \
((__INSTANCE__) == GPIOE) || \
((__INSTANCE__) == GPIOF) || \
((__INSTANCE__) == GPIOG) || \
((__INSTANCE__) == GPIOH) || \
((__INSTANCE__) == GPIOI) || \
((__INSTANCE__) == GPIOJ) || \
((__INSTANCE__) == GPIOK))
#define IS_GPIO_AF_INSTANCE(__INSTANCE__) (((__INSTANCE__) == GPIOA) || \
((__INSTANCE__) == GPIOB) || \
((__INSTANCE__) == GPIOC) || \
((__INSTANCE__) == GPIOD) || \
((__INSTANCE__) == GPIOE) || \
((__INSTANCE__) == GPIOF) || \
((__INSTANCE__) == GPIOG) || \
((__INSTANCE__) == GPIOH) || \
((__INSTANCE__) == GPIOI) || \
((__INSTANCE__) == GPIOJ) || \
((__INSTANCE__) == GPIOK))
/****************************** CEC Instances *********************************/
#define IS_CEC_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == CEC)
/****************************** QSPI Instances *********************************/
#define IS_QSPI_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == QUADSPI)
/******************************** I2C Instances *******************************/
#define IS_I2C_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == I2C1) || \
((__INSTANCE__) == I2C2) || \
((__INSTANCE__) == I2C3) || \
((__INSTANCE__) == I2C4))
/******************************** I2S Instances *******************************/
#define IS_I2S_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == SPI1) || \
((__INSTANCE__) == SPI2) || \
((__INSTANCE__) == SPI3))
/******************************* LPTIM Instances ********************************/
#define IS_LPTIM_INSTANCE(__INSTANCE__) ((__INSTANCE__) == LPTIM1)
/****************************** MDIOS Instances ********************************/
#define IS_MDIOS_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == MDIOS)
/******************************* RNG Instances ********************************/
#define IS_RNG_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == RNG)
/****************************** RTC Instances *********************************/
#define IS_RTC_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == RTC)
/******************************* SAI Instances ********************************/
#define IS_SAI_ALL_INSTANCE(__PERIPH__) (((__PERIPH__) == SAI1_Block_A) || \
((__PERIPH__) == SAI1_Block_B) || \
((__PERIPH__) == SAI2_Block_A) || \
((__PERIPH__) == SAI2_Block_B))
/* Legacy define */
#define IS_SAI_BLOCK_PERIPH IS_SAI_ALL_INSTANCE
/******************************** SDMMC Instances *******************************/
#define IS_SDMMC_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == SDMMC1) || \
((__INSTANCE__) == SDMMC2))
/****************************** SPDIFRX Instances *********************************/
#define IS_SPDIFRX_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == SPDIFRX)
/******************************** SPI Instances *******************************/
#define IS_SPI_ALL_INSTANCE(__INSTANCE__) (((__INSTANCE__) == SPI1) || \
((__INSTANCE__) == SPI2) || \
((__INSTANCE__) == SPI3) || \
((__INSTANCE__) == SPI4) || \
((__INSTANCE__) == SPI5) || \
((__INSTANCE__) == SPI6))
/****************** TIM Instances : All supported instances *******************/
#define IS_TIM_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM6) || \
((__INSTANCE__) == TIM7) || \
((__INSTANCE__) == TIM8) || \
((__INSTANCE__) == TIM9) || \
((__INSTANCE__) == TIM10) || \
((__INSTANCE__) == TIM11) || \
((__INSTANCE__) == TIM12) || \
((__INSTANCE__) == TIM13) || \
((__INSTANCE__) == TIM14))
/************* TIM Instances : at least 1 capture/compare channel *************/
#define IS_TIM_CC1_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8) || \
((__INSTANCE__) == TIM9) || \
((__INSTANCE__) == TIM10) || \
((__INSTANCE__) == TIM11) || \
((__INSTANCE__) == TIM12) || \
((__INSTANCE__) == TIM13) || \
((__INSTANCE__) == TIM14))
/************ TIM Instances : at least 2 capture/compare channels *************/
#define IS_TIM_CC2_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8) || \
((__INSTANCE__) == TIM9) || \
((__INSTANCE__) == TIM12))
/************ TIM Instances : at least 3 capture/compare channels *************/
#define IS_TIM_CC3_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/************ TIM Instances : at least 4 capture/compare channels *************/
#define IS_TIM_CC4_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : supporting combined 3-phase PWM mode ******/
#define IS_TIM_COMBINED3PHASEPWM_INSTANCE(__INSTANCE__) \
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : supporting OCxREF clear *******************/
#define IS_TIM_OCXREF_CLEAR_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : supporting external clock mode 1 for TIX inputs*/
#define IS_TIM_CLOCKSOURCE_TIX_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : supporting internal trigger inputs(ITRX) *******/
#define IS_TIM_CLOCKSOURCE_ITRX_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : at least 5 capture/compare channels *******/
#define IS_TIM_CC5_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8) )
/****************** TIM Instances : at least 6 capture/compare channels *******/
#define IS_TIM_CC6_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8))
/******************** TIM Instances : Advanced-control timers *****************/
#define IS_TIM_ADVANCED_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : supporting 2 break inputs *****************/
#define IS_TIM_BREAK_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8))
/******************* TIM Instances : Timer input XOR function *****************/
#define IS_TIM_XOR_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : DMA requests generation (UDE) *************/
#define IS_TIM_DMA_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM6) || \
((__INSTANCE__) == TIM7) || \
((__INSTANCE__) == TIM8))
/************ TIM Instances : DMA requests generation (CCxDE) *****************/
#define IS_TIM_DMA_CC_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/************ TIM Instances : DMA requests generation (COMDE) *****************/
#define IS_TIM_CCDMA_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/******************** TIM Instances : DMA burst feature ***********************/
#define IS_TIM_DMABURST_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****** TIM Instances : master mode available (TIMx_CR2.MMS available )********/
#define IS_TIM_MASTER_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM6) || \
((__INSTANCE__) == TIM7) || \
((__INSTANCE__) == TIM8) || \
((__INSTANCE__) == TIM13) || \
((__INSTANCE__) == TIM14))
/*********** TIM Instances : Slave mode available (TIMx_SMCR available )*******/
#define IS_TIM_SLAVE_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8) || \
((__INSTANCE__) == TIM9) || \
((__INSTANCE__) == TIM12))
/********************** TIM Instances : 32 bit Counter ************************/
#define IS_TIM_32B_COUNTER_INSTANCE(__INSTANCE__)(((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM5))
/***************** TIM Instances : external trigger input available ************/
#define IS_TIM_ETR_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM8))
/****************** TIM Instances : remapping capability **********************/
#define IS_TIM_REMAP_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM11))
/******************* TIM Instances : output(s) available **********************/
#define IS_TIM_CCX_INSTANCE(__INSTANCE__, __CHANNEL__) \
((((__INSTANCE__) == TIM1) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM2) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM3) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM4) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM5) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM8) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3) || \
((__CHANNEL__) == TIM_CHANNEL_4))) \
|| \
(((__INSTANCE__) == TIM9) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2))) \
|| \
(((__INSTANCE__) == TIM10) && \
(((__CHANNEL__) == TIM_CHANNEL_1))) \
|| \
(((__INSTANCE__) == TIM11) && \
(((__CHANNEL__) == TIM_CHANNEL_1))) \
|| \
(((__INSTANCE__) == TIM12) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2))) \
|| \
(((__INSTANCE__) == TIM13) && \
(((__CHANNEL__) == TIM_CHANNEL_1))) \
|| \
(((__INSTANCE__) == TIM14) && \
(((__CHANNEL__) == TIM_CHANNEL_1))))
/************ TIM Instances : complementary output(s) available ***************/
#define IS_TIM_CCXN_INSTANCE(__INSTANCE__, __CHANNEL__) \
((((__INSTANCE__) == TIM1) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3))) \
|| \
(((__INSTANCE__) == TIM8) && \
(((__CHANNEL__) == TIM_CHANNEL_1) || \
((__CHANNEL__) == TIM_CHANNEL_2) || \
((__CHANNEL__) == TIM_CHANNEL_3))))
/****************** TIM Instances : supporting ADC triggering through TRGO2 ***/
#define IS_TIM_TRGO2_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM8) )
/****************** TIM Instances : supporting synchronization ****************/
#define IS_TIM_SYNCHRO_INSTANCE(__INSTANCE__)\
(((__INSTANCE__) == TIM1) || \
((__INSTANCE__) == TIM2) || \
((__INSTANCE__) == TIM3) || \
((__INSTANCE__) == TIM4) || \
((__INSTANCE__) == TIM5) || \
((__INSTANCE__) == TIM6) || \
((__INSTANCE__) == TIM7) || \
((__INSTANCE__) == TIM8))
/******************** USART Instances : Synchronous mode **********************/
#define IS_USART_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == USART6))
/******************** UART Instances : Asynchronous mode **********************/
#define IS_UART_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == UART4) || \
((__INSTANCE__) == UART5) || \
((__INSTANCE__) == USART6) || \
((__INSTANCE__) == UART7) || \
((__INSTANCE__) == UART8))
/****************** UART Instances : Driver Enable *****************/
#define IS_UART_DRIVER_ENABLE_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == UART4) || \
((__INSTANCE__) == UART5) || \
((__INSTANCE__) == USART6) || \
((__INSTANCE__) == UART7) || \
((__INSTANCE__) == UART8))
/****************** UART Instances : Hardware Flow control ********************/
#define IS_UART_HWFLOW_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == UART4) || \
((__INSTANCE__) == UART5) || \
((__INSTANCE__) == USART6) || \
((__INSTANCE__) == UART7) || \
((__INSTANCE__) == UART8))
/********************* UART Instances : Smart card mode ***********************/
#define IS_SMARTCARD_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == USART6))
/*********************** UART Instances : IRDA mode ***************************/
#define IS_IRDA_INSTANCE(__INSTANCE__) (((__INSTANCE__) == USART1) || \
((__INSTANCE__) == USART2) || \
((__INSTANCE__) == USART3) || \
((__INSTANCE__) == UART4) || \
((__INSTANCE__) == UART5) || \
((__INSTANCE__) == USART6) || \
((__INSTANCE__) == UART7) || \
((__INSTANCE__) == UART8))
/****************************** IWDG Instances ********************************/
#define IS_IWDG_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == IWDG)
/****************************** WWDG Instances ********************************/
#define IS_WWDG_ALL_INSTANCE(__INSTANCE__) ((__INSTANCE__) == WWDG)
/******************************************************************************/
/* For a painless codes migration between the STM32F7xx device product */
/* lines, the aliases defined below are put in place to overcome the */
/* differences in the interrupt handlers and IRQn definitions. */
/* No need to update developed interrupt code when moving across */
/* product lines within the same STM32F7 Family */
/******************************************************************************/
/* Aliases for __IRQn */
#define HASH_RNG_IRQn RNG_IRQn
/* Aliases for __IRQHandler */
#define HASH_RNG_IRQHandler RNG_IRQHandler
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __STM32F765xx_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| netik/dc26_spqr_badge | sw/firmware/ChibiOS/os/common/ext/CMSIS/ST/STM32F7xx/stm32f765xx.h | C | apache-2.0 | 701,553 |
<extend name="Public/base"/>
<block name="body">
<!-- 标题栏 -->
<div class="main-title">
<h2>模型列表</h2>
</div>
<div class="tools">
<a class="btn" href="{:U('Model/add')}">新 增</a>
<button class="btn ajax-post" target-form="ids" url="{:U('Model/setStatus',array('status'=>1))}">启 用</button>
<button class="btn ajax-post" target-form="ids" url="{:U('Model/setStatus',array('status'=>0))}">禁 用</button>
<a class="btn" href="{:U('Model/generate')}">生 成</a>
<a class="btn" href="{:U('Model/add_comon_model')}" title="包括关键词、关键词类型、Token、发布时间等常用字段的模型">一键新增微信插件常用模型</a>
<a class="btn" href="{:U('Model/update_sql')}" title="更新所有插件里的install.sql和uninstall.sql文件,注:不会导出目标表里的测试数据">一键更新插件里的安装卸载sql文件</a>
<div class="search-form fr cf">
<div class="sleft">
<php> $search_url = U('index');</php>
<php>$search_key='title';</php>
<input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="请输入关键字">
<a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data-table">
<div class="data-table table-striped">
<table class="">
<thead>
<tr>
<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
<th class="">编号</th>
<th class="">标识</th>
<th class="">名称</th>
<th class="">所属插件</th>
<th class="">创建时间</th>
<th class="">状态</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
<notempty name="_list">
<volist name="_list" id="vo">
<tr>
<td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td>
<td>{$vo.id} </td>
<td>{$vo.name}</td>
<td><a data-id="{$vo.id}" href="{:U('model/edit?id='.$vo['id'])}#2">{$vo.title}</a></td>
<td>{$vo.addon}</td>
<td><span>{$vo.create_time|time_format}</span></td>
<td>{$vo.status_text}</td>
<td>
<a href="{:U('think/lists?model='.$vo['name'])}">数据</a>
<a href="{:U('model/setstatus?ids='.$vo['id'].'&status='.abs(1-$vo['status']))}" class="ajax-get">{$vo.status|show_status_op}</a>
<a href="{:U('model/edit?id='.$vo['id'])}#2">编辑</a>
<a href="{:U('model/del?ids='.$vo['id'])}" class="confirm ajax-get">删除</a>
<a href="{:U('model/export?type=0&id='.$vo['id'])}">导出安装文件</a>
<a href="{:U('model/export?type=1&id='.$vo['id'])}">导出卸载文件</a>
<a href="{:U('attribute/index?model_id='.$vo['id'])}">字段管理</a>
</td>
</tr>
</volist>
<else/>
<td colspan="7" class="text-center"> aOh! 暂时还没有内容! </td>
</notempty>
</tbody>
</table>
</div>
</div>
<div class="page">
{$_page}
</div>
</block>
<block name="script">
<script src="__STATIC__/thinkbox/jquery.thinkbox.js?v={:SITE_VERSION}"></script>
<script type="text/javascript">
$(function(){
//搜索功能
$("#search").click(function(){
var url = $(this).attr('url');
var query = $('.search-form').find('input').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if( url.indexOf('?')>0 ){
url += '&' + query;
}else{
url += '?' + query;
}
window.location.href = url;
});
//回车自动提交
$('.search-form').find('input').keyup(function(event){
if(event.keyCode===13){
$("#search").click();
}
});
//导航高亮
highlight_subnav('{:U('index')}');
})
</script>
</block>
| lovebull/wild_weiphp | Application/Admin/View/Model/index.html | HTML | apache-2.0 | 3,936 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.maven.packaging;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.camel.spi.Metadata;
import org.apache.camel.tooling.model.JsonMapper;
import org.apache.camel.tooling.model.MainModel;
import org.apache.camel.tooling.model.MainModel.MainGroupModel;
import org.apache.camel.tooling.util.JavadocHelper;
import org.apache.camel.tooling.util.PackageHelper;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.AnnotationSource;
import org.jboss.forge.roaster.model.source.FieldSource;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.MethodSource;
import org.sonatype.plexus.build.incremental.BuildContext;
/**
* Prepares camel-main by generating Camel Main configuration metadata for tooling support.
*/
@Mojo(name = "prepare-main-doc", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE)
public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
/**
* The output directory for generated spring boot tooling file
*/
@Parameter(defaultValue = "${project.basedir}/src/main/doc")
protected File outFolder;
/**
* Parses the Camel Main configuration java source file.
*/
public static List<MainModel.MainOptionModel> parseConfigurationSource(String fileName) throws IOException {
return parseConfigurationSource(new File(fileName));
}
/**
* Parses the Camel Main configuration java source file.
*/
public static List<MainModel.MainOptionModel> parseConfigurationSource(File file) throws IOException {
final List<MainModel.MainOptionModel> answer = new ArrayList<>();
JavaClassSource clazz = (JavaClassSource) Roaster.parse(file);
List<FieldSource<JavaClassSource>> fields = clazz.getFields();
// filter out final or static fields
fields = fields.stream().filter(f -> !f.isFinal() && !f.isStatic()).collect(Collectors.toList());
fields.forEach(f -> {
AnnotationSource as = f.getAnnotation(Metadata.class);
String name = f.getName();
String javaType = f.getType().getQualifiedName();
String sourceType = clazz.getQualifiedName();
String defaultValue = f.getStringInitializer();
if (as != null) {
defaultValue = as.getStringValue("defaultValue");
}
if (defaultValue != null && defaultValue.startsWith("new ")) {
// skip constructors
defaultValue = null;
}
// the field must have a setter
String setterName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
MethodSource<?> setter = clazz.getMethod(setterName, javaType);
if (setter != null) {
String desc = setter.getJavaDoc().getFullText();
boolean deprecated
= clazz.getAnnotation(Deprecated.class) != null || setter.getAnnotation(Deprecated.class) != null;
String type = fromMainToType(javaType);
MainModel.MainOptionModel model = new MainModel.MainOptionModel();
model.setName(name);
model.setType(type);
model.setJavaType(javaType);
model.setDescription(JavadocHelper.sanitizeDescription(desc, false));
model.setSourceType(sourceType);
model.setDefaultValue(asDefaultValue(type, defaultValue));
model.setDeprecated(deprecated);
List<String> enums = null;
// add known enums
if ("org.apache.camel.LoggingLevel".equals(javaType)) {
enums = Arrays.asList("ERROR,WARN,INFO,DEBUG,TRACE,OFF".split(","));
} else if ("org.apache.camel.ManagementStatisticsLevel".equals(javaType)) {
enums = Arrays.asList("Extended,Default,RoutesOnly,Off".split(","));
} else if ("org.apache.camel.spi.RestBindingMode".equals(javaType)) {
enums = Arrays.asList("auto,off,json,xml,json_xml".split(","));
} else if ("org.apache.camel.spi.RestHostNameResolver".equals(javaType)) {
enums = Arrays.asList("allLocalIp,localIp,localHostName".split(","));
} else if ("org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy".equals(javaType)) {
enums = Arrays.asList("Abort,CallerRuns,DiscardOldest,Discard".split(","));
}
if (enums == null && as != null) {
String text = as.getStringValue("enums");
if (text != null) {
enums = Arrays.asList(text.split(","));
}
}
model.setEnums(enums);
answer.add(model);
}
});
return answer;
}
private static String fromMainToType(String type) {
if ("boolean".equals(type) || "java.lang.Boolean".equals(type)) {
return "boolean";
} else if ("int".equals(type) || "java.lang.Integer".equals(type)) {
return "integer";
} else if ("long".equals(type) || "java.lang.Long".equals(type)) {
return "integer";
} else if ("float".equals(type) || "java.lang.Float".equals(type)) {
return "number";
} else if ("double".equals(type) || "java.lang.Double".equals(type)) {
return "number";
} else if ("string".equals(type) || "java.lang.String".equals(type)) {
return "string";
} else {
return "object";
}
}
private static Object asDefaultValue(String type, String defaultValue) {
if (defaultValue != null) {
if ("boolean".equals(type)) {
return Boolean.parseBoolean(defaultValue);
} else if ("integer".equals(type)) {
return Integer.parseInt(defaultValue);
}
}
return defaultValue;
}
@Override
public void execute(MavenProject project, MavenProjectHelper projectHelper, BuildContext buildContext)
throws MojoFailureException, MojoExecutionException {
outFolder = new File(project.getBasedir(), "src/generated/resources");
super.execute(project, projectHelper, buildContext);
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// scan for configuration files
File[] files = new File(project.getBasedir(), "src/main/java/org/apache/camel/main")
.listFiles(f -> f.isFile() && f.getName().endsWith("Properties.java"));
if (files == null || files.length == 0) {
return;
}
final List<MainModel.MainOptionModel> data = new ArrayList<>();
for (File file : files) {
getLog().info("Parsing Camel Main configuration file: " + file);
try {
List<MainModel.MainOptionModel> model = parseConfigurationSource(file);
// compute prefix for name
String prefix;
if (file.getName().contains("Hystrix")) {
prefix = "camel.hystrix.";
} else if (file.getName().contains("Resilience")) {
prefix = "camel.resilience4j.";
} else if (file.getName().contains("FaultTolerance")) {
prefix = "camel.faulttolerance.";
} else if (file.getName().contains("Rest")) {
prefix = "camel.rest.";
} else if (file.getName().contains("Health")) {
prefix = "camel.health.";
} else if (file.getName().contains("Lra")) {
prefix = "camel.lra.";
} else if (file.getName().contains("ThreadPoolProfileConfigurationProperties")) {
// skip this file
continue;
} else if (file.getName().contains("ThreadPoolConfigurationProperties")) {
prefix = "camel.threadpool.";
} else {
prefix = "camel.main.";
}
final String namePrefix = prefix;
model.forEach(m -> m.setName(namePrefix + m.getName()));
data.addAll(model);
} catch (Exception e) {
throw new MojoFailureException("Error parsing file " + file + " due " + e.getMessage(), e);
}
}
// include additional rest configuration from camel-api
File camelApiDir = PackageHelper.findCamelDirectory(project.getBasedir(), "core/camel-api");
File restConfig = new File(camelApiDir, "src/main/java/org/apache/camel/spi/RestConfiguration.java");
try {
List<MainModel.MainOptionModel> model = parseConfigurationSource(restConfig);
model.forEach(m -> m.setName("camel.rest." + m.getName()));
data.addAll(model);
} catch (Exception e) {
throw new MojoFailureException("Error parsing file " + restConfig + " due " + e.getMessage(), e);
}
// lets sort so they are always ordered (but camel.main in top)
data.sort((o1, o2) -> {
if (o1.getName().startsWith("camel.main.") && !o2.getName().startsWith("camel.main.")) {
return -1;
} else if (!o1.getName().startsWith("camel.main.") && o2.getName().startsWith("camel.main.")) {
return 1;
} else {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
if (!data.isEmpty()) {
MainModel model = new MainModel();
model.getOptions().addAll(data);
model.getGroups().add(new MainGroupModel(
"camel.main", "camel-main configurations.", "org.apache.camel.main.DefaultConfigurationProperties"));
model.getGroups()
.add(new MainGroupModel(
"camel.faulttolerance", "camel-fault-tolerance configurations.",
"org.apache.camel.main.FaultToleranceConfigurationProperties"));
model.getGroups().add(new MainGroupModel(
"camel.hystrix", "camel-hystrix configurations.", "org.apache.camel.main.HystrixConfigurationProperties"));
model.getGroups()
.add(new MainGroupModel(
"camel.resilience4j", "camel-resilience4j configurations.",
"org.apache.camel.main.Resilience4jConfigurationProperties"));
model.getGroups().add(
new MainGroupModel("camel.rest", "camel-rest configurations.", "org.apache.camel.spi.RestConfiguration"));
model.getGroups().add(new MainGroupModel(
"camel.health", "camel-health configurations.", "org.apache.camel.main.HealthConfigurationProperties"));
model.getGroups().add(new MainGroupModel(
"camel.lra", "camel-lra configurations.", "org.apache.camel.main.LraConfigurationProperties"));
model.getGroups()
.add(new MainGroupModel(
"camel.threadpool", "camel-threadpool configurations.",
"org.apache.camel.main.ThreadPoolConfigurationProperties"));
String json = JsonMapper.createJsonSchema(model);
updateResource(outFolder.toPath(), "META-INF/camel-main-configuration-metadata.json", json);
}
}
}
| adessaigne/camel | tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java | Java | apache-2.0 | 13,049 |
/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.analytics.financial.instrument.index;
import java.util.HashMap;
import java.util.Map;
import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.util.money.Currency;
/**
*
*/
public final class IndexPriceMaster {
/**
* The method unique instance.
*/
private static final IndexPriceMaster INSTANCE = new IndexPriceMaster();
/**
* Return the unique instance of the class.
* @return The instance.
*/
public static IndexPriceMaster getInstance() {
return INSTANCE;
}
/**
* The map with the list of Ibor Indexes and their conventions.
*/
private final Map<String, IndexPrice> _priceIndex;
/**
* Private constructor.
*/
private IndexPriceMaster() {
_priceIndex = new HashMap<>();
_priceIndex.put(
"EURHICP",
new IndexPrice("EUR HICP", Currency.EUR));
_priceIndex.put(
"UKRPI",
new IndexPrice("UK RPI", Currency.GBP));
_priceIndex.put(
"FRCPI",
new IndexPrice("FR CPI", Currency.EUR));
_priceIndex.put(
"USCPI",
new IndexPrice("US CPI", Currency.USD));
}
public IndexPrice getIndex(final String name) {
final IndexPrice indexNoCalendar = _priceIndex.get(name);
if (indexNoCalendar == null) {
throw new OpenGammaRuntimeException("Could not get Ibor index for " + name);
}
return new IndexPrice(indexNoCalendar.getName(), indexNoCalendar.getCurrency());
}
}
| jeorme/OG-Platform | projects/OG-Analytics/src/test/java/com/opengamma/analytics/financial/instrument/index/IndexPriceMaster.java | Java | apache-2.0 | 1,592 |
/** @file bson_db.h
This file contains the implementation of BSON-related methods that are required
by the MongoDB database server.
Normally, for standalone BSON usage, you do not want this file - it will tend to
pull in some other files from the MongoDB project. Thus, bson.h (the main file
one would use) does not include this file.
*/
/* Copyright 2009 10gen 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.
*/
#pragma once
#include "../util/optime.h"
#include "../util/time_support.h"
namespace mongo {
/**
Timestamps are a special BSON datatype that is used internally for replication.
Append a timestamp element to the object being ebuilt.
@param time - in millis (but stored in seconds)
*/
inline BSONObjBuilder& BSONObjBuilder::appendTimestamp( const StringData& fieldName , unsigned long long time , unsigned int inc ) {
OpTime t( (unsigned) (time / 1000) , inc );
appendTimestamp( fieldName , t.asDate() );
return *this;
}
inline OpTime BSONElement::_opTime() const {
if( type() == mongo::Date || type() == Timestamp )
return OpTime( *reinterpret_cast< const unsigned long long* >( value() ) );
return OpTime();
}
inline std::string BSONElement::_asCode() const {
switch( type() ) {
case mongo::String:
case Code:
return std::string(valuestr(), valuestrsize()-1);
case CodeWScope:
return std::string(codeWScopeCode(), *(int*)(valuestr())-1);
default:
log() << "can't convert type: " << (int)(type()) << " to code" << std::endl;
}
uassert( 10062 , "not code" , 0 );
return "";
}
inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(DateNowLabeler& id) {
_builder->appendDate(_fieldName, jsTime());
_fieldName = 0;
return *_builder;
}
inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(NullLabeler& id) {
_builder->appendNull(_fieldName);
_fieldName = 0;
return *_builder;
}
inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(MinKeyLabeler& id) {
_builder->appendMinKey(_fieldName);
_fieldName = 0;
return *_builder;
}
inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(MaxKeyLabeler& id) {
_builder->appendMaxKey(_fieldName);
_fieldName = 0;
return *_builder;
}
}
| TimMensch/mongo-cxx-driver | src/mongo/bson/bson_db.h | C | apache-2.0 | 3,011 |
/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.analytics.financial.interestrate.future.method;
import com.opengamma.analytics.financial.interestrate.InstrumentDerivative;
import com.opengamma.analytics.financial.interestrate.InterestRateCurveSensitivity;
import com.opengamma.analytics.financial.interestrate.YieldCurveBundle;
import com.opengamma.analytics.financial.interestrate.future.derivative.InterestRateFutureOptionPremiumTransaction;
import com.opengamma.analytics.financial.model.option.definition.YieldCurveWithBlackCubeBundle;
import com.opengamma.analytics.util.amount.SurfaceValue;
import com.opengamma.util.ArgumentChecker;
import com.opengamma.util.money.CurrencyAmount;
/**
* Method for the pricing of interest rate future options with up-front premium. The pricing is done with a Black approach on the future rate (1.0-price).
* The Black parameters are represented by (expiration-strike-delay) surfaces. The "delay" is the time between option expiration and future last trading date,
* i.e. 0 for quarterly options and x for x-year mid-curve options. The future prices are computed without convexity adjustments.
* @deprecated The parent class is deprecated
*/
@Deprecated
public final class InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod extends InterestRateFutureOptionPremiumTransactionMethod {
/** Calculates values for the security */
private static final InterestRateFutureOptionPremiumSecurityBlackSurfaceMethod SECURITY_METHOD = InterestRateFutureOptionPremiumSecurityBlackSurfaceMethod.getInstance();
/**
* Creates the method unique instance.
*/
private static final InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod INSTANCE = new InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod();
/**
* Return the method unique instance.
* @return The instance.
*/
public static InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod getInstance() {
return INSTANCE;
}
/**
* Constructor.
*/
private InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod() {
super(InterestRateFutureOptionPremiumSecurityBlackSurfaceMethod.getInstance());
}
@Override
public CurrencyAmount presentValue(final InstrumentDerivative instrument, final YieldCurveBundle curves) {
ArgumentChecker.isTrue(instrument instanceof InterestRateFutureOptionPremiumTransaction, "The instrument should be a InterestRateFutureOptionPremiumTransaction");
final InterestRateFutureOptionPremiumTransaction transaction = (InterestRateFutureOptionPremiumTransaction) instrument;
final double price = SECURITY_METHOD.optionPrice(transaction.getUnderlyingSecurity(), curves);
final double pvTransaction = presentValueFromPrice(transaction, curves, price);
return CurrencyAmount.of(transaction.getUnderlyingSecurity().getCurrency(), pvTransaction);
}
/**
* Computes the present value volatility sensitivity of a transaction.
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The present value curve sensitivity.
*/
public double vega(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
final double securitySensitivity = SECURITY_METHOD.optionPriceVega(transaction.getUnderlyingSecurity(), blackData);
final double txnSensitivity = securitySensitivity
* transaction.getQuantity()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor();
return txnSensitivity;
}
/**
* Computes the theta of a transaction.
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The theta.
*/
public double theta(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
final double securitySensitivity = SECURITY_METHOD.optionPriceTheta(transaction.getUnderlyingSecurity(), blackData);
final double txnSensitivity = securitySensitivity
* transaction.getQuantity()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor();
return txnSensitivity;
}
/**
* Computes the present value volatility sensitivity of a transaction.
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The present value curve sensitivity.
*/
public SurfaceValue presentValueBlackSensitivity(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
SurfaceValue securitySensitivity = ((InterestRateFutureOptionPremiumSecurityBlackSurfaceMethod) getSecurityMethod()).priceBlackSensitivity(transaction.getUnderlyingSecurity(), blackData);
securitySensitivity = SurfaceValue.multiplyBy(securitySensitivity, transaction.getQuantity() * transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor());
return securitySensitivity;
}
/**
* Computes the present value delta of a transaction.
* This is with respect to futures price
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The present value curve sensitivity.
*/
public double deltaWrtFuturesPrice(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
final double securityDelta = SECURITY_METHOD.optionPriceDelta(transaction.getUnderlyingSecurity(), blackData);
final double txnDelta = securityDelta
* transaction.getQuantity()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor();
return txnDelta;
}
/**
* Computes the present value delta of a transaction.
* This is with respect to futures price
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The present value curve sensitivity.
*/
public InterestRateCurveSensitivity deltaWrtCurve(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
final InterestRateCurveSensitivity securityDelta = SECURITY_METHOD.priceCurveSensitivity(transaction.getUnderlyingSecurity(), blackData);
final double scaleFactor = transaction.getQuantity() * transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor();
return securityDelta.multipliedBy(scaleFactor);
}
/**
* Computes the present value gamma of a transaction.
* This is with respect to either futures price, or rate=1-price
* @param transaction The future option transaction.
* @param blackData The curve and Black volatility data.
* @return The present value curve sensitivity.
*/
public double presentValueGamma(final InterestRateFutureOptionPremiumTransaction transaction, final YieldCurveWithBlackCubeBundle blackData) {
final double securityGamma = SECURITY_METHOD.optionPriceGamma(transaction.getUnderlyingSecurity(), blackData);
final double txnGamma = securityGamma
* transaction.getQuantity()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getNotional()
* transaction.getUnderlyingSecurity().getUnderlyingFuture().getPaymentAccrualFactor();
return txnGamma;
}
/**
* Interpolates on the Black Volatility Surface at expiry and strike of optionTransaction
* @param optionTransaction InterestRateFutureOptionPremiumTransaction
* @param curveBundle YieldCurveWithBlackSwaptionBundle
* @return Lognormal Implied Volatility
*/
public Double impliedVolatility(final InterestRateFutureOptionPremiumTransaction optionTransaction, final YieldCurveBundle curveBundle) {
ArgumentChecker.notNull(optionTransaction, "optionTransaction");
return SECURITY_METHOD.impliedVolatility(optionTransaction.getUnderlyingSecurity(), curveBundle);
}
}
| jeorme/OG-Platform | projects/OG-Analytics/src/main/java/com/opengamma/analytics/financial/interestrate/future/method/InterestRateFutureOptionPremiumTransactionBlackSurfaceMethod.java | Java | apache-2.0 | 8,543 |
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package preflight
import (
"bytes"
"fmt"
"io/ioutil"
"strings"
"testing"
"github.com/lithammer/dedent"
"github.com/pkg/errors"
"net/http"
"os"
"k8s.io/apimachinery/pkg/util/sets"
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
utilruntime "k8s.io/kubernetes/cmd/kubeadm/app/util/runtime"
"k8s.io/utils/exec"
fakeexec "k8s.io/utils/exec/testing"
)
var (
externalEtcdRootCAFileContent = dedent.Dedent(`
-----BEGIN CERTIFICATE-----
MIIFrjCCA5agAwIBAgIUJAM5bQz/Ann8qye8T7Uyl+cAt3wwDQYJKoZIhvcNAQEN
BQAwbzEOMAwGA1UEBhMFQ2hpbmExDzANBgNVBAgTBkhhaW5hbjEOMAwGA1UEBxMF
U2FueWExDTALBgNVBAoTBGV0Y2QxFjAUBgNVBAsTDWV0Y2Qgc2VjdXJpdHkxFTAT
BgNVBAMTDGV0Y2Qtcm9vdC1jYTAeFw0xNzAyMjIwNzEyMDBaFw0yMjAyMjEwNzEy
MDBaMG8xDjAMBgNVBAYTBUNoaW5hMQ8wDQYDVQQIEwZIYWluYW4xDjAMBgNVBAcT
BVNhbnlhMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIHNlY3VyaXR5MRUw
EwYDVQQDEwxldGNkLXJvb3QtY2EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK
AoICAQDD16VNTwvEvy1yd/vt8Eq2NwTw51mKHGYlZwsDqdqMEnEiWoJ7Iv9HZ+cl
jX0FnahKnaV76j3xPO73L5WOvRYxnZ8MvU/aBdDO+Tct4ht3m7TJaav6s55otjDy
dQNmlpBt4fFEB/nDozQaocfu2mqr5nyKJOjJpe+57Uw4h0LshreDOlzHEs8CkP6W
/B9yGFARVyz84YgVtemUX8WTB3cVU49KEYMCuhqXY8s97xSTGT/4Tq/MruKb2V+w
uUPjvyO5eIUcWetjBhgEGsS37NrsSFhoUNMp/PtIkth0LQoWb9sjnG069KIQqm61
1PKxH7jgLYLf4q455iAuTFr0lF1OcmICTeJB+GiS+3ubOb1TH3AYICXvQUniNWJx
sDz3qUUu4GLHk9wHtdNmX2FXYB8kHMZAidDM4Zw3IhZZap6n6BlGVVBV5h8sNM3t
SB+pDLuAaZLx3/ah2ds6AwkfaMdYDsE/MWcWQqzBfhOp758Mx3dF16IY+6IQp0RS
8qGKxgLDnTF9LgyHVOait2N/pT54faf8//ShSqTqzTK1wzHCkYwL6/B259zXWxeX
z4gOpQOk4rO4pgm/65QW9aKzHoQnpQ7lFQL2cdsKJv2tyC7pDfVrFy2uHWaUibbP
7pDw3OD8MQwR1TuhflK1AIicpMQe/kTAuRwH4fneeaGVdddBQQIDAQABo0IwQDAO
BgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUtoqcReNJ
p8z8Hz1/Q7XMK2fgi74wDQYJKoZIhvcNAQENBQADggIBADbh4HB//Gb0TUUEPoSw
VMJSUK1pb6KVTqAITSCKPwGT8KfCvVpUxEjh9J3dm1L8wbdr48yffdjhdl96cx2F
aGWdUIxRBIcpt5xvauBoj0OwfNcD5B9q1aKuh5XPNu4BndNeGw51vdJ8bJbtrZa8
wKWF/PHciCo/wlzE/YgsemHeY5bYeXawXVP/+ocoLH82Fb8Aq0Af3ZABiA6fmawz
FiZlnIrZnHVJYSap4yDhC/AQECXKY5gj7kjSnDebsIYds5OrW0D3LeRzs+q5nQXE
xR35qg834kxUULS8AywqmR3+zjfeymm2FtsjT/PuzEImA80y29qpLZIpPg0meKHF
pCMJkEHaRh4/JAinLaKCGLpnchqBy7CR6yvVnGkx93J0louIbVyUfn63R6mxCvd7
kL16a2xBMKgV4RDFcu+VYjbJTFdWOTGFrxPBmd/rLdwD3XNiwPtI0vXGM7I35DDP
SWwKVvR97F3uEnIQ1u8vHa1pNfQ1qSf/+hUJx2D9ypr7LTQ0LpLh1vUeTeUAVHmT
EEpcqzDg6lsqXw6KHJ55kd3QR/hRXd/Vr6EWUawDEnGjxyFVV2dTBbunsbSobNI4
eKV+60oCk3NMwrZoLw4Fv5qs2saS62dgJNfxbKqBX9ljSQxGzHjRwh+hVByCnG8m
Z9JkQayesM6D7uwbQJXd5rgy
-----END CERTIFICATE-----
`)
externalEtcdCertFileContent = dedent.Dedent(`
-----BEGIN CERTIFICATE-----
MIIGEjCCA/qgAwIBAgIURHJFslbPveA1WwQ4FaPJg1x6B8YwDQYJKoZIhvcNAQEN
BQAwbzEOMAwGA1UEBhMFQ2hpbmExDzANBgNVBAgTBkhhaW5hbjEOMAwGA1UEBxMF
U2FueWExDTALBgNVBAoTBGV0Y2QxFjAUBgNVBAsTDWV0Y2Qgc2VjdXJpdHkxFTAT
BgNVBAMTDGV0Y2Qtcm9vdC1jYTAeFw0xNzAyMjIwNzE0MDBaFw0yNzAyMjAwNzE0
MDBaMGwxDjAMBgNVBAYTBUNoaW5hMQ8wDQYDVQQIEwZIYWluYW4xDjAMBgNVBAcT
BVNhbnlhMQ0wCwYDVQQKEwRldGNkMRYwFAYDVQQLEw1ldGNkIHNlY3VyaXR5MRIw
EAYDVQQDEwlteS1ldGNkLTEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
AQCmCR4OSRrUCES90sUbj5tvjF24lPCMj7qP9MBUxcVvWfaJM12o4AxqBr8OThgd
lpNvlbKmRpfvbraXiDnuGty1vPa3z7RmKbwFgENfgKHz4fUw/MQ7CALOQ5PAvgf1
rQ6Ii4cr49nWctpQmBXHtZRjvquBYnw70KrWfQ121DwPYy7cb/StuHLsTgqsgzhl
ECILWCj9GNqcGQr5+ZvwUxa2yam2CS1M+PLbB6HxX/4RBBTWKAt8+kjt6TxxMaSE
bNDHNDLWzQSpxg5qTLOQtrubFD4O3JT2E8DEj+LvXJKH7pJd1Z+r0m3ymQvBAIXr
6OJs+sHbaaxKWS35k9m88NRojR+r5KPoEcBgxhtBtXUfMS5v5dTtcNsHl/mHmTC+
gWiqpzA+tF55uUEWhRoA+pN7Ie2PviRhG43t99l7bsHVnrxZQqWsWlvCxMN1c2+7
PRwhsYZFITyKcMSvd19Nb5HGc5hT7btZlWc2xKS2YNnDXbD8C5SdxZek5Cb/xRxL
T8taf2c1bHs8sZrzIK2DCGvaN3471WEnmaCuRWr2fqyJeCPwsvvWeNDVmgPP6v7g
ncyy+4QyyfNrdURTZFyw81ZbCiznPc070u7vtIYt3Sa0NXd0oEG1ybAZwBIYhMOY
5ctepJLf7QxHXR70RdI0ksHEmZGZ1igk7gzhmHEgQM87pQIDAQABo4GoMIGlMA4G
A1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYD
VR0TAQH/BAIwADAdBgNVHQ4EFgQU0U/Zn4mc95UXm+LVO67wqJpL9gIwHwYDVR0j
BBgwFoAUtoqcReNJp8z8Hz1/Q7XMK2fgi74wJgYDVR0RBB8wHYIJbG9jYWxob3N0
hwR/AAABhwQKcjPGhwQKcgwwMA0GCSqGSIb3DQEBDQUAA4ICAQCikW5SNpndBxEz
qblER72KkfSEXMFhQry3RZJeAw6rQiOl+PMJqMnylcepOAUrNi20emS270dQDh3z
Hw/JBgKftZ1JrjbF9NF4oFUZcFUKmTgyWYnhLH0BskgwJf2u+DpugFa4U8niQf15
ciZGoUfWCGOJbgVP7esdnyhH/P/DpOEObWf8vOfvfQ49r7MzATyzMESyJjdtAH/F
c5JKACxpJhaYfTZ78F43jSw0vswBdLQ7fJWqg/sJBlTG0GBFJcEJzFVpwzYUxwZ4
rUpAn4A02M2V9XDNlptrWvcQz/5Vs/aCmehz7GOiMJB6SLWcMSpJRLMqoJjaFVfO
OPm7bWMMaVOUPedzvcBKRXmEAg7HQnm3ibkVNjTW8Hr66n34Yk/dO9WXD+6IXnOQ
bMY+Mf9vpIsscSpGTO15sAKqiXCzHR9RWqNd4U3jvo3JtewkNMhIKzPThgYNfsO3
7HSrlfffeEQKc59rDUaC3Y9YSc5ERJRMC+mdOqXNMy2iedZnNEsmgYlaVDg6xfG8
65w9UkMOe+DTJtMHnMxP4rT6WE4cKysQeSYxkyo/jh+8rKEy9+AyuEntJAknABUc
N5mizdYu8nrtiSu9jdLKhwO41gC2IlXPUHizylo6g24RFVBjHLlzYAAsVMMMSQW1
XRMVQjawUTknbAgHuE7/rEX8c27WUA==
-----END CERTIFICATE-----
`)
externalEtcdKeyFileContent = dedent.Dedent(`
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEApgkeDkka1AhEvdLFG4+bb4xduJTwjI+6j/TAVMXFb1n2iTNd
qOAMaga/Dk4YHZaTb5WypkaX7262l4g57hrctbz2t8+0Zim8BYBDX4Ch8+H1MPzE
OwgCzkOTwL4H9a0OiIuHK+PZ1nLaUJgVx7WUY76rgWJ8O9Cq1n0NdtQ8D2Mu3G/0
rbhy7E4KrIM4ZRAiC1go/RjanBkK+fmb8FMWtsmptgktTPjy2weh8V/+EQQU1igL
fPpI7ek8cTGkhGzQxzQy1s0EqcYOakyzkLa7mxQ+DtyU9hPAxI/i71ySh+6SXdWf
q9Jt8pkLwQCF6+jibPrB22msSlkt+ZPZvPDUaI0fq+Sj6BHAYMYbQbV1HzEub+XU
7XDbB5f5h5kwvoFoqqcwPrReeblBFoUaAPqTeyHtj74kYRuN7ffZe27B1Z68WUKl
rFpbwsTDdXNvuz0cIbGGRSE8inDEr3dfTW+RxnOYU+27WZVnNsSktmDZw12w/AuU
ncWXpOQm/8UcS0/LWn9nNWx7PLGa8yCtgwhr2jd+O9VhJ5mgrkVq9n6siXgj8LL7
1njQ1ZoDz+r+4J3MsvuEMsnza3VEU2RcsPNWWwos5z3NO9Lu77SGLd0mtDV3dKBB
tcmwGcASGITDmOXLXqSS3+0MR10e9EXSNJLBxJmRmdYoJO4M4ZhxIEDPO6UCAwEA
AQKCAgEAmr3OlDPP3CLkpiFEcJ5TmA+y3S96TRY7IqVRhvBXRKMMoOwNczF0gHBP
Ka7gzNqkCA/1UwBh49VEOU/N5bqFTp+RNNhQYhKtWFck82H4Dkrd8EzzOa0KqF/U
2YKB+pbR/7JCRUZypGmgTBKh4eG6LYfrYYd/D2Q3g/VCUigU3aZrayiwWiOYf+Fw
Ez2slowFnpsIgHHkdCzmzPi0O7PEbJDgKXa+EInIFRg09renGwa5wKnLoyvEQm7o
VPqWQJEFt1JPu1+R5ARhNPLNO6cCi9K+z60G65yXQNp0/u5A5o0TPn609DcHH11B
1ht9tNL0C+tcNvhyiUw6C+uet3egDVu1TqptzAfb2Y3MQK6UV/by7KJxcFxBAzWl
UQ4zDaQzCcU81T92zI+XeRSJuCPuOL61mH7zEiPZZPOLV8MbxBX/7lj+IJTBL+vJ
Idq7Nn/+LRtuSy5PH2MzZ5DzIMmjkjQ/ScpzAr9Zpkm3dpTcGTpFV0uqHseE77Re
55tz9uB7pxV1n6Gz4uMNnsioEYsFIRfzst4QWDdaQqcYJQuKvW9pXNmgRgSCIlft
54DxQ98a1PVFmS40TT9mjUg0P66m+8bk5vEb58iAjoYJRcoriZhlT6cOcuPW6hos
3PfA2gMXuWu61mAjzdP0zbzNBXCn5nRppqLNmWMVZCI0nLjmyZUCggEBAMEpCQu9
cRWc/GjvmnfXHewvqQHu3A3J1HCLR0VqJo8rcIIvhSe7dPRAMtUFxV1R2eOfMvSZ
Y4y69tMHZPVTgnp2t5TSavjpMqSQLvXyBkgL8FnGEl5l6HEQTm8y0C13Cm+CUB5a
uxQnQflkX539SjWX0XdOmYuLORmrKGxgcDOd9652fDJcFSXYa0mx6KN2JZHh9psA
9ldHhUIq1ngoVnrctlK53MptckPrFwMFdXRCKiMfkvpUkXTeXu4D7Z1VNh2V/3gF
lmRNioXaxp7W8omBSQlwaHY5btPj5jktiC9/so4ORqJjHvbCURrIvdkPPaXi/YJy
HdoOgHYFnn3p6M8CggEBANwNDtdbHWwwVC7Op6TNc8qK+SWAId5RqPOmM70XBVvg
u9nxT7a5vmRTs81fcVoxtE0t+KWIfOXquxqTbk0ONqIsl2CLTiTFaNHoHlvwgFBT
aYukORiGILIzOJr82RPugAw1+j8jmw3OsCOXnf2odGs+oC/V9vEd9NyZpDHPohtK
a8Bk8p326mQam23ArUesIqnw31fG22KRpoLXuk/9nNcAAAZd1Qd9hGWf0HHxunXB
wj6e3VTm0G4NPTli5vmVavYRPMFUUJpU5lwTHhlrHTSmANHTjZGnn0mEOfIrfodF
ODwJjwoyq4rPls0fqOvyAyBCnhop4fC8yOd4cQcLSUsCggEAbv9Br3lhLmZTtYla
XltDWqHYoL+9vD6q0TF39y+UkNkJggYEolxaTLFHhJoYXBPY/bBR+7TZO9mEVKf/
H+qpI+5seByiU/7NlzszgSle6q/RogTsMUqmU7JnIAc3EalCWemsWIUS0/XrN4Cy
YXtX1Yw0VjbYjROn8FQmmoCgeUjhN2Pm4pl/nYvLu0F8ydHurPIIX/IhnO4AaZFs
RQgJCfki3E7pzXkvHFBPnPDaGcCbritKrodCPsI6EtQ3Cx4YRtAXScUMMv9MBrc9
Q7GJFfMxITdzD9zZDvH7Lgg4JfNfi7owZMhI1su7B4UrczwK1PSncPpapR+IOkno
VbrAiQKCAQB2xGV6PqdGuV72VHuPK4SPkSqf3uRoxdJWjyHlsQMnb8hz/RZ1HRNx
uuuUsSrQ73rNHT7SuTQQM/0AfwpNdJpwNXkOlqF6n0HP6WRZYxkeQab5w409e0cy
ZwrqPAY+B7/81zVV1rXdYe0XiMGxIraTG54Bs44w3WZHmnVQnSx1Zll54gJA1//y
P5ocRp4/zNx4tJUXHzFRpiMlA6J/gfag5FMfHI3aGRjYcMVken+VBxr8CWqUZG+i
tmqRCpx3oPm2Dd+oyQUoByK+F2NrfLCqtd5DYddLAhmq6D8OQgNspyOO4+ncKzUD
Gr/dvnTBxEGDq/EBVhGoiXw10n/OuXy5AoIBAAUAoTyt4gQjjC0ddtMLN7+R1Ymp
eNULpq2XTvidj7jaysIW9Q52ncvN6h2Vds/Z3Ujvdne2jMq7Q/C96fKcrhgMH9ca
ADGLWtD+VkP4NgFjj7R2jabF8d9IQdJDXAgvR/kokojF0RsJuvD2hawN6lQkkj6S
fNNGMBk4sGyt7gzAn3iO4Zoy+QjtALNnZcaH6s7oIg3UKf6OwskiBB60Q5P1U3/E
RPtTxhex3jFuySNJ413JgyGkvcP+qjuzi6eyVDxkfiyNohQYGuZ8rieFX7QfQFAY
TIXptchVUTxmGKWzcpLC3AfkwFvV2IPoMk8YnDSp270D30cqWiI9puSEcxQ=
-----END RSA PRIVATE KEY-----
`)
)
type preflightCheckTest struct {
msg string
}
func (pfct preflightCheckTest) Name() string {
return "preflightCheckTest"
}
func (pfct preflightCheckTest) Check() (warning, errorList []error) {
if pfct.msg == "warning" {
return []error{errors.New("warning")}, nil
}
if pfct.msg != "" {
return nil, []error{errors.New("fake error")}
}
return
}
func TestRunInitNodeChecks(t *testing.T) {
var tests = []struct {
name string
cfg *kubeadmapi.InitConfiguration
expected bool
isSecondaryControlPlane bool
downloadCerts bool
}{
{name: "Test valid advertised address",
cfg: &kubeadmapi.InitConfiguration{
LocalAPIEndpoint: kubeadmapi.APIEndpoint{AdvertiseAddress: "foo"},
},
expected: false,
},
{
name: "Test CA file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CAFile: "/foo"}},
},
},
expected: false,
},
{
name: "Skip test CA file exists if specified/download certs",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CAFile: "/foo"}},
},
},
expected: true,
isSecondaryControlPlane: true,
downloadCerts: true,
},
{
name: "Test Cert file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CertFile: "/foo"}},
},
},
expected: false,
},
{
name: "Test Key file exists if specified",
cfg: &kubeadmapi.InitConfiguration{
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CertFile: "/foo"}},
},
},
expected: false,
},
{
cfg: &kubeadmapi.InitConfiguration{
LocalAPIEndpoint: kubeadmapi.APIEndpoint{AdvertiseAddress: "2001:1234::1:15"},
},
expected: false,
},
}
for _, rt := range tests {
// TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString(), rt.isSecondaryControlPlane, rt.downloadCerts)
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
rt.expected,
(actual == nil),
actual,
)
}
}
}
func TestRunJoinNodeChecks(t *testing.T) {
var tests = []struct {
cfg *kubeadmapi.JoinConfiguration
expected bool
}{
{
cfg: &kubeadmapi.JoinConfiguration{},
expected: false,
},
{
cfg: &kubeadmapi.JoinConfiguration{
Discovery: kubeadmapi.Discovery{
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
APIServerEndpoint: "192.168.1.15",
},
},
},
expected: false,
},
{
cfg: &kubeadmapi.JoinConfiguration{
Discovery: kubeadmapi.Discovery{
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
APIServerEndpoint: "2001:1234::1:15",
},
},
},
expected: false,
},
}
for _, rt := range tests {
actual := RunJoinNodeChecks(exec.New(), rt.cfg, sets.NewString())
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunJoinNodeChecks:\n\texpected: %t\n\t actual: %t",
rt.expected,
(actual != nil),
)
}
}
}
func TestRunChecks(t *testing.T) {
var tokenTest = []struct {
p []Checker
expected bool
output string
}{
{[]Checker{}, true, ""},
{[]Checker{preflightCheckTest{"warning"}}, true, "\t[WARNING preflightCheckTest]: warning\n"}, // should just print warning
{[]Checker{preflightCheckTest{"error"}}, false, ""},
{[]Checker{preflightCheckTest{"test"}}, false, ""},
{[]Checker{DirAvailableCheck{Path: "/does/not/exist"}}, true, ""},
{[]Checker{DirAvailableCheck{Path: "/"}}, false, ""},
{[]Checker{FileAvailableCheck{Path: "/does/not/exist"}}, true, ""},
{[]Checker{FileContentCheck{Path: "/does/not/exist"}}, false, ""},
{[]Checker{FileContentCheck{Path: "/"}}, true, ""},
{[]Checker{FileContentCheck{Path: "/", Content: []byte("does not exist")}}, false, ""},
{[]Checker{InPathCheck{executable: "foobarbaz", exec: exec.New()}}, true, "\t[WARNING FileExisting-foobarbaz]: foobarbaz not found in system path\n"},
{[]Checker{InPathCheck{executable: "foobarbaz", mandatory: true, exec: exec.New()}}, false, ""},
{[]Checker{InPathCheck{executable: "foobar", mandatory: false, exec: exec.New(), suggestion: "install foobar"}}, true, "\t[WARNING FileExisting-foobar]: foobar not found in system path\nSuggestion: install foobar\n"},
}
for _, rt := range tokenTest {
buf := new(bytes.Buffer)
actual := RunChecks(rt.p, buf, sets.NewString())
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunChecks:\n\texpected: %t\n\t actual: %t",
rt.expected,
(actual == nil),
)
}
if buf.String() != rt.output {
t.Errorf(
"failed RunChecks:\n\texpected: %s\n\t actual: %s",
rt.output,
buf.String(),
)
}
}
}
func TestConfigRootCAs(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-cafile")
if err != nil {
t.Errorf("failed configRootCAs:\n\texpected: succeed creating temp CA file\n\tactual:%v", err)
}
defer os.Remove(f.Name())
if err := ioutil.WriteFile(f.Name(), []byte(externalEtcdRootCAFileContent), 0644); err != nil {
t.Errorf("failed configRootCAs:\n\texpected: succeed writing contents to temp CA file %s\n\tactual:%v", f.Name(), err)
}
c := ExternalEtcdVersionCheck{Etcd: kubeadmapi.Etcd{External: &kubeadmapi.ExternalEtcd{CAFile: f.Name()}}}
config, err := c.configRootCAs(nil)
if err != nil {
t.Errorf(
"failed configRootCAs:\n\texpected: has no error\n\tactual:%v",
err,
)
}
if config.RootCAs == nil {
t.Errorf(
"failed configRootCAs:\n\texpected: RootCAs not equal to nil\n\tactual:%v",
config.RootCAs,
)
}
}
func TestConfigCertAndKey(t *testing.T) {
certFile, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-certfile")
if err != nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: succeed creating temp CertFile file\n\tactual:%v",
err,
)
}
defer os.Remove(certFile.Name())
if err := ioutil.WriteFile(certFile.Name(), []byte(externalEtcdCertFileContent), 0644); err != nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: succeed writing contents to temp CertFile file %s\n\tactual:%v",
certFile.Name(),
err,
)
}
keyFile, err := ioutil.TempFile(os.TempDir(), "kubeadm-external-etcd-test-keyfile")
if err != nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: succeed creating temp KeyFile file\n\tactual:%v",
err,
)
}
defer os.Remove(keyFile.Name())
if err := ioutil.WriteFile(keyFile.Name(), []byte(externalEtcdKeyFileContent), 0644); err != nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: succeed writing contents to temp KeyFile file %s\n\tactual:%v",
keyFile.Name(),
err,
)
}
c := ExternalEtcdVersionCheck{
Etcd: kubeadmapi.Etcd{
External: &kubeadmapi.ExternalEtcd{
CertFile: certFile.Name(),
KeyFile: keyFile.Name(),
},
},
}
config, err := c.configCertAndKey(nil)
if err != nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: has no error\n\tactual:%v",
err,
)
}
if config.Certificates == nil {
t.Errorf(
"failed configCertAndKey:\n\texpected: Certificates not equal to nil\n\tactual:%v",
config.Certificates,
)
}
}
func TestKubernetesVersionCheck(t *testing.T) {
var tests = []struct {
check KubernetesVersionCheck
expectWarnings bool
}{
{
check: KubernetesVersionCheck{
KubeadmVersion: "v1.6.6", //Same version
KubernetesVersion: "v1.6.6",
},
expectWarnings: false,
},
{
check: KubernetesVersionCheck{
KubeadmVersion: "v1.6.6", //KubernetesVersion version older than KubeadmVersion
KubernetesVersion: "v1.5.5",
},
expectWarnings: false,
},
{
check: KubernetesVersionCheck{
KubeadmVersion: "v1.6.6", //KubernetesVersion newer than KubeadmVersion, within the same minor release (new patch)
KubernetesVersion: "v1.6.7",
},
expectWarnings: false,
},
{
check: KubernetesVersionCheck{
KubeadmVersion: "v1.6.6", //KubernetesVersion newer than KubeadmVersion, in a different minor/in pre-release
KubernetesVersion: "v1.7.0-alpha.0",
},
expectWarnings: true,
},
{
check: KubernetesVersionCheck{
KubeadmVersion: "v1.6.6", //KubernetesVersion newer than KubeadmVersion, in a different minor/stable
KubernetesVersion: "v1.7.0",
},
expectWarnings: true,
},
{
check: KubernetesVersionCheck{
KubeadmVersion: "v0.0.0", //"super-custom" builds - Skip this check
KubernetesVersion: "v1.7.0",
},
expectWarnings: false,
},
}
for _, rt := range tests {
warning, _ := rt.check.Check()
if (warning != nil) != rt.expectWarnings {
t.Errorf(
"failed KubernetesVersionCheck:\n\texpected: %t\n\t actual: %t (KubeadmVersion:%s, KubernetesVersion: %s)",
rt.expectWarnings,
(warning != nil),
rt.check.KubeadmVersion,
rt.check.KubernetesVersion,
)
}
}
}
func TestHTTPProxyCIDRCheck(t *testing.T) {
var tests = []struct {
check HTTPProxyCIDRCheck
expectWarnings bool
}{
{
check: HTTPProxyCIDRCheck{
Proto: "https",
CIDR: "127.0.0.0/8",
}, // Loopback addresses never should produce proxy warnings
expectWarnings: false,
},
{
check: HTTPProxyCIDRCheck{
Proto: "https",
CIDR: "10.96.0.0/12",
}, // Expected to be accessed directly, we set NO_PROXY to 10.0.0.0/8
expectWarnings: false,
},
{
check: HTTPProxyCIDRCheck{
Proto: "https",
CIDR: "192.168.0.0/16",
}, // Expected to go via proxy as this range is not listed in NO_PROXY
expectWarnings: true,
},
{
check: HTTPProxyCIDRCheck{
Proto: "https",
CIDR: "2001:db8::/56",
}, // Expected to be accessed directly, part of 2001:db8::/48 in NO_PROXY
expectWarnings: false,
},
{
check: HTTPProxyCIDRCheck{
Proto: "https",
CIDR: "2001:db8:1::/56",
}, // Expected to go via proxy, range is not in 2001:db8::/48
expectWarnings: true,
},
}
// Save current content of *_proxy and *_PROXY variables.
savedEnv := resetProxyEnv(t)
defer restoreEnv(savedEnv)
for _, rt := range tests {
warning, _ := rt.check.Check()
if (warning != nil) != rt.expectWarnings {
t.Errorf(
"failed HTTPProxyCIDRCheck:\n\texpected: %t\n\t actual: %t (CIDR:%s). Warnings: %v",
rt.expectWarnings,
(warning != nil),
rt.check.CIDR,
warning,
)
}
}
}
func TestHTTPProxyCheck(t *testing.T) {
var tests = []struct {
name string
check HTTPProxyCheck
expectWarnings bool
}{
{
name: "Loopback address",
check: HTTPProxyCheck{
Proto: "https",
Host: "127.0.0.1",
}, // Loopback addresses never should produce proxy warnings
expectWarnings: false,
},
{
name: "IPv4 direct access",
check: HTTPProxyCheck{
Proto: "https",
Host: "10.96.0.1",
}, // Expected to be accessed directly, we set NO_PROXY to 10.0.0.0/8
expectWarnings: false,
},
{
name: "IPv4 via proxy",
check: HTTPProxyCheck{
Proto: "https",
Host: "192.168.0.1",
}, // Expected to go via proxy as this range is not listed in NO_PROXY
expectWarnings: true,
},
{
name: "IPv6 direct access",
check: HTTPProxyCheck{
Proto: "https",
Host: "[2001:db8::1:15]",
}, // Expected to be accessed directly, part of 2001:db8::/48 in NO_PROXY
expectWarnings: false,
},
{
name: "IPv6 via proxy",
check: HTTPProxyCheck{
Proto: "https",
Host: "[2001:db8:1::1:15]",
}, // Expected to go via proxy, range is not in 2001:db8::/48
expectWarnings: true,
},
{
name: "IPv6 direct access, no brackets",
check: HTTPProxyCheck{
Proto: "https",
Host: "2001:db8::1:15",
}, // Expected to be accessed directly, part of 2001:db8::/48 in NO_PROXY
expectWarnings: false,
},
{
name: "IPv6 via proxy, no brackets",
check: HTTPProxyCheck{
Proto: "https",
Host: "2001:db8:1::1:15",
}, // Expected to go via proxy, range is not in 2001:db8::/48
expectWarnings: true,
},
}
// Save current content of *_proxy and *_PROXY variables.
savedEnv := resetProxyEnv(t)
defer restoreEnv(savedEnv)
for _, rt := range tests {
warning, _ := rt.check.Check()
if (warning != nil) != rt.expectWarnings {
t.Errorf(
"%s failed HTTPProxyCheck:\n\texpected: %t\n\t actual: %t (Host:%s). Warnings: %v",
rt.name,
rt.expectWarnings,
(warning != nil),
rt.check.Host,
warning,
)
}
}
}
// resetProxyEnv is helper function that unsets all *_proxy variables
// and return previously set values as map. This can be used to restore
// original state of the environment.
func resetProxyEnv(t *testing.T) map[string]string {
savedEnv := make(map[string]string)
for _, e := range os.Environ() {
pair := strings.Split(e, "=")
if strings.HasSuffix(strings.ToLower(pair[0]), "_proxy") {
savedEnv[pair[0]] = pair[1]
os.Unsetenv(pair[0])
}
}
t.Log("Saved environment: ", savedEnv)
os.Setenv("HTTP_PROXY", "http://proxy.example.com:3128")
os.Setenv("NO_PROXY", "example.com,10.0.0.0/8,2001:db8::/48")
// Check if we can reliably execute tests:
// ProxyFromEnvironment caches the *_proxy environment variables and
// if ProxyFromEnvironment already executed before our test with empty
// HTTP_PROXY it will make these tests return false positive failures
req, err := http.NewRequest("GET", "http://host.fake.tld/", nil)
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
proxy, err := http.ProxyFromEnvironment(req)
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
if proxy == nil {
t.Skip("test skipped as ProxyFromEnvironment already initialized in environment without defined HTTP proxy")
}
t.Log("http.ProxyFromEnvironment is usable, continue executing test")
return savedEnv
}
// restoreEnv is helper function to restores values
// of environment variables from saved state in the map
func restoreEnv(e map[string]string) {
for k, v := range e {
os.Setenv(k, v)
}
}
func TestKubeletVersionCheck(t *testing.T) {
// TODO: Re-enable this test
// fakeexec.FakeCmd supports only combined output.
// Hence .Output() returns a "not supported" error and we cannot use it for the test ATM.
t.Skip()
cases := []struct {
kubeletVersion string
k8sVersion string
expectErrors bool
expectWarnings bool
}{
{"v" + constants.CurrentKubernetesVersion.WithPatch(2).String(), "", false, false}, // check minimally supported version when there is no information about control plane
{"v1.11.3", "v1.11.8", true, false}, // too old kubelet (older than kubeadmconstants.MinimumKubeletVersion), should fail.
{"v" + constants.MinimumKubeletVersion.String(), constants.MinimumControlPlaneVersion.WithPatch(5).String(), false, false}, // kubelet within same major.minor as control plane
{"v" + constants.MinimumKubeletVersion.WithPatch(5).String(), constants.MinimumControlPlaneVersion.WithPatch(1).String(), false, false}, // kubelet is newer, but still within same major.minor as control plane
{"v" + constants.MinimumKubeletVersion.String(), constants.CurrentKubernetesVersion.WithPatch(1).String(), false, false}, // kubelet is lower than control plane, but newer than minimally supported
{"v" + constants.CurrentKubernetesVersion.WithPreRelease("alpha.1").String(), constants.MinimumControlPlaneVersion.WithPatch(1).String(), true, false}, // kubelet is newer (development build) than control plane, should fail.
{"v" + constants.CurrentKubernetesVersion.String(), constants.MinimumControlPlaneVersion.WithPatch(5).String(), true, false}, // kubelet is newer (release) than control plane, should fail.
}
for _, tc := range cases {
t.Run(tc.kubeletVersion, func(t *testing.T) {
fcmd := fakeexec.FakeCmd{
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
func() ([]byte, error) { return []byte("Kubernetes " + tc.kubeletVersion), nil },
},
}
fexec := &fakeexec.FakeExec{
CommandScript: []fakeexec.FakeCommandAction{
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
},
}
check := KubeletVersionCheck{KubernetesVersion: tc.k8sVersion, exec: fexec}
warnings, errors := check.Check()
switch {
case warnings != nil && !tc.expectWarnings:
t.Errorf("KubeletVersionCheck: unexpected warnings for kubelet version %q and Kubernetes version %q. Warnings: %v", tc.kubeletVersion, tc.k8sVersion, warnings)
case warnings == nil && tc.expectWarnings:
t.Errorf("KubeletVersionCheck: expected warnings for kubelet version %q and Kubernetes version %q but got nothing", tc.kubeletVersion, tc.k8sVersion)
case errors != nil && !tc.expectErrors:
t.Errorf("KubeletVersionCheck: unexpected errors for kubelet version %q and Kubernetes version %q. errors: %v", tc.kubeletVersion, tc.k8sVersion, errors)
case errors == nil && tc.expectErrors:
t.Errorf("KubeletVersionCheck: expected errors for kubelet version %q and Kubernetes version %q but got nothing", tc.kubeletVersion, tc.k8sVersion)
}
})
}
}
func TestSetHasItemOrAll(t *testing.T) {
var tests = []struct {
ignoreSet sets.String
testString string
expectedResult bool
}{
{sets.NewString(), "foo", false},
{sets.NewString("all"), "foo", true},
{sets.NewString("all", "bar"), "foo", true},
{sets.NewString("bar"), "foo", false},
{sets.NewString("baz", "foo", "bar"), "foo", true},
{sets.NewString("baz", "bar", "foo"), "Foo", true},
}
for _, rt := range tests {
t.Run(rt.testString, func(t *testing.T) {
result := setHasItemOrAll(rt.ignoreSet, rt.testString)
if result != rt.expectedResult {
t.Errorf(
"setHasItemOrAll: expected: %v actual: %v (arguments: %q, %q)",
rt.expectedResult, result,
rt.ignoreSet,
rt.testString,
)
}
})
}
}
func TestImagePullCheck(t *testing.T) {
fcmd := fakeexec.FakeCmd{
RunScript: []fakeexec.FakeRunAction{
// Test case 1: img1 and img2 exist, img3 doesn't exist
func() ([]byte, []byte, error) { return nil, nil, nil },
func() ([]byte, []byte, error) { return nil, nil, nil },
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
// Test case 2: images don't exist
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
},
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
// Test case1: pull only img3
func() ([]byte, error) { return nil, nil },
// Test case 2: fail to pull image2 and image3
func() ([]byte, error) { return nil, nil },
func() ([]byte, error) { return []byte("error"), &fakeexec.FakeExitError{Status: 1} },
func() ([]byte, error) { return []byte("error"), &fakeexec.FakeExitError{Status: 1} },
},
}
fexec := fakeexec.FakeExec{
CommandScript: []fakeexec.FakeCommandAction{
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
},
LookPathFunc: func(cmd string) (string, error) { return "/usr/bin/docker", nil },
}
containerRuntime, err := utilruntime.NewContainerRuntime(&fexec, constants.DefaultDockerCRISocket)
if err != nil {
t.Errorf("unexpected NewContainerRuntime error: %v", err)
}
check := ImagePullCheck{
runtime: containerRuntime,
imageList: []string{"img1", "img2", "img3"},
}
warnings, errors := check.Check()
if len(warnings) != 0 {
t.Fatalf("did not expect any warnings but got %q", warnings)
}
if len(errors) != 0 {
t.Fatalf("expected 1 errors but got %d: %q", len(errors), errors)
}
warnings, errors = check.Check()
if len(warnings) != 0 {
t.Fatalf("did not expect any warnings but got %q", warnings)
}
if len(errors) != 2 {
t.Fatalf("expected 2 errors but got %d: %q", len(errors), errors)
}
}
func TestNumCPUCheck(t *testing.T) {
var tests = []struct {
numCPU int
numErrors int
numWarnings int
}{
{0, 0, 0},
{999999999, 1, 0},
}
for _, rt := range tests {
t.Run(fmt.Sprintf("number of CPUs: %d", rt.numCPU), func(t *testing.T) {
warnings, errors := NumCPUCheck{NumCPU: rt.numCPU}.Check()
if len(warnings) != rt.numWarnings {
t.Errorf("expected %d warning(s) but got %d: %q", rt.numWarnings, len(warnings), warnings)
}
if len(errors) != rt.numErrors {
t.Errorf("expected %d warning(s) but got %d: %q", rt.numErrors, len(errors), errors)
}
})
}
}
| pweil-/origin | vendor/k8s.io/kubernetes/cmd/kubeadm/app/preflight/checks_test.go | GO | apache-2.0 | 30,930 |
# Copyright (c) Metaswitch Networks 2015. All rights reserved.
import logging
from calico.felix.actor import Actor, actor_message
from calico.felix.futils import IPV4, IPV6
from calico.felix.ipsets import Ipset, FELIX_PFX
_log = logging.getLogger(__name__)
ALL_POOLS_SET_NAME = FELIX_PFX + "all-ipam-pools"
MASQ_POOLS_SET_NAME = FELIX_PFX + "masq-ipam-pools"
MASQ_RULE_FRAGMENT = ("POSTROUTING "
"--match set --match-set %s src "
"--match set ! --match-set %s dst "
"--jump MASQUERADE" % (MASQ_POOLS_SET_NAME,
ALL_POOLS_SET_NAME))
class MasqueradeManager(Actor):
def __init__(self, ip_type, iptables_mgr):
super(MasqueradeManager, self).__init__(qualifier=str(ip_type))
assert ip_type in (IPV4, IPV6)
assert iptables_mgr.table == "nat"
self.ip_type = ip_type
self.pools_by_id = {}
self._iptables_mgr = iptables_mgr
ip_family = "inet" if ip_type == IPV4 else "inet6"
self._all_pools_ipset = Ipset(ALL_POOLS_SET_NAME,
ALL_POOLS_SET_NAME + "-tmp",
ip_family,
"hash:net")
self._masq_pools_ipset = Ipset(MASQ_POOLS_SET_NAME,
MASQ_POOLS_SET_NAME + "-tmp",
ip_family,
"hash:net")
self._dirty = False
@actor_message()
def apply_snapshot(self, pools_by_id):
_log.info("Applying IPAM pool snapshot with %s pools",
len(pools_by_id))
self.pools_by_id.clear()
self.pools_by_id.update(pools_by_id)
self._dirty = True
@actor_message()
def on_ipam_pool_updated(self, pool_id, pool):
if self.pools_by_id.get(pool_id) != pool:
if pool is None:
_log.info("IPAM pool deleted: %s", pool_id)
del self.pools_by_id[pool_id]
else:
_log.info("IPAM pool %s updated: %s", pool_id, pool)
self.pools_by_id[pool_id] = pool
self._dirty = True
def _finish_msg_batch(self, batch, results):
_log.debug("Finishing batch of IPAM pool changes")
if self._dirty:
_log.info("Marked as dirty, looking for masq-enabled pools")
masq_enabled_cidrs = set()
all_cidrs = set()
for pool in self.pools_by_id.itervalues():
all_cidrs.add(pool["cidr"])
if pool.get("masquerade", False):
masq_enabled_cidrs.add(pool["cidr"])
if masq_enabled_cidrs:
_log.info("There are masquerade-enabled pools present. "
"Updating.")
self._all_pools_ipset.replace_members(all_cidrs)
self._masq_pools_ipset.replace_members(masq_enabled_cidrs)
# Enable masquerading for traffic coming from pools that
# have it enabled only when the traffic is heading to an IP
# that isn't in any Calico-owned pool. (We assume that NAT
# is not required for Calico-owned IPs.)
self._iptables_mgr.ensure_rule_inserted(MASQ_RULE_FRAGMENT,
async=True)
else:
_log.info("No masquerade-enabled pools present. "
"Removing rules and ipsets.")
# Ensure that the rule doesn't exist before we try to remove
# our ipsets. Have to make a blocking call so that we don't
# try to remove the ipsets before we've cleaned up the rule
# that references them.
self._iptables_mgr.ensure_rule_removed(MASQ_RULE_FRAGMENT,
async=False)
# Safe to call even if the ipsets don't exist:
self._all_pools_ipset.delete()
self._masq_pools_ipset.delete()
self._dirty = False
_log.info("Finished refreshing ipsets")
| alexhersh/calico | calico/felix/masq.py | Python | apache-2.0 | 4,208 |
import { NgModule } from '@angular/core';
import { SharedModule } from 'app/shared';
import { ServerMapSearchResultViewerContainerComponent } from './server-map-search-result-viewer-container.component';
@NgModule({
declarations: [
ServerMapSearchResultViewerContainerComponent
],
imports: [
SharedModule
],
exports: [
ServerMapSearchResultViewerContainerComponent
],
providers: []
})
export class ServerMapSearchResultViewerModule { }
| minwoo-jung/pinpoint | web/src/main/angular/src/app/core/components/server-map-search-result-viewer/index.ts | TypeScript | apache-2.0 | 491 |
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <algorithm>
#include <cstdint>
#include <string>
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/platform/errors.h"
// Please use the appropriate namespace for your project
namespace tensorflow {
namespace custom_op_examples {
using CPUDevice = Eigen::ThreadPoolDevice;
using ::tensorflow::errors::InvalidArgument;
template <typename T>
class MultiplexSparseOp : public OpKernel {
public:
explicit MultiplexSparseOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
MultiplexSparseOp(const MultiplexSparseOp& other) = delete;
MultiplexSparseOp& operator=(const MultiplexSparseOp& other) = delete;
~MultiplexSparseOp() override = default;
void Compute(OpKernelContext* ctx) override {
const auto& cond_indices_tensor = ctx->input(0);
const auto& cond_values_tensor = ctx->input(1);
const auto& cond_shape_tensor = ctx->input(2);
const auto& a_indices_tensor = ctx->input(3);
const auto& a_values_tensor = ctx->input(4);
const auto& a_shape_tensor = ctx->input(5);
const auto& b_indices_tensor = ctx->input(6);
const auto& b_values_tensor = ctx->input(7);
const auto& b_shape_tensor = ctx->input(8);
OP_REQUIRES_OK(ctx,
ValidateSparseTensor(cond_indices_tensor, cond_values_tensor,
cond_shape_tensor, "cond"));
OP_REQUIRES_OK(ctx, ValidateSparseTensor(a_indices_tensor, a_values_tensor,
a_shape_tensor, "a"));
OP_REQUIRES_OK(ctx, ValidateSparseTensor(b_indices_tensor, b_values_tensor,
b_shape_tensor, "b"));
OP_REQUIRES(
ctx, cond_shape_tensor.shape() == a_shape_tensor.shape(),
InvalidArgument("Sparse tensors must be the same shape. cond_shape: ",
cond_shape_tensor.shape().DebugString(),
" vs a_shape: ", a_shape_tensor.shape().DebugString()));
OP_REQUIRES(
ctx, a_shape_tensor.shape() == b_shape_tensor.shape(),
InvalidArgument("Sparse tensors must be the same shape. a_shape: ",
a_shape_tensor.shape().DebugString(),
" vs b_shape: ", b_shape_tensor.shape().DebugString()));
const int rank = a_shape_tensor.dim_size(0);
OP_REQUIRES(
ctx, rank == 1,
InvalidArgument("Sorry, multiplex for sparse tensors only "
"supports rank 1 tensors to simplify this example."));
const int cond_elements = cond_indices_tensor.dim_size(0);
const int a_elements = a_indices_tensor.dim_size(0);
const int b_elements = b_indices_tensor.dim_size(0);
const auto cond_indices = cond_indices_tensor.matrix<int64_t>();
const auto cond_values = cond_values_tensor.flat<bool>();
const auto cond_shape = cond_shape_tensor.flat<int64_t>();
const auto a_indices = a_indices_tensor.matrix<int64_t>();
const auto a_values = a_values_tensor.flat<T>();
const auto a_shape = a_shape_tensor.flat<int64_t>();
const auto b_indices = b_indices_tensor.matrix<int64_t>();
const auto b_values = b_values_tensor.flat<T>();
const auto b_shape = b_shape_tensor.flat<int64_t>();
int cond_index = 0;
int a_index = 0;
int b_index = 0;
// This vector is a list of source tensors (a = true, b = false) and source
// indices.
std::vector<std::pair<bool, int>> merged_output;
merged_output.reserve(std::min(cond_elements, a_elements) + b_elements);
while (a_index < a_elements || b_index < b_elements) {
// Determine the whether the current location with values has a value
// for `a`, for `b` or for both `a` and `b`.
int64_t cur_row;
bool is_a_at_cur = false;
bool is_b_at_cur = false;
if (a_index < a_elements && b_index < b_elements) {
const int64_t a_row = a_indices(a_index, 0);
const int64_t b_row = b_indices(b_index, 0);
cur_row = std::min(a_row, b_row);
if (a_row == cur_row) {
is_a_at_cur = true;
}
if (b_row == cur_row) {
is_b_at_cur = true;
}
} else if (a_index < a_elements) {
cur_row = a_indices(a_index, 0);
is_a_at_cur = true;
} else { // b_index < b_elements
cur_row = b_indices(b_index, 0);
is_b_at_cur = true;
}
// Deterimine if `cond` has a value at the current location
bool cond_flag = false;
while (cond_index < cond_elements) {
const int64_t cond_row = cond_indices(cond_index, 0);
if (cond_row > cur_row) {
break;
}
if (cond_row == cur_row) {
cond_flag = cond_values(cond_index);
break;
}
++cond_index;
}
// Add `a` or `b` to the merged output based on the condition
if (is_a_at_cur) {
if (cond_flag) {
merged_output.emplace_back(true, a_index);
}
++a_index;
}
if (is_b_at_cur) {
if (!cond_flag) {
merged_output.emplace_back(false, b_index);
}
++b_index;
}
}
// Allocate output tensors.
Tensor* output_indices_tensor;
Tensor* output_values_tensor;
Tensor* output_dense_shape_tensor;
const int num_values = merged_output.size();
OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({num_values, rank}),
&output_indices_tensor));
OP_REQUIRES_OK(ctx, ctx->allocate_output(1, TensorShape({num_values}),
&output_values_tensor));
OP_REQUIRES_OK(ctx, ctx->allocate_output(2, TensorShape({rank}),
&output_dense_shape_tensor));
auto output_indices = output_indices_tensor->matrix<int64_t>();
auto output_values = output_values_tensor->flat<T>();
auto output_shape = output_dense_shape_tensor->flat<int64_t>();
for (int row = 0; row < num_values; ++row) {
const auto& source_flag = merged_output[row].first;
const auto& source_row = merged_output[row].second;
const auto& indices = source_flag ? a_indices : b_indices;
const auto& values = source_flag ? a_values : b_values;
for (int column = 0; column < rank; ++column) {
output_indices(row, column) = indices(source_row, column);
}
output_values(row) = values(source_row);
}
// Expand the shape of the output sparse tensor so that it is as large
// as the shape of the largest input in each dimension.
// An alternative behavoir would be to require that the shapes be the
// same and implement error checking that all the corresponding values
// in the shape tensors are the same (e.g.
// `cond_shape(i) == a_shape(i)` and `a_shape(i) == b_shape(i)` in
// OP_REQUIRES above and `output_shape(i) = a_shape(i)` here).
for (int i = 0; i < rank; ++i) {
output_shape(i) =
std::max(cond_shape(i), std::max(a_shape(i), b_shape(i)));
}
}
private:
Status ValidateSparseTensor(const ::tensorflow::Tensor& indices_tensor,
const ::tensorflow::Tensor& values_tensor,
const ::tensorflow::Tensor& shape_tensor,
const string label) {
if (!TensorShapeUtils::IsMatrix(indices_tensor.shape())) {
return InvalidArgument(
"Sparse indices for ", label,
" must be rank 2, not shape: ", indices_tensor.shape().DebugString());
}
if (!TensorShapeUtils::IsVector(values_tensor.shape())) {
return InvalidArgument("Sparse values for ", label,
" must be a vector, not shape: ",
values_tensor.shape().DebugString());
}
if (!TensorShapeUtils::IsVector(shape_tensor.shape())) {
return InvalidArgument(
"Sparse shape for ", label,
" must be a vector, not shape: ", shape_tensor.shape().DebugString());
}
if (indices_tensor.dim_size(0) != values_tensor.dim_size(0)) {
return InvalidArgument("Sparse indices and values for " + label +
" must have the same "
"number of rows. indices: ",
indices_tensor.shape().DebugString(),
" values: ", values_tensor.shape().DebugString());
}
return Status::OK();
}
};
// To support tensors containing different types (e.g. int32, float), one
// kernel per type is registered and is templatized by the "T" attr value.
// See go/tf-custom-ops-guide
#define REGISTER_KERNELS_CPU(type) \
REGISTER_KERNEL_BUILDER(Name("Examples>MultiplexSparse") \
.Device(::tensorflow::DEVICE_CPU) \
.TypeConstraint<type>("T"), \
MultiplexSparseOp<type>)
TF_CALL_ALL_TYPES(REGISTER_KERNELS_CPU);
#undef REGISTER_KERNELS_CPU
} // namespace custom_op_examples
} // namespace tensorflow
| tensorflow/tensorflow | tensorflow/examples/custom_ops_doc/multiplex_3/multiplex_3_kernel.cc | C++ | apache-2.0 | 9,788 |
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.gradle.api.internal.resolve;
import org.gradle.platform.base.Binary;
import org.gradle.platform.base.VariantComponent;
import javax.annotation.Nullable;
import java.util.Collection;
public interface VariantBinarySelector {
Collection<? extends Binary> selectVariants(VariantComponent componentSpec, @Nullable String requestedVariant);
}
| gstevey/gradle | subprojects/platform-base/src/main/java/org/gradle/api/internal/resolve/VariantBinarySelector.java | Java | apache-2.0 | 973 |
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f<T:Eq + Ord>(_: T) {
}
pub fn main() {
f(3);
}
| Ryman/rust | src/test/run-pass/multiple-trait-bounds.rs | Rust | apache-2.0 | 523 |
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.web.servlet.filter;
import java.io.IOException;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.web.filter.OncePerRequestFilter;
/**
* {@link OncePerRequestFilter} to add an {@literal X-Application-Context} header that
* contains the {@link ApplicationContext#getId() ApplicationContext ID}.
*
* @author Phillip Webb
* @author Venil Noronha
* @since 2.0.0
*/
public class ApplicationContextHeaderFilter extends OncePerRequestFilter {
/**
* Public constant for {@literal X-Application-Context}.
*/
public static final String HEADER_NAME = "X-Application-Context";
private final ApplicationContext applicationContext;
public ApplicationContextHeaderFilter(ApplicationContext context) {
this.applicationContext = context;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
response.addHeader(HEADER_NAME, this.applicationContext.getId());
filterChain.doFilter(request, response);
}
}
| aahlenst/spring-boot | spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/filter/ApplicationContextHeaderFilter.java | Java | apache-2.0 | 1,897 |
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was automatically generated by informer-gen with arguments: --input-dirs=[k8s.io/kubernetes/cmd/kube-aggregator/pkg/apis/apiregistration,k8s.io/kubernetes/cmd/kube-aggregator/pkg/apis/apiregistration/v1alpha1] --internal-clientset-package=k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/clientset_generated/internalclientset --listers-package=k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/listers --output-package=k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/informers --versioned-clientset-package=k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/clientset_generated/clientset
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
apiregistration_v1alpha1 "k8s.io/kubernetes/cmd/kube-aggregator/pkg/apis/apiregistration/v1alpha1"
clientset "k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/clientset_generated/clientset"
internalinterfaces "k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/informers/internalinterfaces"
v1alpha1 "k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/listers/apiregistration/v1alpha1"
cache "k8s.io/kubernetes/pkg/client/cache"
time "time"
)
// APIServiceInformer provides access to a shared informer and lister for
// APIServices.
type APIServiceInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.APIServiceLister
}
type aPIServiceInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newAPIServiceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.ApiregistrationV1alpha1().APIServices().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.ApiregistrationV1alpha1().APIServices().Watch(options)
},
},
&apiregistration_v1alpha1.APIService{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *aPIServiceInformer) Informer() cache.SharedIndexInformer {
return f.factory.VersionedInformerFor(&apiregistration_v1alpha1.APIService{}, newAPIServiceInformer)
}
func (f *aPIServiceInformer) Lister() v1alpha1.APIServiceLister {
return v1alpha1.NewAPIServiceLister(f.Informer().GetIndexer())
}
| sameo/cri-o | vendor/k8s.io/kubernetes/cmd/kube-aggregator/pkg/client/informers/apiregistration/v1alpha1/apiservice.go | GO | apache-2.0 | 3,011 |
# Copyright 2016 Intel Corporation
# Copyright 2015 Hewlett Packard Development Company, LP
# Copyright 2015 Universidade Federal de Campina Grande
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from ironic.common.i18n import _
opts = [
cfg.StrOpt('manager_url',
help=_('URL where OneView is available.')),
cfg.StrOpt('username',
help=_('OneView username to be used.')),
cfg.StrOpt('password',
secret=True,
help=_('OneView password to be used.')),
cfg.BoolOpt('allow_insecure_connections',
default=False,
help=_('Option to allow insecure connection with OneView.')),
cfg.StrOpt('tls_cacert_file',
help=_('Path to CA certificate.')),
cfg.IntOpt('max_polling_attempts',
default=12,
help=_('Max connection retries to check changes on OneView.')),
cfg.BoolOpt('enable_periodic_tasks',
default=True,
help=_('Whether to enable the periodic tasks for OneView '
'driver be aware when OneView hardware resources are '
'taken and released by Ironic or OneView users '
'and proactively manage nodes in clean fail state '
'according to Dynamic Allocation model of hardware '
'resources allocation in OneView.')),
cfg.IntOpt('periodic_check_interval',
default=300,
help=_('Period (in seconds) for periodic tasks to be '
'executed when enable_periodic_tasks=True.')),
]
def register_opts(conf):
conf.register_opts(opts, group='oneview')
| SauloAislan/ironic | ironic/conf/oneview.py | Python | apache-2.0 | 2,255 |
/*
* 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 io.trino.connector.system.jdbc;
import io.trino.FullConnectorSession;
import io.trino.Session;
import io.trino.metadata.Metadata;
import io.trino.security.AccessControl;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorTableMetadata;
import io.trino.spi.connector.ConnectorTransactionHandle;
import io.trino.spi.connector.InMemoryRecordSet;
import io.trino.spi.connector.InMemoryRecordSet.Builder;
import io.trino.spi.connector.RecordCursor;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.predicate.TupleDomain;
import javax.inject.Inject;
import static io.trino.metadata.MetadataListing.listCatalogs;
import static io.trino.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
import static io.trino.spi.type.VarcharType.createUnboundedVarcharType;
import static java.util.Objects.requireNonNull;
public class CatalogJdbcTable
extends JdbcTable
{
public static final SchemaTableName NAME = new SchemaTableName("jdbc", "catalogs");
public static final ConnectorTableMetadata METADATA = tableMetadataBuilder(NAME)
.column("table_cat", createUnboundedVarcharType())
.build();
private final Metadata metadata;
private final AccessControl accessControl;
@Inject
public CatalogJdbcTable(Metadata metadata, AccessControl accessControl)
{
this.metadata = requireNonNull(metadata, "metadata is null");
this.accessControl = requireNonNull(accessControl, "accessControl is null");
}
@Override
public ConnectorTableMetadata getTableMetadata()
{
return METADATA;
}
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = ((FullConnectorSession) connectorSession).getSession();
Builder table = InMemoryRecordSet.builder(METADATA);
for (String name : listCatalogs(session, metadata, accessControl).keySet()) {
table.addRow(name);
}
return table.build().cursor();
}
}
| ebyhr/presto | core/trino-main/src/main/java/io/trino/connector/system/jdbc/CatalogJdbcTable.java | Java | apache-2.0 | 2,689 |
/*! jQuery UI - v1.10.4 - 2014-06-10
* http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.slider.js, jquery.ui.tooltip.js
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
(function( $, undefined ) {
var uuid = 0,
runiqueId = /^ui-id-\d+$/;
// $.ui might exist from components with no dependencies, e.g., $.ui.position
$.ui = $.ui || {};
$.extend( $.ui, {
version: "1.10.4",
keyCode: {
BACKSPACE: 8,
COMMA: 188,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
LEFT: 37,
NUMPAD_ADD: 107,
NUMPAD_DECIMAL: 110,
NUMPAD_DIVIDE: 111,
NUMPAD_ENTER: 108,
NUMPAD_MULTIPLY: 106,
NUMPAD_SUBTRACT: 109,
PAGE_DOWN: 34,
PAGE_UP: 33,
PERIOD: 190,
RIGHT: 39,
SPACE: 32,
TAB: 9,
UP: 38
}
});
// plugins
$.fn.extend({
focus: (function( orig ) {
return function( delay, fn ) {
return typeof delay === "number" ?
this.each(function() {
var elem = this;
setTimeout(function() {
$( elem ).focus();
if ( fn ) {
fn.call( elem );
}
}, delay );
}) :
orig.apply( this, arguments );
};
})( $.fn.focus ),
scrollParent: function() {
var scrollParent;
if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
scrollParent = this.parents().filter(function() {
return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
} else {
scrollParent = this.parents().filter(function() {
return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
}
return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
},
zIndex: function( zIndex ) {
if ( zIndex !== undefined ) {
return this.css( "zIndex", zIndex );
}
if ( this.length ) {
var elem = $( this[ 0 ] ), position, value;
while ( elem.length && elem[ 0 ] !== document ) {
// Ignore z-index if position is set to a value where z-index is ignored by the browser
// This makes behavior of this function consistent across browsers
// WebKit always returns auto if the element is positioned
position = elem.css( "position" );
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
// IE returns 0 when zIndex is not specified
// other browsers return a string
// we ignore the case of nested elements with an explicit value of 0
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
value = parseInt( elem.css( "zIndex" ), 10 );
if ( !isNaN( value ) && value !== 0 ) {
return value;
}
}
elem = elem.parent();
}
}
return 0;
},
uniqueId: function() {
return this.each(function() {
if ( !this.id ) {
this.id = "ui-id-" + (++uuid);
}
});
},
removeUniqueId: function() {
return this.each(function() {
if ( runiqueId.test( this.id ) ) {
$( this ).removeAttr( "id" );
}
});
}
});
// selectors
function focusable( element, isTabIndexNotNaN ) {
var map, mapName, img,
nodeName = element.nodeName.toLowerCase();
if ( "area" === nodeName ) {
map = element.parentNode;
mapName = map.name;
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
return false;
}
img = $( "img[usemap=#" + mapName + "]" )[0];
return !!img && visible( img );
}
return ( /input|select|textarea|button|object/.test( nodeName ) ?
!element.disabled :
"a" === nodeName ?
element.href || isTabIndexNotNaN :
isTabIndexNotNaN) &&
// the element and all of its ancestors must be visible
visible( element );
}
function visible( element ) {
return $.expr.filters.visible( element ) &&
!$( element ).parents().addBack().filter(function() {
return $.css( this, "visibility" ) === "hidden";
}).length;
}
$.extend( $.expr[ ":" ], {
data: $.expr.createPseudo ?
$.expr.createPseudo(function( dataName ) {
return function( elem ) {
return !!$.data( elem, dataName );
};
}) :
// support: jQuery <1.8
function( elem, i, match ) {
return !!$.data( elem, match[ 3 ] );
},
focusable: function( element ) {
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
},
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
isTabIndexNaN = isNaN( tabIndex );
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
}
});
// support: jQuery <1.8
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
$.each( [ "Width", "Height" ], function( i, name ) {
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
type = name.toLowerCase(),
orig = {
innerWidth: $.fn.innerWidth,
innerHeight: $.fn.innerHeight,
outerWidth: $.fn.outerWidth,
outerHeight: $.fn.outerHeight
};
function reduce( elem, size, border, margin ) {
$.each( side, function() {
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
if ( border ) {
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
}
if ( margin ) {
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
}
});
return size;
}
$.fn[ "inner" + name ] = function( size ) {
if ( size === undefined ) {
return orig[ "inner" + name ].call( this );
}
return this.each(function() {
$( this ).css( type, reduce( this, size ) + "px" );
});
};
$.fn[ "outer" + name] = function( size, margin ) {
if ( typeof size !== "number" ) {
return orig[ "outer" + name ].call( this, size );
}
return this.each(function() {
$( this).css( type, reduce( this, size, true, margin ) + "px" );
});
};
});
}
// support: jQuery <1.8
if ( !$.fn.addBack ) {
$.fn.addBack = function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter( selector )
);
};
}
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
$.fn.removeData = (function( removeData ) {
return function( key ) {
if ( arguments.length ) {
return removeData.call( this, $.camelCase( key ) );
} else {
return removeData.call( this );
}
};
})( $.fn.removeData );
}
// deprecated
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
$.support.selectstart = "onselectstart" in document.createElement( "div" );
$.fn.extend({
disableSelection: function() {
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
".ui-disableSelection", function( event ) {
event.preventDefault();
});
},
enableSelection: function() {
return this.unbind( ".ui-disableSelection" );
}
});
$.extend( $.ui, {
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
plugin: {
add: function( module, option, set ) {
var i,
proto = $.ui[ module ].prototype;
for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args ) {
var i,
set = instance.plugins[ name ];
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
return;
}
for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
}
},
// only used by resizable
hasScroll: function( el, a ) {
//If overflow is hidden, the element might have extra content, but the user wants to hide it
if ( $( el ).css( "overflow" ) === "hidden") {
return false;
}
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
has = false;
if ( el[ scroll ] > 0 ) {
return true;
}
// TODO: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to
// set the scroll
el[ scroll ] = 1;
has = ( el[ scroll ] > 0 );
el[ scroll ] = 0;
return has;
}
});
})( jQuery );
(function( $, undefined ) {
var uuid = 0,
slice = Array.prototype.slice,
_cleanData = $.cleanData;
$.cleanData = function( elems ) {
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
try {
$( elem ).triggerHandler( "remove" );
// http://bugs.jquery.com/ticket/8235
} catch( e ) {}
}
_cleanData( elems );
};
$.widget = function( name, base, prototype ) {
var fullName, existingConstructor, constructor, basePrototype,
// proxiedPrototype allows the provided prototype to remain unmodified
// so that it can be used as a mixin for multiple widgets (#8876)
proxiedPrototype = {},
namespace = name.split( "." )[ 0 ];
name = name.split( "." )[ 1 ];
fullName = namespace + "-" + name;
if ( !prototype ) {
prototype = base;
base = $.Widget;
}
// create selector for plugin
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
return !!$.data( elem, fullName );
};
$[ namespace ] = $[ namespace ] || {};
existingConstructor = $[ namespace ][ name ];
constructor = $[ namespace ][ name ] = function( options, element ) {
// allow instantiation without "new" keyword
if ( !this._createWidget ) {
return new constructor( options, element );
}
// allow instantiation without initializing for simple inheritance
// must use "new" keyword (the code above always passes args)
if ( arguments.length ) {
this._createWidget( options, element );
}
};
// extend with the existing constructor to carry over any static properties
$.extend( constructor, existingConstructor, {
version: prototype.version,
// copy the object used to create the prototype in case we need to
// redefine the widget later
_proto: $.extend( {}, prototype ),
// track widgets that inherit from this widget in case this widget is
// redefined after a widget inherits from it
_childConstructors: []
});
basePrototype = new base();
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
basePrototype.options = $.widget.extend( {}, basePrototype.options );
$.each( prototype, function( prop, value ) {
if ( !$.isFunction( value ) ) {
proxiedPrototype[ prop ] = value;
return;
}
proxiedPrototype[ prop ] = (function() {
var _super = function() {
return base.prototype[ prop ].apply( this, arguments );
},
_superApply = function( args ) {
return base.prototype[ prop ].apply( this, args );
};
return function() {
var __super = this._super,
__superApply = this._superApply,
returnValue;
this._super = _super;
this._superApply = _superApply;
returnValue = value.apply( this, arguments );
this._super = __super;
this._superApply = __superApply;
return returnValue;
};
})();
});
constructor.prototype = $.widget.extend( basePrototype, {
// TODO: remove support for widgetEventPrefix
// always use the name + a colon as the prefix, e.g., draggable:start
// don't prefix for widgets that aren't DOM-based
widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
}, proxiedPrototype, {
constructor: constructor,
namespace: namespace,
widgetName: name,
widgetFullName: fullName
});
// If this widget is being redefined then we need to find all widgets that
// are inheriting from it and redefine all of them so that they inherit from
// the new version of this widget. We're essentially trying to replace one
// level in the prototype chain.
if ( existingConstructor ) {
$.each( existingConstructor._childConstructors, function( i, child ) {
var childPrototype = child.prototype;
// redefine the child widget using the same prototype that was
// originally used, but inherit from the new version of the base
$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
});
// remove the list of existing child constructors from the old constructor
// so the old child constructors can be garbage collected
delete existingConstructor._childConstructors;
} else {
base._childConstructors.push( constructor );
}
$.widget.bridge( name, constructor );
};
$.widget.extend = function( target ) {
var input = slice.call( arguments, 1 ),
inputIndex = 0,
inputLength = input.length,
key,
value;
for ( ; inputIndex < inputLength; inputIndex++ ) {
for ( key in input[ inputIndex ] ) {
value = input[ inputIndex ][ key ];
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
// Clone objects
if ( $.isPlainObject( value ) ) {
target[ key ] = $.isPlainObject( target[ key ] ) ?
$.widget.extend( {}, target[ key ], value ) :
// Don't extend strings, arrays, etc. with objects
$.widget.extend( {}, value );
// Copy everything else by reference
} else {
target[ key ] = value;
}
}
}
}
return target;
};
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
args = slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.widget.extend.apply( null, [ options ].concat(args) ) :
options;
if ( isMethodCall ) {
this.each(function() {
var methodValue,
instance = $.data( this, fullName );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
}
methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue && methodValue.jquery ?
returnValue.pushStack( methodValue.get() ) :
methodValue;
return false;
}
});
} else {
this.each(function() {
var instance = $.data( this, fullName );
if ( instance ) {
instance.option( options || {} )._init();
} else {
$.data( this, fullName, new object( options, this ) );
}
});
}
return returnValue;
};
};
$.Widget = function( /* options, element */ ) {};
$.Widget._childConstructors = [];
$.Widget.prototype = {
widgetName: "widget",
widgetEventPrefix: "",
defaultElement: "<div>",
options: {
disabled: false,
// callbacks
create: null
},
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
this.uuid = uuid++;
this.eventNamespace = "." + this.widgetName + this.uuid;
this.options = $.widget.extend( {},
this.options,
this._getCreateOptions(),
options );
this.bindings = $();
this.hoverable = $();
this.focusable = $();
if ( element !== this ) {
$.data( element, this.widgetFullName, this );
this._on( true, this.element, {
remove: function( event ) {
if ( event.target === element ) {
this.destroy();
}
}
});
this.document = $( element.style ?
// element within the document
element.ownerDocument :
// element is window or document
element.document || element );
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
}
this._create();
this._trigger( "create", null, this._getCreateEventData() );
this._init();
},
_getCreateOptions: $.noop,
_getCreateEventData: $.noop,
_create: $.noop,
_init: $.noop,
destroy: function() {
this._destroy();
// we can probably remove the unbind calls in 2.0
// all event bindings should go through this._on()
this.element
.unbind( this.eventNamespace )
// 1.9 BC for #7810
// TODO remove dual storage
.removeData( this.widgetName )
.removeData( this.widgetFullName )
// support: jquery <1.6.3
// http://bugs.jquery.com/ticket/9413
.removeData( $.camelCase( this.widgetFullName ) );
this.widget()
.unbind( this.eventNamespace )
.removeAttr( "aria-disabled" )
.removeClass(
this.widgetFullName + "-disabled " +
"ui-state-disabled" );
// clean up events and states
this.bindings.unbind( this.eventNamespace );
this.hoverable.removeClass( "ui-state-hover" );
this.focusable.removeClass( "ui-state-focus" );
},
_destroy: $.noop,
widget: function() {
return this.element;
},
option: function( key, value ) {
var options = key,
parts,
curOption,
i;
if ( arguments.length === 0 ) {
// don't return a reference to the internal hash
return $.widget.extend( {}, this.options );
}
if ( typeof key === "string" ) {
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
parts = key.split( "." );
key = parts.shift();
if ( parts.length ) {
curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
for ( i = 0; i < parts.length - 1; i++ ) {
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
curOption = curOption[ parts[ i ] ];
}
key = parts.pop();
if ( arguments.length === 1 ) {
return curOption[ key ] === undefined ? null : curOption[ key ];
}
curOption[ key ] = value;
} else {
if ( arguments.length === 1 ) {
return this.options[ key ] === undefined ? null : this.options[ key ];
}
options[ key ] = value;
}
}
this._setOptions( options );
return this;
},
_setOptions: function( options ) {
var key;
for ( key in options ) {
this._setOption( key, options[ key ] );
}
return this;
},
_setOption: function( key, value ) {
this.options[ key ] = value;
if ( key === "disabled" ) {
this.widget()
.toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
.attr( "aria-disabled", value );
this.hoverable.removeClass( "ui-state-hover" );
this.focusable.removeClass( "ui-state-focus" );
}
return this;
},
enable: function() {
return this._setOption( "disabled", false );
},
disable: function() {
return this._setOption( "disabled", true );
},
_on: function( suppressDisabledCheck, element, handlers ) {
var delegateElement,
instance = this;
// no suppressDisabledCheck flag, shuffle arguments
if ( typeof suppressDisabledCheck !== "boolean" ) {
handlers = element;
element = suppressDisabledCheck;
suppressDisabledCheck = false;
}
// no element argument, shuffle and use this.element
if ( !handlers ) {
handlers = element;
element = this.element;
delegateElement = this.widget();
} else {
// accept selectors, DOM elements
element = delegateElement = $( element );
this.bindings = this.bindings.add( element );
}
$.each( handlers, function( event, handler ) {
function handlerProxy() {
// allow widgets to customize the disabled handling
// - disabled as an array instead of boolean
// - disabled class as method for disabling individual parts
if ( !suppressDisabledCheck &&
( instance.options.disabled === true ||
$( this ).hasClass( "ui-state-disabled" ) ) ) {
return;
}
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
}
// copy the guid so direct unbinding works
if ( typeof handler !== "string" ) {
handlerProxy.guid = handler.guid =
handler.guid || handlerProxy.guid || $.guid++;
}
var match = event.match( /^(\w+)\s*(.*)$/ ),
eventName = match[1] + instance.eventNamespace,
selector = match[2];
if ( selector ) {
delegateElement.delegate( selector, eventName, handlerProxy );
} else {
element.bind( eventName, handlerProxy );
}
});
},
_off: function( element, eventName ) {
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
element.unbind( eventName ).undelegate( eventName );
},
_delay: function( handler, delay ) {
function handlerProxy() {
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
}
var instance = this;
return setTimeout( handlerProxy, delay || 0 );
},
_hoverable: function( element ) {
this.hoverable = this.hoverable.add( element );
this._on( element, {
mouseenter: function( event ) {
$( event.currentTarget ).addClass( "ui-state-hover" );
},
mouseleave: function( event ) {
$( event.currentTarget ).removeClass( "ui-state-hover" );
}
});
},
_focusable: function( element ) {
this.focusable = this.focusable.add( element );
this._on( element, {
focusin: function( event ) {
$( event.currentTarget ).addClass( "ui-state-focus" );
},
focusout: function( event ) {
$( event.currentTarget ).removeClass( "ui-state-focus" );
}
});
},
_trigger: function( type, event, data ) {
var prop, orig,
callback = this.options[ type ];
data = data || {};
event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ?
type :
this.widgetEventPrefix + type ).toLowerCase();
// the original event may come from any element
// so we need to reset the target on the new event
event.target = this.element[ 0 ];
// copy original event properties over to the new event
orig = event.originalEvent;
if ( orig ) {
for ( prop in orig ) {
if ( !( prop in event ) ) {
event[ prop ] = orig[ prop ];
}
}
}
this.element.trigger( event, data );
return !( $.isFunction( callback ) &&
callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
}
};
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
if ( typeof options === "string" ) {
options = { effect: options };
}
var hasOptions,
effectName = !options ?
method :
options === true || typeof options === "number" ?
defaultEffect :
options.effect || defaultEffect;
options = options || {};
if ( typeof options === "number" ) {
options = { duration: options };
}
hasOptions = !$.isEmptyObject( options );
options.complete = callback;
if ( options.delay ) {
element.delay( options.delay );
}
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
element[ method ]( options );
} else if ( effectName !== method && element[ effectName ] ) {
element[ effectName ]( options.duration, options.easing, callback );
} else {
element.queue(function( next ) {
$( this )[ method ]();
if ( callback ) {
callback.call( element[ 0 ] );
}
next();
});
}
};
});
})( jQuery );
(function( $, undefined ) {
var mouseHandled = false;
$( document ).mouseup( function() {
mouseHandled = false;
});
$.widget("ui.mouse", {
version: "1.10.4",
options: {
cancel: "input,textarea,button,select,option",
distance: 1,
delay: 0
},
_mouseInit: function() {
var that = this;
this.element
.bind("mousedown."+this.widgetName, function(event) {
return that._mouseDown(event);
})
.bind("click."+this.widgetName, function(event) {
if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
$.removeData(event.target, that.widgetName + ".preventClickEvent");
event.stopImmediatePropagation();
return false;
}
});
this.started = false;
},
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
_mouseDestroy: function() {
this.element.unbind("."+this.widgetName);
if ( this._mouseMoveDelegate ) {
$(document)
.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
}
},
_mouseDown: function(event) {
// don't let more than one widget handle mouseStart
if( mouseHandled ) { return; }
// we may have missed mouseup (out of window)
(this._mouseStarted && this._mouseUp(event));
this._mouseDownEvent = event;
var that = this,
btnIsLeft = (event.which === 1),
// event.target.nodeName works around a bug in IE 8 with
// disabled inputs (#7620)
elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
return true;
}
this.mouseDelayMet = !this.options.delay;
if (!this.mouseDelayMet) {
this._mouseDelayTimer = setTimeout(function() {
that.mouseDelayMet = true;
}, this.options.delay);
}
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
this._mouseStarted = (this._mouseStart(event) !== false);
if (!this._mouseStarted) {
event.preventDefault();
return true;
}
}
// Click event may never have fired (Gecko & Opera)
if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
$.removeData(event.target, this.widgetName + ".preventClickEvent");
}
// these delegates are required to keep context
this._mouseMoveDelegate = function(event) {
return that._mouseMove(event);
};
this._mouseUpDelegate = function(event) {
return that._mouseUp(event);
};
$(document)
.bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.bind("mouseup."+this.widgetName, this._mouseUpDelegate);
event.preventDefault();
mouseHandled = true;
return true;
},
_mouseMove: function(event) {
// IE mouseup check - mouseup happened when mouse was out of window
if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
return this._mouseUp(event);
}
if (this._mouseStarted) {
this._mouseDrag(event);
return event.preventDefault();
}
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
this._mouseStarted =
(this._mouseStart(this._mouseDownEvent, event) !== false);
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
}
return !this._mouseStarted;
},
_mouseUp: function(event) {
$(document)
.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
if (this._mouseStarted) {
this._mouseStarted = false;
if (event.target === this._mouseDownEvent.target) {
$.data(event.target, this.widgetName + ".preventClickEvent", true);
}
this._mouseStop(event);
}
return false;
},
_mouseDistanceMet: function(event) {
return (Math.max(
Math.abs(this._mouseDownEvent.pageX - event.pageX),
Math.abs(this._mouseDownEvent.pageY - event.pageY)
) >= this.options.distance
);
},
_mouseDelayMet: function(/* event */) {
return this.mouseDelayMet;
},
// These are placeholder methods, to be overriden by extending plugin
_mouseStart: function(/* event */) {},
_mouseDrag: function(/* event */) {},
_mouseStop: function(/* event */) {},
_mouseCapture: function(/* event */) { return true; }
});
})(jQuery);
(function( $, undefined ) {
$.ui = $.ui || {};
var cachedScrollbarWidth,
max = Math.max,
abs = Math.abs,
round = Math.round,
rhorizontal = /left|center|right/,
rvertical = /top|center|bottom/,
roffset = /[\+\-]\d+(\.[\d]+)?%?/,
rposition = /^\w+/,
rpercent = /%$/,
_position = $.fn.position;
function getOffsets( offsets, width, height ) {
return [
parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
];
}
function parseCss( element, property ) {
return parseInt( $.css( element, property ), 10 ) || 0;
}
function getDimensions( elem ) {
var raw = elem[0];
if ( raw.nodeType === 9 ) {
return {
width: elem.width(),
height: elem.height(),
offset: { top: 0, left: 0 }
};
}
if ( $.isWindow( raw ) ) {
return {
width: elem.width(),
height: elem.height(),
offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
};
}
if ( raw.preventDefault ) {
return {
width: 0,
height: 0,
offset: { top: raw.pageY, left: raw.pageX }
};
}
return {
width: elem.outerWidth(),
height: elem.outerHeight(),
offset: elem.offset()
};
}
$.position = {
scrollbarWidth: function() {
if ( cachedScrollbarWidth !== undefined ) {
return cachedScrollbarWidth;
}
var w1, w2,
div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
innerDiv = div.children()[0];
$( "body" ).append( div );
w1 = innerDiv.offsetWidth;
div.css( "overflow", "scroll" );
w2 = innerDiv.offsetWidth;
if ( w1 === w2 ) {
w2 = div[0].clientWidth;
}
div.remove();
return (cachedScrollbarWidth = w1 - w2);
},
getScrollInfo: function( within ) {
var overflowX = within.isWindow || within.isDocument ? "" :
within.element.css( "overflow-x" ),
overflowY = within.isWindow || within.isDocument ? "" :
within.element.css( "overflow-y" ),
hasOverflowX = overflowX === "scroll" ||
( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
hasOverflowY = overflowY === "scroll" ||
( overflowY === "auto" && within.height < within.element[0].scrollHeight );
return {
width: hasOverflowY ? $.position.scrollbarWidth() : 0,
height: hasOverflowX ? $.position.scrollbarWidth() : 0
};
},
getWithinInfo: function( element ) {
var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[0] ),
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
return {
element: withinElement,
isWindow: isWindow,
isDocument: isDocument,
offset: withinElement.offset() || { left: 0, top: 0 },
scrollLeft: withinElement.scrollLeft(),
scrollTop: withinElement.scrollTop(),
width: isWindow ? withinElement.width() : withinElement.outerWidth(),
height: isWindow ? withinElement.height() : withinElement.outerHeight()
};
}
};
$.fn.position = function( options ) {
if ( !options || !options.of ) {
return _position.apply( this, arguments );
}
// make a copy, we don't want to modify arguments
options = $.extend( {}, options );
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
target = $( options.of ),
within = $.position.getWithinInfo( options.within ),
scrollInfo = $.position.getScrollInfo( within ),
collision = ( options.collision || "flip" ).split( " " ),
offsets = {};
dimensions = getDimensions( target );
if ( target[0].preventDefault ) {
// force left top to allow flipping
options.at = "left top";
}
targetWidth = dimensions.width;
targetHeight = dimensions.height;
targetOffset = dimensions.offset;
// clone to reuse original targetOffset later
basePosition = $.extend( {}, targetOffset );
// force my and at to have valid horizontal and vertical positions
// if a value is missing or invalid, it will be converted to center
$.each( [ "my", "at" ], function() {
var pos = ( options[ this ] || "" ).split( " " ),
horizontalOffset,
verticalOffset;
if ( pos.length === 1) {
pos = rhorizontal.test( pos[ 0 ] ) ?
pos.concat( [ "center" ] ) :
rvertical.test( pos[ 0 ] ) ?
[ "center" ].concat( pos ) :
[ "center", "center" ];
}
pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
// calculate offsets
horizontalOffset = roffset.exec( pos[ 0 ] );
verticalOffset = roffset.exec( pos[ 1 ] );
offsets[ this ] = [
horizontalOffset ? horizontalOffset[ 0 ] : 0,
verticalOffset ? verticalOffset[ 0 ] : 0
];
// reduce to just the positions without the offsets
options[ this ] = [
rposition.exec( pos[ 0 ] )[ 0 ],
rposition.exec( pos[ 1 ] )[ 0 ]
];
});
// normalize collision option
if ( collision.length === 1 ) {
collision[ 1 ] = collision[ 0 ];
}
if ( options.at[ 0 ] === "right" ) {
basePosition.left += targetWidth;
} else if ( options.at[ 0 ] === "center" ) {
basePosition.left += targetWidth / 2;
}
if ( options.at[ 1 ] === "bottom" ) {
basePosition.top += targetHeight;
} else if ( options.at[ 1 ] === "center" ) {
basePosition.top += targetHeight / 2;
}
atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ];
return this.each(function() {
var collisionPosition, using,
elem = $( this ),
elemWidth = elem.outerWidth(),
elemHeight = elem.outerHeight(),
marginLeft = parseCss( this, "marginLeft" ),
marginTop = parseCss( this, "marginTop" ),
collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
if ( options.my[ 0 ] === "right" ) {
position.left -= elemWidth;
} else if ( options.my[ 0 ] === "center" ) {
position.left -= elemWidth / 2;
}
if ( options.my[ 1 ] === "bottom" ) {
position.top -= elemHeight;
} else if ( options.my[ 1 ] === "center" ) {
position.top -= elemHeight / 2;
}
position.left += myOffset[ 0 ];
position.top += myOffset[ 1 ];
// if the browser doesn't support fractions, then round for consistent results
if ( !$.support.offsetFractions ) {
position.left = round( position.left );
position.top = round( position.top );
}
collisionPosition = {
marginLeft: marginLeft,
marginTop: marginTop
};
$.each( [ "left", "top" ], function( i, dir ) {
if ( $.ui.position[ collision[ i ] ] ) {
$.ui.position[ collision[ i ] ][ dir ]( position, {
targetWidth: targetWidth,
targetHeight: targetHeight,
elemWidth: elemWidth,
elemHeight: elemHeight,
collisionPosition: collisionPosition,
collisionWidth: collisionWidth,
collisionHeight: collisionHeight,
offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
my: options.my,
at: options.at,
within: within,
elem : elem
});
}
});
if ( options.using ) {
// adds feedback as second argument to using callback, if present
using = function( props ) {
var left = targetOffset.left - position.left,
right = left + targetWidth - elemWidth,
top = targetOffset.top - position.top,
bottom = top + targetHeight - elemHeight,
feedback = {
target: {
element: target,
left: targetOffset.left,
top: targetOffset.top,
width: targetWidth,
height: targetHeight
},
element: {
element: elem,
left: position.left,
top: position.top,
width: elemWidth,
height: elemHeight
},
horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
};
if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
feedback.horizontal = "center";
}
if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
feedback.vertical = "middle";
}
if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
feedback.important = "horizontal";
} else {
feedback.important = "vertical";
}
options.using.call( this, props, feedback );
};
}
elem.offset( $.extend( position, { using: using } ) );
});
};
$.ui.position = {
fit: {
left: function( position, data ) {
var within = data.within,
withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
outerWidth = within.width,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
overLeft = withinOffset - collisionPosLeft,
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
newOverRight;
// element is wider than within
if ( data.collisionWidth > outerWidth ) {
// element is initially over the left side of within
if ( overLeft > 0 && overRight <= 0 ) {
newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
position.left += overLeft - newOverRight;
// element is initially over right side of within
} else if ( overRight > 0 && overLeft <= 0 ) {
position.left = withinOffset;
// element is initially over both left and right sides of within
} else {
if ( overLeft > overRight ) {
position.left = withinOffset + outerWidth - data.collisionWidth;
} else {
position.left = withinOffset;
}
}
// too far left -> align with left edge
} else if ( overLeft > 0 ) {
position.left += overLeft;
// too far right -> align with right edge
} else if ( overRight > 0 ) {
position.left -= overRight;
// adjust based on position and margin
} else {
position.left = max( position.left - collisionPosLeft, position.left );
}
},
top: function( position, data ) {
var within = data.within,
withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
outerHeight = data.within.height,
collisionPosTop = position.top - data.collisionPosition.marginTop,
overTop = withinOffset - collisionPosTop,
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
newOverBottom;
// element is taller than within
if ( data.collisionHeight > outerHeight ) {
// element is initially over the top of within
if ( overTop > 0 && overBottom <= 0 ) {
newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
position.top += overTop - newOverBottom;
// element is initially over bottom of within
} else if ( overBottom > 0 && overTop <= 0 ) {
position.top = withinOffset;
// element is initially over both top and bottom of within
} else {
if ( overTop > overBottom ) {
position.top = withinOffset + outerHeight - data.collisionHeight;
} else {
position.top = withinOffset;
}
}
// too far up -> align with top
} else if ( overTop > 0 ) {
position.top += overTop;
// too far down -> align with bottom edge
} else if ( overBottom > 0 ) {
position.top -= overBottom;
// adjust based on position and margin
} else {
position.top = max( position.top - collisionPosTop, position.top );
}
}
},
flip: {
left: function( position, data ) {
var within = data.within,
withinOffset = within.offset.left + within.scrollLeft,
outerWidth = within.width,
offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
overLeft = collisionPosLeft - offsetLeft,
overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
data.my[ 0 ] === "right" ?
data.elemWidth :
0,
atOffset = data.at[ 0 ] === "left" ?
data.targetWidth :
data.at[ 0 ] === "right" ?
-data.targetWidth :
0,
offset = -2 * data.offset[ 0 ],
newOverRight,
newOverLeft;
if ( overLeft < 0 ) {
newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
position.left += myOffset + atOffset + offset;
}
}
else if ( overRight > 0 ) {
newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
position.left += myOffset + atOffset + offset;
}
}
},
top: function( position, data ) {
var within = data.within,
withinOffset = within.offset.top + within.scrollTop,
outerHeight = within.height,
offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
collisionPosTop = position.top - data.collisionPosition.marginTop,
overTop = collisionPosTop - offsetTop,
overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
top = data.my[ 1 ] === "top",
myOffset = top ?
-data.elemHeight :
data.my[ 1 ] === "bottom" ?
data.elemHeight :
0,
atOffset = data.at[ 1 ] === "top" ?
data.targetHeight :
data.at[ 1 ] === "bottom" ?
-data.targetHeight :
0,
offset = -2 * data.offset[ 1 ],
newOverTop,
newOverBottom;
if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
position.top += myOffset + atOffset + offset;
}
}
else if ( overBottom > 0 ) {
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
position.top += myOffset + atOffset + offset;
}
}
}
},
flipfit: {
left: function() {
$.ui.position.flip.left.apply( this, arguments );
$.ui.position.fit.left.apply( this, arguments );
},
top: function() {
$.ui.position.flip.top.apply( this, arguments );
$.ui.position.fit.top.apply( this, arguments );
}
}
};
// fraction support test
(function () {
var testElement, testElementParent, testElementStyle, offsetLeft, i,
body = document.getElementsByTagName( "body" )[ 0 ],
div = document.createElement( "div" );
//Create a "fake body" for testing based on method used in jQuery.support
testElement = document.createElement( body ? "div" : "body" );
testElementStyle = {
visibility: "hidden",
width: 0,
height: 0,
border: 0,
margin: 0,
background: "none"
};
if ( body ) {
$.extend( testElementStyle, {
position: "absolute",
left: "-1000px",
top: "-1000px"
});
}
for ( i in testElementStyle ) {
testElement.style[ i ] = testElementStyle[ i ];
}
testElement.appendChild( div );
testElementParent = body || document.documentElement;
testElementParent.insertBefore( testElement, testElementParent.firstChild );
div.style.cssText = "position: absolute; left: 10.7432222px;";
offsetLeft = $( div ).offset().left;
$.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
testElement.innerHTML = "";
testElementParent.removeChild( testElement );
})();
}( jQuery ) );
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
version: "1.10.4",
widgetEventPrefix: "drag",
options: {
addClasses: true,
appendTo: "parent",
axis: false,
connectToSortable: false,
containment: false,
cursor: "auto",
cursorAt: false,
grid: false,
handle: false,
helper: "original",
iframeFix: false,
opacity: false,
refreshPositions: false,
revert: false,
revertDuration: 500,
scope: "default",
scroll: true,
scrollSensitivity: 20,
scrollSpeed: 20,
snap: false,
snapMode: "both",
snapTolerance: 20,
stack: false,
zIndex: false,
// callbacks
drag: null,
start: null,
stop: null
},
_create: function() {
if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
this.element[0].style.position = "relative";
}
if (this.options.addClasses){
this.element.addClass("ui-draggable");
}
if (this.options.disabled){
this.element.addClass("ui-draggable-disabled");
}
this._mouseInit();
},
_destroy: function() {
this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
this._mouseDestroy();
},
_mouseCapture: function(event) {
var o = this.options;
// among others, prevent a drag on a resizable-handle
if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
return false;
}
//Quit if we're not on a valid handle
this.handle = this._getHandle(event);
if (!this.handle) {
return false;
}
$(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
$("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
.css({
width: this.offsetWidth+"px", height: this.offsetHeight+"px",
position: "absolute", opacity: "0.001", zIndex: 1000
})
.css($(this).offset())
.appendTo("body");
});
return true;
},
_mouseStart: function(event) {
var o = this.options;
//Create and append the visible helper
this.helper = this._createHelper(event);
this.helper.addClass("ui-draggable-dragging");
//Cache the helper size
this._cacheHelperProportions();
//If ddmanager is used for droppables, set the global draggable
if($.ui.ddmanager) {
$.ui.ddmanager.current = this;
}
/*
* - Position generation -
* This block generates everything position related - it's the core of draggables.
*/
//Cache the margins of the original element
this._cacheMargins();
//Store the helper's css position
this.cssPosition = this.helper.css( "position" );
this.scrollParent = this.helper.scrollParent();
this.offsetParent = this.helper.offsetParent();
this.offsetParentCssPosition = this.offsetParent.css( "position" );
//The element's absolute position on the page minus margins
this.offset = this.positionAbs = this.element.offset();
this.offset = {
top: this.offset.top - this.margins.top,
left: this.offset.left - this.margins.left
};
//Reset scroll cache
this.offset.scroll = false;
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
//Generate the original position
this.originalPosition = this.position = this._generatePosition(event);
this.originalPageX = event.pageX;
this.originalPageY = event.pageY;
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
//Set a containment if given in the options
this._setContainment();
//Trigger event + callbacks
if(this._trigger("start", event) === false) {
this._clear();
return false;
}
//Recache the helper size
this._cacheHelperProportions();
//Prepare the droppable offsets
if ($.ui.ddmanager && !o.dropBehaviour) {
$.ui.ddmanager.prepareOffsets(this, event);
}
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
if ( $.ui.ddmanager ) {
$.ui.ddmanager.dragStart(this, event);
}
return true;
},
_mouseDrag: function(event, noPropagation) {
// reset any necessary cached properties (see #5009)
if ( this.offsetParentCssPosition === "fixed" ) {
this.offset.parent = this._getParentOffset();
}
//Compute the helpers position
this.position = this._generatePosition(event);
this.positionAbs = this._convertPositionTo("absolute");
//Call plugins and callbacks and use the resulting position if something is returned
if (!noPropagation) {
var ui = this._uiHash();
if(this._trigger("drag", event, ui) === false) {
this._mouseUp({});
return false;
}
this.position = ui.position;
}
if(!this.options.axis || this.options.axis !== "y") {
this.helper[0].style.left = this.position.left+"px";
}
if(!this.options.axis || this.options.axis !== "x") {
// 晓强修改 Start 为了修正遇到滚动条被拖拽元素的不跟随bug
this.position.top += this.helper.parent().scrollTop();
var startScrrolTop = this.helper.attr('data-sort-startScrrolTop');
if (startScrrolTop) {
this.position.top -= startScrrolTop;
}
// 晓强修改 End
this.helper[0].style.top = this.position.top+"px";
}
if($.ui.ddmanager) {
$.ui.ddmanager.drag(this, event);
}
return false;
},
_mouseStop: function(event) {
//If we are using droppables, inform the manager about the drop
var that = this,
dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour) {
dropped = $.ui.ddmanager.drop(this, event);
}
//if a drop comes from outside (a sortable)
if(this.dropped) {
dropped = this.dropped;
this.dropped = false;
}
//if the original element is no longer in the DOM don't bother to continue (see #8269)
if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
return false;
}
if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
if(that._trigger("stop", event) !== false) {
that._clear();
}
});
} else {
if(this._trigger("stop", event) !== false) {
this._clear();
}
}
return false;
},
_mouseUp: function(event) {
//Remove frame helpers
$("div.ui-draggable-iframeFix").each(function() {
this.parentNode.removeChild(this);
});
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
if( $.ui.ddmanager ) {
$.ui.ddmanager.dragStop(this, event);
}
return $.ui.mouse.prototype._mouseUp.call(this, event);
},
cancel: function() {
if(this.helper.is(".ui-draggable-dragging")) {
this._mouseUp({});
} else {
this._clear();
}
return this;
},
_getHandle: function(event) {
return this.options.handle ?
!!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
true;
},
_createHelper: function(event) {
var o = this.options,
helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
if(!helper.parents("body").length) {
helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
}
if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
helper.css("position", "absolute");
}
return helper;
},
_adjustOffsetFromHelper: function(obj) {
if (typeof obj === "string") {
obj = obj.split(" ");
}
if ($.isArray(obj)) {
obj = {left: +obj[0], top: +obj[1] || 0};
}
if ("left" in obj) {
this.offset.click.left = obj.left + this.margins.left;
}
if ("right" in obj) {
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
}
if ("top" in obj) {
this.offset.click.top = obj.top + this.margins.top;
}
if ("bottom" in obj) {
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
}
},
_getParentOffset: function() {
//Get the offsetParent and cache its position
var po = this.offsetParent.offset();
// This is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
//This needs to be actually done for all browsers, since pageX/pageY includes this information
//Ugly IE fix
if((this.offsetParent[0] === document.body) ||
(this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
po = { top: 0, left: 0 };
}
return {
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
};
},
_getRelativeOffset: function() {
if(this.cssPosition === "relative") {
var p = this.element.position();
return {
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
};
} else {
return { top: 0, left: 0 };
}
},
_cacheMargins: function() {
this.margins = {
left: (parseInt(this.element.css("marginLeft"),10) || 0),
top: (parseInt(this.element.css("marginTop"),10) || 0),
right: (parseInt(this.element.css("marginRight"),10) || 0),
bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
};
},
_cacheHelperProportions: function() {
this.helperProportions = {
width: this.helper.outerWidth(),
height: this.helper.outerHeight()
};
},
_setContainment: function() {
var over, c, ce,
o = this.options;
if ( !o.containment ) {
this.containment = null;
return;
}
if ( o.containment === "window" ) {
this.containment = [
$( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
$( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
$( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
$( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
return;
}
if ( o.containment === "document") {
this.containment = [
0,
0,
$( document ).width() - this.helperProportions.width - this.margins.left,
( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
];
return;
}
if ( o.containment.constructor === Array ) {
this.containment = o.containment;
return;
}
if ( o.containment === "parent" ) {
o.containment = this.helper[ 0 ].parentNode;
}
c = $( o.containment );
ce = c[ 0 ];
if( !ce ) {
return;
}
over = c.css( "overflow" ) !== "hidden";
this.containment = [
( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
];
this.relative_container = c;
},
_convertPositionTo: function(d, pos) {
if(!pos) {
pos = this.position;
}
var mod = d === "absolute" ? 1 : -1,
scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
//Cache the scroll
if (!this.offset.scroll) {
this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
}
return {
top: (
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
)
};
},
_generatePosition: function(event) {
var containment, co, top, left,
o = this.options,
scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
pageX = event.pageX,
pageY = event.pageY;
//Cache the scroll
if (!this.offset.scroll) {
this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
}
/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
*/
// If we are not dragging yet, we won't check for options
if ( this.originalPosition ) {
if ( this.containment ) {
if ( this.relative_container ){
co = this.relative_container.offset();
containment = [
this.containment[ 0 ] + co.left,
this.containment[ 1 ] + co.top,
this.containment[ 2 ] + co.left,
this.containment[ 3 ] + co.top
];
}
else {
containment = this.containment;
}
if(event.pageX - this.offset.click.left < containment[0]) {
pageX = containment[0] + this.offset.click.left;
}
if(event.pageY - this.offset.click.top < containment[1]) {
pageY = containment[1] + this.offset.click.top;
}
if(event.pageX - this.offset.click.left > containment[2]) {
pageX = containment[2] + this.offset.click.left;
}
if(event.pageY - this.offset.click.top > containment[3]) {
pageY = containment[3] + this.offset.click.top;
}
}
if(o.grid) {
//Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
}
}
return {
top: (
pageY - // The absolute mouse position
this.offset.click.top - // Click offset (relative to the element)
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
),
left: (
pageX - // The absolute mouse position
this.offset.click.left - // Click offset (relative to the element)
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
)
};
},
_clear: function() {
this.helper.removeClass("ui-draggable-dragging");
if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
this.helper.remove();
}
this.helper = null;
this.cancelHelperRemoval = false;
},
// From now on bulk stuff - mainly helpers
_trigger: function(type, event, ui) {
ui = ui || this._uiHash();
$.ui.plugin.call(this, type, [event, ui]);
//The absolute position has to be recalculated after plugins
if(type === "drag") {
this.positionAbs = this._convertPositionTo("absolute");
}
return $.Widget.prototype._trigger.call(this, type, event, ui);
},
plugins: {},
_uiHash: function() {
return {
helper: this.helper,
position: this.position,
originalPosition: this.originalPosition,
offset: this.positionAbs
};
}
});
$.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) {
var inst = $(this).data("ui-draggable"), o = inst.options,
uiSortable = $.extend({}, ui, { item: inst.element });
inst.sortables = [];
$(o.connectToSortable).each(function() {
var sortable = $.data(this, "ui-sortable");
if (sortable && !sortable.options.disabled) {
inst.sortables.push({
instance: sortable,
shouldRevert: sortable.options.revert
});
sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
sortable._trigger("activate", event, uiSortable);
}
});
},
stop: function(event, ui) {
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
var inst = $(this).data("ui-draggable"),
uiSortable = $.extend({}, ui, { item: inst.element });
$.each(inst.sortables, function() {
if(this.instance.isOver) {
this.instance.isOver = 0;
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
if(this.shouldRevert) {
this.instance.options.revert = this.shouldRevert;
}
//Trigger the stop of the sortable
this.instance._mouseStop(event);
this.instance.options.helper = this.instance.options._helper;
//If the helper has been the original item, restore properties in the sortable
if(inst.options.helper === "original") {
this.instance.currentItem.css({ top: "auto", left: "auto" });
}
} else {
this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
this.instance._trigger("deactivate", event, uiSortable);
}
});
},
drag: function(event, ui) {
var inst = $(this).data("ui-draggable"), that = this;
$.each(inst.sortables, function() {
var innermostIntersecting = false,
thisSortable = this;
//Copy over some variables to allow calling the sortable's native _intersectsWith
this.instance.positionAbs = inst.positionAbs;
this.instance.helperProportions = inst.helperProportions;
this.instance.offset.click = inst.offset.click;
if(this.instance._intersectsWith(this.instance.containerCache)) {
innermostIntersecting = true;
$.each(inst.sortables, function () {
this.instance.positionAbs = inst.positionAbs;
this.instance.helperProportions = inst.helperProportions;
this.instance.offset.click = inst.offset.click;
if (this !== thisSortable &&
this.instance._intersectsWith(this.instance.containerCache) &&
$.contains(thisSortable.instance.element[0], this.instance.element[0])
) {
innermostIntersecting = false;
}
return innermostIntersecting;
});
}
if(innermostIntersecting) {
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
if(!this.instance.isOver) {
this.instance.isOver = 1;
//Now we fake the start of dragging for the sortable instance,
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
this.instance.options.helper = function() { return ui.helper[0]; };
event.target = this.instance.currentItem[0];
this.instance._mouseCapture(event, true);
this.instance._mouseStart(event, true, true);
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
this.instance.offset.click.top = inst.offset.click.top;
this.instance.offset.click.left = inst.offset.click.left;
this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
inst._trigger("toSortable", event);
inst.dropped = this.instance.element; //draggable revert needs that
//hack so receive/update callbacks work (mostly)
inst.currentItem = inst.element;
this.instance.fromOutside = inst;
}
//Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
if(this.instance.currentItem) {
this.instance._mouseDrag(event);
}
} else {
//If it doesn't intersect with the sortable, and it intersected before,
//we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
if(this.instance.isOver) {
this.instance.isOver = 0;
this.instance.cancelHelperRemoval = true;
//Prevent reverting on this forced stop
this.instance.options.revert = false;
// The out event needs to be triggered independently
this.instance._trigger("out", event, this.instance._uiHash(this.instance));
this.instance._mouseStop(event, true);
this.instance.options.helper = this.instance.options._helper;
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
this.instance.currentItem.remove();
if(this.instance.placeholder) {
this.instance.placeholder.remove();
}
inst._trigger("fromSortable", event);
inst.dropped = false; //draggable revert needs that
}
}
});
}
});
$.ui.plugin.add("draggable", "cursor", {
start: function() {
var t = $("body"), o = $(this).data("ui-draggable").options;
if (t.css("cursor")) {
o._cursor = t.css("cursor");
}
t.css("cursor", o.cursor);
},
stop: function() {
var o = $(this).data("ui-draggable").options;
if (o._cursor) {
$("body").css("cursor", o._cursor);
}
}
});
$.ui.plugin.add("draggable", "opacity", {
start: function(event, ui) {
var t = $(ui.helper), o = $(this).data("ui-draggable").options;
if(t.css("opacity")) {
o._opacity = t.css("opacity");
}
t.css("opacity", o.opacity);
},
stop: function(event, ui) {
var o = $(this).data("ui-draggable").options;
if(o._opacity) {
$(ui.helper).css("opacity", o._opacity);
}
}
});
$.ui.plugin.add("draggable", "scroll", {
start: function() {
var i = $(this).data("ui-draggable");
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
i.overflowOffset = i.scrollParent.offset();
}
},
drag: function( event ) {
var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
if(!o.axis || o.axis !== "x") {
if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
} else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
}
}
if(!o.axis || o.axis !== "y") {
if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
} else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
}
}
} else {
if(!o.axis || o.axis !== "x") {
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
}
}
if(!o.axis || o.axis !== "y") {
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
}
}
}
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
$.ui.ddmanager.prepareOffsets(i, event);
}
}
});
$.ui.plugin.add("draggable", "snap", {
start: function() {
var i = $(this).data("ui-draggable"),
o = i.options;
i.snapElements = [];
$(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
var $t = $(this),
$o = $t.offset();
if(this !== i.element[0]) {
i.snapElements.push({
item: this,
width: $t.outerWidth(), height: $t.outerHeight(),
top: $o.top, left: $o.left
});
}
});
},
drag: function(event, ui) {
var ts, bs, ls, rs, l, r, t, b, i, first,
inst = $(this).data("ui-draggable"),
o = inst.options,
d = o.snapTolerance,
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
for (i = inst.snapElements.length - 1; i >= 0; i--){
l = inst.snapElements[i].left;
r = l + inst.snapElements[i].width;
t = inst.snapElements[i].top;
b = t + inst.snapElements[i].height;
if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
if(inst.snapElements[i].snapping) {
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
}
inst.snapElements[i].snapping = false;
continue;
}
if(o.snapMode !== "inner") {
ts = Math.abs(t - y2) <= d;
bs = Math.abs(b - y1) <= d;
ls = Math.abs(l - x2) <= d;
rs = Math.abs(r - x1) <= d;
if(ts) {
ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
}
if(bs) {
ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
}
if(ls) {
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
}
if(rs) {
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
}
}
first = (ts || bs || ls || rs);
if(o.snapMode !== "outer") {
ts = Math.abs(t - y1) <= d;
bs = Math.abs(b - y2) <= d;
ls = Math.abs(l - x1) <= d;
rs = Math.abs(r - x2) <= d;
if(ts) {
ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
}
if(bs) {
ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
}
if(ls) {
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
}
if(rs) {
ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
}
}
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
}
inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
}
}
});
$.ui.plugin.add("draggable", "stack", {
start: function() {
var min,
o = this.data("ui-draggable").options,
group = $.makeArray($(o.stack)).sort(function(a,b) {
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
});
if (!group.length) { return; }
min = parseInt($(group[0]).css("zIndex"), 10) || 0;
$(group).each(function(i) {
$(this).css("zIndex", min + i);
});
this.css("zIndex", (min + group.length));
}
});
$.ui.plugin.add("draggable", "zIndex", {
start: function(event, ui) {
var t = $(ui.helper), o = $(this).data("ui-draggable").options;
if(t.css("zIndex")) {
o._zIndex = t.css("zIndex");
}
t.css("zIndex", o.zIndex);
},
stop: function(event, ui) {
var o = $(this).data("ui-draggable").options;
if(o._zIndex) {
$(ui.helper).css("zIndex", o._zIndex);
}
}
});
})(jQuery);
(function( $, undefined ) {
function isOverAxis( x, reference, size ) {
return ( x > reference ) && ( x < ( reference + size ) );
}
$.widget("ui.droppable", {
version: "1.10.4",
widgetEventPrefix: "drop",
options: {
accept: "*",
activeClass: false,
addClasses: true,
greedy: false,
hoverClass: false,
scope: "default",
tolerance: "intersect",
// callbacks
activate: null,
deactivate: null,
drop: null,
out: null,
over: null
},
_create: function() {
var proportions,
o = this.options,
accept = o.accept;
this.isover = false;
this.isout = true;
this.accept = $.isFunction(accept) ? accept : function(d) {
return d.is(accept);
};
this.proportions = function( /* valueToWrite */ ) {
if ( arguments.length ) {
// Store the droppable's proportions
proportions = arguments[ 0 ];
} else {
// Retrieve or derive the droppable's proportions
return proportions ?
proportions :
proportions = {
width: this.element[ 0 ].offsetWidth,
height: this.element[ 0 ].offsetHeight
};
}
};
// Add the reference and positions to the manager
$.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
$.ui.ddmanager.droppables[o.scope].push(this);
(o.addClasses && this.element.addClass("ui-droppable"));
},
_destroy: function() {
var i = 0,
drop = $.ui.ddmanager.droppables[this.options.scope];
for ( ; i < drop.length; i++ ) {
if ( drop[i] === this ) {
drop.splice(i, 1);
}
}
this.element.removeClass("ui-droppable ui-droppable-disabled");
},
_setOption: function(key, value) {
if(key === "accept") {
this.accept = $.isFunction(value) ? value : function(d) {
return d.is(value);
};
}
$.Widget.prototype._setOption.apply(this, arguments);
},
_activate: function(event) {
var draggable = $.ui.ddmanager.current;
if(this.options.activeClass) {
this.element.addClass(this.options.activeClass);
}
if(draggable){
this._trigger("activate", event, this.ui(draggable));
}
},
_deactivate: function(event) {
var draggable = $.ui.ddmanager.current;
if(this.options.activeClass) {
this.element.removeClass(this.options.activeClass);
}
if(draggable){
this._trigger("deactivate", event, this.ui(draggable));
}
},
_over: function(event) {
var draggable = $.ui.ddmanager.current;
// Bail if draggable and droppable are same element
if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
return;
}
if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
if(this.options.hoverClass) {
this.element.addClass(this.options.hoverClass);
}
this._trigger("over", event, this.ui(draggable));
}
},
_out: function(event) {
var draggable = $.ui.ddmanager.current;
// Bail if draggable and droppable are same element
if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
return;
}
if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
if(this.options.hoverClass) {
this.element.removeClass(this.options.hoverClass);
}
this._trigger("out", event, this.ui(draggable));
}
},
_drop: function(event,custom) {
var draggable = custom || $.ui.ddmanager.current,
childrenIntersection = false;
// Bail if draggable and droppable are same element
if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
return false;
}
this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
var inst = $.data(this, "ui-droppable");
if(
inst.options.greedy &&
!inst.options.disabled &&
inst.options.scope === draggable.options.scope &&
inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
$.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
) { childrenIntersection = true; return false; }
});
if(childrenIntersection) {
return false;
}
if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
if(this.options.activeClass) {
this.element.removeClass(this.options.activeClass);
}
if(this.options.hoverClass) {
this.element.removeClass(this.options.hoverClass);
}
this._trigger("drop", event, this.ui(draggable));
return this.element;
}
return false;
},
ui: function(c) {
return {
draggable: (c.currentItem || c.element),
helper: c.helper,
position: c.position,
offset: c.positionAbs
};
}
});
$.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) {
return false;
}
var draggableLeft, draggableTop,
x1 = (draggable.positionAbs || draggable.position.absolute).left,
y1 = (draggable.positionAbs || draggable.position.absolute).top,
x2 = x1 + draggable.helperProportions.width,
y2 = y1 + draggable.helperProportions.height,
l = droppable.offset.left,
t = droppable.offset.top,
r = l + droppable.proportions().width,
b = t + droppable.proportions().height;
switch (toleranceMode) {
case "fit":
return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
case "intersect":
return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
x2 - (draggable.helperProportions.width / 2) < r && // Left Half
t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
case "pointer":
draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
case "touch":
return (
(y1 >= t && y1 <= b) || // Top edge touching
(y2 >= t && y2 <= b) || // Bottom edge touching
(y1 < t && y2 > b) // Surrounded vertically
) && (
(x1 >= l && x1 <= r) || // Left edge touching
(x2 >= l && x2 <= r) || // Right edge touching
(x1 < l && x2 > r) // Surrounded horizontally
);
default:
return false;
}
};
/*
This manager tracks offsets of draggables and droppables
*/
$.ui.ddmanager = {
current: null,
droppables: { "default": [] },
prepareOffsets: function(t, event) {
var i, j,
m = $.ui.ddmanager.droppables[t.options.scope] || [],
type = event ? event.type : null, // workaround for #2317
list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
droppablesLoop: for (i = 0; i < m.length; i++) {
//No disabled and non-accepted
if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
continue;
}
// Filter out elements in the current dragged item
for (j=0; j < list.length; j++) {
if(list[j] === m[i].element[0]) {
m[i].proportions().height = 0;
continue droppablesLoop;
}
}
m[i].visible = m[i].element.css("display") !== "none";
if(!m[i].visible) {
continue;
}
//Activate the droppable if used directly from draggables
if(type === "mousedown") {
m[i]._activate.call(m[i], event);
}
m[ i ].offset = m[ i ].element.offset();
m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
}
},
drop: function(draggable, event) {
var dropped = false;
// Create a copy of the droppables in case the list changes during the drop (#9116)
$.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
if(!this.options) {
return;
}
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
dropped = this._drop.call(this, event) || dropped;
}
if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
this.isout = true;
this.isover = false;
this._deactivate.call(this, event);
}
});
return dropped;
},
dragStart: function( draggable, event ) {
//Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
if( !draggable.options.refreshPositions ) {
$.ui.ddmanager.prepareOffsets( draggable, event );
}
});
},
drag: function(draggable, event) {
//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
if(draggable.options.refreshPositions) {
$.ui.ddmanager.prepareOffsets(draggable, event);
}
//Run through all droppables and check their positions based on specific tolerance options
$.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
if(this.options.disabled || this.greedyChild || !this.visible) {
return;
}
var parentInstance, scope, parent,
intersects = $.ui.intersect(draggable, this, this.options.tolerance),
c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
if(!c) {
return;
}
if (this.options.greedy) {
// find droppable parents with same scope
scope = this.options.scope;
parent = this.element.parents(":data(ui-droppable)").filter(function () {
return $.data(this, "ui-droppable").options.scope === scope;
});
if (parent.length) {
parentInstance = $.data(parent[0], "ui-droppable");
parentInstance.greedyChild = (c === "isover");
}
}
// we just moved into a greedy child
if (parentInstance && c === "isover") {
parentInstance.isover = false;
parentInstance.isout = true;
parentInstance._out.call(parentInstance, event);
}
this[c] = true;
this[c === "isout" ? "isover" : "isout"] = false;
this[c === "isover" ? "_over" : "_out"].call(this, event);
// we just moved out of a greedy child
if (parentInstance && c === "isout") {
parentInstance.isout = false;
parentInstance.isover = true;
parentInstance._over.call(parentInstance, event);
}
});
},
dragStop: function( draggable, event ) {
draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
//Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
if( !draggable.options.refreshPositions ) {
$.ui.ddmanager.prepareOffsets( draggable, event );
}
}
};
})(jQuery);
(function( $, undefined ) {
function num(v) {
return parseInt(v, 10) || 0;
}
function isNumber(value) {
return !isNaN(parseInt(value, 10));
}
$.widget("ui.resizable", $.ui.mouse, {
version: "1.10.4",
widgetEventPrefix: "resize",
options: {
alsoResize: false,
animate: false,
animateDuration: "slow",
animateEasing: "swing",
aspectRatio: false,
autoHide: false,
containment: false,
ghost: false,
grid: false,
handles: "e,s,se",
helper: false,
maxHeight: null,
maxWidth: null,
minHeight: 10,
minWidth: 10,
// See #7960
zIndex: 90,
// callbacks
resize: null,
start: null,
stop: null
},
_create: function() {
var n, i, handle, axis, hname,
that = this,
o = this.options;
this.element.addClass("ui-resizable");
$.extend(this, {
_aspectRatio: !!(o.aspectRatio),
aspectRatio: o.aspectRatio,
originalElement: this.element,
_proportionallyResizeElements: [],
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
});
//Wrap the element if it cannot hold child nodes
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
//Create a wrapper element and set the wrapper to the new current internal element
this.element.wrap(
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
position: this.element.css("position"),
width: this.element.outerWidth(),
height: this.element.outerHeight(),
top: this.element.css("top"),
left: this.element.css("left")
})
);
//Overwrite the original this.element
this.element = this.element.parent().data(
"ui-resizable", this.element.data("ui-resizable")
);
this.elementIsWrapper = true;
//Move margins to the wrapper
this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
//Prevent Safari textarea resize
this.originalResizeStyle = this.originalElement.css("resize");
this.originalElement.css("resize", "none");
//Push the actual element to our proportionallyResize internal array
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
// avoid IE jump (hard set the margin)
this.originalElement.css({ margin: this.originalElement.css("margin") });
// fix handlers offset
this._proportionallyResize();
}
this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
if(this.handles.constructor === String) {
if ( this.handles === "all") {
this.handles = "n,e,s,w,se,sw,ne,nw";
}
n = this.handles.split(",");
this.handles = {};
for(i = 0; i < n.length; i++) {
handle = $.trim(n[i]);
hname = "ui-resizable-"+handle;
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
// Apply zIndex to all handles - see #7960
axis.css({ zIndex: o.zIndex });
//TODO : What's going on here?
if ("se" === handle) {
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
}
//Insert into internal handles object and append to element
this.handles[handle] = ".ui-resizable-"+handle;
this.element.append(axis);
}
}
this._renderAxis = function(target) {
var i, axis, padPos, padWrapper;
target = target || this.element;
for(i in this.handles) {
if(this.handles[i].constructor === String) {
this.handles[i] = $(this.handles[i], this.element).show();
}
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
axis = $(this.handles[i], this.element);
//Checking the correct pad and border
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
//The padding type i have to apply...
padPos = [ "padding",
/ne|nw|n/.test(i) ? "Top" :
/se|sw|s/.test(i) ? "Bottom" :
/^e$/.test(i) ? "Right" : "Left" ].join("");
target.css(padPos, padWrapper);
this._proportionallyResize();
}
//TODO: What's that good for? There's not anything to be executed left
if(!$(this.handles[i]).length) {
continue;
}
}
};
//TODO: make renderAxis a prototype function
this._renderAxis(this.element);
this._handles = $(".ui-resizable-handle", this.element)
.disableSelection();
//Matching axis name
this._handles.mouseover(function() {
if (!that.resizing) {
if (this.className) {
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
}
//Axis, default = se
that.axis = axis && axis[1] ? axis[1] : "se";
}
});
//If we want to auto hide the elements
if (o.autoHide) {
this._handles.hide();
$(this.element)
.addClass("ui-resizable-autohide")
.mouseenter(function() {
if (o.disabled) {
return;
}
$(this).removeClass("ui-resizable-autohide");
that._handles.show();
})
.mouseleave(function(){
if (o.disabled) {
return;
}
if (!that.resizing) {
$(this).addClass("ui-resizable-autohide");
that._handles.hide();
}
});
}
//Initialize the mouse interaction
this._mouseInit();
},
_destroy: function() {
this._mouseDestroy();
var wrapper,
_destroy = function(exp) {
$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
};
//TODO: Unwrap at same DOM position
if (this.elementIsWrapper) {
_destroy(this.element);
wrapper = this.element;
this.originalElement.css({
position: wrapper.css("position"),
width: wrapper.outerWidth(),
height: wrapper.outerHeight(),
top: wrapper.css("top"),
left: wrapper.css("left")
}).insertAfter( wrapper );
wrapper.remove();
}
this.originalElement.css("resize", this.originalResizeStyle);
_destroy(this.originalElement);
return this;
},
_mouseCapture: function(event) {
var i, handle,
capture = false;
for (i in this.handles) {
handle = $(this.handles[i])[0];
if (handle === event.target || $.contains(handle, event.target)) {
capture = true;
}
}
return !this.options.disabled && capture;
},
_mouseStart: function(event) {
var curleft, curtop, cursor,
o = this.options,
iniPos = this.element.position(),
el = this.element;
this.resizing = true;
// bugfix for http://dev.jquery.com/ticket/1749
if ( (/absolute/).test( el.css("position") ) ) {
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
} else if (el.is(".ui-draggable")) {
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
}
this._renderProxy();
curleft = num(this.helper.css("left"));
curtop = num(this.helper.css("top"));
if (o.containment) {
curleft += $(o.containment).scrollLeft() || 0;
curtop += $(o.containment).scrollTop() || 0;
}
//Store needed variables
this.offset = this.helper.offset();
this.position = { left: curleft, top: curtop };
this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
this.originalPosition = { left: curleft, top: curtop };
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
this.originalMousePosition = { left: event.pageX, top: event.pageY };
//Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
cursor = $(".ui-resizable-" + this.axis).css("cursor");
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
el.addClass("ui-resizable-resizing");
this._propagate("start", event);
return true;
},
_mouseDrag: function(event) {
//Increase performance, avoid regex
var data,
el = this.helper, props = {},
smp = this.originalMousePosition,
a = this.axis,
prevTop = this.position.top,
prevLeft = this.position.left,
prevWidth = this.size.width,
prevHeight = this.size.height,
dx = (event.pageX-smp.left)||0,
dy = (event.pageY-smp.top)||0,
trigger = this._change[a];
if (!trigger) {
return false;
}
// Calculate the attrs that will be change
data = trigger.apply(this, [event, dx, dy]);
// Put this in the mouseDrag handler since the user can start pressing shift while resizing
this._updateVirtualBoundaries(event.shiftKey);
if (this._aspectRatio || event.shiftKey) {
data = this._updateRatio(data, event);
}
data = this._respectSize(data, event);
this._updateCache(data);
// plugins callbacks need to be called first
this._propagate("resize", event);
if (this.position.top !== prevTop) {
props.top = this.position.top + "px";
}
if (this.position.left !== prevLeft) {
props.left = this.position.left + "px";
}
if (this.size.width !== prevWidth) {
props.width = this.size.width + "px";
}
if (this.size.height !== prevHeight) {
props.height = this.size.height + "px";
}
el.css(props);
if (!this._helper && this._proportionallyResizeElements.length) {
this._proportionallyResize();
}
// Call the user callback if the element was resized
if ( ! $.isEmptyObject(props) ) {
this._trigger("resize", event, this.ui());
}
return false;
},
_mouseStop: function(event) {
this.resizing = false;
var pr, ista, soffseth, soffsetw, s, left, top,
o = this.options, that = this;
if(this._helper) {
pr = this._proportionallyResizeElements;
ista = pr.length && (/textarea/i).test(pr[0].nodeName);
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffsetw = ista ? 0 : that.sizeDiff.width;
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
if (!o.animate) {
this.element.css($.extend(s, { top: top, left: left }));
}
that.helper.height(that.size.height);
that.helper.width(that.size.width);
if (this._helper && !o.animate) {
this._proportionallyResize();
}
}
$("body").css("cursor", "auto");
this.element.removeClass("ui-resizable-resizing");
this._propagate("stop", event);
if (this._helper) {
this.helper.remove();
}
return false;
},
_updateVirtualBoundaries: function(forceAspectRatio) {
var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
o = this.options;
b = {
minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
};
if(this._aspectRatio || forceAspectRatio) {
// We want to create an enclosing box whose aspect ration is the requested one
// First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
pMinWidth = b.minHeight * this.aspectRatio;
pMinHeight = b.minWidth / this.aspectRatio;
pMaxWidth = b.maxHeight * this.aspectRatio;
pMaxHeight = b.maxWidth / this.aspectRatio;
if(pMinWidth > b.minWidth) {
b.minWidth = pMinWidth;
}
if(pMinHeight > b.minHeight) {
b.minHeight = pMinHeight;
}
if(pMaxWidth < b.maxWidth) {
b.maxWidth = pMaxWidth;
}
if(pMaxHeight < b.maxHeight) {
b.maxHeight = pMaxHeight;
}
}
this._vBoundaries = b;
},
_updateCache: function(data) {
this.offset = this.helper.offset();
if (isNumber(data.left)) {
this.position.left = data.left;
}
if (isNumber(data.top)) {
this.position.top = data.top;
}
if (isNumber(data.height)) {
this.size.height = data.height;
}
if (isNumber(data.width)) {
this.size.width = data.width;
}
},
_updateRatio: function( data ) {
var cpos = this.position,
csize = this.size,
a = this.axis;
if (isNumber(data.height)) {
data.width = (data.height * this.aspectRatio);
} else if (isNumber(data.width)) {
data.height = (data.width / this.aspectRatio);
}
if (a === "sw") {
data.left = cpos.left + (csize.width - data.width);
data.top = null;
}
if (a === "nw") {
data.top = cpos.top + (csize.height - data.height);
data.left = cpos.left + (csize.width - data.width);
}
return data;
},
_respectSize: function( data ) {
var o = this._vBoundaries,
a = this.axis,
ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
dw = this.originalPosition.left + this.originalSize.width,
dh = this.position.top + this.size.height,
cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
if (isminw) {
data.width = o.minWidth;
}
if (isminh) {
data.height = o.minHeight;
}
if (ismaxw) {
data.width = o.maxWidth;
}
if (ismaxh) {
data.height = o.maxHeight;
}
if (isminw && cw) {
data.left = dw - o.minWidth;
}
if (ismaxw && cw) {
data.left = dw - o.maxWidth;
}
if (isminh && ch) {
data.top = dh - o.minHeight;
}
if (ismaxh && ch) {
data.top = dh - o.maxHeight;
}
// fixing jump error on top/left - bug #2330
if (!data.width && !data.height && !data.left && data.top) {
data.top = null;
} else if (!data.width && !data.height && !data.top && data.left) {
data.left = null;
}
return data;
},
_proportionallyResize: function() {
if (!this._proportionallyResizeElements.length) {
return;
}
var i, j, borders, paddings, prel,
element = this.helper || this.element;
for ( i=0; i < this._proportionallyResizeElements.length; i++) {
prel = this._proportionallyResizeElements[i];
if (!this.borderDif) {
this.borderDif = [];
borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
for ( j = 0; j < borders.length; j++ ) {
this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
}
}
prel.css({
height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
});
}
},
_renderProxy: function() {
var el = this.element, o = this.options;
this.elementOffset = el.offset();
if(this._helper) {
this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
this.helper.addClass(this._helper).css({
width: this.element.outerWidth() - 1,
height: this.element.outerHeight() - 1,
position: "absolute",
left: this.elementOffset.left +"px",
top: this.elementOffset.top +"px",
zIndex: ++o.zIndex //TODO: Don't modify option
});
this.helper
.appendTo("body")
.disableSelection();
} else {
this.helper = this.element;
}
},
_change: {
e: function(event, dx) {
return { width: this.originalSize.width + dx };
},
w: function(event, dx) {
var cs = this.originalSize, sp = this.originalPosition;
return { left: sp.left + dx, width: cs.width - dx };
},
n: function(event, dx, dy) {
var cs = this.originalSize, sp = this.originalPosition;
return { top: sp.top + dy, height: cs.height - dy };
},
s: function(event, dx, dy) {
return { height: this.originalSize.height + dy };
},
se: function(event, dx, dy) {
return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
},
sw: function(event, dx, dy) {
return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
},
ne: function(event, dx, dy) {
return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
},
nw: function(event, dx, dy) {
return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
}
},
_propagate: function(n, event) {
$.ui.plugin.call(this, n, [event, this.ui()]);
(n !== "resize" && this._trigger(n, event, this.ui()));
},
plugins: {},
ui: function() {
return {
originalElement: this.originalElement,
element: this.element,
helper: this.helper,
position: this.position,
size: this.size,
originalSize: this.originalSize,
originalPosition: this.originalPosition
};
}
});
/*
* Resizable Extensions
*/
$.ui.plugin.add("resizable", "animate", {
stop: function( event ) {
var that = $(this).data("ui-resizable"),
o = that.options,
pr = that._proportionallyResizeElements,
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffsetw = ista ? 0 : that.sizeDiff.width,
style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
that.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), {
duration: o.animateDuration,
easing: o.animateEasing,
step: function() {
var data = {
width: parseInt(that.element.css("width"), 10),
height: parseInt(that.element.css("height"), 10),
top: parseInt(that.element.css("top"), 10),
left: parseInt(that.element.css("left"), 10)
};
if (pr && pr.length) {
$(pr[0]).css({ width: data.width, height: data.height });
}
// propagating resize, and updating values for each animation step
that._updateCache(data);
that._propagate("resize", event);
}
}
);
}
});
$.ui.plugin.add("resizable", "containment", {
start: function() {
var element, p, co, ch, cw, width, height,
that = $(this).data("ui-resizable"),
o = that.options,
el = that.element,
oc = o.containment,
ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
if (!ce) {
return;
}
that.containerElement = $(ce);
if (/document/.test(oc) || oc === document) {
that.containerOffset = { left: 0, top: 0 };
that.containerPosition = { left: 0, top: 0 };
that.parentData = {
element: $(document), left: 0, top: 0,
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
};
}
// i'm a node, so compute top, left, right, bottom
else {
element = $(ce);
p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
that.containerOffset = element.offset();
that.containerPosition = element.position();
that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
co = that.containerOffset;
ch = that.containerSize.height;
cw = that.containerSize.width;
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height
};
}
},
resize: function( event ) {
var woset, hoset, isParent, isOffsetRelative,
that = $(this).data("ui-resizable"),
o = that.options,
co = that.containerOffset, cp = that.position,
pRatio = that._aspectRatio || event.shiftKey,
cop = { top:0, left:0 }, ce = that.containerElement;
if (ce[0] !== document && (/static/).test(ce.css("position"))) {
cop = co;
}
if (cp.left < (that._helper ? co.left : 0)) {
that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
if (pRatio) {
that.size.height = that.size.width / that.aspectRatio;
}
that.position.left = o.helper ? co.left : 0;
}
if (cp.top < (that._helper ? co.top : 0)) {
that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
if (pRatio) {
that.size.width = that.size.height * that.aspectRatio;
}
that.position.top = that._helper ? co.top : 0;
}
that.offset.left = that.parentData.left+that.position.left;
that.offset.top = that.parentData.top+that.position.top;
woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
isParent = that.containerElement.get(0) === that.element.parent().get(0);
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
if ( isParent && isOffsetRelative ) {
woset -= Math.abs( that.parentData.left );
}
if (woset + that.size.width >= that.parentData.width) {
that.size.width = that.parentData.width - woset;
if (pRatio) {
that.size.height = that.size.width / that.aspectRatio;
}
}
if (hoset + that.size.height >= that.parentData.height) {
that.size.height = that.parentData.height - hoset;
if (pRatio) {
that.size.width = that.size.height * that.aspectRatio;
}
}
},
stop: function(){
var that = $(this).data("ui-resizable"),
o = that.options,
co = that.containerOffset,
cop = that.containerPosition,
ce = that.containerElement,
helper = $(that.helper),
ho = helper.offset(),
w = helper.outerWidth() - that.sizeDiff.width,
h = helper.outerHeight() - that.sizeDiff.height;
if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
}
});
$.ui.plugin.add("resizable", "alsoResize", {
start: function () {
var that = $(this).data("ui-resizable"),
o = that.options,
_store = function (exp) {
$(exp).each(function() {
var el = $(this);
el.data("ui-resizable-alsoresize", {
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
});
});
};
if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
}else{
_store(o.alsoResize);
}
},
resize: function (event, ui) {
var that = $(this).data("ui-resizable"),
o = that.options,
os = that.originalSize,
op = that.originalPosition,
delta = {
height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
},
_alsoResize = function (exp, c) {
$(exp).each(function() {
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
$.each(css, function (i, prop) {
var sum = (start[prop]||0) + (delta[prop]||0);
if (sum && sum >= 0) {
style[prop] = sum || null;
}
});
el.css(style);
});
};
if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
}else{
_alsoResize(o.alsoResize);
}
},
stop: function () {
$(this).removeData("resizable-alsoresize");
}
});
$.ui.plugin.add("resizable", "ghost", {
start: function() {
var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
that.ghost = that.originalElement.clone();
that.ghost
.css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass("ui-resizable-ghost")
.addClass(typeof o.ghost === "string" ? o.ghost : "");
that.ghost.appendTo(that.helper);
},
resize: function(){
var that = $(this).data("ui-resizable");
if (that.ghost) {
that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
}
},
stop: function() {
var that = $(this).data("ui-resizable");
if (that.ghost && that.helper) {
that.helper.get(0).removeChild(that.ghost.get(0));
}
}
});
$.ui.plugin.add("resizable", "grid", {
resize: function() {
var that = $(this).data("ui-resizable"),
o = that.options,
cs = that.size,
os = that.originalSize,
op = that.originalPosition,
a = that.axis,
grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
gridX = (grid[0]||1),
gridY = (grid[1]||1),
ox = Math.round((cs.width - os.width) / gridX) * gridX,
oy = Math.round((cs.height - os.height) / gridY) * gridY,
newWidth = os.width + ox,
newHeight = os.height + oy,
isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
isMinWidth = o.minWidth && (o.minWidth > newWidth),
isMinHeight = o.minHeight && (o.minHeight > newHeight);
o.grid = grid;
if (isMinWidth) {
newWidth = newWidth + gridX;
}
if (isMinHeight) {
newHeight = newHeight + gridY;
}
if (isMaxWidth) {
newWidth = newWidth - gridX;
}
if (isMaxHeight) {
newHeight = newHeight - gridY;
}
if (/^(se|s|e)$/.test(a)) {
that.size.width = newWidth;
that.size.height = newHeight;
} else if (/^(ne)$/.test(a)) {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.top = op.top - oy;
} else if (/^(sw)$/.test(a)) {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.left = op.left - ox;
} else {
if ( newHeight - gridY > 0 ) {
that.size.height = newHeight;
that.position.top = op.top - oy;
} else {
that.size.height = gridY;
that.position.top = op.top + os.height - gridY;
}
if ( newWidth - gridX > 0 ) {
that.size.width = newWidth;
that.position.left = op.left - ox;
} else {
that.size.width = gridX;
that.position.left = op.left + os.width - gridX;
}
}
}
});
})(jQuery);
(function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, {
version: "1.10.4",
options: {
appendTo: "body",
autoRefresh: true,
distance: 0,
filter: "*",
tolerance: "touch",
// callbacks
selected: null,
selecting: null,
start: null,
stop: null,
unselected: null,
unselecting: null
},
_create: function() {
var selectees,
that = this;
this.element.addClass("ui-selectable");
this.dragged = false;
// cache selectee children based on filter
this.refresh = function() {
selectees = $(that.options.filter, that.element[0]);
selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this),
pos = $this.offset();
$.data(this, "selectable-item", {
element: this,
$element: $this,
left: pos.left,
top: pos.top,
right: pos.left + $this.outerWidth(),
bottom: pos.top + $this.outerHeight(),
startselected: false,
selected: $this.hasClass("ui-selected"),
selecting: $this.hasClass("ui-selecting"),
unselecting: $this.hasClass("ui-unselecting")
});
});
};
this.refresh();
this.selectees = selectees.addClass("ui-selectee");
this._mouseInit();
this.helper = $("<div class='ui-selectable-helper'></div>");
},
_destroy: function() {
this.selectees
.removeClass("ui-selectee")
.removeData("selectable-item");
this.element
.removeClass("ui-selectable ui-selectable-disabled");
this._mouseDestroy();
},
_mouseStart: function(event) {
var that = this,
options = this.options;
this.opos = [event.pageX, event.pageY];
if (this.options.disabled) {
return;
}
this.selectees = $(options.filter, this.element[0]);
this._trigger("start", event);
$(options.appendTo).append(this.helper);
// position helper (lasso)
this.helper.css({
"left": event.pageX,
"top": event.pageY,
"width": 0,
"height": 0
});
if (options.autoRefresh) {
this.refresh();
}
this.selectees.filter(".ui-selected").each(function() {
var selectee = $.data(this, "selectable-item");
selectee.startselected = true;
if (!event.metaKey && !event.ctrlKey) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
});
$(event.target).parents().addBack().each(function() {
var doSelect,
selectee = $.data(this, "selectable-item");
if (selectee) {
doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
selectee.$element
.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
selectee.unselecting = !doSelect;
selectee.selecting = doSelect;
selectee.selected = doSelect;
// selectable (UN)SELECTING callback
if (doSelect) {
that._trigger("selecting", event, {
selecting: selectee.element
});
} else {
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
return false;
}
});
},
_mouseDrag: function(event) {
this.dragged = true;
if (this.options.disabled) {
return;
}
var tmp,
that = this,
options = this.options,
x1 = this.opos[0],
y1 = this.opos[1],
x2 = event.pageX,
y2 = event.pageY;
if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
this.selectees.each(function() {
var selectee = $.data(this, "selectable-item"),
hit = false;
//prevent helper from being selected if appendTo: selectable
if (!selectee || selectee.element === that.element[0]) {
return;
}
if (options.tolerance === "touch") {
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
} else if (options.tolerance === "fit") {
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
}
if (hit) {
// SELECT
if (selectee.selected) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
}
if (selectee.unselecting) {
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
}
if (!selectee.selecting) {
selectee.$element.addClass("ui-selecting");
selectee.selecting = true;
// selectable SELECTING callback
that._trigger("selecting", event, {
selecting: selectee.element
});
}
} else {
// UNSELECT
if (selectee.selecting) {
if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
selectee.$element.addClass("ui-selected");
selectee.selected = true;
} else {
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
if (selectee.startselected) {
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
}
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
}
if (selectee.selected) {
if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
}
}
});
return false;
},
_mouseStop: function(event) {
var that = this;
this.dragged = false;
$(".ui-unselecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
selectee.startselected = false;
that._trigger("unselected", event, {
unselected: selectee.element
});
});
$(".ui-selecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
that._trigger("selected", event, {
selected: selectee.element
});
});
this._trigger("stop", event);
this.helper.remove();
return false;
}
});
})(jQuery);
(function( $, undefined ) {
function isOverAxis( x, reference, size ) {
return ( x > reference ) && ( x < ( reference + size ) );
}
function isFloating(item) {
return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
}
$.widget("ui.sortable", $.ui.mouse, {
version: "1.10.4",
widgetEventPrefix: "sort",
ready: false,
options: {
appendTo: "parent",
axis: false,
connectWith: false,
containment: false,
cursor: "auto",
cursorAt: false,
dropOnEmpty: true,
forcePlaceholderSize: false,
forceHelperSize: false,
grid: false,
handle: false,
helper: "original",
items: "> *",
opacity: false,
placeholder: false,
revert: false,
scroll: true,
scrollSensitivity: 20,
scrollSpeed: 20,
scope: "default",
tolerance: "intersect",
zIndex: 1000,
// callbacks
activate: null,
beforeStop: null,
change: null,
deactivate: null,
out: null,
over: null,
receive: null,
remove: null,
sort: null,
start: null,
stop: null,
update: null
},
_create: function() {
var o = this.options;
this.containerCache = {};
this.element.addClass("ui-sortable");
//Get the items
this.refresh();
//Let's determine if the items are being displayed horizontally
this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
//Let's determine the parent's offset
this.offset = this.element.offset();
//Initialize mouse events for interaction
this._mouseInit();
//We're ready to go
this.ready = true;
},
_destroy: function() {
this.element
.removeClass("ui-sortable ui-sortable-disabled");
this._mouseDestroy();
for ( var i = this.items.length - 1; i >= 0; i-- ) {
this.items[i].item.removeData(this.widgetName + "-item");
}
return this;
},
_setOption: function(key, value){
if ( key === "disabled" ) {
this.options[ key ] = value;
this.widget().toggleClass( "ui-sortable-disabled", !!value );
} else {
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
$.Widget.prototype._setOption.apply(this, arguments);
}
},
_mouseCapture: function(event, overrideHandle) {
var currentItem = null,
validHandle = false,
that = this;
if (this.reverting) {
return false;
}
if(this.options.disabled || this.options.type === "static") {
return false;
}
//We have to refresh the items data once first
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in this.items
$(event.target).parents().each(function() {
if($.data(this, that.widgetName + "-item") === that) {
currentItem = $(this);
return false;
}
});
if($.data(event.target, that.widgetName + "-item") === that) {
currentItem = $(event.target);
}
if(!currentItem) {
return false;
}
if(this.options.handle && !overrideHandle) {
$(this.options.handle, currentItem).find("*").addBack().each(function() {
if(this === event.target) {
validHandle = true;
}
});
if(!validHandle) {
return false;
}
}
this.currentItem = currentItem;
this._removeCurrentsFromItems();
return true;
},
_mouseStart: function(event, overrideHandle, noActivation) {
var i, body,
o = this.options;
this.currentContainer = this;
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
this.refreshPositions();
//Create and append the visible helper
this.helper = this._createHelper(event);
//Cache the helper size
this._cacheHelperProportions();
/*
* - Position generation -
* This block generates everything position related - it's the core of draggables.
*/
//Cache the margins of the original element
this._cacheMargins();
//Get the next scrolling parent
this.scrollParent = this.helper.scrollParent();
//The element's absolute position on the page minus margins
this.offset = this.currentItem.offset();
this.offset = {
top: this.offset.top - this.margins.top,
left: this.offset.left - this.margins.left
};
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
top: event.pageY - this.offset.top
},
parent: this._getParentOffset(),
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
// Only after we got the offset, we can change the helper's position to absolute
// TODO: Still need to figure out a way to make relative sorting possible
this.helper.css("position", "absolute");
this.cssPosition = this.helper.css("position");
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
this.originalPageY = event.pageY;
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
//Cache the former DOM position
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
if(this.helper[0] !== this.currentItem[0]) {
this.currentItem.hide();
}
//Create the placeholder
this._createPlaceholder();
//Set a containment if given in the options
if(o.containment) {
this._setContainment();
}
if( o.cursor && o.cursor !== "auto" ) { // cursor option
body = this.document.find( "body" );
// support: IE
this.storedCursor = body.css( "cursor" );
body.css( "cursor", o.cursor );
this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
}
if(o.opacity) { // opacity option
if (this.helper.css("opacity")) {
this._storedOpacity = this.helper.css("opacity");
}
this.helper.css("opacity", o.opacity);
}
if(o.zIndex) { // zIndex option
if (this.helper.css("zIndex")) {
this._storedZIndex = this.helper.css("zIndex");
}
this.helper.css("zIndex", o.zIndex);
}
//Prepare scrolling
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
this.overflowOffset = this.scrollParent.offset();
}
//Call callbacks
this._trigger("start", event, this._uiHash());
//Recache the helper size
if(!this._preserveHelperProportions) {
this._cacheHelperProportions();
}
//Post "activate" events to possible containers
if( !noActivation ) {
for ( i = this.containers.length - 1; i >= 0; i-- ) {
this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
}
}
//Prepare possible droppables
if($.ui.ddmanager) {
$.ui.ddmanager.current = this;
}
if ($.ui.ddmanager && !o.dropBehaviour) {
$.ui.ddmanager.prepareOffsets(this, event);
}
this.dragging = true;
this.helper.addClass("ui-sortable-helper");
this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
return true;
},
_mouseDrag: function(event) {
var i, item, itemElement, intersection,
o = this.options,
scrolled = false;
//Compute the helpers position
this.position = this._generatePosition(event);
this.positionAbs = this._convertPositionTo("absolute");
if (!this.lastPositionAbs) {
this.lastPositionAbs = this.positionAbs;
}
//Do scrolling
if(this.options.scroll) {
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
} else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
}
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
} else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
}
} else {
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
}
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
}
}
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
$.ui.ddmanager.prepareOffsets(this, event);
}
}
//Regenerate the absolute position used for position checks
this.positionAbs = this._convertPositionTo("absolute");
//Set the helper position
if(!this.options.axis || this.options.axis !== "y") {
this.helper[0].style.left = this.position.left+"px";
}
if(!this.options.axis || this.options.axis !== "x") {
this.helper[0].style.top = this.position.top+"px";
}
//Rearrange
for (i = this.items.length - 1; i >= 0; i--) {
//Cache variables and intersection, continue if no intersection
item = this.items[i];
itemElement = item.item[0];
intersection = this._intersectsWithPointer(item);
if (!intersection) {
continue;
}
// Only put the placeholder inside the current Container, skip all
// items from other containers. This works because when moving
// an item from one container to another the
// currentContainer is switched before the placeholder is moved.
//
// Without this, moving items in "sub-sortables" can cause
// the placeholder to jitter beetween the outer and inner container.
if (item.instance !== this.currentContainer) {
continue;
}
// cannot intersect with itself
// no useless actions that have been done before
// no action if the item moved is the parent of the item checked
if (itemElement !== this.currentItem[0] &&
this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
!$.contains(this.placeholder[0], itemElement) &&
(this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
) {
this.direction = intersection === 1 ? "down" : "up";
if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
this._rearrange(event, item);
} else {
break;
}
this._trigger("change", event, this._uiHash());
break;
}
}
//Post events to containers
this._contactContainers(event);
//Interconnect with droppables
if($.ui.ddmanager) {
$.ui.ddmanager.drag(this, event);
}
//Call callbacks
this._trigger("sort", event, this._uiHash());
this.lastPositionAbs = this.positionAbs;
return false;
},
_mouseStop: function(event, noPropagation) {
if(!event) {
return;
}
//If we are using droppables, inform the manager about the drop
if ($.ui.ddmanager && !this.options.dropBehaviour) {
$.ui.ddmanager.drop(this, event);
}
if(this.options.revert) {
var that = this,
cur = this.placeholder.offset(),
axis = this.options.axis,
animation = {};
if ( !axis || axis === "x" ) {
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
}
if ( !axis || axis === "y" ) {
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
}
this.reverting = true;
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
that._clear(event);
});
} else {
this._clear(event, noPropagation);
}
return false;
},
cancel: function() {
if(this.dragging) {
this._mouseUp({ target: null });
if(this.options.helper === "original") {
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
} else {
this.currentItem.show();
}
//Post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
this.containers[i]._trigger("deactivate", null, this._uiHash(this));
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", null, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
}
if (this.placeholder) {
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
if(this.placeholder[0].parentNode) {
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
}
if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
this.helper.remove();
}
$.extend(this, {
helper: null,
dragging: false,
reverting: false,
_noFinalSort: null
});
if(this.domPosition.prev) {
$(this.domPosition.prev).after(this.currentItem);
} else {
$(this.domPosition.parent).prepend(this.currentItem);
}
}
return this;
},
serialize: function(o) {
var items = this._getItemsAsjQuery(o && o.connected),
str = [];
o = o || {};
$(items).each(function() {
var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
if (res) {
str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
}
});
if(!str.length && o.key) {
str.push(o.key + "=");
}
return str.join("&");
},
toArray: function(o) {
var items = this._getItemsAsjQuery(o && o.connected),
ret = [];
o = o || {};
items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
return ret;
},
/* Be careful with the following core functions */
_intersectsWith: function(item) {
var x1 = this.positionAbs.left,
x2 = x1 + this.helperProportions.width,
y1 = this.positionAbs.top,
y2 = y1 + this.helperProportions.height,
l = item.left,
r = l + item.width,
t = item.top,
b = t + item.height,
dyClick = this.offset.click.top,
dxClick = this.offset.click.left,
isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
isOverElement = isOverElementHeight && isOverElementWidth;
if ( this.options.tolerance === "pointer" ||
this.options.forcePointerForContainers ||
(this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
) {
return isOverElement;
} else {
return (l < x1 + (this.helperProportions.width / 2) && // Right Half
x2 - (this.helperProportions.width / 2) < r && // Left Half
t < y1 + (this.helperProportions.height / 2) && // Bottom Half
y2 - (this.helperProportions.height / 2) < b ); // Top Half
}
},
_intersectsWithPointer: function(item) {
var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
if (!isOverElement) {
return false;
}
return this.floating ?
( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
: ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
},
_intersectsWithSides: function(item) {
var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
if (this.floating && horizontalDirection) {
return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
} else {
return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
}
},
_getDragVerticalDirection: function() {
var delta = this.positionAbs.top - this.lastPositionAbs.top;
return delta !== 0 && (delta > 0 ? "down" : "up");
},
_getDragHorizontalDirection: function() {
var delta = this.positionAbs.left - this.lastPositionAbs.left;
return delta !== 0 && (delta > 0 ? "right" : "left");
},
refresh: function(event) {
this._refreshItems(event);
this.refreshPositions();
return this;
},
_connectWith: function() {
var options = this.options;
return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
},
_getItemsAsjQuery: function(connected) {
var i, j, cur, inst,
items = [],
queries = [],
connectWith = this._connectWith();
if(connectWith && connected) {
for (i = connectWith.length - 1; i >= 0; i--){
cur = $(connectWith[i]);
for ( j = cur.length - 1; j >= 0; j--){
inst = $.data(cur[j], this.widgetFullName);
if(inst && inst !== this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
}
}
}
}
queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
function addItems() {
items.push( this );
}
for (i = queries.length - 1; i >= 0; i--){
queries[i][0].each( addItems );
}
return $(items);
},
_removeCurrentsFromItems: function() {
var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
this.items = $.grep(this.items, function (item) {
for (var j=0; j < list.length; j++) {
if(list[j] === item.item[0]) {
return false;
}
}
return true;
});
},
_refreshItems: function(event) {
this.items = [];
this.containers = [this];
var i, j, cur, inst, targetData, _queries, item, queriesLength,
items = this.items,
queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
connectWith = this._connectWith();
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
for (i = connectWith.length - 1; i >= 0; i--){
cur = $(connectWith[i]);
for (j = cur.length - 1; j >= 0; j--){
inst = $.data(cur[j], this.widgetFullName);
if(inst && inst !== this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
this.containers.push(inst);
}
}
}
}
for (i = queries.length - 1; i >= 0; i--) {
targetData = queries[i][1];
_queries = queries[i][0];
for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
item = $(_queries[j]);
item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
items.push({
item: item,
instance: targetData,
width: 0, height: 0,
left: 0, top: 0
});
}
}
},
refreshPositions: function(fast) {
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
if(this.offsetParent && this.helper) {
this.offset.parent = this._getParentOffset();
}
var i, item, t, p;
for (i = this.items.length - 1; i >= 0; i--){
item = this.items[i];
//We ignore calculating positions of all connected containers when we're not over them
if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
continue;
}
t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
if (!fast) {
item.width = t.outerWidth();
item.height = t.outerHeight();
}
p = t.offset();
item.left = p.left;
item.top = p.top;
}
if(this.options.custom && this.options.custom.refreshContainers) {
this.options.custom.refreshContainers.call(this);
} else {
for (i = this.containers.length - 1; i >= 0; i--){
p = this.containers[i].element.offset();
this.containers[i].containerCache.left = p.left;
this.containers[i].containerCache.top = p.top;
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
}
}
return this;
},
_createPlaceholder: function(that) {
that = that || this;
var className,
o = that.options;
if(!o.placeholder || o.placeholder.constructor === String) {
className = o.placeholder;
o.placeholder = {
element: function() {
var nodeName = that.currentItem[0].nodeName.toLowerCase(),
element = $( "<" + nodeName + ">", that.document[0] )
.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
.removeClass("ui-sortable-helper");
if ( nodeName === "tr" ) {
that.currentItem.children().each(function() {
$( "<td> </td>", that.document[0] )
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
.appendTo( element );
});
} else if ( nodeName === "img" ) {
element.attr( "src", that.currentItem.attr( "src" ) );
}
if ( !className ) {
element.css( "visibility", "hidden" );
}
return element;
},
update: function(container, p) {
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
if(className && !o.forcePlaceholderSize) {
return;
}
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
}
};
}
//Create the placeholder
that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
//Append it after the actual current item
that.currentItem.after(that.placeholder);
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
o.placeholder.update(that, that.placeholder);
},
_contactContainers: function(event) {
var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
innermostContainer = null,
innermostIndex = null;
// get innermost container that intersects with item
for (i = this.containers.length - 1; i >= 0; i--) {
// never consider a container that's located within the item itself
if($.contains(this.currentItem[0], this.containers[i].element[0])) {
continue;
}
if(this._intersectsWith(this.containers[i].containerCache)) {
// if we've already found a container and it's more "inner" than this, then continue
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
continue;
}
innermostContainer = this.containers[i];
innermostIndex = i;
} else {
// container doesn't intersect. trigger "out" event if necessary
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", event, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
}
// if no intersecting containers found, return
if(!innermostContainer) {
return;
}
// move the item into the container if it's not there already
if(this.containers.length === 1) {
if (!this.containers[innermostIndex].containerCache.over) {
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
}
} else {
//When entering a new container, we will find the item with the least distance and append our item near it
dist = 10000;
itemWithLeastDistance = null;
floating = innermostContainer.floating || isFloating(this.currentItem);
posProperty = floating ? "left" : "top";
sizeProperty = floating ? "width" : "height";
base = this.positionAbs[posProperty] + this.offset.click[posProperty];
for (j = this.items.length - 1; j >= 0; j--) {
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
continue;
}
if(this.items[j].item[0] === this.currentItem[0]) {
continue;
}
if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
continue;
}
cur = this.items[j].item.offset()[posProperty];
nearBottom = false;
if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
nearBottom = true;
cur += this.items[j][sizeProperty];
}
if(Math.abs(cur - base) < dist) {
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
this.direction = nearBottom ? "up": "down";
}
}
//Check if dropOnEmpty is enabled
if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
return;
}
if(this.currentContainer === this.containers[innermostIndex]) {
return;
}
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
this._trigger("change", event, this._uiHash());
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
this.currentContainer = this.containers[innermostIndex];
//Update the placeholder
this.options.placeholder.update(this.currentContainer, this.placeholder);
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
}
},
_createHelper: function(event) {
var o = this.options,
helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
//Add the helper to the DOM if that didn't happen already
if(!helper.parents("body").length) {
$(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
}
if(helper[0] === this.currentItem[0]) {
this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
}
if(!helper[0].style.width || o.forceHelperSize) {
helper.width(this.currentItem.width());
}
if(!helper[0].style.height || o.forceHelperSize) {
helper.height(this.currentItem.height());
}
return helper;
},
_adjustOffsetFromHelper: function(obj) {
if (typeof obj === "string") {
obj = obj.split(" ");
}
if ($.isArray(obj)) {
obj = {left: +obj[0], top: +obj[1] || 0};
}
if ("left" in obj) {
this.offset.click.left = obj.left + this.margins.left;
}
if ("right" in obj) {
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
}
if ("top" in obj) {
this.offset.click.top = obj.top + this.margins.top;
}
if ("bottom" in obj) {
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
}
},
_getParentOffset: function() {
//Get the offsetParent and cache its position
this.offsetParent = this.helper.offsetParent();
var po = this.offsetParent.offset();
// This is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
// This needs to be actually done for all browsers, since pageX/pageY includes this information
// with an ugly IE fix
if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
po = { top: 0, left: 0 };
}
return {
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
};
},
_getRelativeOffset: function() {
if(this.cssPosition === "relative") {
var p = this.currentItem.position();
return {
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
};
} else {
return { top: 0, left: 0 };
}
},
_cacheMargins: function() {
this.margins = {
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
};
},
_cacheHelperProportions: function() {
this.helperProportions = {
width: this.helper.outerWidth(),
height: this.helper.outerHeight()
};
},
_setContainment: function() {
var ce, co, over,
o = this.options;
if(o.containment === "parent") {
o.containment = this.helper[0].parentNode;
}
if(o.containment === "document" || o.containment === "window") {
this.containment = [
0 - this.offset.relative.left - this.offset.parent.left,
0 - this.offset.relative.top - this.offset.parent.top,
$(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
];
}
if(!(/^(document|window|parent)$/).test(o.containment)) {
ce = $(o.containment)[0];
co = $(o.containment).offset();
over = ($(ce).css("overflow") !== "hidden");
this.containment = [
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
];
}
},
_convertPositionTo: function(d, pos) {
if(!pos) {
pos = this.position;
}
var mod = d === "absolute" ? 1 : -1,
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
)
};
},
_generatePosition: function(event) {
var top, left,
o = this.options,
pageX = event.pageX,
pageY = event.pageY,
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
// This is another very weird special case that only happens for relative elements:
// 1. If the css position is relative
// 2. and the scroll parent is the document or similar to the offset parent
// we have to refresh the relative offset during the scroll so there are no jumps
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
this.offset.relative = this._getRelativeOffset();
}
/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
*/
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
if(this.containment) {
if(event.pageX - this.offset.click.left < this.containment[0]) {
pageX = this.containment[0] + this.offset.click.left;
}
if(event.pageY - this.offset.click.top < this.containment[1]) {
pageY = this.containment[1] + this.offset.click.top;
}
if(event.pageX - this.offset.click.left > this.containment[2]) {
pageX = this.containment[2] + this.offset.click.left;
}
if(event.pageY - this.offset.click.top > this.containment[3]) {
pageY = this.containment[3] + this.offset.click.top;
}
}
if(o.grid) {
top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
}
}
return {
top: (
pageY - // The absolute mouse position
this.offset.click.top - // Click offset (relative to the element)
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
),
left: (
pageX - // The absolute mouse position
this.offset.click.left - // Click offset (relative to the element)
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
)
};
},
_rearrange: function(event, i, a, hardRefresh) {
a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
//Various things done here to improve the performance:
// 1. we create a setTimeout, that calls refreshPositions
// 2. on the instance, we have a counter variable, that get's higher after every append
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
// 4. this lets only the last addition to the timeout stack through
this.counter = this.counter ? ++this.counter : 1;
var counter = this.counter;
this._delay(function() {
if(counter === this.counter) {
this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
}
});
},
_clear: function(event, noPropagation) {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
var i,
delayedTriggers = [];
// We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
if(!this._noFinalSort && this.currentItem.parent().length) {
this.placeholder.before(this.currentItem);
}
this._noFinalSort = null;
if(this.helper[0] === this.currentItem[0]) {
for(i in this._storedCSS) {
if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
this._storedCSS[i] = "";
}
}
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
} else {
this.currentItem.show();
}
if(this.fromOutside && !noPropagation) {
delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
}
if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
}
// Check if the items Container has Changed and trigger appropriate
// events.
if (this !== this.currentContainer) {
if(!noPropagation) {
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
}
}
//Post events to containers
function delayEvent( type, instance, container ) {
return function( event ) {
container._trigger( type, event, instance._uiHash( instance ) );
};
}
for (i = this.containers.length - 1; i >= 0; i--){
if (!noPropagation) {
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
}
if(this.containers[i].containerCache.over) {
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
this.containers[i].containerCache.over = 0;
}
}
//Do what was originally in plugins
if ( this.storedCursor ) {
this.document.find( "body" ).css( "cursor", this.storedCursor );
this.storedStylesheet.remove();
}
if(this._storedOpacity) {
this.helper.css("opacity", this._storedOpacity);
}
if(this._storedZIndex) {
this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
}
this.dragging = false;
if(this.cancelHelperRemoval) {
if(!noPropagation) {
this._trigger("beforeStop", event, this._uiHash());
for (i=0; i < delayedTriggers.length; i++) {
delayedTriggers[i].call(this, event);
} //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
}
this.fromOutside = false;
return false;
}
if(!noPropagation) {
this._trigger("beforeStop", event, this._uiHash());
}
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
if(this.helper[0] !== this.currentItem[0]) {
this.helper.remove();
}
this.helper = null;
if(!noPropagation) {
for (i=0; i < delayedTriggers.length; i++) {
delayedTriggers[i].call(this, event);
} //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
}
this.fromOutside = false;
return true;
},
_trigger: function() {
if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
this.cancel();
}
},
_uiHash: function(_inst) {
var inst = _inst || this;
return {
helper: inst.helper,
placeholder: inst.placeholder || $([]),
position: inst.position,
originalPosition: inst.originalPosition,
offset: inst.positionAbs,
item: inst.currentItem,
sender: _inst ? _inst.element : null
};
}
});
})(jQuery);
(function( $, undefined ) {
$.widget( "ui.autocomplete", {
version: "1.10.4",
defaultElement: "<input>",
options: {
appendTo: null,
autoFocus: false,
delay: 300,
minLength: 1,
position: {
my: "left top",
at: "left bottom",
collision: "none"
},
source: null,
// callbacks
change: null,
close: null,
focus: null,
open: null,
response: null,
search: null,
select: null
},
requestIndex: 0,
pending: 0,
_create: function() {
// Some browsers only repeat keydown events, not keypress events,
// so we use the suppressKeyPress flag to determine if we've already
// handled the keydown event. #7269
// Unfortunately the code for & in keypress is the same as the up arrow,
// so we use the suppressKeyPressRepeat flag to avoid handling keypress
// events when we know the keydown event was used to modify the
// search term. #7799
var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
nodeName = this.element[0].nodeName.toLowerCase(),
isTextarea = nodeName === "textarea",
isInput = nodeName === "input";
this.isMultiLine =
// Textareas are always multi-line
isTextarea ? true :
// Inputs are always single-line, even if inside a contentEditable element
// IE also treats inputs as contentEditable
isInput ? false :
// All other element types are determined by whether or not they're contentEditable
this.element.prop( "isContentEditable" );
this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
this.isNewMenu = true;
this.element
.addClass( "ui-autocomplete-input" )
.attr( "autocomplete", "off" );
this._on( this.element, {
keydown: function( event ) {
if ( this.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
suppressKeyPressRepeat = true;
return;
}
suppressKeyPress = false;
suppressInput = false;
suppressKeyPressRepeat = false;
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
suppressKeyPress = true;
this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
suppressKeyPress = true;
this._move( "nextPage", event );
break;
case keyCode.UP:
suppressKeyPress = true;
this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
suppressKeyPress = true;
this._keyEvent( "next", event );
break;
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
// when menu is open and has focus
if ( this.menu.active ) {
// #6055 - Opera still allows the keypress to occur
// which causes forms to submit
suppressKeyPress = true;
event.preventDefault();
this.menu.select( event );
}
break;
case keyCode.TAB:
if ( this.menu.active ) {
this.menu.select( event );
}
break;
case keyCode.ESCAPE:
if ( this.menu.element.is( ":visible" ) ) {
this._value( this.term );
this.close( event );
// Different browsers have different default behavior for escape
// Single press can mean undo or clear
// Double press in IE means clear the whole form
event.preventDefault();
}
break;
default:
suppressKeyPressRepeat = true;
// search timeout should be triggered before the input value is changed
this._searchTimeout( event );
break;
}
},
keypress: function( event ) {
if ( suppressKeyPress ) {
suppressKeyPress = false;
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
event.preventDefault();
}
return;
}
if ( suppressKeyPressRepeat ) {
return;
}
// replicate some key handlers to allow them to repeat in Firefox and Opera
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
this._move( "nextPage", event );
break;
case keyCode.UP:
this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
this._keyEvent( "next", event );
break;
}
},
input: function( event ) {
if ( suppressInput ) {
suppressInput = false;
event.preventDefault();
return;
}
this._searchTimeout( event );
},
focus: function() {
this.selectedItem = null;
this.previous = this._value();
},
blur: function( event ) {
if ( this.cancelBlur ) {
delete this.cancelBlur;
return;
}
clearTimeout( this.searching );
this.close( event );
this._change( event );
}
});
this._initSource();
this.menu = $( "<ul>" )
.addClass( "ui-autocomplete ui-front" )
.appendTo( this._appendTo() )
.menu({
// disable ARIA support, the live region takes care of that
role: null
})
.hide()
.data( "ui-menu" );
this._on( this.menu.element, {
mousedown: function( event ) {
// prevent moving focus out of the text field
event.preventDefault();
// IE doesn't prevent moving focus even with event.preventDefault()
// so we set a flag to know when we should ignore the blur event
this.cancelBlur = true;
this._delay(function() {
delete this.cancelBlur;
});
// clicking on the scrollbar causes focus to shift to the body
// but we can't detect a mouseup or a click immediately afterward
// so we have to track the next mousedown and close the menu if
// the user clicks somewhere outside of the autocomplete
var menuElement = this.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
this._delay(function() {
var that = this;
this.document.one( "mousedown", function( event ) {
if ( event.target !== that.element[ 0 ] &&
event.target !== menuElement &&
!$.contains( menuElement, event.target ) ) {
that.close();
}
});
});
}
},
menufocus: function( event, ui ) {
// support: Firefox
// Prevent accidental activation of menu items in Firefox (#7024 #9118)
if ( this.isNewMenu ) {
this.isNewMenu = false;
if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
this.menu.blur();
this.document.one( "mousemove", function() {
$( event.target ).trigger( event.originalEvent );
});
return;
}
}
var item = ui.item.data( "ui-autocomplete-item" );
if ( false !== this._trigger( "focus", event, { item: item } ) ) {
// use value to match what will end up in the input, if it was a key event
if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
this._value( item.value );
}
} else {
// Normally the input is populated with the item's value as the
// menu is navigated, causing screen readers to notice a change and
// announce the item. Since the focus event was canceled, this doesn't
// happen, so we update the live region so that screen readers can
// still notice the change and announce it.
this.liveRegion.text( item.value );
}
},
menuselect: function( event, ui ) {
var item = ui.item.data( "ui-autocomplete-item" ),
previous = this.previous;
// only trigger when focus was lost (click on menu)
if ( this.element[0] !== this.document[0].activeElement ) {
this.element.focus();
this.previous = previous;
// #6109 - IE triggers two focus events and the second
// is asynchronous, so we need to reset the previous
// term synchronously and asynchronously :-(
this._delay(function() {
this.previous = previous;
this.selectedItem = item;
});
}
if ( false !== this._trigger( "select", event, { item: item } ) ) {
this._value( item.value );
}
// reset the term after the select event
// this allows custom select handling to work properly
this.term = this._value();
this.close( event );
this.selectedItem = item;
}
});
this.liveRegion = $( "<span>", {
role: "status",
"aria-live": "polite"
})
.addClass( "ui-helper-hidden-accessible" )
.insertBefore( this.element );
// turning off autocomplete prevents the browser from remembering the
// value when navigating through history, so we re-enable autocomplete
// if the page is unloaded before the widget is destroyed. #7790
this._on( this.window, {
beforeunload: function() {
this.element.removeAttr( "autocomplete" );
}
});
},
_destroy: function() {
clearTimeout( this.searching );
this.element
.removeClass( "ui-autocomplete-input" )
.removeAttr( "autocomplete" );
this.menu.element.remove();
this.liveRegion.remove();
},
_setOption: function( key, value ) {
this._super( key, value );
if ( key === "source" ) {
this._initSource();
}
if ( key === "appendTo" ) {
this.menu.element.appendTo( this._appendTo() );
}
if ( key === "disabled" && value && this.xhr ) {
this.xhr.abort();
}
},
_appendTo: function() {
var element = this.options.appendTo;
if ( element ) {
element = element.jquery || element.nodeType ?
$( element ) :
this.document.find( element ).eq( 0 );
}
if ( !element ) {
element = this.element.closest( ".ui-front" );
}
if ( !element.length ) {
element = this.document[0].body;
}
return element;
},
_initSource: function() {
var array, url,
that = this;
if ( $.isArray(this.options.source) ) {
array = this.options.source;
this.source = function( request, response ) {
response( $.ui.autocomplete.filter( array, request.term ) );
};
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
if ( that.xhr ) {
that.xhr.abort();
}
that.xhr = $.ajax({
url: url,
data: request,
dataType: "json",
success: function( data ) {
response( data );
},
error: function() {
response( [] );
}
});
};
} else {
this.source = this.options.source;
}
},
_searchTimeout: function( event ) {
clearTimeout( this.searching );
this.searching = this._delay(function() {
// only search if the value has changed
if ( this.term !== this._value() ) {
this.selectedItem = null;
this.search( null, event );
}
}, this.options.delay );
},
search: function( value, event ) {
value = value != null ? value : this._value();
// always save the actual value, not the one passed as an argument
this.term = this._value();
if ( value.length < this.options.minLength ) {
return this.close( event );
}
if ( this._trigger( "search", event ) === false ) {
return;
}
return this._search( value );
},
_search: function( value ) {
this.pending++;
this.element.addClass( "ui-autocomplete-loading" );
this.cancelSearch = false;
this.source( { term: value }, this._response() );
},
_response: function() {
var index = ++this.requestIndex;
return $.proxy(function( content ) {
if ( index === this.requestIndex ) {
this.__response( content );
}
this.pending--;
if ( !this.pending ) {
this.element.removeClass( "ui-autocomplete-loading" );
}
}, this );
},
__response: function( content ) {
if ( content ) {
content = this._normalize( content );
}
this._trigger( "response", null, { content: content } );
if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
this._suggest( content );
this._trigger( "open" );
} else {
// use ._close() instead of .close() so we don't cancel future searches
this._close();
}
},
close: function( event ) {
this.cancelSearch = true;
this._close( event );
},
_close: function( event ) {
if ( this.menu.element.is( ":visible" ) ) {
this.menu.element.hide();
this.menu.blur();
this.isNewMenu = true;
this._trigger( "close", event );
}
},
_change: function( event ) {
if ( this.previous !== this._value() ) {
this._trigger( "change", event, { item: this.selectedItem } );
}
},
_normalize: function( items ) {
// assume all items have the right format when the first item is complete
if ( items.length && items[0].label && items[0].value ) {
return items;
}
return $.map( items, function( item ) {
if ( typeof item === "string" ) {
return {
label: item,
value: item
};
}
return $.extend({
label: item.label || item.value,
value: item.value || item.label
}, item );
});
},
_suggest: function( items ) {
var ul = this.menu.element.empty();
this._renderMenu( ul, items );
this.isNewMenu = true;
this.menu.refresh();
// size and position menu
ul.show();
this._resizeMenu();
ul.position( $.extend({
of: this.element
}, this.options.position ));
if ( this.options.autoFocus ) {
this.menu.next();
}
},
_resizeMenu: function() {
var ul = this.menu.element;
ul.outerWidth( Math.max(
// Firefox wraps long text (possibly a rounding bug)
// so we add 1px to avoid the wrapping (#7513)
ul.width( "" ).outerWidth() + 1,
this.element.outerWidth()
) );
},
_renderMenu: function( ul, items ) {
var that = this;
$.each( items, function( index, item ) {
that._renderItemData( ul, item );
});
},
_renderItemData: function( ul, item ) {
return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
},
_renderItem: function( ul, item ) {
return $( "<li>" )
.append( $( "<a>" ).text( item.label ) )
.appendTo( ul );
},
_move: function( direction, event ) {
if ( !this.menu.element.is( ":visible" ) ) {
this.search( null, event );
return;
}
if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
this.menu.isLastItem() && /^next/.test( direction ) ) {
this._value( this.term );
this.menu.blur();
return;
}
this.menu[ direction ]( event );
},
widget: function() {
return this.menu.element;
},
_value: function() {
return this.valueMethod.apply( this.element, arguments );
},
_keyEvent: function( keyEvent, event ) {
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
this._move( keyEvent, event );
// prevents moving cursor to beginning/end of the text field in some browsers
event.preventDefault();
}
}
});
$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
},
filter: function(array, term) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( value.label || value.value || value );
});
}
});
// live region extension, adding a `messages` option
// NOTE: This is an experimental API. We are still investigating
// a full solution for string manipulation and internationalization.
$.widget( "ui.autocomplete", $.ui.autocomplete, {
options: {
messages: {
noResults: "No search results.",
results: function( amount ) {
return amount + ( amount > 1 ? " results are" : " result is" ) +
" available, use up and down arrow keys to navigate.";
}
}
},
__response: function( content ) {
var message;
this._superApply( arguments );
if ( this.options.disabled || this.cancelSearch ) {
return;
}
if ( content && content.length ) {
message = this.options.messages.results( content.length );
} else {
message = this.options.messages.noResults;
}
this.liveRegion.text( message );
}
});
}( jQuery ));
(function( $, undefined ) {
var lastActive,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
formResetHandler = function() {
var form = $( this );
setTimeout(function() {
form.find( ":ui-button" ).button( "refresh" );
}, 1 );
},
radioGroup = function( radio ) {
var name = radio.name,
form = radio.form,
radios = $( [] );
if ( name ) {
name = name.replace( /'/g, "\\'" );
if ( form ) {
radios = $( form ).find( "[name='" + name + "']" );
} else {
radios = $( "[name='" + name + "']", radio.ownerDocument )
.filter(function() {
return !this.form;
});
}
}
return radios;
};
$.widget( "ui.button", {
version: "1.10.4",
defaultElement: "<button>",
options: {
disabled: null,
text: true,
label: null,
icons: {
primary: null,
secondary: null
}
},
_create: function() {
this.element.closest( "form" )
.unbind( "reset" + this.eventNamespace )
.bind( "reset" + this.eventNamespace, formResetHandler );
if ( typeof this.options.disabled !== "boolean" ) {
this.options.disabled = !!this.element.prop( "disabled" );
} else {
this.element.prop( "disabled", this.options.disabled );
}
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );
var that = this,
options = this.options,
toggleButton = this.type === "checkbox" || this.type === "radio",
activeClass = !toggleButton ? "ui-state-active" : "";
if ( options.label === null ) {
options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
}
this._hoverable( this.buttonElement );
this.buttonElement
.addClass( baseClasses )
.attr( "role", "button" )
.bind( "mouseenter" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
if ( this === lastActive ) {
$( this ).addClass( "ui-state-active" );
}
})
.bind( "mouseleave" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
$( this ).removeClass( activeClass );
})
.bind( "click" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
event.preventDefault();
event.stopImmediatePropagation();
}
});
// Can't use _focusable() because the element that receives focus
// and the element that gets the ui-state-focus class are different
this._on({
focus: function() {
this.buttonElement.addClass( "ui-state-focus" );
},
blur: function() {
this.buttonElement.removeClass( "ui-state-focus" );
}
});
if ( toggleButton ) {
this.element.bind( "change" + this.eventNamespace, function() {
that.refresh();
});
}
if ( this.type === "checkbox" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).addClass( "ui-state-active" );
that.buttonElement.attr( "aria-pressed", "true" );
var radio = that.element[ 0 ];
radioGroup( radio )
.not( radio )
.map(function() {
return $( this ).button( "widget" )[ 0 ];
})
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
});
} else {
this.buttonElement
.bind( "mousedown" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).addClass( "ui-state-active" );
lastActive = this;
that.document.one( "mouseup", function() {
lastActive = null;
});
})
.bind( "mouseup" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).removeClass( "ui-state-active" );
})
.bind( "keydown" + this.eventNamespace, function(event) {
if ( options.disabled ) {
return false;
}
if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
$( this ).addClass( "ui-state-active" );
}
})
// see #8559, we bind to blur here in case the button element loses
// focus between keydown and keyup, it would be left in an "active" state
.bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
$( this ).removeClass( "ui-state-active" );
});
if ( this.buttonElement.is("a") ) {
this.buttonElement.keyup(function(event) {
if ( event.keyCode === $.ui.keyCode.SPACE ) {
// TODO pass through original event correctly (just as 2nd argument doesn't work)
$( this ).click();
}
});
}
}
// TODO: pull out $.Widget's handling for the disabled option into
// $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
// be overridden by individual plugins
this._setOption( "disabled", options.disabled );
this._resetButton();
},
_determineButtonType: function() {
var ancestor, labelSelector, checked;
if ( this.element.is("[type=checkbox]") ) {
this.type = "checkbox";
} else if ( this.element.is("[type=radio]") ) {
this.type = "radio";
} else if ( this.element.is("input") ) {
this.type = "input";
} else {
this.type = "button";
}
if ( this.type === "checkbox" || this.type === "radio" ) {
// we don't search against the document in case the element
// is disconnected from the DOM
ancestor = this.element.parents().last();
labelSelector = "label[for='" + this.element.attr("id") + "']";
this.buttonElement = ancestor.find( labelSelector );
if ( !this.buttonElement.length ) {
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
this.buttonElement = ancestor.filter( labelSelector );
if ( !this.buttonElement.length ) {
this.buttonElement = ancestor.find( labelSelector );
}
}
this.element.addClass( "ui-helper-hidden-accessible" );
checked = this.element.is( ":checked" );
if ( checked ) {
this.buttonElement.addClass( "ui-state-active" );
}
this.buttonElement.prop( "aria-pressed", checked );
} else {
this.buttonElement = this.element;
}
},
widget: function() {
return this.buttonElement;
},
_destroy: function() {
this.element
.removeClass( "ui-helper-hidden-accessible" );
this.buttonElement
.removeClass( baseClasses + " ui-state-active " + typeClasses )
.removeAttr( "role" )
.removeAttr( "aria-pressed" )
.html( this.buttonElement.find(".ui-button-text").html() );
if ( !this.hasTitle ) {
this.buttonElement.removeAttr( "title" );
}
},
_setOption: function( key, value ) {
this._super( key, value );
if ( key === "disabled" ) {
this.element.prop( "disabled", !!value );
if ( value ) {
this.buttonElement.removeClass( "ui-state-focus" );
}
return;
}
this._resetButton();
},
refresh: function() {
//See #8237 & #8828
var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
if ( isDisabled !== this.options.disabled ) {
this._setOption( "disabled", isDisabled );
}
if ( this.type === "radio" ) {
radioGroup( this.element[0] ).each(function() {
if ( $( this ).is( ":checked" ) ) {
$( this ).button( "widget" )
.addClass( "ui-state-active" )
.attr( "aria-pressed", "true" );
} else {
$( this ).button( "widget" )
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
}
});
} else if ( this.type === "checkbox" ) {
if ( this.element.is( ":checked" ) ) {
this.buttonElement
.addClass( "ui-state-active" )
.attr( "aria-pressed", "true" );
} else {
this.buttonElement
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
}
}
},
_resetButton: function() {
if ( this.type === "input" ) {
if ( this.options.label ) {
this.element.val( this.options.label );
}
return;
}
var buttonElement = this.buttonElement.removeClass( typeClasses ),
buttonText = $( "<span></span>", this.document[0] )
.addClass( "ui-button-text" )
.html( this.options.label )
.appendTo( buttonElement.empty() )
.text(),
icons = this.options.icons,
multipleIcons = icons.primary && icons.secondary,
buttonClasses = [];
if ( icons.primary || icons.secondary ) {
if ( this.options.text ) {
buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
}
if ( icons.primary ) {
buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
}
if ( icons.secondary ) {
buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
}
if ( !this.options.text ) {
buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
if ( !this.hasTitle ) {
buttonElement.attr( "title", $.trim( buttonText ) );
}
}
} else {
buttonClasses.push( "ui-button-text-only" );
}
buttonElement.addClass( buttonClasses.join( " " ) );
}
});
$.widget( "ui.buttonset", {
version: "1.10.4",
options: {
items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
},
_create: function() {
this.element.addClass( "ui-buttonset" );
},
_init: function() {
this.refresh();
},
_setOption: function( key, value ) {
if ( key === "disabled" ) {
this.buttons.button( "option", key, value );
}
this._super( key, value );
},
refresh: function() {
var rtl = this.element.css( "direction" ) === "rtl";
this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
.end()
.not( ":ui-button" )
.button()
.end()
.map(function() {
return $( this ).button( "widget" )[ 0 ];
})
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" )
.addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
.end()
.filter( ":last" )
.addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
.end()
.end();
},
_destroy: function() {
this.element.removeClass( "ui-buttonset" );
this.buttons
.map(function() {
return $( this ).button( "widget" )[ 0 ];
})
.removeClass( "ui-corner-left ui-corner-right" )
.end()
.button( "destroy" );
}
});
}( jQuery ) );
(function( $, undefined ) {
$.extend($.ui, { datepicker: { version: "1.10.4" } });
var PROP_NAME = "datepicker",
instActive;
/* Date picker manager.
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
Settings for (groups of) date pickers are maintained in an instance object,
allowing multiple different settings on the same page. */
function Datepicker() {
this._curInst = null; // The current instance in use
this._keyEvent = false; // If the last event was a key event
this._disabledInputs = []; // List of date picker inputs that have been disabled
this._datepickerShowing = false; // True if the popup picker is showing , false if not
this._inDialog = false; // True if showing within a "dialog", false if not
this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
this._appendClass = "ui-datepicker-append"; // The name of the append marker class
this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
this.regional = []; // Available regional settings, indexed by language code
this.regional[""] = { // Default regional settings
closeText: "Done", // Display text for close link
prevText: "Prev", // Display text for previous month link
nextText: "Next", // Display text for next month link
currentText: "Today", // Display text for current month link
monthNames: ["January","February","March","April","May","June",
"July","August","September","October","November","December"], // Names of months for drop-down and formatting
monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
weekHeader: "Wk", // Column header for week of the year
dateFormat: "mm/dd/yy", // See format options on parseDate
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
isRTL: false, // True if right-to-left language, false if left-to-right
showMonthAfterYear: false, // True if the year select precedes month, false for month then year
yearSuffix: "" // Additional text to append to the year in the month headers
};
this._defaults = { // Global defaults for all the date picker instances
showOn: "focus", // "focus" for popup on focus,
// "button" for trigger button, or "both" for either
showAnim: "fadeIn", // Name of jQuery animation for popup
showOptions: {}, // Options for enhanced animations
defaultDate: null, // Used when field is blank: actual date,
// +/-number for offset from today, null for today
appendText: "", // Display text following the input box, e.g. showing the format
buttonText: "...", // Text for trigger button
buttonImage: "", // URL for trigger button image
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
hideIfNoPrevNext: false, // True to hide next/previous month links
// if not applicable, false to just disable them
navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
gotoCurrent: false, // True if today link goes back to current selection instead
changeMonth: false, // True if month can be selected directly, false if only prev/next
changeYear: false, // True if year can be selected directly, false if only prev/next
yearRange: "c-10:c+10", // Range of years to display in drop-down,
// either relative to today's year (-nn:+nn), relative to currently displayed year
// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
showOtherMonths: false, // True to show dates in other months, false to leave blank
selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
showWeek: false, // True to show week of the year, false to not show it
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
// takes a Date and returns the number of the week for it
shortYearCutoff: "+10", // Short year values < this are in the current century,
// > this are in the previous century,
// string value starting with "+" for current year + value
minDate: null, // The earliest selectable date, or null for no limit
maxDate: null, // The latest selectable date, or null for no limit
duration: "fast", // Duration of display/closure
beforeShowDay: null, // Function that takes a date and returns an array with
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
beforeShow: null, // Function that takes an input field and
// returns a set of custom settings for the date picker
onSelect: null, // Define a callback function when a date is selected
onChangeMonthYear: null, // Define a callback function when the month or year is changed
onClose: null, // Define a callback function when the datepicker is closed
numberOfMonths: 1, // Number of months to show at a time
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
stepMonths: 1, // Number of months to step back/forward
stepBigMonths: 12, // Number of months to step back/forward for the big links
altField: "", // Selector for an alternate field to store selected dates into
altFormat: "", // The date format to use for the alternate field
constrainInput: true, // The input is constrained by the current date format
showButtonPanel: false, // True to show button panel, false to not show it
autoSize: false, // True to size the input for the date format, false to leave as is
disabled: false // The initial disabled state
};
$.extend(this._defaults, this.regional[""]);
this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
}
$.extend(Datepicker.prototype, {
/* Class name added to elements to indicate already configured with a date picker. */
markerClassName: "hasDatepicker",
//Keep track of the maximum number of rows displayed (see #7043)
maxRows: 4,
// TODO rename to "widget" when switching to widget factory
_widgetDatepicker: function() {
return this.dpDiv;
},
/* Override the default settings for all instances of the date picker.
* @param settings object - the new settings to use as defaults (anonymous object)
* @return the manager object
*/
setDefaults: function(settings) {
extendRemove(this._defaults, settings || {});
return this;
},
/* Attach the date picker to a jQuery selection.
* @param target element - the target input field or division or span
* @param settings object - the new settings to use for this date picker instance (anonymous)
*/
_attachDatepicker: function(target, settings) {
var nodeName, inline, inst;
nodeName = target.nodeName.toLowerCase();
inline = (nodeName === "div" || nodeName === "span");
if (!target.id) {
this.uuid += 1;
target.id = "dp" + this.uuid;
}
inst = this._newInst($(target), inline);
inst.settings = $.extend({}, settings || {});
if (nodeName === "input") {
this._connectDatepicker(target, inst);
} else if (inline) {
this._inlineDatepicker(target, inst);
}
},
/* Create a new instance object. */
_newInst: function(target, inline) {
var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
return {id: id, input: target, // associated target
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
drawMonth: 0, drawYear: 0, // month being drawn
inline: inline, // is datepicker inline or not
dpDiv: (!inline ? this.dpDiv : // presentation div
bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
},
/* Attach the date picker to an input field. */
_connectDatepicker: function(target, inst) {
var input = $(target);
inst.append = $([]);
inst.trigger = $([]);
if (input.hasClass(this.markerClassName)) {
return;
}
this._attachments(input, inst);
input.addClass(this.markerClassName).keydown(this._doKeyDown).
keypress(this._doKeyPress).keyup(this._doKeyUp);
this._autoSize(inst);
$.data(target, PROP_NAME, inst);
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
if( inst.settings.disabled ) {
this._disableDatepicker( target );
}
},
/* Make attachments based on settings. */
_attachments: function(input, inst) {
var showOn, buttonText, buttonImage,
appendText = this._get(inst, "appendText"),
isRTL = this._get(inst, "isRTL");
if (inst.append) {
inst.append.remove();
}
if (appendText) {
inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
input[isRTL ? "before" : "after"](inst.append);
}
input.unbind("focus", this._showDatepicker);
if (inst.trigger) {
inst.trigger.remove();
}
showOn = this._get(inst, "showOn");
if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
input.focus(this._showDatepicker);
}
if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
buttonText = this._get(inst, "buttonText");
buttonImage = this._get(inst, "buttonImage");
inst.trigger = $(this._get(inst, "buttonImageOnly") ?
$("<img/>").addClass(this._triggerClass).
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
$("<button type='button'></button>").addClass(this._triggerClass).
html(!buttonImage ? buttonText : $("<img/>").attr(
{ src:buttonImage, alt:buttonText, title:buttonText })));
input[isRTL ? "before" : "after"](inst.trigger);
inst.trigger.click(function() {
if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
$.datepicker._hideDatepicker();
} else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
$.datepicker._hideDatepicker();
$.datepicker._showDatepicker(input[0]);
} else {
$.datepicker._showDatepicker(input[0]);
}
return false;
});
}
},
/* Apply the maximum length for the date format. */
_autoSize: function(inst) {
if (this._get(inst, "autoSize") && !inst.inline) {
var findMax, max, maxI, i,
date = new Date(2009, 12 - 1, 20), // Ensure double digits
dateFormat = this._get(inst, "dateFormat");
if (dateFormat.match(/[DM]/)) {
findMax = function(names) {
max = 0;
maxI = 0;
for (i = 0; i < names.length; i++) {
if (names[i].length > max) {
max = names[i].length;
maxI = i;
}
}
return maxI;
};
date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
"monthNames" : "monthNamesShort"))));
date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
"dayNames" : "dayNamesShort"))) + 20 - date.getDay());
}
inst.input.attr("size", this._formatDate(inst, date).length);
}
},
/* Attach an inline date picker to a div. */
_inlineDatepicker: function(target, inst) {
var divSpan = $(target);
if (divSpan.hasClass(this.markerClassName)) {
return;
}
divSpan.addClass(this.markerClassName).append(inst.dpDiv);
$.data(target, PROP_NAME, inst);
this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst);
this._updateAlternate(inst);
//If disabled option is true, disable the datepicker before showing it (see ticket #5665)
if( inst.settings.disabled ) {
this._disableDatepicker( target );
}
// Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
// http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
inst.dpDiv.css( "display", "block" );
},
/* Pop-up the date picker in a "dialog" box.
* @param input element - ignored
* @param date string or Date - the initial date to display
* @param onSelect function - the function to call when a date is selected
* @param settings object - update the dialog date picker instance's settings (anonymous object)
* @param pos int[2] - coordinates for the dialog's position within the screen or
* event - with x/y coordinates or
* leave empty for default (screen centre)
* @return the manager object
*/
_dialogDatepicker: function(input, date, onSelect, settings, pos) {
var id, browserWidth, browserHeight, scrollX, scrollY,
inst = this._dialogInst; // internal instance
if (!inst) {
this.uuid += 1;
id = "dp" + this.uuid;
this._dialogInput = $("<input type='text' id='" + id +
"' style='position: absolute; top: -100px; width: 0px;'/>");
this._dialogInput.keydown(this._doKeyDown);
$("body").append(this._dialogInput);
inst = this._dialogInst = this._newInst(this._dialogInput, false);
inst.settings = {};
$.data(this._dialogInput[0], PROP_NAME, inst);
}
extendRemove(inst.settings, settings || {});
date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
this._dialogInput.val(date);
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
if (!this._pos) {
browserWidth = document.documentElement.clientWidth;
browserHeight = document.documentElement.clientHeight;
scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
scrollY = document.documentElement.scrollTop || document.body.scrollTop;
this._pos = // should use actual width/height below
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
}
// move input on screen for focus, but hidden behind dialog
this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
inst.settings.onSelect = onSelect;
this._inDialog = true;
this.dpDiv.addClass(this._dialogClass);
this._showDatepicker(this._dialogInput[0]);
if ($.blockUI) {
$.blockUI(this.dpDiv);
}
$.data(this._dialogInput[0], PROP_NAME, inst);
return this;
},
/* Detach a datepicker from its control.
* @param target element - the target input field or division or span
*/
_destroyDatepicker: function(target) {
var nodeName,
$target = $(target),
inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
nodeName = target.nodeName.toLowerCase();
$.removeData(target, PROP_NAME);
if (nodeName === "input") {
inst.append.remove();
inst.trigger.remove();
$target.removeClass(this.markerClassName).
unbind("focus", this._showDatepicker).
unbind("keydown", this._doKeyDown).
unbind("keypress", this._doKeyPress).
unbind("keyup", this._doKeyUp);
} else if (nodeName === "div" || nodeName === "span") {
$target.removeClass(this.markerClassName).empty();
}
},
/* Enable the date picker to a jQuery selection.
* @param target element - the target input field or division or span
*/
_enableDatepicker: function(target) {
var nodeName, inline,
$target = $(target),
inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
nodeName = target.nodeName.toLowerCase();
if (nodeName === "input") {
target.disabled = false;
inst.trigger.filter("button").
each(function() { this.disabled = false; }).end().
filter("img").css({opacity: "1.0", cursor: ""});
} else if (nodeName === "div" || nodeName === "span") {
inline = $target.children("." + this._inlineClass);
inline.children().removeClass("ui-state-disabled");
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
prop("disabled", false);
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value === target ? null : value); }); // delete entry
},
/* Disable the date picker to a jQuery selection.
* @param target element - the target input field or division or span
*/
_disableDatepicker: function(target) {
var nodeName, inline,
$target = $(target),
inst = $.data(target, PROP_NAME);
if (!$target.hasClass(this.markerClassName)) {
return;
}
nodeName = target.nodeName.toLowerCase();
if (nodeName === "input") {
target.disabled = true;
inst.trigger.filter("button").
each(function() { this.disabled = true; }).end().
filter("img").css({opacity: "0.5", cursor: "default"});
} else if (nodeName === "div" || nodeName === "span") {
inline = $target.children("." + this._inlineClass);
inline.children().addClass("ui-state-disabled");
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
prop("disabled", true);
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value === target ? null : value); }); // delete entry
this._disabledInputs[this._disabledInputs.length] = target;
},
/* Is the first field in a jQuery collection disabled as a datepicker?
* @param target element - the target input field or division or span
* @return boolean - true if disabled, false if enabled
*/
_isDisabledDatepicker: function(target) {
if (!target) {
return false;
}
for (var i = 0; i < this._disabledInputs.length; i++) {
if (this._disabledInputs[i] === target) {
return true;
}
}
return false;
},
/* Retrieve the instance data for the target control.
* @param target element - the target input field or division or span
* @return object - the associated instance data
* @throws error if a jQuery problem getting data
*/
_getInst: function(target) {
try {
return $.data(target, PROP_NAME);
}
catch (err) {
throw "Missing instance data for this datepicker";
}
},
/* Update or retrieve the settings for a date picker attached to an input field or division.
* @param target element - the target input field or division or span
* @param name object - the new settings to update or
* string - the name of the setting to change or retrieve,
* when retrieving also "all" for all instance settings or
* "defaults" for all global defaults
* @param value any - the new value for the setting
* (omit if above is an object or to retrieve a value)
*/
_optionDatepicker: function(target, name, value) {
var settings, date, minDate, maxDate,
inst = this._getInst(target);
if (arguments.length === 2 && typeof name === "string") {
return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
(inst ? (name === "all" ? $.extend({}, inst.settings) :
this._get(inst, name)) : null));
}
settings = name || {};
if (typeof name === "string") {
settings = {};
settings[name] = value;
}
if (inst) {
if (this._curInst === inst) {
this._hideDatepicker();
}
date = this._getDateDatepicker(target, true);
minDate = this._getMinMaxDate(inst, "min");
maxDate = this._getMinMaxDate(inst, "max");
extendRemove(inst.settings, settings);
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
inst.settings.minDate = this._formatDate(inst, minDate);
}
if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
inst.settings.maxDate = this._formatDate(inst, maxDate);
}
if ( "disabled" in settings ) {
if ( settings.disabled ) {
this._disableDatepicker(target);
} else {
this._enableDatepicker(target);
}
}
this._attachments($(target), inst);
this._autoSize(inst);
this._setDate(inst, date);
this._updateAlternate(inst);
this._updateDatepicker(inst);
}
},
// change method deprecated
_changeDatepicker: function(target, name, value) {
this._optionDatepicker(target, name, value);
},
/* Redraw the date picker attached to an input field or division.
* @param target element - the target input field or division or span
*/
_refreshDatepicker: function(target) {
var inst = this._getInst(target);
if (inst) {
this._updateDatepicker(inst);
}
},
/* Set the dates for a jQuery selection.
* @param target element - the target input field or division or span
* @param date Date - the new date
*/
_setDateDatepicker: function(target, date) {
var inst = this._getInst(target);
if (inst) {
this._setDate(inst, date);
this._updateDatepicker(inst);
this._updateAlternate(inst);
}
},
/* Get the date(s) for the first entry in a jQuery selection.
* @param target element - the target input field or division or span
* @param noDefault boolean - true if no default date is to be used
* @return Date - the current date
*/
_getDateDatepicker: function(target, noDefault) {
var inst = this._getInst(target);
if (inst && !inst.inline) {
this._setDateFromField(inst, noDefault);
}
return (inst ? this._getDate(inst) : null);
},
/* Handle keystrokes. */
_doKeyDown: function(event) {
var onSelect, dateStr, sel,
inst = $.datepicker._getInst(event.target),
handled = true,
isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
inst._keyEvent = true;
if ($.datepicker._datepickerShowing) {
switch (event.keyCode) {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
$.datepicker._currentClass + ")", inst.dpDiv);
if (sel[0]) {
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
}
onSelect = $.datepicker._get(inst, "onSelect");
if (onSelect) {
dateStr = $.datepicker._formatDate(inst);
// trigger custom callback
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
} else {
$.datepicker._hideDatepicker();
}
return false; // don't submit the form
case 27: $.datepicker._hideDatepicker();
break; // hide on escape
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
break; // previous month/year on page up/+ ctrl
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
break; // next month/year on page down/+ ctrl
case 35: if (event.ctrlKey || event.metaKey) {
$.datepicker._clearDate(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // clear on ctrl or command +end
case 36: if (event.ctrlKey || event.metaKey) {
$.datepicker._gotoToday(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // current on ctrl or command +home
case 37: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
}
handled = event.ctrlKey || event.metaKey;
// -1 day on ctrl or command +left
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +left on Mac
break;
case 38: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, -7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // -1 week on ctrl or command +up
case 39: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
}
handled = event.ctrlKey || event.metaKey;
// +1 day on ctrl or command +right
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +right
break;
case 40: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, +7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // +1 week on ctrl or command +down
default: handled = false;
}
} else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
$.datepicker._showDatepicker(this);
} else {
handled = false;
}
if (handled) {
event.preventDefault();
event.stopPropagation();
}
},
/* Filter entered characters - based on date format. */
_doKeyPress: function(event) {
var chars, chr,
inst = $.datepicker._getInst(event.target);
if ($.datepicker._get(inst, "constrainInput")) {
chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
}
},
/* Synchronise manual entry and field/alternate field. */
_doKeyUp: function(event) {
var date,
inst = $.datepicker._getInst(event.target);
if (inst.input.val() !== inst.lastVal) {
try {
date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
(inst.input ? inst.input.val() : null),
$.datepicker._getFormatConfig(inst));
if (date) { // only if valid
$.datepicker._setDateFromField(inst);
$.datepicker._updateAlternate(inst);
$.datepicker._updateDatepicker(inst);
}
}
catch (err) {
}
}
return true;
},
/* Pop-up the date picker for a given input field.
* If false returned from beforeShow event handler do not show.
* @param input element - the input field attached to the date picker or
* event - if triggered by focus
*/
_showDatepicker: function(input) {
input = input.target || input;
if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
input = $("input", input.parentNode)[0];
}
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
return;
}
var inst, beforeShow, beforeShowSettings, isFixed,
offset, showAnim, duration;
inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
$.datepicker._curInst.dpDiv.stop(true, true);
if ( inst && $.datepicker._datepickerShowing ) {
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
}
}
beforeShow = $.datepicker._get(inst, "beforeShow");
beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
if(beforeShowSettings === false){
return;
}
extendRemove(inst.settings, beforeShowSettings);
inst.lastVal = null;
$.datepicker._lastInput = input;
$.datepicker._setDateFromField(inst);
if ($.datepicker._inDialog) { // hide cursor
input.value = "";
}
if (!$.datepicker._pos) { // position below input
$.datepicker._pos = $.datepicker._findPos(input);
$.datepicker._pos[1] += input.offsetHeight; // add the height
}
isFixed = false;
$(input).parents().each(function() {
isFixed |= $(this).css("position") === "fixed";
return !isFixed;
});
offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
$.datepicker._pos = null;
//to avoid flashes on Firefox
inst.dpDiv.empty();
// determine sizing offscreen
inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
$.datepicker._updateDatepicker(inst);
// fix width for dynamic number of date pickers
// and adjust position before showing
offset = $.datepicker._checkOffset(inst, offset, isFixed);
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
"static" : (isFixed ? "fixed" : "absolute")), display: "none",
left: offset.left + "px", top: offset.top + "px"});
if (!inst.inline) {
showAnim = $.datepicker._get(inst, "showAnim");
duration = $.datepicker._get(inst, "duration");
inst.dpDiv.zIndex($(input).zIndex()+1);
$.datepicker._datepickerShowing = true;
if ( $.effects && $.effects.effect[ showAnim ] ) {
inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
} else {
inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
}
if ( $.datepicker._shouldFocusInput( inst ) ) {
inst.input.focus();
}
$.datepicker._curInst = inst;
}
},
/* Generate the date picker content. */
_updateDatepicker: function(inst) {
this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst));
this._attachHandlers(inst);
inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
var origyearshtml,
numMonths = this._getNumberOfMonths(inst),
cols = numMonths[1],
width = 17;
inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
if (cols > 1) {
inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
}
inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
"Class"]("ui-datepicker-multi");
inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
"Class"]("ui-datepicker-rtl");
if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
inst.input.focus();
}
// deffered render of the years select (to avoid flashes on Firefox)
if( inst.yearshtml ){
origyearshtml = inst.yearshtml;
setTimeout(function(){
//assure that inst.yearshtml didn't change.
if( origyearshtml === inst.yearshtml && inst.yearshtml ){
inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
}
origyearshtml = inst.yearshtml = null;
}, 0);
}
},
// #6694 - don't focus the input if it's already focused
// this breaks the change event in IE
// Support: IE and jQuery <1.9
_shouldFocusInput: function( inst ) {
return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
},
/* Check positioning to remain on screen. */
_checkOffset: function(inst, offset, isFixed) {
var dpWidth = inst.dpDiv.outerWidth(),
dpHeight = inst.dpDiv.outerHeight(),
inputWidth = inst.input ? inst.input.outerWidth() : 0,
inputHeight = inst.input ? inst.input.outerHeight() : 0,
viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
// now check if datepicker is showing outside window viewport - move to a better place if so.
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
Math.abs(offset.left + dpWidth - viewWidth) : 0);
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
Math.abs(dpHeight + inputHeight) : 0);
return offset;
},
/* Find an object's position on the screen. */
_findPos: function(obj) {
var position,
inst = this._getInst(obj),
isRTL = this._get(inst, "isRTL");
while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
obj = obj[isRTL ? "previousSibling" : "nextSibling"];
}
position = $(obj).offset();
return [position.left, position.top];
},
/* Hide the date picker from view.
* @param input element - the input field attached to the date picker
*/
_hideDatepicker: function(input) {
var showAnim, duration, postProcess, onClose,
inst = this._curInst;
if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
return;
}
if (this._datepickerShowing) {
showAnim = this._get(inst, "showAnim");
duration = this._get(inst, "duration");
postProcess = function() {
$.datepicker._tidyDialog(inst);
};
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
} else {
inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
(showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
}
if (!showAnim) {
postProcess();
}
this._datepickerShowing = false;
onClose = this._get(inst, "onClose");
if (onClose) {
onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
}
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
if ($.blockUI) {
$.unblockUI();
$("body").append(this.dpDiv);
}
}
this._inDialog = false;
}
},
/* Tidy up after a dialog display. */
_tidyDialog: function(inst) {
inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
},
/* Close date picker if clicked elsewhere. */
_checkExternalClick: function(event) {
if (!$.datepicker._curInst) {
return;
}
var $target = $(event.target),
inst = $.datepicker._getInst($target[0]);
if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
$target.parents("#" + $.datepicker._mainDivId).length === 0 &&
!$target.hasClass($.datepicker.markerClassName) &&
!$target.closest("." + $.datepicker._triggerClass).length &&
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
$.datepicker._hideDatepicker();
}
},
/* Adjust one of the date sub-fields. */
_adjustDate: function(id, offset, period) {
var target = $(id),
inst = this._getInst(target[0]);
if (this._isDisabledDatepicker(target[0])) {
return;
}
this._adjustInstDate(inst, offset +
(period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
period);
this._updateDatepicker(inst);
},
/* Action for current link. */
_gotoToday: function(id) {
var date,
target = $(id),
inst = this._getInst(target[0]);
if (this._get(inst, "gotoCurrent") && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
} else {
date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
}
this._notifyChange(inst);
this._adjustDate(target);
},
/* Action for selecting a new month/year. */
_selectMonthYear: function(id, select, period) {
var target = $(id),
inst = this._getInst(target[0]);
inst["selected" + (period === "M" ? "Month" : "Year")] =
inst["draw" + (period === "M" ? "Month" : "Year")] =
parseInt(select.options[select.selectedIndex].value,10);
this._notifyChange(inst);
this._adjustDate(target);
},
/* Action for selecting a day. */
_selectDay: function(id, month, year, td) {
var inst,
target = $(id);
if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
return;
}
inst = this._getInst(target[0]);
inst.selectedDay = inst.currentDay = $("a", td).html();
inst.selectedMonth = inst.currentMonth = month;
inst.selectedYear = inst.currentYear = year;
this._selectDate(id, this._formatDate(inst,
inst.currentDay, inst.currentMonth, inst.currentYear));
},
/* Erase the input field and hide the date picker. */
_clearDate: function(id) {
var target = $(id);
this._selectDate(target, "");
},
/* Update the input field with the selected date. */
_selectDate: function(id, dateStr) {
var onSelect,
target = $(id),
inst = this._getInst(target[0]);
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
if (inst.input) {
inst.input.val(dateStr);
}
this._updateAlternate(inst);
onSelect = this._get(inst, "onSelect");
if (onSelect) {
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
} else if (inst.input) {
inst.input.trigger("change"); // fire the change event
}
if (inst.inline){
this._updateDatepicker(inst);
} else {
this._hideDatepicker();
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) !== "object") {
inst.input.focus(); // restore focus
}
this._lastInput = null;
}
},
/* Update any alternate field to synchronise with the main field. */
_updateAlternate: function(inst) {
var altFormat, date, dateStr,
altField = this._get(inst, "altField");
if (altField) { // update alternate field too
altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
date = this._getDate(inst);
dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
$(altField).each(function() { $(this).val(dateStr); });
}
},
/* Set as beforeShowDay function to prevent selection of weekends.
* @param date Date - the date to customise
* @return [boolean, string] - is this date selectable?, what is its CSS class?
*/
noWeekends: function(date) {
var day = date.getDay();
return [(day > 0 && day < 6), ""];
},
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
* @param date Date - the date to get the week for
* @return number - the number of the week within the year that contains this date
*/
iso8601Week: function(date) {
var time,
checkDate = new Date(date.getTime());
// Find Thursday of this week starting on Monday
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
time = checkDate.getTime();
checkDate.setMonth(0); // Compare with Jan 1
checkDate.setDate(1);
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
},
/* Parse a string value into a date object.
* See formatDate below for the possible formats.
*
* @param format string - the expected format of the date
* @param value string - the date in the above format
* @param settings Object - attributes include:
* shortYearCutoff number - the cutoff year for determining the century (optional)
* dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
* dayNames string[7] - names of the days from Sunday (optional)
* monthNamesShort string[12] - abbreviated names of the months (optional)
* monthNames string[12] - names of the months (optional)
* @return Date - the extracted date value or null if value is blank
*/
parseDate: function (format, value, settings) {
if (format == null || value == null) {
throw "Invalid arguments";
}
value = (typeof value === "object" ? value.toString() : value + "");
if (value === "") {
return null;
}
var iFormat, dim, extra,
iValue = 0,
shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
year = -1,
month = -1,
day = -1,
doy = -1,
literal = false,
date,
// Check whether a format character is doubled
lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
if (matches) {
iFormat++;
}
return matches;
},
// Extract a number from the string value
getNumber = function(match) {
var isDoubled = lookAhead(match),
size = (match === "@" ? 14 : (match === "!" ? 20 :
(match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
digits = new RegExp("^\\d{1," + size + "}"),
num = value.substring(iValue).match(digits);
if (!num) {
throw "Missing number at position " + iValue;
}
iValue += num[0].length;
return parseInt(num[0], 10);
},
// Extract a name from the string value and convert to an index
getName = function(match, shortNames, longNames) {
var index = -1,
names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
return [ [k, v] ];
}).sort(function (a, b) {
return -(a[1].length - b[1].length);
});
$.each(names, function (i, pair) {
var name = pair[1];
if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
index = pair[0];
iValue += name.length;
return false;
}
});
if (index !== -1) {
return index + 1;
} else {
throw "Unknown name at position " + iValue;
}
},
// Confirm that a literal character matches the string value
checkLiteral = function() {
if (value.charAt(iValue) !== format.charAt(iFormat)) {
throw "Unexpected literal at position " + iValue;
}
iValue++;
};
for (iFormat = 0; iFormat < format.length; iFormat++) {
if (literal) {
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
literal = false;
} else {
checkLiteral();
}
} else {
switch (format.charAt(iFormat)) {
case "d":
day = getNumber("d");
break;
case "D":
getName("D", dayNamesShort, dayNames);
break;
case "o":
doy = getNumber("o");
break;
case "m":
month = getNumber("m");
break;
case "M":
month = getName("M", monthNamesShort, monthNames);
break;
case "y":
year = getNumber("y");
break;
case "@":
date = new Date(getNumber("@"));
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
break;
case "!":
date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
break;
case "'":
if (lookAhead("'")){
checkLiteral();
} else {
literal = true;
}
break;
default:
checkLiteral();
}
}
}
if (iValue < value.length){
extra = value.substr(iValue);
if (!/^\s+/.test(extra)) {
throw "Extra/unparsed characters found in date: " + extra;
}
}
if (year === -1) {
year = new Date().getFullYear();
} else if (year < 100) {
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
(year <= shortYearCutoff ? 0 : -100);
}
if (doy > -1) {
month = 1;
day = doy;
do {
dim = this._getDaysInMonth(year, month - 1);
if (day <= dim) {
break;
}
month++;
day -= dim;
} while (true);
}
date = this._daylightSavingAdjust(new Date(year, month - 1, day));
if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
throw "Invalid date"; // E.g. 31/02/00
}
return date;
},
/* Standard date formats. */
ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
COOKIE: "D, dd M yy",
ISO_8601: "yy-mm-dd",
RFC_822: "D, d M y",
RFC_850: "DD, dd-M-y",
RFC_1036: "D, d M y",
RFC_1123: "D, d M yy",
RFC_2822: "D, d M yy",
RSS: "D, d M y", // RFC 822
TICKS: "!",
TIMESTAMP: "@",
W3C: "yy-mm-dd", // ISO 8601
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
/* Format a date object into a string value.
* The format can be combinations of the following:
* d - day of month (no leading zero)
* dd - day of month (two digit)
* o - day of year (no leading zeros)
* oo - day of year (three digit)
* D - day name short
* DD - day name long
* m - month of year (no leading zero)
* mm - month of year (two digit)
* M - month name short
* MM - month name long
* y - year (two digit)
* yy - year (four digit)
* @ - Unix timestamp (ms since 01/01/1970)
* ! - Windows ticks (100ns since 01/01/0001)
* "..." - literal text
* '' - single quote
*
* @param format string - the desired format of the date
* @param date Date - the date value to format
* @param settings Object - attributes include:
* dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
* dayNames string[7] - names of the days from Sunday (optional)
* monthNamesShort string[12] - abbreviated names of the months (optional)
* monthNames string[12] - names of the months (optional)
* @return string - the date in the above format
*/
formatDate: function (format, date, settings) {
if (!date) {
return "";
}
var iFormat,
dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
// Check whether a format character is doubled
lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
if (matches) {
iFormat++;
}
return matches;
},
// Format a number, with leading zero if necessary
formatNumber = function(match, value, len) {
var num = "" + value;
if (lookAhead(match)) {
while (num.length < len) {
num = "0" + num;
}
}
return num;
},
// Format a name, short or long as requested
formatName = function(match, value, shortNames, longNames) {
return (lookAhead(match) ? longNames[value] : shortNames[value]);
},
output = "",
literal = false;
if (date) {
for (iFormat = 0; iFormat < format.length; iFormat++) {
if (literal) {
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
literal = false;
} else {
output += format.charAt(iFormat);
}
} else {
switch (format.charAt(iFormat)) {
case "d":
output += formatNumber("d", date.getDate(), 2);
break;
case "D":
output += formatName("D", date.getDay(), dayNamesShort, dayNames);
break;
case "o":
output += formatNumber("o",
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
break;
case "m":
output += formatNumber("m", date.getMonth() + 1, 2);
break;
case "M":
output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
break;
case "y":
output += (lookAhead("y") ? date.getFullYear() :
(date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
break;
case "@":
output += date.getTime();
break;
case "!":
output += date.getTime() * 10000 + this._ticksTo1970;
break;
case "'":
if (lookAhead("'")) {
output += "'";
} else {
literal = true;
}
break;
default:
output += format.charAt(iFormat);
}
}
}
}
return output;
},
/* Extract all possible characters from the date format. */
_possibleChars: function (format) {
var iFormat,
chars = "",
literal = false,
// Check whether a format character is doubled
lookAhead = function(match) {
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
if (matches) {
iFormat++;
}
return matches;
};
for (iFormat = 0; iFormat < format.length; iFormat++) {
if (literal) {
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
literal = false;
} else {
chars += format.charAt(iFormat);
}
} else {
switch (format.charAt(iFormat)) {
case "d": case "m": case "y": case "@":
chars += "0123456789";
break;
case "D": case "M":
return null; // Accept anything
case "'":
if (lookAhead("'")) {
chars += "'";
} else {
literal = true;
}
break;
default:
chars += format.charAt(iFormat);
}
}
}
return chars;
},
/* Get a setting value, defaulting if necessary. */
_get: function(inst, name) {
return inst.settings[name] !== undefined ?
inst.settings[name] : this._defaults[name];
},
/* Parse existing date and initialise date picker. */
_setDateFromField: function(inst, noDefault) {
if (inst.input.val() === inst.lastVal) {
return;
}
var dateFormat = this._get(inst, "dateFormat"),
dates = inst.lastVal = inst.input ? inst.input.val() : null,
defaultDate = this._getDefaultDate(inst),
date = defaultDate,
settings = this._getFormatConfig(inst);
try {
date = this.parseDate(dateFormat, dates, settings) || defaultDate;
} catch (event) {
dates = (noDefault ? "" : dates);
}
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
inst.currentDay = (dates ? date.getDate() : 0);
inst.currentMonth = (dates ? date.getMonth() : 0);
inst.currentYear = (dates ? date.getFullYear() : 0);
this._adjustInstDate(inst);
},
/* Retrieve the default date shown on opening. */
_getDefaultDate: function(inst) {
return this._restrictMinMax(inst,
this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
},
/* A date may be specified as an exact value or a relative one. */
_determineDate: function(inst, date, defaultDate) {
var offsetNumeric = function(offset) {
var date = new Date();
date.setDate(date.getDate() + offset);
return date;
},
offsetString = function(offset) {
try {
return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
offset, $.datepicker._getFormatConfig(inst));
}
catch (e) {
// Ignore
}
var date = (offset.toLowerCase().match(/^c/) ?
$.datepicker._getDate(inst) : null) || new Date(),
year = date.getFullYear(),
month = date.getMonth(),
day = date.getDate(),
pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
matches = pattern.exec(offset);
while (matches) {
switch (matches[2] || "d") {
case "d" : case "D" :
day += parseInt(matches[1],10); break;
case "w" : case "W" :
day += parseInt(matches[1],10) * 7; break;
case "m" : case "M" :
month += parseInt(matches[1],10);
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
break;
case "y": case "Y" :
year += parseInt(matches[1],10);
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
break;
}
matches = pattern.exec(offset);
}
return new Date(year, month, day);
},
newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
(typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
if (newDate) {
newDate.setHours(0);
newDate.setMinutes(0);
newDate.setSeconds(0);
newDate.setMilliseconds(0);
}
return this._daylightSavingAdjust(newDate);
},
/* Handle switch to/from daylight saving.
* Hours may be non-zero on daylight saving cut-over:
* > 12 when midnight changeover, but then cannot generate
* midnight datetime, so jump to 1AM, otherwise reset.
* @param date (Date) the date to check
* @return (Date) the corrected date
*/
_daylightSavingAdjust: function(date) {
if (!date) {
return null;
}
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
return date;
},
/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
var clear = !date,
origMonth = inst.selectedMonth,
origYear = inst.selectedYear,
newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
inst.selectedDay = inst.currentDay = newDate.getDate();
inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
this._notifyChange(inst);
}
this._adjustInstDate(inst);
if (inst.input) {
inst.input.val(clear ? "" : this._formatDate(inst));
}
},
/* Retrieve the date(s) directly. */
_getDate: function(inst) {
var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
this._daylightSavingAdjust(new Date(
inst.currentYear, inst.currentMonth, inst.currentDay)));
return startDate;
},
/* Attach the onxxx handlers. These are declared statically so
* they work with static code transformers like Caja.
*/
_attachHandlers: function(inst) {
var stepMonths = this._get(inst, "stepMonths"),
id = "#" + inst.id.replace( /\\\\/g, "\\" );
inst.dpDiv.find("[data-handler]").map(function () {
var handler = {
prev: function () {
$.datepicker._adjustDate(id, -stepMonths, "M");
},
next: function () {
$.datepicker._adjustDate(id, +stepMonths, "M");
},
hide: function () {
$.datepicker._hideDatepicker();
},
today: function () {
$.datepicker._gotoToday(id);
},
selectDay: function () {
$.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
return false;
},
selectMonth: function () {
$.datepicker._selectMonthYear(id, this, "M");
return false;
},
selectYear: function () {
$.datepicker._selectMonthYear(id, this, "Y");
return false;
}
};
$(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
});
},
/* Generate the HTML for the current state of the date picker. */
_generateHTML: function(inst) {
var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
printDate, dRow, tbody, daySettings, otherMonth, unselectable,
tempDate = new Date(),
today = this._daylightSavingAdjust(
new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
isRTL = this._get(inst, "isRTL"),
showButtonPanel = this._get(inst, "showButtonPanel"),
hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
numMonths = this._getNumberOfMonths(inst),
showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
stepMonths = this._get(inst, "stepMonths"),
isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
minDate = this._getMinMaxDate(inst, "min"),
maxDate = this._getMinMaxDate(inst, "max"),
drawMonth = inst.drawMonth - showCurrentAtPos,
drawYear = inst.drawYear;
if (drawMonth < 0) {
drawMonth += 12;
drawYear--;
}
if (maxDate) {
maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
drawMonth--;
if (drawMonth < 0) {
drawMonth = 11;
drawYear--;
}
}
}
inst.drawMonth = drawMonth;
inst.drawYear = drawYear;
prevText = this._get(inst, "prevText");
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
this._getFormatConfig(inst)));
prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
" title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
(hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
nextText = this._get(inst, "nextText");
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
this._getFormatConfig(inst)));
next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
" title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
(hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
currentText = this._get(inst, "currentText");
gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
currentText = (!navigationAsDateFormat ? currentText :
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
this._get(inst, "closeText") + "</button>" : "");
buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
(this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
firstDay = parseInt(this._get(inst, "firstDay"),10);
firstDay = (isNaN(firstDay) ? 0 : firstDay);
showWeek = this._get(inst, "showWeek");
dayNames = this._get(inst, "dayNames");
dayNamesMin = this._get(inst, "dayNamesMin");
monthNames = this._get(inst, "monthNames");
monthNamesShort = this._get(inst, "monthNamesShort");
beforeShowDay = this._get(inst, "beforeShowDay");
showOtherMonths = this._get(inst, "showOtherMonths");
selectOtherMonths = this._get(inst, "selectOtherMonths");
defaultDate = this._getDefaultDate(inst);
html = "";
dow;
for (row = 0; row < numMonths[0]; row++) {
group = "";
this.maxRows = 4;
for (col = 0; col < numMonths[1]; col++) {
selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
cornerClass = " ui-corner-all";
calender = "";
if (isMultiMonth) {
calender += "<div class='ui-datepicker-group";
if (numMonths[1] > 1) {
switch (col) {
case 0: calender += " ui-datepicker-group-first";
cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
case numMonths[1]-1: calender += " ui-datepicker-group-last";
cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
}
}
calender += "'>";
}
calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
(/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
(/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
"</div><table class='ui-datepicker-calendar'><thead>" +
"<tr>";
thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
for (dow = 0; dow < 7; dow++) { // days of the week
day = (dow + firstDay) % 7;
thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
"<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
}
calender += thead + "</tr></thead><tbody>";
daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
}
leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
this.maxRows = numRows;
printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
calender += "<tr>";
tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
this._get(inst, "calculateWeek")(printDate) + "</td>");
for (dow = 0; dow < 7; dow++) { // create date picker days
daySettings = (beforeShowDay ?
beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
otherMonth = (printDate.getMonth() !== drawMonth);
unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
tbody += "<td class='" +
((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
(otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
(defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
// or defaultDate is current printedDate and defaultDate is selectedDate
" " + this._dayOverClass : "") + // highlight selected day
(unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
(otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
(printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
(printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title
(unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
(otherMonth && !showOtherMonths ? " " : // display for other months
(unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
(printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
(printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
(otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
"' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
printDate.setDate(printDate.getDate() + 1);
printDate = this._daylightSavingAdjust(printDate);
}
calender += tbody + "</tr>";
}
drawMonth++;
if (drawMonth > 11) {
drawMonth = 0;
drawYear++;
}
calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
group += calender;
}
html += group;
}
html += buttonPanel;
inst._keyEvent = false;
return html;
},
/* Generate the month and year header. */
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
secondary, monthNames, monthNamesShort) {
var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
changeMonth = this._get(inst, "changeMonth"),
changeYear = this._get(inst, "changeYear"),
showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
html = "<div class='ui-datepicker-title'>",
monthHtml = "";
// month selection
if (secondary || !changeMonth) {
monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
} else {
inMinYear = (minDate && minDate.getFullYear() === drawYear);
inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
for ( month = 0; month < 12; month++) {
if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
monthHtml += "<option value='" + month + "'" +
(month === drawMonth ? " selected='selected'" : "") +
">" + monthNamesShort[month] + "</option>";
}
}
monthHtml += "</select>";
}
if (!showMonthAfterYear) {
html += monthHtml + (secondary || !(changeMonth && changeYear) ? " " : "");
}
// year selection
if ( !inst.yearshtml ) {
inst.yearshtml = "";
if (secondary || !changeYear) {
html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
} else {
// determine range of years to display
years = this._get(inst, "yearRange").split(":");
thisYear = new Date().getFullYear();
determineYear = function(value) {
var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
(value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
parseInt(value, 10)));
return (isNaN(year) ? thisYear : year);
};
year = determineYear(years[0]);
endYear = Math.max(year, determineYear(years[1] || ""));
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
for (; year <= endYear; year++) {
inst.yearshtml += "<option value='" + year + "'" +
(year === drawYear ? " selected='selected'" : "") +
">" + year + "</option>";
}
inst.yearshtml += "</select>";
html += inst.yearshtml;
inst.yearshtml = null;
}
}
html += this._get(inst, "yearSuffix");
if (showMonthAfterYear) {
html += (secondary || !(changeMonth && changeYear) ? " " : "") + monthHtml;
}
html += "</div>"; // Close datepicker_header
return html;
},
/* Adjust one of the date sub-fields. */
_adjustInstDate: function(inst, offset, period) {
var year = inst.drawYear + (period === "Y" ? offset : 0),
month = inst.drawMonth + (period === "M" ? offset : 0),
day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
if (period === "M" || period === "Y") {
this._notifyChange(inst);
}
},
/* Ensure a date is within any min/max bounds. */
_restrictMinMax: function(inst, date) {
var minDate = this._getMinMaxDate(inst, "min"),
maxDate = this._getMinMaxDate(inst, "max"),
newDate = (minDate && date < minDate ? minDate : date);
return (maxDate && newDate > maxDate ? maxDate : newDate);
},
/* Notify change of month/year. */
_notifyChange: function(inst) {
var onChange = this._get(inst, "onChangeMonthYear");
if (onChange) {
onChange.apply((inst.input ? inst.input[0] : null),
[inst.selectedYear, inst.selectedMonth + 1, inst]);
}
},
/* Determine the number of months to show. */
_getNumberOfMonths: function(inst) {
var numMonths = this._get(inst, "numberOfMonths");
return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
},
/* Determine the current maximum date - ensure no time components are set. */
_getMinMaxDate: function(inst, minMax) {
return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
},
/* Find the number of days in a given month. */
_getDaysInMonth: function(year, month) {
return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
},
/* Find the day of the week of the first of a month. */
_getFirstDayOfMonth: function(year, month) {
return new Date(year, month, 1).getDay();
},
/* Determines if we should allow a "next/prev" month display change. */
_canAdjustMonth: function(inst, offset, curYear, curMonth) {
var numMonths = this._getNumberOfMonths(inst),
date = this._daylightSavingAdjust(new Date(curYear,
curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
if (offset < 0) {
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
}
return this._isInRange(inst, date);
},
/* Is the given date in the accepted range? */
_isInRange: function(inst, date) {
var yearSplit, currentYear,
minDate = this._getMinMaxDate(inst, "min"),
maxDate = this._getMinMaxDate(inst, "max"),
minYear = null,
maxYear = null,
years = this._get(inst, "yearRange");
if (years){
yearSplit = years.split(":");
currentYear = new Date().getFullYear();
minYear = parseInt(yearSplit[0], 10);
maxYear = parseInt(yearSplit[1], 10);
if ( yearSplit[0].match(/[+\-].*/) ) {
minYear += currentYear;
}
if ( yearSplit[1].match(/[+\-].*/) ) {
maxYear += currentYear;
}
}
return ((!minDate || date.getTime() >= minDate.getTime()) &&
(!maxDate || date.getTime() <= maxDate.getTime()) &&
(!minYear || date.getFullYear() >= minYear) &&
(!maxYear || date.getFullYear() <= maxYear));
},
/* Provide the configuration settings for formatting/parsing. */
_getFormatConfig: function(inst) {
var shortYearCutoff = this._get(inst, "shortYearCutoff");
shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
return {shortYearCutoff: shortYearCutoff,
dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
},
/* Format the given date for display. */
_formatDate: function(inst, day, month, year) {
if (!day) {
inst.currentDay = inst.selectedDay;
inst.currentMonth = inst.selectedMonth;
inst.currentYear = inst.selectedYear;
}
var date = (day ? (typeof day === "object" ? day :
this._daylightSavingAdjust(new Date(year, month, day))) :
this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
}
});
/*
* Bind hover events for datepicker elements.
* Done via delegate so the binding only occurs once in the lifetime of the parent div.
* Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
*/
function bindHover(dpDiv) {
var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
return dpDiv.delegate(selector, "mouseout", function() {
$(this).removeClass("ui-state-hover");
if (this.className.indexOf("ui-datepicker-prev") !== -1) {
$(this).removeClass("ui-datepicker-prev-hover");
}
if (this.className.indexOf("ui-datepicker-next") !== -1) {
$(this).removeClass("ui-datepicker-next-hover");
}
})
.delegate(selector, "mouseover", function(){
if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
$(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
$(this).addClass("ui-state-hover");
if (this.className.indexOf("ui-datepicker-prev") !== -1) {
$(this).addClass("ui-datepicker-prev-hover");
}
if (this.className.indexOf("ui-datepicker-next") !== -1) {
$(this).addClass("ui-datepicker-next-hover");
}
}
});
}
/* jQuery extend now ignores nulls! */
function extendRemove(target, props) {
$.extend(target, props);
for (var name in props) {
if (props[name] == null) {
target[name] = props[name];
}
}
return target;
}
/* Invoke the datepicker functionality.
@param options string - a command, optionally followed by additional parameters or
Object - settings for attaching new datepicker functionality
@return jQuery object */
$.fn.datepicker = function(options){
/* Verify an empty collection wasn't passed - Fixes #6976 */
if ( !this.length ) {
return this;
}
/* Initialise the date picker. */
if (!$.datepicker.initialized) {
$(document).mousedown($.datepicker._checkExternalClick);
$.datepicker.initialized = true;
}
/* Append datepicker main container to body if not exist. */
if ($("#"+$.datepicker._mainDivId).length === 0) {
$("body").append($.datepicker.dpDiv);
}
var otherArgs = Array.prototype.slice.call(arguments, 1);
if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
return $.datepicker["_" + options + "Datepicker"].
apply($.datepicker, [this[0]].concat(otherArgs));
}
if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
return $.datepicker["_" + options + "Datepicker"].
apply($.datepicker, [this[0]].concat(otherArgs));
}
return this.each(function() {
typeof options === "string" ?
$.datepicker["_" + options + "Datepicker"].
apply($.datepicker, [this].concat(otherArgs)) :
$.datepicker._attachDatepicker(this, options);
});
};
$.datepicker = new Datepicker(); // singleton instance
$.datepicker.initialized = false;
$.datepicker.uuid = new Date().getTime();
$.datepicker.version = "1.10.4";
})(jQuery);
(function( $, undefined ) {
var sizeRelatedOptions = {
buttons: true,
height: true,
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true,
width: true
},
resizableRelatedOptions = {
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true
};
$.widget( "ui.dialog", {
version: "1.10.4",
options: {
appendTo: "body",
autoOpen: true,
buttons: [],
closeOnEscape: true,
closeText: "close",
dialogClass: "",
draggable: true,
hide: null,
height: "auto",
maxHeight: null,
maxWidth: null,
minHeight: 150,
minWidth: 150,
modal: false,
position: {
my: "center",
at: "center",
of: window,
collision: "fit",
// Ensure the titlebar is always visible
using: function( pos ) {
var topOffset = $( this ).css( pos ).offset().top;
if ( topOffset < 0 ) {
$( this ).css( "top", pos.top - topOffset );
}
}
},
resizable: true,
show: null,
title: null,
width: 300,
// callbacks
beforeClose: null,
close: null,
drag: null,
dragStart: null,
dragStop: null,
focus: null,
open: null,
resize: null,
resizeStart: null,
resizeStop: null
},
_create: function() {
this.originalCss = {
display: this.element[0].style.display,
width: this.element[0].style.width,
minHeight: this.element[0].style.minHeight,
maxHeight: this.element[0].style.maxHeight,
height: this.element[0].style.height
};
this.originalPosition = {
parent: this.element.parent(),
index: this.element.parent().children().index( this.element )
};
this.originalTitle = this.element.attr("title");
this.options.title = this.options.title || this.originalTitle;
this._createWrapper();
this.element
.show()
.removeAttr("title")
.addClass("ui-dialog-content ui-widget-content")
.appendTo( this.uiDialog );
this._createTitlebar();
this._createButtonPane();
if ( this.options.draggable && $.fn.draggable ) {
this._makeDraggable();
}
if ( this.options.resizable && $.fn.resizable ) {
this._makeResizable();
}
this._isOpen = false;
},
_init: function() {
if ( this.options.autoOpen ) {
this.open();
}
},
_appendTo: function() {
var element = this.options.appendTo;
if ( element && (element.jquery || element.nodeType) ) {
return $( element );
}
return this.document.find( element || "body" ).eq( 0 );
},
_destroy: function() {
var next,
originalPosition = this.originalPosition;
this._destroyOverlay();
this.element
.removeUniqueId()
.removeClass("ui-dialog-content ui-widget-content")
.css( this.originalCss )
// Without detaching first, the following becomes really slow
.detach();
this.uiDialog.stop( true, true ).remove();
if ( this.originalTitle ) {
this.element.attr( "title", this.originalTitle );
}
next = originalPosition.parent.children().eq( originalPosition.index );
// Don't try to place the dialog next to itself (#8613)
if ( next.length && next[0] !== this.element[0] ) {
next.before( this.element );
} else {
originalPosition.parent.append( this.element );
}
},
widget: function() {
return this.uiDialog;
},
disable: $.noop,
enable: $.noop,
close: function( event ) {
var activeElement,
that = this;
if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
return;
}
this._isOpen = false;
this._destroyOverlay();
if ( !this.opener.filter(":focusable").focus().length ) {
// support: IE9
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
try {
activeElement = this.document[ 0 ].activeElement;
// Support: IE9, IE10
// If the <body> is blurred, IE will switch windows, see #4520
if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
// Hiding a focused element doesn't trigger blur in WebKit
// so in case we have nothing to focus on, explicitly blur the active element
// https://bugs.webkit.org/show_bug.cgi?id=47182
$( activeElement ).blur();
}
} catch ( error ) {}
}
this._hide( this.uiDialog, this.options.hide, function() {
that._trigger( "close", event );
});
},
isOpen: function() {
return this._isOpen;
},
moveToTop: function() {
this._moveToTop();
},
_moveToTop: function( event, silent ) {
var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
if ( moved && !silent ) {
this._trigger( "focus", event );
}
return moved;
},
open: function() {
var that = this;
if ( this._isOpen ) {
if ( this._moveToTop() ) {
this._focusTabbable();
}
return;
}
this._isOpen = true;
this.opener = $( this.document[0].activeElement );
this._size();
this._position();
this._createOverlay();
this._moveToTop( null, true );
this._show( this.uiDialog, this.options.show, function() {
that._focusTabbable();
that._trigger("focus");
});
this._trigger("open");
},
_focusTabbable: function() {
// Set focus to the first match:
// 1. First element inside the dialog matching [autofocus]
// 2. Tabbable element inside the content element
// 3. Tabbable element inside the buttonpane
// 4. The close button
// 5. The dialog itself
var hasFocus = this.element.find("[autofocus]");
if ( !hasFocus.length ) {
hasFocus = this.element.find(":tabbable");
}
if ( !hasFocus.length ) {
hasFocus = this.uiDialogButtonPane.find(":tabbable");
}
if ( !hasFocus.length ) {
hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
}
if ( !hasFocus.length ) {
hasFocus = this.uiDialog;
}
hasFocus.eq( 0 ).focus();
},
_keepFocus: function( event ) {
function checkFocus() {
var activeElement = this.document[0].activeElement,
isActive = this.uiDialog[0] === activeElement ||
$.contains( this.uiDialog[0], activeElement );
if ( !isActive ) {
this._focusTabbable();
}
}
event.preventDefault();
checkFocus.call( this );
// support: IE
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
// so we check again later
this._delay( checkFocus );
},
_createWrapper: function() {
this.uiDialog = $("<div>")
.addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
this.options.dialogClass )
.hide()
.attr({
// Setting tabIndex makes the div focusable
tabIndex: -1,
role: "dialog"
})
.appendTo( this._appendTo() );
this._on( this.uiDialog, {
keydown: function( event ) {
if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
event.keyCode === $.ui.keyCode.ESCAPE ) {
event.preventDefault();
this.close( event );
return;
}
// prevent tabbing out of dialogs
if ( event.keyCode !== $.ui.keyCode.TAB ) {
return;
}
var tabbables = this.uiDialog.find(":tabbable"),
first = tabbables.filter(":first"),
last = tabbables.filter(":last");
if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
first.focus( 1 );
event.preventDefault();
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
last.focus( 1 );
event.preventDefault();
}
},
mousedown: function( event ) {
if ( this._moveToTop( event ) ) {
this._focusTabbable();
}
}
});
// We assume that any existing aria-describedby attribute means
// that the dialog content is marked up properly
// otherwise we brute force the content as the description
if ( !this.element.find("[aria-describedby]").length ) {
this.uiDialog.attr({
"aria-describedby": this.element.uniqueId().attr("id")
});
}
},
_createTitlebar: function() {
var uiDialogTitle;
this.uiDialogTitlebar = $("<div>")
.addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
.prependTo( this.uiDialog );
this._on( this.uiDialogTitlebar, {
mousedown: function( event ) {
// Don't prevent click on close button (#8838)
// Focusing a dialog that is partially scrolled out of view
// causes the browser to scroll it into view, preventing the click event
if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
// Dialog isn't getting focus when dragging (#8063)
this.uiDialog.focus();
}
}
});
// support: IE
// Use type="button" to prevent enter keypresses in textboxes from closing the
// dialog in IE (#9312)
this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
.button({
label: this.options.closeText,
icons: {
primary: "ui-icon-closethick"
},
text: false
})
.addClass("ui-dialog-titlebar-close")
.appendTo( this.uiDialogTitlebar );
this._on( this.uiDialogTitlebarClose, {
click: function( event ) {
event.preventDefault();
this.close( event );
}
});
uiDialogTitle = $("<span>")
.uniqueId()
.addClass("ui-dialog-title")
.prependTo( this.uiDialogTitlebar );
this._title( uiDialogTitle );
this.uiDialog.attr({
"aria-labelledby": uiDialogTitle.attr("id")
});
},
_title: function( title ) {
if ( !this.options.title ) {
title.html(" ");
}
title.text( this.options.title );
},
_createButtonPane: function() {
this.uiDialogButtonPane = $("<div>")
.addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
this.uiButtonSet = $("<div>")
.addClass("ui-dialog-buttonset")
.appendTo( this.uiDialogButtonPane );
this._createButtons();
},
_createButtons: function() {
var that = this,
buttons = this.options.buttons;
// if we already have a button pane, remove it
this.uiDialogButtonPane.remove();
this.uiButtonSet.empty();
if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
this.uiDialog.removeClass("ui-dialog-buttons");
return;
}
$.each( buttons, function( name, props ) {
var click, buttonOptions;
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
// Default to a non-submitting button
props = $.extend( { type: "button" }, props );
// Change the context for the click callback to be the main element
click = props.click;
props.click = function() {
click.apply( that.element[0], arguments );
};
buttonOptions = {
icons: props.icons,
text: props.showText
};
delete props.icons;
delete props.showText;
$( "<button></button>", props )
.button( buttonOptions )
.appendTo( that.uiButtonSet );
});
this.uiDialog.addClass("ui-dialog-buttons");
this.uiDialogButtonPane.appendTo( this.uiDialog );
},
_makeDraggable: function() {
var that = this,
options = this.options;
function filteredUi( ui ) {
return {
position: ui.position,
offset: ui.offset
};
}
this.uiDialog.draggable({
cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
handle: ".ui-dialog-titlebar",
containment: "document",
start: function( event, ui ) {
$( this ).addClass("ui-dialog-dragging");
that._blockFrames();
that._trigger( "dragStart", event, filteredUi( ui ) );
},
drag: function( event, ui ) {
that._trigger( "drag", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
options.position = [
ui.position.left - that.document.scrollLeft(),
ui.position.top - that.document.scrollTop()
];
$( this ).removeClass("ui-dialog-dragging");
that._unblockFrames();
that._trigger( "dragStop", event, filteredUi( ui ) );
}
});
},
_makeResizable: function() {
var that = this,
options = this.options,
handles = options.resizable,
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
position = this.uiDialog.css("position"),
resizeHandles = typeof handles === "string" ?
handles :
"n,e,s,w,se,sw,ne,nw";
function filteredUi( ui ) {
return {
originalPosition: ui.originalPosition,
originalSize: ui.originalSize,
position: ui.position,
size: ui.size
};
}
this.uiDialog.resizable({
cancel: ".ui-dialog-content",
containment: "document",
alsoResize: this.element,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
minWidth: options.minWidth,
minHeight: this._minHeight(),
handles: resizeHandles,
start: function( event, ui ) {
$( this ).addClass("ui-dialog-resizing");
that._blockFrames();
that._trigger( "resizeStart", event, filteredUi( ui ) );
},
resize: function( event, ui ) {
that._trigger( "resize", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
options.height = $( this ).height();
options.width = $( this ).width();
$( this ).removeClass("ui-dialog-resizing");
that._unblockFrames();
that._trigger( "resizeStop", event, filteredUi( ui ) );
}
})
.css( "position", position );
},
_minHeight: function() {
var options = this.options;
return options.height === "auto" ?
options.minHeight :
Math.min( options.minHeight, options.height );
},
_position: function() {
// Need to show the dialog to get the actual offset in the position plugin
var isVisible = this.uiDialog.is(":visible");
if ( !isVisible ) {
this.uiDialog.show();
}
this.uiDialog.position( this.options.position );
if ( !isVisible ) {
this.uiDialog.hide();
}
},
_setOptions: function( options ) {
var that = this,
resize = false,
resizableOptions = {};
$.each( options, function( key, value ) {
that._setOption( key, value );
if ( key in sizeRelatedOptions ) {
resize = true;
}
if ( key in resizableRelatedOptions ) {
resizableOptions[ key ] = value;
}
});
if ( resize ) {
this._size();
this._position();
}
if ( this.uiDialog.is(":data(ui-resizable)") ) {
this.uiDialog.resizable( "option", resizableOptions );
}
},
_setOption: function( key, value ) {
var isDraggable, isResizable,
uiDialog = this.uiDialog;
if ( key === "dialogClass" ) {
uiDialog
.removeClass( this.options.dialogClass )
.addClass( value );
}
if ( key === "disabled" ) {
return;
}
this._super( key, value );
if ( key === "appendTo" ) {
this.uiDialog.appendTo( this._appendTo() );
}
if ( key === "buttons" ) {
this._createButtons();
}
if ( key === "closeText" ) {
this.uiDialogTitlebarClose.button({
// Ensure that we always pass a string
label: "" + value
});
}
if ( key === "draggable" ) {
isDraggable = uiDialog.is(":data(ui-draggable)");
if ( isDraggable && !value ) {
uiDialog.draggable("destroy");
}
if ( !isDraggable && value ) {
this._makeDraggable();
}
}
if ( key === "position" ) {
this._position();
}
if ( key === "resizable" ) {
// currently resizable, becoming non-resizable
isResizable = uiDialog.is(":data(ui-resizable)");
if ( isResizable && !value ) {
uiDialog.resizable("destroy");
}
// currently resizable, changing handles
if ( isResizable && typeof value === "string" ) {
uiDialog.resizable( "option", "handles", value );
}
// currently non-resizable, becoming resizable
if ( !isResizable && value !== false ) {
this._makeResizable();
}
}
if ( key === "title" ) {
this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
}
},
_size: function() {
// If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
// divs will both have width and height set, so we need to reset them
var nonContentHeight, minContentHeight, maxContentHeight,
options = this.options;
// Reset content sizing
this.element.show().css({
width: "auto",
minHeight: 0,
maxHeight: "none",
height: 0
});
if ( options.minWidth > options.width ) {
options.width = options.minWidth;
}
// reset wrapper sizing
// determine the height of all the non-content elements
nonContentHeight = this.uiDialog.css({
height: "auto",
width: options.width
})
.outerHeight();
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
maxContentHeight = typeof options.maxHeight === "number" ?
Math.max( 0, options.maxHeight - nonContentHeight ) :
"none";
if ( options.height === "auto" ) {
this.element.css({
minHeight: minContentHeight,
maxHeight: maxContentHeight,
height: "auto"
});
} else {
this.element.height( Math.max( 0, options.height - nonContentHeight ) );
}
if (this.uiDialog.is(":data(ui-resizable)") ) {
this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
}
},
_blockFrames: function() {
this.iframeBlocks = this.document.find( "iframe" ).map(function() {
var iframe = $( this );
return $( "<div>" )
.css({
position: "absolute",
width: iframe.outerWidth(),
height: iframe.outerHeight()
})
.appendTo( iframe.parent() )
.offset( iframe.offset() )[0];
});
},
_unblockFrames: function() {
if ( this.iframeBlocks ) {
this.iframeBlocks.remove();
delete this.iframeBlocks;
}
},
_allowInteraction: function( event ) {
if ( $( event.target ).closest(".ui-dialog").length ) {
return true;
}
// TODO: Remove hack when datepicker implements
// the .ui-front logic (#8989)
return !!$( event.target ).closest(".ui-datepicker").length;
},
_createOverlay: function() {
if ( !this.options.modal ) {
return;
}
var that = this,
widgetFullName = this.widgetFullName;
if ( !$.ui.dialog.overlayInstances ) {
// Prevent use of anchors and inputs.
// We use a delay in case the overlay is created from an
// event that we're going to be cancelling. (#2804)
this._delay(function() {
// Handle .dialog().dialog("close") (#4065)
if ( $.ui.dialog.overlayInstances ) {
this.document.bind( "focusin.dialog", function( event ) {
if ( !that._allowInteraction( event ) ) {
event.preventDefault();
$(".ui-dialog:visible:last .ui-dialog-content")
.data( widgetFullName )._focusTabbable();
}
});
}
});
}
this.overlay = $("<div>")
.addClass("ui-widget-overlay ui-front")
.appendTo( this._appendTo() );
this._on( this.overlay, {
mousedown: "_keepFocus"
});
$.ui.dialog.overlayInstances++;
},
_destroyOverlay: function() {
if ( !this.options.modal ) {
return;
}
if ( this.overlay ) {
$.ui.dialog.overlayInstances--;
if ( !$.ui.dialog.overlayInstances ) {
this.document.unbind( "focusin.dialog" );
}
this.overlay.remove();
this.overlay = null;
}
}
});
$.ui.dialog.overlayInstances = 0;
// DEPRECATED
if ( $.uiBackCompat !== false ) {
// position option with array notation
// just override with old implementation
$.widget( "ui.dialog", $.ui.dialog, {
_position: function() {
var position = this.options.position,
myAt = [],
offset = [ 0, 0 ],
isVisible;
if ( position ) {
if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
if ( myAt.length === 1 ) {
myAt[1] = myAt[0];
}
$.each( [ "left", "top" ], function( i, offsetPosition ) {
if ( +myAt[ i ] === myAt[ i ] ) {
offset[ i ] = myAt[ i ];
myAt[ i ] = offsetPosition;
}
});
position = {
my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
at: myAt.join(" ")
};
}
position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
} else {
position = $.ui.dialog.prototype.options.position;
}
// need to show the dialog to get the actual offset in the position plugin
isVisible = this.uiDialog.is(":visible");
if ( !isVisible ) {
this.uiDialog.show();
}
this.uiDialog.position( position );
if ( !isVisible ) {
this.uiDialog.hide();
}
}
});
}
}( jQuery ) );
(function( $, undefined ) {
$.widget( "ui.menu", {
version: "1.10.4",
defaultElement: "<ul>",
delay: 300,
options: {
icons: {
submenu: "ui-icon-carat-1-e"
},
menus: "ul",
position: {
my: "left top",
at: "right top"
},
role: "menu",
// callbacks
blur: null,
focus: null,
select: null
},
_create: function() {
this.activeMenu = this.element;
// flag used to prevent firing of the click handler
// as the event bubbles up through nested menus
this.mouseHandled = false;
this.element
.uniqueId()
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
.attr({
role: this.options.role,
tabIndex: 0
})
// need to catch all clicks on disabled menu
// not possible through _on
.bind( "click" + this.eventNamespace, $.proxy(function( event ) {
if ( this.options.disabled ) {
event.preventDefault();
}
}, this ));
if ( this.options.disabled ) {
this.element
.addClass( "ui-state-disabled" )
.attr( "aria-disabled", "true" );
}
this._on({
// Prevent focus from sticking to links inside menu after clicking
// them (focus should always stay on UL during navigation).
"mousedown .ui-menu-item > a": function( event ) {
event.preventDefault();
},
"click .ui-state-disabled > a": function( event ) {
event.preventDefault();
},
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target ).closest( ".ui-menu-item" );
if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
this.select( event );
// Only set the mouseHandled flag if the event will bubble, see #9469.
if ( !event.isPropagationStopped() ) {
this.mouseHandled = true;
}
// Open submenu on click
if ( target.has( ".ui-menu" ).length ) {
this.expand( event );
} else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
// Redirect focus to the menu
this.element.trigger( "focus", [ true ] );
// If the active item is on the top level, let it stay active.
// Otherwise, blur the active item since it is no longer visible.
if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
clearTimeout( this.timer );
}
}
}
},
"mouseenter .ui-menu-item": function( event ) {
var target = $( event.currentTarget );
// Remove ui-state-active class from siblings of the newly focused menu item
// to avoid a jump caused by adjacent elements both having a class with a border
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
this.focus( event, target );
},
mouseleave: "collapseAll",
"mouseleave .ui-menu": "collapseAll",
focus: function( event, keepActiveItem ) {
// If there's already an active item, keep it active
// If not, activate the first item
var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
if ( !keepActiveItem ) {
this.focus( event, item );
}
},
blur: function( event ) {
this._delay(function() {
if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
this.collapseAll( event );
}
});
},
keydown: "_keydown"
});
this.refresh();
// Clicks outside of a menu collapse any open menus
this._on( this.document, {
click: function( event ) {
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
this.collapseAll( event );
}
// Reset the mouseHandled flag
this.mouseHandled = false;
}
});
},
_destroy: function() {
// Destroy (sub)menus
this.element
.removeAttr( "aria-activedescendant" )
.find( ".ui-menu" ).addBack()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
.removeAttr( "role" )
.removeAttr( "tabIndex" )
.removeAttr( "aria-labelledby" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-hidden" )
.removeAttr( "aria-disabled" )
.removeUniqueId()
.show();
// Destroy menu items
this.element.find( ".ui-menu-item" )
.removeClass( "ui-menu-item" )
.removeAttr( "role" )
.removeAttr( "aria-disabled" )
.children( "a" )
.removeUniqueId()
.removeClass( "ui-corner-all ui-state-hover" )
.removeAttr( "tabIndex" )
.removeAttr( "role" )
.removeAttr( "aria-haspopup" )
.children().each( function() {
var elem = $( this );
if ( elem.data( "ui-menu-submenu-carat" ) ) {
elem.remove();
}
});
// Destroy menu dividers
this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
},
_keydown: function( event ) {
var match, prev, character, skip, regex,
preventDefault = true;
function escape( value ) {
return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
}
switch ( event.keyCode ) {
case $.ui.keyCode.PAGE_UP:
this.previousPage( event );
break;
case $.ui.keyCode.PAGE_DOWN:
this.nextPage( event );
break;
case $.ui.keyCode.HOME:
this._move( "first", "first", event );
break;
case $.ui.keyCode.END:
this._move( "last", "last", event );
break;
case $.ui.keyCode.UP:
this.previous( event );
break;
case $.ui.keyCode.DOWN:
this.next( event );
break;
case $.ui.keyCode.LEFT:
this.collapse( event );
break;
case $.ui.keyCode.RIGHT:
if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
this.expand( event );
}
break;
case $.ui.keyCode.ENTER:
case $.ui.keyCode.SPACE:
this._activate( event );
break;
case $.ui.keyCode.ESCAPE:
this.collapse( event );
break;
default:
preventDefault = false;
prev = this.previousFilter || "";
character = String.fromCharCode( event.keyCode );
skip = false;
clearTimeout( this.filterTimer );
if ( character === prev ) {
skip = true;
} else {
character = prev + character;
}
regex = new RegExp( "^" + escape( character ), "i" );
match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
return regex.test( $( this ).children( "a" ).text() );
});
match = skip && match.index( this.active.next() ) !== -1 ?
this.active.nextAll( ".ui-menu-item" ) :
match;
// If no matches on the current filter, reset to the last character pressed
// to move down the menu to the first item that starts with that character
if ( !match.length ) {
character = String.fromCharCode( event.keyCode );
regex = new RegExp( "^" + escape( character ), "i" );
match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
return regex.test( $( this ).children( "a" ).text() );
});
}
if ( match.length ) {
this.focus( event, match );
if ( match.length > 1 ) {
this.previousFilter = character;
this.filterTimer = this._delay(function() {
delete this.previousFilter;
}, 1000 );
} else {
delete this.previousFilter;
}
} else {
delete this.previousFilter;
}
}
if ( preventDefault ) {
event.preventDefault();
}
},
_activate: function( event ) {
if ( !this.active.is( ".ui-state-disabled" ) ) {
if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
this.expand( event );
} else {
this.select( event );
}
}
},
refresh: function() {
var menus,
icon = this.options.icons.submenu,
submenus = this.element.find( this.options.menus );
this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
// Initialize nested menus
submenus.filter( ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.hide()
.attr({
role: this.options.role,
"aria-hidden": "true",
"aria-expanded": "false"
})
.each(function() {
var menu = $( this ),
item = menu.prev( "a" ),
submenuCarat = $( "<span>" )
.addClass( "ui-menu-icon ui-icon " + icon )
.data( "ui-menu-submenu-carat", true );
item
.attr( "aria-haspopup", "true" )
.prepend( submenuCarat );
menu.attr( "aria-labelledby", item.attr( "id" ) );
});
menus = submenus.add( this.element );
// Don't refresh list items that are already adapted
menus.children( ":not(.ui-menu-item):has(a)" )
.addClass( "ui-menu-item" )
.attr( "role", "presentation" )
.children( "a" )
.uniqueId()
.addClass( "ui-corner-all" )
.attr({
tabIndex: -1,
role: this._itemRole()
});
// Initialize unlinked menu-items containing spaces and/or dashes only as dividers
menus.children( ":not(.ui-menu-item)" ).each(function() {
var item = $( this );
// hyphen, em dash, en dash
if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
item.addClass( "ui-widget-content ui-menu-divider" );
}
});
// Add aria-disabled attribute to any disabled menu item
menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
// If the active item has been removed, blur the menu
if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
this.blur();
}
},
_itemRole: function() {
return {
menu: "menuitem",
listbox: "option"
}[ this.options.role ];
},
_setOption: function( key, value ) {
if ( key === "icons" ) {
this.element.find( ".ui-menu-icon" )
.removeClass( this.options.icons.submenu )
.addClass( value.submenu );
}
this._super( key, value );
},
focus: function( event, item ) {
var nested, focused;
this.blur( event, event && event.type === "focus" );
this._scrollIntoView( item );
this.active = item.first();
focused = this.active.children( "a" ).addClass( "ui-state-focus" );
// Only update aria-activedescendant if there's a role
// otherwise we assume focus is managed elsewhere
if ( this.options.role ) {
this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
}
// Highlight active parent menu item, if any
this.active
.parent()
.closest( ".ui-menu-item" )
.children( "a:first" )
.addClass( "ui-state-active" );
if ( event && event.type === "keydown" ) {
this._close();
} else {
this.timer = this._delay(function() {
this._close();
}, this.delay );
}
nested = item.children( ".ui-menu" );
if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
this._startOpening(nested);
}
this.activeMenu = item.parent();
this._trigger( "focus", event, { item: item } );
},
_scrollIntoView: function( item ) {
var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
if ( this._hasScroll() ) {
borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
scroll = this.activeMenu.scrollTop();
elementHeight = this.activeMenu.height();
itemHeight = item.height();
if ( offset < 0 ) {
this.activeMenu.scrollTop( scroll + offset );
} else if ( offset + itemHeight > elementHeight ) {
this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
}
}
},
blur: function( event, fromFocus ) {
if ( !fromFocus ) {
clearTimeout( this.timer );
}
if ( !this.active ) {
return;
}
this.active.children( "a" ).removeClass( "ui-state-focus" );
this.active = null;
this._trigger( "blur", event, { item: this.active } );
},
_startOpening: function( submenu ) {
clearTimeout( this.timer );
// Don't open if already open fixes a Firefox bug that caused a .5 pixel
// shift in the submenu position when mousing over the carat icon
if ( submenu.attr( "aria-hidden" ) !== "true" ) {
return;
}
this.timer = this._delay(function() {
this._close();
this._open( submenu );
}, this.delay );
},
_open: function( submenu ) {
var position = $.extend({
of: this.active
}, this.options.position );
clearTimeout( this.timer );
this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
.hide()
.attr( "aria-hidden", "true" );
submenu
.show()
.removeAttr( "aria-hidden" )
.attr( "aria-expanded", "true" )
.position( position );
},
collapseAll: function( event, all ) {
clearTimeout( this.timer );
this.timer = this._delay(function() {
// If we were passed an event, look for the submenu that contains the event
var currentMenu = all ? this.element :
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
// If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
if ( !currentMenu.length ) {
currentMenu = this.element;
}
this._close( currentMenu );
this.blur( event );
this.activeMenu = currentMenu;
}, this.delay );
},
// With no arguments, closes the currently active menu - if nothing is active
// it closes all menus. If passed an argument, it will search for menus BELOW
_close: function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
.removeClass( "ui-state-active" );
},
collapse: function( event ) {
var newItem = this.active &&
this.active.parent().closest( ".ui-menu-item", this.element );
if ( newItem && newItem.length ) {
this._close();
this.focus( event, newItem );
}
},
expand: function( event ) {
var newItem = this.active &&
this.active
.children( ".ui-menu " )
.children( ".ui-menu-item" )
.first();
if ( newItem && newItem.length ) {
this._open( newItem.parent() );
// Delay so Firefox will not hide activedescendant change in expanding submenu from AT
this._delay(function() {
this.focus( event, newItem );
});
}
},
next: function( event ) {
this._move( "next", "first", event );
},
previous: function( event ) {
this._move( "prev", "last", event );
},
isFirstItem: function() {
return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
},
isLastItem: function() {
return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
},
_move: function( direction, filter, event ) {
var next;
if ( this.active ) {
if ( direction === "first" || direction === "last" ) {
next = this.active
[ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
.eq( -1 );
} else {
next = this.active
[ direction + "All" ]( ".ui-menu-item" )
.eq( 0 );
}
}
if ( !next || !next.length || !this.active ) {
next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
}
this.focus( event, next );
},
nextPage: function( event ) {
var item, base, height;
if ( !this.active ) {
this.next( event );
return;
}
if ( this.isLastItem() ) {
return;
}
if ( this._hasScroll() ) {
base = this.active.offset().top;
height = this.element.height();
this.active.nextAll( ".ui-menu-item" ).each(function() {
item = $( this );
return item.offset().top - base - height < 0;
});
this.focus( event, item );
} else {
this.focus( event, this.activeMenu.children( ".ui-menu-item" )
[ !this.active ? "first" : "last" ]() );
}
},
previousPage: function( event ) {
var item, base, height;
if ( !this.active ) {
this.next( event );
return;
}
if ( this.isFirstItem() ) {
return;
}
if ( this._hasScroll() ) {
base = this.active.offset().top;
height = this.element.height();
this.active.prevAll( ".ui-menu-item" ).each(function() {
item = $( this );
return item.offset().top - base + height > 0;
});
this.focus( event, item );
} else {
this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
}
},
_hasScroll: function() {
return this.element.outerHeight() < this.element.prop( "scrollHeight" );
},
select: function( event ) {
// TODO: It should never be possible to not have an active item at this
// point, but the tests don't trigger mouseenter before click.
this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
var ui = { item: this.active };
if ( !this.active.has( ".ui-menu" ).length ) {
this.collapseAll( event, true );
}
this._trigger( "select", event, ui );
}
});
}( jQuery ));
(function( $, undefined ) {
// number of pages in a slider
// (how many times can you page up/down to go through the whole range)
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, {
version: "1.10.4",
widgetEventPrefix: "slide",
options: {
animate: false,
distance: 0,
max: 100,
min: 0,
orientation: "horizontal",
range: false,
step: 1,
value: 0,
values: null,
// callbacks
change: null,
slide: null,
start: null,
stop: null
},
_create: function() {
this._keySliding = false;
this._mouseSliding = false;
this._animateOff = true;
this._handleIndex = null;
this._detectOrientation();
this._mouseInit();
this.element
.addClass( "ui-slider" +
" ui-slider-" + this.orientation +
" ui-widget" +
" ui-widget-content" +
" ui-corner-all");
this._refresh();
this._setOption( "disabled", this.options.disabled );
this._animateOff = false;
},
_refresh: function() {
this._createRange();
this._createHandles();
this._setupEvents();
this._refreshValue();
},
_createHandles: function() {
var i, handleCount,
options = this.options,
existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
handles = [];
handleCount = ( options.values && options.values.length ) || 1;
if ( existingHandles.length > handleCount ) {
existingHandles.slice( handleCount ).remove();
existingHandles = existingHandles.slice( 0, handleCount );
}
for ( i = existingHandles.length; i < handleCount; i++ ) {
handles.push( handle );
}
this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
this.handle = this.handles.eq( 0 );
this.handles.each(function( i ) {
$( this ).data( "ui-slider-handle-index", i );
});
},
_createRange: function() {
var options = this.options,
classes = "";
if ( options.range ) {
if ( options.range === true ) {
if ( !options.values ) {
options.values = [ this._valueMin(), this._valueMin() ];
} else if ( options.values.length && options.values.length !== 2 ) {
options.values = [ options.values[0], options.values[0] ];
} else if ( $.isArray( options.values ) ) {
options.values = options.values.slice(0);
}
}
if ( !this.range || !this.range.length ) {
this.range = $( "<div></div>" )
.appendTo( this.element );
classes = "ui-slider-range" +
// note: this isn't the most fittingly semantic framework class for this element,
// but worked best visually with a variety of themes
" ui-widget-header ui-corner-all";
} else {
this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
// Handle range switching from true to min/max
.css({
"left": "",
"bottom": ""
});
}
this.range.addClass( classes +
( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
} else {
if ( this.range ) {
this.range.remove();
}
this.range = null;
}
},
_setupEvents: function() {
var elements = this.handles.add( this.range ).filter( "a" );
this._off( elements );
this._on( elements, this._handleEvents );
this._hoverable( elements );
this._focusable( elements );
},
_destroy: function() {
this.handles.remove();
if ( this.range ) {
this.range.remove();
}
this.element
.removeClass( "ui-slider" +
" ui-slider-horizontal" +
" ui-slider-vertical" +
" ui-widget" +
" ui-widget-content" +
" ui-corner-all" );
this._mouseDestroy();
},
_mouseCapture: function( event ) {
var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
that = this,
o = this.options;
if ( o.disabled ) {
return false;
}
this.elementSize = {
width: this.element.outerWidth(),
height: this.element.outerHeight()
};
this.elementOffset = this.element.offset();
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
distance = this._valueMax() - this._valueMin() + 1;
this.handles.each(function( i ) {
var thisDistance = Math.abs( normValue - that.values(i) );
if (( distance > thisDistance ) ||
( distance === thisDistance &&
(i === that._lastChangedValue || that.values(i) === o.min ))) {
distance = thisDistance;
closestHandle = $( this );
index = i;
}
});
allowed = this._start( event, index );
if ( allowed === false ) {
return false;
}
this._mouseSliding = true;
this._handleIndex = index;
closestHandle
.addClass( "ui-state-active" )
.focus();
offset = closestHandle.offset();
mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
top: event.pageY - offset.top -
( closestHandle.height() / 2 ) -
( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
};
if ( !this.handles.hasClass( "ui-state-hover" ) ) {
this._slide( event, index, normValue );
}
this._animateOff = true;
return true;
},
_mouseStart: function() {
return true;
},
_mouseDrag: function( event ) {
var position = { x: event.pageX, y: event.pageY },
normValue = this._normValueFromMouse( position );
this._slide( event, this._handleIndex, normValue );
return false;
},
_mouseStop: function( event ) {
this.handles.removeClass( "ui-state-active" );
this._mouseSliding = false;
this._stop( event, this._handleIndex );
this._change( event, this._handleIndex );
this._handleIndex = null;
this._clickOffset = null;
this._animateOff = false;
return false;
},
_detectOrientation: function() {
this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
},
_normValueFromMouse: function( position ) {
var pixelTotal,
pixelMouse,
percentMouse,
valueTotal,
valueMouse;
if ( this.orientation === "horizontal" ) {
pixelTotal = this.elementSize.width;
pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
} else {
pixelTotal = this.elementSize.height;
pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
}
percentMouse = ( pixelMouse / pixelTotal );
if ( percentMouse > 1 ) {
percentMouse = 1;
}
if ( percentMouse < 0 ) {
percentMouse = 0;
}
if ( this.orientation === "vertical" ) {
percentMouse = 1 - percentMouse;
}
valueTotal = this._valueMax() - this._valueMin();
valueMouse = this._valueMin() + percentMouse * valueTotal;
return this._trimAlignValue( valueMouse );
},
_start: function( event, index ) {
var uiHash = {
handle: this.handles[ index ],
value: this.value()
};
if ( this.options.values && this.options.values.length ) {
uiHash.value = this.values( index );
uiHash.values = this.values();
}
return this._trigger( "start", event, uiHash );
},
_slide: function( event, index, newVal ) {
var otherVal,
newValues,
allowed;
if ( this.options.values && this.options.values.length ) {
otherVal = this.values( index ? 0 : 1 );
if ( ( this.options.values.length === 2 && this.options.range === true ) &&
( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
) {
newVal = otherVal;
}
if ( newVal !== this.values( index ) ) {
newValues = this.values();
newValues[ index ] = newVal;
// A slide can be canceled by returning false from the slide callback
allowed = this._trigger( "slide", event, {
handle: this.handles[ index ],
value: newVal,
values: newValues
} );
otherVal = this.values( index ? 0 : 1 );
if ( allowed !== false ) {
this.values( index, newVal );
}
}
} else {
if ( newVal !== this.value() ) {
// A slide can be canceled by returning false from the slide callback
allowed = this._trigger( "slide", event, {
handle: this.handles[ index ],
value: newVal
} );
if ( allowed !== false ) {
this.value( newVal );
}
}
}
},
_stop: function( event, index ) {
var uiHash = {
handle: this.handles[ index ],
value: this.value()
};
if ( this.options.values && this.options.values.length ) {
uiHash.value = this.values( index );
uiHash.values = this.values();
}
this._trigger( "stop", event, uiHash );
},
_change: function( event, index ) {
if ( !this._keySliding && !this._mouseSliding ) {
var uiHash = {
handle: this.handles[ index ],
value: this.value()
};
if ( this.options.values && this.options.values.length ) {
uiHash.value = this.values( index );
uiHash.values = this.values();
}
//store the last changed value index for reference when handles overlap
this._lastChangedValue = index;
this._trigger( "change", event, uiHash );
}
},
value: function( newValue ) {
if ( arguments.length ) {
this.options.value = this._trimAlignValue( newValue );
this._refreshValue();
this._change( null, 0 );
return;
}
return this._value();
},
values: function( index, newValue ) {
var vals,
newValues,
i;
if ( arguments.length > 1 ) {
this.options.values[ index ] = this._trimAlignValue( newValue );
this._refreshValue();
this._change( null, index );
return;
}
if ( arguments.length ) {
if ( $.isArray( arguments[ 0 ] ) ) {
vals = this.options.values;
newValues = arguments[ 0 ];
for ( i = 0; i < vals.length; i += 1 ) {
vals[ i ] = this._trimAlignValue( newValues[ i ] );
this._change( null, i );
}
this._refreshValue();
} else {
if ( this.options.values && this.options.values.length ) {
return this._values( index );
} else {
return this.value();
}
}
} else {
return this._values();
}
},
_setOption: function( key, value ) {
var i,
valsLength = 0;
if ( key === "range" && this.options.range === true ) {
if ( value === "min" ) {
this.options.value = this._values( 0 );
this.options.values = null;
} else if ( value === "max" ) {
this.options.value = this._values( this.options.values.length-1 );
this.options.values = null;
}
}
if ( $.isArray( this.options.values ) ) {
valsLength = this.options.values.length;
}
$.Widget.prototype._setOption.apply( this, arguments );
switch ( key ) {
case "orientation":
this._detectOrientation();
this.element
.removeClass( "ui-slider-horizontal ui-slider-vertical" )
.addClass( "ui-slider-" + this.orientation );
this._refreshValue();
break;
case "value":
this._animateOff = true;
this._refreshValue();
this._change( null, 0 );
this._animateOff = false;
break;
case "values":
this._animateOff = true;
this._refreshValue();
for ( i = 0; i < valsLength; i += 1 ) {
this._change( null, i );
}
this._animateOff = false;
break;
case "min":
case "max":
this._animateOff = true;
this._refreshValue();
this._animateOff = false;
break;
case "range":
this._animateOff = true;
this._refresh();
this._animateOff = false;
break;
}
},
//internal value getter
// _value() returns value trimmed by min and max, aligned by step
_value: function() {
var val = this.options.value;
val = this._trimAlignValue( val );
return val;
},
//internal values getter
// _values() returns array of values trimmed by min and max, aligned by step
// _values( index ) returns single value trimmed by min and max, aligned by step
_values: function( index ) {
var val,
vals,
i;
if ( arguments.length ) {
val = this.options.values[ index ];
val = this._trimAlignValue( val );
return val;
} else if ( this.options.values && this.options.values.length ) {
// .slice() creates a copy of the array
// this copy gets trimmed by min and max and then returned
vals = this.options.values.slice();
for ( i = 0; i < vals.length; i+= 1) {
vals[ i ] = this._trimAlignValue( vals[ i ] );
}
return vals;
} else {
return [];
}
},
// returns the step-aligned value that val is closest to, between (inclusive) min and max
_trimAlignValue: function( val ) {
if ( val <= this._valueMin() ) {
return this._valueMin();
}
if ( val >= this._valueMax() ) {
return this._valueMax();
}
var step = ( this.options.step > 0 ) ? this.options.step : 1,
valModStep = (val - this._valueMin()) % step,
alignValue = val - valModStep;
if ( Math.abs(valModStep) * 2 >= step ) {
alignValue += ( valModStep > 0 ) ? step : ( -step );
}
// Since JavaScript has problems with large floats, round
// the final value to 5 digits after the decimal point (see #4124)
return parseFloat( alignValue.toFixed(5) );
},
_valueMin: function() {
return this.options.min;
},
_valueMax: function() {
return this.options.max;
},
_refreshValue: function() {
var lastValPercent, valPercent, value, valueMin, valueMax,
oRange = this.options.range,
o = this.options,
that = this,
animate = ( !this._animateOff ) ? o.animate : false,
_set = {};
if ( this.options.values && this.options.values.length ) {
this.handles.each(function( i ) {
valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
_set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
if ( that.options.range === true ) {
if ( that.orientation === "horizontal" ) {
if ( i === 0 ) {
that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
}
if ( i === 1 ) {
that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
} else {
if ( i === 0 ) {
that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
}
if ( i === 1 ) {
that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
}
lastValPercent = valPercent;
});
} else {
value = this.value();
valueMin = this._valueMin();
valueMax = this._valueMax();
valPercent = ( valueMax !== valueMin ) ?
( value - valueMin ) / ( valueMax - valueMin ) * 100 :
0;
_set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
if ( oRange === "min" && this.orientation === "horizontal" ) {
this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
}
if ( oRange === "max" && this.orientation === "horizontal" ) {
this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
}
if ( oRange === "min" && this.orientation === "vertical" ) {
this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
}
if ( oRange === "max" && this.orientation === "vertical" ) {
this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
},
_handleEvents: {
keydown: function( event ) {
var allowed, curVal, newVal, step,
index = $( event.target ).data( "ui-slider-handle-index" );
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
case $.ui.keyCode.END:
case $.ui.keyCode.PAGE_UP:
case $.ui.keyCode.PAGE_DOWN:
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
event.preventDefault();
if ( !this._keySliding ) {
this._keySliding = true;
$( event.target ).addClass( "ui-state-active" );
allowed = this._start( event, index );
if ( allowed === false ) {
return;
}
}
break;
}
step = this.options.step;
if ( this.options.values && this.options.values.length ) {
curVal = newVal = this.values( index );
} else {
curVal = newVal = this.value();
}
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
newVal = this._valueMin();
break;
case $.ui.keyCode.END:
newVal = this._valueMax();
break;
case $.ui.keyCode.PAGE_UP:
newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.PAGE_DOWN:
newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
if ( curVal === this._valueMax() ) {
return;
}
newVal = this._trimAlignValue( curVal + step );
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
if ( curVal === this._valueMin() ) {
return;
}
newVal = this._trimAlignValue( curVal - step );
break;
}
this._slide( event, index, newVal );
},
click: function( event ) {
event.preventDefault();
},
keyup: function( event ) {
var index = $( event.target ).data( "ui-slider-handle-index" );
if ( this._keySliding ) {
this._keySliding = false;
this._stop( event, index );
this._change( event, index );
$( event.target ).removeClass( "ui-state-active" );
}
}
}
});
}(jQuery));
(function( $ ) {
var increments = 0;
function addDescribedBy( elem, id ) {
var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
describedby.push( id );
elem
.data( "ui-tooltip-id", id )
.attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
}
function removeDescribedBy( elem ) {
var id = elem.data( "ui-tooltip-id" ),
describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
index = $.inArray( id, describedby );
if ( index !== -1 ) {
describedby.splice( index, 1 );
}
elem.removeData( "ui-tooltip-id" );
describedby = $.trim( describedby.join( " " ) );
if ( describedby ) {
elem.attr( "aria-describedby", describedby );
} else {
elem.removeAttr( "aria-describedby" );
}
}
$.widget( "ui.tooltip", {
version: "1.10.4",
options: {
content: function() {
// support: IE<9, Opera in jQuery <1.7
// .text() can't accept undefined, so coerce to a string
var title = $( this ).attr( "title" ) || "";
// Escape title, since we're going from an attribute to raw HTML
return $( "<a>" ).text( title ).html();
},
hide: true,
// Disabled elements have inconsistent behavior across browsers (#8661)
items: "[title]:not([disabled])",
position: {
my: "left top+15",
at: "left bottom",
collision: "flipfit flip"
},
show: true,
tooltipClass: null,
track: false,
// callbacks
close: null,
open: null
},
_create: function() {
this._on({
mouseover: "open",
focusin: "open"
});
// IDs of generated tooltips, needed for destroy
this.tooltips = {};
// IDs of parent tooltips where we removed the title attribute
this.parents = {};
if ( this.options.disabled ) {
this._disable();
}
},
_setOption: function( key, value ) {
var that = this;
if ( key === "disabled" ) {
this[ value ? "_disable" : "_enable" ]();
this.options[ key ] = value;
// disable element style changes
return;
}
this._super( key, value );
if ( key === "content" ) {
$.each( this.tooltips, function( id, element ) {
that._updateContent( element );
});
}
},
_disable: function() {
var that = this;
// close open tooltips
$.each( this.tooltips, function( id, element ) {
var event = $.Event( "blur" );
event.target = event.currentTarget = element[0];
that.close( event, true );
});
// remove title attributes to prevent native tooltips
this.element.find( this.options.items ).addBack().each(function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
element
.data( "ui-tooltip-title", element.attr( "title" ) )
.attr( "title", "" );
}
});
},
_enable: function() {
// restore title attributes
this.element.find( this.options.items ).addBack().each(function() {
var element = $( this );
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
}
});
},
open: function( event ) {
var that = this,
target = $( event ? event.target : this.element )
// we need closest here due to mouseover bubbling,
// but always pointing at the same event target
.closest( this.options.items );
// No element to show a tooltip for or the tooltip is already open
if ( !target.length || target.data( "ui-tooltip-id" ) ) {
return;
}
if ( target.attr( "title" ) ) {
target.data( "ui-tooltip-title", target.attr( "title" ) );
}
target.data( "ui-tooltip-open", true );
// kill parent tooltips, custom or native, for hover
if ( event && event.type === "mouseover" ) {
target.parents().each(function() {
var parent = $( this ),
blurEvent;
if ( parent.data( "ui-tooltip-open" ) ) {
blurEvent = $.Event( "blur" );
blurEvent.target = blurEvent.currentTarget = this;
that.close( blurEvent, true );
}
if ( parent.attr( "title" ) ) {
parent.uniqueId();
that.parents[ this.id ] = {
element: this,
title: parent.attr( "title" )
};
parent.attr( "title", "" );
}
});
}
this._updateContent( target, event );
},
_updateContent: function( target, event ) {
var content,
contentOption = this.options.content,
that = this,
eventType = event ? event.type : null;
if ( typeof contentOption === "string" ) {
return this._open( event, target, contentOption );
}
content = contentOption.call( target[0], function( response ) {
// ignore async response if tooltip was closed already
if ( !target.data( "ui-tooltip-open" ) ) {
return;
}
// IE may instantly serve a cached response for ajax requests
// delay this call to _open so the other call to _open runs first
that._delay(function() {
// jQuery creates a special event for focusin when it doesn't
// exist natively. To improve performance, the native event
// object is reused and the type is changed. Therefore, we can't
// rely on the type being correct after the event finished
// bubbling, so we set it back to the previous value. (#8740)
if ( event ) {
event.type = eventType;
}
this._open( event, target, response );
});
});
if ( content ) {
this._open( event, target, content );
}
},
_open: function( event, target, content ) {
var tooltip, events, delayedShow,
positionOption = $.extend( {}, this.options.position );
if ( !content ) {
return;
}
// Content can be updated multiple times. If the tooltip already
// exists, then just update the content and bail.
tooltip = this._find( target );
if ( tooltip.length ) {
tooltip.find( ".ui-tooltip-content" ).html( content );
return;
}
// if we have a title, clear it to prevent the native tooltip
// we have to check first to avoid defining a title if none exists
// (we don't want to cause an element to start matching [title])
//
// We use removeAttr only for key events, to allow IE to export the correct
// accessible attributes. For mouse events, set to empty string to avoid
// native tooltip showing up (happens only when removing inside mouseover).
if ( target.is( "[title]" ) ) {
if ( event && event.type === "mouseover" ) {
target.attr( "title", "" );
} else {
target.removeAttr( "title" );
}
}
tooltip = this._tooltip( target );
addDescribedBy( target, tooltip.attr( "id" ) );
tooltip.find( ".ui-tooltip-content" ).html( content );
function position( event ) {
positionOption.of = event;
if ( tooltip.is( ":hidden" ) ) {
return;
}
tooltip.position( positionOption );
}
if ( this.options.track && event && /^mouse/.test( event.type ) ) {
this._on( this.document, {
mousemove: position
});
// trigger once to override element-relative positioning
position( event );
} else {
tooltip.position( $.extend({
of: target
}, this.options.position ) );
}
tooltip.hide();
this._show( tooltip, this.options.show );
// Handle tracking tooltips that are shown with a delay (#8644). As soon
// as the tooltip is visible, position the tooltip using the most recent
// event.
if ( this.options.show && this.options.show.delay ) {
delayedShow = this.delayedShow = setInterval(function() {
if ( tooltip.is( ":visible" ) ) {
position( positionOption.of );
clearInterval( delayedShow );
}
}, $.fx.interval );
}
this._trigger( "open", event, { tooltip: tooltip } );
events = {
keyup: function( event ) {
if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
var fakeEvent = $.Event(event);
fakeEvent.currentTarget = target[0];
this.close( fakeEvent, true );
}
},
remove: function() {
this._removeTooltip( tooltip );
}
};
if ( !event || event.type === "mouseover" ) {
events.mouseleave = "close";
}
if ( !event || event.type === "focusin" ) {
events.focusout = "close";
}
this._on( true, target, events );
},
close: function( event ) {
var that = this,
target = $( event ? event.currentTarget : this.element ),
tooltip = this._find( target );
// disabling closes the tooltip, so we need to track when we're closing
// to avoid an infinite loop in case the tooltip becomes disabled on close
if ( this.closing ) {
return;
}
// Clear the interval for delayed tracking tooltips
clearInterval( this.delayedShow );
// only set title if we had one before (see comment in _open())
if ( target.data( "ui-tooltip-title" ) ) {
target.attr( "title", target.data( "ui-tooltip-title" ) );
}
removeDescribedBy( target );
tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() {
that._removeTooltip( $( this ) );
});
target.removeData( "ui-tooltip-open" );
this._off( target, "mouseleave focusout keyup" );
// Remove 'remove' binding only on delegated targets
if ( target[0] !== this.element[0] ) {
this._off( target, "remove" );
}
this._off( this.document, "mousemove" );
if ( event && event.type === "mouseleave" ) {
$.each( this.parents, function( id, parent ) {
$( parent.element ).attr( "title", parent.title );
delete that.parents[ id ];
});
}
this.closing = true;
this._trigger( "close", event, { tooltip: tooltip } );
this.closing = false;
},
_tooltip: function( element ) {
var id = "ui-tooltip-" + increments++,
tooltip = $( "<div>" )
.attr({
id: id,
role: "tooltip"
})
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
( this.options.tooltipClass || "" ) );
$( "<div>" )
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
tooltip.appendTo( this.document[0].body );
this.tooltips[ id ] = element;
return tooltip;
},
_find: function( target ) {
var id = target.data( "ui-tooltip-id" );
return id ? $( "#" + id ) : $();
},
_removeTooltip: function( tooltip ) {
tooltip.remove();
delete this.tooltips[ tooltip.attr( "id" ) ];
},
_destroy: function() {
var that = this;
// close open tooltips
$.each( this.tooltips, function( id, element ) {
// Delegate to close method to handle common cleanup
var event = $.Event( "blur" );
event.target = event.currentTarget = element[0];
that.close( event, true );
// Remove immediately; destroying an open tooltip doesn't use the
// hide animation
$( "#" + id ).remove();
// Restore the title
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
element.removeData( "ui-tooltip-title" );
}
});
}
});
}( jQuery ) );
| qqming113/bi-platform | designer/src/main/resources/public/silkroad/dep/jquery-ui.custom-1.10.4.js | JavaScript | apache-2.0 | 339,820 |
/*
* 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 io.trino.sql.planner.iterative.rule;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import io.trino.matching.Capture;
import io.trino.matching.Captures;
import io.trino.matching.Pattern;
import io.trino.sql.planner.TypeAnalyzer;
import io.trino.sql.planner.iterative.Rule;
import io.trino.sql.planner.plan.Assignments;
import io.trino.sql.planner.plan.MarkDistinctNode;
import io.trino.sql.planner.plan.ProjectNode;
import io.trino.sql.tree.Expression;
import io.trino.sql.tree.SubscriptExpression;
import io.trino.sql.tree.SymbolReference;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static io.trino.matching.Capture.newCapture;
import static io.trino.sql.planner.ExpressionNodeInliner.replaceExpression;
import static io.trino.sql.planner.iterative.rule.DereferencePushdown.extractRowSubscripts;
import static io.trino.sql.planner.iterative.rule.DereferencePushdown.getBase;
import static io.trino.sql.planner.plan.Patterns.markDistinct;
import static io.trino.sql.planner.plan.Patterns.project;
import static io.trino.sql.planner.plan.Patterns.source;
import static java.util.Objects.requireNonNull;
/**
* Transforms:
* <pre>
* Project(D := f1(A.x), E := f2(B.x), G := f3(C))
* MarkDistinct(distinctSymbols = [B])
* Source(A, B, C)
* </pre>
* to:
* <pre>
* Project(D := f1(symbol), E := f2(B.x), G := f3(C))
* MarkDistinct(distinctSymbols = [B])
* Project(A, B, C, symbol := A.x)
* Source(A, B, C)
* </pre>
* <p>
* Pushes down dereference projections through MarkDistinct. Excludes dereferences on "distinct symbols" to avoid data
* replication, since these symbols cannot be pruned.
*/
public class PushDownDereferencesThroughMarkDistinct
implements Rule<ProjectNode>
{
private static final Capture<MarkDistinctNode> CHILD = newCapture();
private final TypeAnalyzer typeAnalyzer;
public PushDownDereferencesThroughMarkDistinct(TypeAnalyzer typeAnalyzer)
{
this.typeAnalyzer = requireNonNull(typeAnalyzer, "typeAnalyzer is null");
}
@Override
public Pattern<ProjectNode> getPattern()
{
return project()
.with(source().matching(markDistinct().capturedAs(CHILD)));
}
@Override
public Result apply(ProjectNode projectNode, Captures captures, Context context)
{
MarkDistinctNode markDistinctNode = captures.get(CHILD);
// Extract dereferences from project node assignments for pushdown
Set<SubscriptExpression> dereferences = extractRowSubscripts(projectNode.getAssignments().getExpressions(), false, context.getSession(), typeAnalyzer, context.getSymbolAllocator().getTypes());
// Exclude dereferences on distinct symbols being used in markDistinctNode. We do not need to filter
// dereferences on markerSymbol since it is supposed to be of boolean type.
dereferences = dereferences.stream()
.filter(expression -> !markDistinctNode.getDistinctSymbols().contains(getBase(expression)))
.collect(toImmutableSet());
if (dereferences.isEmpty()) {
return Result.empty();
}
// Create new symbols for dereference expressions
Assignments dereferenceAssignments = Assignments.of(dereferences, context.getSession(), context.getSymbolAllocator(), typeAnalyzer);
// Rewrite project node assignments using new symbols for dereference expressions
Map<Expression, SymbolReference> mappings = HashBiMap.create(dereferenceAssignments.getMap())
.inverse()
.entrySet().stream()
.collect(toImmutableMap(Map.Entry::getKey, entry -> entry.getValue().toSymbolReference()));
Assignments newAssignments = projectNode.getAssignments().rewrite(expression -> replaceExpression(expression, mappings));
return Result.ofPlanNode(
new ProjectNode(
context.getIdAllocator().getNextId(),
markDistinctNode.replaceChildren(ImmutableList.of(
new ProjectNode(
context.getIdAllocator().getNextId(),
markDistinctNode.getSource(),
Assignments.builder()
.putIdentities(markDistinctNode.getSource().getOutputSymbols())
.putAll(dereferenceAssignments)
.build()))),
newAssignments));
}
}
| ebyhr/presto | core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/PushDownDereferencesThroughMarkDistinct.java | Java | apache-2.0 | 5,356 |
/*
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <vector>
#include "kernel/expr_maps.h"
namespace lean {
class equiv_manager {
typedef unsigned node_ref;
struct node {
node_ref m_parent;
unsigned m_rank;
};
std::vector<node> m_nodes;
expr_struct_map<node_ref> m_to_node;
bool m_use_hash;
node_ref mk_node();
node_ref find(node_ref n);
void merge(node_ref n1, node_ref n2);
node_ref to_node(expr const & e);
bool is_equiv_core(expr const & e1, expr const & e2);
public:
equiv_manager():m_use_hash(false) {}
bool is_equiv(expr const & e1, expr const & e2, bool use_hash = false);
void add_equiv(expr const & e1, expr const & e2);
};
}
| fgdorais/lean | src/kernel/equiv_manager.h | C | apache-2.0 | 875 |
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package seccomp
import (
"strings"
"testing"
"k8s.io/kubernetes/pkg/api"
)
func TestNewWithSeccompProfile(t *testing.T) {
tests := map[string]struct {
allowedProfiles []string
}{
"empty": {allowedProfiles: []string{}},
"nil": {allowedProfiles: nil},
"wildcard": {allowedProfiles: []string{allowAnyProfile}},
"values": {allowedProfiles: []string{"foo", "bar", "*"}},
}
for k, v := range tests {
_, err := NewWithSeccompProfile(v.allowedProfiles)
if err != nil {
t.Errorf("%s failed with error %v", k, err)
}
}
}
func TestGenerate(t *testing.T) {
tests := map[string]struct {
allowedProfiles []string
expectedProfile string
}{
"empty allowed profiles": {
allowedProfiles: []string{},
expectedProfile: "",
},
"nil allowed profiles": {
allowedProfiles: nil,
expectedProfile: "",
},
"allow wildcard only": {
allowedProfiles: []string{allowAnyProfile},
expectedProfile: "",
},
"allow values": {
allowedProfiles: []string{"foo", "bar"},
expectedProfile: "foo",
},
"allow wildcard and values": {
allowedProfiles: []string{"*", "foo", "bar"},
expectedProfile: "foo",
},
}
for k, v := range tests {
strategy, err := NewWithSeccompProfile(v.allowedProfiles)
if err != nil {
t.Errorf("%s failed to create strategy with error %v", k, err)
continue
}
actualProfile, generationError := strategy.Generate(nil)
if generationError != nil {
t.Errorf("%s received generation error %v", k, generationError)
continue
}
if v.expectedProfile != actualProfile {
t.Errorf("%s expected %s but received %s", k, v.expectedProfile, actualProfile)
}
}
}
func TestValidatePod(t *testing.T) {
newPod := func(podProfile string) *api.Pod {
pod := &api.Pod{}
if podProfile != "" {
pod.Annotations = map[string]string{
api.SeccompPodAnnotationKey: podProfile,
}
}
return pod
}
tests := map[string]struct {
allowedProfiles []string
pod *api.Pod
expectedMsg string
}{
"empty allowed profiles, no pod profile": {
allowedProfiles: nil,
pod: newPod(""),
expectedMsg: "",
},
"empty allowed profiles, pod profile": {
allowedProfiles: nil,
pod: newPod("foo"),
expectedMsg: "seccomp may not be set",
},
"good pod profile": {
allowedProfiles: []string{"foo"},
pod: newPod("foo"),
expectedMsg: "",
},
"bad pod profile": {
allowedProfiles: []string{"foo"},
pod: newPod("bar"),
expectedMsg: "bar is not a valid seccomp profile",
},
"wildcard allows pod profile": {
allowedProfiles: []string{"*"},
pod: newPod("foo"),
expectedMsg: "",
},
"wildcard allows no profile": {
allowedProfiles: []string{"*"},
pod: newPod(""),
expectedMsg: "",
},
}
for name, tc := range tests {
strategy, err := NewWithSeccompProfile(tc.allowedProfiles)
if err != nil {
t.Errorf("%s failed to create strategy with error %v", name, err)
continue
}
errs := strategy.ValidatePod(tc.pod)
//should've passed but didn't
if len(tc.expectedMsg) == 0 && len(errs) > 0 {
t.Errorf("%s expected no errors but received %v", name, errs)
}
//should've failed but didn't
if len(tc.expectedMsg) != 0 && len(errs) == 0 {
t.Errorf("%s expected error %s but received no errors", name, tc.expectedMsg)
}
//failed with additional messages
if len(tc.expectedMsg) != 0 && len(errs) > 1 {
t.Errorf("%s expected error %s but received multiple errors: %v", name, tc.expectedMsg, errs)
}
//check that we got the right message
if len(tc.expectedMsg) != 0 && len(errs) == 1 {
if !strings.Contains(errs[0].Error(), tc.expectedMsg) {
t.Errorf("%s expected error to contain %s but it did not: %v", name, tc.expectedMsg, errs)
}
}
}
}
func TestValidateContainer(t *testing.T) {
newPod := func(profile string) *api.Pod {
pod := &api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
api.Container{
Name: "test",
},
},
},
}
if profile != "" {
pod.Annotations = map[string]string{
api.SeccompContainerAnnotationKeyPrefix + "test": profile,
}
}
return pod
}
tests := map[string]struct {
allowedProfiles []string
pod *api.Pod
expectedMsg string
}{
"empty allowed profiles, no container profile": {
allowedProfiles: nil,
pod: newPod(""),
expectedMsg: "",
},
"empty allowed profiles, container profile": {
allowedProfiles: nil,
pod: newPod("foo"),
expectedMsg: "seccomp may not be set",
},
"good container profile": {
allowedProfiles: []string{"foo"},
pod: newPod("foo"),
expectedMsg: "",
},
"bad container profile": {
allowedProfiles: []string{"foo"},
pod: newPod("bar"),
expectedMsg: "bar is not a valid seccomp profile",
},
"wildcard allows container profile": {
allowedProfiles: []string{"*"},
pod: newPod("foo"),
expectedMsg: "",
},
"wildcard allows no profile": {
allowedProfiles: []string{"*"},
pod: newPod(""),
expectedMsg: "",
},
}
for name, tc := range tests {
strategy, err := NewWithSeccompProfile(tc.allowedProfiles)
if err != nil {
t.Errorf("%s failed to create strategy with error %v", name, err)
continue
}
errs := strategy.ValidateContainer(tc.pod, &tc.pod.Spec.Containers[0])
//should've passed but didn't
if len(tc.expectedMsg) == 0 && len(errs) > 0 {
t.Errorf("%s expected no errors but received %v", name, errs)
}
//should've failed but didn't
if len(tc.expectedMsg) != 0 && len(errs) == 0 {
t.Errorf("%s expected error %s but received no errors", name, tc.expectedMsg)
}
//failed with additional messages
if len(tc.expectedMsg) != 0 && len(errs) > 1 {
t.Errorf("%s expected error %s but received multiple errors: %v", name, tc.expectedMsg, errs)
}
//check that we got the right message
if len(tc.expectedMsg) != 0 && len(errs) == 1 {
if !strings.Contains(errs[0].Error(), tc.expectedMsg) {
t.Errorf("%s expected error to contain %s but it did not: %v", name, tc.expectedMsg, errs)
}
}
}
}
| tracyrankin/origin | vendor/k8s.io/kubernetes/pkg/securitycontextconstraints/seccomp/withseccomp_test.go | GO | apache-2.0 | 6,763 |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sysml.runtime.instructions.spark;
import org.apache.sysml.runtime.DMLRuntimeException;
import org.apache.sysml.runtime.controlprogram.context.ExecutionContext;
import org.apache.sysml.runtime.instructions.cp.CPOperand;
import org.apache.sysml.runtime.matrix.operators.Operator;
public class MatrixScalarRelationalSPInstruction extends RelationalBinarySPInstruction
{
public MatrixScalarRelationalSPInstruction(Operator op, CPOperand in1, CPOperand in2, CPOperand out, String opcode, String istr)
{
super(op, in1, in2, out, opcode, istr);
}
@Override
public void processInstruction(ExecutionContext ec)
throws DMLRuntimeException
{
String opcode = getOpcode();
if ( !(opcode.equalsIgnoreCase("==") || opcode.equalsIgnoreCase("!=") || opcode.equalsIgnoreCase("<")
|| opcode.equalsIgnoreCase(">") || opcode.equalsIgnoreCase("<=") || opcode.equalsIgnoreCase(">=")) )
{
throw new DMLRuntimeException("Unknown opcode in instruction: " + opcode);
}
//common binary matrix-scalar process instruction
super.processMatrixScalarBinaryInstruction(ec);
}
}
| sandeep-n/incubator-systemml | src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarRelationalSPInstruction.java | Java | apache-2.0 | 1,919 |
// ========================================================================
// Copyright (c) Webtide LLC
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.apache.org/licenses/LICENSE-2.0.txt
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.test;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpRequestTester;
import org.eclipse.jetty.test.support.rawhttp.HttpResponseTester;
import org.eclipse.jetty.test.support.rawhttp.HttpSocketImpl;
import org.eclipse.jetty.test.support.rawhttp.HttpTesting;
import org.eclipse.jetty.util.IO;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Tests against the facilities within the TestSuite to ensure that the various
* org.eclipse.jetty.test.support.* classes do what they are supposed to.
*/
public class DefaultHandlerTest
{
private boolean debug = false;
private static TestableJettyServer server;
private int serverPort;
@BeforeClass
public static void setUpServer() throws Exception
{
server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTP);
server.addConfiguration("DefaultHandler.xml");
server.load();
server.start();
}
@Before
public void testInit() {
serverPort = server.getServerPort();
}
@AfterClass
public static void tearDownServer() throws Exception
{
server.stop();
}
@Test
public void testGET_URL() throws Exception
{
URL url = new URL("http://localhost:" + serverPort + "/tests/alpha.txt");
URLConnection conn = url.openConnection();
conn.connect();
InputStream in = conn.getInputStream();
String response = IO.toString(in);
String expected = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
Assert.assertEquals("Response",expected,response);
}
@Test
public void testGET_Raw() throws Exception
{
StringBuffer rawRequest = new StringBuffer();
rawRequest.append("GET /tests/alpha.txt HTTP/1.1\r\n");
rawRequest.append("Host: localhost\r\n");
rawRequest.append("Connection: close\r\n");
rawRequest.append("\r\n");
Socket sock = new Socket(InetAddress.getLocalHost(),serverPort);
sock.setSoTimeout(5000); // 5 second timeout;
DEBUG("--raw-request--\n" + rawRequest);
InputStream in = new ByteArrayInputStream(rawRequest.toString().getBytes());
// Send request
IO.copy(in,sock.getOutputStream());
// Collect response
String rawResponse = IO.toString(sock.getInputStream());
DEBUG("--raw-response--\n" + rawResponse);
HttpResponseTester response = new HttpResponseTester();
response.parse(rawResponse);
response.assertStatusOK();
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
}
@Test
public void testMultiGET_Raw() throws Exception
{
StringBuffer rawRequests = new StringBuffer();
rawRequests.append("GET /tests/alpha.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("\r\n");
rawRequests.append("GET /tests/R1.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("\r\n");
rawRequests.append("GET /tests/R1.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("Connection: close\r\n");
rawRequests.append("\r\n");
HttpTesting http = new HttpTesting(new HttpSocketImpl(),serverPort);
List<HttpResponseTester> responses = http.requests(rawRequests);
HttpResponseTester response = responses.get(0);
response.assertStatusOK();
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
response = responses.get(1);
response.assertStatusOK();
response.assertBody("Host=Default\nResource=R1\n");
response = responses.get(2);
response.assertStatusOK();
response.assertBody("Host=Default\nResource=R1\n");
}
@Test
public void testGET_HttpTesting() throws Exception
{
HttpRequestTester request = new HttpRequestTester();
request.setMethod("GET");
request.setURI("/tests/alpha.txt");
request.addHeader("Host","localhost");
request.addHeader("Connection","close");
// request.setContent(null);
HttpTesting testing = new HttpTesting(new HttpSocketImpl(),serverPort);
HttpResponseTester response = testing.request(request);
response.assertStatusOK();
response.assertContentType("text/plain");
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
}
private void DEBUG(String msg)
{
if (debug)
{
System.out.println(msg);
}
}
}
| jamiepg1/jetty.project | tests/test-integration/src/test/java/org/eclipse/jetty/test/DefaultHandlerTest.java | Java | apache-2.0 | 5,687 |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.aws.kinesis;
import java.nio.ByteBuffer;
import com.amazonaws.services.kinesis.model.PutRecordRequest;
import com.amazonaws.services.kinesis.model.PutRecordResult;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.support.DefaultProducer;
public class KinesisProducer extends DefaultProducer {
public KinesisProducer(KinesisEndpoint endpoint) {
super(endpoint);
}
@Override
public KinesisEndpoint getEndpoint() {
return (KinesisEndpoint) super.getEndpoint();
}
@Override
public void process(Exchange exchange) throws Exception {
PutRecordRequest request = createRequest(exchange);
PutRecordResult putRecordResult = getEndpoint().getClient().putRecord(request);
Message message = getMessageForResponse(exchange);
message.setHeader(KinesisConstants.SEQUENCE_NUMBER, putRecordResult.getSequenceNumber());
message.setHeader(KinesisConstants.SHARD_ID, putRecordResult.getShardId());
}
private PutRecordRequest createRequest(Exchange exchange) {
ByteBuffer body = exchange.getIn().getBody(ByteBuffer.class);
Object partitionKey = exchange.getIn().getHeader(KinesisConstants.PARTITION_KEY);
Object sequenceNumber = exchange.getIn().getHeader(KinesisConstants.SEQUENCE_NUMBER);
PutRecordRequest putRecordRequest = new PutRecordRequest();
putRecordRequest.setData(body);
putRecordRequest.setStreamName(getEndpoint().getConfiguration().getStreamName());
putRecordRequest.setPartitionKey(partitionKey.toString());
if (sequenceNumber != null) {
putRecordRequest.setSequenceNumberForOrdering(sequenceNumber.toString());
}
return putRecordRequest;
}
public static Message getMessageForResponse(final Exchange exchange) {
return exchange.getMessage();
}
}
| adessaigne/camel | components/camel-aws-kinesis/src/main/java/org/apache/camel/component/aws/kinesis/KinesisProducer.java | Java | apache-2.0 | 2,733 |
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Admin\Logic;
use Think\Model;
/**
* 文档模型逻辑层公共模型
* 所有逻辑层模型都需要继承此模型
*/
class BaseLogic extends Model {
/* 自动验证规则 */
protected $_validate = array();
/* 自动完成规则 */
protected $_auto = array();
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix = C('DB_PREFIX') . 'document_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 获取模型详细信息
* @param integer $id 文档ID
* @return array 当前模型详细信息
*/
public function detail($id) {
if ($this->getDbFields() == false) {
$data = array();
} else {
$data = $this->field(true)->find($id);
if (!$data) {
$this->error = '获取详细信息出错!';
return false;
}
}
return $data;
}
/**
* 新增或添加模型数据
* @param number $id 文章ID
* @return boolean true-操作成功,false-操作失败
*/
public function update($id = 0) {
/* 获取数据 */
$data = $this->create();
if ($data === false) {
return false;
}
if (empty($data['id'])) {//新增数据
$data['id'] = $id;
$id = $this->add($data);
if (!$id) {
$this->error = '新增数据失败!';
return false;
}
} else { //更新数据
$status = $this->save($data);
if (false === $status) {
$this->error = '更新数据失败!';
return false;
}
}
return true;
}
/**
* 模型数据自动保存
* @return boolean
*/
public function autoSave($id = 0) {
$this->_validate = array();
return $this->update($id);
}
/**
* 检测属性的自动验证和自动完成属性
* @return boolean
*/
public function checkModelAttr($model_id){
$fields = get_model_attribute($model_id);
$validate = $auto = array();
foreach($fields as $key=>$attr){
if($attr['is_must']){// 必填字段
$validate[] = array($attr['name'],'require',$attr['title'].'必须!',self::MUST_VALIDATE , 'regex', self::MODEL_BOTH);
}
// 自动验证规则
if(!empty($attr['validate_rule'])) {
$validate[] = array($attr['name'],$attr['validate_rule'],$attr['error_info']?$attr['error_info']:$attr['title'].'验证错误',0,$attr['validate_type'],$attr['validate_time']);
}
// 自动完成规则
if(!empty($attr['auto_rule'])) {
$auto[] = array($attr['name'],$attr['auto_rule'],$attr['auto_time'],$attr['auto_type']);
}elseif('checkbox' == $attr ['type'] || 'dynamic_checkbox' == $attr ['type']){ // 多选型
$auto[] = array($attr['name'],'arr2str',3,'function');
}elseif('datetime' == $attr['type'] || 'date' == $attr['type']){ // 日期型
$auto[] = array($attr['name'],'strtotime',3,'function');
}
}
$validate = array_merge($validate,$this->_validate);
$auto = array_merge($auto,$this->_auto);
return $this->validate($validate)->auto($auto);
}
}
| lovebull/wild_weiphp | Application/Admin/Logic/BaseLogic.class.php | PHP | apache-2.0 | 4,249 |
/*
* 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 org.unitime.timetable.model.dao;
import org.unitime.timetable.model.base.BaseDistributionTypeDAO;
/**
* @author Tomas Muller
*/
public class DistributionTypeDAO extends BaseDistributionTypeDAO {
/**
* Default constructor. Can be used in place of getInstance()
*/
public DistributionTypeDAO () {}
}
| rafati/unitime | JavaSource/org/unitime/timetable/model/dao/DistributionTypeDAO.java | Java | apache-2.0 | 1,126 |
/*
* Copyright (C) 2012 - 2012 NHN Corporation
* All rights reserved.
*
* This file is part of The nGrinder software distribution. Refer to
* the file LICENSE which is part of The nGrinder distribution for
* licensing details. The nGrinder distribution is available on the
* Internet at http://nhnopensource.org/ngrinder
*
* 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 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.grinder.scriptengine.groovy;
import static net.grinder.script.Grinder.grinder;
import net.grinder.plugin.http.HTTPRequest;
import net.grinder.script.GTest;
import net.grinder.script.InvalidContextException;
import net.grinder.script.NonInstrumentableTypeException;
import net.grinder.scriptengine.groovy.junit.GrinderRunner;
import net.grinder.scriptengine.groovy.junit.annotation.AfterProcess;
import net.grinder.scriptengine.groovy.junit.annotation.AfterThread;
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread;
import net.grinder.scriptengine.groovy.junit.annotation.Repeat;
import net.grinder.scriptengine.groovy.junit.annotation.RunRate;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import HTTPClient.HTTPResponse;
/**
* Grinder Runner Test
*
* @author Mavlarn
* @author JunHo Yoon
* @since 3.2
*/
public class GrinderRunnerTest {
private static final Logger LOGGER = LoggerFactory.getLogger(GrinderRunnerTest.class);
@Test
public void testThreadInitialization() throws Throwable {
GrinderRunner runner = new GrinderRunner(TestSample.class);
LOGGER.debug("start the test function...");
runner.run(new RunNotifier() {
@Override
public void fireTestFailure(Failure failure) {
throw new RuntimeException(failure.getException());
}
});
}
@RunWith(GrinderRunner.class)
@Repeat(100)
public static class TestSample {
private static HTTPRequest request = null;
private static GTest test = new GTest(1, "Hello");
@BeforeClass
public static void beforeProcess() {
request = new HTTPRequest();
try {
test.record(request);
} catch (NonInstrumentableTypeException e) {
}
}
@BeforeThread
public void beforeThread() throws InvalidContextException {
grinder.getStatistics().setDelayReports(true);
}
@RunRate(50)
@Test
public void doTest() throws Exception {
HTTPResponse result = request.GET("http://www.naver.com");
if (result.getStatusCode() != 200) {
grinder.getStatistics().getForLastTest().setSuccess(false);
} else {
grinder.getStatistics().getForLastTest().setSuccess(true);
}
}
@Test
@RunRate(10)
public void doTest2() throws Exception {
grinder.getStatistics().setDelayReports(true);
HTTPResponse result = request.GET("http://www.google.co.kr");
if (result.getStatusCode() != 200) {
grinder.getStatistics().getForLastTest().setSuccess(false);
} else {
grinder.getStatistics().getForLastTest().setSuccess(true);
}
}
@AfterThread
public void doAfter() {
}
@AfterProcess
public static void afterProcess() {
}
}
}
| nanpa83/ngrinder | ngrinder-groovy/src/test/java/net/grinder/scriptengine/groovy/GrinderRunnerTest.java | Java | apache-2.0 | 4,040 |
/**
* Copyright (C) 2015 DataTorrent, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datatorrent.stram.util;
import java.io.Closeable;
import java.io.IOException;
import java.util.EnumSet;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.permission.FsPermission;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>FSJsonLineFile class.</p>
*
* @since 1.0.2
*/
public class FSJsonLineFile implements Closeable
{
private final ObjectMapper objectMapper;
private final FSDataOutputStream os;
private static final Logger LOG = LoggerFactory.getLogger(FSJsonLineFile.class);
public FSJsonLineFile(FileContext fileContext, Path path, FsPermission permission) throws IOException
{
this.os = fileContext.create(path, EnumSet.of(CreateFlag.CREATE, CreateFlag.APPEND), Options.CreateOpts.perms(permission));
this.objectMapper = (new JSONSerializationProvider()).getContext(null);
}
public synchronized void append(JSONObject json) throws IOException
{
os.writeBytes(json.toString() + "\n");
os.hflush();
}
public synchronized void append(Object obj) throws IOException
{
os.writeBytes(objectMapper.writeValueAsString(obj) + "\n");
os.hflush();
}
@Override
public void close() throws IOException
{
os.close();
}
}
| andyperlitch/incubator-apex-core | engine/src/main/java/com/datatorrent/stram/util/FSJsonLineFile.java | Java | apache-2.0 | 1,929 |
/*
* Copyright 2014 Ruediger Moeller.
*
* 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.nustaq.serialization.coders;
import java.io.*;
import org.nustaq.offheap.bytez.*;
import org.nustaq.offheap.bytez.onheap.*;
import org.nustaq.serialization.*;
import org.nustaq.serialization.util.*;
/**
* Created by ruedi on 09.11.2014.
*
* uses unsafe to read values directly from memory instead an inputstream. no value compression is applied.
*
*/
public class FSTBytezDecoder implements FSTDecoder {
BasicBytez input;
HeapBytez ascStringCache;
FSTConfiguration conf;
public FSTClazzNameRegistry clnames;
long pos;
InputStream inputStream;
long readUntil = 0;
public FSTBytezDecoder(FSTConfiguration conf, BasicBytez input) {
this(conf);
if ( FSTConfiguration.isAndroid )
throw new RuntimeException("not supported on android");
this.input = input;
}
@Override
public void setConf(FSTConfiguration conf) {
this.conf = conf;
}
public FSTBytezDecoder(FSTConfiguration conf) {
this.conf = conf;
clnames = (FSTClazzNameRegistry) conf.getCachedObject(FSTClazzNameRegistry.class);
if (clnames == null) {
clnames = new FSTClazzNameRegistry(conf.getClassRegistry());
} else {
clnames.clear();
}
}
byte tmp[];
public int ensureReadAhead(int bytes) {
if ( inputStream != null ) {
if ( pos+bytes > readUntil ) {
return readNextInputChunk(bytes);
}
} else if ( pos+bytes > input.length() ) {
return -1;
}
return 0;
}
protected int readNextInputChunk(int bytes) {
try {
int toRead = Math.min(Integer.MAX_VALUE - 5, bytes);
if ( inputStream instanceof ByteArrayInputStream ) {
toRead = Math.min(((ByteArrayInputStream) inputStream).available(),toRead);
}
if ( tmp == null || tmp.length < toRead ) {
tmp = new byte[toRead];
}
int read = inputStream.read(tmp, 0, toRead);
if ( read > 0 ) {
if ( input.length() < pos+read ) {
BasicBytez bytez = input.newInstance(2*(pos + read));
input.copyTo(bytez,0,0,pos);
input = (HeapBytez) bytez;
}
input.set(pos,tmp,0,read);
readUntil = pos+read;
return read;
} else if ( read == -1 )
return -1;
// fixme: should loop in case read == 0
} catch (IOException e) {
FSTUtil.<RuntimeException>rethrow(e);
}
return 0;
}
char chBufS[];
char[] getCharBuf(int siz) {
char chars[] = chBufS;
if (chars == null || chars.length < siz) {
chars = new char[Math.max(siz, 15)];
chBufS = chars;
}
return chars;
}
public String readStringUTF() throws IOException {
int len = readFInt();
char[] charBuf = getCharBuf(len * 2);
ensureReadAhead(len*2);
input.getCharArr(pos,charBuf,0,len);
pos += len*2;
return new String(charBuf, 0, len);
}
public byte readObjectHeaderTag() throws IOException {
return readFByte();
}
/**
* len < 127 !!!!!
*
* @return
* @throws java.io.IOException
*/
@Override
public String readStringAsc() throws IOException {
int len = readFInt();
if (ascStringCache == null || ascStringCache.length() < len)
ascStringCache = new HeapBytez(new byte[len]);
ensureReadAhead(len);
// System.arraycopy(input.buf, input.pos, ascStringCache, 0, len);
input.copyTo(ascStringCache, 0, pos, len);
pos += len;
return new String(ascStringCache.getBase(), 0, 0, len);
}
public BasicBytez getInput() {
return input;
}
public void setInput(BasicBytez input) {
this.input = input;
}
/**
* assumes class header+len already read
*
* @param componentType
* @param len
* @return
*/
@Override
public Object readFPrimitiveArray(Object array, Class componentType, int len) {
// FIXME: if else chaining could be avoided
if (componentType == byte.class) {
ensureReadAhead(len);
byte arr[] = (byte[]) array;
input.getArr(pos, arr, 0, len);
pos += len;
return arr;
} else if (componentType == char.class) {
ensureReadAhead(len*2);
char[] arr = (char[]) array;
input.getCharArr(pos, arr, 0, len);
pos += len * 2;
return arr;
} else if (componentType == short.class) {
ensureReadAhead(len*2);
short[] arr = (short[]) array;
input.getShortArr(pos, arr, 0, len);
pos += len * 2;
return arr;
} else if (componentType == int.class) {
ensureReadAhead(len*4);
int[] arr = (int[]) array;
input.getIntArr(pos, arr, 0, len);
pos += len * 4;
return arr;
} else if (componentType == float.class) {
ensureReadAhead(len*4);
float[] arr = (float[]) array;
input.getFloatArr(pos, arr, 0, len);
pos += len * 4;
return arr;
} else if (componentType == double.class) {
ensureReadAhead(len*8);
double[] arr = (double[]) array;
input.getDoubleArr(pos, arr, 0, len);
pos += len * 8;
return arr;
} else if (componentType == long.class) {
ensureReadAhead(len*8);
long[] arr = (long[]) array;
input.getLongArr(pos, arr, 0, len);
pos += len * 8;
return arr;
} else if (componentType == boolean.class) {
ensureReadAhead(len);
boolean[] arr = (boolean[]) array;
input.getBooleanArr(pos, arr, 0, len);
pos += len;
return arr;
} else {
throw new RuntimeException("unexpected primitive type " + componentType.getName());
}
}
@Override
public void readFIntArr(int len, int[] arr) throws IOException {
input.getIntArr(pos, arr, 0, len);
pos += len * 4;
}
@Override
public int readFInt() throws IOException {
return readPlainInt();
}
@Override
public double readFDouble() throws IOException {
return Double.longBitsToDouble(readPlainLong());
}
/**
* Reads a 4 byte float.
*/
@Override
public float readFFloat() throws IOException {
return Float.intBitsToFloat(readPlainInt());
}
@Override
public final byte readFByte() throws IOException {
ensureReadAhead(1);
return input.get(pos++);
}
@Override
public int readIntByte() throws IOException {
final int res = ensureReadAhead(1);
if ( res == -1 )
return -1;
return input.get(pos++) & 0xff;
}
@Override
public long readFLong() throws IOException {
return readPlainLong();
}
@Override
public char readFChar() throws IOException {
return readPlainChar();
}
@Override
public short readFShort() throws IOException {
return readPlainShort();
}
private char readPlainChar() throws IOException {
ensureReadAhead(2);
char res = input.getChar(pos);
pos += 2;
return res;
}
private short readPlainShort() throws IOException {
ensureReadAhead(2);
short res = input.getShort(pos);
pos += 2;
return res;
}
@Override
public int readPlainInt() throws IOException {
ensureReadAhead(4);
int res = input.getInt(pos);
pos += 4;
return res;
}
private long readPlainLong() throws IOException {
ensureReadAhead(8);
long res = input.getLong(pos);
pos += 8;
return res;
}
@Override
public byte[] getBuffer() {
if ( input instanceof HeapBytez && ((HeapBytez) input).getOffsetIndex() == 0 ) {
return ((HeapBytez) input).asByteArray();
}
byte res[] = new byte[(int) pos];
input.getArr(0,res,0, (int) pos);
return res;
}
@Override
public int getInputPos() {
return (int) pos;
}
@Override
public void moveTo(int position) {
pos = position;
}
@Override
public void reset() {
pos = 0;
clnames.clear();
inputStream = null;
}
@Override
public void setInputStream(InputStream in) {
if ( in == FSTObjectInput.emptyStream ) {
inputStream = null;
readUntil = 0;
return;
}
this.inputStream = in;
clnames.clear();
pos = 0;
if ( input == null )
input = new HeapBytez(new byte[4096]);
readUntil = 0;
}
@Override
public void resetToCopyOf(byte[] bytes, int off, int len) {
inputStream = null;
if ( input == null ) {
byte[] base = new byte[len];
input = new HeapBytez(base,0,len);
}
if ( input.length() < len )
{
input = (HeapBytez) input.newInstance(len);
}
input.set(0, bytes, off, len);
pos = 0;
clnames.clear();
}
@Override
public void resetWith(byte[] bytes, int len) {
inputStream = null;
if ( input == null ) {
input = new HeapBytez(bytes,0,len);
return;
}
// suboptimal method for non heap backing
if ( input.getClass() == HeapBytez.class ) {
((HeapBytez)input).setBase(bytes,0,len);
} else {
BasicBytez newBytez = input.newInstance(len);
newBytez.set(0,bytes,0,len);
}
pos = 0;
clnames.clear();
}
@Override
public FSTClazzInfo readClass() throws IOException, ClassNotFoundException {
return clnames.decodeClass(this,conf);
}
@Override
public Class classForName(String name) throws ClassNotFoundException {
return clnames.classForName(name,conf);
}
@Override
public void registerClass(Class possible) {
clnames.registerClass(possible,conf);
}
@Override
public void close() {
conf.returnObject(clnames);
}
@Override
public void skip(int n) {
pos += n;
}
@Override
public void readPlainBytes(byte[] b, int off, int len) {
ensureReadAhead(len);
// System.arraycopy(input.buf,input.pos,b,off,len);
input.getArr(pos, b, off, len);
pos += len;
}
@Override
public boolean isMapBased() {
return false;
}
@Override
public Object getDirectObject() // in case class already resolves to read object (e.g. mix input)
{
return null;
}
@Override
public int getObjectHeaderLen() {
return -1;
}
@Override
public void consumeEndMarker() {
}
@Override
public Class readArrayHeader() throws Exception {
return readClass().getClazz();
}
@Override
public void readExternalEnd() {
// do nothing for direct encoding
}
@Override
public boolean isEndMarker(String s) {
return false;
}
@Override
public int readVersionTag() throws IOException {
return readFByte();
}
@Override
public void pushBack(int bytes) {
pos -= bytes;
}
@Override
public void readArrayEnd(FSTClazzInfo clzSerInfo) {}
@Override
public void readObjectEnd() {}
@Override
public Object coerceElement(Class arrType, Object value) {
return value;
}
@Override
public int available() {
return (int) (input.length()-pos);
}
@Override
public boolean inArray() {
return false;
}
@Override
public void startFieldReading(Object newObj) {
}
}
| jtsay362/fast-serialization | src/main/java/org/nustaq/serialization/coders/FSTBytezDecoder.java | Java | apache-2.0 | 12,766 |
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_CHROMEOS_H_
#define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_CHROMEOS_H_
#include <map>
#include <string>
#include <vector>
#include "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h"
#include "chrome/common/extensions/api/input_ime/input_components_handler.h"
#include "extensions/browser/extension_function.h"
namespace chromeos {
class InputMethodEngine;
} // namespace chromeos
namespace extensions {
class InputImeClearCompositionFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.clearComposition",
INPUT_IME_CLEARCOMPOSITION)
protected:
~InputImeClearCompositionFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeSetCandidateWindowPropertiesFunction
: public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.setCandidateWindowProperties",
INPUT_IME_SETCANDIDATEWINDOWPROPERTIES)
protected:
~InputImeSetCandidateWindowPropertiesFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeSetCandidatesFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.setCandidates", INPUT_IME_SETCANDIDATES)
protected:
~InputImeSetCandidatesFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeSetCursorPositionFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.setCursorPosition",
INPUT_IME_SETCURSORPOSITION)
protected:
~InputImeSetCursorPositionFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeSetMenuItemsFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.setMenuItems", INPUT_IME_SETMENUITEMS)
protected:
~InputImeSetMenuItemsFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeUpdateMenuItemsFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.updateMenuItems",
INPUT_IME_UPDATEMENUITEMS)
protected:
~InputImeUpdateMenuItemsFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeDeleteSurroundingTextFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.deleteSurroundingText",
INPUT_IME_DELETESURROUNDINGTEXT)
protected:
~InputImeDeleteSurroundingTextFunction() override {}
// ExtensionFunction:
ResponseAction Run() override;
};
class InputImeHideInputViewFunction : public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.hideInputView",
INPUT_IME_HIDEINPUTVIEW)
protected:
~InputImeHideInputViewFunction() override {}
// ExtensionFunction:
bool RunAsync() override;
};
class InputMethodPrivateNotifyImeMenuItemActivatedFunction
: public UIThreadExtensionFunction {
public:
InputMethodPrivateNotifyImeMenuItemActivatedFunction() {}
protected:
~InputMethodPrivateNotifyImeMenuItemActivatedFunction() override {}
// UIThreadExtensionFunction:
ResponseAction Run() override;
private:
DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.notifyImeMenuItemActivated",
INPUTMETHODPRIVATE_NOTIFYIMEMENUITEMACTIVATED)
DISALLOW_COPY_AND_ASSIGN(
InputMethodPrivateNotifyImeMenuItemActivatedFunction);
};
class InputImeEventRouter : public InputImeEventRouterBase {
public:
explicit InputImeEventRouter(Profile* profile);
~InputImeEventRouter() override;
bool RegisterImeExtension(
const std::string& extension_id,
const std::vector<extensions::InputComponentInfo>& input_components);
void UnregisterAllImes(const std::string& extension_id);
chromeos::InputMethodEngine* GetEngine(const std::string& extension_id,
const std::string& component_id);
input_method::InputMethodEngineBase* GetActiveEngine(
const std::string& extension_id) override;
private:
// The engine map from extension_id to an engine.
std::map<std::string, chromeos::InputMethodEngine*> engine_map_;
DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_CHROMEOS_H_
| ssaroha/node-webrtc | third_party/webrtc/include/chromium/src/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h | C | bsd-2-clause | 4,727 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
#define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
#include <Cocoa/Cocoa.h>
#include <memory>
class FullscreenObserver;
namespace content {
class WebContents;
}
// A class that controls the WebContents view. It internally creates a container
// view (the NSView accessed by calling |-view|) which manages the layout and
// display of the WebContents view.
//
// Client code that inserts [controller view] into the view hierarchy needs to
// call -ensureContentsVisibleInSuperview:(NSView*)superview to match the
// container to the [superview bounds] and avoid multiple resize messages being
// sent to the renderer, which triggers redundant and costly layouts.
//
// AutoEmbedFullscreen mode: When enabled, TabContentsController will observe
// for WebContents fullscreen changes and automatically swap the normal
// WebContents view with the fullscreen view (if different). In addition, if a
// WebContents is being screen-captured, the view will be centered within the
// container view, sized to the aspect ratio of the capture video resolution,
// and scaling will be avoided whenever possible.
@interface TabContentsController : NSViewController {
@private
content::WebContents* contents_; // weak
// When |fullscreenObserver_| is not-NULL, TabContentsController monitors for
// and auto-embeds fullscreen widgets as a subview.
std::unique_ptr<FullscreenObserver> fullscreenObserver_;
// Set to true while TabContentsController is embedding a fullscreen widget
// view as a subview instead of the normal WebContentsView render view.
// Note: This will be false in the case of non-Flash fullscreen.
BOOL isEmbeddingFullscreenWidget_;
// Set to true if the window is a popup.
BOOL isPopup_;
}
@property(readonly, nonatomic) content::WebContents* webContents;
// This flag is set to true when we don't want the fullscreen widget to
// resize. This is done so that we can avoid resizing the fullscreen widget
// to intermediate sizes during the fullscreen transition.
// As a result, we would prevent janky movements during the transition and
// Pepper Fullscreen from blowing up.
@property(assign, nonatomic) BOOL blockFullscreenResize;
// Create the contents of a tab represented by |contents|.
- (id)initWithContents:(content::WebContents*)contents isPopup:(BOOL)popup;
// Call to insert the container view into the view hierarchy, sizing it to match
// |superview|. Then, this method will select either the WebContents view or
// the fullscreen view and swap it into the container for display.
- (void)ensureContentsVisibleInSuperview:(NSView*)superview;
// Called after we enter fullscreen to ensure that the fullscreen widget will
// have the right frame.
- (void)updateFullscreenWidgetFrame;
// Call to change the underlying web contents object. View is not changed,
// call |-ensureContentsVisible| to display the |newContents|'s render widget
// host view.
- (void)changeWebContents:(content::WebContents*)newContents;
// Called when the tab contents is the currently selected tab and is about to be
// removed from the view hierarchy.
- (void)willBecomeUnselectedTab;
// Called when the tab contents is about to be put into the view hierarchy as
// the selected tab. Handles things such as ensuring the toolbar is correctly
// enabled.
- (void)willBecomeSelectedTab;
// Called when the tab contents is updated in some non-descript way (the
// notification from the model isn't specific). |updatedContents| could reflect
// an entirely new tab contents object.
- (void)tabDidChange:(content::WebContents*)updatedContents;
// Called to switch the container's subview to the WebContents-owned fullscreen
// widget or back to WebContentsView's widget.
- (void)toggleFullscreenWidget:(BOOL)enterFullscreen;
@end
#endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_TAB_CONTENTS_CONTROLLER_H_
| ssaroha/node-webrtc | third_party/webrtc/include/chromium/src/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h | C | bsd-2-clause | 4,106 |
/*
* Copyright 2014, General Dynamics C4 Systems
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
*/
#include <types.h>
#include <machine/io.h>
#include <kernel/vspace.h>
#include <arch/machine.h>
#include <arch/kernel/vspace.h>
#include <plat/machine.h>
#include <arch/linker.h>
#include <plat/machine/devices.h>
#include <plat/machine/hardware.h>
/* Available physical memory regions on platform (RAM) */
/* NOTE: Regions are not allowed to be adjacent! */
const p_region_t BOOT_RODATA avail_p_regs[] = {
/* 1 GiB */
{ /* .start = */ 0x00000000, /* .end = */ 0x40000000 }
};
BOOT_CODE int
get_num_avail_p_regs(void)
{
return sizeof(avail_p_regs) / sizeof(p_region_t);
}
BOOT_CODE p_region_t
get_avail_p_reg(unsigned int i)
{
return avail_p_regs[i];
}
const p_region_t BOOT_RODATA dev_p_regs[] = {
{ /* .start = */ UART0_PADDR , /* .end = */ UART0_PADDR + ( 1 << 12)},
{ /* .start = */ UART1_PADDR , /* .end = */ UART1_PADDR + ( 1 << 12)},
{ /* .start = */ USB0_PADDR , /* .end = */ USB0_PADDR + ( 1 << 12)},
{ /* .start = */ USB1_PADDR , /* .end = */ USB1_PADDR + ( 1 << 12)},
{ /* .start = */ I2C0_PADDR , /* .end = */ I2C0_PADDR + ( 1 << 12)},
{ /* .start = */ I2C1_PADDR , /* .end = */ I2C1_PADDR + ( 1 << 12)},
{ /* .start = */ SPI0_PADDR , /* .end = */ SPI0_PADDR + ( 1 << 12)},
{ /* .start = */ SPI1_PADDR , /* .end = */ SPI1_PADDR + ( 1 << 12)},
{ /* .start = */ CAN0_PADDR , /* .end = */ CAN0_PADDR + ( 1 << 12)},
{ /* .start = */ CAN1_PADDR , /* .end = */ CAN1_PADDR + ( 1 << 12)},
{ /* .start = */ GPIO_PADDR , /* .end = */ GPIO_PADDR + ( 1 << 12)},
{ /* .start = */ ETH0_PADDR , /* .end = */ ETH0_PADDR + ( 1 << 12)},
{ /* .start = */ ETH1_PADDR , /* .end = */ ETH1_PADDR + ( 1 << 12)},
{ /* .start = */ QSPI_PADDR , /* .end = */ QSPI_PADDR + ( 1 << 12)},
{ /* .start = */ SMC_PADDR , /* .end = */ SMC_PADDR + ( 1 << 12)},
{ /* .start = */ SDIO0_PADDR , /* .end = */ SDIO0_PADDR + ( 1 << 12)},
{ /* .start = */ SDIO1_PADDR , /* .end = */ SDIO1_PADDR + ( 1 << 12)},
{ /* .start = */ SMC_NAND_PADDR , /* .end = */ SMC_NAND_PADDR + (16 << 20)},
{ /* .start = */ SMC_NOR0_PADDR , /* .end = */ SMC_NOR0_PADDR + (32 << 20)},
{ /* .start = */ SMC_NOR1_PADDR , /* .end = */ SMC_NOR1_PADDR + (32 << 20)},
{ /* .start = */ SMC_SLCR_PADDR , /* .end = */ SMC_SLCR_PADDR + ( 1 << 12)},
{ /* .start = */ TRPL_TIMER0_PADDR , /* .end = */ TRPL_TIMER0_PADDR + ( 1 << 12)},
{ /* .start = */ TRPL_TIMER1_PADDR , /* .end = */ TRPL_TIMER1_PADDR + ( 1 << 12)},
{ /* .start = */ DMAC_S_PADDR , /* .end = */ DMAC_S_PADDR + ( 1 << 12)},
{ /* .start = */ DMAC_NS_PADDR , /* .end = */ DMAC_NS_PADDR + ( 1 << 12)},
{ /* .start = */ SWDT_PADDR , /* .end = */ SWDT_PADDR + ( 1 << 12)},
{ /* .start = */ DDRC_PADDR , /* .end = */ DDRC_PADDR + ( 1 << 12)},
{ /* .start = */ DEVCFG_PADDR , /* .end = */ DEVCFG_PADDR + ( 1 << 12)},
{ /* .start = */ AXI_HP0_PADDR , /* .end = */ AXI_HP0_PADDR + ( 1 << 12)},
{ /* .start = */ AXI_HP1_PADDR , /* .end = */ AXI_HP1_PADDR + ( 1 << 12)},
{ /* .start = */ AXI_HP2_PADDR , /* .end = */ AXI_HP2_PADDR + ( 1 << 12)},
{ /* .start = */ AXI_HP3_PADDR , /* .end = */ AXI_HP3_PADDR + ( 1 << 12)},
{ /* .start = */ OCM_PADDR , /* .end = */ OCM_PADDR + ( 1 << 12)},
{ /* .start = */ EFUSE_PADDR , /* .end = */ EFUSE_PADDR + ( 2 << 12)},
{ /* .start = */ DEBUG_DAP_ROM_PADDR , /* .end = */ DEBUG_DAP_ROM_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_ETB_PADDR , /* .end = */ DEBUG_ETB_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CTI_ETB_TPIU_PADDR, /* .end = */ DEBUG_CTI_ETB_TPIU_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_TPIU_PADDR , /* .end = */ DEBUG_TPIU_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_FUNNEL_PADDR , /* .end = */ DEBUG_FUNNEL_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_ITM_PADDR , /* .end = */ DEBUG_ITM_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CTI_FTM_PADDR , /* .end = */ DEBUG_CTI_FTM_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_FTM_PADDR , /* .end = */ DEBUG_FTM_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_PMU0_PADDR , /* .end = */ DEBUG_CPU_PMU0_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_PMU1_PADDR , /* .end = */ DEBUG_CPU_PMU1_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_CTI0_PADDR , /* .end = */ DEBUG_CPU_CTI0_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_CTI1_PADDR , /* .end = */ DEBUG_CPU_CTI1_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_PTM0_PADDR , /* .end = */ DEBUG_CPU_PTM0_PADDR + ( 1 << 12)},
{ /* .start = */ DEBUG_CPU_PTM1_PADDR , /* .end = */ DEBUG_CPU_PTM1_PADDR + ( 1 << 12)},
{ /* .start = */ GPV_TRUSTZONE_PADDR , /* .end = */ GPV_TRUSTZONE_PADDR + ( 1 << 12)},
{ /* .start = */ GPV_QOS301_CPU_PADDR , /* .end = */ GPV_QOS301_CPU_PADDR + ( 1 << 12)},
{ /* .start = */ GPV_QOS301_DMAC_PADDR , /* .end = */ GPV_QOS301_DMAC_PADDR + ( 1 << 12)},
{ /* .start = */ GPV_QOS301_IOU_PADDR , /* .end = */ GPV_QOS301_IOU_PADDR + ( 1 << 12)},
// { /* .start = */ MPCORE_PRIV_PADDR , /* .end = */ MPCORE_PRIV_PADDR + ( 1 << 12)},
// { /* .start = */ GIC_DIST_PADDR , /* .end = */ GIC_DIST_PADDR + ( 1 << 12)},
// { /* .start = */ L2CC_PL310_PADDR , /* .end = */ L2CC_PL310_PADDR + ( 1 << 12)},
{ /* .start = */ QSPI_LINEAR_PADDR , /* .end = */ QSPI_LINEAR_PADDR + (32 << 20)},
{ /* .start = */ OCM_HIGH_PADDR , /* .end = */ OCM_HIGH_PADDR + (64 << 12)},
/* Programmable logic */
{ /* .start = */ PL_M_AXI_GP0_PADDR, /* .end = */ PL_M_AXI_GP0_PADDR + 0x40000000U},
{ /* .start = */ PL_M_AXI_GP1_PADDR, /* .end = */ PL_M_AXI_GP1_PADDR + 0x40000000U},
};
BOOT_CODE int
get_num_dev_p_regs(void)
{
return sizeof(dev_p_regs) / sizeof(p_region_t);
}
BOOT_CODE p_region_t
get_dev_p_reg(unsigned int i)
{
return dev_p_regs[i];
}
/* Determine if the given IRQ should be reserved by the kernel. */
bool_t CONST
isReservedIRQ(irq_t irq)
{
return irq == KERNEL_TIMER_IRQ;
}
/* Handle a platform-reserved IRQ. */
void
handleReservedIRQ(irq_t irq)
{
printf("Received reserved IRQ: %d\n", (int)irq);
}
BOOT_CODE void
map_kernel_devices(void)
{
/* map kernel device: GIC controller and private timers */
map_kernel_frame(
MPCORE_PRIV_PADDR,
ARM_MP_PPTR1,
VMKernelOnly,
vm_attributes_new(
true, /* armExecuteNever */
false, /* armParityEnabled */
false /* armPageCacheable */
)
);
/* map kernel device: GIC distributor */
map_kernel_frame(
MPCORE_PRIV_PADDR + BIT(PAGE_BITS),
ARM_MP_PPTR2,
VMKernelOnly,
vm_attributes_new(
true, /* armExecuteNever */
false, /* armParityEnabled */
false /* armPageCacheable */
)
);
/* map kernel device: L2CC */
map_kernel_frame(
L2CC_PL310_PADDR,
L2CC_PL310_PPTR,
VMKernelOnly,
vm_attributes_new(
true, /* armExecuteNever */
false, /* armParityEnabled */
false /* armPageCacheable */
)
);
#if defined(DEBUG)
/* map kernel device: UART */
map_kernel_frame(
UART_PADDR,
UART_PPTR,
VMKernelOnly,
vm_attributes_new(
true, /* armExecuteNever */
false, /* armParityEnabled */
false /* armPageCacheable */
)
);
#endif /* DEBUG */
}
| sigma-random/seL4 | src/plat/zynq7000/machine/hardware.c | C | bsd-2-clause | 8,701 |
# Copyright 2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
module CommandT
class Scanner
class FileScanner
# Uses git ls-files to scan for files
class GitFileScanner < FindFileScanner
LsFilesError = Class.new(::RuntimeError)
def paths!
Dir.chdir(@path) do
all_files = list_files(%w[git ls-files --exclude-standard -z])
if @scan_submodules
base = nil
list_files(%w[
git submodule foreach --recursive
git ls-files --exclude-standard -z
]).each do |path|
if path =~ /\AEntering '(.*)'\n(.*)\z/
base = $~[1]
path = $~[2]
end
all_files.push(base + File::SEPARATOR + path)
end
end
all_files.
map { |path| path.chomp }.
reject { |path| path_excluded?(path, 0) }.
take(@max_files).
to_a
end
rescue LsFilesError
super
rescue Errno::ENOENT
# git executable not present and executable
super
end
private
def list_files(command)
stdin, stdout, stderr = Open3.popen3(*command)
stdout.read.split("\0")
ensure
raise LsFilesError if stderr && stderr.gets
end
end # class GitFileScanner
end # class FileScanner
end # class Scanner
end # module CommandT
| vrkansagara/command-t | ruby/command-t/scanner/file_scanner/git_file_scanner.rb | Ruby | bsd-2-clause | 1,547 |
cask 'find-empty-folders' do
version '1.1'
sha256 '6eea5c0cde96b1d2297ccbd9c98391f6c76ef2076654871faf5e27030ca1e293'
url 'http://files.tempel.org/FindEmptyFolders/FindEmptyFolders.zip'
name 'Find Empty Folders'
homepage 'http://www.tempel.org/FindEmptyFolders'
license :gratis
app 'Find Empty Folders.app'
depends_on :macos => '>= :snow_leopard'
end
| mgryszko/homebrew-cask | Casks/find-empty-folders.rb | Ruby | bsd-2-clause | 369 |
// Copyright 2016 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 PRINTING_BACKEND_CUPS_PRINTER_H_
#define PRINTING_BACKEND_CUPS_PRINTER_H_
#include <cups/cups.h>
#include <memory>
#include <string>
#include <vector>
#include "printing/backend/cups_deleters.h"
#include "printing/printing_export.h"
#include "url/gurl.h"
namespace base {
class FilePath;
}
namespace printing {
struct PrinterBasicInfo;
// Provides information regarding cups options.
class PRINTING_EXPORT CupsOptionProvider {
public:
virtual ~CupsOptionProvider() = default;
// Returns the supported ipp attributes for the given |option_name|.
// ipp_attribute_t* is owned by CupsOptionProvider.
virtual ipp_attribute_t* GetSupportedOptionValues(
base::StringPiece option_name) const = 0;
// Returns supported attribute values for |option_name| where the value can be
// convered to a string.
virtual std::vector<base::StringPiece> GetSupportedOptionValueStrings(
base::StringPiece option_name) const = 0;
// Returns the default ipp attributes for the given |option_name|.
// ipp_attribute_t* is owned by CupsOptionProvider.
virtual ipp_attribute_t* GetDefaultOptionValue(
base::StringPiece option_name) const = 0;
// Returns true if the |value| is supported by option |name|.
virtual bool CheckOptionSupported(base::StringPiece name,
base::StringPiece value) const = 0;
};
// Represents a CUPS printer.
// Retrieves information from CUPS printer objects as requested. This class
// is only valid as long as the CupsConnection which created it exists as they
// share an http connection which the CupsConnection closes on destruction.
class PRINTING_EXPORT CupsPrinter : public CupsOptionProvider {
public:
// Create a printer with a connection defined by |http| and |dest|. |info|
// can be null and will be lazily initialized when needed.
CupsPrinter(http_t* http,
std::unique_ptr<cups_dest_t, DestinationDeleter> dest,
std::unique_ptr<cups_dinfo_t, DestInfoDeleter> info);
CupsPrinter(CupsPrinter&& printer);
~CupsPrinter() override;
// Returns true if this is the default printer
bool is_default() const;
// CupsOptionProvider
ipp_attribute_t* GetSupportedOptionValues(
base::StringPiece option_name) const override;
std::vector<base::StringPiece> GetSupportedOptionValueStrings(
base::StringPiece option_name) const override;
ipp_attribute_t* GetDefaultOptionValue(
base::StringPiece option_name) const override;
bool CheckOptionSupported(base::StringPiece name,
base::StringPiece value) const override;
// Returns the file name for the PPD retrieved from the print server.
base::FilePath GetPPD() const;
// Returns the name of the printer as configured in CUPS
std::string GetName() const;
std::string GetMakeAndModel() const;
// Returns true if the printer is currently reachable and working.
bool IsAvailable() const;
// Populates |basic_info| with the relevant information about the printer
bool ToPrinterInfo(PrinterBasicInfo* basic_info) const;
// Start a print job. Writes the id of the started job to |job_id|. |job_id|
// is 0 if there is an error. Check availability before using this operation.
// Usage on an unavailable printer is undefined.
ipp_status_t CreateJob(int* job_id,
base::StringPiece job_title,
const std::vector<cups_option_t>& options);
// Add a document to a print job. |job_id| must be non-zero and refer to a
// job started with CreateJob. |document_name| will be displayed in print
// status. |last_doc| should be true if this is the last document for this
// print job. |options| should be IPP key value pairs for the Send-Document
// operation.
bool StartDocument(int job_id,
base::StringPiece document_name,
bool last_doc,
const std::vector<cups_option_t>& options);
// Add data to the current document started by StartDocument. Calling this
// without a started document will fail.
bool StreamData(const std::vector<char>& buffer);
// Finish the current document. Another document can be added or the job can
// be closed to complete printing.
bool FinishDocument();
// Close the job. If the job is not closed, the documents will not be
// printed. |job_id| should match the id from CreateJob.
ipp_status_t CloseJob(int job_id);
private:
// Lazily initialize dest info as it can require a network call
bool InitializeDestInfo() const;
// http connection owned by the CupsConnection which created this object
http_t* const cups_http_;
// information to identify a printer
std::unique_ptr<cups_dest_t, DestinationDeleter> destination_;
// opaque object containing printer attributes and options
mutable std::unique_ptr<cups_dinfo_t, DestInfoDeleter> dest_info_;
DISALLOW_COPY_AND_ASSIGN(CupsPrinter);
};
} // namespace printing
#endif // PRINTING_BACKEND_CUPS_PRINTER_H_
| ssaroha/node-webrtc | third_party/webrtc/include/chromium/src/printing/backend/cups_printer.h | C | bsd-2-clause | 5,198 |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_SDCH_SDCH_OWNER_H_
#define NET_SDCH_SDCH_OWNER_H_
#include <stddef.h>
#include <stdint.h>
#include <map>
#include <string>
#include "base/macros.h"
#include "base/memory/memory_coordinator_client.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/ref_counted.h"
#include "net/base/net_export.h"
#include "net/base/sdch_observer.h"
#include "net/url_request/sdch_dictionary_fetcher.h"
class GURL;
namespace base {
class Clock;
}
namespace net {
class NetLogWithSource;
class SdchManager;
class URLRequestContext;
// This class owns the SDCH objects not owned as part of URLRequestContext, and
// exposes interface for setting SDCH policy. It should be instantiated by
// the net/ embedder.
// TODO(rdsmith): Implement dictionary prioritization.
class NET_EXPORT SdchOwner : public SdchObserver,
public base::MemoryCoordinatorClient {
public:
// Abstact storage interface for storing settings that allows the embedder
// to provide the appropriate storage backend.
class NET_EXPORT PrefStorage {
public:
// Possible values returned by GetReadError. This is a subset of the error
// values of Chromium's pref storage that we care about.
//
// DO NOT CHANGE VALUES. This is logged persistently in a histogram.
enum ReadError {
PERSISTENCE_FAILURE_NONE = 0,
// File didn't exist; is being created.
PERSISTENCE_FAILURE_REASON_NO_FILE = 1,
// Error reading in information, but should be able to write.
PERSISTENCE_FAILURE_REASON_READ_FAILED = 2,
// Error leading to abort on attempted persistence.
PERSISTENCE_FAILURE_REASON_WRITE_FAILED = 3,
// Anything else.
PERSISTENCE_FAILURE_REASON_OTHER = 4,
PERSISTENCE_FAILURE_REASON_MAX = 5
// See RecordPersistenceFailure for UMA logging of this value if
// adding a value here.
};
virtual ~PrefStorage();
// Returns the read error if any. Valid to be called after initialization
// is complete (see IsInitializationComplete).
virtual ReadError GetReadError() const = 0;
// Gets or sets the value in the preferences store.
virtual bool GetValue(const base::DictionaryValue** result) const = 0;
virtual bool GetMutableValue(base::DictionaryValue** result) = 0;
virtual void SetValue(std::unique_ptr<base::DictionaryValue> value) = 0;
// Notifies the storage system that a value was changed via mutating the
// result of GetMutableValue().
virtual void ReportValueChanged() = 0;
// Returns true if the store's init is complete. See the Start/Stop
// functions below for observing changes to this value.
virtual bool IsInitializationComplete() = 0;
// Starts and stops observing preferences storage init. There will only
// be one observer active at a time. The store should call
// OnPrefStorageInitializationComplete() when it transitions to initialized
// and there is an observer active. See also IsInitializationComplete().
virtual void StartObservingInit(SdchOwner* observer) = 0;
virtual void StopObservingInit() = 0;
};
static const size_t kMaxTotalDictionarySize;
static const size_t kMinSpaceForDictionaryFetch;
// Consumer must guarantee that |sdch_manager| and |context| outlive
// this object.
SdchOwner(SdchManager* sdch_manager, URLRequestContext* context);
~SdchOwner() override;
// Enables use of pref persistence. Ownership of the storage will be passed.
// This routine may only be called once per SdchOwner instance.
void EnablePersistentStorage(std::unique_ptr<PrefStorage> pref_store);
// Defaults to kMaxTotalDictionarySize.
void SetMaxTotalDictionarySize(size_t max_total_dictionary_size);
// Defaults to kMinSpaceForDictionaryFetch.
void SetMinSpaceForDictionaryFetch(size_t min_space_for_dictionary_fetch);
// SdchObserver implementation.
void OnDictionaryAdded(const GURL& dictionary_url,
const std::string& server_hash) override;
void OnDictionaryRemoved(const std::string& server_hash) override;
void OnDictionaryUsed(const std::string& server_hash) override;
void OnGetDictionary(const GURL& request_url,
const GURL& dictionary_url) override;
void OnClearDictionaries() override;
// Called by the PrefStorage implementation when initialization is complete.
// See PrefStorage::StartObservingInit().
void OnPrefStorageInitializationComplete(bool succeeded);
// Implementation detail--this is the function callback by the callback passed
// to the fetcher through which the fetcher informs the SdchOwner that it's
// gotten the dictionary. The first two arguments are bound locally.
// Public for testing.
void OnDictionaryFetched(base::Time last_used,
base::Time created_time,
int use_count,
const std::string& dictionary_text,
const GURL& dictionary_url,
const NetLogWithSource& net_log,
bool was_from_cache);
void SetClockForTesting(std::unique_ptr<base::Clock> clock);
// Returns the total number of dictionaries loaded.
int GetDictionaryCountForTesting() const;
// Returns whether this SdchOwner has dictionary from |url| loaded.
bool HasDictionaryFromURLForTesting(const GURL& url) const;
void SetFetcherForTesting(std::unique_ptr<SdchDictionaryFetcher> fetcher);
private:
// For each active dictionary, stores local info.
// Indexed by the server hash of the dictionary.
struct DictionaryInfo {
base::Time last_used;
int use_count;
size_t size;
DictionaryInfo() : use_count(0), size(0) {}
DictionaryInfo(const base::Time& last_used, size_t size)
: last_used(last_used), use_count(0), size(size) {}
DictionaryInfo(const DictionaryInfo& rhs) = default;
DictionaryInfo& operator=(const DictionaryInfo& rhs) = default;
};
// base::MemoryCoordinatorClient implementation:
void OnMemoryStateChange(base::MemoryState state) override;
void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel level);
// Clears data to save memory usage.
void ClearData();
// Schedule loading of all dictionaries described in |persisted_info|.
// Returns false and does not schedule a load if |persisted_info| has an
// unsupported version or no dictionaries key. Skips any dictionaries that are
// malformed in |persisted_info|.
bool SchedulePersistedDictionaryLoads(
const base::DictionaryValue& persisted_info);
bool IsPersistingDictionaries() const;
enum DictionaryFate {
// A Get-Dictionary header wasn't acted on.
DICTIONARY_FATE_GET_IGNORED = 1,
// A fetch was attempted, but failed.
// TODO(rdsmith): Actually record this case.
DICTIONARY_FATE_FETCH_FAILED = 2,
// A successful fetch was dropped on the floor, no space.
DICTIONARY_FATE_FETCH_IGNORED_NO_SPACE = 3,
// A successful fetch was refused by the SdchManager.
DICTIONARY_FATE_FETCH_MANAGER_REFUSED = 4,
// A dictionary was successfully added based on
// a Get-Dictionary header in a response.
DICTIONARY_FATE_ADD_RESPONSE_TRIGGERED = 5,
// A dictionary was evicted by an incoming dict.
DICTIONARY_FATE_EVICT_FOR_DICT = 6,
// A dictionary was evicted by memory pressure.
DICTIONARY_FATE_EVICT_FOR_MEMORY = 7,
// A dictionary was evicted on destruction.
DICTIONARY_FATE_EVICT_FOR_DESTRUCTION = 8,
// A dictionary was successfully added based on
// persistence from a previous browser revision.
DICTIONARY_FATE_ADD_PERSISTENCE_TRIGGERED = 9,
// A dictionary was unloaded on destruction, but is still present on disk.
DICTIONARY_FATE_UNLOAD_FOR_DESTRUCTION = 10,
DICTIONARY_FATE_MAX = 11
};
void RecordDictionaryFate(DictionaryFate fate);
// Record the lifetime memory use of a specified dictionary, identified by
// server hash.
void RecordDictionaryEvictionOrUnload(
const std::string& server_hash,
size_t size,
int use_count, DictionaryFate fate);
net::SdchManager* manager_;
std::unique_ptr<net::SdchDictionaryFetcher> fetcher_;
size_t total_dictionary_bytes_;
std::unique_ptr<base::Clock> clock_;
size_t max_total_dictionary_size_;
size_t min_space_for_dictionary_fetch_;
base::MemoryPressureListener memory_pressure_listener_;
// Dictionary persistence machinery.
// * |in_memory_pref_store_| is created on construction and used in the
// absence of any call to EnablePersistentStorage().
// * |external_pref_store_| holds the preference store specified by
// EnablePersistentStorage() (if any).
// * The external pref store is initialized asynchronously. During this time,
// both pointers will be value, pref_store_ will point to the in-memory
// one, and this class will be observing the initialization of the external
// store.
// * When the external pref store is initialized, the in-memory version will
// be freed, and pref_store_ will point to the external one.
// * |pref_store_| holds an unowned pointer to the currently
// active pref store (one of the preceding two).
std::unique_ptr<PrefStorage> in_memory_pref_store_;
std::unique_ptr<PrefStorage> external_pref_store_;
PrefStorage* pref_store_;
// The use counts of dictionaries when they were loaded from the persistent
// store, keyed by server hash. These are stored to avoid generating
// misleading ever-increasing use counts for dictionaries that are persisted,
// since the UMA histogram for use counts is only supposed to be since last
// load.
std::map<std::string, int> use_counts_at_load_;
// Load times for loaded dictionaries, keyed by server hash. These are used to
// track the durations that dictionaries are in memory.
std::map<std::string, base::Time> load_times_;
// Byte-seconds consumed by dictionaries that have been unloaded. These are
// stored for later uploading in the SdchOwner destructor.
std::vector<int64_t> consumed_byte_seconds_;
// Creation time for this SdchOwner object, used for reporting temporal memory
// pressure.
base::Time creation_time_;
DISALLOW_COPY_AND_ASSIGN(SdchOwner);
};
} // namespace net
#endif // NET_SDCH_SDCH_OWNER_H_
| ssaroha/node-webrtc | third_party/webrtc/include/chromium/src/net/sdch/sdch_owner.h | C | bsd-2-clause | 10,524 |
/*
* Licensed to Jasig under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Jasig 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 the following location:
*
* 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.jasig.cas.adaptors.x509.authentication.handler.support;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.cert.X509CRLEntry;
import java.util.Date;
/**
* Exception that describes a revoked X.509 certificate.
*
* @author Marvin S. Addison
* @version $Revision$
* @since 3.4.6
*
*/
public class RevokedCertificateException extends GeneralSecurityException {
/** Serialization marker */
private static final long serialVersionUID = 8827788431199129708L;
/** OID for reasonCode CRL extension */
public static final String CRL_REASON_OID = "2.5.29.21";
/** CRL revocation reason codes per RFC 3280 */
public enum Reason {
Unspecified,
KeyCompromise,
CACompromise,
AffiliationChanged,
Superseded,
CessationOfOperation,
CertificateHold,
RemoveFromCRL,
PrivilegeWithdrawn,
AACompromise;
public static Reason fromCode(final int code) {
for (int i = 0; i < Reason.values().length; i++) {
if (i == code) {
return Reason.values()[i];
}
}
throw new IllegalArgumentException("Unknown CRL reason code.");
}
}
private Date revocationDate;
private BigInteger serial;
private Reason reason;
public RevokedCertificateException(final Date revoked, final BigInteger serial) {
this(revoked, serial, null);
}
public RevokedCertificateException(final Date revoked, final BigInteger serial, final Reason reason) {
this.revocationDate = revoked;
this.serial = serial;
this.reason = reason;
}
public RevokedCertificateException(final X509CRLEntry entry) {
this.revocationDate = entry.getRevocationDate();
this.serial = entry.getSerialNumber();
if (entry.hasExtensions()) {
try {
final int code = Integer.parseInt(
new String(entry.getExtensionValue(CRL_REASON_OID), "ASCII"));
if (code < Reason.values().length) {
this.reason = Reason.fromCode(code);
}
} catch (final Exception e) {
// Ignore invalid reason codes
}
}
}
/**
* @return Returns the revocationDate.
*/
public Date getRevocationDate() {
return this.revocationDate;
}
/**
* @return Returns the serial.
*/
public BigInteger getSerial() {
return this.serial;
}
/**
* @return Returns the reason.
*/
public Reason getReason() {
return this.reason;
}
/** {@inheritDoc} */
@Override
public String getMessage() {
if (this.reason != null) {
return String.format("Certificate %s revoked on %s for reason %s",
this.serial, this.revocationDate, this.reason);
}
return String.format("Certificate %s revoked on %s", this.serial, this.revocationDate);
}
}
| ConnCollege/cas | cas-server-support-x509/src/main/java/org/jasig/cas/adaptors/x509/authentication/handler/support/RevokedCertificateException.java | Java | bsd-3-clause | 3,904 |
*> \brief \b DDRVSX
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DDRVSX( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
* NIUNIT, NOUNIT, A, LDA, H, HT, WR, WI, WRT,
* WIT, WRTMP, WITMP, VS, LDVS, VS1, RESULT, WORK,
* LWORK, IWORK, BWORK, INFO )
*
* .. Scalar Arguments ..
* INTEGER INFO, LDA, LDVS, LWORK, NIUNIT, NOUNIT, NSIZES,
* $ NTYPES
* DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
* LOGICAL BWORK( * ), DOTYPE( * )
* INTEGER ISEED( 4 ), IWORK( * ), NN( * )
* DOUBLE PRECISION A( LDA, * ), H( LDA, * ), HT( LDA, * ),
* $ RESULT( 17 ), VS( LDVS, * ), VS1( LDVS, * ),
* $ WI( * ), WIT( * ), WITMP( * ), WORK( * ),
* $ WR( * ), WRT( * ), WRTMP( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DDRVSX checks the nonsymmetric eigenvalue (Schur form) problem
*> expert driver DGEESX.
*>
*> DDRVSX uses both test matrices generated randomly depending on
*> data supplied in the calling sequence, as well as on data
*> read from an input file and including precomputed condition
*> numbers to which it compares the ones it computes.
*>
*> When DDRVSX is called, a number of matrix "sizes" ("n's") and a
*> number of matrix "types" are specified. For each size ("n")
*> and each type of matrix, one matrix will be generated and used
*> to test the nonsymmetric eigenroutines. For each matrix, 15
*> tests will be performed:
*>
*> (1) 0 if T is in Schur form, 1/ulp otherwise
*> (no sorting of eigenvalues)
*>
*> (2) | A - VS T VS' | / ( n |A| ulp )
*>
*> Here VS is the matrix of Schur eigenvectors, and T is in Schur
*> form (no sorting of eigenvalues).
*>
*> (3) | I - VS VS' | / ( n ulp ) (no sorting of eigenvalues).
*>
*> (4) 0 if WR+sqrt(-1)*WI are eigenvalues of T
*> 1/ulp otherwise
*> (no sorting of eigenvalues)
*>
*> (5) 0 if T(with VS) = T(without VS),
*> 1/ulp otherwise
*> (no sorting of eigenvalues)
*>
*> (6) 0 if eigenvalues(with VS) = eigenvalues(without VS),
*> 1/ulp otherwise
*> (no sorting of eigenvalues)
*>
*> (7) 0 if T is in Schur form, 1/ulp otherwise
*> (with sorting of eigenvalues)
*>
*> (8) | A - VS T VS' | / ( n |A| ulp )
*>
*> Here VS is the matrix of Schur eigenvectors, and T is in Schur
*> form (with sorting of eigenvalues).
*>
*> (9) | I - VS VS' | / ( n ulp ) (with sorting of eigenvalues).
*>
*> (10) 0 if WR+sqrt(-1)*WI are eigenvalues of T
*> 1/ulp otherwise
*> If workspace sufficient, also compare WR, WI with and
*> without reciprocal condition numbers
*> (with sorting of eigenvalues)
*>
*> (11) 0 if T(with VS) = T(without VS),
*> 1/ulp otherwise
*> If workspace sufficient, also compare T with and without
*> reciprocal condition numbers
*> (with sorting of eigenvalues)
*>
*> (12) 0 if eigenvalues(with VS) = eigenvalues(without VS),
*> 1/ulp otherwise
*> If workspace sufficient, also compare VS with and without
*> reciprocal condition numbers
*> (with sorting of eigenvalues)
*>
*> (13) if sorting worked and SDIM is the number of
*> eigenvalues which were SELECTed
*> If workspace sufficient, also compare SDIM with and
*> without reciprocal condition numbers
*>
*> (14) if RCONDE the same no matter if VS and/or RCONDV computed
*>
*> (15) if RCONDV the same no matter if VS and/or RCONDE computed
*>
*> The "sizes" are specified by an array NN(1:NSIZES); the value of
*> each element NN(j) specifies one size.
*> The "types" are specified by a logical array DOTYPE( 1:NTYPES );
*> if DOTYPE(j) is .TRUE., then matrix type "j" will be generated.
*> Currently, the list of possible types is:
*>
*> (1) The zero matrix.
*> (2) The identity matrix.
*> (3) A (transposed) Jordan block, with 1's on the diagonal.
*>
*> (4) A diagonal matrix with evenly spaced entries
*> 1, ..., ULP and random signs.
*> (ULP = (first number larger than 1) - 1 )
*> (5) A diagonal matrix with geometrically spaced entries
*> 1, ..., ULP and random signs.
*> (6) A diagonal matrix with "clustered" entries 1, ULP, ..., ULP
*> and random signs.
*>
*> (7) Same as (4), but multiplied by a constant near
*> the overflow threshold
*> (8) Same as (4), but multiplied by a constant near
*> the underflow threshold
*>
*> (9) A matrix of the form U' T U, where U is orthogonal and
*> T has evenly spaced entries 1, ..., ULP with random signs
*> on the diagonal and random O(1) entries in the upper
*> triangle.
*>
*> (10) A matrix of the form U' T U, where U is orthogonal and
*> T has geometrically spaced entries 1, ..., ULP with random
*> signs on the diagonal and random O(1) entries in the upper
*> triangle.
*>
*> (11) A matrix of the form U' T U, where U is orthogonal and
*> T has "clustered" entries 1, ULP,..., ULP with random
*> signs on the diagonal and random O(1) entries in the upper
*> triangle.
*>
*> (12) A matrix of the form U' T U, where U is orthogonal and
*> T has real or complex conjugate paired eigenvalues randomly
*> chosen from ( ULP, 1 ) and random O(1) entries in the upper
*> triangle.
*>
*> (13) A matrix of the form X' T X, where X has condition
*> SQRT( ULP ) and T has evenly spaced entries 1, ..., ULP
*> with random signs on the diagonal and random O(1) entries
*> in the upper triangle.
*>
*> (14) A matrix of the form X' T X, where X has condition
*> SQRT( ULP ) and T has geometrically spaced entries
*> 1, ..., ULP with random signs on the diagonal and random
*> O(1) entries in the upper triangle.
*>
*> (15) A matrix of the form X' T X, where X has condition
*> SQRT( ULP ) and T has "clustered" entries 1, ULP,..., ULP
*> with random signs on the diagonal and random O(1) entries
*> in the upper triangle.
*>
*> (16) A matrix of the form X' T X, where X has condition
*> SQRT( ULP ) and T has real or complex conjugate paired
*> eigenvalues randomly chosen from ( ULP, 1 ) and random
*> O(1) entries in the upper triangle.
*>
*> (17) Same as (16), but multiplied by a constant
*> near the overflow threshold
*> (18) Same as (16), but multiplied by a constant
*> near the underflow threshold
*>
*> (19) Nonsymmetric matrix with random entries chosen from (-1,1).
*> If N is at least 4, all entries in first two rows and last
*> row, and first column and last two columns are zero.
*> (20) Same as (19), but multiplied by a constant
*> near the overflow threshold
*> (21) Same as (19), but multiplied by a constant
*> near the underflow threshold
*>
*> In addition, an input file will be read from logical unit number
*> NIUNIT. The file contains matrices along with precomputed
*> eigenvalues and reciprocal condition numbers for the eigenvalue
*> average and right invariant subspace. For these matrices, in
*> addition to tests (1) to (15) we will compute the following two
*> tests:
*>
*> (16) |RCONDE - RCDEIN| / cond(RCONDE)
*>
*> RCONDE is the reciprocal average eigenvalue condition number
*> computed by DGEESX and RCDEIN (the precomputed true value)
*> is supplied as input. cond(RCONDE) is the condition number
*> of RCONDE, and takes errors in computing RCONDE into account,
*> so that the resulting quantity should be O(ULP). cond(RCONDE)
*> is essentially given by norm(A)/RCONDV.
*>
*> (17) |RCONDV - RCDVIN| / cond(RCONDV)
*>
*> RCONDV is the reciprocal right invariant subspace condition
*> number computed by DGEESX and RCDVIN (the precomputed true
*> value) is supplied as input. cond(RCONDV) is the condition
*> number of RCONDV, and takes errors in computing RCONDV into
*> account, so that the resulting quantity should be O(ULP).
*> cond(RCONDV) is essentially given by norm(A)/RCONDE.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] NSIZES
*> \verbatim
*> NSIZES is INTEGER
*> The number of sizes of matrices to use. NSIZES must be at
*> least zero. If it is zero, no randomly generated matrices
*> are tested, but any test matrices read from NIUNIT will be
*> tested.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER array, dimension (NSIZES)
*> An array containing the sizes to be used for the matrices.
*> Zero values will be skipped. The values must be at least
*> zero.
*> \endverbatim
*>
*> \param[in] NTYPES
*> \verbatim
*> NTYPES is INTEGER
*> The number of elements in DOTYPE. NTYPES must be at least
*> zero. If it is zero, no randomly generated test matrices
*> are tested, but and test matrices read from NIUNIT will be
*> tested. If it is MAXTYP+1 and NSIZES is 1, then an
*> additional type, MAXTYP+1 is defined, which is to use
*> whatever matrix is in A. This is only useful if
*> DOTYPE(1:MAXTYP) is .FALSE. and DOTYPE(MAXTYP+1) is .TRUE. .
*> \endverbatim
*>
*> \param[in] DOTYPE
*> \verbatim
*> DOTYPE is LOGICAL array, dimension (NTYPES)
*> If DOTYPE(j) is .TRUE., then for each size in NN a
*> matrix of that size and of type j will be generated.
*> If NTYPES is smaller than the maximum number of types
*> defined (PARAMETER MAXTYP), then types NTYPES+1 through
*> MAXTYP will not be generated. If NTYPES is larger
*> than MAXTYP, DOTYPE(MAXTYP+1) through DOTYPE(NTYPES)
*> will be ignored.
*> \endverbatim
*>
*> \param[in,out] ISEED
*> \verbatim
*> ISEED is INTEGER array, dimension (4)
*> On entry ISEED specifies the seed of the random number
*> generator. The array elements should be between 0 and 4095;
*> if not they will be reduced mod 4096. Also, ISEED(4) must
*> be odd. The random number generator uses a linear
*> congruential sequence limited to small integers, and so
*> should produce machine independent random numbers. The
*> values of ISEED are changed on exit, and can be used in the
*> next call to DDRVSX to continue the same random number
*> sequence.
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is DOUBLE PRECISION
*> A test will count as "failed" if the "error", computed as
*> described above, exceeds THRESH. Note that the error
*> is scaled to be O(1), so THRESH should be a reasonably
*> small multiple of 1, e.g., 10 or 100. In particular,
*> it should not depend on the precision (single vs. double)
*> or the size of the matrix. It must be at least zero.
*> \endverbatim
*>
*> \param[in] NIUNIT
*> \verbatim
*> NIUNIT is INTEGER
*> The FORTRAN unit number for reading in the data file of
*> problems to solve.
*> \endverbatim
*>
*> \param[in] NOUNIT
*> \verbatim
*> NOUNIT is INTEGER
*> The FORTRAN unit number for printing out error messages
*> (e.g., if a routine returns INFO not equal to 0.)
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA, max(NN))
*> Used to hold the matrix whose eigenvalues are to be
*> computed. On exit, A contains the last matrix actually used.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of A, and H. LDA must be at
*> least 1 and at least max( NN ).
*> \endverbatim
*>
*> \param[out] H
*> \verbatim
*> H is DOUBLE PRECISION array, dimension (LDA, max(NN))
*> Another copy of the test matrix A, modified by DGEESX.
*> \endverbatim
*>
*> \param[out] HT
*> \verbatim
*> HT is DOUBLE PRECISION array, dimension (LDA, max(NN))
*> Yet another copy of the test matrix A, modified by DGEESX.
*> \endverbatim
*>
*> \param[out] WR
*> \verbatim
*> WR is DOUBLE PRECISION array, dimension (max(NN))
*> \endverbatim
*>
*> \param[out] WI
*> \verbatim
*> WI is DOUBLE PRECISION array, dimension (max(NN))
*>
*> The real and imaginary parts of the eigenvalues of A.
*> On exit, WR + WI*i are the eigenvalues of the matrix in A.
*> \endverbatim
*>
*> \param[out] WRT
*> \verbatim
*> WRT is DOUBLE PRECISION array, dimension (max(NN))
*> \endverbatim
*>
*> \param[out] WIT
*> \verbatim
*> WIT is DOUBLE PRECISION array, dimension (max(NN))
*>
*> Like WR, WI, these arrays contain the eigenvalues of A,
*> but those computed when DGEESX only computes a partial
*> eigendecomposition, i.e. not Schur vectors
*> \endverbatim
*>
*> \param[out] WRTMP
*> \verbatim
*> WRTMP is DOUBLE PRECISION array, dimension (max(NN))
*> \endverbatim
*>
*> \param[out] WITMP
*> \verbatim
*> WITMP is DOUBLE PRECISION array, dimension (max(NN))
*>
*> More temporary storage for eigenvalues.
*> \endverbatim
*>
*> \param[out] VS
*> \verbatim
*> VS is DOUBLE PRECISION array, dimension (LDVS, max(NN))
*> VS holds the computed Schur vectors.
*> \endverbatim
*>
*> \param[in] LDVS
*> \verbatim
*> LDVS is INTEGER
*> Leading dimension of VS. Must be at least max(1,max(NN)).
*> \endverbatim
*>
*> \param[out] VS1
*> \verbatim
*> VS1 is DOUBLE PRECISION array, dimension (LDVS, max(NN))
*> VS1 holds another copy of the computed Schur vectors.
*> \endverbatim
*>
*> \param[out] RESULT
*> \verbatim
*> RESULT is DOUBLE PRECISION array, dimension (17)
*> The values computed by the 17 tests described above.
*> The values are currently limited to 1/ulp, to avoid overflow.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION array, dimension (LWORK)
*> \endverbatim
*>
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The number of entries in WORK. This must be at least
*> max(3*NN(j),2*NN(j)**2) for all j.
*> \endverbatim
*>
*> \param[out] IWORK
*> \verbatim
*> IWORK is INTEGER array, dimension (max(NN)*max(NN))
*> \endverbatim
*>
*> \param[out] BWORK
*> \verbatim
*> BWORK is LOGICAL array, dimension (max(NN))
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> If 0, successful exit.
*> <0, input parameter -INFO is incorrect
*> >0, DLATMR, SLATMS, SLATME or DGET24 returned an error
*> code and INFO is its absolute value
*>
*>-----------------------------------------------------------------------
*>
*> Some Local Variables and Parameters:
*> ---- ----- --------- --- ----------
*> ZERO, ONE Real 0 and 1.
*> MAXTYP The number of types defined.
*> NMAX Largest value in NN.
*> NERRS The number of tests which have exceeded THRESH
*> COND, CONDS,
*> IMODE Values to be passed to the matrix generators.
*> ANORM Norm of A; passed to matrix generators.
*>
*> OVFL, UNFL Overflow and underflow thresholds.
*> ULP, ULPINV Finest relative precision and its inverse.
*> RTULP, RTULPI Square roots of the previous 4 values.
*> The following four arrays decode JTYPE:
*> KTYPE(j) The general type (1-10) for type "j".
*> KMODE(j) The MODE value to be passed to the matrix
*> generator for type "j".
*> KMAGN(j) The order of magnitude ( O(1),
*> O(overflow^(1/2) ), O(underflow^(1/2) )
*> KCONDS(j) Selectw whether CONDS is to be 1 or
*> 1/sqrt(ulp). (0 means irrelevant.)
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date June 2016
*
*> \ingroup double_eig
*
* =====================================================================
SUBROUTINE DDRVSX( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
$ NIUNIT, NOUNIT, A, LDA, H, HT, WR, WI, WRT,
$ WIT, WRTMP, WITMP, VS, LDVS, VS1, RESULT, WORK,
$ LWORK, IWORK, BWORK, INFO )
*
* -- LAPACK test routine (version 3.7.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* June 2016
*
* .. Scalar Arguments ..
INTEGER INFO, LDA, LDVS, LWORK, NIUNIT, NOUNIT, NSIZES,
$ NTYPES
DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
LOGICAL BWORK( * ), DOTYPE( * )
INTEGER ISEED( 4 ), IWORK( * ), NN( * )
DOUBLE PRECISION A( LDA, * ), H( LDA, * ), HT( LDA, * ),
$ RESULT( 17 ), VS( LDVS, * ), VS1( LDVS, * ),
$ WI( * ), WIT( * ), WITMP( * ), WORK( * ),
$ WR( * ), WRT( * ), WRTMP( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
INTEGER MAXTYP
PARAMETER ( MAXTYP = 21 )
* ..
* .. Local Scalars ..
LOGICAL BADNN
CHARACTER*3 PATH
INTEGER I, IINFO, IMODE, ITYPE, IWK, J, JCOL, JSIZE,
$ JTYPE, MTYPES, N, NERRS, NFAIL, NMAX, NNWORK,
$ NSLCT, NTEST, NTESTF, NTESTT
DOUBLE PRECISION ANORM, COND, CONDS, OVFL, RCDEIN, RCDVIN,
$ RTULP, RTULPI, ULP, ULPINV, UNFL
* ..
* .. Local Arrays ..
CHARACTER ADUMMA( 1 )
INTEGER IDUMMA( 1 ), IOLDSD( 4 ), ISLCT( 20 ),
$ KCONDS( MAXTYP ), KMAGN( MAXTYP ),
$ KMODE( MAXTYP ), KTYPE( MAXTYP )
* ..
* .. Arrays in Common ..
LOGICAL SELVAL( 20 )
DOUBLE PRECISION SELWI( 20 ), SELWR( 20 )
* ..
* .. Scalars in Common ..
INTEGER SELDIM, SELOPT
* ..
* .. Common blocks ..
COMMON / SSLCT / SELOPT, SELDIM, SELVAL, SELWR, SELWI
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH
EXTERNAL DLAMCH
* ..
* .. External Subroutines ..
EXTERNAL DGET24, DLABAD, DLASET, DLASUM, DLATME, DLATMR,
$ DLATMS, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX, MIN, SQRT
* ..
* .. Data statements ..
DATA KTYPE / 1, 2, 3, 5*4, 4*6, 6*6, 3*9 /
DATA KMAGN / 3*1, 1, 1, 1, 2, 3, 4*1, 1, 1, 1, 1, 2,
$ 3, 1, 2, 3 /
DATA KMODE / 3*0, 4, 3, 1, 4, 4, 4, 3, 1, 5, 4, 3,
$ 1, 5, 5, 5, 4, 3, 1 /
DATA KCONDS / 3*0, 5*0, 4*1, 6*2, 3*0 /
* ..
* .. Executable Statements ..
*
PATH( 1: 1 ) = 'Double precision'
PATH( 2: 3 ) = 'SX'
*
* Check for errors
*
NTESTT = 0
NTESTF = 0
INFO = 0
*
* Important constants
*
BADNN = .FALSE.
*
* 12 is the largest dimension in the input file of precomputed
* problems
*
NMAX = 12
DO 10 J = 1, NSIZES
NMAX = MAX( NMAX, NN( J ) )
IF( NN( J ).LT.0 )
$ BADNN = .TRUE.
10 CONTINUE
*
* Check for errors
*
IF( NSIZES.LT.0 ) THEN
INFO = -1
ELSE IF( BADNN ) THEN
INFO = -2
ELSE IF( NTYPES.LT.0 ) THEN
INFO = -3
ELSE IF( THRESH.LT.ZERO ) THEN
INFO = -6
ELSE IF( NIUNIT.LE.0 ) THEN
INFO = -7
ELSE IF( NOUNIT.LE.0 ) THEN
INFO = -8
ELSE IF( LDA.LT.1 .OR. LDA.LT.NMAX ) THEN
INFO = -10
ELSE IF( LDVS.LT.1 .OR. LDVS.LT.NMAX ) THEN
INFO = -20
ELSE IF( MAX( 3*NMAX, 2*NMAX**2 ).GT.LWORK ) THEN
INFO = -24
END IF
*
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DDRVSX', -INFO )
RETURN
END IF
*
* If nothing to do check on NIUNIT
*
IF( NSIZES.EQ.0 .OR. NTYPES.EQ.0 )
$ GO TO 150
*
* More Important constants
*
UNFL = DLAMCH( 'Safe minimum' )
OVFL = ONE / UNFL
CALL DLABAD( UNFL, OVFL )
ULP = DLAMCH( 'Precision' )
ULPINV = ONE / ULP
RTULP = SQRT( ULP )
RTULPI = ONE / RTULP
*
* Loop over sizes, types
*
NERRS = 0
*
DO 140 JSIZE = 1, NSIZES
N = NN( JSIZE )
IF( NSIZES.NE.1 ) THEN
MTYPES = MIN( MAXTYP, NTYPES )
ELSE
MTYPES = MIN( MAXTYP+1, NTYPES )
END IF
*
DO 130 JTYPE = 1, MTYPES
IF( .NOT.DOTYPE( JTYPE ) )
$ GO TO 130
*
* Save ISEED in case of an error.
*
DO 20 J = 1, 4
IOLDSD( J ) = ISEED( J )
20 CONTINUE
*
* Compute "A"
*
* Control parameters:
*
* KMAGN KCONDS KMODE KTYPE
* =1 O(1) 1 clustered 1 zero
* =2 large large clustered 2 identity
* =3 small exponential Jordan
* =4 arithmetic diagonal, (w/ eigenvalues)
* =5 random log symmetric, w/ eigenvalues
* =6 random general, w/ eigenvalues
* =7 random diagonal
* =8 random symmetric
* =9 random general
* =10 random triangular
*
IF( MTYPES.GT.MAXTYP )
$ GO TO 90
*
ITYPE = KTYPE( JTYPE )
IMODE = KMODE( JTYPE )
*
* Compute norm
*
GO TO ( 30, 40, 50 )KMAGN( JTYPE )
*
30 CONTINUE
ANORM = ONE
GO TO 60
*
40 CONTINUE
ANORM = OVFL*ULP
GO TO 60
*
50 CONTINUE
ANORM = UNFL*ULPINV
GO TO 60
*
60 CONTINUE
*
CALL DLASET( 'Full', LDA, N, ZERO, ZERO, A, LDA )
IINFO = 0
COND = ULPINV
*
* Special Matrices -- Identity & Jordan block
*
* Zero
*
IF( ITYPE.EQ.1 ) THEN
IINFO = 0
*
ELSE IF( ITYPE.EQ.2 ) THEN
*
* Identity
*
DO 70 JCOL = 1, N
A( JCOL, JCOL ) = ANORM
70 CONTINUE
*
ELSE IF( ITYPE.EQ.3 ) THEN
*
* Jordan Block
*
DO 80 JCOL = 1, N
A( JCOL, JCOL ) = ANORM
IF( JCOL.GT.1 )
$ A( JCOL, JCOL-1 ) = ONE
80 CONTINUE
*
ELSE IF( ITYPE.EQ.4 ) THEN
*
* Diagonal Matrix, [Eigen]values Specified
*
CALL DLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
$ ANORM, 0, 0, 'N', A, LDA, WORK( N+1 ),
$ IINFO )
*
ELSE IF( ITYPE.EQ.5 ) THEN
*
* Symmetric, eigenvalues specified
*
CALL DLATMS( N, N, 'S', ISEED, 'S', WORK, IMODE, COND,
$ ANORM, N, N, 'N', A, LDA, WORK( N+1 ),
$ IINFO )
*
ELSE IF( ITYPE.EQ.6 ) THEN
*
* General, eigenvalues specified
*
IF( KCONDS( JTYPE ).EQ.1 ) THEN
CONDS = ONE
ELSE IF( KCONDS( JTYPE ).EQ.2 ) THEN
CONDS = RTULPI
ELSE
CONDS = ZERO
END IF
*
ADUMMA( 1 ) = ' '
CALL DLATME( N, 'S', ISEED, WORK, IMODE, COND, ONE,
$ ADUMMA, 'T', 'T', 'T', WORK( N+1 ), 4,
$ CONDS, N, N, ANORM, A, LDA, WORK( 2*N+1 ),
$ IINFO )
*
ELSE IF( ITYPE.EQ.7 ) THEN
*
* Diagonal, random eigenvalues
*
CALL DLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
$ 'T', 'N', WORK( N+1 ), 1, ONE,
$ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, 0, 0,
$ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
*
ELSE IF( ITYPE.EQ.8 ) THEN
*
* Symmetric, random eigenvalues
*
CALL DLATMR( N, N, 'S', ISEED, 'S', WORK, 6, ONE, ONE,
$ 'T', 'N', WORK( N+1 ), 1, ONE,
$ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, N,
$ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
*
ELSE IF( ITYPE.EQ.9 ) THEN
*
* General, random eigenvalues
*
CALL DLATMR( N, N, 'S', ISEED, 'N', WORK, 6, ONE, ONE,
$ 'T', 'N', WORK( N+1 ), 1, ONE,
$ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, N,
$ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
IF( N.GE.4 ) THEN
CALL DLASET( 'Full', 2, N, ZERO, ZERO, A, LDA )
CALL DLASET( 'Full', N-3, 1, ZERO, ZERO, A( 3, 1 ),
$ LDA )
CALL DLASET( 'Full', N-3, 2, ZERO, ZERO, A( 3, N-1 ),
$ LDA )
CALL DLASET( 'Full', 1, N, ZERO, ZERO, A( N, 1 ),
$ LDA )
END IF
*
ELSE IF( ITYPE.EQ.10 ) THEN
*
* Triangular, random eigenvalues
*
CALL DLATMR( N, N, 'S', ISEED, 'N', WORK, 6, ONE, ONE,
$ 'T', 'N', WORK( N+1 ), 1, ONE,
$ WORK( 2*N+1 ), 1, ONE, 'N', IDUMMA, N, 0,
$ ZERO, ANORM, 'NO', A, LDA, IWORK, IINFO )
*
ELSE
*
IINFO = 1
END IF
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUNIT, FMT = 9991 )'Generator', IINFO, N, JTYPE,
$ IOLDSD
INFO = ABS( IINFO )
RETURN
END IF
*
90 CONTINUE
*
* Test for minimal and generous workspace
*
DO 120 IWK = 1, 2
IF( IWK.EQ.1 ) THEN
NNWORK = 3*N
ELSE
NNWORK = MAX( 3*N, 2*N*N )
END IF
NNWORK = MAX( NNWORK, 1 )
*
CALL DGET24( .FALSE., JTYPE, THRESH, IOLDSD, NOUNIT, N,
$ A, LDA, H, HT, WR, WI, WRT, WIT, WRTMP,
$ WITMP, VS, LDVS, VS1, RCDEIN, RCDVIN, NSLCT,
$ ISLCT, RESULT, WORK, NNWORK, IWORK, BWORK,
$ INFO )
*
* Check for RESULT(j) > THRESH
*
NTEST = 0
NFAIL = 0
DO 100 J = 1, 15
IF( RESULT( J ).GE.ZERO )
$ NTEST = NTEST + 1
IF( RESULT( J ).GE.THRESH )
$ NFAIL = NFAIL + 1
100 CONTINUE
*
IF( NFAIL.GT.0 )
$ NTESTF = NTESTF + 1
IF( NTESTF.EQ.1 ) THEN
WRITE( NOUNIT, FMT = 9999 )PATH
WRITE( NOUNIT, FMT = 9998 )
WRITE( NOUNIT, FMT = 9997 )
WRITE( NOUNIT, FMT = 9996 )
WRITE( NOUNIT, FMT = 9995 )THRESH
WRITE( NOUNIT, FMT = 9994 )
NTESTF = 2
END IF
*
DO 110 J = 1, 15
IF( RESULT( J ).GE.THRESH ) THEN
WRITE( NOUNIT, FMT = 9993 )N, IWK, IOLDSD, JTYPE,
$ J, RESULT( J )
END IF
110 CONTINUE
*
NERRS = NERRS + NFAIL
NTESTT = NTESTT + NTEST
*
120 CONTINUE
130 CONTINUE
140 CONTINUE
*
150 CONTINUE
*
* Read in data from file to check accuracy of condition estimation
* Read input data until N=0
*
JTYPE = 0
160 CONTINUE
READ( NIUNIT, FMT = *, END = 200 )N, NSLCT
IF( N.EQ.0 )
$ GO TO 200
JTYPE = JTYPE + 1
ISEED( 1 ) = JTYPE
IF( NSLCT.GT.0 )
$ READ( NIUNIT, FMT = * )( ISLCT( I ), I = 1, NSLCT )
DO 170 I = 1, N
READ( NIUNIT, FMT = * )( A( I, J ), J = 1, N )
170 CONTINUE
READ( NIUNIT, FMT = * )RCDEIN, RCDVIN
*
CALL DGET24( .TRUE., 22, THRESH, ISEED, NOUNIT, N, A, LDA, H, HT,
$ WR, WI, WRT, WIT, WRTMP, WITMP, VS, LDVS, VS1,
$ RCDEIN, RCDVIN, NSLCT, ISLCT, RESULT, WORK, LWORK,
$ IWORK, BWORK, INFO )
*
* Check for RESULT(j) > THRESH
*
NTEST = 0
NFAIL = 0
DO 180 J = 1, 17
IF( RESULT( J ).GE.ZERO )
$ NTEST = NTEST + 1
IF( RESULT( J ).GE.THRESH )
$ NFAIL = NFAIL + 1
180 CONTINUE
*
IF( NFAIL.GT.0 )
$ NTESTF = NTESTF + 1
IF( NTESTF.EQ.1 ) THEN
WRITE( NOUNIT, FMT = 9999 )PATH
WRITE( NOUNIT, FMT = 9998 )
WRITE( NOUNIT, FMT = 9997 )
WRITE( NOUNIT, FMT = 9996 )
WRITE( NOUNIT, FMT = 9995 )THRESH
WRITE( NOUNIT, FMT = 9994 )
NTESTF = 2
END IF
DO 190 J = 1, 17
IF( RESULT( J ).GE.THRESH ) THEN
WRITE( NOUNIT, FMT = 9992 )N, JTYPE, J, RESULT( J )
END IF
190 CONTINUE
*
NERRS = NERRS + NFAIL
NTESTT = NTESTT + NTEST
GO TO 160
200 CONTINUE
*
* Summary
*
CALL DLASUM( PATH, NOUNIT, NERRS, NTESTT )
*
9999 FORMAT( / 1X, A3, ' -- Real Schur Form Decomposition Expert ',
$ 'Driver', / ' Matrix types (see DDRVSX for details):' )
*
9998 FORMAT( / ' Special Matrices:', / ' 1=Zero matrix. ',
$ ' ', ' 5=Diagonal: geometr. spaced entries.',
$ / ' 2=Identity matrix. ', ' 6=Diagona',
$ 'l: clustered entries.', / ' 3=Transposed Jordan block. ',
$ ' ', ' 7=Diagonal: large, evenly spaced.', / ' ',
$ '4=Diagonal: evenly spaced entries. ', ' 8=Diagonal: s',
$ 'mall, evenly spaced.' )
9997 FORMAT( ' Dense, Non-Symmetric Matrices:', / ' 9=Well-cond., ev',
$ 'enly spaced eigenvals.', ' 14=Ill-cond., geomet. spaced e',
$ 'igenals.', / ' 10=Well-cond., geom. spaced eigenvals. ',
$ ' 15=Ill-conditioned, clustered e.vals.', / ' 11=Well-cond',
$ 'itioned, clustered e.vals. ', ' 16=Ill-cond., random comp',
$ 'lex ', / ' 12=Well-cond., random complex ', ' ',
$ ' 17=Ill-cond., large rand. complx ', / ' 13=Ill-condi',
$ 'tioned, evenly spaced. ', ' 18=Ill-cond., small rand.',
$ ' complx ' )
9996 FORMAT( ' 19=Matrix with random O(1) entries. ', ' 21=Matrix ',
$ 'with small random entries.', / ' 20=Matrix with large ran',
$ 'dom entries. ', / )
9995 FORMAT( ' Tests performed with test threshold =', F8.2,
$ / ' ( A denotes A on input and T denotes A on output)',
$ / / ' 1 = 0 if T in Schur form (no sort), ',
$ ' 1/ulp otherwise', /
$ ' 2 = | A - VS T transpose(VS) | / ( n |A| ulp ) (no sort)',
$ / ' 3 = | I - VS transpose(VS) | / ( n ulp ) (no sort) ', /
$ ' 4 = 0 if WR+sqrt(-1)*WI are eigenvalues of T (no sort),',
$ ' 1/ulp otherwise', /
$ ' 5 = 0 if T same no matter if VS computed (no sort),',
$ ' 1/ulp otherwise', /
$ ' 6 = 0 if WR, WI same no matter if VS computed (no sort)',
$ ', 1/ulp otherwise' )
9994 FORMAT( ' 7 = 0 if T in Schur form (sort), ', ' 1/ulp otherwise',
$ / ' 8 = | A - VS T transpose(VS) | / ( n |A| ulp ) (sort)',
$ / ' 9 = | I - VS transpose(VS) | / ( n ulp ) (sort) ',
$ / ' 10 = 0 if WR+sqrt(-1)*WI are eigenvalues of T (sort),',
$ ' 1/ulp otherwise', /
$ ' 11 = 0 if T same no matter what else computed (sort),',
$ ' 1/ulp otherwise', /
$ ' 12 = 0 if WR, WI same no matter what else computed ',
$ '(sort), 1/ulp otherwise', /
$ ' 13 = 0 if sorting successful, 1/ulp otherwise',
$ / ' 14 = 0 if RCONDE same no matter what else computed,',
$ ' 1/ulp otherwise', /
$ ' 15 = 0 if RCONDv same no matter what else computed,',
$ ' 1/ulp otherwise', /
$ ' 16 = | RCONDE - RCONDE(precomputed) | / cond(RCONDE),',
$ / ' 17 = | RCONDV - RCONDV(precomputed) | / cond(RCONDV),' )
9993 FORMAT( ' N=', I5, ', IWK=', I2, ', seed=', 4( I4, ',' ),
$ ' type ', I2, ', test(', I2, ')=', G10.3 )
9992 FORMAT( ' N=', I5, ', input example =', I3, ', test(', I2, ')=',
$ G10.3 )
9991 FORMAT( ' DDRVSX: ', A, ' returned INFO=', I6, '.', / 9X, 'N=',
$ I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5, ')' )
*
RETURN
*
* End of DDRVSX
*
END
| grisuthedragon/OpenBLAS | lapack-netlib/TESTING/EIG/ddrvsx.f | FORTRAN | bsd-3-clause | 33,842 |
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
module.exports = () => [
require.resolve('./console.js'),
require.resolve('./error-guard.js'),
require.resolve('./Object.es7.js'),
];
| arthuralee/react-native | packages/polyfills/index.js | JavaScript | bsd-3-clause | 359 |
// Copyright 2015 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.
/**
* @fileoverview Behavior common to Site Settings classes.
*/
/** @polymerBehavior */
var SiteSettingsBehaviorImpl = {
properties: {
/**
* The ID of the category this element is displaying data for.
* See site_settings/constants.js for possible values.
*/
category: {
type: Number,
},
},
/**
* Returns whether the category default is set to enabled or not.
* @param {number} category The category to check.
* @return {boolean} True if the category default is set to enabled.
* @protected
*/
isCategoryAllowed: function(category) {
var pref = this.getPref(this.computeCategoryPrefName(category));
// FullScreen is Allow vs. Ask.
if (category == settings.ContentSettingsTypes.FULLSCREEN)
return pref.value != settings.PermissionValues.ASK;
return pref.value != settings.PermissionValues.BLOCK;
},
/**
* Re-sets the category permission for a given origin.
* @param {string} origin The origin to change the permission for.
* @param {number} category The category permission to change.
* @protected
*/
resetCategoryPermissionForOrigin: function(origin, category) {
var pref = JSON.parse(JSON.stringify(this.getPref(
this.computeCategoryExceptionsPrefName(category))));
delete pref.value[origin + ',' + origin];
delete pref.value[origin + ',*'];
this.setPrefValue(
this.computeCategoryExceptionsPrefName(category), pref.value);
},
/**
* Sets the category permission for a given origin.
* @param {string} origin The origin to change the permission for.
* @param {number} value What value to set the permission to.
* @param {number} category The category permission to change.
* @protected
*/
setCategoryPermissionForOrigin: function(origin, value, category) {
var pref = JSON.parse(JSON.stringify(this.getPref(
this.computeCategoryExceptionsPrefName(category))));
var key1 = origin + ',' + origin;
var key2 = origin + ',*';
if (pref.value[key1] != undefined)
pref.value[key1].setting = value;
if (pref.value[key2] != undefined)
pref.value[key2].setting = value;
this.setPrefValue(
this.computeCategoryExceptionsPrefName(category), pref.value);
},
/**
* A utility function to lookup a category name from its enum.
* @param {number} category The category ID to look up.
* @return {string} The category found or blank string if not found.
* @protected
*/
computeCategoryTextId: function(category) {
switch (category) {
case settings.ContentSettingsTypes.CAMERA:
return 'camera';
case settings.ContentSettingsTypes.COOKIES:
return 'cookies';
case settings.ContentSettingsTypes.FULLSCREEN:
return 'fullscreen';
case settings.ContentSettingsTypes.GEOLOCATION:
return 'location';
case settings.ContentSettingsTypes.IMAGES:
return 'images';
case settings.ContentSettingsTypes.JAVASCRIPT:
return 'javascript';
case settings.ContentSettingsTypes.MIC:
return 'microphone';
case settings.ContentSettingsTypes.NOTIFICATIONS:
return 'notifications';
case settings.ContentSettingsTypes.POPUPS:
return 'popups';
default:
return '';
}
},
/**
* A utility function to compute the icon to use for the category.
* @param {number} category The category to show the icon for.
* @return {string} The id of the icon for the given category.
* @protected
*/
computeIconForContentCategory: function(category) {
switch (category) {
case settings.ContentSettingsTypes.CAMERA:
return 'av:videocam';
case settings.ContentSettingsTypes.COOKIES:
return 'md-settings-icons:cookie';
case settings.ContentSettingsTypes.FULLSCREEN:
return 'icons:fullscreen';
case settings.ContentSettingsTypes.GEOLOCATION:
return 'communication:location-on';
case settings.ContentSettingsTypes.IMAGES:
return 'image:photo';
case settings.ContentSettingsTypes.JAVASCRIPT:
return 'icons:input';
case settings.ContentSettingsTypes.MIC:
return 'av:mic';
case settings.ContentSettingsTypes.NOTIFICATIONS:
return 'social:notifications';
case settings.ContentSettingsTypes.POPUPS:
return 'icons:open-in-new';
default:
assertNotReached();
return '';
}
},
/**
* A utility function to compute the title of the category.
* @param {number} category The category to show the title for.
* @return {string} The title for the given category.
* @protected
*/
computeTitleForContentCategory: function(category) {
switch (category) {
case settings.ContentSettingsTypes.CAMERA:
return loadTimeData.getString('siteSettingsCamera');
case settings.ContentSettingsTypes.COOKIES:
return loadTimeData.getString('siteSettingsCookies');
case settings.ContentSettingsTypes.FULLSCREEN:
return loadTimeData.getString('siteSettingsFullscreen');
case settings.ContentSettingsTypes.GEOLOCATION:
return loadTimeData.getString('siteSettingsLocation');
case settings.ContentSettingsTypes.IMAGES:
return loadTimeData.getString('siteSettingsImages');
case settings.ContentSettingsTypes.JAVASCRIPT:
return loadTimeData.getString('siteSettingsJavascript');
case settings.ContentSettingsTypes.MIC:
return loadTimeData.getString('siteSettingsMic');
case settings.ContentSettingsTypes.NOTIFICATIONS:
return loadTimeData.getString('siteSettingsNotifications');
case settings.ContentSettingsTypes.POPUPS:
return loadTimeData.getString('siteSettingsPopups');
default:
assertNotReached();
return '';
}
},
/**
* A utility function to compute the name of the pref for the category.
* @param {number} category The category to find the pref name for.
* @return {string} The pref name for the given category.
* @protected
*/
computeCategoryPrefName: function(category) {
return 'profile.default_content_setting_values.' +
this.computeCategorySuffix(category);
},
/**
* A utility function to compute the name of the pref for the exceptions
* for a given category.
* @param {number} category The category to find the pref name for.
* @return {string} The pref name for the given category exceptions.
* @protected
*/
computeCategoryExceptionsPrefName: function(category) {
return 'profile.content_settings.exceptions.' +
this.computeCategorySuffix(category);
},
/**
* A utility function to convert the category enum into its text
* representation, for use with prefs.
* @param {number} category The category to find the pref name for.
* @return {string} The pref name (suffix) for the given category.
* @protected
*/
computeCategorySuffix: function(category) {
switch (category) {
case settings.ContentSettingsTypes.CAMERA:
return 'media_stream_camera';
case settings.ContentSettingsTypes.COOKIES:
return 'cookies';
case settings.ContentSettingsTypes.FULLSCREEN:
return 'fullscreen';
case settings.ContentSettingsTypes.GEOLOCATION:
return 'geolocation';
case settings.ContentSettingsTypes.IMAGES:
return 'images';
case settings.ContentSettingsTypes.JAVASCRIPT:
return 'javascript';
case settings.ContentSettingsTypes.MIC:
return 'media_stream_mic';
case settings.ContentSettingsTypes.NOTIFICATIONS:
return 'notifications';
case settings.ContentSettingsTypes.POPUPS:
return 'popups';
default:
assertNotReached();
return '';
}
},
/**
* A utility function to compute the description for the category.
* @param {number} category The category to show the description for.
* @param {boolean} categoryEnabled The state of the global toggle.
* @param {boolean} showRecommendation Whether to show the '(recommended)'
* label prefix.
* @return {string} The category description.
* @protected
*/
computeCategoryDesc: function(category, categoryEnabled, showRecommendation) {
switch (category) {
case settings.ContentSettingsTypes.JAVASCRIPT:
// "Allowed (recommended)" vs "Blocked".
if (!categoryEnabled) {
return loadTimeData.getString('siteSettingsBlocked');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsAllowedRecommended') :
loadTimeData.getString('siteSettingsAllowed');
case settings.ContentSettingsTypes.POPUPS:
// "Allowed" vs "Blocked (recommended)".
if (categoryEnabled) {
return loadTimeData.getString('siteSettingsAllowed');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsBlockedRecommended') :
loadTimeData.getString('siteSettingsBlocked');
case settings.ContentSettingsTypes.NOTIFICATIONS:
// "Ask before sending (recommended)" vs "Blocked".
if (!categoryEnabled) {
return loadTimeData.getString('siteSettingsBlocked');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsAskBeforeSendingRecommended') :
loadTimeData.getString('siteSettingsAskBeforeSending');
case settings.ContentSettingsTypes.GEOLOCATION:
case settings.ContentSettingsTypes.CAMERA:
case settings.ContentSettingsTypes.MIC:
// "Ask before accessing (recommended)" vs "Blocked".
if (!categoryEnabled) {
return loadTimeData.getString('siteSettingsBlocked');
}
return showRecommendation ?
loadTimeData.getString(
'siteSettingsAskBeforeAccessingRecommended') :
loadTimeData.getString('siteSettingsAskBeforeAccessing');
case settings.ContentSettingsTypes.FULLSCREEN:
// "Allowed" vs. "Ask first (recommended)".
if (categoryEnabled) {
return loadTimeData.getString('siteSettingsAllowed');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsAskFirstRecommended') :
loadTimeData.getString('siteSettingsAskFirst');
case settings.ContentSettingsTypes.COOKIES:
// "Allow sites to save and read cookie data" vs "Blocked".
if (!categoryEnabled) {
return loadTimeData.getString('siteSettingsBlocked');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsCookiesAllowedRecommended') :
loadTimeData.getString('siteSettingsCookiesAllowed');
case settings.ContentSettingsTypes.IMAGES:
if (!categoryEnabled) {
return loadTimeData.getString('siteSettingsDontShowImages');
}
return showRecommendation ?
loadTimeData.getString('siteSettingsShowAllRecommended') :
loadTimeData.getString('siteSettingsShowAll');
default:
assertNotReached();
return '';
}
},
/**
* A utility function to compute the category given the description.
* @param {string} description The category description to look up.
* @return {number} category The category id to return.
* @protected
*/
computeCategoryFromDesc: function(description) {
for (var type in settings.ContentSettingsTypes) {
if (description == this.computeTitleForContentCategory(
settings.ContentSettingsTypes[type])) {
return settings.ContentSettingsTypes[type];
}
}
assertNotReached();
return 0;
},
};
/** @polymerBehavior */
var SiteSettingsBehavior = [PrefsBehavior, SiteSettingsBehaviorImpl];
| js0701/chromium-crosswalk | chrome/browser/resources/settings/site_settings/site_settings_behavior.js | JavaScript | bsd-3-clause | 11,974 |
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/monitoring/v3/common.proto
package com.google.monitoring.v3;
public interface TimeIntervalOrBuilder extends
// @@protoc_insertion_point(interface_extends:google.monitoring.v3.TimeInterval)
com.google.protobuf.MessageOrBuilder {
/**
* <pre>
* Required. The end of the time interval.
* </pre>
*
* <code>.google.protobuf.Timestamp end_time = 2;</code>
*/
boolean hasEndTime();
/**
* <pre>
* Required. The end of the time interval.
* </pre>
*
* <code>.google.protobuf.Timestamp end_time = 2;</code>
*/
com.google.protobuf.Timestamp getEndTime();
/**
* <pre>
* Required. The end of the time interval.
* </pre>
*
* <code>.google.protobuf.Timestamp end_time = 2;</code>
*/
com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder();
/**
* <pre>
* Optional. The beginning of the time interval. The default value
* for the start time is the end time. The start time must not be
* later than the end time.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
boolean hasStartTime();
/**
* <pre>
* Optional. The beginning of the time interval. The default value
* for the start time is the end time. The start time must not be
* later than the end time.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
com.google.protobuf.Timestamp getStartTime();
/**
* <pre>
* Optional. The beginning of the time interval. The default value
* for the start time is the end time. The start time must not be
* later than the end time.
* </pre>
*
* <code>.google.protobuf.Timestamp start_time = 1;</code>
*/
com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder();
}
| eoogbe/api-client-staging | generated/java/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/TimeIntervalOrBuilder.java | Java | bsd-3-clause | 1,833 |
/*
* Copyright 2011 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// Despite the name and location, this is portable code.
#include "SkFixed.h"
#include "SkFontMgr.h"
#include "SkFontMgr_android_parser.h"
#include "SkMalloc.h"
#include "SkOSFile.h"
#include "SkStream.h"
#include "SkTDArray.h"
#include "SkTSearch.h"
#include "SkTemplates.h"
#include "SkTLogic.h"
#include <expat.h>
#include <stdlib.h>
#include <string.h>
#define LMP_SYSTEM_FONTS_FILE "/system/etc/fonts.xml"
#define OLD_SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml"
#define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml"
#define VENDOR_FONTS_FILE "/vendor/etc/fallback_fonts.xml"
#define LOCALE_FALLBACK_FONTS_SYSTEM_DIR "/system/etc"
#define LOCALE_FALLBACK_FONTS_VENDOR_DIR "/vendor/etc"
#define LOCALE_FALLBACK_FONTS_PREFIX "fallback_fonts-"
#define LOCALE_FALLBACK_FONTS_SUFFIX ".xml"
#ifndef SK_FONT_FILE_PREFIX
# define SK_FONT_FILE_PREFIX "/fonts/"
#endif
/**
* This file contains TWO 'familyset' handlers:
* One for JB and earlier which works with
* /system/etc/system_fonts.xml
* /system/etc/fallback_fonts.xml
* /vendor/etc/fallback_fonts.xml
* /system/etc/fallback_fonts-XX.xml
* /vendor/etc/fallback_fonts-XX.xml
* and the other for LMP and later which works with
* /system/etc/fonts.xml
*
* If the 'familyset' 'version' attribute is 21 or higher the LMP parser is used, otherwise the JB.
*/
struct FamilyData;
struct TagHandler {
/** Called at the start tag.
* Called immediately after the parent tag retuns this handler from a call to 'tag'.
* Allows setting up for handling the tag content and processing attributes.
* If nullptr, will not be called.
*/
void (*start)(FamilyData* data, const char* tag, const char** attributes);
/** Called at the end tag.
* Allows post-processing of any accumulated information.
* This will be the last call made in relation to the current tag.
* If nullptr, will not be called.
*/
void (*end)(FamilyData* data, const char* tag);
/** Called when a nested tag is encountered.
* This is responsible for determining how to handle the tag.
* If the tag is not recognized, return nullptr to skip the tag.
* If nullptr, all nested tags will be skipped.
*/
const TagHandler* (*tag)(FamilyData* data, const char* tag, const char** attributes);
/** The character handler for this tag.
* This is only active for character data contained directly in this tag (not sub-tags).
* The first parameter will be castable to a FamilyData*.
* If nullptr, any character data in this tag will be ignored.
*/
XML_CharacterDataHandler chars;
};
/** Represents the current parsing state. */
struct FamilyData {
FamilyData(XML_Parser parser, SkTDArray<FontFamily*>& families,
const SkString& basePath, bool isFallback, const char* filename,
const TagHandler* topLevelHandler)
: fParser(parser)
, fFamilies(families)
, fCurrentFamily(nullptr)
, fCurrentFontInfo(nullptr)
, fVersion(0)
, fBasePath(basePath)
, fIsFallback(isFallback)
, fFilename(filename)
, fDepth(1)
, fSkip(0)
, fHandler(&topLevelHandler, 1)
{ }
XML_Parser fParser; // The expat parser doing the work, owned by caller
SkTDArray<FontFamily*>& fFamilies; // The array to append families, owned by caller
std::unique_ptr<FontFamily> fCurrentFamily; // The family being created, owned by this
FontFileInfo* fCurrentFontInfo; // The info being created, owned by fCurrentFamily
int fVersion; // The version of the file parsed.
const SkString& fBasePath; // The current base path.
const bool fIsFallback; // The file being parsed is a fallback file
const char* fFilename; // The name of the file currently being parsed.
int fDepth; // The current element depth of the parse.
int fSkip; // The depth to stop skipping, 0 if not skipping.
SkTDArray<const TagHandler*> fHandler; // The stack of current tag handlers.
};
static bool memeq(const char* s1, const char* s2, size_t n1, size_t n2) {
return n1 == n2 && 0 == memcmp(s1, s2, n1);
}
#define MEMEQ(c, s, n) memeq(c, s, sizeof(c) - 1, n)
#define ATTS_NON_NULL(a, i) (a[i] != nullptr && a[i+1] != nullptr)
#define SK_FONTMGR_ANDROID_PARSER_PREFIX "[SkFontMgr Android Parser] "
#define SK_FONTCONFIGPARSER_WARNING(message, ...) \
SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "%s:%d:%d: warning: " message "\n", self->fFilename, \
XML_GetCurrentLineNumber(self->fParser), XML_GetCurrentColumnNumber(self->fParser), \
##__VA_ARGS__)
static bool is_whitespace(char c) {
return c == ' ' || c == '\n'|| c == '\r' || c == '\t';
}
static void trim_string(SkString* s) {
char* str = s->writable_str();
const char* start = str; // start is inclusive
const char* end = start + s->size(); // end is exclusive
while (is_whitespace(*start)) { ++start; }
if (start != end) {
--end; // make end inclusive
while (is_whitespace(*end)) { --end; }
++end; // make end exclusive
}
size_t len = end - start;
memmove(str, start, len);
s->resize(len);
}
namespace lmpParser {
static const TagHandler axisHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
FontFileInfo& file = *self->fCurrentFontInfo;
SkFourByteTag axisTag = SkSetFourByteTag('\0','\0','\0','\0');
SkFixed axisStyleValue = 0;
bool axisTagIsValid = false;
bool axisStyleValueIsValid = false;
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
const char* value = attributes[i+1];
size_t nameLen = strlen(name);
if (MEMEQ("tag", name, nameLen)) {
size_t valueLen = strlen(value);
if (valueLen == 4) {
axisTag = SkSetFourByteTag(value[0], value[1], value[2], value[3]);
axisTagIsValid = true;
for (int j = 0; j < file.fVariationDesignPosition.count() - 1; ++j) {
if (file.fVariationDesignPosition[j].axis == axisTag) {
axisTagIsValid = false;
SK_FONTCONFIGPARSER_WARNING("'%c%c%c%c' axis specified more than once",
(axisTag >> 24) & 0xFF,
(axisTag >> 16) & 0xFF,
(axisTag >> 8) & 0xFF,
(axisTag ) & 0xFF);
}
}
} else {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis tag", value);
}
} else if (MEMEQ("stylevalue", name, nameLen)) {
if (parse_fixed<16>(value, &axisStyleValue)) {
axisStyleValueIsValid = true;
} else {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis stylevalue", value);
}
}
}
if (axisTagIsValid && axisStyleValueIsValid) {
auto& coordinate = file.fVariationDesignPosition.push_back();
coordinate.axis = axisTag;
coordinate.value = SkFixedToScalar(axisStyleValue);
}
},
/*end*/nullptr,
/*tag*/nullptr,
/*chars*/nullptr,
};
static const TagHandler fontHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
// 'weight' (non-negative integer) [default 0]
// 'style' ("normal", "italic") [default "auto"]
// 'index' (non-negative integer) [default 0]
// The character data should be a filename.
FontFileInfo& file = self->fCurrentFamily->fFonts.push_back();
self->fCurrentFontInfo = &file;
SkString fallbackFor;
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
const char* value = attributes[i+1];
size_t nameLen = strlen(name);
if (MEMEQ("weight", name, nameLen)) {
if (!parse_non_negative_integer(value, &file.fWeight)) {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid weight", value);
}
} else if (MEMEQ("style", name, nameLen)) {
size_t valueLen = strlen(value);
if (MEMEQ("normal", value, valueLen)) {
file.fStyle = FontFileInfo::Style::kNormal;
} else if (MEMEQ("italic", value, valueLen)) {
file.fStyle = FontFileInfo::Style::kItalic;
}
} else if (MEMEQ("index", name, nameLen)) {
if (!parse_non_negative_integer(value, &file.fIndex)) {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid index", value);
}
} else if (MEMEQ("fallbackFor", name, nameLen)) {
/** fallbackFor specifies a family fallback and should have been on family. */
fallbackFor = value;
}
}
if (!fallbackFor.isEmpty()) {
std::unique_ptr<FontFamily>* fallbackFamily =
self->fCurrentFamily->fallbackFamilies.find(fallbackFor);
if (!fallbackFamily) {
std::unique_ptr<FontFamily> newFallbackFamily(
new FontFamily(self->fCurrentFamily->fBasePath, true));
fallbackFamily = self->fCurrentFamily->fallbackFamilies.set(
fallbackFor, std::move(newFallbackFamily));
(*fallbackFamily)->fLanguages = self->fCurrentFamily->fLanguages;
(*fallbackFamily)->fVariant = self->fCurrentFamily->fVariant;
(*fallbackFamily)->fOrder = self->fCurrentFamily->fOrder;
(*fallbackFamily)->fFallbackFor = fallbackFor;
}
self->fCurrentFontInfo = &(*fallbackFamily)->fFonts.emplace_back(file);
self->fCurrentFamily->fFonts.pop_back();
}
},
/*end*/[](FamilyData* self, const char* tag) {
trim_string(&self->fCurrentFontInfo->fFileName);
},
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("axis", tag, len)) {
return &axisHandler;
}
return nullptr;
},
/*chars*/[](void* data, const char* s, int len) {
FamilyData* self = static_cast<FamilyData*>(data);
self->fCurrentFontInfo->fFileName.append(s, len);
}
};
static const TagHandler familyHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
// 'name' (string) [optional]
// 'lang' (space separated string) [default ""]
// 'variant' ("elegant", "compact") [default "default"]
// If there is no name, this is a fallback only font.
FontFamily* family = new FontFamily(self->fBasePath, true);
self->fCurrentFamily.reset(family);
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
const char* value = attributes[i+1];
size_t nameLen = strlen(name);
size_t valueLen = strlen(value);
if (MEMEQ("name", name, nameLen)) {
SkAutoAsciiToLC tolc(value);
family->fNames.push_back().set(tolc.lc());
family->fIsFallbackFont = false;
} else if (MEMEQ("lang", name, nameLen)) {
size_t i = 0;
while (true) {
for (; i < valueLen && is_whitespace(value[i]); ++i) { }
if (i == valueLen) { break; }
size_t j;
for (j = i + 1; j < valueLen && !is_whitespace(value[j]); ++j) { }
family->fLanguages.emplace_back(value + i, j - i);
i = j;
if (i == valueLen) { break; }
}
} else if (MEMEQ("variant", name, nameLen)) {
if (MEMEQ("elegant", value, valueLen)) {
family->fVariant = kElegant_FontVariant;
} else if (MEMEQ("compact", value, valueLen)) {
family->fVariant = kCompact_FontVariant;
}
}
}
},
/*end*/[](FamilyData* self, const char* tag) {
*self->fFamilies.append() = self->fCurrentFamily.release();
},
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("font", tag, len)) {
return &fontHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
static FontFamily* find_family(FamilyData* self, const SkString& familyName) {
for (int i = 0; i < self->fFamilies.count(); i++) {
FontFamily* candidate = self->fFamilies[i];
for (int j = 0; j < candidate->fNames.count(); j++) {
if (candidate->fNames[j] == familyName) {
return candidate;
}
}
}
return nullptr;
}
static const TagHandler aliasHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
// 'name' (string) introduces a new family name.
// 'to' (string) specifies which (previous) family to alias
// 'weight' (non-negative integer) [optional]
// If it *does not* have a weight, 'name' is an alias for the entire 'to' family.
// If it *does* have a weight, 'name' is a new family consisting of
// the font(s) with 'weight' from the 'to' family.
SkString aliasName;
SkString to;
int weight = 0;
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
const char* value = attributes[i+1];
size_t nameLen = strlen(name);
if (MEMEQ("name", name, nameLen)) {
SkAutoAsciiToLC tolc(value);
aliasName.set(tolc.lc());
} else if (MEMEQ("to", name, nameLen)) {
to.set(value);
} else if (MEMEQ("weight", name, nameLen)) {
if (!parse_non_negative_integer(value, &weight)) {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid weight", value);
}
}
}
// Assumes that the named family is already declared
FontFamily* targetFamily = find_family(self, to);
if (!targetFamily) {
SK_FONTCONFIGPARSER_WARNING("'%s' alias target not found", to.c_str());
return;
}
if (weight) {
FontFamily* family = new FontFamily(targetFamily->fBasePath, self->fIsFallback);
family->fNames.push_back().set(aliasName);
for (int i = 0; i < targetFamily->fFonts.count(); i++) {
if (targetFamily->fFonts[i].fWeight == weight) {
family->fFonts.push_back(targetFamily->fFonts[i]);
}
}
*self->fFamilies.append() = family;
} else {
targetFamily->fNames.push_back().set(aliasName);
}
},
/*end*/nullptr,
/*tag*/nullptr,
/*chars*/nullptr,
};
static const TagHandler familySetHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) { },
/*end*/nullptr,
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("family", tag, len)) {
return &familyHandler;
} else if (MEMEQ("alias", tag, len)) {
return &aliasHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
} // lmpParser
namespace jbParser {
static const TagHandler fileHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
// 'variant' ("elegant", "compact") [default "default"]
// 'lang' (string) [default ""]
// 'index' (non-negative integer) [default 0]
// The character data should be a filename.
FontFamily& currentFamily = *self->fCurrentFamily.get();
FontFileInfo& newFileInfo = currentFamily.fFonts.push_back();
if (attributes) {
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
const char* value = attributes[i+1];
size_t nameLen = strlen(name);
size_t valueLen = strlen(value);
if (MEMEQ("variant", name, nameLen)) {
const FontVariant prevVariant = currentFamily.fVariant;
if (MEMEQ("elegant", value, valueLen)) {
currentFamily.fVariant = kElegant_FontVariant;
} else if (MEMEQ("compact", value, valueLen)) {
currentFamily.fVariant = kCompact_FontVariant;
}
if (currentFamily.fFonts.count() > 1 && currentFamily.fVariant != prevVariant) {
SK_FONTCONFIGPARSER_WARNING("'%s' unexpected variant found\n"
"Note: Every font file within a family must have identical variants.",
value);
}
} else if (MEMEQ("lang", name, nameLen)) {
SkLanguage currentLanguage = SkLanguage(value, valueLen);
bool showWarning = false;
if (currentFamily.fLanguages.empty()) {
showWarning = (currentFamily.fFonts.count() > 1);
currentFamily.fLanguages.push_back(std::move(currentLanguage));
} else if (currentFamily.fLanguages[0] != currentLanguage) {
showWarning = true;
currentFamily.fLanguages[0] = std::move(currentLanguage);
}
if (showWarning) {
SK_FONTCONFIGPARSER_WARNING("'%s' unexpected language found\n"
"Note: Every font file within a family must have identical languages.",
value);
}
} else if (MEMEQ("index", name, nameLen)) {
if (!parse_non_negative_integer(value, &newFileInfo.fIndex)) {
SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid index", value);
}
}
}
}
self->fCurrentFontInfo = &newFileInfo;
},
/*end*/nullptr,
/*tag*/nullptr,
/*chars*/[](void* data, const char* s, int len) {
FamilyData* self = static_cast<FamilyData*>(data);
self->fCurrentFontInfo->fFileName.append(s, len);
}
};
static const TagHandler fileSetHandler = {
/*start*/nullptr,
/*end*/nullptr,
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("file", tag, len)) {
return &fileHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
static const TagHandler nameHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
// The character data should be a name for the font.
self->fCurrentFamily->fNames.push_back();
},
/*end*/nullptr,
/*tag*/nullptr,
/*chars*/[](void* data, const char* s, int len) {
FamilyData* self = static_cast<FamilyData*>(data);
SkAutoAsciiToLC tolc(s, len);
self->fCurrentFamily->fNames.back().append(tolc.lc(), len);
}
};
static const TagHandler nameSetHandler = {
/*start*/nullptr,
/*end*/nullptr,
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("name", tag, len)) {
return &nameHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
static const TagHandler familyHandler = {
/*start*/[](FamilyData* self, const char* tag, const char** attributes) {
self->fCurrentFamily.reset(new FontFamily(self->fBasePath, self->fIsFallback));
// 'order' (non-negative integer) [default -1]
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* value = attributes[i+1];
parse_non_negative_integer(value, &self->fCurrentFamily->fOrder);
}
},
/*end*/[](FamilyData* self, const char* tag) {
*self->fFamilies.append() = self->fCurrentFamily.release();
},
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("nameset", tag, len)) {
return &nameSetHandler;
} else if (MEMEQ("fileset", tag, len)) {
return &fileSetHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
static const TagHandler familySetHandler = {
/*start*/nullptr,
/*end*/nullptr,
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("family", tag, len)) {
return &familyHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
} // namespace jbParser
static const TagHandler topLevelHandler = {
/*start*/nullptr,
/*end*/nullptr,
/*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("familyset", tag, len)) {
// 'version' (non-negative integer) [default 0]
for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
const char* name = attributes[i];
size_t nameLen = strlen(name);
if (MEMEQ("version", name, nameLen)) {
const char* value = attributes[i+1];
if (parse_non_negative_integer(value, &self->fVersion)) {
if (self->fVersion >= 21) {
return &lmpParser::familySetHandler;
}
}
}
}
return &jbParser::familySetHandler;
}
return nullptr;
},
/*chars*/nullptr,
};
static void XMLCALL start_element_handler(void *data, const char *tag, const char **attributes) {
FamilyData* self = static_cast<FamilyData*>(data);
if (!self->fSkip) {
const TagHandler* parent = self->fHandler.top();
const TagHandler* child = parent->tag ? parent->tag(self, tag, attributes) : nullptr;
if (child) {
if (child->start) {
child->start(self, tag, attributes);
}
self->fHandler.push_back(child);
XML_SetCharacterDataHandler(self->fParser, child->chars);
} else {
SK_FONTCONFIGPARSER_WARNING("'%s' tag not recognized, skipping", tag);
XML_SetCharacterDataHandler(self->fParser, nullptr);
self->fSkip = self->fDepth;
}
}
++self->fDepth;
}
static void XMLCALL end_element_handler(void* data, const char* tag) {
FamilyData* self = static_cast<FamilyData*>(data);
--self->fDepth;
if (!self->fSkip) {
const TagHandler* child = self->fHandler.top();
if (child->end) {
child->end(self, tag);
}
self->fHandler.pop();
const TagHandler* parent = self->fHandler.top();
XML_SetCharacterDataHandler(self->fParser, parent->chars);
}
if (self->fSkip == self->fDepth) {
self->fSkip = 0;
const TagHandler* parent = self->fHandler.top();
XML_SetCharacterDataHandler(self->fParser, parent->chars);
}
}
static void XMLCALL xml_entity_decl_handler(void *data,
const XML_Char *entityName,
int is_parameter_entity,
const XML_Char *value,
int value_length,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName)
{
FamilyData* self = static_cast<FamilyData*>(data);
SK_FONTCONFIGPARSER_WARNING("'%s' entity declaration found, stopping processing", entityName);
XML_StopParser(self->fParser, XML_FALSE);
}
static const XML_Memory_Handling_Suite sk_XML_alloc = {
sk_malloc_throw,
sk_realloc_throw,
sk_free
};
/**
* This function parses the given filename and stores the results in the given
* families array. Returns the version of the file, negative if the file does not exist.
*/
static int parse_config_file(const char* filename, SkTDArray<FontFamily*>& families,
const SkString& basePath, bool isFallback)
{
SkFILEStream file(filename);
// Some of the files we attempt to parse (in particular, /vendor/etc/fallback_fonts.xml)
// are optional - failure here is okay because one of these optional files may not exist.
if (!file.isValid()) {
SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "'%s' could not be opened\n", filename);
return -1;
}
SkAutoTCallVProc<skstd::remove_pointer_t<XML_Parser>, XML_ParserFree> parser(
XML_ParserCreate_MM(nullptr, &sk_XML_alloc, nullptr));
if (!parser) {
SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "could not create XML parser\n");
return -1;
}
FamilyData self(parser, families, basePath, isFallback, filename, &topLevelHandler);
XML_SetUserData(parser, &self);
// Disable entity processing, to inhibit internal entity expansion. See expat CVE-2013-0340
XML_SetEntityDeclHandler(parser, xml_entity_decl_handler);
// Start parsing oldschool; switch these in flight if we detect a newer version of the file.
XML_SetElementHandler(parser, start_element_handler, end_element_handler);
// One would assume it would be faster to have a buffer on the stack and call XML_Parse.
// But XML_Parse will call XML_GetBuffer anyway and memmove the passed buffer into it.
// (Unless XML_CONTEXT_BYTES is undefined, but all users define it.)
// In debug, buffer a small odd number of bytes to detect slicing in XML_CharacterDataHandler.
static const int bufferSize = 512 SkDEBUGCODE( - 507);
bool done = false;
while (!done) {
void* buffer = XML_GetBuffer(parser, bufferSize);
if (!buffer) {
SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "could not buffer enough to continue\n");
return -1;
}
size_t len = file.read(buffer, bufferSize);
done = file.isAtEnd();
XML_Status status = XML_ParseBuffer(parser, len, done);
if (XML_STATUS_ERROR == status) {
XML_Error error = XML_GetErrorCode(parser);
int line = XML_GetCurrentLineNumber(parser);
int column = XML_GetCurrentColumnNumber(parser);
const XML_LChar* errorString = XML_ErrorString(error);
SkDebugf(SK_FONTMGR_ANDROID_PARSER_PREFIX "%s:%d:%d error %d: %s.\n",
filename, line, column, error, errorString);
return -1;
}
}
return self.fVersion;
}
/** Returns the version of the system font file actually found, negative if none. */
static int append_system_font_families(SkTDArray<FontFamily*>& fontFamilies,
const SkString& basePath)
{
int initialCount = fontFamilies.count();
int version = parse_config_file(LMP_SYSTEM_FONTS_FILE, fontFamilies, basePath, false);
if (version < 0 || fontFamilies.count() == initialCount) {
version = parse_config_file(OLD_SYSTEM_FONTS_FILE, fontFamilies, basePath, false);
}
return version;
}
/**
* In some versions of Android prior to Android 4.2 (JellyBean MR1 at API
* Level 17) the fallback fonts for certain locales were encoded in their own
* XML files with a suffix that identified the locale. We search the provided
* directory for those files,add all of their entries to the fallback chain, and
* include the locale as part of each entry.
*/
static void append_fallback_font_families_for_locale(SkTDArray<FontFamily*>& fallbackFonts,
const char* dir,
const SkString& basePath)
{
SkOSFile::Iter iter(dir, nullptr);
SkString fileName;
while (iter.next(&fileName, false)) {
// The size of the prefix and suffix.
static const size_t fixedLen = sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1
+ sizeof(LOCALE_FALLBACK_FONTS_SUFFIX) - 1;
// The size of the prefix, suffix, and a minimum valid language code
static const size_t minSize = fixedLen + 2;
if (fileName.size() < minSize ||
!fileName.startsWith(LOCALE_FALLBACK_FONTS_PREFIX) ||
!fileName.endsWith(LOCALE_FALLBACK_FONTS_SUFFIX))
{
continue;
}
SkString locale(fileName.c_str() + sizeof(LOCALE_FALLBACK_FONTS_PREFIX) - 1,
fileName.size() - fixedLen);
SkString absoluteFilename;
absoluteFilename.printf("%s/%s", dir, fileName.c_str());
SkTDArray<FontFamily*> langSpecificFonts;
parse_config_file(absoluteFilename.c_str(), langSpecificFonts, basePath, true);
for (int i = 0; i < langSpecificFonts.count(); ++i) {
FontFamily* family = langSpecificFonts[i];
family->fLanguages.emplace_back(locale);
*fallbackFonts.append() = family;
}
}
}
static void append_system_fallback_font_families(SkTDArray<FontFamily*>& fallbackFonts,
const SkString& basePath)
{
parse_config_file(FALLBACK_FONTS_FILE, fallbackFonts, basePath, true);
append_fallback_font_families_for_locale(fallbackFonts,
LOCALE_FALLBACK_FONTS_SYSTEM_DIR,
basePath);
}
static void mixin_vendor_fallback_font_families(SkTDArray<FontFamily*>& fallbackFonts,
const SkString& basePath)
{
SkTDArray<FontFamily*> vendorFonts;
parse_config_file(VENDOR_FONTS_FILE, vendorFonts, basePath, true);
append_fallback_font_families_for_locale(vendorFonts,
LOCALE_FALLBACK_FONTS_VENDOR_DIR,
basePath);
// This loop inserts the vendor fallback fonts in the correct order in the
// overall fallbacks list.
int currentOrder = -1;
for (int i = 0; i < vendorFonts.count(); ++i) {
FontFamily* family = vendorFonts[i];
int order = family->fOrder;
if (order < 0) {
if (currentOrder < 0) {
// Default case - just add it to the end of the fallback list
*fallbackFonts.append() = family;
} else {
// no order specified on this font, but we're incrementing the order
// based on an earlier order insertion request
*fallbackFonts.insert(currentOrder++) = family;
}
} else {
// Add the font into the fallback list in the specified order. Set
// currentOrder for correct placement of other fonts in the vendor list.
*fallbackFonts.insert(order) = family;
currentOrder = order + 1;
}
}
}
void SkFontMgr_Android_Parser::GetSystemFontFamilies(SkTDArray<FontFamily*>& fontFamilies) {
// Version 21 of the system font configuration does not need any fallback configuration files.
SkString basePath(getenv("ANDROID_ROOT"));
basePath.append(SK_FONT_FILE_PREFIX, sizeof(SK_FONT_FILE_PREFIX) - 1);
if (append_system_font_families(fontFamilies, basePath) >= 21) {
return;
}
// Append all the fallback fonts to system fonts
SkTDArray<FontFamily*> fallbackFonts;
append_system_fallback_font_families(fallbackFonts, basePath);
mixin_vendor_fallback_font_families(fallbackFonts, basePath);
fontFamilies.append(fallbackFonts.count(), fallbackFonts.begin());
}
void SkFontMgr_Android_Parser::GetCustomFontFamilies(SkTDArray<FontFamily*>& fontFamilies,
const SkString& basePath,
const char* fontsXml,
const char* fallbackFontsXml,
const char* langFallbackFontsDir)
{
if (fontsXml) {
parse_config_file(fontsXml, fontFamilies, basePath, false);
}
if (fallbackFontsXml) {
parse_config_file(fallbackFontsXml, fontFamilies, basePath, true);
}
if (langFallbackFontsDir) {
append_fallback_font_families_for_locale(fontFamilies,
langFallbackFontsDir,
basePath);
}
}
SkLanguage SkLanguage::getParent() const {
SkASSERT(!fTag.isEmpty());
const char* tag = fTag.c_str();
// strip off the rightmost "-.*"
const char* parentTagEnd = strrchr(tag, '-');
if (parentTagEnd == nullptr) {
return SkLanguage();
}
size_t parentTagLen = parentTagEnd - tag;
return SkLanguage(tag, parentTagLen);
}
| Hikari-no-Tenshi/android_external_skia | src/ports/SkFontMgr_android_parser.cpp | C++ | bsd-3-clause | 34,402 |
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Site
*/
'use strict';
var HeaderLinks = require('HeaderLinks');
var Metadata = require('Metadata');
var React = require('React');
var Site = React.createClass({
render: function() {
const path = Metadata.config.RN_DEPLOYMENT_PATH;
const version = Metadata.config.RN_VERSION;
const algoliaVersion = version === 'next'
? 'master'
: version;
var basePath = '/react-native/' +
(path ? path + '/' : '');
var currentYear = new Date().getFullYear();
var title = this.props.title
? this.props.title
: 'React Native | A framework for building native apps using React';
var metaTags = [
{ charSet: 'utf-8' },
{
httpEquiv: 'X-UA-Compatible',
content: 'IE=edge,chrome=1',
},
{
name: 'viewport',
content: 'width=device-width',
},
// Facebook
{
property: 'fb:app_id',
content: '1677033832619985',
},
{ property: 'fb:admins', content: '121800083' },
// Open Graph
{
property: 'og:site_name',
content: 'React Native',
},
{
property: 'og:title',
content: title,
},
{
property: 'og:url',
content: 'https://facebook.github.io/react-native/' +
(this.props.path
? this.props.path
: 'index.html'),
},
{
property: 'og:image',
content: this.props.image
? this.props.image
: 'https://facebook.github.io/react-native/img/opengraph.png',
},
{
property: 'og:description',
content: this.props.description
? this.props.description
: 'A framework for building native apps using React',
},
// Twitter Cards
{
name: 'twitter:site',
content: '@reactnative',
},
{
name: 'twitter:card',
content: 'summary_large_image',
},
];
var typeTags = [
{
property: 'og:type',
content: 'website',
},
];
if (this.props.author) {
typeTags = [
{
property: 'og:type',
content: 'article',
},
{
property: 'article:author',
content: this.props.author,
},
];
}
metaTags.push(...typeTags);
if (this.props.authorTwitter) {
metaTags.push({
name: 'twitter:creator',
content: '@' + this.props.authorTwitter,
});
}
return (
<html>
<head>
<title>{title}</title>
{metaTags.map((tag, index) => (
<meta key={index} {...tag} />
))}
<base href={basePath} />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"
/>
<link
rel="shortcut icon"
href="img/favicon.png?2"
/>
<link
rel="stylesheet"
href="css/react-native.css"
/>
<link rel="stylesheet" href="css/prism.css" />
<link
rel="alternate"
type="application/rss+xml"
title="React Native Blog"
href="https://facebook.github.io/react-native/blog/feed.xml"
/>
<link
href="//cdn-images.mailchimp.com/embedcode/horizontal-slim-10_7.css"
rel="stylesheet"
type="text/css"
/>
<script
type="text/javascript"
src="//use.typekit.net/vqa1hcx.js"
/>
<script type="text/javascript">
{'try{Typekit.load();}catch(e){}'}
</script>
</head>
<body>
<script
dangerouslySetInnerHTML={{
__html: "window.fbAsyncInit = function() {FB.init({appId:'1677033832619985',xfbml:true,version:'v2.7'});};(function(d, s, id){var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) {return;}js = d.createElement(s); js.id = id;js.src = '//connect.facebook.net/en_US/sdk.js';fjs.parentNode.insertBefore(js, fjs);}(document, 'script','facebook-jssdk'));",
}}
/>
<script
dangerouslySetInnerHTML={{
__html: "window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));",
}}
/>
<div className="container">
<div className="nav-main">
<div className="wrap">
<a className="nav-home" href="">
<img src="img/header_logo.png" />
React Native
</a>
<a
className="nav-version"
href="/react-native/versions.html"
>
{version}
</a>
<HeaderLinks section={this.props.section} />
</div>
</div>
{this.props.children}
<footer className="nav-footer">
<section className="sitemap">
<a
href="/react-native"
className="nav-home"
>
<img
src="img/header_logo.png"
alt="React Native"
width="66"
height="58"
/>
</a>
<div>
<h5><a href="docs/">Docs</a></h5>
<a href="docs/getting-started.html">
Getting Started
</a>
<a href="docs/tutorial.html">Learn the Basics</a>
<a
href="docs/components-and-apis.html"
>
Components and APIs
</a>
<a href="docs/more-resources.html">
More Resources
</a>
</div>
<div>
<h5>
<a href="/react-native/support.html">
Community
</a>
</h5>
<a href="/react-native/showcase.html">
Who's using React Native?
</a>
<a
href="http://www.meetup.com/topics/react-native/"
target="_blank"
>
Meetups
</a>
<a
href="https://www.facebook.com/groups/react.native.community"
target="_blank"
>
Facebook Group
</a>
<a
href="https://twitter.com/reactnative"
target="_blank"
>
Twitter
</a>
</div>
<div>
<h5>
<a href="/react-native/support.html">
Help
</a>
</h5>
<a
href="http://stackoverflow.com/questions/tagged/react-native"
target="_blank"
>
Stack Overflow
</a>
<a
href="https://discord.gg/0ZcbPKXt5bZjGY5n"
>
Reactiflux Chat
</a>
<a
href="/react-native/versions.html"
target="_blank"
>
Latest Releases
</a>
<a
href="https://react-native.canny.io/feature-requests"
target="_blank"
>
Feature Requests
</a>
</div>
<div>
<h5>More</h5>
<a href="/react-native/blog">Blog</a>
<a
href="http://facebook.github.io/react/"
target="_blank"
>
React
</a>
<a
href="https://github.com/facebook/react-native"
target="_blank"
>
GitHub
</a>
<div className="githubButton">
<a
className="github-button"
href="https://github.com/facebook/react-native"
data-icon="octicon-star"
data-count-href="/facebook/react-native/stargazers"
data-count-api="/repos/facebook/react-native#stargazers_count"
data-count-aria-label="# stargazers on GitHub"
aria-label="Star facebook/react-native on GitHub"
>
Star
</a>
</div>
</div>
</section>
<section className="newsletter">
<div id="mc_embed_signup">
<form
action="//reactnative.us10.list-manage.com/subscribe/post?u=db0dd948e2b729ee62625b1a8&id=47cd41008f"
method="post"
id="mc-embedded-subscribe-form"
name="mc-embedded-subscribe-form"
className="validate"
target="_blank"
noValidate
>
<div id="mc_embed_signup_scroll">
<label htmlFor="mce-EMAIL">
<h5>
Get the React Native Newsletter
</h5>
</label>
<input
type="email"
value=""
name="EMAIL"
className="email"
id="mce-EMAIL"
placeholder="email address"
required
/>
<div
style={{
position: 'absolute',
left: '-5000px',
}}
aria-hidden="true"
>
<input
type="text"
name="b_db0dd948e2b729ee62625b1a8_47cd41008f"
tabIndex="-1"
value=""
/>
</div>
<div className="clear">
<input
type="submit"
value="Sign up"
name="subscribe"
id="mc-embedded-subscribe"
className="button"
/>
</div>
</div>
</form>
</div>
</section>
<a
href="https://code.facebook.com/projects/"
target="_blank"
className="fbOpenSource"
>
<img
src="img/oss_logo.png"
alt="Facebook Open Source"
width="170"
height="45"
/>
</a>
<section className="copyright">
Copyright © {currentYear} Facebook Inc.
</section>
</footer>
</div>
<div id="fb-root" />
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"
/>
<script
dangerouslySetInnerHTML={{
__html: `
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41298772-2', 'facebook.github.io');
ga('send', 'pageview');
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)
){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
docsearch({
apiKey: '2c98749b4a1e588efec53b2acec13025',
indexName: 'react-native-versions',
inputSelector: '#algolia-doc-search',
algoliaOptions: { facetFilters: [ "tags:${algoliaVersion}" ], hitsPerPage: 5 }
});
`,
}}
/>
<script src="js/scripts.js" />
{/* Mailchimp Inline form-submission script for the React Native newsletter sign up form */}
<script
type="text/javascript"
src="//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js"
/>
<script
type="text/javascript"
dangerouslySetInnerHTML={{
__html: "(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);",
}}
/>
<script
type="text/javascript"
src="https://snack.expo.io/embed.js"
/>
<script
async
defer
src="https://buttons.github.io/buttons.js"
/>
</body>
</html>
);
},
});
module.exports = Site;
| cpunion/react-native | website/core/Site.js | JavaScript | bsd-3-clause | 14,480 |
// Copyright 2020 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
REG_FIDDLE_ANIMATED(Octopus_Generator_Animated, 256, 256, false, 0, 4) {
void paintOctopus(int x, int y, int size_base, SkColor color, SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(color);
int radius = 3*size_base;
canvas->drawCircle(x, y, radius, paint);
for (int leg = 0; leg < 8; ++leg) {
canvas->drawCircle(x - radius + (2*radius/7.5*leg),
y + radius - pow(abs(4-leg), 2), size_base/2 + 2, paint);
}
paint.setColor(SkColorSetRGB(std::min(255u, SkColorGetR(color) + 20),
std::min(255u, SkColorGetG(color) + 20),
std::min(255u, SkColorGetB(color) + 20)));
canvas->drawCircle(x-size_base, y+size_base, size_base/2, paint);
canvas->drawCircle(x+size_base, y+size_base, size_base/2, paint);
}
void draw(SkCanvas* canvas) {
SkRandom rand;
for (int i = 0; i < 400; ++i) {
float x = rand.nextRangeScalar(0, 256);
float y = rand.nextRangeScalar(0, 256);
float s = rand.nextRangeScalar(6, 12);
SkColor c = rand.nextU() | SkColorSetARGB(255, 0, 0, 0);
float radius = rand.nextRangeScalar(0, 40);
float angle = (rand.nextRangeScalar(0, 1) + frame) * 6.28319;
x += radius * cos(angle);
y += radius * sin(angle);
paintOctopus(x, y, s, c, canvas);
}
}
} // END FIDDLE
| youtube/cobalt | third_party/skia_next/third_party/skia/docs/examples/Octopus_Generator_Animated.cpp | C++ | bsd-3-clause | 1,559 |
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/widget/input/event_with_callback.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "cc/metrics/event_metrics.h"
#include "third_party/blink/public/common/input/web_input_event_attribution.h"
namespace blink {
EventWithCallback::EventWithCallback(
std::unique_ptr<WebCoalescedInputEvent> event,
base::TimeTicks timestamp_now,
InputHandlerProxy::EventDispositionCallback callback,
std::unique_ptr<cc::EventMetrics> metrics)
: event_(std::make_unique<WebCoalescedInputEvent>(*event)),
creation_timestamp_(timestamp_now),
last_coalesced_timestamp_(timestamp_now) {
original_events_.emplace_back(std::move(event), std::move(metrics),
std::move(callback));
}
EventWithCallback::EventWithCallback(
std::unique_ptr<WebCoalescedInputEvent> event,
base::TimeTicks creation_timestamp,
base::TimeTicks last_coalesced_timestamp,
OriginalEventList original_events)
: event_(std::move(event)),
original_events_(std::move(original_events)),
creation_timestamp_(creation_timestamp),
last_coalesced_timestamp_(last_coalesced_timestamp) {}
EventWithCallback::~EventWithCallback() = default;
bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const {
return event().CanCoalesce(other.event());
}
void EventWithCallback::SetScrollbarManipulationHandledOnCompositorThread() {
for (auto& original_event : original_events_) {
original_event.event_->EventPointer()
->SetScrollbarManipulationHandledOnCompositorThread();
}
}
void EventWithCallback::CoalesceWith(EventWithCallback* other,
base::TimeTicks timestamp_now) {
event_->CoalesceWith(*other->event_);
auto* metrics = original_events_.empty()
? nullptr
: original_events_.front().metrics_.get();
auto* scroll_update_metrics = metrics ? metrics->AsScrollUpdate() : nullptr;
auto* other_metrics = other->original_events_.empty()
? nullptr
: other->original_events_.front().metrics_.get();
auto* other_scroll_update_metrics =
other_metrics ? other_metrics->AsScrollUpdate() : nullptr;
if (scroll_update_metrics && other_scroll_update_metrics)
scroll_update_metrics->CoalesceWith(*other_scroll_update_metrics);
// Move original events.
original_events_.splice(original_events_.end(), other->original_events_);
last_coalesced_timestamp_ = timestamp_now;
}
static bool HandledOnCompositorThread(
InputHandlerProxy::EventDisposition disposition) {
return (disposition != InputHandlerProxy::DID_NOT_HANDLE &&
disposition !=
InputHandlerProxy::DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING &&
disposition != InputHandlerProxy::DID_NOT_HANDLE_NON_BLOCKING);
}
void EventWithCallback::RunCallbacks(
InputHandlerProxy::EventDisposition disposition,
const ui::LatencyInfo& latency,
std::unique_ptr<InputHandlerProxy::DidOverscrollParams>
did_overscroll_params,
const WebInputEventAttribution& attribution) {
// |original_events_| could be empty if this is the scroll event extracted
// from the matrix multiplication.
if (original_events_.size() == 0)
return;
// Ack the oldest event with original latency.
auto& oldest_event = original_events_.front();
oldest_event.event_->latency_info() = latency;
std::move(oldest_event.callback_)
.Run(disposition, std::move(oldest_event.event_),
did_overscroll_params
? std::make_unique<InputHandlerProxy::DidOverscrollParams>(
*did_overscroll_params)
: nullptr,
attribution, std::move(oldest_event.metrics_));
original_events_.pop_front();
// If the event was handled on the compositor thread, ack other events with
// coalesced latency to avoid redundant tracking. `cc::EventMetrics` objects
// will also be nullptr in this case because `TakeMetrics()` function is
// already called and deleted them. This is fine since no further processing
// and metrics reporting will be done on the events.
//
// On the other hand, if the event was not handled, original events should be
// handled on the main thread. So, original latencies and `cc::EventMetrics`
// should be used.
//
// We overwrite the trace_id to ensure proper flow events along the critical
// path.
bool handled = HandledOnCompositorThread(disposition);
for (auto& coalesced_event : original_events_) {
if (handled) {
int64_t original_trace_id =
coalesced_event.event_->latency_info().trace_id();
coalesced_event.event_->latency_info() = latency;
coalesced_event.event_->latency_info().set_trace_id(original_trace_id);
coalesced_event.event_->latency_info().set_coalesced();
}
std::move(coalesced_event.callback_)
.Run(disposition, std::move(coalesced_event.event_),
did_overscroll_params
? std::make_unique<InputHandlerProxy::DidOverscrollParams>(
*did_overscroll_params)
: nullptr,
attribution, std::move(coalesced_event.metrics_));
}
}
std::unique_ptr<cc::EventMetrics> EventWithCallback::TakeMetrics() {
auto it = original_events_.begin();
// Scroll events extracted from the matrix multiplication have no original
// events and we don't report metrics for them.
if (it == original_events_.end())
return nullptr;
// Throw away all original metrics except for the first one as they are not
// useful anymore.
auto first = it++;
for (; it != original_events_.end(); it++)
it->metrics_ = nullptr;
// Return metrics for the first original event for reporting purposes.
return std::move(first->metrics_);
}
void EventWithCallback::WillStartProcessingForMetrics() {
DCHECK(metrics());
for (auto& original_event : original_events_) {
if (original_event.metrics_) {
original_event.metrics_->SetDispatchStageTimestamp(
cc::EventMetrics::DispatchStage::kRendererCompositorStarted);
}
}
}
void EventWithCallback::DidCompleteProcessingForMetrics() {
DCHECK(metrics());
for (auto& original_event : original_events_) {
if (original_event.metrics_) {
original_event.metrics_->SetDispatchStageTimestamp(
cc::EventMetrics::DispatchStage::kRendererCompositorFinished);
}
}
}
EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback(
std::unique_ptr<WebCoalescedInputEvent> event,
std::unique_ptr<cc::EventMetrics> metrics,
InputHandlerProxy::EventDispositionCallback callback)
: event_(std::move(event)),
metrics_(std::move(metrics)),
callback_(std::move(callback)) {}
EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() =
default;
} // namespace blink
| chromium/chromium | third_party/blink/renderer/platform/widget/input/event_with_callback.cc | C++ | bsd-3-clause | 7,118 |
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_DEVTOOLS_REMOTE_DEBUGGING_SERVER_H_
#define CHROMECAST_BROWSER_DEVTOOLS_REMOTE_DEBUGGING_SERVER_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_member.h"
namespace devtools_http_handler {
class DevToolsHttpHandler;
}
namespace chromecast {
namespace shell {
class CastDevToolsManagerDelegate;
class RemoteDebuggingServer {
public:
explicit RemoteDebuggingServer(bool start_immediately);
~RemoteDebuggingServer();
private:
// Called when pref_enabled_ is changed.
void OnEnabledChanged();
scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
BooleanPrefMember pref_enabled_;
uint16_t port_;
DISALLOW_COPY_AND_ASSIGN(RemoteDebuggingServer);
};
} // namespace shell
} // namespace chromecast
#endif // CHROMECAST_BROWSER_DEVTOOLS_REMOTE_DEBUGGING_SERVER_H_
| js0701/chromium-crosswalk | chromecast/browser/devtools/remote_debugging_server.h | C | bsd-3-clause | 1,068 |
// Copyright 2015 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 IOS_CHROME_BROWSER_SYNC_IOS_CHROME_SYNC_CLIENT_H__
#define IOS_CHROME_BROWSER_SYNC_IOS_CHROME_SYNC_CLIENT_H__
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/sync_driver/sync_client.h"
namespace autofill {
class AutofillWebDataService;
}
namespace ios {
class ChromeBrowserState;
}
namespace password_manager {
class PasswordStore;
}
namespace sync_driver {
class SyncApiComponentFactory;
class SyncService;
}
class IOSChromeSyncClient : public sync_driver::SyncClient {
public:
explicit IOSChromeSyncClient(ios::ChromeBrowserState* browser_state);
~IOSChromeSyncClient() override;
// SyncClient implementation.
void Initialize() override;
sync_driver::SyncService* GetSyncService() override;
PrefService* GetPrefService() override;
bookmarks::BookmarkModel* GetBookmarkModel() override;
favicon::FaviconService* GetFaviconService() override;
history::HistoryService* GetHistoryService() override;
sync_driver::ClearBrowsingDataCallback GetClearBrowsingDataCallback()
override;
base::Closure GetPasswordStateChangedCallback() override;
sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
GetRegisterPlatformTypesCallback() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
invalidation::InvalidationService* GetInvalidationService() override;
BookmarkUndoService* GetBookmarkUndoServiceIfExists() override;
scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() override;
sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override;
base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
syncer::ModelType type) override;
scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup(
syncer::ModelSafeGroup group,
syncer::WorkerLoopDestructionObserver* observer) override;
sync_driver::SyncApiComponentFactory* GetSyncApiComponentFactory() override;
void SetSyncApiComponentFactoryForTesting(
scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory);
private:
void ClearBrowsingData(base::Time start, base::Time end);
ios::ChromeBrowserState* const browser_state_;
// The sync api component factory in use by this client.
scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory_;
// Members that must be fetched on the UI thread but accessed on their
// respective backend threads.
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
scoped_refptr<password_manager::PasswordStore> password_store_;
scoped_ptr<sync_sessions::SyncSessionsClient> sync_sessions_client_;
const scoped_refptr<syncer::ExtensionsActivity> dummy_extensions_activity_;
base::WeakPtrFactory<IOSChromeSyncClient> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(IOSChromeSyncClient);
};
#endif // IOS_CHROME_BROWSER_SYNC_IOS_CHROME_SYNC_CLIENT_H__
| js0701/chromium-crosswalk | ios/chrome/browser/sync/ios_chrome_sync_client.h | C | bsd-3-clause | 3,046 |
/*
* Algorithm.scala
* General Figaro algorithms.
*
* Created By: Avi Pfeffer (apfeffer@cra.com)
* Creation Date: Jan 1, 2009
*
* Copyright 2013 Avrom J. Pfeffer and Charles River Analytics, Inc.
* See http://www.cra.com or email figaro@cra.com for information.
*
* See http://www.github.com/p2t2/figaro for a copy of the software license.
*/
package com.cra.figaro.algorithm
/**
* Algorithm.scala
*
* General class of Figaro algorithms.
*/
import com.cra.figaro.language._
class UnsupportedAlgorithmException(element: Element[_]) extends RuntimeException(element.toString)
class AlgorithmException extends RuntimeException
class AlgorithmInactiveException extends AlgorithmException
class AlgorithmActiveException extends AlgorithmException
/**
* The general class of Figaro algorithms. The Algorithm class is defined to generalize both
* one-time and anytime algorithms, using a start/stop/resume/kill mechanism.
*/
trait Algorithm {
/**
* Called when the algorithm is started before running any steps. By default, does nothing. Can be overridden.
*/
def initialize(): Unit = {}
/**
* Called when the algorithm is killed. By default, does nothing. Can be overridden.
*/
def cleanUp(): Unit = {}
/* The following six methods are implemented by AnytimeAlgorithm and OneTimeAlgorithm. */
/*
* Start the algorithm. After it returns, the algorithm must be ready to provide answers.
*/
protected[algorithm] def doStart(): Unit
/*
* Stop the algorithm from computing. The algorithm is still ready to provide answers after it returns.
*/
protected[algorithm] def doStop(): Unit
/*
* Resume the computation of the algorithm, if it has been stopped.
*/
protected[algorithm] def doResume(): Unit
/*
* Kill the algorithm so that it is inactive. It will no longer be able to provide answers.
*/
protected[algorithm] def doKill(): Unit
protected var active = false
def isActive = active
/*
* The following are convenient wrappers for the Algorithm's methods that do some error checking before
* calling the appropriate method.
*/
/**
* Start the algorithm and make it active. After it returns, the algorithm must be ready to provide
* answers. Throws AlgorithmActiveException if the algorithm is already active.
*/
def start(): Unit = {
if (active) throw new AlgorithmActiveException
active = true
doStart()
}
/**
* Stop the algorithm from computing. The algorithm is still ready to provide answers after it returns.
* Throws AlgorithmInactiveException if the algorithm is not active.
*/
def stop(): Unit = {
if (!active) throw new AlgorithmInactiveException
doStop()
}
/**
* Resume the computation of the algorithm, if it has been stopped. Throws AlgorithmInactiveException if
* the algorithm is not active.
*/
def resume(): Unit = {
if (!active) throw new AlgorithmInactiveException
doResume()
}
/**
* Kill the algorithm so that it is inactive. It will no longer be able to provide answers.Throws
* AlgorithmInactiveException if the algorithm is not active.
*/
def kill(): Unit = {
if (!active) throw new AlgorithmInactiveException
doKill()
active = false
}
}
| jyuhuan/figaro | Figaro/src/main/scala/com/cra/figaro/algorithm/Algorithm.scala | Scala | bsd-3-clause | 3,276 |
# 1.5 Summary
In this chapter, we talked about how to install Go using three different methods including from source code, the standard package and via third-party tools. Then we showed you how to configure the Go development environment, mainly covering how to setup your `$GOPATH`. After that, we introduced some steps for compiling and deploying Go programs. We then covered Go commands, including the compile, install, format and test commands. Finally, there are many powerful tools to develop Go programs such as LiteIDE, Sublime Text, VSCode, Atom, GoLand, Vim, Emacs, Eclipse, IntelliJ IDEA, etc. You can choose any one you like exploring the world of Go.
## Links
- [Directory](preface.md)
- Previous section: [Go development tools](01.4.md)
- Next chapter: [Go basic knowledge](02.0.md)
| astaxie/build-web-application-with-golang | th/01.5.md | Markdown | bsd-3-clause | 800 |
<?php
/**
* Pimcore
*
* 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://www.pimcore.org/license
*
* @category Pimcore
* @package Document
* @copyright Copyright (c) 2009-2014 pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license New BSD License
*/
namespace Pimcore\Model\Document;
use Pimcore\Model;
class DocType extends Model\AbstractModel {
/**
* ID of the document-type
*
* @var integer
*/
public $id;
/**
* Name of the document-type
*
* @var string
*/
public $name;
/**
* @var string
*/
public $module;
/**
* The specified controller
*
* @var string
*/
public $controller;
/**
* The specified action
*
* @var string
*/
public $action;
/**
* The specified template
*
* @var string
*/
public $template;
/**
* Type, must be one of the following: page,snippet,email
*
* @var string
*/
public $type;
/**
* @var integer
*/
public $priority = 0;
/**
* @var integer
*/
public $creationDate;
/**
* @var integer
*/
public $modificationDate;
/**
* Static helper to retrieve an instance of Document\DocType by the given ID
*
* @param integer $id
* @return DocType
*/
public static function getById($id) {
$docType = new self();
$docType->setId(intval($id));
try {
$docType->getResource()->getById();
} catch (\Exception $e) {
return null;
}
return $docType;
}
/**
* Shortcut to quickly create a new instance
*
* @return DocType
*/
public static function create() {
$type = new self();
$type->save();
return $type;
}
/**
* @return string
*/
public function getAction() {
return $this->action;
}
/**
* @return string
*/
public function getController() {
return $this->controller;
}
/**
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return string
*/
public function getTemplate() {
return $this->template;
}
/**
* @param string $action
* @return void
*/
public function setAction($action) {
$this->action = $action;
return $this;
}
/**
* @param string $controller
* @return void
*/
public function setController($controller) {
$this->controller = $controller;
return $this;
}
/**
* @param integer $id
* @return void
*/
public function setId($id) {
$this->id = (int) $id;
return $this;
}
/**
* @param string $name
* @return void
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* @param string $template
* @return void
*/
public function setTemplate($template) {
$this->template = $template;
return $this;
}
/**
* @return string
*/
public function getType() {
return $this->type;
}
/**
* @param string $type
* @return void
*/
public function setType($type) {
$this->type = $type;
return $this;
}
/**
* @param integer $priority
* @return void
*/
public function setPriority($priority) {
$this->priority = (int) $priority;
return $this;
}
/**
* @return integer
*/
public function getPriority() {
return $this->priority;
}
/**
* @param $module
* @return $this
*/
public function setModule($module)
{
$this->module = $module;
return $this;
}
/**
* @return string
*/
public function getModule()
{
return $this->module;
}
/**
* @param $modificationDate
* @return $this
*/
public function setModificationDate($modificationDate)
{
$this->modificationDate = (int) $modificationDate;
return $this;
}
/**
* @return int
*/
public function getModificationDate()
{
return $this->modificationDate;
}
/**
* @param $creationDate
* @return $this
*/
public function setCreationDate($creationDate)
{
$this->creationDate = (int) $creationDate;
return $this;
}
/**
* @return int
*/
public function getCreationDate()
{
return $this->creationDate;
}
}
| kanevbg/pimcore | pimcore/models/Document/DocType.php | PHP | bsd-3-clause | 5,233 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/plugins/npapi/plugin_lib.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace webkit {
namespace npapi {
// Test the unloading of plugin libs. Bug http://crbug.com/46526 showed that
// if UnloadAllPlugins() simply iterates through the g_loaded_libs global
// variable, we can get a crash if no plugin libs were marked as always loaded.
class PluginLibTest : public PluginLib {
public:
PluginLibTest() : PluginLib(WebPluginInfo(), NULL) {}
using PluginLib::Unload;
protected:
virtual ~PluginLibTest() {}
};
TEST(PluginLibLoading, UnloadAllPlugins) {
// For the creation of the g_loaded_libs global variable.
ASSERT_EQ(static_cast<PluginLibTest*>(NULL),
PluginLibTest::CreatePluginLib(FilePath()));
// Try with a single plugin lib.
scoped_refptr<PluginLibTest> plugin_lib1(new PluginLibTest());
PluginLib::UnloadAllPlugins();
// Need to create it again, it should have been destroyed above.
ASSERT_EQ(static_cast<PluginLibTest*>(NULL),
PluginLibTest::CreatePluginLib(FilePath()));
// Try with two plugin libs.
plugin_lib1 = new PluginLibTest();
scoped_refptr<PluginLibTest> plugin_lib2(new PluginLibTest());
PluginLib::UnloadAllPlugins();
// Need to create it again, it should have been destroyed above.
ASSERT_EQ(static_cast<PluginLibTest*>(NULL),
PluginLibTest::CreatePluginLib(FilePath()));
// Now try to manually Unload one and then UnloadAll.
plugin_lib1 = new PluginLibTest();
plugin_lib2 = new PluginLibTest();
plugin_lib1->Unload();
PluginLib::UnloadAllPlugins();
// Need to create it again, it should have been destroyed above.
ASSERT_EQ(static_cast<PluginLibTest*>(NULL),
PluginLibTest::CreatePluginLib(FilePath()));
// Now try to manually Unload the only one and then UnloadAll.
plugin_lib1 = new PluginLibTest();
plugin_lib1->Unload();
PluginLib::UnloadAllPlugins();
}
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Test parsing a simple description: Real Audio.
TEST(MIMEDescriptionParse, Simple) {
std::vector<WebPluginMimeType> types;
PluginLib::ParseMIMEDescription(
"audio/x-pn-realaudio-plugin:rpm:RealAudio document;",
&types);
ASSERT_EQ(1U, types.size());
const WebPluginMimeType& type = types[0];
EXPECT_EQ("audio/x-pn-realaudio-plugin", type.mime_type);
ASSERT_EQ(1U, type.file_extensions.size());
EXPECT_EQ("rpm", type.file_extensions[0]);
EXPECT_EQ(ASCIIToUTF16("RealAudio document"), type.description);
}
// Test parsing a multi-entry description: QuickTime as provided by Totem.
TEST(MIMEDescriptionParse, Multi) {
std::vector<WebPluginMimeType> types;
PluginLib::ParseMIMEDescription(
"video/quicktime:mov:QuickTime video;video/mp4:mp4:MPEG-4 "
"video;image/x-macpaint:pntg:MacPaint Bitmap image;image/x"
"-quicktime:pict, pict1, pict2:QuickTime image;video/x-m4v"
":m4v:MPEG-4 video;",
&types);
ASSERT_EQ(5U, types.size());
// Check the x-quicktime one, since it looks tricky with spaces in the
// extension list.
const WebPluginMimeType& type = types[3];
EXPECT_EQ("image/x-quicktime", type.mime_type);
ASSERT_EQ(3U, type.file_extensions.size());
EXPECT_EQ("pict2", type.file_extensions[2]);
EXPECT_EQ(ASCIIToUTF16("QuickTime image"), type.description);
}
// Test parsing a Japanese description, since we got this wrong in the past.
// This comes from loading Totem with LANG=ja_JP.UTF-8.
TEST(MIMEDescriptionParse, JapaneseUTF8) {
std::vector<WebPluginMimeType> types;
PluginLib::ParseMIMEDescription(
"audio/x-ogg:ogg:Ogg \xe3\x82\xaa\xe3\x83\xbc\xe3\x83\x87"
"\xe3\x82\xa3\xe3\x83\xaa",
&types);
ASSERT_EQ(1U, types.size());
// Check we got the right number of Unicode characters out of the parse.
EXPECT_EQ(9U, types[0].description.size());
}
// Test that we handle corner cases gracefully.
TEST(MIMEDescriptionParse, CornerCases) {
std::vector<WebPluginMimeType> types;
PluginLib::ParseMIMEDescription("mime/type:", &types);
EXPECT_TRUE(types.empty());
types.clear();
PluginLib::ParseMIMEDescription("mime/type:ext1:", &types);
ASSERT_EQ(1U, types.size());
EXPECT_EQ("mime/type", types[0].mime_type);
EXPECT_EQ(1U, types[0].file_extensions.size());
EXPECT_EQ("ext1", types[0].file_extensions[0]);
EXPECT_EQ(string16(), types[0].description);
}
// This Java plugin has embedded semicolons in the mime type.
TEST(MIMEDescriptionParse, ComplicatedJava) {
std::vector<WebPluginMimeType> types;
PluginLib::ParseMIMEDescription(
"application/x-java-vm:class,jar:IcedTea;application/x-java"
"-applet:class,jar:IcedTea;application/x-java-applet;versio"
"n=1.1:class,jar:IcedTea;application/x-java-applet;version="
"1.1.1:class,jar:IcedTea;application/x-java-applet;version="
"1.1.2:class,jar:IcedTea;application/x-java-applet;version="
"1.1.3:class,jar:IcedTea;application/x-java-applet;version="
"1.2:class,jar:IcedTea;application/x-java-applet;version=1."
"2.1:class,jar:IcedTea;application/x-java-applet;version=1."
"2.2:class,jar:IcedTea;application/x-java-applet;version=1."
"3:class,jar:IcedTea;application/x-java-applet;version=1.3."
"1:class,jar:IcedTea;application/x-java-applet;version=1.4:"
"class,jar:IcedTea",
&types);
ASSERT_EQ(12U, types.size());
for (size_t i = 0; i < types.size(); ++i)
EXPECT_EQ(ASCIIToUTF16("IcedTea"), types[i].description);
// Verify that the mime types with semis are coming through ok.
EXPECT_TRUE(types[4].mime_type.find(';') != std::string::npos);
}
// Make sure we understand how to get the version numbers for common Linux
// plug-ins.
TEST(PluginDescriptionParse, ExtractVersion) {
WebPluginInfo info;
PluginLib::ExtractVersionString("Shockwave Flash 10.1 r102", &info);
EXPECT_EQ(ASCIIToUTF16("10.1 r102"), info.version);
PluginLib::ExtractVersionString("Java(TM) Plug-in 1.6.0_22", &info);
EXPECT_EQ(ASCIIToUTF16("1.6.0_22"), info.version);
// It's actually much more likely for a modern Linux distribution to have
// IcedTea.
PluginLib::ExtractVersionString(
"IcedTea-Web Plugin "
"(using IcedTea-Web 1.2 (1.2-2ubuntu0.10.04.2))",
&info);
EXPECT_EQ(ASCIIToUTF16("1.2"), info.version);
}
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
} // namespace npapi
} // namespace webkit
| nacl-webkit/chrome_deps | webkit/plugins/npapi/plugin_lib_unittest.cc | C++ | bsd-3-clause | 6,617 |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autocomplete/url_index_private_data.h"
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/files/file_util.h"
#include "base/i18n/break_iterator.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/autocomplete/in_memory_url_index.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/history/core/browser/history_database.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_service.h"
#include "net/base/net_util.h"
#if defined(USE_SYSTEM_PROTOBUF)
#include <google/protobuf/repeated_field.h>
#else
#include "third_party/protobuf/src/google/protobuf/repeated_field.h"
#endif
using google::protobuf::RepeatedField;
using google::protobuf::RepeatedPtrField;
using in_memory_url_index::InMemoryURLIndexCacheItem;
namespace {
static const size_t kMaxVisitsToStoreInCache = 10u;
}
typedef in_memory_url_index::InMemoryURLIndexCacheItem_WordListItem
WordListItem;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_WordMapItem_WordMapEntry
WordMapEntry;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_WordMapItem WordMapItem;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_CharWordMapItem
CharWordMapItem;
typedef in_memory_url_index::
InMemoryURLIndexCacheItem_CharWordMapItem_CharWordMapEntry CharWordMapEntry;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_WordIDHistoryMapItem
WordIDHistoryMapItem;
typedef in_memory_url_index::
InMemoryURLIndexCacheItem_WordIDHistoryMapItem_WordIDHistoryMapEntry
WordIDHistoryMapEntry;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_HistoryInfoMapItem
HistoryInfoMapItem;
typedef in_memory_url_index::
InMemoryURLIndexCacheItem_HistoryInfoMapItem_HistoryInfoMapEntry
HistoryInfoMapEntry;
typedef in_memory_url_index::
InMemoryURLIndexCacheItem_HistoryInfoMapItem_HistoryInfoMapEntry_VisitInfo
HistoryInfoMapEntry_VisitInfo;
typedef in_memory_url_index::InMemoryURLIndexCacheItem_WordStartsMapItem
WordStartsMapItem;
typedef in_memory_url_index::
InMemoryURLIndexCacheItem_WordStartsMapItem_WordStartsMapEntry
WordStartsMapEntry;
// Algorithm Functions ---------------------------------------------------------
// Comparison function for sorting search terms by descending length.
bool LengthGreater(const base::string16& string_a,
const base::string16& string_b) {
return string_a.length() > string_b.length();
}
// UpdateRecentVisitsFromHistoryDBTask -----------------------------------------
// HistoryDBTask used to update the recent visit data for a particular
// row from the history database.
class UpdateRecentVisitsFromHistoryDBTask : public history::HistoryDBTask {
public:
explicit UpdateRecentVisitsFromHistoryDBTask(
URLIndexPrivateData* private_data,
history::URLID url_id);
bool RunOnDBThread(history::HistoryBackend* backend,
history::HistoryDatabase* db) override;
void DoneRunOnMainThread() override;
private:
~UpdateRecentVisitsFromHistoryDBTask() override;
// The URLIndexPrivateData that gets updated after the historyDB
// task returns.
URLIndexPrivateData* private_data_;
// The ID of the URL to get visits for and then update.
history::URLID url_id_;
// Whether fetching the recent visits for the URL succeeded.
bool succeeded_;
// The awaited data that's shown to private_data_ for it to copy and
// store.
history::VisitVector recent_visits_;
DISALLOW_COPY_AND_ASSIGN(UpdateRecentVisitsFromHistoryDBTask);
};
UpdateRecentVisitsFromHistoryDBTask::UpdateRecentVisitsFromHistoryDBTask(
URLIndexPrivateData* private_data,
history::URLID url_id)
: private_data_(private_data), url_id_(url_id), succeeded_(false) {
}
bool UpdateRecentVisitsFromHistoryDBTask::RunOnDBThread(
history::HistoryBackend* backend,
history::HistoryDatabase* db) {
// Make sure the private data is going to get as many recent visits as
// ScoredHistoryMatch::GetFrequency() hopes to use.
DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore);
succeeded_ = db->GetMostRecentVisitsForURL(url_id_,
kMaxVisitsToStoreInCache,
&recent_visits_);
if (!succeeded_)
recent_visits_.clear();
return true; // Always claim to be done; do not retry failures.
}
void UpdateRecentVisitsFromHistoryDBTask::DoneRunOnMainThread() {
if (succeeded_)
private_data_->UpdateRecentVisits(url_id_, recent_visits_);
}
UpdateRecentVisitsFromHistoryDBTask::~UpdateRecentVisitsFromHistoryDBTask() {
}
// URLIndexPrivateData ---------------------------------------------------------
URLIndexPrivateData::URLIndexPrivateData()
: restored_cache_version_(0),
saved_cache_version_(kCurrentCacheFileVersion),
pre_filter_item_count_(0),
post_filter_item_count_(0),
post_scoring_item_count_(0) {
}
ScoredHistoryMatches URLIndexPrivateData::HistoryItemsForTerms(
base::string16 search_string,
size_t cursor_position,
size_t max_matches,
const std::string& languages,
bookmarks::BookmarkModel* bookmark_model) {
// If cursor position is set and useful (not at either end of the
// string), allow the search string to be broken at cursor position.
// We do this by pretending there's a space where the cursor is.
if ((cursor_position != base::string16::npos) &&
(cursor_position < search_string.length()) &&
(cursor_position > 0)) {
search_string.insert(cursor_position, base::ASCIIToUTF16(" "));
}
pre_filter_item_count_ = 0;
post_filter_item_count_ = 0;
post_scoring_item_count_ = 0;
// The search string we receive may contain escaped characters. For reducing
// the index we need individual, lower-cased words, ignoring escapings. For
// the final filtering we need whitespace separated substrings possibly
// containing escaped characters.
base::string16 lower_raw_string(base::i18n::ToLower(search_string));
base::string16 lower_unescaped_string =
net::UnescapeURLComponent(lower_raw_string,
net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
// Extract individual 'words' (as opposed to 'terms'; see below) from the
// search string. When the user types "colspec=ID%20Mstone Release" we get
// four 'words': "colspec", "id", "mstone" and "release".
String16Vector lower_words(
String16VectorFromString16(lower_unescaped_string, false, NULL));
ScoredHistoryMatches scored_items;
// Do nothing if we have indexed no words (probably because we've not been
// initialized yet) or the search string has no words.
if (word_list_.empty() || lower_words.empty()) {
search_term_cache_.clear(); // Invalidate the term cache.
return scored_items;
}
// Reset used_ flags for search_term_cache_. We use a basic mark-and-sweep
// approach.
ResetSearchTermCache();
HistoryIDSet history_id_set = HistoryIDSetFromWords(lower_words);
// Trim the candidate pool if it is large. Note that we do not filter out
// items that do not contain the search terms as proper substrings -- doing
// so is the performance-costly operation we are trying to avoid in order
// to maintain omnibox responsiveness.
const size_t kItemsToScoreLimit = 500;
pre_filter_item_count_ = history_id_set.size();
// If we trim the results set we do not want to cache the results for next
// time as the user's ultimately desired result could easily be eliminated
// in this early rough filter.
bool was_trimmed = (pre_filter_item_count_ > kItemsToScoreLimit);
if (was_trimmed) {
HistoryIDVector history_ids;
std::copy(history_id_set.begin(), history_id_set.end(),
std::back_inserter(history_ids));
// Trim down the set by sorting by typed-count, visit-count, and last
// visit.
HistoryItemFactorGreater
item_factor_functor(history_info_map_);
std::partial_sort(history_ids.begin(),
history_ids.begin() + kItemsToScoreLimit,
history_ids.end(),
item_factor_functor);
history_id_set.clear();
std::copy(history_ids.begin(), history_ids.begin() + kItemsToScoreLimit,
std::inserter(history_id_set, history_id_set.end()));
post_filter_item_count_ = history_id_set.size();
}
// Pass over all of the candidates filtering out any without a proper
// substring match, inserting those which pass in order by score. Note that
// in this step we are using the raw search string complete with escaped
// URL elements. When the user has specifically typed something akin to
// "sort=pri&colspec=ID%20Mstone%20Release" we want to make sure that that
// specific substring appears in the URL or page title.
// We call these 'terms' (as opposed to 'words'; see above) as in this case
// we only want to break up the search string on 'true' whitespace rather than
// escaped whitespace. When the user types "colspec=ID%20Mstone Release" we
// get two 'terms': "colspec=id%20mstone" and "release".
String16Vector lower_raw_terms;
if (Tokenize(lower_raw_string, base::kWhitespaceUTF16,
&lower_raw_terms) == 0) {
// Don't score matches when there are no terms to score against. (It's
// possible that the word break iterater that extracts words to search
// for in the database allows some whitespace "words" whereas Tokenize
// excludes a long list of whitespace.) One could write a scoring
// function that gives a reasonable order to matches when there
// are no terms (i.e., all the words are some form of whitespace),
// but this is such a rare edge case that it's not worth the time.
return scored_items;
}
scored_items =
std::for_each(
history_id_set.begin(), history_id_set.end(),
AddHistoryMatch(bookmark_model, *this, languages, lower_raw_string,
lower_raw_terms, base::Time::Now())).ScoredMatches();
// Select and sort only the top |max_matches| results.
if (scored_items.size() > max_matches) {
std::partial_sort(scored_items.begin(),
scored_items.begin() +
max_matches,
scored_items.end(),
ScoredHistoryMatch::MatchScoreGreater);
scored_items.resize(max_matches);
} else {
std::sort(scored_items.begin(), scored_items.end(),
ScoredHistoryMatch::MatchScoreGreater);
}
post_scoring_item_count_ = scored_items.size();
if (was_trimmed) {
search_term_cache_.clear(); // Invalidate the term cache.
} else {
// Remove any stale SearchTermCacheItems.
for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin();
cache_iter != search_term_cache_.end(); ) {
if (!cache_iter->second.used_)
search_term_cache_.erase(cache_iter++);
else
++cache_iter;
}
}
return scored_items;
}
bool URLIndexPrivateData::UpdateURL(
history::HistoryService* history_service,
const history::URLRow& row,
const std::string& languages,
const std::set<std::string>& scheme_whitelist,
base::CancelableTaskTracker* tracker) {
// The row may or may not already be in our index. If it is not already
// indexed and it qualifies then it gets indexed. If it is already
// indexed and still qualifies then it gets updated, otherwise it
// is deleted from the index.
bool row_was_updated = false;
history::URLID row_id = row.id();
HistoryInfoMap::iterator row_pos = history_info_map_.find(row_id);
if (row_pos == history_info_map_.end()) {
// This new row should be indexed if it qualifies.
history::URLRow new_row(row);
new_row.set_id(row_id);
row_was_updated = RowQualifiesAsSignificant(new_row, base::Time()) &&
IndexRow(NULL,
history_service,
new_row,
languages,
scheme_whitelist,
tracker);
} else if (RowQualifiesAsSignificant(row, base::Time())) {
// This indexed row still qualifies and will be re-indexed.
// The url won't have changed but the title, visit count, etc.
// might have changed.
history::URLRow& row_to_update = row_pos->second.url_row;
bool title_updated = row_to_update.title() != row.title();
if (row_to_update.visit_count() != row.visit_count() ||
row_to_update.typed_count() != row.typed_count() ||
row_to_update.last_visit() != row.last_visit() || title_updated) {
row_to_update.set_visit_count(row.visit_count());
row_to_update.set_typed_count(row.typed_count());
row_to_update.set_last_visit(row.last_visit());
// If something appears to have changed, update the recent visits
// information.
ScheduleUpdateRecentVisits(history_service, row_id, tracker);
// While the URL is guaranteed to remain stable, the title may have
// changed. If so, then update the index with the changed words.
if (title_updated) {
// Clear all words associated with this row and re-index both the
// URL and title.
RemoveRowWordsFromIndex(row_to_update);
row_to_update.set_title(row.title());
RowWordStarts word_starts;
AddRowWordsToIndex(row_to_update, &word_starts, languages);
word_starts_map_[row_id] = word_starts;
}
row_was_updated = true;
}
} else {
// This indexed row no longer qualifies and will be de-indexed by
// clearing all words associated with this row.
RemoveRowFromIndex(row);
row_was_updated = true;
}
if (row_was_updated)
search_term_cache_.clear(); // This invalidates the cache.
return row_was_updated;
}
void URLIndexPrivateData::UpdateRecentVisits(
history::URLID url_id,
const history::VisitVector& recent_visits) {
HistoryInfoMap::iterator row_pos = history_info_map_.find(url_id);
if (row_pos != history_info_map_.end()) {
VisitInfoVector* visits = &row_pos->second.visits;
visits->clear();
const size_t size =
std::min(recent_visits.size(), kMaxVisitsToStoreInCache);
visits->reserve(size);
for (size_t i = 0; i < size; i++) {
// Copy from the history::VisitVector the only fields visits needs.
visits->push_back(std::make_pair(recent_visits[i].visit_time,
recent_visits[i].transition));
}
}
// Else: Oddly, the URL doesn't seem to exist in the private index.
// Ignore this update. This can happen if, for instance, the user
// removes the URL from URLIndexPrivateData before the historyDB call
// returns.
}
void URLIndexPrivateData::ScheduleUpdateRecentVisits(
history::HistoryService* history_service,
history::URLID url_id,
base::CancelableTaskTracker* tracker) {
history_service->ScheduleDBTask(
scoped_ptr<history::HistoryDBTask>(
new UpdateRecentVisitsFromHistoryDBTask(this, url_id)), tracker);
}
// Helper functor for DeleteURL.
class HistoryInfoMapItemHasURL {
public:
explicit HistoryInfoMapItemHasURL(const GURL& url): url_(url) {}
bool operator()(const std::pair<const HistoryID, HistoryInfoMapValue>& item) {
return item.second.url_row.url() == url_;
}
private:
const GURL& url_;
};
bool URLIndexPrivateData::DeleteURL(const GURL& url) {
// Find the matching entry in the history_info_map_.
HistoryInfoMap::iterator pos = std::find_if(
history_info_map_.begin(),
history_info_map_.end(),
HistoryInfoMapItemHasURL(url));
if (pos == history_info_map_.end())
return false;
RemoveRowFromIndex(pos->second.url_row);
search_term_cache_.clear(); // This invalidates the cache.
return true;
}
// static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RestoreFromFile(
const base::FilePath& file_path,
const std::string& languages) {
base::TimeTicks beginning_time = base::TimeTicks::Now();
if (!base::PathExists(file_path))
return NULL;
std::string data;
// If there is no cache file then simply give up. This will cause us to
// attempt to rebuild from the history database.
if (!base::ReadFileToString(file_path, &data))
return NULL;
scoped_refptr<URLIndexPrivateData> restored_data(new URLIndexPrivateData);
InMemoryURLIndexCacheItem index_cache;
if (!index_cache.ParseFromArray(data.c_str(), data.size())) {
LOG(WARNING) << "Failed to parse URLIndexPrivateData cache data read from "
<< file_path.value();
return restored_data;
}
if (!restored_data->RestorePrivateData(index_cache, languages))
return NULL;
UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexRestoreCacheTime",
base::TimeTicks::Now() - beginning_time);
UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems",
restored_data->history_id_word_map_.size());
UMA_HISTOGRAM_COUNTS("History.InMemoryURLCacheSize", data.size());
UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords",
restored_data->word_map_.size());
UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLChars",
restored_data->char_word_map_.size());
if (restored_data->Empty())
return NULL; // 'No data' is the same as a failed reload.
return restored_data;
}
// static
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::RebuildFromHistory(
history::HistoryDatabase* history_db,
const std::string& languages,
const std::set<std::string>& scheme_whitelist) {
if (!history_db)
return NULL;
base::TimeTicks beginning_time = base::TimeTicks::Now();
scoped_refptr<URLIndexPrivateData>
rebuilt_data(new URLIndexPrivateData);
history::URLDatabase::URLEnumerator history_enum;
if (!history_db->InitURLEnumeratorForSignificant(&history_enum))
return NULL;
rebuilt_data->last_time_rebuilt_from_history_ = base::Time::Now();
for (history::URLRow row; history_enum.GetNextURL(&row);) {
rebuilt_data->IndexRow(
history_db, NULL, row, languages, scheme_whitelist, NULL);
}
UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexingTime",
base::TimeTicks::Now() - beginning_time);
UMA_HISTOGRAM_COUNTS("History.InMemoryURLHistoryItems",
rebuilt_data->history_id_word_map_.size());
UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLWords",
rebuilt_data->word_map_.size());
UMA_HISTOGRAM_COUNTS_10000("History.InMemoryURLChars",
rebuilt_data->char_word_map_.size());
return rebuilt_data;
}
// static
bool URLIndexPrivateData::WritePrivateDataToCacheFileTask(
scoped_refptr<URLIndexPrivateData> private_data,
const base::FilePath& file_path) {
DCHECK(private_data.get());
DCHECK(!file_path.empty());
return private_data->SaveToFile(file_path);
}
scoped_refptr<URLIndexPrivateData> URLIndexPrivateData::Duplicate() const {
scoped_refptr<URLIndexPrivateData> data_copy = new URLIndexPrivateData;
data_copy->last_time_rebuilt_from_history_ = last_time_rebuilt_from_history_;
data_copy->word_list_ = word_list_;
data_copy->available_words_ = available_words_;
data_copy->word_map_ = word_map_;
data_copy->char_word_map_ = char_word_map_;
data_copy->word_id_history_map_ = word_id_history_map_;
data_copy->history_id_word_map_ = history_id_word_map_;
data_copy->history_info_map_ = history_info_map_;
data_copy->word_starts_map_ = word_starts_map_;
return data_copy;
// Not copied:
// search_term_cache_
// pre_filter_item_count_
// post_filter_item_count_
// post_scoring_item_count_
}
bool URLIndexPrivateData::Empty() const {
return history_info_map_.empty();
}
void URLIndexPrivateData::Clear() {
last_time_rebuilt_from_history_ = base::Time();
word_list_.clear();
available_words_.clear();
word_map_.clear();
char_word_map_.clear();
word_id_history_map_.clear();
history_id_word_map_.clear();
history_info_map_.clear();
word_starts_map_.clear();
}
URLIndexPrivateData::~URLIndexPrivateData() {}
HistoryIDSet URLIndexPrivateData::HistoryIDSetFromWords(
const String16Vector& unsorted_words) {
// Break the terms down into individual terms (words), get the candidate
// set for each term, and intersect each to get a final candidate list.
// Note that a single 'term' from the user's perspective might be
// a string like "http://www.somewebsite.com" which, from our perspective,
// is four words: 'http', 'www', 'somewebsite', and 'com'.
HistoryIDSet history_id_set;
String16Vector words(unsorted_words);
// Sort the words into the longest first as such are likely to narrow down
// the results quicker. Also, single character words are the most expensive
// to process so save them for last.
std::sort(words.begin(), words.end(), LengthGreater);
for (String16Vector::iterator iter = words.begin(); iter != words.end();
++iter) {
base::string16 uni_word = *iter;
HistoryIDSet term_history_set = HistoryIDsForTerm(uni_word);
if (term_history_set.empty()) {
history_id_set.clear();
break;
}
if (iter == words.begin()) {
history_id_set.swap(term_history_set);
} else {
HistoryIDSet new_history_id_set = base::STLSetIntersection<HistoryIDSet>(
history_id_set, term_history_set);
history_id_set.swap(new_history_id_set);
}
}
return history_id_set;
}
HistoryIDSet URLIndexPrivateData::HistoryIDsForTerm(
const base::string16& term) {
if (term.empty())
return HistoryIDSet();
// TODO(mrossetti): Consider optimizing for very common terms such as
// 'http[s]', 'www', 'com', etc. Or collect the top 100 more frequently
// occuring words in the user's searches.
size_t term_length = term.length();
WordIDSet word_id_set;
if (term_length > 1) {
// See if this term or a prefix thereof is present in the cache.
SearchTermCacheMap::iterator best_prefix(search_term_cache_.end());
for (SearchTermCacheMap::iterator cache_iter = search_term_cache_.begin();
cache_iter != search_term_cache_.end(); ++cache_iter) {
if (StartsWith(term, cache_iter->first, false) &&
(best_prefix == search_term_cache_.end() ||
cache_iter->first.length() > best_prefix->first.length()))
best_prefix = cache_iter;
}
// If a prefix was found then determine the leftover characters to be used
// for further refining the results from that prefix.
Char16Set prefix_chars;
base::string16 leftovers(term);
if (best_prefix != search_term_cache_.end()) {
// If the prefix is an exact match for the term then grab the cached
// results and we're done.
size_t prefix_length = best_prefix->first.length();
if (prefix_length == term_length) {
best_prefix->second.used_ = true;
return best_prefix->second.history_id_set_;
}
// Otherwise we have a handy starting point.
// If there are no history results for this prefix then we can bail early
// as there will be no history results for the full term.
if (best_prefix->second.history_id_set_.empty()) {
search_term_cache_[term] = SearchTermCacheItem();
return HistoryIDSet();
}
word_id_set = best_prefix->second.word_id_set_;
prefix_chars = Char16SetFromString16(best_prefix->first);
leftovers = term.substr(prefix_length);
}
// Filter for each remaining, unique character in the term.
Char16Set leftover_chars = Char16SetFromString16(leftovers);
Char16Set unique_chars =
base::STLSetDifference<Char16Set>(leftover_chars, prefix_chars);
// Reduce the word set with any leftover, unprocessed characters.
if (!unique_chars.empty()) {
WordIDSet leftover_set(WordIDSetForTermChars(unique_chars));
// We might come up empty on the leftovers.
if (leftover_set.empty()) {
search_term_cache_[term] = SearchTermCacheItem();
return HistoryIDSet();
}
// Or there may not have been a prefix from which to start.
if (prefix_chars.empty()) {
word_id_set.swap(leftover_set);
} else {
WordIDSet new_word_id_set = base::STLSetIntersection<WordIDSet>(
word_id_set, leftover_set);
word_id_set.swap(new_word_id_set);
}
}
// We must filter the word list because the resulting word set surely
// contains words which do not have the search term as a proper subset.
for (WordIDSet::iterator word_set_iter = word_id_set.begin();
word_set_iter != word_id_set.end(); ) {
if (word_list_[*word_set_iter].find(term) == base::string16::npos)
word_id_set.erase(word_set_iter++);
else
++word_set_iter;
}
} else {
word_id_set = WordIDSetForTermChars(Char16SetFromString16(term));
}
// If any words resulted then we can compose a set of history IDs by unioning
// the sets from each word.
HistoryIDSet history_id_set;
if (!word_id_set.empty()) {
for (WordIDSet::iterator word_id_iter = word_id_set.begin();
word_id_iter != word_id_set.end(); ++word_id_iter) {
WordID word_id = *word_id_iter;
WordIDHistoryMap::iterator word_iter = word_id_history_map_.find(word_id);
if (word_iter != word_id_history_map_.end()) {
HistoryIDSet& word_history_id_set(word_iter->second);
history_id_set.insert(word_history_id_set.begin(),
word_history_id_set.end());
}
}
}
// Record a new cache entry for this word if the term is longer than
// a single character.
if (term_length > 1)
search_term_cache_[term] = SearchTermCacheItem(word_id_set, history_id_set);
return history_id_set;
}
WordIDSet URLIndexPrivateData::WordIDSetForTermChars(
const Char16Set& term_chars) {
WordIDSet word_id_set;
for (Char16Set::const_iterator c_iter = term_chars.begin();
c_iter != term_chars.end(); ++c_iter) {
CharWordIDMap::iterator char_iter = char_word_map_.find(*c_iter);
if (char_iter == char_word_map_.end()) {
// A character was not found so there are no matching results: bail.
word_id_set.clear();
break;
}
WordIDSet& char_word_id_set(char_iter->second);
// It is possible for there to no longer be any words associated with
// a particular character. Give up in that case.
if (char_word_id_set.empty()) {
word_id_set.clear();
break;
}
if (c_iter == term_chars.begin()) {
// First character results becomes base set of results.
word_id_set = char_word_id_set;
} else {
// Subsequent character results get intersected in.
WordIDSet new_word_id_set = base::STLSetIntersection<WordIDSet>(
word_id_set, char_word_id_set);
word_id_set.swap(new_word_id_set);
}
}
return word_id_set;
}
bool URLIndexPrivateData::IndexRow(
history::HistoryDatabase* history_db,
history::HistoryService* history_service,
const history::URLRow& row,
const std::string& languages,
const std::set<std::string>& scheme_whitelist,
base::CancelableTaskTracker* tracker) {
const GURL& gurl(row.url());
// Index only URLs with a whitelisted scheme.
if (!URLSchemeIsWhitelisted(gurl, scheme_whitelist))
return false;
history::URLID row_id = row.id();
// Strip out username and password before saving and indexing.
base::string16 url(net::FormatUrl(gurl, languages,
net::kFormatUrlOmitUsernamePassword,
net::UnescapeRule::NONE,
NULL, NULL, NULL));
HistoryID history_id = static_cast<HistoryID>(row_id);
DCHECK_LT(history_id, std::numeric_limits<HistoryID>::max());
// Add the row for quick lookup in the history info store.
history::URLRow new_row(GURL(url), row_id);
new_row.set_visit_count(row.visit_count());
new_row.set_typed_count(row.typed_count());
new_row.set_last_visit(row.last_visit());
new_row.set_title(row.title());
history_info_map_[history_id].url_row = new_row;
// Index the words contained in the URL and title of the row.
RowWordStarts word_starts;
AddRowWordsToIndex(new_row, &word_starts, languages);
word_starts_map_[history_id] = word_starts;
// Update the recent visits information or schedule the update
// as appropriate.
if (history_db) {
// We'd like to check that we're on the history DB thread.
// However, unittest code actually calls this on the UI thread.
// So we don't do any thread checks.
history::VisitVector recent_visits;
// Make sure the private data is going to get as many recent visits as
// ScoredHistoryMatch::GetFrequency() hopes to use.
DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore);
if (history_db->GetMostRecentVisitsForURL(row_id,
kMaxVisitsToStoreInCache,
&recent_visits))
UpdateRecentVisits(row_id, recent_visits);
} else {
DCHECK(tracker);
DCHECK(history_service);
ScheduleUpdateRecentVisits(history_service, row_id, tracker);
}
return true;
}
void URLIndexPrivateData::AddRowWordsToIndex(const history::URLRow& row,
RowWordStarts* word_starts,
const std::string& languages) {
HistoryID history_id = static_cast<HistoryID>(row.id());
// Split URL into individual, unique words then add in the title words.
const GURL& gurl(row.url());
const base::string16& url =
bookmarks::CleanUpUrlForMatching(gurl, languages, NULL);
String16Set url_words = String16SetFromString16(url,
word_starts ? &word_starts->url_word_starts_ : NULL);
const base::string16& title = bookmarks::CleanUpTitleForMatching(row.title());
String16Set title_words = String16SetFromString16(title,
word_starts ? &word_starts->title_word_starts_ : NULL);
String16Set words = base::STLSetUnion<String16Set>(url_words, title_words);
for (String16Set::iterator word_iter = words.begin();
word_iter != words.end(); ++word_iter)
AddWordToIndex(*word_iter, history_id);
search_term_cache_.clear(); // Invalidate the term cache.
}
void URLIndexPrivateData::AddWordToIndex(const base::string16& term,
HistoryID history_id) {
WordMap::iterator word_pos = word_map_.find(term);
if (word_pos != word_map_.end())
UpdateWordHistory(word_pos->second, history_id);
else
AddWordHistory(term, history_id);
}
void URLIndexPrivateData::AddWordHistory(const base::string16& term,
HistoryID history_id) {
WordID word_id = word_list_.size();
if (available_words_.empty()) {
word_list_.push_back(term);
} else {
word_id = *(available_words_.begin());
word_list_[word_id] = term;
available_words_.erase(word_id);
}
word_map_[term] = word_id;
HistoryIDSet history_id_set;
history_id_set.insert(history_id);
word_id_history_map_[word_id] = history_id_set;
AddToHistoryIDWordMap(history_id, word_id);
// For each character in the newly added word (i.e. a word that is not
// already in the word index), add the word to the character index.
Char16Set characters = Char16SetFromString16(term);
for (Char16Set::iterator uni_char_iter = characters.begin();
uni_char_iter != characters.end(); ++uni_char_iter) {
base::char16 uni_char = *uni_char_iter;
CharWordIDMap::iterator char_iter = char_word_map_.find(uni_char);
if (char_iter != char_word_map_.end()) {
// Update existing entry in the char/word index.
WordIDSet& word_id_set(char_iter->second);
word_id_set.insert(word_id);
} else {
// Create a new entry in the char/word index.
WordIDSet word_id_set;
word_id_set.insert(word_id);
char_word_map_[uni_char] = word_id_set;
}
}
}
void URLIndexPrivateData::UpdateWordHistory(WordID word_id,
HistoryID history_id) {
WordIDHistoryMap::iterator history_pos = word_id_history_map_.find(word_id);
DCHECK(history_pos != word_id_history_map_.end());
HistoryIDSet& history_id_set(history_pos->second);
history_id_set.insert(history_id);
AddToHistoryIDWordMap(history_id, word_id);
}
void URLIndexPrivateData::AddToHistoryIDWordMap(HistoryID history_id,
WordID word_id) {
HistoryIDWordMap::iterator iter = history_id_word_map_.find(history_id);
if (iter != history_id_word_map_.end()) {
WordIDSet& word_id_set(iter->second);
word_id_set.insert(word_id);
} else {
WordIDSet word_id_set;
word_id_set.insert(word_id);
history_id_word_map_[history_id] = word_id_set;
}
}
void URLIndexPrivateData::RemoveRowFromIndex(const history::URLRow& row) {
RemoveRowWordsFromIndex(row);
HistoryID history_id = static_cast<HistoryID>(row.id());
history_info_map_.erase(history_id);
word_starts_map_.erase(history_id);
}
void URLIndexPrivateData::RemoveRowWordsFromIndex(const history::URLRow& row) {
// Remove the entries in history_id_word_map_ and word_id_history_map_ for
// this row.
HistoryID history_id = static_cast<HistoryID>(row.id());
WordIDSet word_id_set = history_id_word_map_[history_id];
history_id_word_map_.erase(history_id);
// Reconcile any changes to word usage.
for (WordIDSet::iterator word_id_iter = word_id_set.begin();
word_id_iter != word_id_set.end(); ++word_id_iter) {
WordID word_id = *word_id_iter;
word_id_history_map_[word_id].erase(history_id);
if (!word_id_history_map_[word_id].empty())
continue; // The word is still in use.
// The word is no longer in use. Reconcile any changes to character usage.
base::string16 word = word_list_[word_id];
Char16Set characters = Char16SetFromString16(word);
for (Char16Set::iterator uni_char_iter = characters.begin();
uni_char_iter != characters.end(); ++uni_char_iter) {
base::char16 uni_char = *uni_char_iter;
char_word_map_[uni_char].erase(word_id);
if (char_word_map_[uni_char].empty())
char_word_map_.erase(uni_char); // No longer in use.
}
// Complete the removal of references to the word.
word_id_history_map_.erase(word_id);
word_map_.erase(word);
word_list_[word_id] = base::string16();
available_words_.insert(word_id);
}
}
void URLIndexPrivateData::ResetSearchTermCache() {
for (SearchTermCacheMap::iterator iter = search_term_cache_.begin();
iter != search_term_cache_.end(); ++iter)
iter->second.used_ = false;
}
bool URLIndexPrivateData::SaveToFile(const base::FilePath& file_path) {
base::TimeTicks beginning_time = base::TimeTicks::Now();
InMemoryURLIndexCacheItem index_cache;
SavePrivateData(&index_cache);
std::string data;
if (!index_cache.SerializeToString(&data)) {
LOG(WARNING) << "Failed to serialize the InMemoryURLIndex cache.";
return false;
}
int size = data.size();
if (base::WriteFile(file_path, data.c_str(), size) != size) {
LOG(WARNING) << "Failed to write " << file_path.value();
return false;
}
UMA_HISTOGRAM_TIMES("History.InMemoryURLIndexSaveCacheTime",
base::TimeTicks::Now() - beginning_time);
return true;
}
void URLIndexPrivateData::SavePrivateData(
InMemoryURLIndexCacheItem* cache) const {
DCHECK(cache);
cache->set_last_rebuild_timestamp(
last_time_rebuilt_from_history_.ToInternalValue());
cache->set_version(saved_cache_version_);
// history_item_count_ is no longer used but rather than change the protobuf
// definition use a placeholder. This will go away with the switch to SQLite.
cache->set_history_item_count(0);
SaveWordList(cache);
SaveWordMap(cache);
SaveCharWordMap(cache);
SaveWordIDHistoryMap(cache);
SaveHistoryInfoMap(cache);
SaveWordStartsMap(cache);
}
void URLIndexPrivateData::SaveWordList(InMemoryURLIndexCacheItem* cache) const {
if (word_list_.empty())
return;
WordListItem* list_item = cache->mutable_word_list();
list_item->set_word_count(word_list_.size());
for (String16Vector::const_iterator iter = word_list_.begin();
iter != word_list_.end(); ++iter)
list_item->add_word(base::UTF16ToUTF8(*iter));
}
void URLIndexPrivateData::SaveWordMap(InMemoryURLIndexCacheItem* cache) const {
if (word_map_.empty())
return;
WordMapItem* map_item = cache->mutable_word_map();
map_item->set_item_count(word_map_.size());
for (WordMap::const_iterator iter = word_map_.begin();
iter != word_map_.end(); ++iter) {
WordMapEntry* map_entry = map_item->add_word_map_entry();
map_entry->set_word(base::UTF16ToUTF8(iter->first));
map_entry->set_word_id(iter->second);
}
}
void URLIndexPrivateData::SaveCharWordMap(
InMemoryURLIndexCacheItem* cache) const {
if (char_word_map_.empty())
return;
CharWordMapItem* map_item = cache->mutable_char_word_map();
map_item->set_item_count(char_word_map_.size());
for (CharWordIDMap::const_iterator iter = char_word_map_.begin();
iter != char_word_map_.end(); ++iter) {
CharWordMapEntry* map_entry = map_item->add_char_word_map_entry();
map_entry->set_char_16(iter->first);
const WordIDSet& word_id_set(iter->second);
map_entry->set_item_count(word_id_set.size());
for (WordIDSet::const_iterator set_iter = word_id_set.begin();
set_iter != word_id_set.end(); ++set_iter)
map_entry->add_word_id(*set_iter);
}
}
void URLIndexPrivateData::SaveWordIDHistoryMap(
InMemoryURLIndexCacheItem* cache) const {
if (word_id_history_map_.empty())
return;
WordIDHistoryMapItem* map_item = cache->mutable_word_id_history_map();
map_item->set_item_count(word_id_history_map_.size());
for (WordIDHistoryMap::const_iterator iter = word_id_history_map_.begin();
iter != word_id_history_map_.end(); ++iter) {
WordIDHistoryMapEntry* map_entry =
map_item->add_word_id_history_map_entry();
map_entry->set_word_id(iter->first);
const HistoryIDSet& history_id_set(iter->second);
map_entry->set_item_count(history_id_set.size());
for (HistoryIDSet::const_iterator set_iter = history_id_set.begin();
set_iter != history_id_set.end(); ++set_iter)
map_entry->add_history_id(*set_iter);
}
}
void URLIndexPrivateData::SaveHistoryInfoMap(
InMemoryURLIndexCacheItem* cache) const {
if (history_info_map_.empty())
return;
HistoryInfoMapItem* map_item = cache->mutable_history_info_map();
map_item->set_item_count(history_info_map_.size());
for (HistoryInfoMap::const_iterator iter = history_info_map_.begin();
iter != history_info_map_.end(); ++iter) {
HistoryInfoMapEntry* map_entry = map_item->add_history_info_map_entry();
map_entry->set_history_id(iter->first);
const history::URLRow& url_row(iter->second.url_row);
// Note: We only save information that contributes to the index so there
// is no need to save search_term_cache_ (not persistent).
map_entry->set_visit_count(url_row.visit_count());
map_entry->set_typed_count(url_row.typed_count());
map_entry->set_last_visit(url_row.last_visit().ToInternalValue());
map_entry->set_url(url_row.url().spec());
map_entry->set_title(base::UTF16ToUTF8(url_row.title()));
const VisitInfoVector& visits(iter->second.visits);
for (VisitInfoVector::const_iterator visit_iter = visits.begin();
visit_iter != visits.end(); ++visit_iter) {
HistoryInfoMapEntry_VisitInfo* visit_info = map_entry->add_visits();
visit_info->set_visit_time(visit_iter->first.ToInternalValue());
visit_info->set_transition_type(visit_iter->second);
}
}
}
void URLIndexPrivateData::SaveWordStartsMap(
InMemoryURLIndexCacheItem* cache) const {
if (word_starts_map_.empty())
return;
// For unit testing: Enable saving of the cache as an earlier version to
// allow testing of cache file upgrading in ReadFromFile().
// TODO(mrossetti): Instead of intruding on production code with this kind of
// test harness, save a copy of an older version cache with known results.
// Implement this when switching the caching over to SQLite.
if (saved_cache_version_ < 1)
return;
WordStartsMapItem* map_item = cache->mutable_word_starts_map();
map_item->set_item_count(word_starts_map_.size());
for (WordStartsMap::const_iterator iter = word_starts_map_.begin();
iter != word_starts_map_.end(); ++iter) {
WordStartsMapEntry* map_entry = map_item->add_word_starts_map_entry();
map_entry->set_history_id(iter->first);
const RowWordStarts& word_starts(iter->second);
for (WordStarts::const_iterator i = word_starts.url_word_starts_.begin();
i != word_starts.url_word_starts_.end(); ++i)
map_entry->add_url_word_starts(*i);
for (WordStarts::const_iterator i = word_starts.title_word_starts_.begin();
i != word_starts.title_word_starts_.end(); ++i)
map_entry->add_title_word_starts(*i);
}
}
bool URLIndexPrivateData::RestorePrivateData(
const InMemoryURLIndexCacheItem& cache,
const std::string& languages) {
last_time_rebuilt_from_history_ =
base::Time::FromInternalValue(cache.last_rebuild_timestamp());
const base::TimeDelta rebuilt_ago =
base::Time::Now() - last_time_rebuilt_from_history_;
if ((rebuilt_ago > base::TimeDelta::FromDays(7)) ||
(rebuilt_ago < base::TimeDelta::FromDays(-1))) {
// Cache is more than a week old or, somehow, from some time in the future.
// It's probably a good time to rebuild the index from history to
// allow synced entries to now appear, expired entries to disappear, etc.
// Allow one day in the future to make the cache not rebuild on simple
// system clock changes such as time zone changes.
return false;
}
if (cache.has_version()) {
if (cache.version() < kCurrentCacheFileVersion) {
// Don't try to restore an old format cache file. (This will cause
// the InMemoryURLIndex to schedule rebuilding the URLIndexPrivateData
// from history.)
return false;
}
restored_cache_version_ = cache.version();
}
return RestoreWordList(cache) && RestoreWordMap(cache) &&
RestoreCharWordMap(cache) && RestoreWordIDHistoryMap(cache) &&
RestoreHistoryInfoMap(cache) && RestoreWordStartsMap(cache, languages);
}
bool URLIndexPrivateData::RestoreWordList(
const InMemoryURLIndexCacheItem& cache) {
if (!cache.has_word_list())
return false;
const WordListItem& list_item(cache.word_list());
uint32 expected_item_count = list_item.word_count();
uint32 actual_item_count = list_item.word_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<std::string>& words(list_item.word());
for (RepeatedPtrField<std::string>::const_iterator iter = words.begin();
iter != words.end(); ++iter)
word_list_.push_back(base::UTF8ToUTF16(*iter));
return true;
}
bool URLIndexPrivateData::RestoreWordMap(
const InMemoryURLIndexCacheItem& cache) {
if (!cache.has_word_map())
return false;
const WordMapItem& list_item(cache.word_map());
uint32 expected_item_count = list_item.item_count();
uint32 actual_item_count = list_item.word_map_entry_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<WordMapEntry>& entries(list_item.word_map_entry());
for (RepeatedPtrField<WordMapEntry>::const_iterator iter = entries.begin();
iter != entries.end(); ++iter)
word_map_[base::UTF8ToUTF16(iter->word())] = iter->word_id();
return true;
}
bool URLIndexPrivateData::RestoreCharWordMap(
const InMemoryURLIndexCacheItem& cache) {
if (!cache.has_char_word_map())
return false;
const CharWordMapItem& list_item(cache.char_word_map());
uint32 expected_item_count = list_item.item_count();
uint32 actual_item_count = list_item.char_word_map_entry_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<CharWordMapEntry>&
entries(list_item.char_word_map_entry());
for (RepeatedPtrField<CharWordMapEntry>::const_iterator iter =
entries.begin(); iter != entries.end(); ++iter) {
expected_item_count = iter->item_count();
actual_item_count = iter->word_id_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
base::char16 uni_char = static_cast<base::char16>(iter->char_16());
WordIDSet word_id_set;
const RepeatedField<int32>& word_ids(iter->word_id());
for (RepeatedField<int32>::const_iterator jiter = word_ids.begin();
jiter != word_ids.end(); ++jiter)
word_id_set.insert(*jiter);
char_word_map_[uni_char] = word_id_set;
}
return true;
}
bool URLIndexPrivateData::RestoreWordIDHistoryMap(
const InMemoryURLIndexCacheItem& cache) {
if (!cache.has_word_id_history_map())
return false;
const WordIDHistoryMapItem& list_item(cache.word_id_history_map());
uint32 expected_item_count = list_item.item_count();
uint32 actual_item_count = list_item.word_id_history_map_entry_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<WordIDHistoryMapEntry>&
entries(list_item.word_id_history_map_entry());
for (RepeatedPtrField<WordIDHistoryMapEntry>::const_iterator iter =
entries.begin(); iter != entries.end(); ++iter) {
expected_item_count = iter->item_count();
actual_item_count = iter->history_id_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
WordID word_id = iter->word_id();
HistoryIDSet history_id_set;
const RepeatedField<int64>& history_ids(iter->history_id());
for (RepeatedField<int64>::const_iterator jiter = history_ids.begin();
jiter != history_ids.end(); ++jiter) {
history_id_set.insert(*jiter);
AddToHistoryIDWordMap(*jiter, word_id);
}
word_id_history_map_[word_id] = history_id_set;
}
return true;
}
bool URLIndexPrivateData::RestoreHistoryInfoMap(
const InMemoryURLIndexCacheItem& cache) {
if (!cache.has_history_info_map())
return false;
const HistoryInfoMapItem& list_item(cache.history_info_map());
uint32 expected_item_count = list_item.item_count();
uint32 actual_item_count = list_item.history_info_map_entry_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<HistoryInfoMapEntry>&
entries(list_item.history_info_map_entry());
for (RepeatedPtrField<HistoryInfoMapEntry>::const_iterator iter =
entries.begin(); iter != entries.end(); ++iter) {
HistoryID history_id = iter->history_id();
GURL url(iter->url());
history::URLRow url_row(url, history_id);
url_row.set_visit_count(iter->visit_count());
url_row.set_typed_count(iter->typed_count());
url_row.set_last_visit(base::Time::FromInternalValue(iter->last_visit()));
if (iter->has_title()) {
base::string16 title(base::UTF8ToUTF16(iter->title()));
url_row.set_title(title);
}
history_info_map_[history_id].url_row = url_row;
// Restore visits list.
VisitInfoVector visits;
visits.reserve(iter->visits_size());
for (int i = 0; i < iter->visits_size(); ++i) {
visits.push_back(std::make_pair(
base::Time::FromInternalValue(iter->visits(i).visit_time()),
ui::PageTransitionFromInt(iter->visits(i).transition_type())));
}
history_info_map_[history_id].visits = visits;
}
return true;
}
bool URLIndexPrivateData::RestoreWordStartsMap(
const InMemoryURLIndexCacheItem& cache,
const std::string& languages) {
// Note that this function must be called after RestoreHistoryInfoMap() has
// been run as the word starts may have to be recalculated from the urls and
// page titles.
if (cache.has_word_starts_map()) {
const WordStartsMapItem& list_item(cache.word_starts_map());
uint32 expected_item_count = list_item.item_count();
uint32 actual_item_count = list_item.word_starts_map_entry_size();
if (actual_item_count == 0 || actual_item_count != expected_item_count)
return false;
const RepeatedPtrField<WordStartsMapEntry>&
entries(list_item.word_starts_map_entry());
for (RepeatedPtrField<WordStartsMapEntry>::const_iterator iter =
entries.begin(); iter != entries.end(); ++iter) {
HistoryID history_id = iter->history_id();
RowWordStarts word_starts;
// Restore the URL word starts.
const RepeatedField<int32>& url_starts(iter->url_word_starts());
for (RepeatedField<int32>::const_iterator jiter = url_starts.begin();
jiter != url_starts.end(); ++jiter)
word_starts.url_word_starts_.push_back(*jiter);
// Restore the page title word starts.
const RepeatedField<int32>& title_starts(iter->title_word_starts());
for (RepeatedField<int32>::const_iterator jiter = title_starts.begin();
jiter != title_starts.end(); ++jiter)
word_starts.title_word_starts_.push_back(*jiter);
word_starts_map_[history_id] = word_starts;
}
} else {
// Since the cache did not contain any word starts we must rebuild then from
// the URL and page titles.
for (HistoryInfoMap::const_iterator iter = history_info_map_.begin();
iter != history_info_map_.end(); ++iter) {
RowWordStarts word_starts;
const history::URLRow& row(iter->second.url_row);
const base::string16& url =
bookmarks::CleanUpUrlForMatching(row.url(), languages, NULL);
String16VectorFromString16(url, false, &word_starts.url_word_starts_);
const base::string16& title =
bookmarks::CleanUpTitleForMatching(row.title());
String16VectorFromString16(title, false, &word_starts.title_word_starts_);
word_starts_map_[iter->first] = word_starts;
}
}
return true;
}
// static
bool URLIndexPrivateData::URLSchemeIsWhitelisted(
const GURL& gurl,
const std::set<std::string>& whitelist) {
return whitelist.find(gurl.scheme()) != whitelist.end();
}
// SearchTermCacheItem ---------------------------------------------------------
URLIndexPrivateData::SearchTermCacheItem::SearchTermCacheItem(
const WordIDSet& word_id_set,
const HistoryIDSet& history_id_set)
: word_id_set_(word_id_set), history_id_set_(history_id_set), used_(true) {
}
URLIndexPrivateData::SearchTermCacheItem::SearchTermCacheItem() : used_(true) {
}
URLIndexPrivateData::SearchTermCacheItem::~SearchTermCacheItem() {
}
// URLIndexPrivateData::AddHistoryMatch ----------------------------------------
URLIndexPrivateData::AddHistoryMatch::AddHistoryMatch(
bookmarks::BookmarkModel* bookmark_model,
const URLIndexPrivateData& private_data,
const std::string& languages,
const base::string16& lower_string,
const String16Vector& lower_terms,
const base::Time now)
: bookmark_model_(bookmark_model),
private_data_(private_data),
languages_(languages),
lower_string_(lower_string),
lower_terms_(lower_terms),
now_(now) {
// Calculate offsets for each term. For instance, the offset for
// ".net" should be 1, indicating that the actual word-part of the term
// starts at offset 1.
lower_terms_to_word_starts_offsets_.resize(lower_terms_.size(), 0u);
for (size_t i = 0; i < lower_terms_.size(); ++i) {
base::i18n::BreakIterator iter(lower_terms_[i],
base::i18n::BreakIterator::BREAK_WORD);
// If the iterator doesn't work, assume an offset of 0.
if (!iter.Init())
continue;
// Find the first word start.
while (iter.Advance() && !iter.IsWord()) {}
if (iter.IsWord())
lower_terms_to_word_starts_offsets_[i] = iter.prev();
// Else: the iterator didn't find a word break. Assume an offset of 0.
}
}
URLIndexPrivateData::AddHistoryMatch::~AddHistoryMatch() {
}
void URLIndexPrivateData::AddHistoryMatch::operator()(
const HistoryID history_id) {
HistoryInfoMap::const_iterator hist_pos =
private_data_.history_info_map_.find(history_id);
if (hist_pos != private_data_.history_info_map_.end()) {
const history::URLRow& hist_item = hist_pos->second.url_row;
const VisitInfoVector& visits = hist_pos->second.visits;
WordStartsMap::const_iterator starts_pos =
private_data_.word_starts_map_.find(history_id);
DCHECK(starts_pos != private_data_.word_starts_map_.end());
ScoredHistoryMatch match(
hist_item, visits, languages_, lower_string_, lower_terms_,
lower_terms_to_word_starts_offsets_, starts_pos->second,
bookmark_model_ && bookmark_model_->IsBookmarked(hist_item.url()),
now_);
if (match.raw_score > 0)
scored_matches_.push_back(match);
}
}
// URLIndexPrivateData::HistoryItemFactorGreater -------------------------------
URLIndexPrivateData::HistoryItemFactorGreater::HistoryItemFactorGreater(
const HistoryInfoMap& history_info_map)
: history_info_map_(history_info_map) {
}
URLIndexPrivateData::HistoryItemFactorGreater::~HistoryItemFactorGreater() {
}
bool URLIndexPrivateData::HistoryItemFactorGreater::operator()(
const HistoryID h1,
const HistoryID h2) {
HistoryInfoMap::const_iterator entry1(history_info_map_.find(h1));
if (entry1 == history_info_map_.end())
return false;
HistoryInfoMap::const_iterator entry2(history_info_map_.find(h2));
if (entry2 == history_info_map_.end())
return true;
const history::URLRow& r1(entry1->second.url_row);
const history::URLRow& r2(entry2->second.url_row);
// First cut: typed count, visit count, recency.
// TODO(mrossetti): This is too simplistic. Consider an approach which ranks
// recently visited (within the last 12/24 hours) as highly important. Get
// input from mpearson.
if (r1.typed_count() != r2.typed_count())
return (r1.typed_count() > r2.typed_count());
if (r1.visit_count() != r2.visit_count())
return (r1.visit_count() > r2.visit_count());
return (r1.last_visit() > r2.last_visit());
}
| mou4e/zirconium | chrome/browser/autocomplete/url_index_private_data.cc | C++ | bsd-3-clause | 54,944 |
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "core/timing/WorkerGlobalScopePerformance.h"
#include "core/timing/WorkerPerformance.h"
#include "core/workers/WorkerGlobalScope.h"
namespace blink {
WorkerGlobalScopePerformance::WorkerGlobalScopePerformance()
{
}
const char* WorkerGlobalScopePerformance::supplementName()
{
return "WorkerGlobalScopePerformance";
}
WorkerGlobalScopePerformance& WorkerGlobalScopePerformance::from(WorkerGlobalScope& context)
{
WorkerGlobalScopePerformance* supplement = static_cast<WorkerGlobalScopePerformance*>(Supplement<WorkerGlobalScope>::from(context, supplementName()));
if (!supplement) {
supplement = new WorkerGlobalScopePerformance;
provideTo(context, supplementName(), supplement);
}
return *supplement;
}
WorkerPerformance* WorkerGlobalScopePerformance::performance(WorkerGlobalScope& context)
{
return from(context).performance(&context);
}
WorkerPerformance* WorkerGlobalScopePerformance::performance(WorkerGlobalScope* context)
{
if (!m_performance)
m_performance = WorkerPerformance::create(context);
return m_performance.get();
}
DEFINE_TRACE(WorkerGlobalScopePerformance)
{
visitor->trace(m_performance);
Supplement<WorkerGlobalScope>::trace(visitor);
}
} // namespace blink
| danakj/chromium | third_party/WebKit/Source/core/timing/WorkerGlobalScopePerformance.cpp | C++ | bsd-3-clause | 2,825 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.