answer
stringlengths
15
1.25M
#include "ui/compositor/paint_context.h" #include "third_party/skia/include/core/SkPictureRecorder.h" #include "ui/gfx/canvas.h" namespace ui { PaintContext::PaintContext(cc::DisplayItemList* list, float device_scale_factor, const gfx::Rect& invalidation) : list_(list), owned_recorder_(new SkPictureRecorder), recorder_(owned_recorder_.get()), <API key>(device_scale_factor), invalidation_(invalidation) { #if DCHECK_IS_ON() root_visited_ = nullptr; <API key> = false; #endif } PaintContext::PaintContext(const PaintContext& other, const gfx::Vector2d& offset) : list_(other.list_), owned_recorder_(nullptr), recorder_(other.recorder_), <API key>(other.<API key>), invalidation_(other.invalidation_), offset_(other.offset_ + offset) { #if DCHECK_IS_ON() root_visited_ = other.root_visited_; <API key> = other.<API key>; #endif } PaintContext::PaintContext(const PaintContext& other, <API key> c) : list_(other.list_), owned_recorder_(nullptr), recorder_(other.recorder_), <API key>(other.<API key>), invalidation_(), offset_(other.offset_) { #if DCHECK_IS_ON() root_visited_ = other.root_visited_; <API key> = other.<API key>; #endif } PaintContext::~PaintContext() { } gfx::Rect PaintContext::ToLayerSpaceBounds( const gfx::Size& size_in_context) const { return gfx::Rect(size_in_context) + offset_; } gfx::Rect PaintContext::ToLayerSpaceRect(const gfx::Rect& rect) const { return rect + offset_; } } // namespace ui
package restful const ( MIME_XML = "application/xml" // Accept or Content-Type used in Consumes() and/or Produces() MIME_JSON = "application/json" // Accept or Content-Type used in Consumes() and/or Produces() MIME_OCTET = "application/octet-stream" // If Content-Type is not present in request, use the default HEADER_Allow = "Allow" HEADER_Accept = "Accept" HEADER_Origin = "Origin" HEADER_ContentType = "Content-Type" HEADER_LastModified = "Last-Modified" <API key> = "Accept-Encoding" <API key> = "Content-Encoding" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" <API key> = "<API key>" ENCODING_GZIP = "gzip" ENCODING_DEFLATE = "deflate" )
// Use of this source code is governed by an ISC package wire import ( "fmt" "io" ) const ( // <API key> is the maximum byte size of a data // element to add to the Bloom filter. It is equal to the // maximum element size of a script. <API key> = 520 ) // MsgFilterAdd implements the Message interface and represents a bitcoin // filteradd message. It is used to add a data element to an existing Bloom // filter. // This message was not added until protocol version BIP0037Version. type MsgFilterAdd struct { Data []byte } // BtcDecode decodes r using the bitcoin protocol encoding into the receiver. // This is part of the Message interface implementation. func (msg *MsgFilterAdd) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error { if pver < BIP0037Version { str := fmt.Sprintf("filteradd message invalid for protocol "+ "version %d", pver) return messageError("MsgFilterAdd.BtcDecode", str) } var err error msg.Data, err = ReadVarBytes(r, pver, <API key>, "filteradd data") return err } // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. // This is part of the Message interface implementation. func (msg *MsgFilterAdd) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error { if pver < BIP0037Version { str := fmt.Sprintf("filteradd message invalid for protocol "+ "version %d", pver) return messageError("MsgFilterAdd.BtcEncode", str) } size := len(msg.Data) if size > <API key> { str := fmt.Sprintf("filteradd size too large for message "+ "[size %v, max %v]", size, <API key>) return messageError("MsgFilterAdd.BtcEncode", str) } return WriteVarBytes(w, pver, msg.Data) } // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgFilterAdd) Command() string { return CmdFilterAdd } // MaxPayloadLength returns the maximum length the payload can be for the // receiver. This is part of the Message interface implementation. func (msg *MsgFilterAdd) MaxPayloadLength(pver uint32) uint32 { return uint32(VarIntSerializeSize(<API key>)) + <API key> } // NewMsgFilterAdd returns a new bitcoin filteradd message that conforms to the // Message interface. See MsgFilterAdd for details. func NewMsgFilterAdd(data []byte) *MsgFilterAdd { return &MsgFilterAdd{ Data: data, } }
import { CrossTab20 } from "../../"; export = CrossTab20;
.mdSearchBar input{height:27px;} ul.mdMemberList li p.mdHoverActions a{font-size:10px;}
## Databases # How do I run this app without a database? Change the following: javascript /* * config/env.js */ DB_TYPE: process.env.DB_TYPE || DB_TYPES.NONE # How do I switch to a different database? Currently, we support these DB_TYPES: - MONGO - POSTGRES - NONE We abstracted the DB config in `env` to enable you to require the correct files if you were to use a different database, e.g. postgresql. javascript /* * config/env.js */ DB_TYPE: process.env.DB_TYPE || DB_TYPES.YOUR_DB You will need to add a folder after `/db` with [may] contain the following ORM specific code: - models - controllers - passport logic - connecting to the database - session stores - deserialising users ##Setting up Postgres # Install Postgres as your database: bash # Update brew formulae brew update # Install Postgres brew install postgres # Run your Postgres server bash postgres -D /usr/local/var/postgres # Setup your postgres database bash createuser root createdb <API key> # or test/production npm run sequelize db:migrate # Installing on Heroku bash heroku addons:create heroku-postgresql:<PLANNAME> --as POSTGRES_DB heroku run bash # once in bash npm run sequelize db:migrate # exit heroku bash
<?php namespace Sylius\Bundle\FixturesBundle\Listener; use Doctrine\Common\DataFixtures\Purger\ORMPurger; use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ORM\<API key>; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; /** * @author Kamil Kokot <kamil.kokot@lakion.com> */ final class ORMPurgerListener extends AbstractListener implements <API key> { /** * @var ManagerRegistry */ private $managerRegistry; /** * @var array */ private static $purgeModes = [ 'delete' => ORMPurger::PURGE_MODE_DELETE, 'truncate' => ORMPurger::PURGE_MODE_TRUNCATE, ]; /** * @param ManagerRegistry $managerRegistry */ public function __construct(ManagerRegistry $managerRegistry) { $this->managerRegistry = $managerRegistry; } /** * {@inheritdoc} */ public function beforeSuite(SuiteEvent $suiteEvent, array $options) { foreach ($options['managers'] as $managerName) { /** @var <API key> $manager */ $manager = $this->managerRegistry->getManager($managerName); $purger = new ORMPurger($manager); $purger->setPurgeMode(static::$purgeModes[$options['mode']]); $purger->purge(); } } /** * {@inheritdoc} */ public function getName() { return 'orm_purger'; } /** * {@inheritdoc} */ protected function <API key>(ArrayNodeDefinition $optionsNode) { $optionsNodeBuilder = $optionsNode->children(); $optionsNodeBuilder ->enumNode('mode') ->values(['delete', 'truncate']) ->defaultValue('delete') ; $optionsNodeBuilder ->arrayNode('managers') ->defaultValue([null]) ->prototype('scalar') ; } }
<?xml version="1.0" encoding="utf-8"?> <html xmlns:MadCap="http: <head> </head> <body> <h1>Copying Design to Child Pages</h1> <p>How to copy the design applied to a page to all of its child (descendant) pages using the ControlBar. This applies the Page Skin and Page Container settings of the parent page to all child pages. This setting is only available for existing pages with child pages.</p> <ol> <li value="1">Navigate to the parent page whose design you want to copy.</li> <li>On the <b>ControlBar</b>, hover over the <span style="font-style: normal; text-decoration: none; font-weight: bold;">Edit Page</span> menu option and select <b>Page Appearance</b>.</li> <li>This will open the <b>Page Settings</b> popup on the <b>Advanced Settings</b> tab with the <b>Appearance Section</b> opened.</li> <li>Scroll down a little bit and click the Copy Design button. This displays the message "Skin and container will be replaced for all children of this page. Are you sure you want to continue?"</li> </ol> <p> <img src="../../Resources/Images/Admin/Pages/<API key>.png" /> </p> <ol> <li value="5">Click the <b>Yes</b> button to confirm.</li> </ol> </body> </html>
<?php /** * API module that facilitates the unblocking of users. Requires API write mode * to be enabled. * * @ingroup API */ class ApiUnblock extends ApiBase { public function __construct( $main, $action ) { parent::__construct( $main, $action ); } /** * Unblocks the specified user or provides the reason the unblock failed. */ public function execute() { $user = $this->getUser(); $params = $this-><API key>(); if ( $params['gettoken'] ) { $res['unblocktoken'] = $user->getEditToken( '', $this->getMain()->getRequest() ); $this->getResult()->addValue( null, $this->getModuleName(), $res ); return; } if ( is_null( $params['id'] ) && is_null( $params['user'] ) ) { $this->dieUsageMsg( 'unblock-notarget' ); } if ( !is_null( $params['id'] ) && !is_null( $params['user'] ) ) { $this->dieUsageMsg( 'unblock-idanduser' ); } if ( !$user->isAllowed( 'block' ) ) { $this->dieUsageMsg( 'cantunblock' ); } # bug 15810: blocked admins should have limited access here if ( $user->isBlocked() ) { $status = SpecialBlock::checkUnblockSelf( $params['user'], $user ); if ( $status !== true ) { $this->dieUsageMsg( $status ); } } $data = array( 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}", 'Reason' => is_null( $params['reason'] ) ? '' : $params['reason'] ); $block = Block::newFromTarget( $data['Target'] ); $retval = SpecialUnblock::processUnblock( $data, $this->getContext() ); if ( $retval !== true ) { $this->dieUsageMsg( $retval[0] ); } $res['id'] = $block->getId(); $res['user'] = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget(); $res['reason'] = $params['reason']; $this->getResult()->addValue( null, $this->getModuleName(), $res ); } public function mustBePosted() { return true; } public function isWriteMode() { return true; } public function getAllowedParams() { return array( 'id' => array( ApiBase::PARAM_TYPE => 'integer', ), 'user' => null, 'token' => null, 'gettoken' => false, 'reason' => null, ); } public function getParamDescription() { $p = $this->getModulePrefix(); return array( 'id' => "ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with {$p}user", 'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id", 'token' => "An unblock token previously obtained through the gettoken parameter or {$p}prop=info", 'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken', 'reason' => 'Reason for unblock (optional)', ); } public function getDescription() { return 'Unblock a user'; } public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'unblock-notarget' ), array( 'unblock-idanduser' ), array( 'cantunblock' ), array( 'ipbblocked' ), array( 'ipbnounblockself' ), ) ); } public function needsToken() { return true; } public function getTokenSalt() { return ''; } public function getExamples() { return array( 'api.php?action=unblock&id=105', 'api.php?action=unblock&user=Bob&reason=Sorry%20Bob' ); } public function getHelpUrls() { return 'https: } public function getVersion() { return __CLASS__ . ': $Id$'; } }
import { PercentageFilled20 } from "../../"; export = PercentageFilled20;
require_relative 'tunes_client' module Spaceship module Tunes class << self # This client stores the default client when using the lazy syntax # Spaceship.app instead of using the spaceship launcher attr_accessor :client # Authenticates with Apple's web services. This method has to be called once # to generate a valid session. The session will automatically be used from then # This method will automatically use the username from the Appfile (if available) # and fetch the password from the Keychain (if available) # @param user (String) (optional): The username (usually the email address) # @param password (String) (optional): The password # @raise <API key>: raised if authentication failed # @return (Spaceship::Client) The client the login method was called for def login(user = nil, password = nil) @client = TunesClient.login(user, password) end # Open up the team selection for the user (if necessary). # If the user is in multiple teams, a team selection is shown. # The user can then select a team by entering the number # @param team_id (String) (optional): The ID of an App Store Connect team # @param team_name (String) (optional): The name of an App Store Connect team def select_team(team_id: nil, team_name: nil) @client.select_team(team_id: team_id, team_name: team_name) end end end end
package org.openhab.persistence.mysql.internal; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Formatter; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; import org.openhab.core.items.GroupItem; import org.openhab.core.items.Item; import org.openhab.core.items.<API key>; import org.openhab.core.items.ItemRegistry; import org.openhab.core.library.items.ColorItem; import org.openhab.core.library.items.ContactItem; import org.openhab.core.library.items.DateTimeItem; import org.openhab.core.library.items.DimmerItem; import org.openhab.core.library.items.NumberItem; import org.openhab.core.library.items.RollershutterItem; import org.openhab.core.library.items.SwitchItem; import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.PercentType; import org.openhab.core.library.types.StringType; import org.openhab.core.persistence.FilterCriteria; import org.openhab.core.persistence.FilterCriteria.Ordering; import org.openhab.core.persistence.HistoricItem; import org.openhab.core.persistence.PersistenceService; import org.openhab.core.persistence.<API key>; import org.openhab.core.types.State; import org.openhab.core.types.UnDefType; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class <API key> implements <API key> { private static final Pattern <API key> = Pattern.compile("^(.*?)\\.([0-9.a-zA-Z]+)$"); private static final Logger logger = LoggerFactory.getLogger(<API key>.class); private String driverClass = "com.mysql.jdbc.Driver"; private String url; private String user; private String password; private boolean initialized = false; protected ItemRegistry itemRegistry; // Error counter - used to reconnect to database on error private int errCnt; private int <API key> = 0; private int waitTimeout = -1; private Connection connection = null; private Map<String, String> sqlTables = new HashMap<String, String>(); private Map<String, String> sqlTypes = new HashMap<String, String>(); /** * Initialise the type array * If other Types like DOUBLE or INT needed for serialisation it can be set in openhab.cfg */ public void activate(final BundleContext bundleContext, final Map<String, Object> config) { sqlTypes.put("CALLITEM", "VARCHAR(200)"); sqlTypes.put("COLORITEM", "VARCHAR(70)"); sqlTypes.put("CONTACTITEM", "VARCHAR(6)"); sqlTypes.put("DATETIMEITEM", "DATETIME"); sqlTypes.put("DIMMERITEM", "TINYINT"); sqlTypes.put("LOCATIONITEM", "VARCHAR(30)"); sqlTypes.put("NUMBERITEM", "DOUBLE"); sqlTypes.put("ROLLERSHUTTERITEM", "TINYINT"); sqlTypes.put("STRINGITEM", "VARCHAR(20000)"); sqlTypes.put("SWITCHITEM", "CHAR(3)"); Iterator<String> keys = config.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); Matcher matcher = <API key>.matcher(key); if (!matcher.matches()) { continue; } matcher.reset(); matcher.find(); if (!matcher.group(1).equals("sqltype")) { continue; } String itemType = matcher.group(2).toUpperCase() + "ITEM"; String value = (String) config.get(key); sqlTypes.put(itemType, value); } <API key>(); url = (String) config.get("url"); if (StringUtils.isBlank(url)) { logger.warn("The SQL database URL is missing - please configure the sql:url parameter in openhab.cfg"); return; } user = (String) config.get("user"); if (StringUtils.isBlank(user)) { logger.warn("The SQL user is missing - please configure the sql:user parameter in openhab.cfg"); return; } password = (String) config.get("password"); if (StringUtils.isBlank(password)) { logger.warn( "The SQL password is missing. Attempting to connect without password. To specify a password configure the sql:password parameter in openhab.cfg."); } String tmpString = (String) config.get("reconnectCnt"); if (StringUtils.isNotBlank(tmpString)) { <API key> = Integer.parseInt(tmpString); } tmpString = (String) config.get("waitTimeout"); if (StringUtils.isNotBlank(tmpString)) { waitTimeout = Integer.parseInt(tmpString); } // reconnect to the database in case the configuration has changed. connectToDatabase(); // connection has been established ... initialization completed! initialized = true; logger.debug("mySQL configuration complete."); } public void deactivate(final int reason) { logger.debug("mySQL persistence bundle stopping. Disconnecting from database."); <API key>(); } public void setItemRegistry(ItemRegistry itemRegistry) { this.itemRegistry = itemRegistry; } public void unsetItemRegistry(ItemRegistry itemRegistry) { this.itemRegistry = null; } /** * @{inheritDoc */ @Override public String getName() { return "mysql"; } /** * * @param i * @return */ private String getItemType(Item i) { Item item = i; if (i instanceof GroupItem) { item = ((GroupItem) i).getBaseItem(); if (item == null) {// if GroupItem:<ItemType> is not defined in *.items using StringType logger.debug( "mySQL: Cannot detect ItemType for {} because the GroupItems' base type isn't set in *.items File.", i.getName()); item = ((GroupItem) i).getMembers().get(0); if (item == null) { logger.debug( "mySQL: No ItemType found for first Child-Member of GroupItem {}, use ItemType STRINGITEM ({}) as Fallback", i.getName(), sqlTypes.get("STRINGITEM")); return sqlTypes.get("STRINGITEM"); } } } String itemType = item.getClass().getSimpleName().toUpperCase(); if (sqlTypes.get(itemType) == null) { logger.debug("mySQL: No sqlType found for ItemType {}, use ItemType STRINGITEM ({}) as Fallback for {}", itemType, sqlTypes.get("STRINGITEM"), i.getName()); return sqlTypes.get("STRINGITEM"); } logger.debug("mySQL: Use ItemType {} ({}) for Item {}", itemType, sqlTypes.get(itemType), itemType, i.getName()); return sqlTypes.get(itemType); } private String getTable(Item item) { PreparedStatement statement = null; String sqlCmd = null; int rowId = 0; String itemName = item.getName(); String tableName = sqlTables.get(itemName); // Table already exists - return the name if (tableName != null) { return tableName; } logger.debug("mySQL: no Table found for itemName={} get:{}", itemName, sqlTables.get(itemName)); // Create a new entry in the Items table. This is the translation of // item name to table try { sqlCmd = new String("INSERT INTO Items (ItemName) VALUES (?)"); statement = connection.prepareStatement(sqlCmd, Statement.<API key>); statement.setString(1, itemName); statement.executeUpdate(); ResultSet resultSet = statement.getGeneratedKeys(); if (resultSet != null && resultSet.next()) { rowId = resultSet.getInt(1); } if (rowId == 0) { throw new SQLException("mySQL: Creating table for item '{}' failed.", itemName); } // Create the table name tableName = new String("Item" + rowId); logger.debug("mySQL: new item {} is Item{}", itemName, rowId); } catch (SQLException e) { errCnt++; logger.error("mySQL: Could not create entry for '{}' in table 'Items' with statement '{}': {}", itemName, sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (SQLException logOrIgnore) { } } } // An error occurred adding the item name into the index list! if (tableName == null) { logger.error("mySQL: tableName was null"); return null; } String mysqlType = getItemType(item); // We have a rowId, create the table for the data sqlCmd = new String( "CREATE TABLE " + tableName + " (Time DATETIME, Value " + mysqlType + ", PRIMARY KEY(Time));"); logger.debug("mySQL: query: {}", sqlCmd); try { statement = connection.prepareStatement(sqlCmd); statement.executeUpdate(); logger.debug("mySQL: Table created for item '{}' with datatype {} in SQL database.", itemName, mysqlType); sqlTables.put(itemName, tableName); } catch (Exception e) { errCnt++; logger.error("mySQL: Could not create table for item '{}' with statement '{}': {}", itemName, sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (Exception hidden) { } } } // Check if the new entry is in the table list // If it's not in the list, then there was an error and we need to do some tidying up // The item needs to be removed from the index table to avoid duplicates if (sqlTables.get(itemName) == null) { logger.error("mySQL: Item '{}' was not added to the table - removing index", itemName); sqlCmd = new String("DELETE FROM Items WHERE ItemName=?"); logger.debug("mySQL: query: {}", sqlCmd); try { statement = connection.prepareStatement(sqlCmd); statement.setString(1, itemName); statement.executeUpdate(); } catch (Exception e) { errCnt++; logger.error("mySQL: Could not remove index for item '{}' with statement '{}': ", itemName, sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (Exception hidden) { } } } } return tableName; } /** * @{inheritDoc */ @Override public void store(Item item, String alias) { // Don't log undefined/uninitialised data if (item.getState() instanceof UnDefType) { return; } // If we've not initialised the bundle, then return if (initialized == false) { return; } // Connect to mySQL server if we're not already connected if (!isConnected()) { connectToDatabase(); } // If we still didn't manage to connect, then return! if (!isConnected()) { logger.warn( "mySQL: No connection to database. Can not persist item '{}'! " + "Will retry connecting to database when error count:{} equals <API key>:{}", item, errCnt, <API key>); return; } // Get the table name for this item String tableName = getTable(item); if (tableName == null) { logger.error("Unable to store item '{}'.", item.getName()); return; } // Do some type conversion to ensure we know the data type. // This is necessary for items that have multiple types and may return their // state in a format that's not preferred or compatible with the MySQL type. // eg. DimmerItem can return OnOffType (ON, OFF), or PercentType (0-100). // We need to make sure we cover the best type for serialisation. String value; if (item instanceof ColorItem) { value = item.getStateAs(HSBType.class).toString(); } else if (item instanceof RollershutterItem) { value = item.getStateAs(PercentType.class).toString(); } else { /* * !!ATTENTION!! * * 1. * DimmerItem.getStateAs(PercentType.class).toString() always returns 0 * RollershutterItem.getStateAs(PercentType.class).toString() works as expected * * 2. * (item instanceof ColorItem) == (item instanceof DimmerItem) = true * Therefore for instance tests ColorItem always has to be tested before DimmerItem * * !!ATTENTION!! */ // All other items should return the best format by default value = item.getState().toString(); } String sqlCmd = null; PreparedStatement statement = null; try { sqlCmd = new String( "INSERT INTO " + tableName + " (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;"); statement = connection.prepareStatement(sqlCmd); statement.setString(1, value); statement.setString(2, value); statement.executeUpdate(); logger.debug("mySQL: Stored item '{}' as '{}'[{}] in SQL database at {}.", item.getName(), item.getState().toString(), value, (new java.util.Date()).toString()); logger.debug("mySQL: query: {}", sqlCmd); // Success errCnt = 0; } catch (Exception e) { errCnt++; logger.error("mySQL: Could not store item '{}' in database with " + "statement '{}': {}", item.getName(), sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (Exception hidden) { } } } } /** * @{inheritDoc */ @Override public void store(Item item) { store(item, null); } /** * Checks if we have a database connection * * @return true if connection has been established, false otherwise */ private boolean isConnected() { // Check if connection is valid try { if (connection != null && !connection.isValid(5000)) { errCnt++; logger.error("mySQL: Connection is not valid!"); } } catch (SQLException e) { errCnt++; logger.error("mySQL: Error while checking connection: {}", e); } // Error check. If we have '<API key>' errors in a row, then // reconnect to the database if (<API key> != 0 && errCnt >= <API key>) { logger.error("mySQL: Error count exceeded {}. Disconnecting database.", <API key>); <API key>(); } return connection != null; } /** * Connects to the database */ private void connectToDatabase() { try { // Reset the error counter errCnt = 0; logger.debug("mySQL: Attempting to connect to database {}", url); Class.forName(driverClass).newInstance(); connection = DriverManager.getConnection(url, user, password); logger.debug("mySQL: Connected to database {}", url); Statement st = connection.createStatement(); int result = st.executeUpdate("SHOW TABLES LIKE 'Items'"); st.close(); if (waitTimeout != -1) { logger.debug("mySQL: Setting wait_timeout to {} seconds.", waitTimeout); st = connection.createStatement(); st.executeUpdate("SET SESSION wait_timeout=" + waitTimeout); st.close(); } if (result == 0) { st = connection.createStatement(); st.executeUpdate( "CREATE TABLE Items (ItemId INT NOT NULL AUTO_INCREMENT,ItemName VARCHAR(200) NOT NULL,PRIMARY KEY (ItemId));", Statement.<API key>); st.close(); } // Retrieve the table array st = connection.createStatement(); // Turn use of the cursor on. st.setFetchSize(50); ResultSet rs = st.executeQuery("SELECT ItemId, ItemName FROM Items"); while (rs.next()) { sqlTables.put(rs.getString(2), "Item" + rs.getInt(1)); } rs.close(); st.close(); } catch (Exception e) { logger.error( "mySQL: Failed connecting to the SQL database using: driverClass={}, url={}, user={}, password={}", driverClass, url, user, password, e); } } /** * Disconnects from the database */ private void <API key>() { if (connection != null) { try { connection.close(); logger.debug("mySQL: Disconnected from database {}", url); } catch (Exception e) { logger.error("mySQL: Failed disconnecting from the SQL database {}", e); } connection = null; } } /** * Formats the given <code>alias</code> by utilizing {@link Formatter}. * * @param alias * the alias String which contains format strings * @param values * the values which will be replaced in the alias String * * @return the formatted value. All format strings are replaced by * appropriate values * @see java.util.Formatter for detailed information on format Strings. */ protected String formatAlias(String alias, Object... values) { return String.format(alias, values); } @Override public Iterable<HistoricItem> query(FilterCriteria filter) { if (!initialized) { logger.debug("Query aborted on item {} - mySQL not initialised!", filter.getItemName()); return Collections.emptyList(); } if (!isConnected()) { connectToDatabase(); } if (!isConnected()) { logger.debug("Query aborted on item {} - mySQL not connected!", filter.getItemName()); return Collections.emptyList(); } SimpleDateFormat mysqlDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Get the item name from the filter // Also get the Item object so we can determine the type Item item = null; String itemName = filter.getItemName(); logger.debug("mySQL query: item is {}", itemName); try { if (itemRegistry != null) { item = itemRegistry.getItem(itemName); } } catch (<API key> e1) { logger.error("Unable to get item type for {}", itemName); // Set type to null - data will be returned as StringType item = null; } if (item instanceof GroupItem) { // For Group Items is BaseItem needed to get correct Type of Value. item = GroupItem.class.cast(item).getBaseItem(); } String table = sqlTables.get(itemName); if (table == null) { logger.error("mySQL: Unable to find table for query '{}'.", itemName); return Collections.emptyList(); } String filterString = new String(); if (filter.getBeginDate() != null) { if (filterString.isEmpty()) { filterString += " WHERE"; } else { filterString += " AND"; } filterString += " TIME>'" + mysqlDateFormat.format(filter.getBeginDate()) + "'"; } if (filter.getEndDate() != null) { if (filterString.isEmpty()) { filterString += " WHERE"; } else { filterString += " AND"; } filterString += " TIME<'" + mysqlDateFormat.format(filter.getEndDate().getTime()) + "'"; } if (filter.getOrdering() == Ordering.ASCENDING) { filterString += " ORDER BY Time ASC"; } else { filterString += " ORDER BY Time DESC"; } if (filter.getPageSize() != 0x7fffffff) { filterString += " LIMIT " + filter.getPageNumber() * filter.getPageSize() + "," + filter.getPageSize(); } try { long timerStart = System.currentTimeMillis(); // Retrieve the table array Statement st = connection.createStatement(); String queryString = new String(); queryString = "SELECT Time, Value FROM " + table; if (!filterString.isEmpty()) { queryString += filterString; } logger.debug("mySQL: query:" + queryString); // Turn use of the cursor on. st.setFetchSize(50); ResultSet rs = st.executeQuery(queryString); long count = 0; List<HistoricItem> items = new ArrayList<HistoricItem>(); State state; while (rs.next()) { count++; if (item instanceof NumberItem) { state = new DecimalType(rs.getDouble(2)); } else if (item instanceof ColorItem) { state = new HSBType(rs.getString(2)); } else if (item instanceof DimmerItem) { state = new PercentType(rs.getInt(2)); } else if (item instanceof SwitchItem) { state = OnOffType.valueOf(rs.getString(2)); } else if (item instanceof ContactItem) { state = OpenClosedType.valueOf(rs.getString(2)); } else if (item instanceof RollershutterItem) { state = new PercentType(rs.getInt(2)); } else if (item instanceof DateTimeItem) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(rs.getTimestamp(2).getTime()); state = new DateTimeType(calendar); } else { state = new StringType(rs.getString(2)); } MysqlItem mysqlItem = new MysqlItem(itemName, state, rs.getTimestamp(1)); items.add(mysqlItem); } rs.close(); st.close(); long timerStop = System.currentTimeMillis(); logger.debug("mySQL: query returned {} rows in {}ms", count, timerStop - timerStart); // Success errCnt = 0; return items; } catch (SQLException e) { errCnt++; logger.error("mySQL: Error running querying : ", e.getMessage()); } return null; } }
#include <linux/module.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/bootmem.h> #include <asm/io.h> #include <linux/arcdevice.h> #define VERSION "arcnet: COM90xx chipset support\n" /* Define this to speed up the autoprobe by assuming if only one io port and * shmem are left in the list at Stage 5, they must correspond to each * other. * * This is undefined by default because it might not always be true, and the * extra check makes the autoprobe even more careful. Speed demons can turn * it on - I think it should be fine if you only have one ARCnet card * installed. * * If no ARCnet cards are installed, this delay never happens anyway and thus * the option has no effect. */ #undef FAST_PROBE /* Internal function declarations */ static int com90xx_found(struct net_device *dev, int ioaddr, int airq, u_long shmem); static void com90xx_command(struct net_device *dev, int command); static int com90xx_status(struct net_device *dev); static void com90xx_setmask(struct net_device *dev, int mask); static int com90xx_reset(struct net_device *dev, int really_reset); static void com90xx_openclose(struct net_device *dev, bool open); static void <API key>(struct net_device *dev, int bufnum, int offset, void *buf, int count); static void <API key>(struct net_device *dev, int bufnum, int offset, void *buf, int count); /* Known ARCnet cards */ static struct net_device *cards[16]; static int numcards; /* Handy defines for ARCnet specific stuff */ /* The number of low I/O ports used by the card */ #define ARCNET_TOTAL_SIZE 16 /* Amount of I/O memory used by the card */ #define BUFFER_SIZE (512) #define MIRROR_SIZE (BUFFER_SIZE*4) /* COM 9026 controller chip --> ARCnet register addresses */ #define _INTMASK (ioaddr+0) /* writable */ #define _STATUS (ioaddr+0) /* readable */ #define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */ #define _CONFIG (ioaddr+2) /* Configuration register */ #define _RESET (ioaddr+8) /* software reset (on read) */ #define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */ #define _ADDR_HI (ioaddr+15) /* Control registers for said */ #define _ADDR_LO (ioaddr+14) #undef ASTATUS #undef ACOMMAND #undef AINTMASK #define ASTATUS() inb(_STATUS) #define ACOMMAND(cmd) outb((cmd),_COMMAND) #define AINTMASK(msk) outb((msk),_INTMASK) static int com90xx_skip_probe __initdata = 0; int __init com90xx_probe(struct net_device *dev) { int count, status, ioaddr, numprint, airq, retval = -ENODEV, openparen = 0; unsigned long airqmask; int ports[(0x3f0 - 0x200) / 16 + 1] = {0}; u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] = {0}; int numports, numshmems, *port; u_long *shmem; if (!dev && com90xx_skip_probe) return -ENODEV; #ifndef MODULE arcnet_init(); #endif BUGLVL(D_NORMAL) printk(VERSION); /* set up the arrays where we'll store the possible probe addresses */ numports = numshmems = 0; if (dev && dev->base_addr) ports[numports++] = dev->base_addr; else for (count = 0x200; count <= 0x3f0; count += 16) ports[numports++] = count; if (dev && dev->mem_start) shmems[numshmems++] = dev->mem_start; else for (count = 0xA0000; count <= 0xFF800; count += 2048) shmems[numshmems++] = count; /* Stage 1: abandon any reserved ports, or ones with status==0xFF * (empty), and reset any others by reading the reset port. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S1: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; if (check_region(*port, ARCNET_TOTAL_SIZE)) { BUGMSG2(D_INIT_REASONS, "(check_region)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports port continue; } if (ASTATUS() == 0xFF) { BUGMSG2(D_INIT_REASONS, "(empty)\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports port continue; } inb(_RESET); /* begin resetting card */ BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S1: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numports) { BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n"); return -ENODEV; } /* Stage 2: we have now reset any possible ARCnet cards, so we can't * do anything until they finish. If D_INIT, print the list of * cards that are left. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S2: "); } BUGMSG2(D_INIT, "%Xh ", *port); } BUGMSG2(D_INIT, "\n"); mdelay(RESETtime); /* Stage 3: abandon any shmem addresses that don't have the signature * 0xD1 byte in the right place, or are read-only. */ numprint = -1; for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { u_long ptr = *shmem; numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S3: "); } BUGMSG2(D_INIT, "%lXh ", *shmem); if (check_mem_region(*shmem, BUFFER_SIZE)) { BUGMSG2(D_INIT_REASONS, "(check_mem_region)\n"); BUGMSG2(D_INIT_REASONS, "Stage 3: "); BUGLVL(D_INIT_REASONS) numprint = 0; *shmem = shmems[numshmems - 1]; numshmems shmem continue; } if (isa_readb(ptr) != TESTvalue) { BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n", isa_readb(ptr), TESTvalue); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; *shmem = shmems[numshmems - 1]; numshmems shmem continue; } /* By writing 0x42 to the TESTvalue location, we also make * sure no "mirror" shmem areas show up - if they occur * in another pass through this loop, they will be discarded * because *cptr != TESTvalue. */ isa_writeb(0x42, ptr); if (isa_readb(ptr) != 0x42) { BUGMSG2(D_INIT_REASONS, "(read only)\n"); BUGMSG2(D_INIT_REASONS, "S3: "); *shmem = shmems[numshmems - 1]; numshmems shmem continue; } BUGMSG2(D_INIT_REASONS, "\n"); BUGMSG2(D_INIT_REASONS, "S3: "); BUGLVL(D_INIT_REASONS) numprint = 0; } BUGMSG2(D_INIT, "\n"); if (!numshmems) { BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n"); return -ENODEV; } /* Stage 4: something of a dummy, to report the shmems that are * still possible after stage 3. */ numprint = -1; for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S4: "); } BUGMSG2(D_INIT, "%lXh ", *shmem); } BUGMSG2(D_INIT, "\n"); /* Stage 5: for any ports that have the correct status, can disable * the RESET flag, and (if no irq is given) generate an autoirq, * register an ARCnet device. * * Currently, we can only register one device per probe, so quit * after the first one is found. */ numprint = -1; for (port = &ports[0]; port - ports < numports; port++) { numprint++; numprint %= 8; if (!numprint) { BUGMSG2(D_INIT, "\n"); BUGMSG2(D_INIT, "S5: "); } BUGMSG2(D_INIT, "%Xh ", *port); ioaddr = *port; status = ASTATUS(); if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) { BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports port continue; } ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); status = ASTATUS(); if (status & RESETflag) { BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n", status); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports port continue; } /* skip this completely if an IRQ was given, because maybe * we're on a machine that locks during autoirq! */ if (!dev || !dev->irq) { /* if we do this, we're sure to get an IRQ since the * card has just reset and the NORXflag is on until * we tell it to start receiving. */ airqmask = probe_irq_on(); AINTMASK(NORXflag); udelay(1); AINTMASK(0); airq = probe_irq_off(airqmask); if (airq <= 0) { BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq); BUGMSG2(D_INIT_REASONS, "S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; *port = ports[numports - 1]; numports port continue; } } else { airq = dev->irq; } BUGMSG2(D_INIT, "(%d,", airq); openparen = 1; /* Everything seems okay. But which shmem, if any, puts * back its signature byte when the card is reset? * * If there are multiple cards installed, there might be * multiple shmems still in the list. */ #ifdef FAST_PROBE if (numports > 1 || numshmems > 1) { inb(_RESET); mdelay(RESETtime); } else { /* just one shmem and port, assume they match */ isa_writeb(TESTvalue, shmems[0]); } #else inb(_RESET); mdelay(RESETtime); #endif for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) { u_long ptr = *shmem; if (isa_readb(ptr) == TESTvalue) { /* found one */ BUGMSG2(D_INIT, "%lXh)\n", *shmem); openparen = 0; /* register the card */ retval = com90xx_found(dev, *port, airq, *shmem); numprint = -1; /* remove shmem from the list */ *shmem = shmems[numshmems - 1]; numshmems break; /* go to the next I/O port */ } else { BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr)); } } if (openparen) { BUGLVL(D_INIT) printk("no matching shmem)\n"); BUGLVL(D_INIT_REASONS) printk("S5: "); BUGLVL(D_INIT_REASONS) numprint = 0; } *port = ports[numports - 1]; numports port } BUGLVL(D_INIT_REASONS) printk("\n"); /* Now put back TESTvalue on all leftover shmems. */ for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) isa_writeb(TESTvalue, *shmem); if (retval && dev && !numcards) BUGMSG2(D_NORMAL, "S5: No ARCnet cards found.\n"); return retval; } /* Set up the struct net_device associated with this card. Called after * probing succeeds. */ static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq, u_long shmem) { struct net_device *dev = dev0; struct arcnet_local *lp; u_long first_mirror, last_mirror; int mirror_size, err; /* allocate struct net_device if we don't have one yet */ if (!dev && !(dev = dev_alloc("arc%d", &err))) { BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n"); return err; } lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL); if (!lp) { BUGMSG(D_NORMAL, "Can't allocate device data!\n"); goto err_free_dev; } /* find the real shared memory start/end points, including mirrors */ /* guess the actual size of one "memory mirror" - the number of * bytes between copies of the shared memory. On most cards, it's * 2k (or there are no mirrors at all) but on some, it's 4k. */ mirror_size = MIRROR_SIZE; if (isa_readb(shmem) == TESTvalue && isa_readb(shmem - mirror_size) != TESTvalue && isa_readb(shmem - 2 * mirror_size) == TESTvalue) mirror_size *= 2; first_mirror = last_mirror = shmem; while (isa_readb(first_mirror) == TESTvalue) first_mirror -= mirror_size; first_mirror += mirror_size; while (isa_readb(last_mirror) == TESTvalue) last_mirror += mirror_size; last_mirror -= mirror_size; dev->mem_start = first_mirror; dev->mem_end = last_mirror + MIRROR_SIZE - 1; dev->rmem_start = dev->mem_start + BUFFER_SIZE * 0; dev->rmem_end = dev->mem_start + BUFFER_SIZE * 2 - 1; /* Initialize the rest of the device structure. */ memset(lp, 0, sizeof(struct arcnet_local)); lp->card_name = "COM90xx"; lp->hw.command = com90xx_command; lp->hw.status = com90xx_status; lp->hw.intmask = com90xx_setmask; lp->hw.reset = com90xx_reset; lp->hw.open_close = com90xx_openclose; lp->hw.copy_to_card = <API key>; lp->hw.copy_from_card = <API key>; lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1); if (!lp->mem_start) { BUGMSG(D_NORMAL, "Can't remap device memory!\n"); goto err_free_dev_priv; } /* Fill in the fields of the device structure with generic values. */ arcdev_setup(dev); /* get and check the station ID from offset 1 in shmem */ dev->dev_addr[0] = readb(lp->mem_start + 1); /* reserve the irq */ if (request_irq(airq, &arcnet_interrupt, 0, "arcnet (90xx)", dev)) { BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq); goto err_unmap; } dev->irq = airq; /* reserve the I/O and memory regions - guaranteed to work by check_region */ request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (90xx)"); request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"); dev->base_addr = ioaddr; BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, " "ShMem %lXh (%ld*%xh).\n", dev->dev_addr[0], dev->base_addr, dev->irq, dev->mem_start, (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size); if (!dev0 && register_netdev(dev)) goto err_release; cards[numcards++] = dev; return 0; err_release: free_irq(dev->irq, dev); release_region(dev->base_addr, ARCNET_TOTAL_SIZE); release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); err_unmap: iounmap(lp->mem_start); err_free_dev_priv: kfree(dev->priv); err_free_dev: if (!dev0) kfree(dev); return -EIO; } static void com90xx_command(struct net_device *dev, int cmd) { short ioaddr = dev->base_addr; ACOMMAND(cmd); } static int com90xx_status(struct net_device *dev) { short ioaddr = dev->base_addr; return ASTATUS(); } static void com90xx_setmask(struct net_device *dev, int mask) { short ioaddr = dev->base_addr; AINTMASK(mask); } /* * Do a hardware reset on the card, and set up necessary registers. * * This should be called as little as possible, because it disrupts the * token on the network (causes a RECON) and requires a significant delay. * * However, it does make sure the card is in a defined state. */ int com90xx_reset(struct net_device *dev, int really_reset) { struct arcnet_local *lp = (struct arcnet_local *) dev->priv; short ioaddr = dev->base_addr; BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS()); if (really_reset) { /* reset the card */ inb(_RESET); mdelay(RESETtime); } ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */ ACOMMAND(CFLAGScmd | CONFIGclear); /* don't do this until we verify that it doesn't hurt older cards! */ /* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */ /* verify that the ARCnet signature byte is present */ if (readb(lp->mem_start) != TESTvalue) { if (really_reset) BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n"); return 1; } /* enable extended (512-byte) packets */ ACOMMAND(CONFIGcmd | EXTconf); /* clean out all the memory to make debugging make more sense :) */ BUGLVL(D_DURING) memset_io(lp->mem_start, 0x42, 2048); /* done! return success. */ return 0; } static void com90xx_openclose(struct net_device *dev, bool open) { if (open) MOD_INC_USE_COUNT; else MOD_DEC_USE_COUNT; } static void <API key>(struct net_device *dev, int bufnum, int offset, void *buf, int count) { struct arcnet_local *lp = (struct arcnet_local *) dev->priv; void *memaddr = lp->mem_start + bufnum * 512 + offset; TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count)); } static void <API key>(struct net_device *dev, int bufnum, int offset, void *buf, int count) { struct arcnet_local *lp = (struct arcnet_local *) dev->priv; void *memaddr = lp->mem_start + bufnum * 512 + offset; TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); } #ifdef MODULE /* Module parameters */ static int io; /* use the insmod io= irq= shmem= options */ static int irq; static int shmem; static char *device; /* use eg. device=arc1 to change name */ MODULE_PARM(io, "i"); MODULE_PARM(irq, "i"); MODULE_PARM(shmem, "i"); MODULE_PARM(device, "s"); MODULE_LICENSE("GPL"); int init_module(void) { struct net_device *dev; int err; if (io || irq || shmem || device) { dev = dev_alloc(device ? : "arc%d", &err); if (!dev) return err; dev->base_addr = io; dev->irq = irq; if (dev->irq == 2) dev->irq = 9; dev->mem_start = shmem; com90xx_probe(dev); } else com90xx_probe(NULL); if (!numcards) return -EIO; return 0; } void cleanup_module(void) { struct net_device *dev; struct arcnet_local *lp; int count; for (count = 0; count < numcards; count++) { dev = cards[count]; lp = (struct arcnet_local *) dev->priv; unregister_netdev(dev); free_irq(dev->irq, dev); iounmap(lp->mem_start); release_region(dev->base_addr, ARCNET_TOTAL_SIZE); release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1); kfree(dev->priv); kfree(dev); } } #else static int __init com90xx_setup(char *s) { struct net_device *dev; int ints[8]; com90xx_skip_probe = 1; s = get_options(s, 8, ints); if (!ints[0] && !*s) { printk("com90xx: Disabled.\n"); return 1; } dev = alloc_bootmem(sizeof(struct net_device)); memset(dev, 0, sizeof(struct net_device)); dev->init = com90xx_probe; switch (ints[0]) { default: /* ERROR */ printk("com90xx: Too many arguments.\n"); case 3: /* Mem address */ dev->mem_start = ints[3]; case 2: /* IRQ */ dev->irq = ints[2]; case 1: /* IO address */ dev->base_addr = ints[1]; } if (*s) strncpy(dev->name, s, 9); else strcpy(dev->name, "arc%d"); if (register_netdev(dev)) printk(KERN_ERR "com90xx: Cannot register arcnet device\n"); return 1; } __setup("com90xx=", com90xx_setup); #endif /* MODULE */
<?php /** Tests for MediaWiki languages/classes/LanguageSe.php */ class LanguageSeTest extends <API key> { /** * @dataProvider providePlural * @covers Language::convertPlural */ public function testPlural( $result, $value ) { $forms = [ 'one', 'two', 'other' ]; $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } /** * @dataProvider providePlural * @covers Language::getPluralRuleType */ public function <API key>( $result, $value ) { $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); } public static function providePlural() { return [ [ 'other', 0 ], [ 'one', 1 ], [ 'two', 2 ], [ 'other', 3 ], ]; } /** * @dataProvider <API key> * @covers Language::convertPlural */ public function testPluralTwoForms( $result, $value ) { $forms = [ 'one', 'other' ]; $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } public static function <API key>() { return [ [ 'other', 0 ], [ 'one', 1 ], [ 'other', 2 ], [ 'other', 3 ], ]; } }
<?php /* Common functions used across samples */ /** * Helper Class for Printing Results * * Class ResultPrinter */ class ResultPrinter { private static $printResultCounter = 0; /** * Prints HTML Output to web page. * * @param string $title * @param string $objectName * @param string $objectId * @param mixed $request * @param mixed $response * @param string $errorMessage */ public static function printOutput($title, $objectName, $objectId = null, $request = null, $response = null, $errorMessage = null) { if (PHP_SAPI == 'cli') { self::$printResultCounter++; printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); printf("(%d) %s", self::$printResultCounter, strtoupper($title)); printf("\n if ($objectId) { printf("Object with ID: %s \n", $objectId); } printf(" printf("\tREQUEST:\n"); self::printConsoleObject($request); printf("\n\n\tRESPONSE:\n"); self::printConsoleObject($response, $errorMessage); printf("\n } else { if (self::$printResultCounter == 0) { include "header.html"; echo ' <div class="row header"><div class="col-md-5 pull-left"><br /><a href="../index.php"><h1 class="home">&#10094;&#10094; Back to Samples</h1></a><br /></div> <br /> <div class="col-md-4 pull-right"><img src="https: echo '<div class="panel-group" id="accordion" role="tablist" <API key>="true">'; } self::$printResultCounter++; echo ' <div class="panel panel-default"> <div class="panel-heading '. ($errorMessage ? 'error' : '') .'" role="tab" id="heading-'.self::$printResultCounter.'"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#step-'. self::$printResultCounter .'" aria-expanded="false" aria-controls="step-'.self::$printResultCounter.'"> '. self::$printResultCounter .'. '. $title . ($errorMessage ? ' (Failed)' : '') . '</a> </h4> </div> <div id="step-'.self::$printResultCounter.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-'. self::$printResultCounter . '"> <div class="panel-body"> '; if ($objectId) { echo "<div>" . ($objectName ? $objectName : "Object") . " with ID: $objectId </div>"; } echo '<div class="row hidden-xs hidden-sm hidden-md"><div class="col-md-6"><h4>Request Object</h4>'; self::printObject($request); echo '</div><div class="col-md-6"><h4 class="'. ($errorMessage ? 'error' : '') .'">Response Object</h4>'; self::printObject($response, $errorMessage); echo '</div></div>'; echo '<div class="hidden-lg"><ul class="nav nav-tabs" role="tablist"> <li role="presentation" ><a href="#step-'.self::$printResultCounter .'-request" role="tab" data-toggle="tab">Request</a></li> <li role="presentation" class="active"><a href="#step-'.self::$printResultCounter .'-response" role="tab" data-toggle="tab">Response</a></li> </ul> <div class="tab-content"> <div role="tabpanel" class="tab-pane" id="step-'.self::$printResultCounter .'-request"><h4>Request Object</h4>'; self::printObject($request) ; echo '</div><div role="tabpanel" class="tab-pane active" id="step-'.self::$printResultCounter .'-response"><h4>Response Object</h4>'; self::printObject($response, $errorMessage); echo '</div></div></div></div> </div> </div>'; } flush(); } /** * Prints success response HTML Output to web page. * * @param string $title * @param string $objectName * @param string $objectId * @param mixed $request * @param mixed $response */ public static function printResult($title, $objectName, $objectId = null, $request = null, $response = null) { self::printOutput($title, $objectName, $objectId, $request, $response, false); } /** * Prints Error * * @param $title * @param $objectName * @param null $objectId * @param null $request * @param \Exception $exception */ public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null) { $data = null; if ($exception instanceof \PayPal\Exception\<API key>) { $data = $exception->getData(); } self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage()); } protected static function printConsoleObject($object, $error = null) { if ($error) { echo 'ERROR:'. $error; } if ($object) { if (is_a($object, 'PayPal\Common\PayPalModel')) { /** @var $object \PayPal\Common\PayPalModel */ echo $object->toJSON(128); } elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) { echo str_replace('\\/', '/', json_encode(json_decode($object), 128)); } elseif (is_string($object)) { echo $object; } else { print_r($object); } } else { echo "No Data"; } } protected static function printObject($object, $error = null) { if ($error) { echo '<p class="error"><i class="fa <API key>"></i> '. $error. '</p>'; } if ($object) { if (is_a($object, 'PayPal\Common\PayPalModel')) { /** @var $object \PayPal\Common\PayPalModel */ echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">' . $object->toJSON(128) . "</pre>"; } elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) { echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">'. str_replace('\\/', '/', json_encode(json_decode($object), 128)) . "</pre>"; } elseif (is_string($object)) { echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">' . $object . '</pre>'; } else { echo "<pre>"; print_r($object); echo "</pre>"; } } else { echo "<span>No Data</span>"; } } } function getBaseUrl() { if (PHP_SAPI == 'cli') { $trace=debug_backtrace(); $relativePath = substr(dirname($trace[0]['file']), strlen(dirname(dirname(__FILE__)))); echo "Warning: This sample may require a server to handle return URL. Cannot execute in command line. Defaulting URL to http://localhost$relativePath \n"; return "http://localhost" . $relativePath; } $protocol = 'http'; if ($_SERVER['SERVER_PORT'] == 443 || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')) { $protocol .= 's'; } $host = $_SERVER['HTTP_HOST']; $request = $_SERVER['PHP_SELF']; return dirname($protocol . '://' . $host . $request); }
@echo off if defined _OLD_VIRTUAL_PROMPT ( set "PROMPT=%_OLD_VIRTUAL_PROMPT%" ) set _OLD_VIRTUAL_PROMPT= if defined <API key> ( set "PYTHONHOME=%<API key>%" set <API key>= ) if defined _OLD_VIRTUAL_PATH ( set "PATH=%_OLD_VIRTUAL_PATH%" ) set _OLD_VIRTUAL_PATH= set VIRTUAL_ENV= :END
/** * todo@all: Documentation */ //{namespace name=backend/config/view/form} //{block name="backend/config/view/form/customer_group"} Ext.define('Shopware.apps.Config.view.form.CustomerGroup', { extend: 'Shopware.apps.Config.view.base.Form', alias: 'widget.<API key>', getItems: function() { var me = this; return [{ xtype: 'config-base-table', store: 'form.CustomerGroup', columns: me.getColumns() },{ xtype: '<API key>' }]; }, getColumns: function() { var me = this; return [{ xtype: 'gridcolumn', dataIndex: 'name', text: '{s name=customer_group/table/name_text}Name{/s}', flex: 1 }, { xtype: 'gridcolumn', dataIndex: 'key', text: '{s name=customer_group/table/key_text}Key{/s}', flex: 1 }, me.getActionColumn()]; } }); //{/block} //taxinput
#ifndef CLANG_C_INDEX_H #define CLANG_C_INDEX_H #include <time.h> #include "Platform.h" #include "CXString.h" /** * \brief The version constants for the libclang API. * <API key> should increase when there are API additions. * <API key> is intended for "major" source/ABI breaking changes. * * The policy about the libclang API was always to keep it source and ABI * compatible, thus <API key> is expected to remain stable. */ #define <API key> 0 #define <API key> 20 #define <API key>(major, minor) ( \ ((major) * 10000) \ + ((minor) * 1)) #define CINDEX_VERSION <API key>( \ <API key>, \ <API key> ) #define <API key>(major, minor) \ #major"."#minor #define <API key>(major, minor) \ <API key>(major, minor) #define <API key> <API key>( \ <API key>, \ <API key>) #ifdef __cplusplus extern "C" { #endif /** \defgroup CINDEX libclang: C Interface to Clang * * The C Interface to Clang provides a relatively small API that exposes * facilities for parsing source code into an abstract syntax tree (AST), * loading already-parsed ASTs, traversing the AST, associating * physical source locations with elements within the AST, and other * facilities that support Clang-based development tools. * * This C interface to Clang will never provide all of the information * representation stored in Clang's C++ AST, nor should it: the intent is to * maintain an API that is relatively stable from one release to the next, * providing only the basic functionality needed to support development tools. * * To avoid namespace pollution, data types are prefixed with "CX" and * functions are prefixed with "clang_". * * @{ */ /** * \brief An "index" that consists of a set of translation units that would * typically be linked together into an executable or library. */ typedef void *CXIndex; /** * \brief A single translation unit, which resides in an index. */ typedef struct <API key> *CXTranslationUnit; /** * \brief Opaque pointer representing client data that will be passed through * to various callbacks and visitors. */ typedef void *CXClientData; /** * \brief Provides the contents of a file that has not yet been saved to disk. * * Each CXUnsavedFile instance provides the name of a file on the * system along with the current contents of that file that have not * yet been saved to disk. */ struct CXUnsavedFile { /** * \brief The file whose contents have not yet been saved. * * This file must already exist in the file system. */ const char *Filename; /** * \brief A buffer containing the unsaved contents of this file. */ const char *Contents; /** * \brief The length of the unsaved contents of this buffer. */ unsigned long Length; }; /** * \brief Describes the availability of a particular entity, which indicates * whether the use of this entity will result in a warning or error due to * it being deprecated or unavailable. */ enum CXAvailabilityKind { /** * \brief The entity is available. */ <API key>, /** * \brief The entity is available, but has been deprecated (and its use is * not recommended). */ <API key>, /** * \brief The entity is not available; any use of it will be an error. */ <API key>, /** * \brief The entity is available, but not accessible; any use of it will be * an error. */ <API key> }; /** * \brief Describes a version number of the form major.minor.subminor. */ typedef struct CXVersion { /** * \brief The major version number, e.g., the '10' in '10.7.3'. A negative * value indicates that there is no version number at all. */ int Major; /** * \brief The minor version number, e.g., the '7' in '10.7.3'. This value * will be negative if no minor version number was provided, e.g., for * version '10'. */ int Minor; /** * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value * will be negative if no minor or subminor version number was provided, * e.g., in version '10' or '10.7'. */ int Subminor; } CXVersion; /** * \brief Provides a shared context for creating translation units. * * It provides two options: * * - <API key>: When non-zero, allows enumeration of "local" * declarations (when loading any new translation units). A "local" declaration * is one that belongs in the translation unit itself and not in a precompiled * header that was used by the translation unit. If zero, all declarations * will be enumerated. * * Here is an example: * * \code * // excludeDeclsFromPCH = 1, displayDiagnostics=1 * Idx = clang_createIndex(1, 1); * * // IndexTest.pch was produced with the following command: * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" * TU = <API key>(Idx, "IndexTest.pch"); * * // This will load all the symbols from 'IndexTest.pch' * clang_visitChildren(<API key>(TU), * <API key>, 0); * <API key>(TU); * * // This will load all the symbols from 'IndexTest.c', excluding symbols * // from 'IndexTest.pch'. * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; * TU = <API key>(Idx, "IndexTest.c", 2, args, * 0, 0); * clang_visitChildren(<API key>(TU), * <API key>, 0); * <API key>(TU); * \endcode * * This process of creating the 'pch', loading it separately, and using it (via * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks * (which gives the indexer the same performance benefit as the compiler). */ CINDEX_LINKAGE CXIndex clang_createIndex(int <API key>, int displayDiagnostics); /** * \brief Destroy the given index. * * The index must not be destroyed until all of the translation units created * within that index have been destroyed. */ CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); typedef enum { /** * \brief Used to indicate that no special CXIndex options are needed. */ CXGlobalOpt_None = 0x0, /** * \brief Used to indicate that threads that libclang creates for indexing * purposes should use background priority. * * Affects #<API key>, #<API key>, * #<API key>, #<API key>. */ <API key> = 0x1, /** * \brief Used to indicate that threads that libclang creates for editing * purposes should use background priority. * * Affects #<API key>, #<API key>, * #<API key> */ <API key> = 0x2, /** * \brief Used to indicate that all threads that libclang creates should use * background priority. */ <API key> = <API key> | <API key> } CXGlobalOptFlags; /** * \brief Sets general options associated with a CXIndex. * * For example: * \code * CXIndex idx = ...; * <API key>(idx, * <API key>(idx) | * <API key>); * \endcode * * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. */ CINDEX_LINKAGE void <API key>(CXIndex, unsigned options); /** * \brief Gets the general options associated with a CXIndex. * * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that * are associated with the given CXIndex object. */ CINDEX_LINKAGE unsigned <API key>(CXIndex); /** * \defgroup CINDEX_FILES File manipulation routines * * @{ */ /** * \brief A particular source file that is part of a translation unit. */ typedef void *CXFile; /** * \brief Retrieve the complete file and path name of the given file. */ CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); /** * \brief Retrieve the last modification time of the given file. */ CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); /** * \brief Uniquely identifies a CXFile, that refers to the same underlying file, * across an indexing session. */ typedef struct { unsigned long long data[3]; } CXFileUniqueID; /** * \brief Retrieve the unique ID for the given \c file. * * \param file the file to get the ID for. * \param outID stores the returned CXFileUniqueID. * \returns If there was a failure getting the unique ID, returns non-zero, * otherwise returns 0. */ CINDEX_LINKAGE int <API key>(CXFile file, CXFileUniqueID *outID); /** * \brief Determine whether the given header is guarded against * multiple inclusions, either with the conventional * \#ifndef/\#define/\#endif macro guards or with \#pragma once. */ CINDEX_LINKAGE unsigned <API key>(CXTranslationUnit tu, CXFile file); /** * \brief Retrieve a file handle within the given translation unit. * * \param tu the translation unit * * \param file_name the name of the file. * * \returns the file handle for the named file in the translation unit \p tu, * or a NULL file handle if the file was not a part of this translation unit. */ CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, const char *file_name); /** * \defgroup CINDEX_LOCATIONS Physical source locations * * Clang represents physical source locations in its abstract syntax tree in * great detail, with file, line, and column information for the majority of * the tokens parsed in the source code. These data types and functions are * used to represent source location information, either for a particular * point in the program or for a range of points in the program, and extract * specific location information from those data types. * * @{ */ /** * \brief Identifies a specific source location within a translation * unit. * * Use <API key>() or <API key>() * to map a source location to a particular file, line, and column. */ typedef struct { const void *ptr_data[2]; unsigned int_data; } CXSourceLocation; /** * \brief Identifies a half-open character range in the source code. * * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the * starting and end locations from a source range, respectively. */ typedef struct { const void *ptr_data[2]; unsigned begin_int_data; unsigned end_int_data; } CXSourceRange; /** * \brief Retrieve a NULL (invalid) source location. */ CINDEX_LINKAGE CXSourceLocation <API key>(void); /** * \brief Determine whether two source locations, which must refer into * the same translation unit, refer to exactly the same point in the source * code. * * \returns non-zero if the source locations refer to the same location, zero * if they refer to different locations. */ CINDEX_LINKAGE unsigned <API key>(CXSourceLocation loc1, CXSourceLocation loc2); /** * \brief Retrieves the source location associated with a given file/line/column * in a particular translation unit. */ CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, CXFile file, unsigned line, unsigned column); /** * \brief Retrieves the source location associated with a given character offset * in a particular translation unit. */ CINDEX_LINKAGE CXSourceLocation <API key>(CXTranslationUnit tu, CXFile file, unsigned offset); /** * \brief Returns non-zero if the given source location is in a system header. */ CINDEX_LINKAGE int <API key>(CXSourceLocation location); /** * \brief Returns non-zero if the given source location is in the main file of * the corresponding translation unit. */ CINDEX_LINKAGE int <API key>(CXSourceLocation location); /** * \brief Retrieve a NULL (invalid) source range. */ CINDEX_LINKAGE CXSourceRange clang_getNullRange(void); /** * \brief Retrieve a source range given the beginning and ending source * locations. */ CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end); /** * \brief Determine whether two ranges are equivalent. * * \returns non-zero if the ranges are the same, zero if they differ. */ CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, CXSourceRange range2); /** * \brief Returns non-zero if \p range is null. */ CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); /** * \brief Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro expansion, retrieves the * location of the macro expansion. * * \param location the location within a source file that will be decomposed * into its parts. * * \param file [out] if non-NULL, will be set to the file to which the given * source location points. * * \param line [out] if non-NULL, will be set to the line to which the given * source location points. * * \param column [out] if non-NULL, will be set to the column to which the given * source location points. * * \param offset [out] if non-NULL, will be set to the offset into the * buffer to which the given source location points. */ CINDEX_LINKAGE void <API key>(CXSourceLocation location, CXFile *file, unsigned *line, unsigned *column, unsigned *offset); /** * \brief Retrieve the file, line, column, and offset represented by * the given source location, as specified in a # line directive. * * Example: given the following source code in a file somefile.c * * \code * #123 "dummy.c" 1 * * static int func(void) * { * return 0; * } * \endcode * * the location information returned by this function would be * * File: dummy.c Line: 124 Column: 12 * * whereas <API key> would have returned * * File: somefile.c Line: 3 Column: 12 * * \param location the location within a source file that will be decomposed * into its parts. * * \param filename [out] if non-NULL, will be set to the filename of the * source location. Note that filenames returned will be for "virtual" files, * which don't necessarily exist on the machine running clang - e.g. when * parsing preprocessed output obtained from a different environment. If * a non-NULL value is passed in, remember to dispose of the returned value * using \c clang_disposeString() once you've finished with it. For an invalid * source location, an empty string is returned. * * \param line [out] if non-NULL, will be set to the line number of the * source location. For an invalid source location, zero is returned. * * \param column [out] if non-NULL, will be set to the column number of the * source location. For an invalid source location, zero is returned. */ CINDEX_LINKAGE void <API key>(CXSourceLocation location, CXString *filename, unsigned *line, unsigned *column); /** * \brief Legacy API to retrieve the file, line, column, and offset represented * by the given source location. * * This interface has been replaced by the newer interface * #<API key>(). See that interface's documentation for * details. */ CINDEX_LINKAGE void <API key>(CXSourceLocation location, CXFile *file, unsigned *line, unsigned *column, unsigned *offset); /** * \brief Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro instantiation, return where the * location was originally spelled in the source file. * * \param location the location within a source file that will be decomposed * into its parts. * * \param file [out] if non-NULL, will be set to the file to which the given * source location points. * * \param line [out] if non-NULL, will be set to the line to which the given * source location points. * * \param column [out] if non-NULL, will be set to the column to which the given * source location points. * * \param offset [out] if non-NULL, will be set to the offset into the * buffer to which the given source location points. */ CINDEX_LINKAGE void <API key>(CXSourceLocation location, CXFile *file, unsigned *line, unsigned *column, unsigned *offset); /** * \brief Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro expansion, return where the macro was * expanded or where the macro argument was written, if the location points at * a macro argument. * * \param location the location within a source file that will be decomposed * into its parts. * * \param file [out] if non-NULL, will be set to the file to which the given * source location points. * * \param line [out] if non-NULL, will be set to the line to which the given * source location points. * * \param column [out] if non-NULL, will be set to the column to which the given * source location points. * * \param offset [out] if non-NULL, will be set to the offset into the * buffer to which the given source location points. */ CINDEX_LINKAGE void <API key>(CXSourceLocation location, CXFile *file, unsigned *line, unsigned *column, unsigned *offset); /** * \brief Retrieve a source location representing the first character within a * source range. */ CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); /** * \brief Retrieve a source location representing the last character within a * source range. */ CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); /** * \defgroup CINDEX_DIAG Diagnostic reporting * * @{ */ /** * \brief Describes the severity of a particular diagnostic. */ enum <API key> { /** * \brief A diagnostic that has been suppressed, e.g., by a command-line * option. */ <API key> = 0, /** * \brief This diagnostic is a note that should be attached to the * previous (non-note) diagnostic. */ CXDiagnostic_Note = 1, /** * \brief This diagnostic indicates suspicious code that may not be * wrong. */ <API key> = 2, /** * \brief This diagnostic indicates that the code is ill-formed. */ CXDiagnostic_Error = 3, /** * \brief This diagnostic indicates that the code is ill-formed such * that future parser recovery is unlikely to produce useful * results. */ CXDiagnostic_Fatal = 4 }; /** * \brief A single diagnostic, containing the diagnostic's severity, * location, text, source ranges, and fix-it hints. */ typedef void *CXDiagnostic; /** * \brief A group of CXDiagnostics. */ typedef void *CXDiagnosticSet; /** * \brief Determine the number of diagnostics in a CXDiagnosticSet. */ CINDEX_LINKAGE unsigned <API key>(CXDiagnosticSet Diags); /** * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet. * * \param Diags the CXDiagnosticSet to query. * \param Index the zero-based diagnostic number to retrieve. * * \returns the requested diagnostic. This diagnostic must be freed * via a call to \c <API key>(). */ CINDEX_LINKAGE CXDiagnostic <API key>(CXDiagnosticSet Diags, unsigned Index); /** * \brief Describes the kind of error that occurred (if any) in a call to * \c <API key>. */ enum CXLoadDiag_Error { /** * \brief Indicates that no error occurred. */ CXLoadDiag_None = 0, /** * \brief Indicates that an unknown error occurred while attempting to * deserialize diagnostics. */ CXLoadDiag_Unknown = 1, /** * \brief Indicates that the file containing the serialized diagnostics * could not be opened. */ <API key> = 2, /** * \brief Indicates that the serialized diagnostics file is invalid or * corrupt. */ <API key> = 3 }; /** * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode * file. * * \param file The name of the file to deserialize. * \param error A pointer to a enum value recording if there was a problem * deserializing the diagnostics. * \param errorString A pointer to a CXString for recording the error string * if the file was not successfully loaded. * * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These * diagnostics should be released using <API key>(). */ CINDEX_LINKAGE CXDiagnosticSet <API key>(const char *file, enum CXLoadDiag_Error *error, CXString *errorString); /** * \brief Release a CXDiagnosticSet and all of its contained diagnostics. */ CINDEX_LINKAGE void <API key>(CXDiagnosticSet Diags); /** * \brief Retrieve the child diagnostics of a CXDiagnostic. * * This CXDiagnosticSet does not need to be released by * <API key>. */ CINDEX_LINKAGE CXDiagnosticSet <API key>(CXDiagnostic D); /** * \brief Determine the number of diagnostics produced for the given * translation unit. */ CINDEX_LINKAGE unsigned <API key>(CXTranslationUnit Unit); /** * \brief Retrieve a diagnostic associated with the given translation unit. * * \param Unit the translation unit to query. * \param Index the zero-based diagnostic number to retrieve. * * \returns the requested diagnostic. This diagnostic must be freed * via a call to \c <API key>(). */ CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index); /** * \brief Retrieve the complete set of diagnostics associated with a * translation unit. * * \param Unit the translation unit to query. */ CINDEX_LINKAGE CXDiagnosticSet <API key>(CXTranslationUnit Unit); /** * \brief Destroy a diagnostic. */ CINDEX_LINKAGE void <API key>(CXDiagnostic Diagnostic); /** * \brief Options to control the display of diagnostics. * * The values in this enum are meant to be combined to customize the * behavior of \c <API key>(). */ enum <API key> { /** * \brief Display the source-location information where the * diagnostic was located. * * When set, diagnostics will be prefixed by the file, line, and * (optionally) column to which the diagnostic refers. For example, * * \code * test.c:28: warning: extra tokens at end of #endif directive * \endcode * * This option corresponds to the clang flag \c -<API key>. */ <API key> = 0x01, /** * \brief If displaying the source-location information of the * diagnostic, also include the column number. * * This option corresponds to the clang flag \c -fshow-column. */ <API key> = 0x02, /** * \brief If displaying the source-location information of the * diagnostic, also include information about source ranges in a * machine-parsable format. * * This option corresponds to the clang flag * \c -<API key>. */ <API key> = 0x04, /** * \brief Display the option name associated with this diagnostic, if any. * * The option name displayed (e.g., -Wconversion) will be placed in brackets * after the diagnostic text. This option corresponds to the clang flag * \c -<API key>. */ <API key> = 0x08, /** * \brief Display the category number associated with this diagnostic, if any. * * The category number is displayed within brackets after the diagnostic text. * This option corresponds to the clang flag * \c -<API key>=id. */ <API key> = 0x10, /** * \brief Display the category name associated with this diagnostic, if any. * * The category name is displayed within brackets after the diagnostic text. * This option corresponds to the clang flag * \c -<API key>=name. */ <API key> = 0x20 }; CINDEX_LINKAGE CXString <API key>(CXDiagnostic Diagnostic, unsigned Options); /** * \brief Retrieve the set of display options most similar to the * default behavior of the clang compiler. * * \returns A set of display options suitable for use with \c * <API key>(). */ CINDEX_LINKAGE unsigned <API key>(void); /** * \brief Determine the severity of the given diagnostic. */ CINDEX_LINKAGE enum <API key> <API key>(CXDiagnostic); /** * \brief Retrieve the source location of the given diagnostic. * * This location is where Clang would print the caret ('^') when * displaying the diagnostic on the command line. */ CINDEX_LINKAGE CXSourceLocation <API key>(CXDiagnostic); /** * \brief Retrieve the text of the given diagnostic. */ CINDEX_LINKAGE CXString <API key>(CXDiagnostic); /** * \brief Retrieve the name of the command-line option that enabled this * diagnostic. * * \param Diag The diagnostic to be queried. * * \param Disable If non-NULL, will be set to the option that disables this * diagnostic (if any). * * \returns A string that contains the command-line option used to enable this * warning, such as "-Wconversion" or "-pedantic". */ CINDEX_LINKAGE CXString <API key>(CXDiagnostic Diag, CXString *Disable); /** * \brief Retrieve the category number for this diagnostic. * * Diagnostics can be categorized into groups along with other, related * diagnostics (e.g., diagnostics under the same warning flag). This routine * retrieves the category number for the given diagnostic. * * \returns The number of the category that contains this diagnostic, or zero * if this diagnostic is uncategorized. */ CINDEX_LINKAGE unsigned <API key>(CXDiagnostic); /** * \brief Retrieve the name of a particular diagnostic category. This * is now deprecated. Use <API key>() * instead. * * \param Category A diagnostic category number, as returned by * \c <API key>(). * * \returns The name of the given diagnostic category. */ CINDEX_DEPRECATED CINDEX_LINKAGE CXString <API key>(unsigned Category); /** * \brief Retrieve the diagnostic category text for a given diagnostic. * * \returns The text of the given diagnostic category. */ CINDEX_LINKAGE CXString <API key>(CXDiagnostic); /** * \brief Determine the number of source ranges associated with the given * diagnostic. */ CINDEX_LINKAGE unsigned <API key>(CXDiagnostic); /** * \brief Retrieve a source range associated with the diagnostic. * * A diagnostic's source ranges highlight important elements in the source * code. On the command line, Clang displays source ranges by * underlining them with '~' characters. * * \param Diagnostic the diagnostic whose range is being extracted. * * \param Range the zero-based index specifying which range to * * \returns the requested source range. */ CINDEX_LINKAGE CXSourceRange <API key>(CXDiagnostic Diagnostic, unsigned Range); /** * \brief Determine the number of fix-it hints associated with the * given diagnostic. */ CINDEX_LINKAGE unsigned <API key>(CXDiagnostic Diagnostic); /** * \brief Retrieve the replacement information for a given fix-it. * * Fix-its are described in terms of a source range whose contents * should be replaced by a string. This approach generalizes over * three kinds of operations: removal of source code (the range covers * the code to be removed and the replacement string is empty), * replacement of source code (the range covers the code to be * replaced and the replacement string provides the new code), and * insertion (both the start and end of the range point at the * insertion location, and the replacement string provides the text to * insert). * * \param Diagnostic The diagnostic whose fix-its are being queried. * * \param FixIt The zero-based index of the fix-it. * * \param ReplacementRange The source range whose contents will be * replaced with the returned replacement string. Note that source * ranges are half-open ranges [a, b), so the source code should be * replaced from a and up to (but not including) b. * * \returns A string containing text that should be replace the source * code indicated by the \c ReplacementRange. */ CINDEX_LINKAGE CXString <API key>(CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange); /** * \defgroup <API key> Translation unit manipulation * * The routines in this group provide the ability to create and destroy * translation units from files, either by parsing the contents of the files or * by reading in a serialized representation of a translation unit. * * @{ */ /** * \brief Get the original translation unit source file name. */ CINDEX_LINKAGE CXString <API key>(CXTranslationUnit CTUnit); /** * \brief Return the CXTranslationUnit for a given source file and the provided * command line arguments one would pass to the compiler. * * Note: The 'source_filename' argument is optional. If the caller provides a * NULL pointer, the name of the source file is expected to reside in the * specified command line arguments. * * Note: When encountered in '<API key>', the following options * are ignored: * * '-c' * '-emit-ast' * '-fsyntax-only' * '-o \<output file>' (both '-o' and '\<output file>' are ignored) * * \param CIdx The index object with which the translation unit will be * associated. * * \param source_filename The name of the source file to load, or NULL if the * source file is included in \p <API key>. * * \param <API key> The number of command-line arguments in * \p <API key>. * * \param <API key> The command-line arguments that would be * passed to the \c clang executable if it were being invoked out-of-process. * These command-line options will be parsed and will affect how the translation * unit is parsed. Note that the following options are ignored: '-c', * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. * * \param num_unsaved_files the number of unsaved file entries in \p * unsaved_files. * * \param unsaved_files the files that have not yet been saved to disk * but may be required for code completion, including the contents of * those files. The contents and name of these files (as specified by * CXUnsavedFile) are copied when necessary, so the client only needs to * guarantee their validity until the call to this function returns. */ CINDEX_LINKAGE CXTranslationUnit <API key>( CXIndex CIdx, const char *source_filename, int <API key>, const char * const *<API key>, unsigned num_unsaved_files, struct CXUnsavedFile *unsaved_files); /** * \brief Create a translation unit from an AST file (-emit-ast). */ CINDEX_LINKAGE CXTranslationUnit <API key>(CXIndex, const char *ast_filename); /** * \brief Flags that control the creation of translation units. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when * constructing the translation unit. */ enum <API key> { /** * \brief Used to indicate that no special translation-unit options are * needed. */ <API key> = 0x0, /** * \brief Used to indicate that the parser should construct a "detailed" * preprocessing record, including all macro definitions and instantiations. * * Constructing a detailed preprocessing record requires more memory * and time to parse, since the information contained in the record * is usually not retained. However, it can be useful for * applications that require more detailed information about the * behavior of the preprocessor. */ <API key> = 0x01, /** * \brief Used to indicate that the translation unit is incomplete. * * When a translation unit is considered "incomplete", semantic * analysis that is typically performed at the end of the * translation unit will be suppressed. For example, this suppresses * the completion of tentative declarations in C and of * instantiation of <API key> function templates in * C++. This option is typically used when parsing a header with the * intent of producing a precompiled header. */ <API key> = 0x02, /** * \brief Used to indicate that the translation unit should be built with an * implicit precompiled header for the preamble. * * An implicit precompiled header is used as an optimization when a * particular translation unit is likely to be reparsed many times * when the sources aren't changing that often. In this case, an * implicit precompiled header will be built containing all of the * initial includes at the top of the main file (what we refer to as * the "preamble" of the file). In subsequent parses, if the * preamble or the files in it have not changed, \c * <API key>() will re-use the implicit * precompiled header to improve parsing performance. */ <API key> = 0x04, /** * \brief Used to indicate that the translation unit should cache some * code-completion results with each reparse of the source file. * * Caching of code-completion results is a performance optimization that * introduces some overhead to reparsing but improves the performance of * code-completion operations. */ <API key> = 0x08, /** * \brief Used to indicate that the translation unit will be serialized with * \c <API key>. * * This option is typically used when parsing a header with the intent of * producing a precompiled header. */ <API key> = 0x10, /** * \brief DEPRECATED: Enabled chained precompiled preambles in C++. * * Note: this is a *temporary* option that is available only while * we are testing C++ precompiled preamble support. It is deprecated. */ <API key> = 0x20, /** * \brief Used to indicate that function/method bodies should be skipped while * parsing. * * This option can be used to search for declarations/definitions while * ignoring the usages. */ <API key> = 0x40, /** * \brief Used to indicate that brief documentation comments should be * included into the set of code completions returned from this translation * unit. */ <API key> = 0x80 }; /** * \brief Returns the set of flags that is suitable for parsing a translation * unit that is being edited. * * The set of flags returned provide options for \c <API key>() * to indicate that the translation unit is likely to be reparsed many times, * either explicitly (via \c <API key>()) or implicitly * (e.g., by code completion (\c <API key>())). The returned flag * set contains an unspecified set of optimizations (e.g., the precompiled * preamble) geared toward improving the performance of these routines. The * set of optimizations enabled may change from one version to the next. */ CINDEX_LINKAGE unsigned <API key>(void); /** * \brief Parse the given source file and the translation unit corresponding * to that file. * * This routine is the main entry point for the Clang C API, providing the * ability to parse a source file into a translation unit that can then be * queried by other functions in the API. This routine accepts a set of * command-line arguments so that the compilation can be configured in the same * way that the compiler is configured on the command line. * * \param CIdx The index object with which the translation unit will be * associated. * * \param source_filename The name of the source file to load, or NULL if the * source file is included in \p command_line_args. * * \param command_line_args The command-line arguments that would be * passed to the \c clang executable if it were being invoked out-of-process. * These command-line options will be parsed and will affect how the translation * unit is parsed. Note that the following options are ignored: '-c', * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. * * \param <API key> The number of command-line arguments in * \p command_line_args. * * \param unsaved_files the files that have not yet been saved to disk * but may be required for parsing, including the contents of * those files. The contents and name of these files (as specified by * CXUnsavedFile) are copied when necessary, so the client only needs to * guarantee their validity until the call to this function returns. * * \param num_unsaved_files the number of unsaved file entries in \p * unsaved_files. * * \param options A bitmask of options that affects how the translation unit * is managed but not its compilation. This should be a bitwise OR of the * <API key> flags. * * \returns A new translation unit describing the parsed code and containing * any diagnostics produced by the compiler. If there is a failure from which * the compiler cannot recover, returns NULL. */ CINDEX_LINKAGE CXTranslationUnit <API key>(CXIndex CIdx, const char *source_filename, const char * const *command_line_args, int <API key>, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options); /** * \brief Flags that control how translation units are saved. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when * saving the translation unit. */ enum <API key> { /** * \brief Used to indicate that no special saving options are needed. */ <API key> = 0x0 }; /** * \brief Returns the set of flags that is suitable for saving a translation * unit. * * The set of flags returned provide options for * \c <API key>() by default. The returned flag * set contains an unspecified set of options that save translation units with * the most commonly-requested data. */ CINDEX_LINKAGE unsigned <API key>(CXTranslationUnit TU); /** * \brief Describes the kind of error that occurred (if any) in a call to * \c <API key>(). */ enum CXSaveError { /** * \brief Indicates that no error occurred while saving a translation unit. */ CXSaveError_None = 0, /** * \brief Indicates that an unknown error occurred while attempting to save * the file. * * This error typically indicates that file I/O failed when attempting to * write the file. */ CXSaveError_Unknown = 1, /** * \brief Indicates that errors during translation prevented this attempt * to save the translation unit. * * Errors that prevent the translation unit from being saved can be * extracted using \c <API key>() and \c clang_getDiagnostic(). */ <API key> = 2, /** * \brief Indicates that the translation unit to be saved was somehow * invalid (e.g., NULL). */ <API key> = 3 }; /** * \brief Saves a translation unit into a serialized representation of * that translation unit on disk. * * Any translation unit that was parsed without error can be saved * into a file. The translation unit can then be deserialized into a * new \c CXTranslationUnit with \c <API key>() or, * if it is an incomplete translation unit that corresponds to a * header, used as a precompiled header when parsing other translation * units. * * \param TU The translation unit to save. * * \param FileName The file to which the translation unit will be saved. * * \param options A bitmask of options that affects how the translation unit * is saved. This should be a bitwise OR of the * <API key> flags. * * \returns A value that will match one of the enumerators of the CXSaveError * enumeration. Zero (CXSaveError_None) indicates that the translation unit was * saved successfully, while a non-zero value indicates that a problem occurred. */ CINDEX_LINKAGE int <API key>(CXTranslationUnit TU, const char *FileName, unsigned options); /** * \brief Destroy the specified CXTranslationUnit object. */ CINDEX_LINKAGE void <API key>(CXTranslationUnit); /** * \brief Flags that control the reparsing of translation units. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when * reparsing the translation unit. */ enum CXReparse_Flags { /** * \brief Used to indicate that no special reparsing options are needed. */ CXReparse_None = 0x0 }; /** * \brief Returns the set of flags that is suitable for reparsing a translation * unit. * * The set of flags returned provide options for * \c <API key>() by default. The returned flag * set contains an unspecified set of optimizations geared toward common uses * of reparsing. The set of optimizations enabled may change from one version * to the next. */ CINDEX_LINKAGE unsigned <API key>(CXTranslationUnit TU); /** * \brief Reparse the source files that produced this translation unit. * * This routine can be used to re-parse the source files that originally * created the given translation unit, for example because those source files * have changed (either on disk or as passed via \p unsaved_files). The * source code will be reparsed with the same command-line options as it * was originally parsed. * * Reparsing a translation unit invalidates all cursors and source locations * that refer into that translation unit. This makes reparsing a translation * unit semantically equivalent to destroying the translation unit and then * creating a new translation unit with the same command-line arguments. * However, it may be more efficient to reparse a translation * unit using this routine. * * \param TU The translation unit whose contents will be re-parsed. The * translation unit must originally have been built with * \c <API key>(). * * \param num_unsaved_files The number of unsaved file entries in \p * unsaved_files. * * \param unsaved_files The files that have not yet been saved to disk * but may be required for parsing, including the contents of * those files. The contents and name of these files (as specified by * CXUnsavedFile) are copied when necessary, so the client only needs to * guarantee their validity until the call to this function returns. * * \param options A bitset of options composed of the flags in CXReparse_Flags. * The function \c <API key>() produces a default set of * options recommended for most uses, based on the translation unit. * * \returns 0 if the sources could be reparsed. A non-zero value will be * returned if reparsing was impossible, such that the translation unit is * invalid. In such cases, the only valid call for \p TU is * \c <API key>(TU). */ CINDEX_LINKAGE int <API key>(CXTranslationUnit TU, unsigned num_unsaved_files, struct CXUnsavedFile *unsaved_files, unsigned options); /** * \brief Categorizes how memory is being used by a translation unit. */ enum <API key> { <API key> = 1, <API key> = 2, <API key> = 3, <API key> = 4, <API key> = 5, <API key> = 6, <API key> = 7, <API key> = 8, <API key> = 9, <API key> = 10, <API key> = 11, <API key> = 12, <API key> = 13, <API key> = 14, <API key> = <API key>, <API key> = <API key>, <API key> = <API key>, <API key> = <API key> }; /** * \brief Returns the human-readable null-terminated C string that represents * the name of the memory category. This string should never be freed. */ CINDEX_LINKAGE const char *<API key>(enum <API key> kind); typedef struct <API key> { /* \brief The memory usage category. */ enum <API key> kind; /* \brief Amount of resources used. The units will depend on the resource kind. */ unsigned long amount; } <API key>; /** * \brief The memory usage of a CXTranslationUnit, broken into categories. */ typedef struct CXTUResourceUsage { /* \brief Private data member, used for queries. */ void *data; /* \brief The number of entries in the 'entries' array. */ unsigned numEntries; /* \brief An array of key-value pairs, representing the breakdown of memory usage. */ <API key> *entries; } CXTUResourceUsage; /** * \brief Return the memory usage of a translation unit. This object * should be released with <API key>(). */ CINDEX_LINKAGE CXTUResourceUsage <API key>(CXTranslationUnit TU); CINDEX_LINKAGE void <API key>(CXTUResourceUsage usage); /** * \brief Describes the kind of entity that a cursor refers to. */ enum CXCursorKind { /* Declarations */ /** * \brief A declaration whose specific kind is not exposed via this * interface. * * Unexposed declarations have the same operations as any other kind * of declaration; one can extract their location information, * spelling, find their definitions, etc. However, the specific kind * of the declaration is not reported. */ <API key> = 1, /** \brief A C or C++ struct. */ CXCursor_StructDecl = 2, /** \brief A C or C++ union. */ CXCursor_UnionDecl = 3, /** \brief A C++ class. */ CXCursor_ClassDecl = 4, /** \brief An enumeration. */ CXCursor_EnumDecl = 5, /** * \brief A field (in C) or non-static data member (in C++) in a * struct, union, or C++ class. */ CXCursor_FieldDecl = 6, /** \brief An enumerator constant. */ <API key> = 7, /** \brief A function. */ <API key> = 8, /** \brief A variable. */ CXCursor_VarDecl = 9, /** \brief A function or method parameter. */ CXCursor_ParmDecl = 10, /** \brief An Objective-C \@interface. */ <API key> = 11, /** \brief An Objective-C \@interface for a category. */ <API key> = 12, /** \brief An Objective-C \@protocol declaration. */ <API key> = 13, /** \brief An Objective-C \@property declaration. */ <API key> = 14, /** \brief An Objective-C instance variable. */ <API key> = 15, /** \brief An Objective-C instance method. */ <API key> = 16, /** \brief An Objective-C class method. */ <API key> = 17, /** \brief An Objective-C \@implementation. */ <API key> = 18, /** \brief An Objective-C \@implementation for a category. */ <API key> = 19, /** \brief A typedef */ <API key> = 20, /** \brief A C++ class method. */ CXCursor_CXXMethod = 21, /** \brief A C++ namespace. */ CXCursor_Namespace = 22, /** \brief A linkage specification, e.g. 'extern "C"'. */ <API key> = 23, /** \brief A C++ constructor. */ <API key> = 24, /** \brief A C++ destructor. */ CXCursor_Destructor = 25, /** \brief A C++ conversion function. */ <API key> = 26, /** \brief A C++ template type parameter. */ <API key> = 27, /** \brief A C++ non-type template parameter. */ <API key> = 28, /** \brief A C++ template template parameter. */ <API key> = 29, /** \brief A C++ function template. */ <API key> = 30, /** \brief A C++ class template. */ <API key> = 31, /** \brief A C++ class template partial specialization. */ <API key> = 32, /** \brief A C++ namespace alias declaration. */ <API key> = 33, /** \brief A C++ using directive. */ <API key> = 34, /** \brief A C++ using declaration. */ <API key> = 35, /** \brief A C++ alias declaration */ <API key> = 36, /** \brief An Objective-C \@synthesize definition. */ <API key> = 37, /** \brief An Objective-C \@dynamic definition. */ <API key> = 38, /** \brief An access specifier. */ <API key> = 39, CXCursor_FirstDecl = <API key>, CXCursor_LastDecl = <API key>, /* References */ CXCursor_FirstRef = 40, /* Decl references */ <API key> = 40, <API key> = 41, <API key> = 42, /** * \brief A reference to a type declaration. * * A type reference occurs anywhere where a type is named but not * declared. For example, given: * * \code * typedef unsigned size_type; * size_type size; * \endcode * * The typedef is a declaration of size_type (<API key>), * while the type of the variable "size" is referenced. The cursor * referenced by the type of size is the typedef for size_type. */ CXCursor_TypeRef = 43, <API key> = 44, /** * \brief A reference to a class template, function template, template * template parameter, or class template partial specialization. */ <API key> = 45, /** * \brief A reference to a namespace or namespace alias. */ <API key> = 46, /** * \brief A reference to a member of a struct, union, or class that occurs in * some non-expression context, e.g., a designated initializer. */ CXCursor_MemberRef = 47, /** * \brief A reference to a labeled statement. * * This cursor kind is used to describe the jump to "start_over" in the * goto statement in the following example: * * \code * start_over: * ++counter; * * goto start_over; * \endcode * * A label reference cursor refers to a label statement. */ CXCursor_LabelRef = 48, /** * \brief A reference to a set of overloaded functions or function templates * that has not yet been resolved to a specific function or function template. * * An overloaded declaration reference cursor occurs in C++ templates where * a dependent name refers to a function. For example: * * \code * template<typename T> void swap(T&, T&); * * struct X { ... }; * void swap(X&, X&); * * template<typename T> * void reverse(T* first, T* last) { * while (first < last - 1) { * swap(*first, *--last); * ++first; * } * } * * struct Y { }; * void swap(Y&, Y&); * \endcode * * Here, the identifier "swap" is associated with an overloaded declaration * reference. In the template definition, "swap" refers to either of the two * "swap" functions declared above, so both results will be available. At * instantiation time, "swap" may also refer to other functions found via * argument-dependent lookup (e.g., the "swap" function at the end of the * example). * * The functions \c <API key>() and * \c <API key>() can be used to retrieve the definitions * referenced by this cursor. */ <API key> = 49, /** * \brief A reference to a variable that occurs in some non-expression * context, e.g., a C++ lambda capture list. */ <API key> = 50, CXCursor_LastRef = <API key>, /* Error conditions */ <API key> = 70, <API key> = 70, <API key> = 71, <API key> = 72, <API key> = 73, <API key> = <API key>, /* Expressions */ CXCursor_FirstExpr = 100, /** * \brief An expression whose specific kind is not exposed via this * interface. * * Unexposed expressions have the same operations as any other kind * of expression; one can extract their location information, * spelling, children, etc. However, the specific kind of the * expression is not reported. */ <API key> = 100, /** * \brief An expression that refers to some value declaration, such * as a function, varible, or enumerator. */ <API key> = 101, /** * \brief An expression that refers to a member of a struct, union, * class, Objective-C class, etc. */ <API key> = 102, /** \brief An expression that calls a function. */ CXCursor_CallExpr = 103, /** \brief An expression that sends a message to an Objective-C object or class. */ <API key> = 104, /** \brief An expression that represents a block literal. */ CXCursor_BlockExpr = 105, /** \brief An integer literal. */ <API key> = 106, /** \brief A floating point number literal. */ <API key> = 107, /** \brief An imaginary number literal. */ <API key> = 108, /** \brief A string literal. */ <API key> = 109, /** \brief A character literal. */ <API key> = 110, /** \brief A parenthesized expression, e.g. "(1)". * * This AST node is only formed if full location information is requested. */ CXCursor_ParenExpr = 111, /** \brief This represents the unary-expression's (except sizeof and * alignof). */ <API key> = 112, /** \brief [C99 6.5.2.1] Array Subscripting. */ <API key> = 113, /** \brief A builtin binary operation expression such as "x + y" or * "x <= y". */ <API key> = 114, /** \brief Compound assignment such as "+=". */ <API key> = 115, /** \brief The ?: ternary operator. */ <API key> = 116, /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++ * (C++ [expr.cast]), which uses the syntax (Type)expr. * * For example: (int)f. */ <API key> = 117, /** \brief [C99 6.5.2.5] */ <API key> = 118, /** \brief Describes an C or C++ initializer list. */ <API key> = 119, /** \brief The GNU address of label extension, representing &&label. */ <API key> = 120, /** \brief This is the GNU Statement Expression extension: ({int X=4; X;}) */ CXCursor_StmtExpr = 121, /** \brief Represents a C11 generic selection. */ <API key> = 122, /** \brief Implements the GNU __null extension, which is a name for a null * pointer constant that has integral type (e.g., int or long) and is the same * size and alignment as a pointer. * * The __null extension is typically only used by system headers, which define * NULL as __null in C++ rather than using 0 (which is an integer that may not * match the size of a pointer). */ <API key> = 123, /** \brief C++'s static_cast<> expression. */ <API key> = 124, /** \brief C++'s dynamic_cast<> expression. */ <API key> = 125, /** \brief C++'s reinterpret_cast<> expression. */ <API key> = 126, /** \brief C++'s const_cast<> expression. */ <API key> = 127, /** \brief Represents an explicit C++ type conversion that uses "functional" * notion (C++ [expr.type.conv]). * * Example: * \code * x = int(0.5); * \endcode */ <API key> = 128, /** \brief A C++ typeid expression (C++ [expr.typeid]). */ <API key> = 129, /** \brief [C++ 2.13.5] C++ Boolean Literal. */ <API key> = 130, /** \brief [C++0x 2.14.7] C++ Pointer Literal. */ <API key> = 131, /** \brief Represents the "this" expression in C++ */ <API key> = 132, /** \brief [C++ 15] C++ Throw Expression. * * This handles 'throw' and 'throw' <API key>. When * <API key> isn't present, Op will be null. */ <API key> = 133, /** \brief A new expression for memory allocation and constructor calls, e.g: * "new CXXNewExpr(foo)". */ CXCursor_CXXNewExpr = 134, /** \brief A delete expression for memory deallocation and destructor calls, * e.g. "delete[] pArray". */ <API key> = 135, /** \brief A unary expression. */ CXCursor_UnaryExpr = 136, /** \brief An Objective-C string literal i.e. @"foo". */ <API key> = 137, /** \brief An Objective-C \@encode expression. */ <API key> = 138, /** \brief An Objective-C \@selector expression. */ <API key> = 139, /** \brief An Objective-C \@protocol expression. */ <API key> = 140, /** \brief An Objective-C "bridged" cast expression, which casts between * Objective-C pointers and C pointers, transferring ownership in the process. * * \code * NSString *str = (__bridge_transfer NSString *)CFCreateString(); * \endcode */ <API key> = 141, /** \brief Represents a C++0x pack expansion that produces a sequence of * expressions. * * A pack expansion expression contains a pattern (which itself is an * expression) followed by an ellipsis. For example: * * \code * template<typename F, typename ...Types> * void forward(F f, Types &&...args) { * f(static_cast<Types&&>(args)...); * } * \endcode */ <API key> = 142, /** \brief Represents an expression that computes the length of a parameter * pack. * * \code * template<typename ...Types> * struct count { * static const unsigned value = sizeof...(Types); * }; * \endcode */ <API key> = 143, /* \brief Represents a C++ lambda expression that produces a local function * object. * * \code * void abssort(float *x, unsigned N) { * std::sort(x, x + N, * [](float a, float b) { * return std::abs(a) < std::abs(b); * }); * } * \endcode */ CXCursor_LambdaExpr = 144, /** \brief Objective-c Boolean Literal. */ <API key> = 145, /** \brief Represents the "self" expression in a ObjC method. */ <API key> = 146, CXCursor_LastExpr = <API key>, /* Statements */ CXCursor_FirstStmt = 200, /** * \brief A statement whose specific kind is not exposed via this * interface. * * Unexposed statements have the same operations as any other kind of * statement; one can extract their location information, spelling, * children, etc. However, the specific kind of the statement is not * reported. */ <API key> = 200, /** \brief A labelled statement in a function. * * This cursor kind is used to describe the "start_over:" label statement in * the following example: * * \code * start_over: * ++counter; * \endcode * */ CXCursor_LabelStmt = 201, /** \brief A group of statements like { stmt stmt }. * * This cursor kind is used to describe compound statements, e.g. function * bodies. */ <API key> = 202, /** \brief A case statment. */ CXCursor_CaseStmt = 203, /** \brief A default statement. */ <API key> = 204, /** \brief An if statement */ CXCursor_IfStmt = 205, /** \brief A switch statement. */ CXCursor_SwitchStmt = 206, /** \brief A while statement. */ CXCursor_WhileStmt = 207, /** \brief A do statement. */ CXCursor_DoStmt = 208, /** \brief A for statement. */ CXCursor_ForStmt = 209, /** \brief A goto statement. */ CXCursor_GotoStmt = 210, /** \brief An indirect goto statement. */ <API key> = 211, /** \brief A continue statement. */ <API key> = 212, /** \brief A break statement. */ CXCursor_BreakStmt = 213, /** \brief A return statement. */ CXCursor_ReturnStmt = 214, /** \brief A GCC inline assembly statement extension. */ CXCursor_GCCAsmStmt = 215, CXCursor_AsmStmt = CXCursor_GCCAsmStmt, /** \brief Objective-C's overall \@try-\@catch-\@finally statement. */ <API key> = 216, /** \brief Objective-C's \@catch statement. */ <API key> = 217, /** \brief Objective-C's \@finally statement. */ <API key> = 218, /** \brief Objective-C's \@throw statement. */ <API key> = 219, /** \brief Objective-C's \@synchronized statement. */ <API key> = 220, /** \brief Objective-C's autorelease pool statement. */ <API key> = 221, /** \brief Objective-C's collection statement. */ <API key> = 222, /** \brief C++'s catch statement. */ <API key> = 223, /** \brief C++'s try statement. */ CXCursor_CXXTryStmt = 224, /** \brief C++'s for (* : *) statement. */ <API key> = 225, /** \brief Windows Structured Exception Handling's try statement. */ CXCursor_SEHTryStmt = 226, /** \brief Windows Structured Exception Handling's except statement. */ <API key> = 227, /** \brief Windows Structured Exception Handling's finally statement. */ <API key> = 228, /** \brief A MS inline assembly statement extension. */ CXCursor_MSAsmStmt = 229, /** \brief The null satement ";": C99 6.8.3p3. * * This cursor kind is used to describe the null statement. */ CXCursor_NullStmt = 230, /** \brief Adaptor class for mixing declarations with statements and * expressions. */ CXCursor_DeclStmt = 231, /** \brief OpenMP parallel directive. */ <API key> = 232, CXCursor_LastStmt = <API key>, /** * \brief Cursor that represents the translation unit itself. * * The translation unit cursor exists primarily to act as the root * cursor for traversing the contents of a translation unit. */ <API key> = 300, /* Attributes */ CXCursor_FirstAttr = 400, /** * \brief An attribute whose specific kind is not exposed via this * interface. */ <API key> = 400, <API key> = 401, <API key> = 402, <API key> = 403, <API key> = 404, <API key> = 405, <API key> = 406, <API key> = 407, CXCursor_LastAttr = <API key>, /* Preprocessing */ <API key> = 500, <API key> = 501, <API key> = 502, <API key> = <API key>, <API key> = 503, <API key> = <API key>, <API key> = <API key>, /* Extra Declarations */ /** * \brief A module import declaration. */ <API key> = 600, <API key> = <API key>, <API key> = <API key> }; /** * \brief A cursor representing some element in the abstract syntax tree for * a translation unit. * * The cursor abstraction unifies the different kinds of entities in a * <API key>, statements, expressions, references to declarations, * etc.--under a single "cursor" abstraction with a common set of operations. * Common operation for a cursor include: getting the physical location in * a source file where the cursor points, getting the name associated with a * cursor, and retrieving cursors for any child nodes of a particular cursor. * * Cursors can be produced in two specific ways. * <API key>() produces a cursor for a translation unit, * from which one can use clang_visitChildren() to explore the rest of the * translation unit. clang_getCursor() maps from a physical source location * to the entity that resides at that location, allowing one to map from the * source code into the AST. */ typedef struct { enum CXCursorKind kind; int xdata; const void *data[3]; } CXCursor; /** * \brief A comment AST node. */ typedef struct { const void *ASTNode; CXTranslationUnit TranslationUnit; } CXComment; /** * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations * * @{ */ /** * \brief Retrieve the NULL cursor, which represents no entity. */ CINDEX_LINKAGE CXCursor clang_getNullCursor(void); /** * \brief Retrieve the cursor that represents the given translation unit. * * The translation unit cursor can be used to start traversing the * various declarations within the given translation unit. */ CINDEX_LINKAGE CXCursor <API key>(CXTranslationUnit); /** * \brief Determine whether two cursors are equivalent. */ CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); /** * \brief Returns non-zero if \p cursor is null. */ CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); /** * \brief Compute a hash value for the given cursor. */ CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); /** * \brief Retrieve the kind of the given cursor. */ CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); /** * \brief Determine whether the given cursor kind represents a declaration. */ CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents a simple * reference. * * Note that other kinds of cursors (such as expressions) can also refer to * other cursors. Use <API key>() to determine whether a * particular cursor refers to another entity. */ CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents an expression. */ CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents a statement. */ CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents an attribute. */ CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents an invalid * cursor. */ CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); /** * \brief Determine whether the given cursor kind represents a translation * unit. */ CINDEX_LINKAGE unsigned <API key>(enum CXCursorKind); /*** * \brief Determine whether the given cursor represents a preprocessing * element, such as a preprocessor directive or macro instantiation. */ CINDEX_LINKAGE unsigned <API key>(enum CXCursorKind); /*** * \brief Determine whether the given cursor represents a currently * unexposed piece of the AST (e.g., <API key>). */ CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); /** * \brief Describe the linkage of the entity referred to by a cursor. */ enum CXLinkageKind { /** \brief This value indicates that no linkage information is available * for a provided CXCursor. */ CXLinkage_Invalid, /** * \brief This is the linkage for variables, parameters, and so on that * have automatic storage. This covers normal (non-extern) local variables. */ CXLinkage_NoLinkage, /** \brief This is the linkage for static variables and static functions. */ CXLinkage_Internal, /** \brief This is the linkage for entities with external linkage that live * in C++ anonymous namespaces.*/ <API key>, /** \brief This is the linkage for entities with true, external linkage. */ CXLinkage_External }; /** * \brief Determine the linkage of the entity referred to by a given cursor. */ CINDEX_LINKAGE enum CXLinkageKind <API key>(CXCursor cursor); /** * \brief Determine the availability of the entity that this cursor refers to, * taking the current target platform into account. * * \param cursor The cursor to query. * * \returns The availability of the cursor. */ CINDEX_LINKAGE enum CXAvailabilityKind <API key>(CXCursor cursor); /** * Describes the availability of a given entity on a particular platform, e.g., * a particular class might only be available on Mac OS 10.7 or newer. */ typedef struct <API key> { /** * \brief A string that describes the platform for which this structure * provides availability information. * * Possible values are "ios" or "macosx". */ CXString Platform; /** * \brief The version number in which this entity was introduced. */ CXVersion Introduced; /** * \brief The version number in which this entity was deprecated (but is * still available). */ CXVersion Deprecated; /** * \brief The version number in which this entity was obsoleted, and therefore * is no longer available. */ CXVersion Obsoleted; /** * \brief Whether the entity is unconditionally unavailable on this platform. */ int Unavailable; /** * \brief An optional message to provide to a user of this API, e.g., to * suggest replacement APIs. */ CXString Message; } <API key>; /** * \brief Determine the availability of the entity that this cursor refers to * on any platforms for which availability information is known. * * \param cursor The cursor to query. * * \param always_deprecated If non-NULL, will be set to indicate whether the * entity is deprecated on all platforms. * * \param deprecated_message If non-NULL, will be set to the message text * provided along with the unconditional deprecation of this entity. The client * is responsible for deallocating this string. * * \param always_unavailable If non-NULL, will be set to indicate whether the * entity is unavailable on all platforms. * * \param unavailable_message If non-NULL, will be set to the message text * provided along with the unconditional unavailability of this entity. The * client is responsible for deallocating this string. * * \param availability If non-NULL, an array of <API key> instances * that will be populated with platform availability information, up to either * the number of platforms for which availability information is available (as * returned by this function) or \c availability_size, whichever is smaller. * * \param availability_size The number of elements available in the * \c availability array. * * \returns The number of platforms (N) for which availability information is * available (which is unrelated to \c availability_size). * * Note that the client is responsible for calling * \c <API key> to free each of the * <API key> structures returned. There are * \c min(N, availability_size) such structures. */ CINDEX_LINKAGE int <API key>(CXCursor cursor, int *always_deprecated, CXString *deprecated_message, int *always_unavailable, CXString *unavailable_message, <API key> *availability, int availability_size); /** * \brief Free the memory associated with a \c <API key> structure. */ CINDEX_LINKAGE void <API key>(<API key> *availability); /** * \brief Describe the "language" of the entity referred to by a cursor. */ CINDEX_LINKAGE enum CXLanguageKind { CXLanguage_Invalid = 0, CXLanguage_C, CXLanguage_ObjC, <API key> }; /** * \brief Determine the "language" of the entity referred to by a given cursor. */ CINDEX_LINKAGE enum CXLanguageKind <API key>(CXCursor cursor); /** * \brief Returns the translation unit that a cursor originated from. */ CINDEX_LINKAGE CXTranslationUnit <API key>(CXCursor); /** * \brief A fast container representing a set of CXCursors. */ typedef struct CXCursorSetImpl *CXCursorSet; /** * \brief Creates an empty CXCursorSet. */ CINDEX_LINKAGE CXCursorSet <API key>(void); /** * \brief Disposes a CXCursorSet and releases its associated memory. */ CINDEX_LINKAGE void <API key>(CXCursorSet cset); /** * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. * * \returns non-zero if the set contains the specified cursor. */ CINDEX_LINKAGE unsigned <API key>(CXCursorSet cset, CXCursor cursor); /** * \brief Inserts a CXCursor into a CXCursorSet. * * \returns zero if the CXCursor was already in the set, and non-zero otherwise. */ CINDEX_LINKAGE unsigned <API key>(CXCursorSet cset, CXCursor cursor); /** * \brief Determine the semantic parent of the given cursor. * * The semantic parent of a cursor is the cursor that semantically contains * the given \p cursor. For many declarations, the lexical and semantic parents * are equivalent (the lexical parent is returned by * \c <API key>()). They diverge when declarations or * definitions are provided out-of-line. For example: * * \code * class C { * void f(); * }; * * void C::f() { } * \endcode * * In the out-of-line definition of \c C::f, the semantic parent is the * the class \c C, of which this function is a member. The lexical parent is * the place where the declaration actually occurs in the source code; in this * case, the definition occurs in the translation unit. In general, the * lexical parent for a given entity can change without affecting the semantics * of the program, and the lexical parent of different declarations of the * same entity may be different. Changing the semantic parent of a declaration, * on the other hand, can have a major impact on semantics, and redeclarations * of a particular entity should all have the same semantic context. * * In the example above, both declarations of \c C::f have \c C as their * semantic context, while the lexical context of the first \c C::f is \c C * and the lexical context of the second \c C::f is the translation unit. * * For global declarations, the semantic parent is the translation unit. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor cursor); /** * \brief Determine the lexical parent of the given cursor. * * The lexical parent of a cursor is the cursor in which the given \p cursor * was actually written. For many declarations, the lexical and semantic parents * are equivalent (the semantic parent is returned by * \c <API key>()). They diverge when declarations or * definitions are provided out-of-line. For example: * * \code * class C { * void f(); * }; * * void C::f() { } * \endcode * * In the out-of-line definition of \c C::f, the semantic parent is the * the class \c C, of which this function is a member. The lexical parent is * the place where the declaration actually occurs in the source code; in this * case, the definition occurs in the translation unit. In general, the * lexical parent for a given entity can change without affecting the semantics * of the program, and the lexical parent of different declarations of the * same entity may be different. Changing the semantic parent of a declaration, * on the other hand, can have a major impact on semantics, and redeclarations * of a particular entity should all have the same semantic context. * * In the example above, both declarations of \c C::f have \c C as their * semantic context, while the lexical context of the first \c C::f is \c C * and the lexical context of the second \c C::f is the translation unit. * * For declarations written in the global scope, the lexical parent is * the translation unit. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor cursor); /** * \brief Determine the set of methods that are overridden by the given * method. * * In both Objective-C and C++, a method (aka virtual member function, * in C++) can override a virtual method in a base class. For * Objective-C, a method is said to override any method in the class's * base class, its protocols, or its categories' protocols, that has the same * selector and is of the same kind (class or instance). * If no such method exists, the search continues to the class's superclass, * its protocols, and its categories, and so on. A method from an Objective-C * implementation is considered to override the same methods as its * corresponding method in the interface. * * For C++, a virtual member function overrides any virtual member * function with the same signature that occurs in its base * classes. With multiple inheritance, a virtual member function can * override several virtual member functions coming from different * base classes. * * In all cases, this function determines the immediate overridden * method, rather than all of the overridden methods. For example, if * a method is originally declared in a class A, then overridden in B * (which in inherits from A) and also in C (which inherited from B), * then the only overridden method returned from this function when * invoked on C's method will be B's method. The client may then * invoke this function again, given the previously-found overridden * methods, to map out the complete method-override set. * * \param cursor A cursor representing an Objective-C or C++ * method. This routine will compute the set of methods that this * method overrides. * * \param overridden A pointer whose pointee will be replaced with a * pointer to an array of cursors, representing the set of overridden * methods. If there are no overridden methods, the pointee will be * set to NULL. The pointee must be freed via a call to * \c <API key>(). * * \param num_overridden A pointer to the number of overridden * functions, will be set to the number of overridden functions in the * array pointed to by \p overridden. */ CINDEX_LINKAGE void <API key>(CXCursor cursor, CXCursor **overridden, unsigned *num_overridden); /** * \brief Free the set of overridden cursors returned by \c * <API key>(). */ CINDEX_LINKAGE void <API key>(CXCursor *overridden); /** * \brief Retrieve the file that is included by the given inclusion directive * cursor. */ CINDEX_LINKAGE CXFile <API key>(CXCursor cursor); /** * \defgroup <API key> Mapping between cursors and source code * * Cursors represent a location within the Abstract Syntax Tree (AST). These * routines help map between cursors and the physical locations where the * described entities occur in the source code. The mapping is provided in * both directions, so one can map from source code to the AST and back. * * @{ */ /** * \brief Map a source location to the cursor that describes the entity at that * location in the source code. * * clang_getCursor() maps an arbitrary source location within a translation * unit down to the most specific cursor that describes the entity at that * location. For example, given an expression \c x + y, invoking * clang_getCursor() with a source location pointing to "x" will return the * cursor for "x"; similarly for "y". If the cursor points anywhere between * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() * will return a cursor referring to the "+" expression. * * \returns a cursor representing the entity at the given source location, or * a NULL cursor if no such entity can be found. */ CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); /** * \brief Retrieve the physical location of the source constructor referenced * by the given cursor. * * The location of a declaration is typically the location of the name of that * declaration, where the name of that declaration would occur if it is * unnamed, or some keyword that introduces that particular declaration. * The location of a reference is where that reference occurs within the * source code. */ CINDEX_LINKAGE CXSourceLocation <API key>(CXCursor); /** * \brief Retrieve the physical extent of the source construct referenced by * the given cursor. * * The extent of a cursor starts with the file/line/column pointing at the * first character within the source construct that the cursor refers to and * ends with the last character withinin that source construct. For a * declaration, the extent covers the declaration itself. For a reference, * the extent covers the location of the reference (e.g., where the referenced * entity was actually used). */ CINDEX_LINKAGE CXSourceRange <API key>(CXCursor); /** * \defgroup CINDEX_TYPES Type information for CXCursors * * @{ */ /** * \brief Describes the kind of type */ enum CXTypeKind { /** * \brief Reprents an invalid type (e.g., where no type is available). */ CXType_Invalid = 0, /** * \brief A type whose specific kind is not exposed via this * interface. */ CXType_Unexposed = 1, /* Builtin types */ CXType_Void = 2, CXType_Bool = 3, CXType_Char_U = 4, CXType_UChar = 5, CXType_Char16 = 6, CXType_Char32 = 7, CXType_UShort = 8, CXType_UInt = 9, CXType_ULong = 10, CXType_ULongLong = 11, CXType_UInt128 = 12, CXType_Char_S = 13, CXType_SChar = 14, CXType_WChar = 15, CXType_Short = 16, CXType_Int = 17, CXType_Long = 18, CXType_LongLong = 19, CXType_Int128 = 20, CXType_Float = 21, CXType_Double = 22, CXType_LongDouble = 23, CXType_NullPtr = 24, CXType_Overload = 25, CXType_Dependent = 26, CXType_ObjCId = 27, CXType_ObjCClass = 28, CXType_ObjCSel = 29, CXType_FirstBuiltin = CXType_Void, CXType_LastBuiltin = CXType_ObjCSel, CXType_Complex = 100, CXType_Pointer = 101, CXType_BlockPointer = 102, <API key> = 103, <API key> = 104, CXType_Record = 105, CXType_Enum = 106, CXType_Typedef = 107, <API key> = 108, <API key> = 109, <API key> = 110, <API key> = 111, <API key> = 112, CXType_Vector = 113, <API key> = 114, <API key> = 115, <API key> = 116 }; /** * \brief Describes the calling convention of a function type */ enum CXCallingConv { <API key> = 0, CXCallingConv_C = 1, <API key> = 2, <API key> = 3, <API key> = 4, <API key> = 5, CXCallingConv_AAPCS = 6, <API key> = 7, <API key> = 8, <API key> = 9, <API key> = 10, <API key> = 11, <API key> = 100, <API key> = 200 }; /** * \brief The type of an element in the abstract syntax tree. * */ typedef struct { enum CXTypeKind kind; void *data[2]; } CXType; /** * \brief Retrieve the type of a CXCursor (if any). */ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); /** * \brief Pretty-print the underlying type using the rules of the * language of the translation unit from which it came. * * If the type is invalid, an empty string is returned. */ CINDEX_LINKAGE CXString <API key>(CXType CT); /** * \brief Retrieve the underlying type of a typedef declaration. * * If the cursor does not reference a typedef declaration, an invalid type is * returned. */ CINDEX_LINKAGE CXType <API key>(CXCursor C); /** * \brief Retrieve the integer type of an enum declaration. * * If the cursor does not reference an enum declaration, an invalid type is * returned. */ CINDEX_LINKAGE CXType <API key>(CXCursor C); /** * \brief Retrieve the integer value of an enum constant declaration as a signed * long long. * * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. * Since this is also potentially a valid constant value, the kind of the cursor * must be verified before calling this function. */ CINDEX_LINKAGE long long <API key>(CXCursor C); /** * \brief Retrieve the integer value of an enum constant declaration as an unsigned * long long. * * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. * Since this is also potentially a valid constant value, the kind of the cursor * must be verified before calling this function. */ CINDEX_LINKAGE unsigned long long <API key>(CXCursor C); /** * \brief Retrieve the bit width of a bit field declaration as an integer. * * If a cursor that is not a bit field declaration is passed in, -1 is returned. */ CINDEX_LINKAGE int <API key>(CXCursor C); /** * \brief Retrieve the number of non-variadic arguments associated with a given * cursor. * * The number of arguments can be determined for calls as well as for * declarations of functions or methods. For other cursors -1 is returned. */ CINDEX_LINKAGE int <API key>(CXCursor C); /** * \brief Retrieve the argument cursor of a function or method. * * The argument cursor can be determined for calls as well as for declarations * of functions or methods. For other cursors and for invalid indices, an * invalid cursor is returned. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor C, unsigned i); /** * \brief Determine whether two CXTypes represent the same type. * * \returns non-zero if the CXTypes represent the same type and * zero otherwise. */ CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); /** * \brief Return the canonical type for a CXType. * * Clang's type system explicitly models typedefs and all the ways * a specific type can be represented. The canonical type is the underlying * type with all the "sugar" removed. For example, if 'T' is a typedef * for 'int', the canonical type for 'T' would be 'int'. */ CINDEX_LINKAGE CXType <API key>(CXType T); /** * \brief Determine whether a CXType has the "const" qualifier set, * without looking through typedefs that may have added "const" at a * different level. */ CINDEX_LINKAGE unsigned <API key>(CXType T); /** * \brief Determine whether a CXType has the "volatile" qualifier set, * without looking through typedefs that may have added "volatile" at * a different level. */ CINDEX_LINKAGE unsigned <API key>(CXType T); /** * \brief Determine whether a CXType has the "restrict" qualifier set, * without looking through typedefs that may have added "restrict" at a * different level. */ CINDEX_LINKAGE unsigned <API key>(CXType T); /** * \brief For pointer types, returns the type of the pointee. */ CINDEX_LINKAGE CXType <API key>(CXType T); /** * \brief Return the cursor for the declaration of the given type. */ CINDEX_LINKAGE CXCursor <API key>(CXType T); /** * Returns the Objective-C type encoding for the specified declaration. */ CINDEX_LINKAGE CXString <API key>(CXCursor C); /** * \brief Retrieve the spelling of a given CXTypeKind. */ CINDEX_LINKAGE CXString <API key>(enum CXTypeKind K); /** * \brief Retrieve the calling convention associated with a function type. * * If a non-function type is passed in, <API key> is returned. */ CINDEX_LINKAGE enum CXCallingConv <API key>(CXType T); /** * \brief Retrieve the result type associated with a function type. * * If a non-function type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_getResultType(CXType T); /** * \brief Retrieve the number of non-variadic arguments associated with a * function type. * * If a non-function type is passed in, -1 is returned. */ CINDEX_LINKAGE int <API key>(CXType T); /** * \brief Retrieve the type of an argument of a function type. * * If a non-function type is passed in or the function does not have enough * parameters, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); /** * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. */ CINDEX_LINKAGE unsigned <API key>(CXType T); /** * \brief Retrieve the result type associated with a given cursor. * * This only returns a valid type if the cursor refers to a function or method. */ CINDEX_LINKAGE CXType <API key>(CXCursor C); /** * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 * otherwise. */ CINDEX_LINKAGE unsigned clang_isPODType(CXType T); /** * \brief Return the element type of an array, complex, or vector type. * * If a type is passed in that is not an array, complex, or vector type, * an invalid type is returned. */ CINDEX_LINKAGE CXType <API key>(CXType T); /** * \brief Return the number of elements of an array or vector type. * * If a type is passed in that is not an array or vector type, * -1 is returned. */ CINDEX_LINKAGE long long <API key>(CXType T); /** * \brief Return the element type of an array type. * * If a non-array type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType <API key>(CXType T); /** * \brief Return the array size of a constant array. * * If a non-array type is passed in, -1 is returned. */ CINDEX_LINKAGE long long clang_getArraySize(CXType T); /** * \brief List the possible error codes for \c <API key>, * \c <API key>, \c <API key> and * \c <API key>. * * A value of this enumeration type can be returned if the target type is not * a valid argument to sizeof, alignof or offsetof. */ enum CXTypeLayoutError { /** * \brief Type is of kind CXType_Invalid. */ <API key> = -1, /** * \brief The type is an incomplete Type. */ <API key> = -2, /** * \brief The type is a dependent Type. */ <API key> = -3, /** * \brief The type is not a constant size type. */ <API key> = -4, /** * \brief The Field name is not valid for this record. */ <API key> = -5 }; /** * \brief Return the alignment of a type in bytes as per C++[expr.alignof] * standard. * * If the type declaration is invalid, <API key> is returned. * If the type declaration is an incomplete type, <API key> * is returned. * If the type declaration is a dependent type, <API key> is * returned. * If the type declaration is not a constant size type, * <API key> is returned. */ CINDEX_LINKAGE long long <API key>(CXType T); /** * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard. * * If the type declaration is invalid, <API key> is returned. * If the type declaration is an incomplete type, <API key> * is returned. * If the type declaration is a dependent type, <API key> is * returned. */ CINDEX_LINKAGE long long <API key>(CXType T); /** * \brief Return the offset of a field named S in a record of type T in bits * as it would be returned by __offsetof__ as per C++11[18.2p4] * * If the cursor is not a record field declaration, <API key> * is returned. * If the field's type declaration is an incomplete type, * <API key> is returned. * If the field's type declaration is a dependent type, * <API key> is returned. * If the field's name S is not found, * <API key> is returned. */ CINDEX_LINKAGE long long <API key>(CXType T, const char *S); /** * \brief Returns non-zero if the cursor specifies a Record member that is a * bitfield. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Returns 1 if the base class specified by the cursor with kind * CX_CXXBaseSpecifier is virtual. */ CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); /** * \brief Represents the C++ access control level to a base class for a * cursor with kind CX_CXXBaseSpecifier. */ enum <API key> { <API key>, CX_CXXPublic, CX_CXXProtected, CX_CXXPrivate }; /** * \brief Returns the access control level for the referenced object. * * If the cursor refers to a C++ declaration, its access control level within its * parent scope is returned. Otherwise, if the cursor refers to a base specifier or * access specifier, the specifier itself is returned. */ CINDEX_LINKAGE enum <API key> <API key>(CXCursor); /** * \brief Determine the number of overloaded declarations referenced by a * \c <API key> cursor. * * \param cursor The cursor whose overloaded declarations are being queried. * * \returns The number of overloaded declarations referenced by \c cursor. If it * is not a \c <API key> cursor, returns 0. */ CINDEX_LINKAGE unsigned <API key>(CXCursor cursor); /** * \brief Retrieve a cursor for one of the overloaded declarations referenced * by a \c <API key> cursor. * * \param cursor The cursor whose overloaded declarations are being queried. * * \param index The zero-based index into the set of overloaded declarations in * the cursor. * * \returns A cursor representing the declaration referenced by the given * \c cursor at the specified \c index. If the cursor does not have an * associated set of overloaded declarations, or if the index is out of bounds, * returns \c clang_getNullCursor(); */ CINDEX_LINKAGE CXCursor <API key>(CXCursor cursor, unsigned index); /** * \defgroup CINDEX_ATTRIBUTES Information for attributes * * @{ */ /** * \brief For cursors representing an iboutletcollection attribute, * this function returns the collection element type. * */ CINDEX_LINKAGE CXType <API key>(CXCursor); /** * \defgroup <API key> Traversing the AST with cursors * * These routines provide the ability to traverse the abstract syntax tree * using cursors. * * @{ */ /** * \brief Describes how the traversal of the children of a particular * cursor should proceed after visiting a particular child cursor. * * A value of this enumeration type should be returned by each * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. */ enum CXChildVisitResult { /** * \brief Terminates the cursor traversal. */ CXChildVisit_Break, /** * \brief Continues the cursor traversal with the next sibling of * the cursor just visited, without visiting its children. */ <API key>, /** * \brief Recursively traverse the children of this cursor, using * the same visitor and client data. */ <API key> }; /** * \brief Visitor invoked for each cursor found by a traversal. * * This visitor function will be invoked for each cursor found by * <API key>(). Its first argument is the cursor being * visited, its second argument is the parent visitor for that cursor, * and its third argument is the client data provided to * <API key>(). * * The visitor should return one of the \c CXChildVisitResult values * to direct <API key>(). */ typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, CXCursor parent, CXClientData client_data); /** * \brief Visit the children of a particular cursor. * * This function visits all the direct children of the given cursor, * invoking the given \p visitor function with the cursors of each * visited child. The traversal may be recursive, if the visitor returns * \c <API key>. The traversal may also be ended prematurely, if * the visitor returns \c CXChildVisit_Break. * * \param parent the cursor whose child may be visited. All kinds of * cursors can be visited, including invalid cursors (which, by * definition, have no children). * * \param visitor the visitor function that will be invoked for each * child of \p parent. * * \param client_data pointer data supplied by the client, which will * be passed to the visitor each time it is invoked. * * \returns a non-zero value if the traversal was terminated * prematurely by the visitor returning \c CXChildVisit_Break. */ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data); #ifdef __has_feature # if __has_feature(blocks) /** * \brief Visitor invoked for each cursor found by a traversal. * * This visitor block will be invoked for each cursor found by * <API key>(). Its first argument is the cursor being * visited, its second argument is the parent visitor for that cursor. * * The visitor should return one of the \c CXChildVisitResult values * to direct <API key>(). */ typedef enum CXChildVisitResult (^<API key>)(CXCursor cursor, CXCursor parent); /** * Visits the children of a cursor using the specified block. Behaves * identically to clang_visitChildren() in all other respects. */ unsigned <API key>(CXCursor parent, <API key> block); # endif #endif /** * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST * * These routines provide the ability to determine references within and * across translation units, by providing the names of the entities referenced * by cursors, follow reference cursors to the declarations they reference, * and associate declarations with their definitions. * * @{ */ /** * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced * by the given cursor. * * A Unified Symbol Resolution (USR) is a string that identifies a particular * entity (function, class, variable, etc.) within a program. USRs can be * compared across translation units to determine, e.g., when references in * one translation refer to an entity defined in another translation unit. */ CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); /** * \brief Construct a USR for a specified Objective-C class. */ CINDEX_LINKAGE CXString <API key>(const char *class_name); /** * \brief Construct a USR for a specified Objective-C category. */ CINDEX_LINKAGE CXString <API key>(const char *class_name, const char *category_name); /** * \brief Construct a USR for a specified Objective-C protocol. */ CINDEX_LINKAGE CXString <API key>(const char *protocol_name); /** * \brief Construct a USR for a specified Objective-C instance variable and * the USR for its containing class. */ CINDEX_LINKAGE CXString <API key>(const char *name, CXString classUSR); /** * \brief Construct a USR for a specified Objective-C method and * the USR for its containing class. */ CINDEX_LINKAGE CXString <API key>(const char *name, unsigned isInstanceMethod, CXString classUSR); /** * \brief Construct a USR for a specified Objective-C property and the USR * for its containing class. */ CINDEX_LINKAGE CXString <API key>(const char *property, CXString classUSR); /** * \brief Retrieve a name for the entity referenced by this cursor. */ CINDEX_LINKAGE CXString <API key>(CXCursor); /** * \brief Retrieve a range for a piece that forms the cursors spelling name. * Most of the times there is only one range for the complete spelling but for * objc methods and objc message expressions, there are multiple pieces for each * selector identifier. * * \param pieceIndex the index of the spelling name piece. If this is greater * than the actual number of pieces, it will return a NULL (invalid) range. * * \param options Reserved. */ CINDEX_LINKAGE CXSourceRange <API key>(CXCursor, unsigned pieceIndex, unsigned options); /** * \brief Retrieve the display name for the entity referenced by this cursor. * * The display name contains extra information that helps identify the cursor, * such as the parameters of a function or template or the arguments of a * class template specialization. */ CINDEX_LINKAGE CXString <API key>(CXCursor); /** \brief For a cursor that is a reference, retrieve a cursor representing the * entity that it references. * * Reference cursors refer to other entities in the AST. For example, an * Objective-C superclass reference cursor refers to an Objective-C class. * This function produces the cursor for the Objective-C class from the * cursor for the superclass reference. If the input cursor is a declaration or * definition, it returns that declaration or definition unchanged. * Otherwise, returns the NULL cursor. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor); /** * \brief For a cursor that is either a reference to or a declaration * of some entity, retrieve a cursor that describes the definition of * that entity. * * Some entities can be declared multiple times within a translation * unit, but only one of those declarations can also be a * definition. For example, given: * * \code * int f(int, int); * int g(int x, int y) { return f(x, y); } * int f(int a, int b) { return a + b; } * int f(int, int); * \endcode * * there are three declarations of the function "f", but only the * second one is a definition. The <API key>() * function will take any cursor pointing to a declaration of "f" * (the first or fourth lines of the example) or a cursor referenced * that uses "f" (the call to "f' inside "g") and will return a * declaration cursor pointing to the definition (the second "f" * declaration). * * If given a cursor for which there is no corresponding definition, * e.g., because there is no definition of that entity within this * translation unit, returns a NULL cursor. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor); /** * \brief Determine whether the declaration pointed to by this cursor * is also a definition of that entity. */ CINDEX_LINKAGE unsigned <API key>(CXCursor); /** * \brief Retrieve the canonical cursor corresponding to the given cursor. * * In the C family of languages, many kinds of entities can be declared several * times within a single translation unit. For example, a structure type can * be forward-declared (possibly multiple times) and later defined: * * \code * struct X; * struct X; * struct X { * int member; * }; * \endcode * * The declarations and the definition of \c X are represented by three * different cursors, all of which are declarations of the same underlying * entity. One of these cursor is considered the "canonical" cursor, which * is effectively the representative for the underlying entity. One can * determine if two cursors are declarations of the same underlying entity by * comparing their canonical cursors. * * \returns The canonical cursor for the entity referred to by the given cursor. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor); /** * \brief If the cursor points to a selector identifier in a objc method or * message expression, this returns the selector index. * * After getting a cursor with #clang_getCursor, this can be called to * determine if the location points to a selector identifier. * * \returns The selector index if the cursor is an objc method or message * expression and the cursor is pointing to a selector identifier, or -1 * otherwise. */ CINDEX_LINKAGE int <API key>(CXCursor); /** * \brief Given a cursor pointing to a C++ method call or an ObjC message, * returns non-zero if the method/message is "dynamic", meaning: * * For a C++ method: the call is virtual. * For an ObjC message: the receiver is an object instance, not 'super' or a * specific class. * * If the method/message is "static" or the cursor does not point to a * method/message, it will return zero. */ CINDEX_LINKAGE int <API key>(CXCursor C); /** * \brief Given a cursor pointing to an ObjC message, returns the CXType of the * receiver. */ CINDEX_LINKAGE CXType <API key>(CXCursor C); /** * \brief Property attributes for a \c <API key>. */ typedef enum { <API key> = 0x00, <API key> = 0x01, <API key> = 0x02, <API key> = 0x04, <API key> = 0x08, <API key> = 0x10, <API key> = 0x20, <API key> = 0x40, <API key> = 0x80, <API key> = 0x100, <API key> = 0x200, <API key> = 0x400, <API key> = 0x800 } <API key>; /** * \brief Given a cursor that represents a property declaration, return the * associated property attributes. The bits are formed from * \c <API key>. * * \param reserved Reserved for future use, pass 0. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C, unsigned reserved); /** * \brief 'Qualifiers' written next to the return and parameter types in * ObjC method declarations. */ typedef enum { <API key> = 0x0, <API key> = 0x1, <API key> = 0x2, <API key> = 0x4, <API key> = 0x8, <API key> = 0x10, <API key> = 0x20 } <API key>; /** * \brief Given a cursor that represents an ObjC method or parameter * declaration, return the associated ObjC qualifiers for the return type or the * parameter respectively. The bits are formed from <API key>. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Given a cursor that represents an ObjC method or property declaration, * return non-zero if the declaration was affected by "@optional". * Returns zero if the cursor is not such a declaration or it is "@required". */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Returns non-zero if the given cursor is a variadic function or method. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Given a cursor that represents a declaration, return the associated * comment's source range. The range may include multiple consecutive comments * with whitespace in between. */ CINDEX_LINKAGE CXSourceRange <API key>(CXCursor C); /** * \brief Given a cursor that represents a declaration, return the associated * comment text, including comment markers. */ CINDEX_LINKAGE CXString <API key>(CXCursor C); /** * \brief Given a cursor that represents a documentable entity (e.g., * declaration), return the associated \\brief paragraph; otherwise return the * first paragraph. */ CINDEX_LINKAGE CXString <API key>(CXCursor C); /** * \brief Given a cursor that represents a documentable entity (e.g., * declaration), return the associated parsed comment as a * \c <API key> AST node. */ CINDEX_LINKAGE CXComment <API key>(CXCursor C); /** * \defgroup CINDEX_MODULE Module introspection * * The functions in this group provide access to information about modules. * * @{ */ typedef void *CXModule; /** * \brief Given a <API key> cursor, return the associated module. */ CINDEX_LINKAGE CXModule <API key>(CXCursor C); /** * \param Module a module object. * * \returns the module file where the provided module object came from. */ CINDEX_LINKAGE CXFile <API key>(CXModule Module); /** * \param Module a module object. * * \returns the parent of a sub-module or NULL if the given module is top-level, * e.g. for 'std.vector' it will return the 'std' module. */ CINDEX_LINKAGE CXModule <API key>(CXModule Module); /** * \param Module a module object. * * \returns the name of the module, e.g. for the 'std.vector' sub-module it * will return "vector". */ CINDEX_LINKAGE CXString <API key>(CXModule Module); /** * \param Module a module object. * * \returns the full name of the module, e.g. "std.vector". */ CINDEX_LINKAGE CXString <API key>(CXModule Module); /** * \param Module a module object. * * \returns the number of top level headers associated with this module. */ CINDEX_LINKAGE unsigned <API key>(CXTranslationUnit, CXModule Module); /** * \param Module a module object. * * \param Index top level header index (zero-based). * * \returns the specified top level header associated with the module. */ CINDEX_LINKAGE CXFile <API key>(CXTranslationUnit, CXModule Module, unsigned Index); /** * \defgroup CINDEX_COMMENT Comment AST introspection * * The routines in this group provide access to information in the * documentation comment ASTs. * * @{ */ /** * \brief Describes the type of the comment AST node (\c CXComment). A comment * node can be considered block content (e. g., paragraph), inline content * (plain text) or neither (the root AST node). */ enum CXCommentKind { /** * \brief Null comment. No AST node is constructed at the requested location * because there is no text or a syntax error. */ CXComment_Null = 0, /** * \brief Plain text. Inline content. */ CXComment_Text = 1, /** * \brief A command with word-like arguments that is considered inline content. * * For example: \\c command. */ <API key> = 2, <API key> = 3, /** * \brief HTML end tag. Considered inline content. * * For example: * \verbatim * </a> * \endverbatim */ <API key> = 4, /** * \brief A paragraph, contains inline comment. The paragraph itself is * block content. */ CXComment_Paragraph = 5, /** * \brief A command that has zero or more word-like arguments (number of * word-like arguments depends on command name) and a paragraph as an * argument. Block command is block content. * * Paragraph argument is also a child of the block command. * * For example: \\brief has 0 word-like arguments and a paragraph argument. * * AST nodes of special kinds that parser knows about (e. g., \\param * command) have their own node kinds. */ <API key> = 6, /** * \brief A \\param or \\arg command that describes the function parameter * (name, passing direction, description). * * For example: \\param [in] ParamName description. */ <API key> = 7, /** * \brief A \\tparam command that describes a template parameter (name and * description). * * For example: \\tparam T description. */ <API key> = 8, /** * \brief A verbatim block command (e. g., preformatted code). Verbatim * block has an opening and a closing command and contains multiple lines of * text (\c <API key> child nodes). * * For example: * \\verbatim * aaa * \\endverbatim */ <API key> = 9, /** * \brief A line of text that is contained within a * <API key> node. */ <API key> = 10, /** * \brief A verbatim line command. Verbatim line has an opening command, * a single line of text (up to the newline after the opening command) and * has no closing command. */ <API key> = 11, /** * \brief A full comment attached to a declaration, contains block content. */ <API key> = 12 }; /** * \brief The most appropriate rendering mode for an inline command, chosen on * command semantics in Doxygen. */ enum <API key> { /** * \brief Command argument should be rendered in a normal font. */ <API key>, /** * \brief Command argument should be rendered in a bold font. */ <API key>, /** * \brief Command argument should be rendered in a monospaced font. */ <API key>, /** * \brief Command argument should be rendered emphasized (typically italic * font). */ <API key> }; /** * \brief Describes parameter passing direction for \\param or \\arg command. */ enum <API key> { /** * \brief The parameter is an input parameter. */ <API key>, /** * \brief The parameter is an output parameter. */ <API key>, /** * \brief The parameter is an input and output parameter. */ <API key> }; /** * \param Comment AST node of any kind. * * \returns the type of the AST node. */ CINDEX_LINKAGE enum CXCommentKind <API key>(CXComment Comment); /** * \param Comment AST node of any kind. * * \returns number of children of the AST node. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment AST node of any kind. * * \param ChildIdx child index (zero-based). * * \returns the specified child of the AST node. */ CINDEX_LINKAGE CXComment <API key>(CXComment Comment, unsigned ChildIdx); /** * \brief A \c CXComment_Paragraph node is considered whitespace if it contains * only \c CXComment_Text nodes that are empty or whitespace. * * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are * never considered whitespace. * * \returns non-zero if \c Comment is whitespace. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \returns non-zero if \c Comment is inline content and has a newline * immediately following it in the comment text. Newlines between paragraphs * do not count. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c CXComment_Text AST node. * * \returns text contained in the AST node. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns name of the inline command. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns the most appropriate rendering mode, chosen on command * semantics in Doxygen. */ CINDEX_LINKAGE enum <API key> <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns number of command arguments. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \param ArgIdx argument index (zero-based). * * \returns text of the specified argument. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment, unsigned ArgIdx); /** * \param Comment a \c <API key> or \c <API key> AST * node. * * \returns HTML tag name. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns non-zero if tag is self-closing (for example, &lt;br /&gt;). */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns number of attributes (name-value pairs) attached to the start tag. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \param AttrIdx attribute index (zero-based). * * \returns name of the specified attribute. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment, unsigned AttrIdx); /** * \param Comment a \c <API key> AST node. * * \param AttrIdx attribute index (zero-based). * * \returns value of the specified attribute. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment, unsigned AttrIdx); /** * \param Comment a \c <API key> AST node. * * \returns name of the block command. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns number of word-like arguments. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \param ArgIdx argument index (zero-based). * * \returns text of the specified word-like argument. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment, unsigned ArgIdx); /** * \param Comment a \c <API key> or * \c <API key> AST node. * * \returns paragraph argument of the block command. */ CINDEX_LINKAGE CXComment <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns parameter name. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns non-zero if the parameter that this AST node represents was found * in the function prototype and \c <API key> * function will return a meaningful value. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns zero-based parameter index in function prototype. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns non-zero if parameter passing direction was specified explicitly in * the comment. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns parameter passing direction. */ CINDEX_LINKAGE enum <API key> <API key>( CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns template parameter name. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns non-zero if the parameter that this AST node represents was found * in the template parameter list and * \c <API key> and * \c <API key> functions will return a meaningful * value. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns zero-based nesting depth of this parameter in the template parameter list. * * For example, * \verbatim * template<typename C, template<typename T> class TT> * void test(TT<int> aaa); * \endverbatim * for C and TT nesting depth is 0, * for T nesting depth is 1. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns zero-based parameter index in the template parameter list at a * given nesting depth. * * For example, * \verbatim * template<typename C, template<typename T> class TT> * void test(TT<int> aaa); * \endverbatim * for C and TT nesting depth is 0, so we can ask for index at depth 0: * at depth 0 C's index is 0, TT's index is 1. * * For T nesting depth is 1, so we can ask for index at depth 0 and 1: * at depth 0 T's index is 1 (same as TT's), * at depth 1 T's index is 0. */ CINDEX_LINKAGE unsigned <API key>(CXComment Comment, unsigned Depth); /** * \param Comment a \c <API key> AST node. * * \returns text contained in the AST node. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \param Comment a \c <API key> AST node. * * \returns text contained in the AST node. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \brief Convert an HTML tag AST node to string. * * \param Comment a \c <API key> or \c <API key> AST * node. * * \returns string containing an HTML tag. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \brief Convert a given full parsed comment to an HTML fragment. * * Specific details of HTML layout are subject to change. Don't try to parse * this HTML back into an AST, use other APIs instead. * * Currently the following CSS classes are used: * \li "para-brief" for \\brief paragraph and equivalent commands; * \li "para-returns" for \\returns paragraph and equivalent commands; * \li "word-returns" for the "Returns" word in \\returns paragraph. * * Function argument documentation is rendered as a \<dl\> list with arguments * sorted in function prototype order. CSS classes used: * \li "<API key>" for parameter name (\<dt\>); * \li "<API key>" for parameter description (\<dd\>); * \li "<API key>" and "<API key>" are used if * parameter index is invalid. * * Template parameter documentation is rendered as a \<dl\> list with * parameters sorted in template parameter list order. CSS classes used: * \li "<API key>" for parameter name (\<dt\>); * \li "<API key>" for parameter description (\<dd\>); * \li "<API key>" and "<API key>" are used for * names inside template template parameters; * \li "<API key>" and "<API key>" are used if * parameter position is invalid. * * \param Comment a \c <API key> AST node. * * \returns string containing an HTML fragment. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \brief Convert a given full parsed comment to an XML document. * * A Relax NG schema for the XML can be found in comment-xml-schema.rng file * inside clang source tree. * * \param Comment a \c <API key> AST node. * * \returns string containing an XML document. */ CINDEX_LINKAGE CXString <API key>(CXComment Comment); /** * \defgroup CINDEX_CPP C++ AST introspection * * The routines in this group provide access information in the ASTs specific * to C++ language features. * * @{ */ /** * \brief Determine if a C++ member function or member function template is * pure virtual. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Determine if a C++ member function or member function template is * declared 'static'. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Determine if a C++ member function or member function template is * explicitly declared 'virtual' or if it overrides a virtual method from * one of the base classes. */ CINDEX_LINKAGE unsigned <API key>(CXCursor C); /** * \brief Given a cursor that represents a template, determine * the cursor kind of the specializations would be generated by instantiating * the template. * * This routine can be used to determine what flavor of function template, * class template, or class template partial specialization is stored in the * cursor. For example, it can describe whether a class template cursor is * declared with "struct", "class" or "union". * * \param C The cursor to query. This cursor should represent a template * declaration. * * \returns The cursor kind of the specializations that would be generated * by instantiating the template \p C. If \p C is not a template, returns * \c <API key>. */ CINDEX_LINKAGE enum CXCursorKind <API key>(CXCursor C); /** * \brief Given a cursor that may represent a specialization or instantiation * of a template, retrieve the cursor that represents the template that it * specializes or from which it was instantiated. * * This routine determines the template involved both for explicit * specializations of templates and for implicit instantiations of the template, * both of which are referred to as "specializations". For a class template * specialization (e.g., \c std::vector<bool>), this routine will return * either the primary template (\c std::vector) or, if the specialization was * instantiated from a class template partial specialization, the class template * partial specialization. For a class template partial specialization and a * function template specialization (including instantiations), this * this routine will return the specialized template. * * For members of a class template (e.g., member functions, member classes, or * static data members), returns the specialized or instantiated member. * Although not strictly "templates" in the C++ language, members of class * templates have the same notions of specializations and instantiations that * templates do, so this routine treats them similarly. * * \param C A cursor that may be a specialization of a template or a member * of a template. * * \returns If the given cursor is a specialization or instantiation of a * template or a member thereof, the template or member that it specializes or * from which it was instantiated. Otherwise, returns a NULL cursor. */ CINDEX_LINKAGE CXCursor <API key>(CXCursor C); /** * \brief Given a cursor that references something else, return the source range * covering that reference. * * \param C A cursor pointing to a member reference, a declaration reference, or * an operator call. * \param NameFlags A bitset with three independent flags: * <API key>, <API key>, and * <API key>. * \param PieceIndex For contiguous names or when passing the flag * <API key>, only one piece with index 0 is * available. When the <API key> flag is not passed for a * non-contiguous names, this index can be used to retrieve the individual * pieces of the name. See also <API key>. * * \returns The piece of the name pointed to by the given cursor. If there is no * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. */ CINDEX_LINKAGE CXSourceRange <API key>(CXCursor C, unsigned NameFlags, unsigned PieceIndex); enum CXNameRefFlags { /** * \brief Include the <API key>, e.g. Foo:: in x.Foo::y, in the * range. */ <API key> = 0x1, /** * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>, * in the range. */ <API key> = 0x2, /** * \brief If the name is non-contiguous, return the full spanning range. * * Non-contiguous names occur in Objective-C when a selector with two or more * parameters is used, or in C++ when using an operator: * \code * [object doSomething:here withValue:there]; // ObjC * return some_vector[1]; // C++ * \endcode */ <API key> = 0x4 }; /** * \defgroup CINDEX_LEX Token extraction and manipulation * * The routines in this group provide access to the tokens within a * translation unit, along with a semantic mapping of those tokens to * their corresponding cursors. * * @{ */ /** * \brief Describes a kind of token. */ typedef enum CXTokenKind { /** * \brief A token that contains some kind of punctuation. */ CXToken_Punctuation, /** * \brief A language keyword. */ CXToken_Keyword, /** * \brief An identifier (that is not a keyword). */ CXToken_Identifier, /** * \brief A numeric, string, or character literal. */ CXToken_Literal, /** * \brief A comment. */ CXToken_Comment } CXTokenKind; /** * \brief Describes a single preprocessing token. */ typedef struct { unsigned int_data[4]; void *ptr_data; } CXToken; /** * \brief Determine the kind of the given token. */ CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); /** * \brief Determine the spelling of the given token. * * The spelling of a token is the textual representation of that token, e.g., * the text of an identifier or keyword. */ CINDEX_LINKAGE CXString <API key>(CXTranslationUnit, CXToken); /** * \brief Retrieve the source location of the given token. */ CINDEX_LINKAGE CXSourceLocation <API key>(CXTranslationUnit, CXToken); /** * \brief Retrieve a source range that covers the given token. */ CINDEX_LINKAGE CXSourceRange <API key>(CXTranslationUnit, CXToken); /** * \brief Tokenize the source code described by the given range into raw * lexical tokens. * * \param TU the translation unit whose text is being tokenized. * * \param Range the source range in which text should be tokenized. All of the * tokens produced by tokenization will fall within this source range, * * \param Tokens this pointer will be set to point to the array of tokens * that occur within the given source range. The returned pointer must be * freed with clang_disposeTokens() before the translation unit is destroyed. * * \param NumTokens will be set to the number of tokens in the \c *Tokens * array. * */ CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, CXToken **Tokens, unsigned *NumTokens); /** * \brief Annotate the given set of tokens by providing cursors for each token * that can be mapped to a specific entity within the abstract syntax tree. * * This token-annotation routine is equivalent to invoking * clang_getCursor() for the source locations of each of the * tokens. The cursors provided are filtered, so that only those * cursors that have a direct correspondence to the token are * accepted. For example, given a function call \c f(x), * clang_getCursor() would provide the following cursors: * * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. * * Only the first and last of these cursors will occur within the * annotate, since the tokens "f" and "x' directly refer to a function * and a variable, respectively, but the parentheses are just a small * part of the full syntax of the function call expression, which is * not provided as an annotation. * * \param TU the translation unit that owns the given tokens. * * \param Tokens the set of tokens to annotate. * * \param NumTokens the number of tokens in \p Tokens. * * \param Cursors an array of \p NumTokens cursors, whose contents will be * replaced with the cursors corresponding to each token. */ CINDEX_LINKAGE void <API key>(CXTranslationUnit TU, CXToken *Tokens, unsigned NumTokens, CXCursor *Cursors); /** * \brief Free the given set of tokens. */ CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens, unsigned NumTokens); /** * \defgroup CINDEX_DEBUG Debugging facilities * * These routines are used for testing and debugging, only, and should not * be relied upon. * * @{ */ /* for debug/testing */ CINDEX_LINKAGE CXString <API key>(enum CXCursorKind Kind); CINDEX_LINKAGE void <API key>(CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine, unsigned *startColumn, unsigned *endLine, unsigned *endColumn); CINDEX_LINKAGE void <API key>(void); CINDEX_LINKAGE void <API key>(void (*fn)(void*), void *user_data, unsigned stack_size); /** * \defgroup CINDEX_CODE_COMPLET Code completion * * Code completion involves taking an (incomplete) source file, along with * knowledge of where the user is actively editing that file, and suggesting * syntactically- and semantically-valid constructs that the user might want to * use at that particular point in the source code. These data structures and * routines provide support for code completion. * * @{ */ /** * \brief A semantic string that describes a code-completion result. * * A semantic string that describes the formatting of a code-completion * result as a single "template" of text that should be inserted into the * source buffer when a particular code-completion result is selected. * Each semantic string is made up of some number of "chunks", each of which * contains some text along with a description of what that text means, e.g., * the name of the entity being referenced, whether the text chunk is part of * the template, or whether it is a "placeholder" that the user should replace * with actual code,of a specific kind. See \c <API key> for a * description of the different kinds of chunks. */ typedef void *CXCompletionString; /** * \brief A single result of code completion. */ typedef struct { /** * \brief The kind of entity that this completion refers to. * * The cursor kind will be a macro, keyword, or a declaration (one of the * *Decl cursor kinds), describing the entity that the completion is * referring to. * * \todo In the future, we would like to provide a full cursor, to allow * the client to extract additional information from declaration. */ enum CXCursorKind CursorKind; /** * \brief The code-completion string that describes how to insert this * code-completion result into the editing buffer. */ CXCompletionString CompletionString; } CXCompletionResult; /** * \brief Describes a single piece of text within a code-completion string. * * Each "chunk" within a code-completion string (\c CXCompletionString) is * either a piece of text with a specific "kind" that describes how that text * should be interpreted by the client or is another completion string. */ enum <API key> { /** * \brief A code-completion string that describes "optional" text that * could be a part of the template (but is not required). * * The Optional chunk is the only kind of chunk that has a code-completion * string for its representation, which is accessible via * \c <API key>(). The code-completion string * describes an additional part of the template that is completely optional. * For example, optional chunks can be used to describe the placeholders for * arguments that match up with defaulted function parameters, e.g. given: * * \code * void f(int x, float y = 3.14, double z = 2.71828); * \endcode * * The code-completion string for this function would contain: * - a TypedText chunk for "f". * - a LeftParen chunk for "(". * - a Placeholder chunk for "int x" * - an Optional chunk containing the remaining defaulted arguments, e.g., * - a Comma chunk for "," * - a Placeholder chunk for "float y" * - an Optional chunk containing the last defaulted argument: * - a Comma chunk for "," * - a Placeholder chunk for "double z" * - a RightParen chunk for ")" * * There are many ways to handle Optional chunks. Two simple approaches are: * - Completely ignore optional chunks, in which case the template for the * function "f" would only include the first parameter ("int x"). * - Fully expand all optional chunks, in which case the template for the * function "f" would have all of the parameters. */ <API key>, /** * \brief Text that a user would be expected to type to get this * code-completion result. * * There will be exactly one "typed text" chunk in a semantic string, which * will typically provide the spelling of a keyword or the name of a * declaration that could be used at the current code point. Clients are * expected to filter the code-completion results based on the text in this * chunk. */ <API key>, /** * \brief Text that should be inserted as part of a code-completion result. * * A "text" chunk represents text that is part of the template to be * inserted into user code should this particular code-completion result * be selected. */ <API key>, /** * \brief Placeholder text that should be replaced by the user. * * A "placeholder" chunk marks a place where the user should insert text * into the code-completion template. For example, placeholders might mark * the function parameters for a function declaration, to indicate that the * user should provide arguments for each of those parameters. The actual * text in a placeholder is a suggestion for the text to display before * the user replaces the placeholder with real code. */ <API key>, /** * \brief Informative text that should be displayed but never inserted as * part of the template. * * An "informative" chunk contains annotations that can be displayed to * help the user decide whether a particular code-completion result is the * right option, but which is not part of the actual template to be inserted * by code completion. */ <API key>, /** * \brief Text that describes the current parameter when code-completion is * referring to function call, message send, or template specialization. * * A "current parameter" chunk occurs when code-completion is providing * information about a parameter corresponding to the argument at the * code-completion point. For example, given a function * * \code * int add(int x, int y); * \endcode * * and the source code \c add(, where the code-completion point is after the * "(", the code-completion string will contain a "current parameter" chunk * for "int x", indicating that the current argument will initialize that * parameter. After typing further, to \c add(17, (where the code-completion * point is after the ","), the code-completion string will contain a * "current paremeter" chunk to "int y". */ <API key>, /** * \brief A left parenthesis ('('), used to initiate a function call or * signal the beginning of a function parameter list. */ <API key>, /** * \brief A right parenthesis (')'), used to finish a function call or * signal the end of a function parameter list. */ <API key>, /** * \brief A left bracket ('['). */ <API key>, /** * \brief A right bracket (']'). */ <API key>, /** * \brief A left brace ('{'). */ <API key>, /** * \brief A right brace ('}'). */ <API key>, /** * \brief A left angle bracket ('<'). */ <API key>, /** * \brief A right angle bracket ('>'). */ <API key>, /** * \brief A comma separator (','). */ <API key>, /** * \brief Text that specifies the result type of a given result. * * This special kind of informative chunk is not meant to be inserted into * the text buffer. Rather, it is meant to illustrate the type that an * expression using the given completion string would have. */ <API key>, /** * \brief A colon (':'). */ <API key>, /** * \brief A semicolon (';'). */ <API key>, /** * \brief An '=' sign. */ <API key>, /** * Horizontal space (' '). */ <API key>, /** * Vertical space ('\n'), after which it is generally a good idea to * perform indentation. */ <API key> }; /** * \brief Determine the kind of a particular chunk within a completion string. * * \param completion_string the completion string to query. * * \param chunk_number the 0-based index of the chunk in the completion string. * * \returns the kind of the chunk at the index \c chunk_number. */ CINDEX_LINKAGE enum <API key> <API key>(CXCompletionString completion_string, unsigned chunk_number); /** * \brief Retrieve the text associated with a particular chunk within a * completion string. * * \param completion_string the completion string to query. * * \param chunk_number the 0-based index of the chunk in the completion string. * * \returns the text associated with the chunk at index \c chunk_number. */ CINDEX_LINKAGE CXString <API key>(CXCompletionString completion_string, unsigned chunk_number); /** * \brief Retrieve the completion string associated with a particular chunk * within a completion string. * * \param completion_string the completion string to query. * * \param chunk_number the 0-based index of the chunk in the completion string. * * \returns the completion string associated with the chunk at index * \c chunk_number. */ CINDEX_LINKAGE CXCompletionString <API key>(CXCompletionString completion_string, unsigned chunk_number); /** * \brief Retrieve the number of chunks in the given code-completion string. */ CINDEX_LINKAGE unsigned <API key>(CXCompletionString completion_string); /** * \brief Determine the priority of this code completion. * * The priority of a code completion indicates how likely it is that this * particular completion is the completion that the user will select. The * priority is selected by various internal heuristics. * * \param completion_string The completion string to query. * * \returns The priority of this completion string. Smaller values indicate * higher-priority (more likely) completions. */ CINDEX_LINKAGE unsigned <API key>(CXCompletionString completion_string); /** * \brief Determine the availability of the entity that this code-completion * string refers to. * * \param completion_string The completion string to query. * * \returns The availability of the completion string. */ CINDEX_LINKAGE enum CXAvailabilityKind <API key>(CXCompletionString completion_string); /** * \brief Retrieve the number of annotations associated with the given * completion string. * * \param completion_string the completion string to query. * * \returns the number of annotations associated with the given completion * string. */ CINDEX_LINKAGE unsigned <API key>(CXCompletionString completion_string); /** * \brief Retrieve the annotation associated with the given completion string. * * \param completion_string the completion string to query. * * \param annotation_number the 0-based index of the annotation of the * completion string. * * \returns annotation string associated with the completion at index * \c annotation_number, or a NULL string if that annotation is not available. */ CINDEX_LINKAGE CXString <API key>(CXCompletionString completion_string, unsigned annotation_number); /** * \brief Retrieve the parent context of the given completion string. * * The parent context of a completion string is the semantic parent of * the declaration (if any) that the code completion represents. For example, * a code completion for an Objective-C method would have the method's class * or protocol as its context. * * \param completion_string The code completion string whose parent is * being queried. * * \param kind DEPRECATED: always set to <API key> if non-NULL. * * \returns The name of the completion parent, e.g., "NSObject" if * the completion string represents a method in the NSObject class. */ CINDEX_LINKAGE CXString <API key>(CXCompletionString completion_string, enum CXCursorKind *kind); /** * \brief Retrieve the brief documentation comment attached to the declaration * that corresponds to the given completion string. */ CINDEX_LINKAGE CXString <API key>(CXCompletionString completion_string); /** * \brief Retrieve a completion string for an arbitrary declaration or macro * definition cursor. * * \param cursor The cursor to query. * * \returns A <API key> completion string for declaration and macro * definition cursors, or NULL for other kinds of cursors. */ CINDEX_LINKAGE CXCompletionString <API key>(CXCursor cursor); /** * \brief Contains the results of code-completion. * * This data structure contains the results of code completion, as * produced by \c <API key>(). Its contents must be freed by * \c <API key>. */ typedef struct { /** * \brief The code-completion results. */ CXCompletionResult *Results; /** * \brief The number of code-completion results stored in the * \c Results array. */ unsigned NumResults; } <API key>; /** * \brief Flags that can be passed to \c <API key>() to * modify its behavior. * * The enumerators in this enumeration can be bitwise-OR'd together to * provide multiple options to \c <API key>(). */ enum <API key> { /** * \brief Whether to include macros within the set of code * completions returned. */ <API key> = 0x01, /** * \brief Whether to include code patterns for language constructs * within the set of code completions, e.g., for loops. */ <API key> = 0x02, /** * \brief Whether to include brief documentation within the set of code * completions returned. */ <API key> = 0x04 }; /** * \brief Bits that represent the context under which completion is occurring. * * The enumerators in this enumeration may be bitwise-OR'd together if multiple * contexts are occurring simultaneously. */ enum CXCompletionContext { /** * \brief The context for completions is unexposed, as only Clang results * should be included. (This is equivalent to having no context bits set.) */ <API key> = 0, /** * \brief Completions for any possible type should be included in the results. */ <API key> = 1 << 0, /** * \brief Completions for any possible value (variables, function calls, etc.) * should be included in the results. */ <API key> = 1 << 1, /** * \brief Completions for values that resolve to an Objective-C object should * be included in the results. */ <API key> = 1 << 2, /** * \brief Completions for values that resolve to an Objective-C selector * should be included in the results. */ <API key> = 1 << 3, /** * \brief Completions for values that resolve to a C++ class type should be * included in the results. */ <API key> = 1 << 4, /** * \brief Completions for fields of the member being accessed using the dot * operator should be included in the results. */ <API key> = 1 << 5, /** * \brief Completions for fields of the member being accessed using the arrow * operator should be included in the results. */ <API key> = 1 << 6, /** * \brief Completions for properties of the Objective-C object being accessed * using the dot operator should be included in the results. */ <API key> = 1 << 7, /** * \brief Completions for enum tags should be included in the results. */ <API key> = 1 << 8, /** * \brief Completions for union tags should be included in the results. */ <API key> = 1 << 9, /** * \brief Completions for struct tags should be included in the results. */ <API key> = 1 << 10, /** * \brief Completions for C++ class names should be included in the results. */ <API key> = 1 << 11, /** * \brief Completions for C++ namespaces and namespace aliases should be * included in the results. */ <API key> = 1 << 12, /** * \brief Completions for C++ nested name specifiers should be included in * the results. */ <API key> = 1 << 13, /** * \brief Completions for Objective-C interfaces (classes) should be included * in the results. */ <API key> = 1 << 14, /** * \brief Completions for Objective-C protocols should be included in * the results. */ <API key> = 1 << 15, /** * \brief Completions for Objective-C categories should be included in * the results. */ <API key> = 1 << 16, /** * \brief Completions for Objective-C instance messages should be included * in the results. */ <API key> = 1 << 17, /** * \brief Completions for Objective-C class messages should be included in * the results. */ <API key> = 1 << 18, /** * \brief Completions for Objective-C selector names should be included in * the results. */ <API key> = 1 << 19, /** * \brief Completions for preprocessor macro names should be included in * the results. */ <API key> = 1 << 20, /** * \brief Natural language completions should be included in the results. */ <API key> = 1 << 21, /** * \brief The current context is unknown, so set all contexts. */ <API key> = ((1 << 22) - 1) }; /** * \brief Returns a default set of code-completion options that can be * passed to\c <API key>(). */ CINDEX_LINKAGE unsigned <API key>(void); /** * \brief Perform code completion at a given location in a translation unit. * * This function performs code completion at a particular file, line, and * column within source code, providing results that suggest potential * code snippets based on the context of the completion. The basic model * for code completion is that Clang will parse a complete source file, * performing syntax checking up to the location where code-completion has * been requested. At that point, a special code-completion token is passed * to the parser, which recognizes this token and determines, based on the * current location in the C/Objective-C/C++ grammar and the state of * semantic analysis, what completions to provide. These completions are * returned via a new \c <API key> structure. * * Code completion itself is meant to be triggered by the client when the * user types punctuation characters or whitespace, at which point the * code-completion location will coincide with the cursor. For example, if \c p * is a pointer, code-completion might be triggered after the "-" and then * after the ">" in \c p->. When the code-completion location is afer the ">", * the completion results will provide, e.g., the members of the struct that * "p" points to. The client is responsible for placing the cursor at the * beginning of the token currently being typed, then filtering the results * based on the contents of the token. For example, when code-completing for * the expression \c p->get, the client should provide the location just after * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the * client can filter the results based on the current token text ("get"), only * showing those results that start with "get". The intent of this interface * is to separate the relatively high-latency acquisition of code-completion * results from the filtering of results on a per-character basis, which must * have a lower latency. * * \param TU The translation unit in which code-completion should * occur. The source files for this translation unit need not be * completely up-to-date (and the contents of those source files may * be overridden via \p unsaved_files). Cursors referring into the * translation unit may be invalidated by this invocation. * * \param complete_filename The name of the source file where code * completion should be performed. This filename may be any file * included in the translation unit. * * \param complete_line The line at which code-completion should occur. * * \param complete_column The column at which code-completion should occur. * Note that the column should point just after the syntactic construct that * initiated code completion, and not in the middle of a lexical token. * * \param unsaved_files the Tiles that have not yet been saved to disk * but may be required for parsing or code completion, including the * contents of those files. The contents and name of these files (as * specified by CXUnsavedFile) are copied when necessary, so the * client only needs to guarantee their validity until the call to * this function returns. * * \param num_unsaved_files The number of unsaved file entries in \p * unsaved_files. * * \param options Extra options that control the behavior of code * completion, expressed as a bitwise OR of the enumerators of the * <API key> enumeration. The * \c <API key>() function returns a default set * of code-completion options. * * \returns If successful, a new \c <API key> structure * containing code-completion results, which should eventually be * freed with \c <API key>(). If code * completion fails, returns NULL. */ CINDEX_LINKAGE <API key> *<API key>(CXTranslationUnit TU, const char *complete_filename, unsigned complete_line, unsigned complete_column, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, unsigned options); /** * \brief Sort the code-completion results in case-insensitive alphabetical * order. * * \param Results The set of results to sort. * \param NumResults The number of results in \p Results. */ CINDEX_LINKAGE void <API key>(CXCompletionResult *Results, unsigned NumResults); /** * \brief Free the given set of code-completion results. */ CINDEX_LINKAGE void <API key>(<API key> *Results); /** * \brief Determine the number of diagnostics produced prior to the * location where code completion was performed. */ CINDEX_LINKAGE unsigned <API key>(<API key> *Results); /** * \brief Retrieve a diagnostic associated with the given code completion. * * \param Results the code completion results to query. * \param Index the zero-based diagnostic number to retrieve. * * \returns the requested diagnostic. This diagnostic must be freed * via a call to \c <API key>(). */ CINDEX_LINKAGE CXDiagnostic <API key>(<API key> *Results, unsigned Index); /** * \brief Determines what compeltions are appropriate for the context * the given code completion. * * \param Results the code completion results to query * * \returns the kinds of completions that are appropriate for use * along with the given code completion results. */ CINDEX_LINKAGE unsigned long long <API key>( <API key> *Results); /** * \brief Returns the cursor kind for the container for the current code * completion context. The container is only guaranteed to be set for * contexts where a container exists (i.e. member accesses or Objective-C * message sends); if there is not a container, this function will return * <API key>. * * \param Results the code completion results to query * * \param IsIncomplete on return, this value will be false if Clang has complete * information about the container. If Clang does not have complete * information, this value will be true. * * \returns the container kind, or <API key> if there is not a * container */ CINDEX_LINKAGE enum CXCursorKind <API key>( <API key> *Results, unsigned *IsIncomplete); /** * \brief Returns the USR for the container for the current code completion * context. If there is not a container for the current context, this * function will return the empty string. * * \param Results the code completion results to query * * \returns the USR for the container */ CINDEX_LINKAGE CXString <API key>(<API key> *Results); /** * \brief Returns the currently-entered selector for an Objective-C message * send, formatted like "initWithFoo:bar:". Only guaranteed to return a * non-empty string for <API key> and * <API key>. * * \param Results the code completion results to query * * \returns the selector (or partial selector) that has been entered thus far * for an Objective-C message send. */ CINDEX_LINKAGE CXString <API key>(<API key> *Results); /** * \defgroup CINDEX_MISC Miscellaneous utility functions * * @{ */ /** * \brief Return a version string, suitable for showing to a user, but not * intended to be parsed (the format is not guaranteed to be stable). */ CINDEX_LINKAGE CXString <API key>(void); /** * \brief Enable/disable crash recovery. * * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero * value enables crash recovery, while 0 disables it. */ CINDEX_LINKAGE void <API key>(unsigned isEnabled); /** * \brief Visitor invoked for each file in a translation unit * (used with clang_getInclusions()). * * This visitor function will be invoked by clang_getInclusions() for each * file included (either at the top-level or by \#include directives) within * a translation unit. The first argument is the file being included, and * the second and third arguments provide the inclusion stack. The * array is sorted in order of immediate inclusion. For example, * the first element refers to the location that included 'included_file'. */ typedef void (*CXInclusionVisitor)(CXFile included_file, CXSourceLocation* inclusion_stack, unsigned include_len, CXClientData client_data); /** * \brief Visit the set of preprocessor inclusions in a translation unit. * The visitor function is called with the provided data for every included * file. This does not include headers included by the PCH file (unless one * is inspecting the inclusions in the PCH file itself). */ CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, CXInclusionVisitor visitor, CXClientData client_data); /** \defgroup CINDEX_REMAPPING Remapping functions * * @{ */ /** * \brief A remapping of original source files and their translated files. */ typedef void *CXRemapping; /** * \brief Retrieve a remapping. * * \param path the path that contains metadata about remappings. * * \returns the requested remapping. This remapping must be freed * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. */ CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); /** * \brief Retrieve a remapping. * * \param filePaths pointer to an array of file paths containing remapping info. * * \param numFiles number of file paths. * * \returns the requested remapping. This remapping must be freed * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. */ CINDEX_LINKAGE CXRemapping <API key>(const char **filePaths, unsigned numFiles); /** * \brief Determine the number of remappings. */ CINDEX_LINKAGE unsigned <API key>(CXRemapping); /** * \brief Get the original and the associated filename from the remapping. * * \param original If non-NULL, will be set to the original filename. * * \param transformed If non-NULL, will be set to the filename that the original * is associated with. */ CINDEX_LINKAGE void <API key>(CXRemapping, unsigned index, CXString *original, CXString *transformed); /** * \brief Dispose the remapping. */ CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); /** \defgroup CINDEX_HIGH Higher level API functions * * @{ */ enum CXVisitorResult { CXVisit_Break, CXVisit_Continue }; typedef struct { void *context; enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); } <API key>; typedef enum { /** * \brief Function returned successfully. */ CXResult_Success = 0, /** * \brief One of the parameters was invalid for the function. */ CXResult_Invalid = 1, /** * \brief The function was terminated by a callback (e.g. it returned * CXVisit_Break) */ CXResult_VisitBreak = 2 } CXResult; /** * \brief Find references of a declaration in a specific file. * * \param cursor pointing to a declaration or a reference of one. * * \param file to search for references. * * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for * each reference found. * The CXSourceRange will point inside the file; if the reference is inside * a macro (and not a macro argument) the CXSourceRange will be invalid. * * \returns one of the CXResult enumerators. */ CINDEX_LINKAGE CXResult <API key>(CXCursor cursor, CXFile file, <API key> visitor); /** * \brief Find #import/#include directives in a specific file. * * \param TU translation unit containing the file to query. * * \param file to search for #import/#include directives. * * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for * each directive found. * * \returns one of the CXResult enumerators. */ CINDEX_LINKAGE CXResult <API key>(CXTranslationUnit TU, CXFile file, <API key> visitor); #ifdef __has_feature # if __has_feature(blocks) typedef enum CXVisitorResult (^<API key>)(CXCursor, CXSourceRange); CINDEX_LINKAGE CXResult <API key>(CXCursor, CXFile, <API key>); CINDEX_LINKAGE CXResult <API key>(CXTranslationUnit, CXFile, <API key>); # endif #endif /** * \brief The client's data object that is associated with a CXFile. */ typedef void *CXIdxClientFile; /** * \brief The client's data object that is associated with a semantic entity. */ typedef void *CXIdxClientEntity; /** * \brief The client's data object that is associated with a semantic container * of entities. */ typedef void *<API key>; /** * \brief The client's data object that is associated with an AST file (PCH * or module). */ typedef void *CXIdxClientASTFile; /** * \brief Source location passed to index callbacks. */ typedef struct { void *ptr_data[2]; unsigned int_data; } CXIdxLoc; /** * \brief Data for ppIncludedFile callback. */ typedef struct { /** * \brief Location of '#' in the \#include/\#import directive. */ CXIdxLoc hashLoc; /** * \brief Filename as written in the \#include/\#import directive. */ const char *filename; /** * \brief The actual file that the \#include/\#import directive resolved to. */ CXFile file; int isImport; int isAngled; /** * \brief Non-zero if the directive was automatically turned into a module * import. */ int isModuleImport; } <API key>; /** * \brief Data for IndexerCallbacks#importedASTFile. */ typedef struct { /** * \brief Top level AST file containing the imported PCH, module or submodule. */ CXFile file; /** * \brief The imported module or NULL if the AST file is a PCH. */ CXModule module; /** * \brief Location where the file is imported. Applicable only for modules. */ CXIdxLoc loc; /** * \brief Non-zero if an inclusion directive was automatically turned into * a module import. Applicable only for modules. */ int isImplicit; } <API key>; typedef enum { <API key> = 0, CXIdxEntity_Typedef = 1, <API key> = 2, <API key> = 3, CXIdxEntity_Field = 4, <API key> = 5, <API key> = 6, <API key> = 7, <API key> = 8, <API key> = 9, <API key> = 10, <API key> = 11, <API key> = 12, CXIdxEntity_Enum = 13, CXIdxEntity_Struct = 14, CXIdxEntity_Union = 15, <API key> = 16, <API key> = 17, <API key> = 18, <API key> = 19, <API key> = 20, <API key> = 21, <API key> = 22, <API key> = 23, <API key> = 24, <API key> = 25, <API key> = 26 } CXIdxEntityKind; typedef enum { <API key> = 0, CXIdxEntityLang_C = 1, <API key> = 2, CXIdxEntityLang_CXX = 3 } CXIdxEntityLanguage; /** * \brief Extra C++ template information for an entity. This can apply to: * <API key> * <API key> * <API key> * <API key> * <API key> * <API key> * <API key> */ typedef enum { <API key> = 0, <API key> = 1, <API key> = 2, <API key> = 3 } <API key>; typedef enum { CXIdxAttr_Unexposed = 0, CXIdxAttr_IBAction = 1, CXIdxAttr_IBOutlet = 2, <API key> = 3 } CXIdxAttrKind; typedef struct { CXIdxAttrKind kind; CXCursor cursor; CXIdxLoc loc; } CXIdxAttrInfo; typedef struct { CXIdxEntityKind kind; <API key> templateKind; CXIdxEntityLanguage lang; const char *name; const char *USR; CXCursor cursor; const CXIdxAttrInfo *const *attributes; unsigned numAttributes; } CXIdxEntityInfo; typedef struct { CXCursor cursor; } CXIdxContainerInfo; typedef struct { const CXIdxAttrInfo *attrInfo; const CXIdxEntityInfo *objcClass; CXCursor classCursor; CXIdxLoc classLoc; } <API key>; typedef enum { <API key> = 0x1 } CXIdxDeclInfoFlags; typedef struct { const CXIdxEntityInfo *entityInfo; CXCursor cursor; CXIdxLoc loc; const CXIdxContainerInfo *semanticContainer; /** * \brief Generally same as #semanticContainer but can be different in * cases like out-of-line C++ member functions. */ const CXIdxContainerInfo *lexicalContainer; int isRedeclaration; int isDefinition; int isContainer; const CXIdxContainerInfo *declAsContainer; /** * \brief Whether the declaration exists in code or was created implicitly * by the compiler, e.g. implicit objc methods for properties. */ int isImplicit; const CXIdxAttrInfo *const *attributes; unsigned numAttributes; unsigned flags; } CXIdxDeclInfo; typedef enum { <API key> = 0, <API key> = 1, <API key> = 2 } <API key>; typedef struct { const CXIdxDeclInfo *declInfo; <API key> kind; } <API key>; typedef struct { const CXIdxEntityInfo *base; CXCursor cursor; CXIdxLoc loc; } CXIdxBaseClassInfo; typedef struct { const CXIdxEntityInfo *protocol; CXCursor cursor; CXIdxLoc loc; } <API key>; typedef struct { const <API key> *const *protocols; unsigned numProtocols; } <API key>; typedef struct { const <API key> *containerInfo; const CXIdxBaseClassInfo *superInfo; const <API key> *protocols; } <API key>; typedef struct { const <API key> *containerInfo; const CXIdxEntityInfo *objcClass; CXCursor classCursor; CXIdxLoc classLoc; const <API key> *protocols; } <API key>; typedef struct { const CXIdxDeclInfo *declInfo; const CXIdxEntityInfo *getter; const CXIdxEntityInfo *setter; } <API key>; typedef struct { const CXIdxDeclInfo *declInfo; const CXIdxBaseClassInfo *const *bases; unsigned numBases; } <API key>; /** * \brief Data for IndexerCallbacks#<API key>. */ typedef enum { /** * \brief The entity is referenced directly in user's code. */ <API key> = 1, /** * \brief An implicit reference, e.g. a reference of an ObjC method via the * dot syntax. */ <API key> = 2 } CXIdxEntityRefKind; /** * \brief Data for IndexerCallbacks#<API key>. */ typedef struct { CXIdxEntityRefKind kind; /** * \brief Reference cursor. */ CXCursor cursor; CXIdxLoc loc; /** * \brief The entity that gets referenced. */ const CXIdxEntityInfo *referencedEntity; /** * \brief Immediate "parent" of the reference. For example: * * \code * Foo *var; * \endcode * * The parent of reference of type 'Foo' is the variable 'var'. * For references inside statement bodies of functions/methods, * the parentEntity will be the function/method. */ const CXIdxEntityInfo *parentEntity; /** * \brief Lexical container context of the reference. */ const CXIdxContainerInfo *container; } CXIdxEntityRefInfo; /** * \brief A group of callbacks used by #<API key> and * #<API key>. */ typedef struct { /** * \brief Called periodically to check whether indexing should be aborted. * Should return 0 to continue, and non-zero to abort. */ int (*abortQuery)(CXClientData client_data, void *reserved); /** * \brief Called at the end of indexing; passes the complete diagnostic set. */ void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved); CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile, void *reserved); /** * \brief Called when a file gets \#included/\#imported. */ CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, const <API key> *); /** * \brief Called when a AST file (PCH or module) gets imported. * * AST files will not get indexed (there will not be callbacks to index all * the entities in an AST file). The recommended action is that, if the AST * file is not already indexed, to initiate a new indexing job specific to * the AST file. */ CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, const <API key> *); /** * \brief Called at the beginning of indexing a translation unit. */ <API key> (*<API key>)(CXClientData client_data, void *reserved); void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *); /** * \brief Called to index a reference of an entity. */ void (*<API key>)(CXClientData client_data, const CXIdxEntityRefInfo *); } IndexerCallbacks; CINDEX_LINKAGE int <API key>(CXIdxEntityKind); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxAttrInfo *); CINDEX_LINKAGE const <API key> * <API key>(const CXIdxDeclInfo *); /** * \brief For retrieving a custom <API key> attached to a * container. */ CINDEX_LINKAGE <API key> <API key>(const CXIdxContainerInfo *); /** * \brief For setting a custom <API key> attached to a * container. */ CINDEX_LINKAGE void <API key>(const CXIdxContainerInfo *,<API key>); /** * \brief For retrieving a custom CXIdxClientEntity attached to an entity. */ CINDEX_LINKAGE CXIdxClientEntity <API key>(const CXIdxEntityInfo *); /** * \brief For setting a custom CXIdxClientEntity attached to an entity. */ CINDEX_LINKAGE void <API key>(const CXIdxEntityInfo *, CXIdxClientEntity); /** * \brief An indexing action/session, to be applied to one or multiple * translation units. */ typedef void *CXIndexAction; /** * \brief An indexing action/session, to be applied to one or multiple * translation units. * * \param CIdx The index object with which the index action will be associated. */ CINDEX_LINKAGE CXIndexAction <API key>(CXIndex CIdx); /** * \brief Destroy the given index action. * * The index action must not be destroyed until all of the translation units * created within that index action have been destroyed. */ CINDEX_LINKAGE void <API key>(CXIndexAction); typedef enum { /** * \brief Used to indicate that no special indexing options are needed. */ CXIndexOpt_None = 0x0, /** * \brief Used to indicate that IndexerCallbacks#<API key> should * be invoked for only one reference of an entity per source file that does * not also include a declaration/definition of the entity. */ <API key> = 0x1, /** * \brief Function-local symbols should be indexed. If this is not set * function-local symbols will be ignored. */ <API key> = 0x2, /** * \brief Implicit function/class template instantiations should be indexed. * If this is not set, implicit instantiations will be ignored. */ <API key> = 0x4, /** * \brief Suppress all compiler warnings when parsing for indexing. */ <API key> = 0x8, /** * \brief Skip a function/method body that was already parsed during an * indexing session assosiated with a \c CXIndexAction object. * Bodies in system headers are always skipped. */ <API key> = 0x10 } CXIndexOptFlags; /** * \brief Index the given source file and the translation unit corresponding * to that file via callbacks implemented through #IndexerCallbacks. * * \param client_data pointer data supplied by the client, which will * be passed to the invoked callbacks. * * \param index_callbacks Pointer to indexing callbacks that the client * implements. * * \param <API key> Size of #IndexerCallbacks structure that gets * passed in index_callbacks. * * \param index_options A bitmask of options that affects how indexing is * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. * * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused * after indexing is finished. Set to NULL if you do not require it. * * \returns If there is a failure from which the there is no recovery, returns * non-zero, otherwise returns 0. * * The rest of the parameters are the same as #<API key>. */ CINDEX_LINKAGE int <API key>(CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, unsigned <API key>, unsigned index_options, const char *source_filename, const char * const *command_line_args, int <API key>, struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); /** * \brief Index the given translation unit via callbacks implemented through * #IndexerCallbacks. * * The order of callback invocations is not guaranteed to be the same as * when indexing a source file. The high level order will be: * * -Preprocessor callbacks invocations * -Declaration/reference callbacks invocations * -Diagnostic callback invocations * * The parameters are the same as #<API key>. * * \returns If there is a failure from which the there is no recovery, returns * non-zero, otherwise returns 0. */ CINDEX_LINKAGE int <API key>(CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, unsigned <API key>, unsigned index_options, CXTranslationUnit); /** * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by * the given CXIdxLoc. * * If the location refers into a macro expansion, retrieves the * location of the macro expansion and if it refers into a macro argument * retrieves the location of the argument. */ CINDEX_LINKAGE void <API key>(CXIdxLoc loc, CXIdxClientFile *indexFile, CXFile *file, unsigned *line, unsigned *column, unsigned *offset); /** * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc. */ CINDEX_LINKAGE CXSourceLocation <API key>(CXIdxLoc loc); #ifdef __cplusplus } #endif #endif
#ifndef CLIF_H #define CLIF_H #include <sys/types.h> #include "clif_internal.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Return types for the @ref sys_clif API */ enum { CLIF_OK = 0, /**< success */ CLIF_NO_SPACE = -1, /**< not enough space in the buffer */ CLIF_NOT_FOUND = -2 /**< could not find a component in a buffer */ }; /** * @brief Types of link format attributes */ typedef enum { CLIF_ATTR_ANCHOR = 0, /**< anchor */ CLIF_ATTR_REL = 1, /**< rel */ CLIF_ATTR_LANG = 2, /**< hreflang */ CLIF_ATTR_MEDIA = 3, /**< media */ CLIF_ATTR_TITLE = 4, /**< title */ CLIF_ATTR_TITLE_EXT = 5, /**< title* */ CLIF_ATTR_TYPE = 6, /**< type */ CLIF_ATTR_RT = 7, CLIF_ATTR_IF = 8, CLIF_ATTR_SZ = 9, CLIF_ATTR_CT = 10, CLIF_ATTR_OBS = 11, /**< obs */ CLIF_ATTR_EXT = 12 /**< extensions */ } clif_attr_type_t; /** * @brief Link format attribute descriptor */ typedef struct { char *value; /**< string with the value */ unsigned value_len; /**< length of the value */ const char *key; /**< attribute name */ unsigned key_len; /**< length of the attribute name */ } clif_attr_t; /** * @brief Link format descriptor */ typedef struct { char *target; /**< target string */ unsigned target_len; /**< length of target string */ clif_attr_t *attrs; /**< array of attributes */ unsigned attrs_len; /**< size of array of attributes */ } clif_t; /** * @brief Encodes a given link in link format into a given buffer * * @pre `link != NULL` * * @param[in] link link to encode.Must not be NULL. * @param[out] buf buffer to output the encoded link. Can be NULL * @param[in] maxlen size of @p buf * * @note If @p buf is NULL this will return the amount of bytes that would be * needed * * @return amount of bytes used from @p buf in success * @return CLIF_NO_SPACE if there is not enough space in the buffer */ ssize_t clif_encode_link(const clif_t *link, char *buf, size_t maxlen); /** * @brief Decodes a string of link format. It decodes the first occurrence of * a link. * * @pre `(link != NULL) && (buf != NULL)` * * @param[out] link link to populate. Must not be NULL. * @param[out] attrs array of attrs to populate * @param[in] attrs_len length of @p attrs * @param[in] buf string to decode. Must not be NULL. * @param[in] maxlen size of @p buf * * @return number of bytes parsed from @p buf in success * @return CLIF_NOT_FOUND if the string is malformed */ ssize_t clif_decode_link(clif_t *link, clif_attr_t *attrs, unsigned attrs_len, const char *buf, size_t maxlen); /** * @brief Adds a given @p target to a given buffer @p buf using link format * * @pre `target != NULL` * * @param[in] target string containing the path to the resource. Must not be * NULL. * @param[out] buf buffer to output the formatted path. Can be NULL * @param[in] maxlen size of @p buf * * @note If @p buf is NULL this will return the amount of bytes that would be * needed * * @return in success the amount of bytes used in the buffer * @return CLIF_NO_SPACE if there is not enough space in the buffer */ ssize_t clif_add_target(const char *target, char *buf, size_t maxlen); /** * @brief Adds a given @p attr to a given buffer @p buf using link format * * @pre `(attr != NULL) && (attr->key != NULL)` * * @param[in] attr pointer to the attribute to add. Must not be NULL, and * must contain a key. * @param[out] buf buffer to add the attribute to. Can be NULL * @param[in] maxlen size of @p buf * * @note * - If @p buf is NULL this will return the amount of bytes that would be * needed. * - If the lengths of the key or the value of the attribute are not * defined a NULL-terminated string will be assumed, and it will be * calculated. * * @return amount of bytes used from the buffer if successful * @return CLIF_NO_SPACE if there is not enough space in the buffer */ ssize_t clif_add_attr(clif_attr_t *attr, char *buf, size_t maxlen); /** * @brief Adds the link separator character to a given @p buf, using link * format * * @param[out] buf buffer to add the separator to. Can be NULL * @param[in] maxlen size of @p buf * * @note If @p buf is NULL this will return the amount of bytes that would be * needed * * @return amount of bytes used from buffer if successful * @return CLIF_NO_SPACE if there is not enough space in the buffer */ ssize_t <API key>(char *buf, size_t maxlen); /** * @brief Looks for a the target URI of a given link. * * @pre `input != NULL` * * @param[in] input string where to look for the target. It should only * be ONE link. Must not be NULL. * @param[in] input_len length of @p input. * @param[out] output if a target is found this will point to the * beginning of it * * @return length of the target if found * @return CLIF_NOT_FOUND if no valid target is found */ ssize_t clif_get_target(const char *input, size_t input_len, char **output); /** * @brief Looks for the first attribute in a given link. * * @pre `(input != NULL) && (attr != NULL)` * * @note In order to consider that the string contains a valid attribute, * @p input should start with the attribute separator character ';'. * * @param[in] input string where to look for the attribute. It should * only be ONE link. Must not be NULL. * @param[in] input_len length of @p input * @param[out] attr pointer to store the found attribute information. * Must not be NULL. * * @return length of the attribute in the buffer if found * @return CLIF_NOT_FOUND if no valid attribute is found */ ssize_t clif_get_attr(const char *input, size_t input_len, clif_attr_t *attr); /** * @brief Returns the attribute type of a given string. * * @pre `(input != NULL) && (input_len > 0)` * * @param[in] input string containing the attribute name. Must not be NULL. * @param[in] input_len length of @p input. Must be greater than 0. * * @return type of the attribute */ clif_attr_type_t clif_get_attr_type(const char *input, size_t input_len); /** * @brief Returns a constant string of a given attribute type * * @param[in] type type of the attribute * @param[out] str pointer to store the string pointer * * @return length of the string * @return CLIF_NOT_FOUND if the type is an extension or unknown */ ssize_t <API key>(clif_attr_type_t type, const char **str); /** * @brief Initializes the key of a given attribute according to a given type. * * @param[out] attr attribute to initialize * @param[in] type type of the attribute * * @return 0 if successful * @return <0 otherwise */ int clif_init_attr(clif_attr_t *attr, clif_attr_type_t type); #ifdef __cplusplus } #endif #endif /* CLIF_H */
/** * @ingroup cpu_saml21 * @{ * * @file lpm_arch.c * @brief Implementation of the kernels power management interface * * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> * * @} */ #include "arch/lpm_arch.h" void lpm_arch_init(void) { // TODO } enum lpm_mode lpm_arch_set(enum lpm_mode target) { // TODO return 0; } enum lpm_mode lpm_arch_get(void) { // TODO return 0; } void lpm_arch_awake(void) { // TODO } void <API key>(void) { // TODO } void lpm_arch_end_awake(void) { // TODO }
{%extends "issue_base.html"%} {%block title1%}Publish+Mail -{%endblock%} {%block head%}{{form.media}}{%endblock%} {%block issue_body%} <script><! function discard(btn) { draftMessage.discard(); btn.disabled = "disabled"; document.getElementById("id_message").value = ""; return false; } draftMessage = new M_draftMessage({{issue.key.id}}, true); </script> <h2>Publish + Mail Draft Comments</h2> <div> <form action="{%url codereview.views.publish issue.key.id%}" method="post" id="publish-form"> <input type="hidden" name="xsrf_token" value="{{xsrf_token}}"> <table class="formtable"> {%ifnotequal user issue.owner%} <tr><th>Subject:</th><td>{{issue.subject}}</td></tr> {%endifnotequal%} {{form}} <tr> <td></td> <td><i>The message will be included in the email sent (if any).</i></td> </tr> <tr> <td></td> <td> <input type="submit" value="Publish all my drafts" /> {%if draft_message%} <input type="button" onclick="return discard(this);" value="Discard Message" /> {%endif%} </td> </tr> </table> </form> <a id="resizer" style="display:none;cursor:pointer"> <img src="{{media_url}}zippyplus.gif"></a> <script language="JavaScript" type="text/javascript"><! M_addTextResizer_(document.getElementById("publish-form")); document.getElementById("id_message").focus(); --></script> </div> {%if preview%} <div style="margin-top: 3em;"> <h3>Unpublished Drafts:</h3> <pre class="description">{{preview|wordwrap:"80"|urlizetrunc:80}}</pre> </div> <form method="post" action="{% url codereview.views.delete_drafts issue.key.id %}" onsubmit="return confirm('Are you sure? All your drafts for this issue will be deleted.');"> <input type="hidden" name="xsrf_token" value="{{xsrf_token}}"> <button type="submit">Delete all my drafts</button> There's no undo! </form> {%endif%} <div style="clear:both"></div> {%endblock%}
package net.officefloor.benchmark; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository public interface WorldRepository extends CrudRepository<World, Integer> { }
// $ANTLR 2.7.5RC1 (20041124-137): "code.g" -> "CodeLexer.java"$ package antlr.actions.python; public interface CodeLexerTokenTypes { int EOF = 1; int NULL_TREE_LOOKAHEAD = 3; int ACTION = 4; int STUFF = 5; int COMMENT = 6; int SL_COMMENT = 7; int IGNWS = 8; int ML_COMMENT = 9; }
#include "llvm-c/Core.h" #include "llvm-c/Target.h" #include "llvm-c/TargetMachine.h" #include "caml/alloc.h" #include "caml/fail.h" #include "caml/memory.h" #include "caml/custom.h" #include "caml/callback.h" void llvm_raise(value Prototype, char *Message); value <API key>(char* Message); #define DataLayout_val(v) (*(LLVMTargetDataRef *)(Data_custom_val(v))) static void <API key>(value DataLayout) { <API key>(DataLayout_val(DataLayout)); } static struct custom_operations <API key> = { (char *) "Llvm_target.DataLayout.t", <API key>, <API key>, custom_hash_default, <API key>, <API key>, <API key> }; value <API key>(LLVMTargetDataRef DataLayout) { value V = alloc_custom(&<API key>, sizeof(LLVMTargetDataRef), 0, 1); DataLayout_val(V) = DataLayout; return V; } /* string -> DataLayout.t */ CAMLprim value <API key>(value StringRep) { return <API key>(<API key>(String_val(StringRep))); } /* DataLayout.t -> string */ CAMLprim value <API key>(value TD) { char *StringRep = <API key>(DataLayout_val(TD)); value Copy = copy_string(StringRep); LLVMDisposeMessage(StringRep); return Copy; } /* DataLayout.t -> Endian.t */ CAMLprim value <API key>(value DL) { return Val_int(LLVMByteOrder(DataLayout_val(DL))); } /* DataLayout.t -> int */ CAMLprim value <API key>(value DL) { return Val_int(LLVMPointerSize(DataLayout_val(DL))); } /* Llvm.llcontext -> DataLayout.t -> Llvm.lltype */ CAMLprim LLVMTypeRef <API key>(LLVMContextRef C, value DL) { return <API key>(C, DataLayout_val(DL)); } /* int -> DataLayout.t -> int */ CAMLprim value <API key>(value AS, value DL) { return Val_int(<API key>(DataLayout_val(DL), Int_val(AS))); } /* Llvm.llcontext -> int -> DataLayout.t -> Llvm.lltype */ CAMLprim LLVMTypeRef <API key>(LLVMContextRef C, value AS, value DL) { return <API key>(C, DataLayout_val(DL), Int_val(AS)); } /* Llvm.lltype -> DataLayout.t -> Int64.t */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return caml_copy_int64(<API key>(DataLayout_val(DL), Ty)); } /* Llvm.lltype -> DataLayout.t -> Int64.t */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return caml_copy_int64(LLVMStoreSizeOfType(DataLayout_val(DL), Ty)); } /* Llvm.lltype -> DataLayout.t -> Int64.t */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return caml_copy_int64(LLVMABISizeOfType(DataLayout_val(DL), Ty)); } /* Llvm.lltype -> DataLayout.t -> int */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return Val_int(<API key>(DataLayout_val(DL), Ty)); } /* Llvm.lltype -> DataLayout.t -> int */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return Val_int(<API key>(DataLayout_val(DL), Ty)); } /* Llvm.lltype -> DataLayout.t -> int */ CAMLprim value <API key>(LLVMTypeRef Ty, value DL) { return Val_int(<API key>(DataLayout_val(DL), Ty)); } /* Llvm.llvalue -> DataLayout.t -> int */ CAMLprim value <API key>(LLVMValueRef GlobalVar, value DL) { return Val_int(<API key>(DataLayout_val(DL), GlobalVar)); } /* Llvm.lltype -> Int64.t -> DataLayout.t -> int */ CAMLprim value <API key>(LLVMTypeRef Ty, value Offset, value DL) { return Val_int(LLVMElementAtOffset(DataLayout_val(DL), Ty, Int64_val(Offset))); } /* Llvm.lltype -> int -> DataLayout.t -> Int64.t */ CAMLprim value <API key>(LLVMTypeRef Ty, value Index, value DL) { return caml_copy_int64(LLVMOffsetOfElement(DataLayout_val(DL), Ty, Int_val(Index))); } static value llvm_target_option(LLVMTargetRef Target) { if(Target != NULL) { value Result = caml_alloc_small(1, 0); Store_field(Result, 0, (value) Target); return Result; } return Val_int(0); } /* unit -> string */ CAMLprim value <API key>(value Unit) { char *TripleCStr = <API key>(); value TripleStr = caml_copy_string(TripleCStr); LLVMDisposeMessage(TripleCStr); return TripleStr; } /* unit -> Target.t option */ CAMLprim value llvm_target_first(value Unit) { return llvm_target_option(LLVMGetFirstTarget()); } /* Target.t -> Target.t option */ CAMLprim value llvm_target_succ(LLVMTargetRef Target) { return llvm_target_option(LLVMGetNextTarget(Target)); } /* string -> Target.t option */ CAMLprim value llvm_target_by_name(value Name) { return llvm_target_option(<API key>(String_val(Name))); } /* string -> Target.t */ CAMLprim LLVMTargetRef <API key>(value Triple) { LLVMTargetRef T; char *Error; if(<API key>(String_val(Triple), &T, &Error)) llvm_raise(*caml_named_value("Llvm_target.Error"), Error); return T; } /* Target.t -> string */ CAMLprim value llvm_target_name(LLVMTargetRef Target) { return caml_copy_string(LLVMGetTargetName(Target)); } /* Target.t -> string */ CAMLprim value <API key>(LLVMTargetRef Target) { return caml_copy_string(<API key>(Target)); } /* Target.t -> bool */ CAMLprim value llvm_target_has_jit(LLVMTargetRef Target) { return Val_bool(LLVMTargetHasJIT(Target)); } /* Target.t -> bool */ CAMLprim value <API key>(LLVMTargetRef Target) { return Val_bool(<API key>(Target)); } /* Target.t -> bool */ CAMLprim value <API key>(LLVMTargetRef Target) { return Val_bool(<API key>(Target)); } #define TargetMachine_val(v) (*(<API key> *)(Data_custom_val(v))) static void <API key>(value Machine) { <API key>(TargetMachine_val(Machine)); } static struct custom_operations <API key> = { (char *) "Llvm_target.TargetMachine.t", <API key>, <API key>, custom_hash_default, <API key>, <API key>, <API key> }; static value <API key>(<API key> Machine) { value V = alloc_custom(&<API key>, sizeof(<API key>), 0, 1); TargetMachine_val(V) = Machine; return V; } /* triple:string -> ?cpu:string -> ?features:string ?level:CodeGenOptLevel.t -> ?reloc_mode:RelocMode.t ?code_model:CodeModel.t -> Target.t -> TargetMachine.t */ CAMLprim value <API key>(value Triple, value CPU, value Features, value OptLevel, value RelocMode, value CodeModel, LLVMTargetRef Target) { <API key> Machine; const char *CPUStr = "", *FeaturesStr = ""; LLVMCodeGenOptLevel OptLevelEnum = <API key>; LLVMRelocMode RelocModeEnum = LLVMRelocDefault; LLVMCodeModel CodeModelEnum = <API key>; if(CPU != Val_int(0)) CPUStr = String_val(Field(CPU, 0)); if(Features != Val_int(0)) FeaturesStr = String_val(Field(Features, 0)); if(OptLevel != Val_int(0)) OptLevelEnum = Int_val(Field(OptLevel, 0)); if(RelocMode != Val_int(0)) RelocModeEnum = Int_val(Field(RelocMode, 0)); if(CodeModel != Val_int(0)) CodeModelEnum = Int_val(Field(CodeModel, 0)); Machine = <API key>(Target, String_val(Triple), CPUStr, FeaturesStr, OptLevelEnum, RelocModeEnum, CodeModelEnum); return <API key>(Machine); } CAMLprim value <API key>(value *argv, int argn) { return <API key>(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], (LLVMTargetRef) argv[6]); } /* TargetMachine.t -> Target.t */ CAMLprim LLVMTargetRef <API key>(value Machine) { return <API key>(TargetMachine_val(Machine)); } /* TargetMachine.t -> string */ CAMLprim value <API key>(value Machine) { return <API key>(<API key>( TargetMachine_val(Machine))); } /* TargetMachine.t -> string */ CAMLprim value <API key>(value Machine) { return <API key>(<API key>( TargetMachine_val(Machine))); } /* TargetMachine.t -> string */ CAMLprim value <API key>(value Machine) { return <API key>(<API key>( TargetMachine_val(Machine))); } /* TargetMachine.t -> DataLayout.t */ CAMLprim value <API key>(value Machine) { return <API key>(<API key>( TargetMachine_val(Machine))); } /* bool -> TargetMachine.t -> unit */ CAMLprim value <API key>(value Verb, value Machine) { <API key>(TargetMachine_val(Machine), Bool_val(Verb)); return Val_unit; } /* Llvm.llmodule -> CodeGenFileType.t -> string -> TargetMachine.t -> unit */ CAMLprim value <API key>(LLVMModuleRef Module, value FileType, value FileName, value Machine) { char *ErrorMessage; if(<API key>(TargetMachine_val(Machine), Module, String_val(FileName), Int_val(FileType), &ErrorMessage)) { llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage); } return Val_unit; } /* Llvm.llmodule -> CodeGenFileType.t -> TargetMachine.t -> Llvm.llmemorybuffer */ CAMLprim LLVMMemoryBufferRef <API key>( LLVMModuleRef Module, value FileType, value Machine) { char *ErrorMessage; LLVMMemoryBufferRef Buffer; if(<API key>(TargetMachine_val(Machine), Module, Int_val(FileType), &ErrorMessage, &Buffer)) { llvm_raise(*caml_named_value("Llvm_target.Error"), ErrorMessage); } return Buffer; } /* TargetMachine.t -> Llvm.PassManager.t -> unit */ CAMLprim value <API key>(LLVMPassManagerRef PM, value Machine) { <API key>(TargetMachine_val(Machine), PM); return Val_unit; }
// Use of this source code is governed by a BSD-style package net import ( "internal/testenv" "io" "net/internal/socktest" "runtime" "sync" "testing" "time" ) var <API key> = []struct { network string address string }{ {"tcp6", "127.0.0.1"}, {"tcp6", "::ffff:127.0.0.1"}, } func <API key>(t *testing.T) { switch runtime.GOOS { case "plan9": t.Skipf("not supported on %s", runtime.GOOS) } if testing.Short() || !*testExternal { t.Skip("avoid external network") } if !supportsIPv4map { t.Skip("mapping ipv4 address inside ipv6 address not supported") } ln, err := Listen("tcp", "[::]:0") if err != nil { t.Fatal(err) } defer ln.Close() _, port, err := SplitHostPort(ln.Addr().String()) if err != nil { t.Fatal(err) } for i, tt := range <API key> { c, err := Dial(tt.network, JoinHostPort(tt.address, port)) if err == nil { c.Close() t.Errorf("#%d: %v", i, err) } } } func TestSelfConnect(t *testing.T) { if runtime.GOOS == "windows" { // TODO(brainman): do not know why it hangs. t.Skip("known-broken test on windows") } // Test that Dial does not honor self-connects. // See the comment in DialTCP. // Find a port that would be used as a local address. l, err := Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatal(err) } c, err := Dial("tcp", l.Addr().String()) if err != nil { t.Fatal(err) } addr := c.LocalAddr().String() c.Close() l.Close() // Try to connect to that address repeatedly. n := 100000 if testing.Short() { n = 1000 } switch runtime.GOOS { case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd", "plan9", "solaris", "windows": // Non-Linux systems take a long time to figure // out that there is nothing listening on localhost. n = 100 } for i := 0; i < n; i++ { c, err := DialTimeout("tcp", addr, time.Millisecond) if err == nil { if c.LocalAddr().String() == addr { t.Errorf("#%d: Dial %q self-connect", i, addr) } else { t.Logf("#%d: Dial %q succeeded - possibly racing with other listener", i, addr) } c.Close() } } } func <API key>(t *testing.T) { switch runtime.GOOS { case "plan9": t.Skipf("%s does not have full support of socktest", runtime.GOOS) } const T = 100 * time.Millisecond switch runtime.GOOS { case "plan9", "windows": <API key> := testHookDialChannel testHookDialChannel = func() { time.Sleep(2 * T) } defer func() { testHookDialChannel = <API key> }() if runtime.GOOS == "plan9" { break } fallthrough default: sw.Set(socktest.FilterConnect, func(so *socktest.Status) (socktest.AfterFilter, error) { time.Sleep(2 * T) return nil, errTimeout }) defer sw.Set(socktest.FilterConnect, nil) } // Avoid tracking open-close jitterbugs between netFD and // socket that leads to confusion of information inside // socktest.Switch. // It may happen when the Dial call bumps against TCP // simultaneous open. See selfConnect in tcpsock_posix.go. defer func() { sw.Set(socktest.FilterClose, nil) forceCloseSockets() }() var mu sync.Mutex var attempts int sw.Set(socktest.FilterClose, func(so *socktest.Status) (socktest.AfterFilter, error) { mu.Lock() attempts++ mu.Unlock() return nil, errTimedout }) const N = 100 var wg sync.WaitGroup wg.Add(N) for i := 0; i < N; i++ { go func() { defer wg.Done() // This dial never starts to send any SYN // segment because of above socket filter and // test hook. c, err := DialTimeout("tcp", "127.0.0.1:0", T) if err == nil { t.Errorf("unexpectedly established: tcp:%s->%s", c.LocalAddr(), c.RemoteAddr()) c.Close() } }() } wg.Wait() if attempts < N { t.Errorf("got %d; want >= %d", attempts, N) } } func <API key>(t *testing.T) { switch runtime.GOOS { case "plan9": t.Skipf("%s does not have full support of socktest", runtime.GOOS) case "windows": t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS) } if !supportsIPv4 || !supportsIPv6 { t.Skip("both IPv4 and IPv6 are required") } <API key> := testHookLookupIP defer func() { testHookLookupIP = <API key> }() testHookLookupIP = lookupLocalhost handler := func(dss *dualStackServer, ln Listener) { for { c, err := ln.Accept() if err != nil { return } c.Close() } } dss, err := newDualStackServer([]streamListener{ {network: "tcp4", address: "127.0.0.1"}, {network: "tcp6", address: "::1"}, }) if err != nil { t.Fatal(err) } defer dss.teardown() if err := dss.buildup(handler); err != nil { t.Fatal(err) } before := sw.Sockets() const T = 100 * time.Millisecond const N = 10 var wg sync.WaitGroup wg.Add(N) d := &Dialer{DualStack: true, Timeout: T} for i := 0; i < N; i++ { go func() { defer wg.Done() c, err := d.Dial("tcp", JoinHostPort("localhost", dss.port)) if err != nil { t.Error(err) return } c.Close() }() } wg.Wait() time.Sleep(2 * T) // wait for the dial racers to stop after := sw.Sockets() if len(after) != len(before) { t.Errorf("got %d; want %d", len(after), len(before)) } } // Define a pair of blackholed (IPv4, IPv6) addresses, for which dialTCP is // expected to hang until the timeout elapses. These addresses are reserved // for benchmarking by RFC 6890. const ( slowDst4 = "192.18.0.254" slowDst6 = "2001:2::254" slowTimeout = 1 * time.Second ) // In some environments, the slow IPs may be explicitly unreachable, and fail // more quickly than expected. This test hook prevents dialTCP from returning // before the deadline. func slowDialTCP(net string, laddr, raddr *TCPAddr, deadline time.Time, cancel <-chan struct{}) (*TCPConn, error) { c, err := dialTCP(net, laddr, raddr, deadline, cancel) if ParseIP(slowDst4).Equal(raddr.IP) || ParseIP(slowDst6).Equal(raddr.IP) { time.Sleep(deadline.Sub(time.Now())) } return c, err } func dialClosedPort() (actual, expected time.Duration) { // Estimate the expected time for this platform. // On Windows, dialing a closed port takes roughly 1 second, // but other platforms should be instantaneous. if runtime.GOOS == "windows" { expected = 1500 * time.Millisecond } else { expected = 95 * time.Millisecond } l, err := Listen("tcp", "127.0.0.1:0") if err != nil { return 999 * time.Hour, expected } addr := l.Addr().String() l.Close() // On OpenBSD, interference from TestSelfConnect is mysteriously // causing the first attempt to hang for a few seconds, so we throw // away the first result and keep the second. for i := 1; ; i++ { startTime := time.Now() c, err := Dial("tcp", addr) if err == nil { c.Close() } elapsed := time.Now().Sub(startTime) if i == 2 { return elapsed, expected } } } func TestDialParallel(t *testing.T) { if testing.Short() || !*testExternal { t.Skip("avoid external network") } if !supportsIPv4 || !supportsIPv6 { t.Skip("both IPv4 and IPv6 are required") } closedPortDelay, <API key> := dialClosedPort() if closedPortDelay > <API key> { t.Errorf("got %v; want <= %v", closedPortDelay, <API key>) } const instant time.Duration = 0 const fallbackDelay = 200 * time.Millisecond // Some cases will run quickly when "connection refused" is fast, // or trigger the fallbackDelay on Windows. This value holds the // lesser of the two delays. var <API key> time.Duration if closedPortDelay < fallbackDelay { <API key> = closedPortDelay } else { <API key> = fallbackDelay } origTestHookDialTCP := testHookDialTCP defer func() { testHookDialTCP = origTestHookDialTCP }() testHookDialTCP = slowDialTCP nCopies := func(s string, n int) []string { out := make([]string, n) for i := 0; i < n; i++ { out[i] = s } return out } var testCases = []struct { primaries []string fallbacks []string teardownNetwork string expectOk bool expectElapsed time.Duration }{ // These should just work on the first try. {[]string{"127.0.0.1"}, []string{}, "", true, instant}, {[]string{"::1"}, []string{}, "", true, instant}, {[]string{"127.0.0.1", "::1"}, []string{slowDst6}, "tcp6", true, instant}, {[]string{"::1", "127.0.0.1"}, []string{slowDst4}, "tcp4", true, instant}, // Primary is slow; fallback should kick in. {[]string{slowDst4}, []string{"::1"}, "", true, fallbackDelay}, // Skip a "connection refused" in the primary thread. {[]string{"127.0.0.1", "::1"}, []string{}, "tcp4", true, closedPortDelay}, {[]string{"::1", "127.0.0.1"}, []string{}, "tcp6", true, closedPortDelay}, // Skip a "connection refused" in the fallback thread. {[]string{slowDst4, slowDst6}, []string{"::1", "127.0.0.1"}, "tcp6", true, fallbackDelay + closedPortDelay}, // Primary refused, fallback without delay. {[]string{"127.0.0.1"}, []string{"::1"}, "tcp4", true, <API key>}, {[]string{"::1"}, []string{"127.0.0.1"}, "tcp6", true, <API key>}, // Everything is refused. {[]string{"127.0.0.1"}, []string{}, "tcp4", false, closedPortDelay}, // Nothing to do; fail instantly. {[]string{}, []string{}, "", false, instant}, // Connecting to tons of addresses should not trip the deadline. {nCopies("::1", 1000), []string{}, "", true, instant}, } handler := func(dss *dualStackServer, ln Listener) { for { c, err := ln.Accept() if err != nil { return } c.Close() } } // Convert a list of IP strings into TCPAddrs. makeAddrs := func(ips []string, port string) addrList { var out addrList for _, ip := range ips { addr, err := ResolveTCPAddr("tcp", JoinHostPort(ip, port)) if err != nil { t.Fatal(err) } out = append(out, addr) } return out } for i, tt := range testCases { dss, err := newDualStackServer([]streamListener{ {network: "tcp4", address: "127.0.0.1"}, {network: "tcp6", address: "::1"}, }) if err != nil { t.Fatal(err) } defer dss.teardown() if err := dss.buildup(handler); err != nil { t.Fatal(err) } if tt.teardownNetwork != "" { // Destroy one of the listening sockets, creating an unreachable port. dss.teardownNetwork(tt.teardownNetwork) } primaries := makeAddrs(tt.primaries, dss.port) fallbacks := makeAddrs(tt.fallbacks, dss.port) d := Dialer{ FallbackDelay: fallbackDelay, Timeout: slowTimeout, } ctx := &dialContext{ Dialer: d, network: "tcp", address: "?", finalDeadline: d.deadline(time.Now()), } startTime := time.Now() c, err := dialParallel(ctx, primaries, fallbacks) elapsed := time.Now().Sub(startTime) if c != nil { c.Close() } if tt.expectOk && err != nil { t.Errorf("#%d: got %v; want nil", i, err) } else if !tt.expectOk && err == nil { t.Errorf("#%d: got nil; want non-nil", i) } expectElapsedMin := tt.expectElapsed - 95*time.Millisecond expectElapsedMax := tt.expectElapsed + 95*time.Millisecond if !(elapsed >= expectElapsedMin) { t.Errorf("#%d: got %v; want >= %v", i, elapsed, expectElapsedMin) } else if !(elapsed <= expectElapsedMax) { t.Errorf("#%d: got %v; want <= %v", i, elapsed, expectElapsedMax) } } // Wait for any slowDst4/slowDst6 connections to timeout. time.Sleep(slowTimeout * 3 / 2) } func lookupSlowFast(fn func(string) ([]IPAddr, error), host string) ([]IPAddr, error) { switch host { case "slow6loopback4": // Returns a slow IPv6 address, and a local IPv4 address. return []IPAddr{ {IP: ParseIP(slowDst6)}, {IP: ParseIP("127.0.0.1")}, }, nil default: return fn(host) } } func <API key>(t *testing.T) { if testing.Short() || !*testExternal { t.Skip("avoid external network") } if !supportsIPv4 || !supportsIPv6 { t.Skip("both IPv4 and IPv6 are required") } <API key> := testHookLookupIP defer func() { testHookLookupIP = <API key> }() testHookLookupIP = lookupSlowFast origTestHookDialTCP := testHookDialTCP defer func() { testHookDialTCP = origTestHookDialTCP }() testHookDialTCP = slowDialTCP var testCases = []struct { dualstack bool delay time.Duration expectElapsed time.Duration }{ // Use a very brief delay, which should fallback immediately. {true, 1 * time.Nanosecond, 0}, // Use a 200ms explicit timeout. {true, 200 * time.Millisecond, 200 * time.Millisecond}, // The default is 300ms. {true, 0, 300 * time.Millisecond}, // This case is last, in order to wait for hanging slowDst6 connections. {false, 0, slowTimeout}, } handler := func(dss *dualStackServer, ln Listener) { for { c, err := ln.Accept() if err != nil { return } c.Close() } } dss, err := newDualStackServer([]streamListener{ {network: "tcp", address: "127.0.0.1"}, }) if err != nil { t.Fatal(err) } defer dss.teardown() if err := dss.buildup(handler); err != nil { t.Fatal(err) } for i, tt := range testCases { d := &Dialer{DualStack: tt.dualstack, FallbackDelay: tt.delay, Timeout: slowTimeout} startTime := time.Now() c, err := d.Dial("tcp", JoinHostPort("slow6loopback4", dss.port)) elapsed := time.Now().Sub(startTime) if err == nil { c.Close() } else if tt.dualstack { t.Error(err) } expectMin := tt.expectElapsed - 1*time.Millisecond expectMax := tt.expectElapsed + 95*time.Millisecond if !(elapsed >= expectMin) { t.Errorf("#%d: got %v; want >= %v", i, elapsed, expectMin) } if !(elapsed <= expectMax) { t.Errorf("#%d: got %v; want <= %v", i, elapsed, expectMax) } } } func <API key>(t *testing.T) { if runtime.GOOS == "plan9" { t.Skip("skipping on plan9; no deadline support, golang.org/issue/11932") } ln, err := newLocalListener("tcp") if err != nil { t.Fatal(err) } defer ln.Close() d := Dialer{} ctx := &dialContext{ Dialer: d, network: "tcp", address: "?", finalDeadline: d.deadline(time.Now()), } results := make(chan dialResult) cancel := make(chan struct{}) // Spawn a connection in the background. go dialSerialAsync(ctx, addrList{ln.Addr()}, nil, cancel, results) // Receive it at the server. c, err := ln.Accept() if err != nil { t.Fatal(err) } defer c.Close() // Tell dialSerialAsync that someone else won the race. close(cancel) // The connection should close itself, without sending data. c.SetReadDeadline(time.Now().Add(1 * time.Second)) var b [1]byte if _, err := c.Read(b[:]); err != io.EOF { t.Errorf("got %v; want %v", err, io.EOF) } } func <API key>(t *testing.T) { now := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) var testCases = []struct { now time.Time deadline time.Time addrs int expectDeadline time.Time expectErr error }{ // Regular division. {now, now.Add(12 * time.Second), 1, now.Add(12 * time.Second), nil}, {now, now.Add(12 * time.Second), 2, now.Add(6 * time.Second), nil}, {now, now.Add(12 * time.Second), 3, now.Add(4 * time.Second), nil}, // Bump against the 2-second sane minimum. {now, now.Add(12 * time.Second), 999, now.Add(2 * time.Second), nil}, // Total available is now below the sane minimum. {now, now.Add(1900 * time.Millisecond), 999, now.Add(1900 * time.Millisecond), nil}, // Null deadline. {now, noDeadline, 1, noDeadline, nil}, // Step the clock forward and cross the deadline. {now.Add(-1 * time.Millisecond), now, 1, now, nil}, {now.Add(0 * time.Millisecond), now, 1, noDeadline, errTimeout}, {now.Add(1 * time.Millisecond), now, 1, noDeadline, errTimeout}, } for i, tt := range testCases { deadline, err := partialDeadline(tt.now, tt.deadline, tt.addrs) if err != tt.expectErr { t.Errorf("#%d: got %v; want %v", i, err, tt.expectErr) } if deadline != tt.expectDeadline { t.Errorf("#%d: got %v; want %v", i, deadline, tt.expectDeadline) } } } func TestDialerLocalAddr(t *testing.T) { ch := make(chan error, 1) handler := func(ls *localServer, ln Listener) { c, err := ln.Accept() if err != nil { ch <- err return } defer c.Close() ch <- nil } ls, err := newLocalServer("tcp") if err != nil { t.Fatal(err) } defer ls.teardown() if err := ls.buildup(handler); err != nil { t.Fatal(err) } laddr, err := ResolveTCPAddr(ls.Listener.Addr().Network(), ls.Listener.Addr().String()) if err != nil { t.Fatal(err) } laddr.Port = 0 d := &Dialer{LocalAddr: laddr} c, err := d.Dial(ls.Listener.Addr().Network(), ls.Addr().String()) if err != nil { t.Fatal(err) } defer c.Close() c.Read(make([]byte, 1)) err = <-ch if err != nil { t.Error(err) } } func TestDialerDualStack(t *testing.T) { if !supportsIPv4 || !supportsIPv6 { t.Skip("both IPv4 and IPv6 are required") } closedPortDelay, <API key> := dialClosedPort() if closedPortDelay > <API key> { t.Errorf("got %v; want <= %v", closedPortDelay, <API key>) } <API key> := testHookLookupIP defer func() { testHookLookupIP = <API key> }() testHookLookupIP = lookupLocalhost handler := func(dss *dualStackServer, ln Listener) { for { c, err := ln.Accept() if err != nil { return } c.Close() } } var timeout = 150*time.Millisecond + closedPortDelay for _, dualstack := range []bool{false, true} { dss, err := newDualStackServer([]streamListener{ {network: "tcp4", address: "127.0.0.1"}, {network: "tcp6", address: "::1"}, }) if err != nil { t.Fatal(err) } defer dss.teardown() if err := dss.buildup(handler); err != nil { t.Fatal(err) } d := &Dialer{DualStack: dualstack, Timeout: timeout} for range dss.lns { c, err := d.Dial("tcp", JoinHostPort("localhost", dss.port)) if err != nil { t.Error(err) continue } switch addr := c.LocalAddr().(*TCPAddr); { case addr.IP.To4() != nil: dss.teardownNetwork("tcp4") case addr.IP.To16() != nil && addr.IP.To4() == nil: dss.teardownNetwork("tcp6") } c.Close() } } time.Sleep(timeout * 3 / 2) // wait for the dial racers to stop } func TestDialerKeepAlive(t *testing.T) { handler := func(ls *localServer, ln Listener) { for { c, err := ln.Accept() if err != nil { return } c.Close() } } ls, err := newLocalServer("tcp") if err != nil { t.Fatal(err) } defer ls.teardown() if err := ls.buildup(handler); err != nil { t.Fatal(err) } defer func() { <API key> = func() {} }() for _, keepAlive := range []bool{false, true} { got := false <API key> = func() { got = true } var d Dialer if keepAlive { d.KeepAlive = 30 * time.Second } c, err := d.Dial("tcp", ls.Listener.Addr().String()) if err != nil { t.Fatal(err) } c.Close() if got != keepAlive { t.Errorf("Dialer.KeepAlive = %v: SetKeepAlive called = %v, want %v", d.KeepAlive, got, !got) } } } func TestDialCancel(t *testing.T) { if runtime.GOOS == "plan9" || runtime.GOOS == "nacl" { // plan9 is not implemented and nacl doesn't have // external network access. t.Skipf("skipping on %s", runtime.GOOS) } onGoBuildFarm := testenv.Builder() != "" if testing.Short() && !onGoBuildFarm { t.Skip("skipping in short mode") } blackholeIPPort := JoinHostPort(slowDst4, "1234") if !supportsIPv4 { blackholeIPPort = JoinHostPort(slowDst6, "1234") } ticker := time.NewTicker(10 * time.Millisecond) defer ticker.Stop() const cancelTick = 5 // the timer tick we cancel the dial at const timeoutTick = 100 var d Dialer cancel := make(chan struct{}) d.Cancel = cancel errc := make(chan error, 1) connc := make(chan Conn, 1) go func() { if c, err := d.Dial("tcp", blackholeIPPort); err != nil { errc <- err } else { connc <- c } }() ticks := 0 for { select { case <-ticker.C: ticks++ if ticks == cancelTick { close(cancel) } if ticks == timeoutTick { t.Fatal("timeout waiting for dial to fail") } case c := <-connc: c.Close() t.Fatal("unexpected successful connection") case err := <-errc: if perr := parseDialError(err); perr != nil { t.Error(perr) } if ticks < cancelTick { t.Fatalf("dial error after %d ticks (%d before cancel sent): %v", ticks, cancelTick-ticks, err) } if oe, ok := err.(*OpError); !ok || oe.Err != errCanceled { t.Fatalf("dial error = %v (%T); want OpError with Err == errCanceled", err, err) } return // success. } } }
import { Vector3 } from '../../math/Vector3'; import { Object3D } from '../../core/Object3D'; import { LineSegments } from '../../objects/LineSegments'; import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; import { Float32Attribute } from '../../core/BufferAttribute'; import { BufferGeometry } from '../../core/BufferGeometry'; function SpotLightHelper( light ) { Object3D.call( this ); this.light = light; this.light.updateMatrixWorld(); this.matrix = light.matrixWorld; this.matrixAutoUpdate = false; var geometry = new BufferGeometry(); var positions = [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, - 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 1, 1 ]; for ( var i = 0, j = 1, l = 32; i < l; i ++, j ++ ) { var p1 = ( i / l ) * Math.PI * 2; var p2 = ( j / l ) * Math.PI * 2; positions.push( Math.cos( p1 ), Math.sin( p1 ), 1, Math.cos( p2 ), Math.sin( p2 ), 1 ); } geometry.addAttribute( 'position', new Float32Attribute( positions, 3 ) ); var material = new LineBasicMaterial( { fog: false } ); this.cone = new LineSegments( geometry, material ); this.add( this.cone ); this.update(); } SpotLightHelper.prototype = Object.create( Object3D.prototype ); SpotLightHelper.prototype.constructor = SpotLightHelper; SpotLightHelper.prototype.dispose = function () { this.cone.geometry.dispose(); this.cone.material.dispose(); }; SpotLightHelper.prototype.update = function () { var vector = new Vector3(); var vector2 = new Vector3(); return function update() { var coneLength = this.light.distance ? this.light.distance : 1000; var coneWidth = coneLength * Math.tan( this.light.angle ); this.cone.scale.set( coneWidth, coneWidth, coneLength ); vector.<API key>( this.light.matrixWorld ); vector2.<API key>( this.light.target.matrixWorld ); this.cone.lookAt( vector2.sub( vector ) ); this.cone.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); }; }(); export { SpotLightHelper };
module.exports = require("npm:vm-browserify@0.0.4/index");
package org.openhab.binding.opensprinkler.internal.api.exception; /** * The {@link <API key>} exception is thrown when result from the OpenSprinkler * API is "result" : 18. * * @author Chris Graham - Initial contribution */ public class <API key> extends Exception { /** * Serial ID of this error class. */ private static final long serialVersionUID = -<API key>; /** * Basic constructor allowing the storing of a single message. * * @param message Descriptive message about the error. */ public <API key>(String message) { super(message); } }
#include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/list.h> #include <linux/i2c.h> #include <linux/irq.h> #include <linux/jiffies.h> #include <linux/uaccess.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/platform_device.h> #include <linux/gpio.h> #include <linux/miscdevice.h> #include <linux/spinlock.h> #define FEATURE_PANTECH_NFC #define NXP_KR_PENDING_READ #ifdef FEATURE_PANTECH_NFC //#define <API key> #define <API key> #define <API key> #if defined(<API key>) || defined(<API key>) || defined(<API key>) #undef <API key> #else #define <API key> #endif #define <API key> //#define <API key> #define <API key> #endif #ifdef <API key> #include <linux/wakelock.h> #endif #ifdef <API key> #include <linux/of.h> #include <linux/of_gpio.h> #endif #ifdef <API key> #include <linux/clk.h> #endif #define MAX_BUFFER_SIZE 512 #ifdef <API key> #define VEN_SET_VALUE(gpio, val) <API key>(gpio, val) #define VEN_GET_VALUE(gpio) <API key>(gpio) #else #define VEN_SET_VALUE(gpio, val) gpio_set_value(gpio, val) #define VEN_GET_VALUE(gpio) gpio_get_value(gpio) #endif #ifdef <API key> #define FW_DL_SET_VALUE(gpio, val) <API key>(gpio, val) #define FW_DL_GET_VALUE(gpio) <API key>(gpio) #else #define FW_DL_SET_VALUE(gpio, val) gpio_set_value(gpio, val) #define FW_DL_GET_VALUE(gpio) gpio_get_value(gpio) #endif #define PN547_MAGIC 0xE9 /* * PN547 power control via ioctl * PN547_SET_PWR(0): power off * PN547_SET_PWR(1): power on * PN547_SET_PWR(2): reset and power on with firmware download enabled */ #define PN547_SET_PWR _IOW(PN547_MAGIC, 0x01, unsigned int) struct pn547_dev { wait_queue_head_t read_wq; struct mutex read_mutex; struct i2c_client *client; struct miscdevice pn547_device; unsigned int ven_gpio; unsigned int firm_gpio; unsigned int irq_gpio; bool irq_enabled; spinlock_t irq_enabled_lock; #if defined(<API key>) struct wake_lock pn547_wake_lock; #endif }; #ifdef <API key> static struct clk *xo_handle_a2; #endif #ifdef NXP_KR_PENDING_READ static bool irq_nfc = false; static bool release_pending = false; #endif static void pn547_disable_irq(struct pn547_dev *pn547_dev) { unsigned long flags; spin_lock_irqsave(&pn547_dev->irq_enabled_lock, flags); if (pn547_dev->irq_enabled) { disable_irq_nosync(pn547_dev->client->irq); pn547_dev->irq_enabled = false; } <API key>(&pn547_dev->irq_enabled_lock, flags); } static irqreturn_t <API key>(int irq, void *dev_id) { struct pn547_dev *pn547_dev = dev_id; pn547_disable_irq(pn547_dev); #ifdef NXP_KR_PENDING_READ irq_nfc = true; #endif #if 0 //def <API key> pr_info("==> %s (ven, firm, irq)=(%d, %d, %d) \n", __func__, VEN_GET_VALUE(pn547_dev->ven_gpio), FW_DL_GET_VALUE(pn547_dev->firm_gpio), gpio_get_value(pn547_dev->irq_gpio)); #endif /* Wake up waiting readers */ wake_up(&pn547_dev->read_wq); return IRQ_HANDLED; } static ssize_t pn547_dev_read(struct file *filp, char __user *buf, size_t count, loff_t *offset) { struct pn547_dev *pn547_dev = filp->private_data; char tmp[MAX_BUFFER_SIZE]; int ret; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; pr_debug("%s : reading %zu bytes.\n", __func__, count); mutex_lock(&pn547_dev->read_mutex); if (!gpio_get_value(pn547_dev->irq_gpio)) { if (filp->f_flags & O_NONBLOCK) { ret = -EAGAIN; goto fail; } pn547_dev->irq_enabled = true; #ifdef NXP_KR_PENDING_READ irq_nfc = false; #endif enable_irq(pn547_dev->client->irq); #ifdef NXP_KR_PENDING_READ ret = <API key>(pn547_dev->read_wq, irq_nfc); if(ret != 0) { pr_info("<API key> return : %d\n", ret); } #else ret = <API key>(pn547_dev->read_wq, gpio_get_value(pn547_dev->irq_gpio)); #endif pn547_disable_irq(pn547_dev); #ifdef NXP_KR_PENDING_READ if(release_pending == true) { release_pending = false; ret = -1; goto fail; } #endif if (ret) goto fail; } #ifdef <API key> pr_info("==> %s #2 (ven, firm, irq)=(%d, %d, %d)\n", __func__, VEN_GET_VALUE(pn547_dev->ven_gpio), FW_DL_GET_VALUE(pn547_dev->firm_gpio), gpio_get_value(pn547_dev->irq_gpio)); #endif /* Read data */ ret = i2c_master_recv(pn547_dev->client, tmp, count); mutex_unlock(&pn547_dev->read_mutex); wake_lock_timeout(&pn547_dev->pn547_wake_lock, 100); if (ret < 0) { pr_err("%s: i2c_master_recv returned %d\n", __func__, ret); return ret; } if (ret > count) { pr_err("%s: received too many bytes from i2c (%d)\n", __func__, ret); return -EIO; } if (copy_to_user(buf, tmp, ret)) { pr_warning("%s : failed to copy to user space\n", __func__); return -EFAULT; } return ret; fail: mutex_unlock(&pn547_dev->read_mutex); return ret; } static ssize_t pn547_dev_write(struct file *filp, const char __user *buf, size_t count, loff_t *offset) { struct pn547_dev *pn547_dev; char tmp[MAX_BUFFER_SIZE]; int ret; pn547_dev = filp->private_data; if (count > MAX_BUFFER_SIZE) count = MAX_BUFFER_SIZE; if (copy_from_user(tmp, buf, count)) { pr_err("%s : failed to copy from user space\n", __func__); return -EFAULT; } #ifdef <API key> pr_info("==> %s (ven, firm, irq)=(%d, %d, %d)\n", __func__, VEN_GET_VALUE(pn547_dev->ven_gpio), FW_DL_GET_VALUE(pn547_dev->firm_gpio), gpio_get_value(pn547_dev->irq_gpio)); #endif pr_debug("%s : writing %zu bytes.\n", __func__, count); /* Write data */ ret = i2c_master_send(pn547_dev->client, tmp, count); if (ret != count) { pr_err("%s : i2c_master_send returned %d\n", __func__, ret); ret = -EIO; } return ret; } static int pn547_dev_open(struct inode *inode, struct file *filp) { struct pn547_dev *pn547_dev = container_of(filp->private_data, struct pn547_dev, pn547_device); filp->private_data = pn547_dev; pr_debug("%s : %d,%d\n", __func__, imajor(inode), iminor(inode)); return 0; } static long pn547_dev_ioctl( struct file *filp, unsigned int cmd, unsigned long arg) { struct pn547_dev *pn547_dev = filp->private_data; switch (cmd) { case PN547_SET_PWR: if (arg == 2) { /* power on with firmware download (requires hw reset) */ pr_info("%s power on with firmware\n", __func__); VEN_SET_VALUE(pn547_dev->ven_gpio, 1); FW_DL_SET_VALUE(pn547_dev->firm_gpio, 1); msleep(20); VEN_SET_VALUE(pn547_dev->ven_gpio, 0); msleep(60); VEN_SET_VALUE(pn547_dev->ven_gpio, 1); msleep(20); } else if (arg == 1) { /* power on */ pr_info("%s power on\n", __func__); FW_DL_SET_VALUE(pn547_dev->firm_gpio, 0); VEN_SET_VALUE(pn547_dev->ven_gpio, 1); msleep(20); } else if (arg == 0) { /* power off */ pr_info("%s power off\n", __func__); FW_DL_SET_VALUE(pn547_dev->firm_gpio, 0); VEN_SET_VALUE(pn547_dev->ven_gpio, 0); msleep(60); } #ifdef NXP_KR_PENDING_READ else if (arg == 3) { pr_info("%s release pending read\n", __func__); release_pending = true; irq_nfc = true; wake_up(&pn547_dev->read_wq); } #endif #ifdef <API key> else if( arg == 0XFF) { pr_info("%s power down\n", __func__); VEN_SET_VALUE(pn547_dev->ven_gpio, 0); FW_DL_SET_VALUE(pn547_dev->firm_gpio, 0); msleep(60); VEN_SET_VALUE(pn547_dev->ven_gpio, 1); msleep(20); VEN_SET_VALUE(pn547_dev->ven_gpio, 0); msleep(20); } #endif else { pr_err("%s bad arg %lu\n", __func__, arg); return -EINVAL; } break; default: pr_err("%s bad ioctl %u\n", __func__, cmd); return -EINVAL; } return 0; } static const struct file_operations pn547_dev_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = pn547_dev_read, .write = pn547_dev_write, .open = pn547_dev_open, .unlocked_ioctl = pn547_dev_ioctl, }; static int pn547_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct pn547_dev *pn547_dev; #ifdef <API key> int rc; #endif #ifdef <API key> struct device_node *np; np = client->dev.of_node; if(np == NULL){ pr_err("%s : pn547_probe np\n", __func__); return -ENODEV; } #else struct <API key> *platform_data; platform_data = client->dev.platform_data; if (platform_data == NULL) { pr_err("%s : nfc probe fail\n", __func__); return -ENODEV; } #endif #ifdef <API key> pr_info("+ pr_info("| NXP pn547 Driver Probe! |\n"); pr_info("+ #endif pn547_dev = kzalloc(sizeof(*pn547_dev), GFP_KERNEL); if (pn547_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } if (!<API key>(client->adapter, I2C_FUNC_I2C)) { pr_err("%s : need I2C_FUNC_I2C\n", __func__); return -ENODEV; } #ifdef <API key> pn547_dev->irq_gpio = (unsigned int)<API key>(np,"nxp,irq-gpio",0,NULL); pn547_dev->ven_gpio = (unsigned int)<API key>(np,"nxp,ven-gpio",0,NULL); pn547_dev->firm_gpio = (unsigned int)<API key>(np,"nxp,firm-gpio",0, NULL); #else pn547_dev->irq_gpio = platform_data->irq_gpio; pn547_dev->ven_gpio = platform_data->ven_gpio; pn547_dev->firm_gpio = platform_data->firm_gpio; #endif pn547_dev->client = client; pr_info("%s (ven, firm, irq)=(%d, %d, %d)\n", __func__, pn547_dev->ven_gpio, pn547_dev->firm_gpio, pn547_dev->irq_gpio); ret = gpio_request(pn547_dev->irq_gpio, "nfc_int"); if (ret) { pr_err("%s : error : gpio_request nfc_int\n", __func__); return -ENODEV; } ret = <API key>(pn547_dev->irq_gpio); if (ret) { pr_err("%s : error : <API key> irq_gpio\n", __func__); goto err_ven; } ret = gpio_request(pn547_dev->ven_gpio, "nfc_ven"); if (ret) { pr_err("%s : error : gpio_request nfc_ven\n", __func__); goto err_ven; } #if !defined(<API key>) ret = <API key>(pn547_dev->ven_gpio, 0); if (ret ) { pr_err("%s : error : <API key> ven_gpio\n", __func__); goto err_firm; } #endif ret = gpio_request(pn547_dev->firm_gpio, "nfc_firm"); if (ret) { pr_err("%s : error : gpio_request nfc_firm\n", __func__); goto err_firm; } #if !defined(<API key>) ret = <API key>(pn547_dev->firm_gpio, 0); if (ret ) { pr_err("%s : error : <API key> firm_gpio\n", __func__); goto err_firm_direction; } #endif /* init mutex and queues */ init_waitqueue_head(&pn547_dev->read_wq); mutex_init(&pn547_dev->read_mutex); spin_lock_init(&pn547_dev->irq_enabled_lock); #if defined(<API key>) wake_lock_init(&pn547_dev->pn547_wake_lock, WAKE_LOCK_SUSPEND, "pn547"); #endif pn547_dev->pn547_device.minor = MISC_DYNAMIC_MINOR; pn547_dev->pn547_device.name = "pn547"; pn547_dev->pn547_device.fops = &pn547_dev_fops; ret = misc_register(&pn547_dev->pn547_device); if (ret) { pr_err("%s : misc_register failed\n", __FILE__); goto err_misc_register; } /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ pr_info("%s : requesting IRQ %d\n", __func__, client->irq); pn547_dev->irq_enabled = true; ret = request_irq(client->irq, <API key>, IRQF_TRIGGER_HIGH, client->name, pn547_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto <API key>; } pn547_disable_irq(pn547_dev); i2c_set_clientdata(client, pn547_dev); #ifdef <API key> #ifdef <API key> pr_info("[%s] device name [%s]\n", __func__,np->name); pr_info("[%s] device full name [%s]\n", __func__,np->full_name); #endif xo_handle_a2 = clk_get_sys(np->name, "xo"); if (IS_ERR(xo_handle_a2)) { dev_err(&client->dev,"[%s] clk_get err \n", __func__); } rc = clk_prepare_enable(xo_handle_a2); if (rc) { dev_err(&client->dev,"[%s] clk_prepare_enable fail rc[%d]\n", __func__, rc); } #endif /* <API key> */ return 0; <API key>: misc_deregister(&pn547_dev->pn547_device); err_misc_register: mutex_destroy(&pn547_dev->read_mutex); #if defined(<API key>) wake_lock_destroy(&pn547_dev->pn547_wake_lock); #endif #if !defined(<API key>) err_firm_direction: #endif gpio_free(pn547_dev->firm_gpio); err_firm: gpio_free(pn547_dev->ven_gpio); err_ven: gpio_free(pn547_dev->irq_gpio); kfree(pn547_dev); err_exit: return ret; } static int pn547_remove(struct i2c_client *client) { struct pn547_dev *pn547_dev; pn547_dev = i2c_get_clientdata(client); free_irq(client->irq, pn547_dev); misc_deregister(&pn547_dev->pn547_device); mutex_destroy(&pn547_dev->read_mutex); #if defined(<API key>) wake_lock_destroy(&pn547_dev->pn547_wake_lock); #endif #ifdef <API key> <API key>(xo_handle_a2); #endif gpio_free(pn547_dev->irq_gpio); gpio_free(pn547_dev->ven_gpio); gpio_free(pn547_dev->firm_gpio); kfree(pn547_dev); return 0; } #if defined(<API key>) static int pn547_suspend(struct device *dev) { struct pn547_dev *pn547_dev = dev_get_drvdata(dev); #ifdef <API key> pr_info("pn547_suspend*********** client IRQ[%d]\n", pn547_dev->client->irq); pr_info("pn547_suspend*********** gpio_to_irq IRQ[%d]\n", gpio_to_irq(pn547_dev->irq_gpio)); #endif if(VEN_GET_VALUE(pn547_dev->ven_gpio) == 1) { irq_set_irq_wake(pn547_dev->client->irq, 1); } return 0; } static int pn547_resume(struct device *dev) { struct pn547_dev *pn547_dev = dev_get_drvdata(dev); #ifdef <API key> pr_info("<************pn547_resume client IRQ[%d]\n", pn547_dev->client->irq); pr_info("<************pn547_resume gpio_to_irq IRQ[%d]\n", gpio_to_irq(pn547_dev->irq_gpio)); pr_info("++++++pn547_resume()______pn547_resume irq_nfc [%d]\n", irq_nfc); #endif if(VEN_GET_VALUE(pn547_dev->ven_gpio) == 1) { if(gpio_get_value(pn547_dev->irq_gpio) == 1) { wake_lock_timeout(&pn547_dev->pn547_wake_lock, 100); } irq_set_irq_wake(pn547_dev->client->irq, 0); } return 0; } static struct dev_pm_ops pn547_pm_ops = { .suspend = pn547_suspend, .resume = pn547_resume, }; #endif #if defined(<API key>) MODULE_DEVICE_TABLE(of, pn547_match_table); static struct of_device_id pn547_match_table[] = { { .compatible = "nxp,pn547",}, { }, }; #endif static const struct i2c_device_id pn547_id[] = { { "pn547", 0 }, { } }; static struct i2c_driver pn547_driver = { .id_table = pn547_id, .probe = pn547_probe, .remove = pn547_remove, .driver = { .owner = THIS_MODULE, .name = "pn547", #if defined(<API key>) .of_match_table = of_match_ptr(pn547_match_table), #endif #if defined(<API key>) .pm = &pn547_pm_ops, #endif }, }; /* * module load/unload record keeping */ static int __init pn547_dev_init(void) { pr_info("Loading pn547 driver\n"); return i2c_add_driver(&pn547_driver); } module_init(pn547_dev_init); static void __exit pn547_dev_exit(void) { pr_info("Unloading pn547 driver\n"); i2c_del_driver(&pn547_driver); } module_exit(pn547_dev_exit); MODULE_AUTHOR("Sylvain Fonteneau"); MODULE_DESCRIPTION("NFC PN547 driver"); MODULE_LICENSE("GPL");
# bcmdhd # SDIO Basic feature DHDCFLAGS += -Wall -Wstrict-prototypes -Dlinux -DLINUX -DBCMDRIVER \ -DBCMDONGLEHOST -DUNRELEASEDCHIP -DBCMDMA32 -DBCMFILEIMAGE \ -DDHDTHREAD -DBDC -DOOB_INTR_ONLY \ -DDHD_BCMEVENTS -DSHOW_EVENTS -DBCMDBG \ -DMMC_SDIO_ABORT -DBCMSDIO -DBCMLXSDMMC -DWLP2P \ -DWIFI_ACT_FRAME -<API key> \ -DKEEP_ALIVE -DCSCAN -DPKT_FILTER_SUPPORT \ -DEMBEDDED_PLATFORM -DPNO_SUPPORT # CM kernel includes 3.4 backports DHDCFLAGS += -DWL_COMPAT_WIRELESS # Common feature DHDCFLAGS += -DCUSTOMER_HW4 DHDCFLAGS += -DWL_CFG80211 # Debug DHDCFLAGS += -DSIMPLE_MAC_PRINT DHDCFLAGS += -DDEBUGFS_CFG80211 # Print out kernel panic point of file and line info when assertion happened DHDCFLAGS += -DBCMASSERT_LOG # Print 8021X DHDCFLAGS += -DDHD_8021X_DUMP # VSDB DHDCFLAGS += -DVSDB DHDCFLAGS += -DPROP_TXSTATUS # Wi-Fi Direct DHDCFLAGS += -<API key> # For p2p connection issue DHDCFLAGS += -DWL_SCB_TIMEOUT=10 # For TDLS tear down inactive time 10 sec DHDCFLAGS += -<API key>=10000 # for TDLS RSSI HIGH for establishing TDLS link DHDCFLAGS += -<API key>=-80 # for TDLS RSSI HIGH for tearing down TDLS link DHDCFLAGS += -<API key>=-85 # Roaming DHDCFLAGS += -<API key> DHDCFLAGS += -DROAM_ENABLE -DROAM_CHANNEL_CACHE -DROAM_API DHDCFLAGS += -<API key> # CCX ifeq ($(CONFIG_BRCM_CCX),y) DHDCFLAGS += -DBCMCCX endif # SoftAP DHDCFLAGS += -<API key> -DSUPPORT_HIDDEN_AP DHDCFLAGS += -<API key> DHDCFLAGS += -DDISABLE_11H_SOFTAP # HW4 specific features DHDCFLAGS += -DSUPPORT_PM2_ONLY DHDCFLAGS += -DSUPPORT_DEEP_SLEEP DHDCFLAGS += -<API key> # For special PNO Event keep wake lock for 10sec DHDCFLAGS += -<API key>=10 # For Passing all multicast packets to host when not in suspend mode. DHDCFLAGS += -<API key> # Early suspend DHDCFLAGS += -<API key> # WiFi turn off delay DHDCFLAGS += -DWIFI_TURNOFF_DELAY=100 # For Scan result patch DHDCFLAGS += -DESCAN_RESULT_PATCH DHDCFLAGS += -<API key> # For Static Buffer ifeq ($(<API key>),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> endif # DTIM listen interval in suspend mode(0 means follow AP's DTIM period) DHDCFLAGS += -<API key>=0 # Ioctl timeout 5000ms DHDCFLAGS += -DIOCTL_RESP_TIMEOUT=5000 # DPC priority DHDCFLAGS += -<API key>=98 # Priority mismatch fix with kernel stack DHDCFLAGS += -DPKTPRIO_OVERRIDE # Prevent rx thread monopolize DHDCFLAGS += -DWAIT_DEQUEUE # Config PM Control DHDCFLAGS += -DCONFIG_CONTROL_PM # Use Android wake lock mechanism DHDCFLAGS += -<API key> # idle count DHDCFLAGS += -DDHD_USE_IDLECOUNT # Used short dwell time during initial scan DHDCFLAGS += -<API key> # SKB TAILPAD to avoid out of boundary memory access DHDCFLAGS += -DDHDENABLE_TAILPAD # Android Platform Definition # KitKat # Definitions are filtered by Kernel version DHDCFLAGS += -DWL_ENABLE_P2P_IF DHDCFLAGS += -<API key> # Default definitions for KitKat DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> # To support p2p private command on kernel 3.8 or above DHDCFLAGS += -<API key> # driver type # m: module type driver # y: built-in type driver DRIVER_TYPE ?= m # Chip dependent feature ifneq ($(CONFIG_BCM4354),) DHDCFLAGS += -DBCM4354_CHIP -DHW_OOB -<API key> DHDCFLAGS += -DMIMO_ANT_SETTING DHDCFLAGS += -DUSE_CID_CHECK DHDCFLAGS += -<API key> DHDCFLAGS += -DSDIO_CRC_ERROR_FIX # tput enhancement DHDCFLAGS += -<API key>=8 -DCUSTOM_RXCHAIN=1 DHDCFLAGS += -<API key> -<API key>=128 DHDCFLAGS += -DBCMSDIOH_TXGLOM -DCUSTOM_TXGLOM=1 -<API key> DHDCFLAGS += -DDHDTCPACK_SUPPRESS DHDCFLAGS += -DUSE_WL_TXBF DHDCFLAGS += -DUSE_WL_FRAMEBURST DHDCFLAGS += -DRXFRAME_THREAD DHDCFLAGS += -DREPEAT_READFRAME DHDCFLAGS += -<API key>=64 -<API key>=16 DHDCFLAGS += -DCUSTOM_DPC_CPUCORE=0 DHDCFLAGS += -DPROP_TXSTATUS_VSDB DHDCFLAGS += -<API key>=40 -DDHD_TXBOUND=40 DHDCFLAGS += -<API key> -<API key>=1000000 DHDCFLAGS += -<API key>=40 DHDCFLAGS += -DMAX_HDR_READ=128 DHDCFLAGS += -DDHD_FIRSTREAD=128 DHDCFLAGS += -DCUSTOM_AMPDU_MPDU=16 DHDCFLAGS += -<API key>=64 # New Features DHDCFLAGS += -DWL11U DHDCFLAGS += -DBCMCCX DHDCFLAGS += -DWES_SUPPORT DHDCFLAGS += -DOKC_SUPPORT DHDCFLAGS += -DWLTDLS DHDCFLAGS += -DWLFBT DHDCFLAGS += -DDHD_ENABLE_LPC DHDCFLAGS += -DWLAIBSS DHDCFLAGS += -DSUPPORT_LTECX DHDCFLAGS += -DSUPPORT_2G_VHT DHDCFLAGS += -DSUPPORT_WL_TXPOWER DHDCFLAGS += -<API key> ifeq ($(CONFIG_BCM4354),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif DHDCFLAGS += -<API key>=30 DHDCFLAGS += -DSUPPORT_P2P_GO_PS endif ifneq ($(CONFIG_BCM4339),) DHDCFLAGS += -DBCM4339_CHIP -DHW_OOB DHDCFLAGS += -DUSE_CID_CHECK DHDCFLAGS += -<API key> DHDCFLAGS += -DUSE_SDIOFIFO_IOVAR # tput enhancement DHDCFLAGS += -<API key>=8 -DCUSTOM_RXCHAIN=1 DHDCFLAGS += -<API key> -<API key>=128 DHDCFLAGS += -DBCMSDIOH_TXGLOM -DCUSTOM_TXGLOM=1 -<API key> DHDCFLAGS += -DDHDTCPACK_SUPPRESS DHDCFLAGS += -DUSE_WL_TXBF DHDCFLAGS += -DUSE_WL_FRAMEBURST DHDCFLAGS += -DRXFRAME_THREAD DHDCFLAGS += -<API key>=64 -<API key>=16 DHDCFLAGS += -DCUSTOM_DPC_CPUCORE=0 DHDCFLAGS += -DPROP_TXSTATUS_VSDB ifeq ($(CONFIG_ARCH_MSM),y) DHDCFLAGS += -<API key>=32 -DDHD_TXBOUND=32 DHDCFLAGS += -<API key> -<API key>=1000000 endif DHDCFLAGS += -<API key>=32 # New Features DHDCFLAGS += -DWL11U DHDCFLAGS += -DBCMCCX DHDCFLAGS += -DWES_SUPPORT DHDCFLAGS += -DOKC_SUPPORT DHDCFLAGS += -DWLTDLS -DWLTDLS_AUTO_ENABLE DHDCFLAGS += -DWLFBT DHDCFLAGS += -DDHD_ENABLE_LPC DHDCFLAGS += -DWLAIBSS DHDCFLAGS += -DSUPPORT_LTECX DHDCFLAGS += -DSUPPORT_2G_VHT DHDCFLAGS += -DSUPPORT_WL_TXPOWER DHDCFLAGS += -DBCMCCX_S69 ifeq ($(CONFIG_BCM4339),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif DHDCFLAGS += -<API key>=30 endif ifneq ($(CONFIG_BCM4335),) DHDCFLAGS += -DBCM4335_CHIP -DHW_OOB -<API key> DHDCFLAGS += -DUSE_CID_CHECK DHDCFLAGS += -<API key> DHDCFLAGS += -DUSE_SDIOFIFO_IOVAR # tput enhancement DHDCFLAGS += -<API key>=8 -DCUSTOM_RXCHAIN=1 DHDCFLAGS += -<API key> -<API key>=128 DHDCFLAGS += -DBCMSDIOH_TXGLOM -DCUSTOM_TXGLOM=1 -<API key> DHDCFLAGS += -DDHDTCPACK_SUPPRESS # DHDCFLAGS += -<API key> DHDCFLAGS += -DUSE_WL_TXBF DHDCFLAGS += -DUSE_WL_FRAMEBURST DHDCFLAGS += -DRXFRAME_THREAD DHDCFLAGS += -DREPEAT_READFRAME DHDCFLAGS += -<API key>=64 DHDCFLAGS += -DCUSTOM_DPC_CPUCORE=0 DHDCFLAGS += -DPROP_TXSTATUS_VSDB # DHDCFLAGS += -DTPUT_DEBUG ifeq ($(CONFIG_MACH_JF),y) DHDCFLAGS += -<API key>=32 -DDHD_TXBOUND=32 endif ifeq ($(CONFIG_ARCH_MSM),y) DHDCFLAGS += -<API key>=32 -DDHD_TXBOUND=32 DHDCFLAGS += -<API key> -<API key>=1000000 endif DHDCFLAGS += -<API key>=32 # New Features DHDCFLAGS += -DWL11U DHDCFLAGS += -DBCMCCX DHDCFLAGS += -DWES_SUPPORT DHDCFLAGS += -DOKC_SUPPORT DHDCFLAGS += -DWLTDLS -DWLTDLS_AUTO_ENABLE DHDCFLAGS += -DWLFBT DHDCFLAGS += -DDHD_ENABLE_LPC DHDCFLAGS += -DWLAIBSS DHDCFLAGS += -DSUPPORT_LTECX DHDCFLAGS += -DSUPPORT_2G_VHT DHDCFLAGS += -DSUPPORT_WL_TXPOWER # For BT LOCK ifeq ($(CONFIG_BCM4335BT),y) DHDCFLAGS += -DENABLE_4335BT_WAR endif ifeq ($(CONFIG_BCM4335),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif endif ifneq ($(CONFIG_BCM4334),) DHDCFLAGS += -DBCM4334_CHIP -DHW_OOB -<API key> DHDCFLAGS += -DUSE_CID_CHECK DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> -<API key>=64 DHDCFLAGS += -<API key>=5 DHDCFLAGS += -DPROP_TXSTATUS_VSDB DHDCFLAGS += -DWES_SUPPORT DHDCFLAGS += -DSUPPORT_WL_TXPOWER # New Features # DHDCFLAGS += -DWL11U DHDCFLAGS += -DBCMCCX DHDCFLAGS += -DOKC_SUPPORT DHDCFLAGS += -DWES_SUPPORT DHDCFLAGS += -DWLFBT ifeq ($(CONFIG_BCM4334),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif endif ifneq ($(CONFIG_BCM4330),) DHDCFLAGS += -DBCM4330_CHIP -<API key> DHDCFLAGS += -<API key> DHDCFLAGS += -<API key>=0 DHDCFLAGS += -<API key> ifeq ($(CONFIG_BCM4330),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif # Remove common feature for BCM4330 DHDCFLAGS :=$(filter-out -<API key>,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -DVSDB,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -DPROP_TXSTATUS,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -<API key>,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -DDHD_USE_IDLECOUNT,$(DHDCFLAGS)) endif ifneq ($(CONFIG_BCM43241),) DHDCFLAGS += -DBCM43241_CHIP -DHW_OOB DHDCFLAGS += -DMIMO_ANT_SETTING DHDCFLAGS += -<API key>=1 -<API key>=128 DHDCFLAGS += -DUSE_SDIOFIFO_IOVAR DHDCFLAGS += -DAMPDU_HOSTREORDER ifeq ($(CONFIG_BCM43241),m) DHDCFLAGS += -fno-pic endif ifeq ($(CONFIG_BCM43241),y) DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> DRIVER_TYPE = y endif endif # Platform dependent feature ifeq ($(CONFIG_SPI_SC8810),y) DHDCFLAGS += -DREAD_MACADDR -DBCMSPI -DBCMSPI_ANDROID -DSPI_PIO_32BIT_RW -<API key> DHDCFLAGS += -<API key> #Remove defines for SDMMC DHDCFLAGS :=$(filter-out -DOOB_INTR_ONLY,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -DBCMLXSDMMC,$(DHDCFLAGS)) #Remove defines for JB DHDCFLAGS :=$(filter-out -DWL_ENABLE_P2P_IF,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -<API key>,$(DHDCFLAGS)) DHDCFLAGS :=$(filter-out -<API key>,$(DHDCFLAGS)) endif # For SLP feature ifeq ($(CONFIG_SLP),y) DHDCFLAGS += -<API key> DHDCFLAGS += -DPLATFORM_SLP DHDCFLAGS += -UWL_ENABLE_P2P_IF DHDCFLAGS += -<API key> DHDCFLAGS += -<API key> endif # <API key> feature is define for only GGSM model ifeq ($(<API key>),true) DHDCFLAGS += -<API key> endif ifeq ($(CONFIG_OF),y) ifneq ($(<API key>),) obj-$(<API key>) += dhd_custom_exynos.o DHDCFLAGS += -DDHD_OF_SUPPORT endif ifneq ($(<API key>),) obj-$(<API key>) += dhd_custom_exynos.o DHDCFLAGS += -DDHD_OF_SUPPORT endif endif # dhd_sec_feature.h DHDCFLAGS += -include "dhd_sec_feature.h" # Others #EXTRA_LDFLAGS += --strip-debug EXTRA_CFLAGS += $(DHDCFLAGS) -DDHD_DEBUG EXTRA_CFLAGS += -DSRCBASE=\"$(src)\" EXTRA_CFLAGS += -I$(src)/include/ -I$(src)/ KBUILD_CFLAGS += -I$(LINUXDIR)/include -I$(shell pwd) DHDOFILES := bcmsdh.o bcmsdh_linux.o bcmsdh_sdmmc.o bcmsdh_sdmmc_linux.o \ dhd_cdc.o dhd_pno.o dhd_common.o dhd_wlfc.o dhd_ip.o dhd_custom_gpio.o dhd_custom_sec.o \ dhd_linux.o dhd_linux_sched.o dhd_cfg80211.o dhd_sdio.o dhd_linux_wq.o aiutils.o bcmevent.o \ bcmutils.o bcmwifi_channels.o hndpmu.o linux_osl.o sbutils.o siutils.o \ wl_android.o wl_cfg80211.o wl_cfgp2p.o wl_cfg_btcoex.o wldev_common.o wl_linux_mon.o wl_roam.o \ dhd_linux_platdev.o dhd_pno.o dhd_linux_wq.o wl_cfg_btcoex.o # For SPI projects ifeq ($(CONFIG_SPI_SC8810),y) DHDOFILES += bcmsdspi_linux.o bcmspibrcm.o DHDOFILES :=$(filter-out bcmsdh_sdmmc.o,$(DHDOFILES)) DHDOFILES :=$(filter-out bcmsdh_sdmmc_linux.o,$(DHDOFILES)) endif dhd-y := $(DHDOFILES) obj-$(DRIVER_TYPE) += dhd.o all: @echo "$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules" @$(MAKE) --no-print-directory -C $(KDIR) SUBDIRS=$(CURDIR) modules clean: rm -rf *.o *.ko *.mod.c *~ .*.cmd *.o.cmd .*.o.cmd \ Module.symvers modules.order .tmp_versions modules.builtin install: @$(MAKE) --no-print-directory -C $(KDIR) \ SUBDIRS=$(CURDIR) modules_install
/* Memory layout of a zipmap, for the map "foo" => "bar", "hello" => "world": * * "foo" => "bar", "hello" => "world" zipmap * * <zmlen><len>"foo"<len><free>"bar"<len>"hello"<len><free>"world"<ZIPMAP_END> * * <zmlen> is 1 byte length that holds the current size of the zipmap. * When the zipmap length is greater than or equal to 254, this value * is not used and the zipmap needs to be traversed to find out the length. * * <zmlen> 1 zipmap size * zipmap < 254 * zipmap >= 254 zipmap * * <len> is the length of the following string (key or value). * <len> lengths are encoded in a single value or in a 5 bytes value. * If the first byte value (as an unsigned 8 bit value) is between 0 and * 252, it's a single-byte length. If it is 253 then a four bytes unsigned * integer follows (in the host byte ordering). A value of 255 is used to * signal the end of the hash. The special value 254 is used to mark * empty space that can be used to add new key/value pairs. * * <len> () * * <len> 1 5 * * * <len> ( 8 bit) 0 252 * * * * 253 4 * (/) * * * 254 key-value * * * 255 * * <free> is the number of free unused bytes after the string, resulting * from modification of values associated to a key. For instance if "foo" * is set to "bar", and later "foo" will be set to "hi", it will have a * free byte to use if the value will enlarge again later, or even in * order to add a key/value pair if it fits. * * <free> * * * * zimap "foo" -> "bar" * "foo" -> "hi" * "hi" * * * "foo" "yoo" * key-value * * <free> is always an unsigned 8 bit number, because if after an * update operation there are more than a few free bytes, the zipmap will be * reallocated to make sure it is as small as possible. * * <free> 8 * <API key> * zipmap * <free> 8 <free> * * The most compact representation of the above two elements hash is actually: * * "foo" -> "bar" "hello" -> "world" * * "\x02\x03foo\x03\x00bar\x05hello\x05\x00world\xff" * * Note that because keys and values are prefixed length "objects", * the lookup will take O(N) where N is the number of elements * in the zipmap and *not* the number of bytes needed to represent the zipmap. * This lowers the constant times considerably. * * key value * zipmap O(N) * N zipmap */ #include <stdio.h> #include <string.h> #include <assert.h> #include "zmalloc.h" #include "endianconv.h" // zipmap #define ZIPMAP_BIGLEN 254 // zipmap #define ZIPMAP_END 255 /* The following defines the max value for the <free> field described in the * comments above, that is, the max number of trailing bytes in a value. */ #define <API key> 4 /* The following macro returns the number of bytes needed to encode the length * for the integer value _l, that is, 1 byte for lengths < ZIPMAP_BIGLEN and * 5 bytes for all the other lengths. */ // <len> #define ZIPMAP_LEN_BYTES(_l) (((_l) < ZIPMAP_BIGLEN) ? 1 : sizeof(unsigned int)+1) /* * zipmap */ unsigned char *zipmapNew(void) { unsigned char *zm = zmalloc(2); zm[0] = 0; /* Length */ zm[1] = ZIPMAP_END; return zm; } /* * <len> */ static unsigned int zipmapDecodeLength(unsigned char *p) { unsigned int len = *p; // <len> p if (len < ZIPMAP_BIGLEN) return len; // <len> p 4 memcpy(&len,p+1,sizeof(unsigned int)); memrev32ifbe(&len); return len; } /* * l p * p NULL l */ static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int len) { if (p == NULL) { return ZIPMAP_LEN_BYTES(len); } else { if (len < ZIPMAP_BIGLEN) { p[0] = len; return 1; } else { p[0] = ZIPMAP_BIGLEN; memcpy(p+1,&len,sizeof(len)); memrev32ifbe(p+1); return 1+sizeof(len); } } } /* Search for a matching key, returning a pointer to the entry inside the * zipmap. Returns NULL if the key is not found. * * If NULL is returned, and totlen is not NULL, it is set to the entire * size of the zimap, so that the calling function will be able to * reallocate the original zipmap to make room for more entries. */ /* * key zipmap NULL * * totlen NULL * totlen zipmap (size) * zipmap * zipmap */ static unsigned char *zipmapLookupRaw( unsigned char *zm, unsigned char *key, unsigned int klen, unsigned int *totlen ) { unsigned char *p = zm+1, // <zmlen> *k = NULL; unsigned int l,llen; // zipmap while(*p != ZIPMAP_END) { unsigned char free; /* Match or skip the key */ // <len> l = zipmapDecodeLength(p); // <len> llen = zipmapEncodeLength(NULL,l); if (key != NULL && // key k == NULL && // key l == klen && // <len> klen !memcmp(p+llen,key,l) // key ) { /* Only return when the user doesn't care * for the total length of the zipmap. */ if (totlen != NULL) { k = p; // goto if (totlen != NUL) ... // goto key_founded; } else { return p; } } // key p += llen+l; // value l = zipmapDecodeLength(p); // value p += zipmapEncodeLength(NULL,l); // value <len> free = p[0]; // <free> p += l+1+free; // value <free> <free> } // key_founded: if (totlen != NULL) *totlen = (unsigned int)(p-zm)+1; return k; } /* * key-value * * key-value <len>key<len><free>value * <len> 1 5 * <free> */ static unsigned long <API key>(unsigned int klen, unsigned int vlen) { unsigned int l; // 3 key value l = klen+vlen+3; // <len> if (klen >= ZIPMAP_BIGLEN) l += 4; if (vlen >= ZIPMAP_BIGLEN) l += 4; return l; } /* * key ( <len> ) */ static unsigned int zipmapRawKeyLength(unsigned char *p) { unsigned int l = zipmapDecodeLength(p); return zipmapEncodeLength(NULL,l) + l; } /* * value * ( <len> <free> ) */ static unsigned int <API key>(unsigned char *p) { unsigned int l = zipmapDecodeLength(p); unsigned int used; used = zipmapEncodeLength(NULL,l); used += p[used] + 1 + l; return used; } /* * p key * ( = key + value + ()) */ static unsigned int <API key>(unsigned char *p) { unsigned int l = zipmapRawKeyLength(p); return l + <API key>(p+l); } /* * zipmap len */ static inline unsigned char *zipmapResize(unsigned char *zm, unsigned int len) { zm = zrealloc(zm, len); zm[len-1] = ZIPMAP_END; return zm; } /* * key value key * * key update NULL * *update 1 0 */ unsigned char *zipmapSet( unsigned char *zm, unsigned char *key, unsigned int klen, unsigned char *val, unsigned int vlen, int *update ) { unsigned int zmlen, offset; unsigned int freelen, reqlen = <API key>(klen,vlen); unsigned int empty, vempty; unsigned char *p; freelen = reqlen; if (update) *update = 0; // key p = zipmapLookupRaw(zm,key,klen,&zmlen); if (p == NULL) { // key zipmap zm = zipmapResize(zm, zmlen+reqlen); p = zm+zmlen-1; // -1 ZIPMAP_END // zipmap zmlen = zmlen+reqlen; if (zm[0] < ZIPMAP_BIGLEN) zm[0]++; } else { /* Key found. Is there enough space for the new value? */ /* Compute the total length: */ if (update) *update = 1; freelen = <API key>(p); if (freelen < reqlen) { /* Store the offset of this key within the current zipmap, so * it can be resized. Then, move the tail backwards so this * pair fits at the current position. */ // zipmap offset = p-zm; zm = zipmapResize(zm, zmlen-freelen+reqlen); p = zm+offset; /* The +1 in the number of bytes to be moved is caused by the * end-of-zipmap byte. Note: the *original* zmlen is used. */ // <many-bytes><p><remain-bytes> // <many-bytes>< ... p ... ><remain-bytes> memmove(p+reqlen, p+freelen, zmlen-(offset+freelen+1)); zmlen = zmlen-freelen+reqlen; freelen = reqlen; } } /* We now have a suitable block where the key/value entry can * be written. If there is too much free space, move the tail * of the zipmap a few bytes to the front and shrink the zipmap, * as we want zipmaps to be very space efficient. */ // value zipmap empty = freelen-reqlen; if (empty >= <API key>) { /* First, move the tail <empty> bytes to the front, then resize * the zipmap to be <empty> bytes smaller. */ offset = p-zm; memmove(p+reqlen, p+freelen, zmlen-(offset+freelen+1)); zmlen -= empty; zm = zipmapResize(zm, zmlen); p = zm+offset; vempty = 0; } else { vempty = empty; } /* Just write the key + value and we are done. */ /* Key: */ p += zipmapEncodeLength(p,klen); memcpy(p,key,klen); p += klen; /* Value: */ p += zipmapEncodeLength(p,vlen); *p++ = vempty; memcpy(p,val,vlen); return zm; } /* * key zipmap * * deleted NULL * - key 0 * - key 1 */ unsigned char *zipmapDel(unsigned char *zm, unsigned char *key, unsigned int klen, int *deleted) { unsigned int zmlen, freelen; unsigned char *p = zipmapLookupRaw(zm,key,klen,&zmlen); if (p) { freelen = <API key>(p); // <many-bytes>< ... p ... ><remain-bytes> // <many-bytes><p><remain-bytes> memmove(p, p+freelen, zmlen-((p-zm)+freelen+1)); zm = zipmapResize(zm, zmlen-freelen); // zipmap if (zm[0] < ZIPMAP_BIGLEN) zm[0] if (deleted) *deleted = 1; } else { if (deleted) *deleted = 0; } return zm; } /* * zipmap */ unsigned char *zipmapRewind(unsigned char *zm) { return zm+1; } /* * zipmap * * zm zipmapRewind() * * * * unsigned char *i = zipmapRewind(my_zipmap); * while((i = zipmapNext(i,&key,&klen,&value,&vlen)) != NULL) { * printf("%d bytes key at $p\n", klen, key); * printf("%d bytes value at $p\n", vlen, value); * } */ unsigned char *zipmapNext(unsigned char *zm, unsigned char **key, unsigned int *klen, unsigned char **value, unsigned int *vlen) { if (zm[0] == ZIPMAP_END) return NULL; if (key) { *key = zm; *klen = zipmapDecodeLength(zm); *key += ZIPMAP_LEN_BYTES(*klen); } zm += zipmapRawKeyLength(zm); if (value) { *value = zm+1; *vlen = zipmapDecodeLength(zm); *value += ZIPMAP_LEN_BYTES(*vlen); } zm += <API key>(zm); return zm; } /* Search a key and retrieve the pointer and len of the associated value. * If the key is found the function returns 1, otherwise 0. */ /* * key value value * 1 0 */ int zipmapGet(unsigned char *zm, unsigned char *key, unsigned int klen, unsigned char **value, unsigned int *vlen) { unsigned char *p; if ((p = zipmapLookupRaw(zm,key,klen,NULL)) == NULL) return 0; p += zipmapRawKeyLength(p); *vlen = zipmapDecodeLength(p); *value = p + ZIPMAP_LEN_BYTES(*vlen) + 1; return 1; } /* * key zipmap 1 0 */ int zipmapExists(unsigned char *zm, unsigned char *key, unsigned int klen) { return zipmapLookupRaw(zm,key,klen,NULL) != NULL; } /* * zipmap */ unsigned int zipmapLen(unsigned char *zm) { unsigned int len = 0; if (zm[0] < ZIPMAP_BIGLEN) { len = zm[0]; } else { unsigned char *p = zipmapRewind(zm); while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) len++; /* Re-store length if small enough */ if (len < ZIPMAP_BIGLEN) zm[0] = len; } return len; } /* Return the raw size in bytes of a zipmap, so that we can serialize * the zipmap on disk (or everywhere is needed) just writing the returned * amount of bytes of the C array starting at the zipmap pointer. */ /* * zipmap */ size_t zipmapBlobLen(unsigned char *zm) { unsigned int totlen; zipmapLookupRaw(zm,NULL,0,&totlen); return totlen; } #ifdef ZIPMAP_TEST_MAIN void zipmapRepr(unsigned char *p) { unsigned int l; printf("{status %u}",*p++); while(1) { if (p[0] == ZIPMAP_END) { printf("{end}"); break; } else { unsigned char e; l = zipmapDecodeLength(p); printf("{key %u}",l); p += zipmapEncodeLength(NULL,l); if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); p += l; l = zipmapDecodeLength(p); printf("{value %u}",l); p += zipmapEncodeLength(NULL,l); e = *p++; if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); p += l+e; if (e) { printf("["); while(e--) printf("."); printf("]"); } } } printf("\n"); } int main(void) { unsigned char *zm; zm = zipmapNew(); zm = zipmapSet(zm,(unsigned char*) "name",4, (unsigned char*) "foo",3,NULL); zm = zipmapSet(zm,(unsigned char*) "surname",7, (unsigned char*) "foo",3,NULL); zm = zipmapSet(zm,(unsigned char*) "age",3, (unsigned char*) "foo",3,NULL); zipmapRepr(zm); zm = zipmapSet(zm,(unsigned char*) "hello",5, (unsigned char*) "world!",6,NULL); zm = zipmapSet(zm,(unsigned char*) "foo",3, (unsigned char*) "bar",3,NULL); zm = zipmapSet(zm,(unsigned char*) "foo",3, (unsigned char*) "!",1,NULL); zipmapRepr(zm); zm = zipmapSet(zm,(unsigned char*) "foo",3, (unsigned char*) "12345",5,NULL); zipmapRepr(zm); zm = zipmapSet(zm,(unsigned char*) "new",3, (unsigned char*) "xx",2,NULL); zm = zipmapSet(zm,(unsigned char*) "noval",5, (unsigned char*) "",0,NULL); zipmapRepr(zm); zm = zipmapDel(zm,(unsigned char*) "new",3,NULL); zipmapRepr(zm); printf("\nLook up large key:\n"); { unsigned char buf[512]; unsigned char *value; unsigned int vlen, i; for (i = 0; i < 512; i++) buf[i] = 'a'; zm = zipmapSet(zm,buf,512,(unsigned char*) "long",4,NULL); if (zipmapGet(zm,buf,512,&value,&vlen)) { printf(" <long key> is associated to the %d bytes value: %.*s\n", vlen, vlen, value); } } printf("\nPerform a direct lookup:\n"); { unsigned char *value; unsigned int vlen; if (zipmapGet(zm,(unsigned char*) "foo",3,&value,&vlen)) { printf(" foo is associated to the %d bytes value: %.*s\n", vlen, vlen, value); } } printf("\nIterate through elements:\n"); { unsigned char *i = zipmapRewind(zm); unsigned char *key, *value; unsigned int klen, vlen; while((i = zipmapNext(i,&key,&klen,&value,&vlen)) != NULL) { printf(" %d:%.*s => %d:%.*s\n", klen, klen, key, vlen, vlen, value); } } return 0; } #endif
<?php // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('VmController'))require(VMPATH_ADMIN.DS.'helpers'.DS.'vmcontroller.php'); /** * Configuration Controller * * @package VirtueMart * @subpackage Config */ class <API key> extends VmController { /** * Method to display the view * * @access public */ function __construct() { VmConfig::loadJLang('<API key>'); parent::__construct(); } /** * Handle the save task */ function save($data = 0){ vRequest::vmCheckToken(); $model = VmModel::getModel('config'); $data = vRequest::getPost(); if(strpos($data['offline_message'],'|')!==false){ $data['offline_message'] = str_replace('|','',$data['offline_message']); } $msg = ''; if ($model->store($data)) { $msg = vmText::_('<API key>'); // Load the newly saved values into the session. VmConfig::loadConfig(); } $redir = 'index.php?option=com_virtuemart'; if(vRequest::getCmd('task') == 'apply'){ $redir = $this->redirectPath; } $this->setRedirect($redir, $msg); } /** * Overwrite the remove task * Removing config is forbidden. * @author Max Milbers */ function remove(){ $msg = vmText::_('<API key>'); $this->setRedirect( $this->redirectPath , $msg); } } //pure php no tag
package java.lang; /** * Thrown when an exceptional arithmetic condition has occurred. For * example, an integer "divide by zero" throws an * instance of this class. * * {@code ArithmeticException} objects may be constructed by the * virtual machine as if {@linkplain Throwable#Throwable(String, * Throwable, boolean, boolean) suppression were disabled and/or the * stack trace was not writable}. * * @author unascribed * @since 1.0 */ public class ArithmeticException extends RuntimeException { private static final long serialVersionUID = <API key>; /** * Constructs an {@code ArithmeticException} with no detail * message. */ public ArithmeticException() { super(); } /** * Constructs an {@code ArithmeticException} with the specified * detail message. * * @param s the detail message. */ public ArithmeticException(String s) { super(s); } }
#include "chrome/browser/extensions/api/<API key>/<API key>.h" #include "base/basictypes.h" #include "base/bind.h" #include "base/files/file_path.h" #include "base/lazy_instance.h" #include "base/location.h" #include "base/prefs/pref_service.h" #include "base/strings/<API key>.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/api/<API key>/<API key>.h" #include "chrome/browser/extensions/api/<API key>/<API key>.h" #include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/media_galleries/<API key>.h" #include "chrome/browser/media_galleries/<API key>.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/storage_monitor/storage_monitor.h" #include "chrome/common/extensions/api/<API key>/<API key>.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_function.h" using base::DictionaryValue; using base::ListValue; namespace extensions { namespace AddGalleryWatch = extensions::api::<API key>::AddGalleryWatch; namespace RemoveGalleryWatch = extensions::api::<API key>::RemoveGalleryWatch; namespace GetAllGalleryWatch = extensions::api::<API key>::GetAllGalleryWatch; namespace <API key> = api::<API key>; namespace { const char <API key>[] = "Invalid gallery ID"; // Handles the profile shutdown event on the file thread to clean up // GalleryWatchManager. void <API key>(void* profile_id) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); GalleryWatchManager::OnProfileShutdown(profile_id); } // Gets the |gallery_file_path| and |gallery_pref_id| of the gallery specified // by the |gallery_id|. Returns true and set |gallery_file_path| and // |gallery_pref_id| if the |gallery_id| is valid and returns false otherwise. bool <API key>(const std::string& gallery_id, Profile* profile, const Extension* extension, base::FilePath* gallery_file_path, MediaGalleryPrefId* gallery_pref_id) { MediaGalleryPrefId pref_id; if (!base::StringToUint64(gallery_id, &pref_id)) return false; <API key>* preferences = g_browser_process-><API key>()->GetPreferences(profile); base::FilePath file_path( preferences-><API key>(pref_id, extension, false)); if (file_path.empty()) return false; *gallery_pref_id = pref_id; *gallery_file_path = file_path; return true; } } // namespace // <API key> // <API key>::<API key>(Profile* profile) : profile_(profile), weak_ptr_factory_(this) { DCHECK(profile_); ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( this, <API key>::OnDeviceAttached::kEventName); ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( this, <API key>::OnDeviceDetached::kEventName); ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( this, <API key>::OnGalleryChanged::kEventName); } <API key>::~<API key>() { } void <API key>::Shutdown() { ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); weak_ptr_factory_.InvalidateWeakPtrs(); content::BrowserThread::PostTask( content::BrowserThread::FILE, FROM_HERE, base::Bind(&<API key>, profile_)); } static base::LazyInstance<<API key><<API key>> > g_factory = <API key>; // static <API key><<API key>>* <API key>::GetFactoryInstance() { return &g_factory.Get(); } // static <API key>* <API key>::Get(Profile* profile) { return <API key><<API key>>::GetForProfile(profile); } void <API key>::OnListenerAdded( const EventListenerInfo& details) { // Make sure <API key> is initialized. After that, // try to initialize the event router for the listener. // This method is called synchronously with the message handler for the // JS invocation. <API key>* preferences = g_browser_process-><API key>()->GetPreferences(profile_); preferences->EnsureInitialized(base::Bind( &<API key>::<API key>, weak_ptr_factory_.GetWeakPtr())); } <API key>* <API key>::GetEventRouter() { <API key>(); return <API key>.get(); } <API key>* <API key>::<API key>() { <API key>(); return tracker_.get(); } void <API key>::<API key>() { if (<API key>.get()) return; <API key>.reset( new <API key>(profile_)); DCHECK(g_browser_process-><API key>()-> GetPreferences(profile_)->IsInitialized()); tracker_.reset( new <API key>(profile_)); } // <API key> // <API key>:: ~<API key>() { } bool <API key>::RunImpl() { DCHECK(GetProfile()); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (!render_view_host() || !render_view_host()->GetProcess()) return false; scoped_ptr<AddGalleryWatch::Params> params( AddGalleryWatch::Params::Create(*args_)); <API key>(params.get()); <API key>* preferences = g_browser_process-><API key>()->GetPreferences( GetProfile()); preferences->EnsureInitialized(base::Bind( &<API key>::OnPreferencesInit, this, params->gallery_id)); return true; } void <API key>::OnPreferencesInit( const std::string& pref_id) { base::FilePath gallery_file_path; MediaGalleryPrefId gallery_pref_id = 0; if (!<API key>(pref_id, GetProfile(), GetExtension(), &gallery_file_path, &gallery_pref_id)) { error_ = <API key>; HandleResponse(gallery_pref_id, false); return; } #if defined(OS_WIN) <API key>* router = <API key>::Get(GetProfile())->GetEventRouter(); DCHECK(router); content::BrowserThread::<API key>( content::BrowserThread::FILE, FROM_HERE, base::Bind(&GalleryWatchManager::SetupGalleryWatch, GetProfile(), gallery_pref_id, gallery_file_path, extension_id(), router->AsWeakPtr()), base::Bind(&<API key>::HandleResponse, this, gallery_pref_id)); #else // Recursive gallery watch operation is not currently supported on // non-windows platforms. Please refer to crbug.com/144491 for more details. HandleResponse(gallery_pref_id, false); #endif } void <API key>::HandleResponse( MediaGalleryPrefId gallery_id, bool success) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); <API key>::<API key> result; result.gallery_id = base::Uint64ToString(gallery_id); result.success = success; SetResult(result.ToValue().release()); if (success) { DCHECK(g_browser_process-><API key>() ->GetPreferences(GetProfile()) ->IsInitialized()); <API key>* state_tracker = <API key>::Get( GetProfile())-><API key>(); state_tracker->OnGalleryWatchAdded(extension_id(), gallery_id); } SendResponse(true); } // <API key> // <API key>:: ~<API key>() { } bool <API key>::RunImpl() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (!render_view_host() || !render_view_host()->GetProcess()) return false; // Remove gallery watch operation is currently supported on windows platforms. // Please refer to crbug.com/144491 for more details. scoped_ptr<RemoveGalleryWatch::Params> params( RemoveGalleryWatch::Params::Create(*args_)); <API key>(params.get()); <API key>* preferences = g_browser_process-><API key>()->GetPreferences( GetProfile()); preferences->EnsureInitialized(base::Bind( &<API key>::OnPreferencesInit, this, params->gallery_id)); return true; } void <API key>::OnPreferencesInit( const std::string& pref_id) { #if defined(OS_WIN) base::FilePath gallery_file_path; MediaGalleryPrefId gallery_pref_id = 0; if (!<API key>(pref_id, GetProfile(), GetExtension(), &gallery_file_path, &gallery_pref_id)) { error_ = <API key>; SendResponse(false); return; } content::BrowserThread::PostTask( content::BrowserThread::FILE, FROM_HERE, base::Bind(&GalleryWatchManager::RemoveGalleryWatch, GetProfile(), gallery_file_path, extension_id())); <API key>* state_tracker = <API key>::Get( GetProfile())-><API key>(); state_tracker-><API key>(extension_id(), gallery_pref_id); #endif SendResponse(true); } // <API key> // <API key>:: ~<API key>() { } bool <API key>::RunImpl() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (!render_view_host() || !render_view_host()->GetProcess()) return false; <API key>* preferences = g_browser_process-><API key>()->GetPreferences( GetProfile()); preferences->EnsureInitialized(base::Bind( &<API key>::OnPreferencesInit, this)); return true; } void <API key>::OnPreferencesInit() { std::vector<std::string> result; #if defined(OS_WIN) <API key>* state_tracker = <API key>::Get( GetProfile())-><API key>(); <API key> gallery_ids = state_tracker-><API key>(extension_id()); for (<API key>::const_iterator iter = gallery_ids.begin(); iter != gallery_ids.end(); ++iter) { result.push_back(base::Uint64ToString(*iter)); } #endif results_ = GetAllGalleryWatch::Results::Create(result); SendResponse(true); } // <API key> // <API key>:: ~<API key>() { } bool <API key>::RunImpl() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (!render_view_host() || !render_view_host()->GetProcess()) return false; <API key>* preferences = g_browser_process-><API key>()->GetPreferences( GetProfile()); preferences->EnsureInitialized(base::Bind( &<API key>::OnPreferencesInit, this)); return true; } void <API key>::OnPreferencesInit() { #if defined(OS_WIN) <API key>* preferences = g_browser_process-><API key>()->GetPreferences( GetProfile()); <API key>* state_tracker = <API key>::Get( GetProfile())-><API key>(); state_tracker-><API key>( extension_id(), preferences); #endif SendResponse(true); } // <API key> // <API key>:: ~<API key>() { } bool <API key>::RunImpl() { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); ExtensionService* service = extensions::ExtensionSystem::Get(GetProfile())->extension_service(); DCHECK(service); ListValue* result_list = new ListValue; for (ExtensionSet::const_iterator iter = service->extensions()->begin(); iter != service->extensions()->end(); ++iter) { const Extension* extension = iter->get(); if (GetProfile()->IsOffTheRecord() && !extension_util::IsIncognitoEnabled(extension->id(), service)) continue; <API key>::List* handler_list = <API key>::GetHandlers(extension); if (!handler_list) continue; for (<API key>::List::const_iterator action_iter = handler_list->begin(); action_iter != handler_list->end(); ++action_iter) { const <API key>* action = action_iter->get(); DictionaryValue* handler = new DictionaryValue; handler->SetString("extensionId", action->extension_id()); handler->SetString("id", action->id()); handler->SetString("title", action->title()); handler->SetString("iconUrl", action->icon_path()); result_list->Append(handler); } } SetResult(result_list); SendResponse(true); return true; } } // namespace extensions
/** @file null_m.h Base for the silent music playback. */ #ifndef MUSIC_NULL_H #define MUSIC_NULL_H #include "music_driver.hpp" /** The music player that does nothing. */ class MusicDriver_Null : public MusicDriver { public: /* virtual */ const char *Start(const char * const *param) { return NULL; } /* virtual */ void Stop() { } /* virtual */ void PlaySong(const char *filename) { } /* virtual */ void StopSong() { } /* virtual */ bool IsSongPlaying() { return true; } /* virtual */ void SetVolume(byte vol) { } /* virtual */ const char *GetName() const { return "null"; } }; /** Factory for the null music player. */ class FMusicDriver_Null : public DriverFactoryBase { public: FMusicDriver_Null() : DriverFactoryBase(Driver::DT_MUSIC, 1, "null", "Null Music Driver") {} /* virtual */ Driver *CreateInstance() const { return new MusicDriver_Null(); } }; #endif /* MUSIC_NULL_H */
package org.wordpress.android; import org.wordpress.android.mocks.O<API key>; import org.wordpress.android.mocks.<API key>; import org.wordpress.android.mocks.<API key>; import org.wordpress.android.mocks.XMLRPCFactoryTest; import org.wordpress.android.networking.O<API key>; import org.wordpress.android.networking.RestClientFactory; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.<API key>; import org.xmlrpc.android.XMLRPCFactory; import java.lang.reflect.Field; public class FactoryUtils { public static void <API key>() { // create test factories <API key>(XMLRPCFactory.class, new XMLRPCFactoryTest()); <API key>(RestClientFactory.class, new <API key>()); <API key>(O<API key>.class, new O<API key>()); <API key>(<API key>.class, new <API key>()); AppLog.v(T.TESTS, "Mocks factories instantiated"); } private static void <API key>(Class klass, Object factory) { try { Field field = klass.getDeclaredField("sFactory"); field.setAccessible(true); field.set(null, factory); AppLog.v(T.TESTS, "Factory " + klass + " injected"); } catch (Exception e) { AppLog.e(T.TESTS, "Can't inject test factory " + klass); } } }
#include <linux/delay.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/poll.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/sysfs.h> #ifdef <API key> #include <linux/earlysuspend.h> #endif #include <linux/iio/buffer.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/iio/kfifo_buf.h> #include <linux/iio/trigger.h> #include <linux/iio/trigger_consumer.h> #include <linux/irq_work.h> #include "yas.h" #include <linux/of_gpio.h> #include <linux/regulator/consumer.h> #if YAS_MAG_DRIVER == <API key> \ || YAS_MAG_DRIVER == <API key> #define YAS532_REG_DEVID (0x80) #define YAS532_REG_RCOILR (0x81) #define YAS532_REG_CMDR (0x82) #define YAS532_REG_CONFR (0x83) #define YAS532_REG_DLYR (0x84) #define YAS532_REG_OXR (0x85) #define YAS532_REG_OY1R (0x86) #define YAS532_REG_OY2R (0x87) #define YAS532_REG_TEST1R (0x88) #define YAS532_REG_TEST2R (0x89) #define YAS532_REG_CALR (0x90) #define YAS532_REG_DATAR (0xB0) #define <API key> (850) #define <API key> (750) #define <API key> (750) #define YAS532_DATA_CENTER (4096) #define <API key> (0) #define <API key> (8190) #define YAS532_DEVICE_ID (0x02) /* YAS532 (MS-3R/3F) */ #define <API key> (390) #define YAS_X_OVERFLOW (0x01) #define YAS_X_UNDERFLOW (0x02) #define YAS_Y1_OVERFLOW (0x04) #define YAS_Y1_UNDERFLOW (0x08) #define YAS_Y2_OVERFLOW (0x10) #define YAS_Y2_UNDERFLOW (0x20) #define YAS_OVERFLOW (YAS_X_OVERFLOW|YAS_Y1_OVERFLOW|YAS_Y2_OVERFLOW) #define YAS_UNDERFLOW (YAS_X_UNDERFLOW|YAS_Y1_UNDERFLOW|YAS_Y2_UNDERFLOW) #define <API key> (0) #define <API key> (1) #define <API key> (2) #define <API key> (1000) /* msec */ #define <API key> (10) #define <API key> (3) #if <API key> #define <API key> (1000) #endif #define <API key> 64 #define CHECK_RANGE(X, MIN, MAX) (X>=MIN && X<=MAX)?1:0 #define CHECK_GREATER(X, MIN) (X>=MIN)?1:0 #define set_vector(to, from) \ {int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; } #define is_valid_offset(a) \ (((a)[0] <= 31) && ((a)[1] <= 31) && ((a)[2] <= 31) \ && (-31 <= (a)[0]) && (-31 <= (a)[1]) && (-31 <= (a)[2])) struct yas_cal_data { int8_t rxy1y2[3]; uint8_t fxy1y2[3]; int32_t Cx, Cy1, Cy2; int32_t a2, a3, a4, a5, a6, a7, a8, a9, k; }; #if 1 < <API key> struct <API key> { uint16_t log[<API key>]; int num; int idx; }; #endif struct yas_cdriver { int initialized; struct yas_cal_data cal; struct yas_driver_callback cbk; int measure_state; int8_t hard_offset[3]; int32_t coef[3]; int overflow; uint32_t overflow_time; int position; int delay; int enable; uint8_t dev_id; const int8_t *transform; #if 1 < <API key> struct <API key> t; #endif uint32_t current_time; uint16_t last_raw[4]; #if <API key> int start_flag; int wait_flag; #endif }; struct yas_platform_data { int placement; int intr; }; static const int <API key>[] = {<API key>, <API key>, <API key>}; static const int8_t INVALID_OFFSET[] = {0x7f, 0x7f, 0x7f}; static const int8_t <API key>[][9] = { { 0, 1, 0, -1, 0, 0, 0, 0, 1 }, {-1, 0, 0, 0, -1, 0, 0, 0, 1 }, { 0, -1, 0, 1, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 1, 0, 0, 0, 1 }, { 0, -1, 0, -1, 0, 0, 0, 0, -1 }, { 1, 0, 0, 0, -1, 0, 0, 0, -1 }, { 0, 1, 0, 1, 0, 0, 0, 0, -1 }, {-1, 0, 0, 0, 1, 0, 0, 0, -1 }, }; static struct yas_cdriver driver; #define yas_read(a, b, c) \ (driver.cbk.device_read(YAS_TYPE_MAG, (a), (b), (c))) static int yas_single_write(uint8_t addr, uint8_t data) { return driver.cbk.device_write(YAS_TYPE_MAG, addr, &data, 1); } static uint32_t curtime(void) { if (driver.cbk.current_time) return driver.cbk.current_time(); else return driver.current_time; } static void xy1y2_to_linear(uint16_t *xy1y2, int32_t *xy1y2_linear) { static const uint16_t cval[] = {3721, 3971, 4221, 4471}; int i; for (i = 0; i < 3; i++) xy1y2_linear[i] = xy1y2[i] - cval[driver.cal.fxy1y2[i]] + (driver.hard_offset[i] - driver.cal.rxy1y2[i]) * driver.coef[i]; } static int get_cal_data_yas532(struct yas_cal_data *c) { uint8_t data[14]; int i; if (yas_read(YAS532_REG_CALR, data, 14) < 0) return <API key>; if (yas_read(YAS532_REG_CALR, data, 14) < 0) return <API key>; c->fxy1y2[0] = (uint8_t)(((data[10]&0x01)<<1) | ((data[11]>>7)&0x01)); c->rxy1y2[0] = ((int8_t)(((data[10]>>1) & 0x3f)<<2))>>2; c->fxy1y2[1] = (uint8_t)(((data[11]&0x01)<<1) | ((data[12]>>7)&0x01)); c->rxy1y2[1] = ((int8_t)(((data[11]>>1) & 0x3f)<<2))>>2; c->fxy1y2[2] = (uint8_t)(((data[12]&0x01)<<1) | ((data[13]>>7)&0x01)); c->rxy1y2[2] = ((int8_t)(((data[12]>>1) & 0x3f)<<2))>>2; c->Cx = data[0] * 10 - 1280; c->Cy1 = data[1] * 10 - 1280; c->Cy2 = data[2] * 10 - 1280; c->a2 = ((data[3]>>2)&0x03f) - 32; c->a3 = (uint8_t)(((data[3]<<2) & 0x0c) | ((data[4]>>6) & 0x03)) - 8; c->a4 = (uint8_t)(data[4] & 0x3f) - 32; c->a5 = ((data[5]>>2) & 0x3f) + 38; c->a6 = (uint8_t)(((data[5]<<4) & 0x30) | ((data[6]>>4) & 0x0f)) - 32; c->a7 = (uint8_t)(((data[6]<<3) & 0x78) | ((data[7]>>5) & 0x07)) - 64; c->a8 = (uint8_t)(((data[7]<<1) & 0x3e) | ((data[8]>>7) & 0x01)) - 32; c->a9 = (uint8_t)(((data[8]<<1) & 0xfe) | ((data[9]>>7) & 0x01)); c->k = (uint8_t)((data[9]>>2) & 0x1f); for (i = 0; i < 13; i++) if (data[i] != 0) return YAS_NO_ERROR; if (data[13] & 0x80) return YAS_NO_ERROR; return YAS_ERROR_CALREG; } #if <API key> static int busy_wait(void) { int i; uint8_t busy; for (i = 0; i < <API key>; i++) { if (yas_read(YAS532_REG_DATAR, &busy, 1) < 0) return <API key>; if (!(busy & 0x80)) return YAS_NO_ERROR; } return YAS_ERROR_BUSY; } static int wait_if_busy(void) { int rt; if (driver.start_flag && driver.wait_flag) { rt = busy_wait(); if (rt < 0) return rt; driver.wait_flag = 0; } return YAS_NO_ERROR; } #endif static int <API key>(int ldtc, int fors, int wait) { uint8_t data = 0x01; data = (uint8_t)(data | (((!!ldtc)<<1) & 0x02)); data = (uint8_t)(data | (((!!fors)<<2) & 0x04)); if (yas_single_write(YAS532_REG_CMDR, data) < 0) return <API key>; #if <API key> if (wait) { int rt; rt = busy_wait(); if (rt < 0) return rt; driver.wait_flag = 0; } else driver.wait_flag = 1; driver.start_flag = 1; #else (void) wait; driver.cbk.usleep(1500); #endif return YAS_NO_ERROR; } static int <API key>(int ldtc, int fors, int *busy, uint16_t *t, uint16_t *xy1y2, int *ouflow) { uint8_t data[8]; int i, rt; #if <API key> if (!driver.start_flag) { #endif rt = <API key>(ldtc, fors, 1); if (rt < 0) return rt; #if <API key> } #endif if (yas_read(YAS532_REG_DATAR, data, 8) < 0) return <API key>; #if <API key> driver.start_flag = 0; #endif *busy = (data[0]>>7) & 0x01; *t = (uint16_t)((((int32_t)data[0]<<3) & 0x3f8)|((data[1]>>5) & 0x07)); xy1y2[0] = (uint16_t)((((int32_t)data[2]<<6) & 0x1fc0) | ((data[3]>>2) & 0x3f)); xy1y2[1] = (uint16_t)((((int32_t)data[4]<<6) & 0x1fc0) | ((data[5]>>2) & 0x3f)); xy1y2[2] = (uint16_t)((((int32_t)data[6]<<6) & 0x1fc0) | ((data[7]>>2) & 0x3f)); *ouflow = 0; for (i = 0; i < 3; i++) { if (xy1y2[i] == <API key>) *ouflow |= (1<<(i*2)); if (xy1y2[i] == <API key>) *ouflow |= (1<<(i*2+1)); } return YAS_NO_ERROR; } static int yas_cdrv_set_offset(const int8_t *offset) { if (yas_single_write(YAS532_REG_OXR, (uint8_t)offset[0]) < 0) return <API key>; if (yas_single_write(YAS532_REG_OY1R, (uint8_t)offset[1]) < 0) return <API key>; if (yas_single_write(YAS532_REG_OY2R, (uint8_t)offset[2]) < 0) return <API key>; set_vector(driver.hard_offset, offset); return YAS_NO_ERROR; } static int <API key>(void) { static const int correct[5] = {16, 8, 4, 2, 1}; int8_t hard_offset[3] = {0, 0, 0}; uint16_t t, xy1y2[3]; int32_t flag[3]; int i, j, busy, ouflow, rt; #if <API key> driver.start_flag = 0; #endif for (i = 0; i < 5; i++) { rt = yas_cdrv_set_offset(hard_offset); if (rt < 0) return rt; rt = <API key>(0, 0, &busy, &t, xy1y2, &ouflow); if (rt < 0) return rt; if (busy) return YAS_ERROR_BUSY; for (j = 0; j < 3; j++) { if (YAS532_DATA_CENTER == xy1y2[j]) flag[j] = 0; if (YAS532_DATA_CENTER < xy1y2[j]) flag[j] = 1; if (xy1y2[j] < YAS532_DATA_CENTER) flag[j] = -1; } for (j = 0; j < 3; j++) if (flag[j]) hard_offset[j] = (int8_t)(hard_offset[j] + flag[j] * correct[i]); } return yas_cdrv_set_offset(hard_offset); } static int <API key>(int32_t *sx, int32_t *sy) { struct yas_cal_data *c = &driver.cal; uint16_t xy1y2_on[3], xy1y2_off[3], t; int busy, flowon = 0, flowoff = 0; if (<API key>(1, 0, &busy, &t, xy1y2_on, &flowon) < 0) return <API key>; if (busy) return YAS_ERROR_BUSY; if (<API key>(1, 1, &busy, &t, xy1y2_off, &flowoff) < 0) return <API key>; if (busy) return YAS_ERROR_BUSY; *sx = c->k * (xy1y2_on[0] - xy1y2_off[0]) * 10 / YAS_MAG_VCORE; *sy = c->k * c->a5 * ((xy1y2_on[1] - xy1y2_off[1]) - (xy1y2_on[2] - xy1y2_off[2])) / 10 / YAS_MAG_VCORE; return flowon | flowoff; } static int yas_get_position(void) { if (!driver.initialized) return <API key>; return driver.position; } static int yas_set_position(int position) { if (!driver.initialized) return <API key>; if (position < 0 || 7 < position) return YAS_ERROR_ARG; if (position == <API key>) driver.transform = NULL; else driver.transform = <API key>[position]; driver.position = position; return YAS_NO_ERROR; } static int yas_set_offset(const int8_t *hard_offset) { if (!driver.enable) { set_vector(driver.hard_offset, hard_offset); return YAS_NO_ERROR; } if (is_valid_offset(hard_offset)) { #if <API key> int rt; rt = wait_if_busy(); if (rt < 0) return rt; #endif if (yas_cdrv_set_offset(hard_offset) < 0) return <API key>; driver.measure_state = <API key>; } else { set_vector(driver.hard_offset, INVALID_OFFSET); driver.measure_state = <API key>; } return YAS_NO_ERROR; } static int yas_measure(struct yas_data *data, int num, int temp_correction, int *ouflow) { struct yas_cal_data *c = &driver.cal; int32_t xy1y2_linear[3]; int32_t xyz_tmp[3], tmp; int32_t sx, sy1, sy2, sy, sz; int i, busy; uint16_t t, xy1y2[3]; uint32_t tm; int rt; #if 1 < <API key> int32_t sum = 0; #endif *ouflow = 0; if (!driver.initialized) return <API key>; if (data == NULL || num < 0) return YAS_ERROR_ARG; if (driver.cbk.current_time == NULL) driver.current_time += (uint32_t)driver.delay; if (num == 0) return 0; if (!driver.enable) return 0; switch (driver.measure_state) { case <API key>: tm = curtime(); if (tm - driver.overflow_time < <API key>) break; driver.overflow_time = tm; if (yas_single_write(YAS532_REG_RCOILR, 0x00) < 0) return <API key>; if (!driver.overflow && is_valid_offset(driver.hard_offset)) { driver.measure_state = <API key>; break; } /* FALLTHRU */ case <API key>: rt = <API key>(); if (rt < 0) return rt; driver.measure_state = <API key>; break; } if (<API key>(0, 0, &busy, &t, xy1y2, ouflow) < 0) return <API key>; xy1y2_to_linear(xy1y2, xy1y2_linear); #if 1 < <API key> driver.t.log[driver.t.idx++] = t; if (<API key> <= driver.t.idx) driver.t.idx = 0; driver.t.num++; if (<API key> <= driver.t.num) driver.t.num = <API key>; for (i = 0; i < driver.t.num; i++) sum += driver.t.log[i]; tmp = sum * 10 / driver.t.num - <API key> * 10; #else tmp = (t - <API key>) * 10; #endif sx = xy1y2_linear[0]; sy1 = xy1y2_linear[1]; sy2 = xy1y2_linear[2]; if (temp_correction) { sx -= (c->Cx * tmp) / 1000; sy1 -= (c->Cy1 * tmp) / 1000; sy2 -= (c->Cy2 * tmp) / 1000; } sy = sy1 - sy2; sz = -sy1 - sy2; data->xyz.v[0] = c->k * ((100 * sx + c->a2 * sy + c->a3 * sz) / 10); data->xyz.v[1] = c->k * ((c->a4 * sx + c->a5 * sy + c->a6 * sz) / 10); data->xyz.v[2] = c->k * ((c->a7 * sx + c->a8 * sy + c->a9 * sz) / 10); if (driver.transform != NULL) { for (i = 0; i < 3; i++) { xyz_tmp[i] = driver.transform[i*3] * data->xyz.v[0] + driver.transform[i*3+1] * data->xyz.v[1] + driver.transform[i*3+2] * data->xyz.v[2]; } set_vector(data->xyz.v, xyz_tmp); } for (i = 0; i < 3; i++) { data->xyz.v[i] -= data->xyz.v[i] % 10; if (*ouflow & (1<<(i*2))) data->xyz.v[i] += 1; /* set overflow */ if (*ouflow & (1<<(i*2+1))) data->xyz.v[i] += 2; /* set underflow */ } tm = curtime(); data->type = YAS_TYPE_MAG; if (driver.cbk.current_time) data->timestamp = tm; else data->timestamp = 0; data->accuracy = 0; if (busy) return YAS_ERROR_BUSY; if (0 < *ouflow) { if (!driver.overflow) driver.overflow_time = tm; driver.overflow = 1; driver.measure_state = <API key>; } else driver.overflow = 0; for (i = 0; i < 3; i++) driver.last_raw[i] = xy1y2[i]; driver.last_raw[i] = t; #if <API key> rt = <API key>(0, 0, 0); if (rt < 0) return rt; #endif return 1; } static int yas_measure_wrap(struct yas_data *data, int num) { int ouflow; return yas_measure(data, num, 1, &ouflow); } static int yas_get_delay(void) { if (!driver.initialized) return <API key>; return driver.delay; } static int yas_set_delay(int delay) { if (!driver.initialized) return <API key>; if (delay < 0) return YAS_ERROR_ARG; driver.delay = delay; return YAS_NO_ERROR; } static int yas_get_enable(void) { if (!driver.initialized) return <API key>; return driver.enable; } static int yas_set_enable(int enable) { int rt = YAS_NO_ERROR; if (!driver.initialized) return <API key>; enable = !!enable; if (driver.enable == enable) return YAS_NO_ERROR; if (enable) { if (driver.cbk.device_open(YAS_TYPE_MAG) < 0) return <API key>; if (yas_single_write(YAS532_REG_TEST1R, 0x00) < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return <API key>; } if (yas_single_write(YAS532_REG_TEST2R, 0x00) < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return <API key>; } if (yas_single_write(YAS532_REG_RCOILR, 0x00) < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return <API key>; } if (is_valid_offset(driver.hard_offset)) { if (yas_cdrv_set_offset(driver.hard_offset) < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return <API key>; } driver.measure_state = <API key>; } else { set_vector(driver.hard_offset, INVALID_OFFSET); driver.measure_state = <API key>; } } else { #if <API key> rt = wait_if_busy(); #endif driver.cbk.device_close(YAS_TYPE_MAG); } driver.enable = enable; return rt; } static int yas_ext(int32_t cmd, void *p) { struct <API key> *r; struct yas_data data; int32_t xy1y2_linear[3], *raw_xyz; int rt, i, enable, ouflow; if (!driver.initialized) return <API key>; if (p == NULL) return YAS_ERROR_ARG; switch (cmd) { case YAS532_SELF_TEST: r = (struct <API key> *) p; r->id = driver.dev_id; enable = driver.enable; if (!enable) { rt = yas_set_enable(1); if (rt < 0) return rt; } #if <API key> rt = wait_if_busy(); if (rt < 0) return rt; #endif if (yas_single_write(YAS532_REG_RCOILR, 0x00) < 0) { if (!enable) yas_set_enable(0); return <API key>; } yas_set_offset(INVALID_OFFSET); rt = yas_measure(&data, 1, 0, &ouflow); set_vector(r->xy1y2, driver.hard_offset); if (rt < 0) { if (!enable) yas_set_enable(0); return rt; } if (ouflow & YAS_OVERFLOW) { if (!enable) yas_set_enable(0); return YAS_ERROR_OVERFLOW; } if (ouflow & YAS_UNDERFLOW) { if (!enable) yas_set_enable(0); return YAS_ERROR_UNDERFLOW; } if (data.xyz.v[0] == 0 && data.xyz.v[1] == 0 && data.xyz.v[2] == 0) { if (!enable) yas_set_enable(0); return YAS_ERROR_DIRCALC; } r->dir = 99; for (i = 0; i < 3; i++) r->xyz[i] = data.xyz.v[i] / 1000; #if <API key> rt = wait_if_busy(); if (rt < 0) { if (!enable) yas_set_enable(0); return rt; } driver.start_flag = 0; #endif rt = <API key>(&r->sx, &r->sy); if (rt < 0) { if (!enable) yas_set_enable(0); return rt; } if (rt & YAS_OVERFLOW) { if (!enable) yas_set_enable(0); return YAS_ERROR_OVERFLOW; } if (rt & YAS_UNDERFLOW) { if (!enable) yas_set_enable(0); return YAS_ERROR_UNDERFLOW; } if (!enable) yas_set_enable(0); return YAS_NO_ERROR; case <API key>: raw_xyz = (int32_t *) p; enable = driver.enable; if (!enable) { rt = yas_set_enable(1); if (rt < 0) return rt; } #if <API key> rt = wait_if_busy(); if (rt < 0) return rt; #endif rt = yas_measure(&data, 1, 0, &ouflow); if (rt < 0) { if (!enable) yas_set_enable(0); return rt; } #if <API key> rt = wait_if_busy(); if (rt < 0) { if (!enable) yas_set_enable(0); return rt; } #endif xy1y2_to_linear(driver.last_raw, xy1y2_linear); raw_xyz[0] = xy1y2_linear[0]; raw_xyz[1] = xy1y2_linear[1] - xy1y2_linear[2]; raw_xyz[2] = -xy1y2_linear[1] - xy1y2_linear[2]; if (!enable) yas_set_enable(0); return YAS_NO_ERROR; case <API key>: set_vector((int8_t *) p, driver.hard_offset); return YAS_NO_ERROR; case <API key>: return yas_set_offset((int8_t *) p); case <API key>: for (i = 0; i < 4; i++) ((uint16_t *) p)[i] = driver.last_raw[i]; return YAS_NO_ERROR; default: break; } return YAS_ERROR_ARG; } static int yas_init(void) { int i, rt; uint8_t data; if (driver.initialized) return <API key>; if (driver.cbk.device_open(YAS_TYPE_MAG) < 0) return <API key>; if (yas_read(YAS532_REG_DEVID, &data, 1) < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return <API key>; } driver.dev_id = data; if (driver.dev_id != YAS532_DEVICE_ID) { driver.cbk.device_close(YAS_TYPE_MAG); return YAS_ERROR_CHIP_ID; } rt = get_cal_data_yas532(&driver.cal); if (rt < 0) { driver.cbk.device_close(YAS_TYPE_MAG); return rt; } driver.cbk.device_close(YAS_TYPE_MAG); driver.measure_state = <API key>; set_vector(driver.hard_offset, INVALID_OFFSET); driver.overflow = 0; driver.overflow_time = driver.current_time; driver.position = <API key>; driver.delay = <API key>; driver.enable = 0; driver.transform = NULL; #if <API key> driver.start_flag = 0; driver.wait_flag = 0; #endif #if 1 < <API key> driver.t.num = driver.t.idx = 0; #endif driver.current_time = curtime(); for (i = 0; i < 3; i++) { driver.coef[i] = <API key>[i]; driver.last_raw[i] = 0; } driver.last_raw[3] = 0; driver.initialized = 1; return YAS_NO_ERROR; } static int yas_term(void) { int rt; if (!driver.initialized) return <API key>; rt = yas_set_enable(0); driver.initialized = 0; return rt; } int yas_mag_driver_init(struct yas_mag_driver *f) { if (f == NULL || f->callback.device_open == NULL || f->callback.device_close == NULL || f->callback.device_read == NULL || f->callback.device_write == NULL #if !<API key> || f->callback.usleep == NULL #endif ) return YAS_ERROR_ARG; f->init = yas_init; f->term = yas_term; f->get_delay = yas_get_delay; f->set_delay = yas_set_delay; f->get_enable = yas_get_enable; f->set_enable = yas_set_enable; f->get_position = yas_get_position; f->set_position = yas_set_position; f->measure = yas_measure_wrap; f->ext = yas_ext; driver.cbk = f->callback; yas_term(); return YAS_NO_ERROR; } #endif static struct i2c_client *this_client; enum { YAS_SCAN_MAGN_X, YAS_SCAN_MAGN_Y, YAS_SCAN_MAGN_Z, YAS_SCAN_TIMESTAMP, }; struct yas_state { struct mutex lock; struct yas_mag_driver mag; struct i2c_client *client; struct iio_trigger *trig; struct delayed_work work; int16_t sampling_frequency; atomic_t pseudo_irq_enable; int32_t compass_data[3]; #ifdef <API key> struct early_suspend sus; #endif struct irq_work iio_irq_work; struct iio_dev *indio_dev; struct class *sensor_class; struct device *sensor_dev; u8 i2c_rdata; int intr; }; static struct yas_state *g_st; static int yas_device_open(int32_t type) { return 0; } static int yas_device_close(int32_t type) { return 0; } static int yas_device_write(int32_t type, uint8_t addr, const uint8_t *buf, int len) { uint8_t tmp[2]; if (sizeof(tmp) - 1 < len) return -1; tmp[0] = addr; memcpy(&tmp[1], buf, len); if (i2c_master_send(this_client, tmp, len + 1) < 0) return -1; return 0; } static int yas_device_read(int32_t type, uint8_t addr, uint8_t *buf, int len) { struct i2c_msg msg[2]; int err; msg[0].addr = this_client->addr; msg[0].flags = 0; msg[0].len = 1; msg[0].buf = &addr; msg[1].addr = this_client->addr; msg[1].flags = I2C_M_RD; msg[1].len = len; msg[1].buf = buf; err = i2c_transfer(this_client->adapter, msg, 2); if (err != 2) { dev_err(&this_client->dev, "i2c_transfer() read error: " "slave_addr=%02x, reg_addr=%02x, err=%d\n", this_client->addr, addr, err); return err; } return 0; } static void yas_usleep(int us) { usleep_range(us, us + 1000); } static uint32_t yas_current_time(void) { return jiffies_to_msecs(jiffies); } static int <API key>(struct iio_dev *indio_dev) { struct yas_state *st = iio_priv(indio_dev); if (!atomic_cmpxchg(&st->pseudo_irq_enable, 0, 1)) <API key>(&st->work, 0); return 0; } static int <API key>(struct iio_dev *indio_dev) { struct yas_state *st = iio_priv(indio_dev); if (atomic_cmpxchg(&st->pseudo_irq_enable, 1, 0)) <API key>(&st->work); return 0; } static int yas_set_pseudo_irq(struct iio_dev *indio_dev, int enable) { if (enable) <API key>(indio_dev); else <API key>(indio_dev); return 0; } static void iio_trigger_work(struct irq_work *work) { struct yas_state *st = g_st; iio_trigger_poll(st->trig, iio_get_time_ns()); } static irqreturn_t yas_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct yas_state *st = iio_priv(indio_dev); int len = 0, i, j; int32_t *mag; mag = (int32_t *)kmalloc(indio_dev->scan_bytes, GFP_KERNEL); if (mag == NULL) { dev_err(indio_dev->dev.parent, "memory alloc failed in buffer bh"); goto done; } if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) { j = 0; for (i = 0; i < 3; i++) { if (test_bit(i, indio_dev->active_scan_mask)) { mag[j] = st->compass_data[i]; j++; } } len = j * 4; } if (indio_dev->scan_timestamp) *(s64 *)((u8 *)mag + ALIGN(len, sizeof(s64))) = pf->timestamp; iio_push_to_buffers(indio_dev, (u8 *)mag); kfree(mag); done: <API key>(indio_dev->trig); return IRQ_HANDLED; } static int <API key>(struct iio_trigger *trig, bool state) { struct iio_dev *indio_dev = <API key>(trig); yas_set_pseudo_irq(indio_dev, state); return 0; } static const struct iio_trigger_ops yas_trigger_ops = { .owner = THIS_MODULE, .set_trigger_state = &<API key>, }; static int yas_probe_trigger(struct iio_dev *indio_dev) { int ret; struct yas_state *st = iio_priv(indio_dev); indio_dev->pollfunc = iio_alloc_pollfunc(&<API key>, &yas_trigger_handler, IRQF_ONESHOT, indio_dev, "%s_consumer%d", indio_dev->name, indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_ret; } st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (!st->trig) { ret = -ENOMEM; goto <API key>; } st->trig->dev.parent = &st->client->dev; st->trig->ops = &yas_trigger_ops; <API key>(st->trig, indio_dev); ret = <API key>(st->trig); if (ret) goto error_free_trig; return 0; error_free_trig: iio_trigger_free(st->trig); <API key>: <API key>(indio_dev->pollfunc); error_ret: return ret; } static void yas_remove_trigger(struct iio_dev *indio_dev) { struct yas_state *st = iio_priv(indio_dev); <API key>(st->trig); iio_trigger_free(st->trig); <API key>(indio_dev->pollfunc); } static const struct <API key> <API key> = { .preenable = &<API key>, .postenable = &<API key>, .predisable = &<API key>, }; static void yas_remove_buffer(struct iio_dev *indio_dev) { <API key>(indio_dev); iio_kfifo_free(indio_dev->buffer); }; static int yas_probe_buffer(struct iio_dev *indio_dev) { int ret; struct iio_buffer *buffer; buffer = iio_kfifo_allocate(indio_dev); if (!buffer) { ret = -ENOMEM; goto error_ret; } buffer->scan_timestamp = true; indio_dev->buffer = buffer; indio_dev->setup_ops = &<API key>; indio_dev->modes |= <API key>; ret = iio_buffer_register(indio_dev, indio_dev->channels, indio_dev->num_channels); if (ret) goto error_free_buf; iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_MAGN_X); iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_MAGN_Y); iio_scan_mask_set(indio_dev, indio_dev->buffer, YAS_SCAN_MAGN_Z); return 0; error_free_buf: iio_kfifo_free(indio_dev->buffer); error_ret: return ret; } static ssize_t yas_position_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int ret; mutex_lock(&st->lock); ret = st->mag.get_position(); mutex_unlock(&st->lock); if (ret < 0) return -EFAULT; return sprintf(buf, "%d\n", ret); } static ssize_t yas_position_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int ret, position; sscanf(buf, "%d\n", &position); mutex_lock(&st->lock); ret = st->mag.set_position(position); mutex_unlock(&st->lock); if (ret < 0) return -EFAULT; return count; } #if YAS_MAG_DRIVER == <API key> \ || YAS_MAG_DRIVER == <API key> static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int8_t hard_offset[3]; int ret; mutex_lock(&st->lock); ret = st->mag.ext(<API key>, hard_offset); mutex_unlock(&st->lock); if (ret < 0) return -EFAULT; return sprintf(buf, "%d %d %d\n", hard_offset[0], hard_offset[1], hard_offset[2]); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int32_t tmp[3]; int8_t hard_offset[3]; int ret, i; sscanf(buf, "%d %d %d\n", &tmp[0], &tmp[1], &tmp[2]); for (i = 0; i < 3; i++) hard_offset[i] = (int8_t)tmp[i]; mutex_lock(&st->lock); ret = st->mag.ext(<API key>, hard_offset); mutex_unlock(&st->lock); if (ret < 0) return -EFAULT; return count; } #endif static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); return sprintf(buf, "%d\n", st->sampling_frequency); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int ret, data; ret = kstrtoint(buf, 10, &data); if (ret) return ret; if (data <= 0) return -EINVAL; st->sampling_frequency = data; return count; } #if YAS_MAG_DRIVER == <API key> \ || YAS_MAG_DRIVER == <API key> int checkresult(int ret, int id, int x, int y1, int y2, int dir, int sx, int sy, int ohx, int ohy, int ohz) { if(ret) return 0; if(id != 0x02) return 0; if(!CHECK_RANGE(x, -30, 30)) return 0; if(!CHECK_RANGE(y1, -30, 30)) return 0; if(!CHECK_RANGE(y2, -30, 30)) return 0; if(!CHECK_RANGE(dir, 0, 359)) return 0; if(!CHECK_GREATER(sx,17)) return 0; if(!CHECK_GREATER(sy,22)) return 0; return 1; } static ssize_t yas_self_test_show(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); struct <API key> r; int ret; int res = 0; mutex_lock(&st->lock); ret = st->mag.ext(YAS532_SELF_TEST, &r); mutex_unlock(&st->lock); res = checkresult(ret, r.id, r.xy1y2[0], r.xy1y2[1], r.xy1y2[2], r.dir, r.sx, r.sy, r.xyz[0], r.xyz[1], r.xyz[2]); return sprintf(buf, "ret=%d, id=%d, xy1y2=%d %d %d, dir=%d, sx=%d, sy=%d, ohxyz=%d %d %d\nself_test: %s\n", ret, r.id, r.xy1y2[0], r.xy1y2[1], r.xy1y2[2], r.dir, r.sx, r.sy, r.xyz[0], r.xyz[1], r.xyz[2], (res)?"Pass":"Fail"); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); int32_t xyz_raw[3]; int ret; mutex_lock(&st->lock); ret = st->mag.ext(<API key>, xyz_raw); mutex_unlock(&st->lock); if (ret < 0) return -EFAULT; return sprintf(buf, "%d %d %d\n", xyz_raw[0], xyz_raw[1], xyz_raw[2]); } static ssize_t yas_ping(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "0x2e:0x%02x\n", driver.dev_id); } #endif static int yas_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { struct yas_state *st = iio_priv(indio_dev); int ret = -EINVAL; if (chan->type != IIO_MAGN) return -EINVAL; mutex_lock(&st->lock); switch (mask) { case 0: *val = st->compass_data[chan->channel2 - IIO_MOD_X]; ret = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: /* Gain : counts / uT = 1000 [nT] */ /* Scaling factor : 1000000 / Gain = 1000 */ *val = 0; *val2 = 1000; ret = <API key>; break; } mutex_unlock(&st->lock); return ret; } static void yas_work_func(struct work_struct *work) { struct yas_data mag[1]; struct yas_state *st = container_of((struct delayed_work *)work, struct yas_state, work); uint32_t time_before, time_after; int32_t delay; int ret, i; time_before = jiffies_to_msecs(jiffies); mutex_lock(&st->lock); ret = st->mag.measure(mag, 1); if (ret == 1) { for (i = 0; i < 3; i++) st->compass_data[i] = mag[0].xyz.v[i]; } mutex_unlock(&st->lock); if (ret == 1) irq_work_queue(&st->iio_irq_work); time_after = jiffies_to_msecs(jiffies); delay = MSEC_PER_SEC / st->sampling_frequency - (time_after - time_before); if (delay <= 0) delay = 1; <API key>(&st->work, msecs_to_jiffies(delay)); } #define <API key>(axis) \ { \ .type = IIO_MAGN, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .<API key> = BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = YAS_SCAN_MAGN_##axis, \ .scan_type = IIO_ST('s', 32, 32, 0) \ } static const struct iio_chan_spec yas_channels[] = { <API key>(X), <API key>(Y), <API key>(Z), <API key>(YAS_SCAN_TIMESTAMP) }; static IIO_DEVICE_ATTR(sampling_frequency, S_IRUSR|S_IWUSR, <API key>, <API key>, 0); static IIO_DEVICE_ATTR(position, S_IRUSR|S_IWUSR, yas_position_show, yas_position_store, 0); #if YAS_MAG_DRIVER == <API key> \ || YAS_MAG_DRIVER == <API key> static IIO_DEVICE_ATTR(hard_offset, S_IRUSR|S_IWUSR, <API key>, <API key>, 0); static IIO_DEVICE_ATTR(self_test, S_IRUGO|S_IWUSR|S_IWGRP, yas_self_test_show, NULL, 0); static IIO_DEVICE_ATTR(self_test_noise, S_IRUSR, <API key>, NULL, 0); static IIO_DEVICE_ATTR(ping, S_IRUGO|S_IWUSR|S_IWGRP, yas_ping, NULL, 0); #endif static struct attribute *yas_attributes[] = { &<API key>.dev_attr.attr, &<API key>.dev_attr.attr, #if YAS_MAG_DRIVER == <API key> \ || YAS_MAG_DRIVER == <API key> &<API key>.dev_attr.attr, &<API key>.dev_attr.attr, &<API key>.dev_attr.attr, &iio_dev_attr_ping.dev_attr.attr, #endif NULL }; static const struct attribute_group yas_attribute_group = { .attrs = yas_attributes, }; static const struct iio_info yas_info = { .read_raw = &yas_read_raw, .attrs = &yas_attribute_group, .driver_module = THIS_MODULE, }; #ifdef <API key> static void yas_early_suspend(struct early_suspend *h) { struct yas_state *st = container_of(h, struct yas_state, sus); if (atomic_read(&st->pseudo_irq_enable)) <API key>(&st->work); } static void yas_late_resume(struct early_suspend *h) { struct yas_state *st = container_of(h, struct yas_state, sus); if (atomic_read(&st->pseudo_irq_enable)) <API key>(&st->work, 0); } #endif static void mag_sensor_power_on(struct i2c_client *client) { static struct regulator *reg_l19; static struct regulator *reg_lvs1; int error; printk(KERN_INFO "%s: mag power on start\n", __func__); //get power and set voltage level reg_l19 = regulator_get(&client->dev, "vdd"); if (IS_ERR(reg_l19)) { printk("[CCI]%s: Regulator get failed vdd rc=%ld\n", __FUNCTION__, PTR_ERR(reg_l19)); } if (<API key>(reg_l19) > 0) { error = <API key>(reg_l19, 2850000, 2850000); if (error) { printk("[CCI]%s: regulator set_vtg vdd failed rc=%d\n", __FUNCTION__, error); } } reg_lvs1 = regulator_get(&client->dev,"vddio"); if (IS_ERR(reg_lvs1)){ printk("[CCI]could not get vddio lvs1, rc = %ld\n", PTR_ERR(reg_lvs1)); } //enable power error = <API key>(reg_l19, 100000); if (error < 0) { printk("[CCI]%s: Regulator vdd set_opt failed rc=%d\n", __FUNCTION__, error); regulator_put(reg_l19); } error = regulator_enable(reg_l19); if (error) { printk("[CCI]%s: Regulator vdd enable failed rc=%d\n", __FUNCTION__, error); regulator_put(reg_l19); } error = regulator_enable(reg_lvs1); if (error) { printk("[CCI]%s: enable vddio lvs1 failed, rc=%d\n", __FUNCTION__, error); regulator_put(reg_lvs1); } printk(KERN_INFO "%s: mag power on end\n", __func__); error = gpio_tlmm_config(GPIO_CFG(<API key>, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if(error < 0) { printk(KERN_ERR "%s: [CCI]gpio_tlmm_config geomagnetic-rstn, err=%d", __FUNCTION__, error); } error = gpio_request(<API key>,"geomagnetic-rstn"); if(error < 0) { printk(KERN_ERR "%s: [CCI]gpio_request geomagnetic-rstn, err=%d", __FUNCTION__, error); } error = <API key>(<API key>, 1); if(error < 0) { printk(KERN_ERR "%s: [CCI]<API key> geomagnetic-rstn, err=%d", __FUNCTION__, error); } mdelay(3);// delay 3 ms for power ready when issue first I2C command } static int <API key>(struct yas_state *st) { int res; st->sensor_class = class_create(THIS_MODULE, "sony_compass"); if (st->sensor_class == NULL) goto custom_class_error; st->sensor_dev = device_create(st->sensor_class, NULL, 0, "%s", "yas532"); if (st->sensor_dev == NULL) goto custom_device_error; res = sysfs_create_link( &st->sensor_dev->kobj, &st->indio_dev->dev.kobj, "iio"); if (res < 0) { printk(KERN_ERR "link create error, res = %d\n", res); goto <API key>; } return 0; <API key>: if (st->sensor_dev) device_destroy(st->sensor_class, 0); custom_device_error: if (st->sensor_class) class_destroy(st->sensor_class); custom_class_error: dev_err(&st->client->dev, "%s:Unable to create class\n", __func__); return -1; } static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct yas_state *st; struct iio_dev *indio_dev; struct yas_platform_data *pdata; int ret; this_client = i2c; mag_sensor_power_on(i2c); printk("%s: yas533_probe start ---\n", __FUNCTION__); indio_dev = iio_device_alloc(sizeof(*st)); if (!indio_dev) { ret = -ENOMEM; goto error_ret; } i2c_set_clientdata(i2c, indio_dev); indio_dev->name = id->name; indio_dev->dev.parent = &i2c->dev; indio_dev->info = &yas_info; indio_dev->channels = yas_channels; indio_dev->num_channels = ARRAY_SIZE(yas_channels); indio_dev->modes = INDIO_DIRECT_MODE; st = iio_priv(indio_dev); st->client = i2c; st->sampling_frequency = 20; st->mag.callback.device_open = yas_device_open; st->mag.callback.device_close = yas_device_close; st->mag.callback.device_read = yas_device_read; st->mag.callback.device_write = yas_device_write; st->mag.callback.usleep = yas_usleep; st->mag.callback.current_time = yas_current_time; st->indio_dev = indio_dev; INIT_DELAYED_WORK(&st->work, yas_work_func); mutex_init(&st->lock); #ifdef <API key> st->sus.level = <API key> + 1; st->sus.suspend = yas_early_suspend; st->sus.resume = yas_late_resume; <API key>(&st->sus); #endif ret = yas_probe_buffer(indio_dev); if (ret) goto error_free_dev; ret = yas_probe_trigger(indio_dev); if (ret) goto error_remove_buffer; ret = iio_device_register(indio_dev); if (ret) goto <API key>; ret = yas_mag_driver_init(&st->mag); if (ret < 0) { ret = -EFAULT; goto <API key>; } ret = st->mag.init(); if (ret < 0) { ret = -EFAULT; goto <API key>; } ret = st->mag.set_enable(1); if (ret < 0) { ret = -EFAULT; goto error_driver_term; } init_irq_work(&st->iio_irq_work, iio_trigger_work); g_st = st; ret = <API key>(st); if (ret) { printk(KERN_ERR "%s: <API key> fail, ret = %d\n", __func__, ret); goto <API key>; } return 0; <API key>: kfree(pdata); error_driver_term: st->mag.term(); <API key>: <API key>(indio_dev); <API key>: yas_remove_trigger(indio_dev); error_remove_buffer: yas_remove_buffer(indio_dev); error_free_dev: #ifdef <API key> <API key>(&st->sus); #endif iio_device_free(indio_dev); error_ret: i2c_set_clientdata(i2c, NULL); this_client = NULL; return ret; } static int yas_remove(struct i2c_client *i2c) { struct iio_dev *indio_dev = i2c_get_clientdata(i2c); struct yas_state *st; if (indio_dev) { st = iio_priv(indio_dev); #ifdef <API key> <API key>(&st->sus); #endif <API key>(indio_dev); st->mag.term(); <API key>(indio_dev); yas_remove_trigger(indio_dev); yas_remove_buffer(indio_dev); iio_device_free(indio_dev); this_client = NULL; } return 0; } #ifdef CONFIG_PM_SLEEP static int yas_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); if (atomic_read(&st->pseudo_irq_enable)) <API key>(&st->work); st->mag.set_enable(0); return 0; } static int yas_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas_state *st = iio_priv(indio_dev); st->mag.set_enable(1); if (atomic_read(&st->pseudo_irq_enable)) <API key>(&st->work, 0); return 0; } static SIMPLE_DEV_PM_OPS(yas_pm_ops, yas_suspend, yas_resume); #define YAS_PM_OPS (&yas_pm_ops) #else #define YAS_PM_OPS NULL #endif static const struct i2c_device_id yas_id[] = { {"yas532", 0}, { } }; MODULE_DEVICE_TABLE(i2c, yas_id); static struct of_device_id yas533_match_table[] = { { .compatible = "qcom,yas532",}, { .compatible = "yas532",}, { }, }; static struct i2c_driver yas_driver = { .driver = { .name = "yas532", .owner = THIS_MODULE, .of_match_table = yas533_match_table, .pm = YAS_PM_OPS, }, .probe = yas_probe, .remove = yas_remove, .id_table = yas_id, }; module_i2c_driver(yas_driver); MODULE_DESCRIPTION("Yamaha YAS532 I2C driver"); MODULE_LICENSE("GPL v2"); MODULE_VERSION("5.1.1000c.c2");
// SplashT1Font.h #ifndef SPLASHT1FONT_H #define SPLASHT1FONT_H #include <aconf.h> #if HAVE_T1LIB_H #ifdef USE_GCC_PRAGMAS #pragma interface #endif #include "SplashFont.h" class SplashT1FontFile; // SplashT1Font class SplashT1Font: public SplashFont { public: SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA, SplashCoord *textMatA); virtual ~SplashT1Font(); // Munge xFrac and yFrac before calling SplashFont::getGlyph. virtual GBool getGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap); // Rasterize a glyph. The <xFrac> and <yFrac> values are the same // as described for getGlyph. virtual GBool makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap); // Return the path for a glyph. virtual SplashPath *getGlyphPath(int c); private: int t1libID; // t1lib font ID int outlineID; // t1lib font ID for glyph outlines float size; float outlineSize; // size for glyph outlines float outlineMul; }; #endif // HAVE_T1LIB_H #endif
#define DEBUG_SUBSYSTEM S_RPC #include "../../include/linux/libcfs/libcfs.h" # ifdef __mips64__ # include <linux/kernel.h> # endif #include "../include/obd_class.h" #include "../include/lustre_net.h" #include "../include/lustre_sec.h" #include "ptlrpc_internal.h" lnet_handle_eq_t ptlrpc_eq_h; /* * Client's outgoing request callback */ void <API key>(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; bool wakeup = false; LASSERT(ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_UNLINK); LASSERT(ev->unlinked); DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); <API key>(req); spin_lock(&req->rq_lock); req->rq_real_sent = <API key>(); req->rq_req_unlinked = 1; /* reply_in_callback happened before <API key>? */ if (req->rq_reply_unlinked) wakeup = true; if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) { /* Failed send: make it seem like the reply timed out, just * like failing sends in client.c does currently... */ req->rq_net_err = 1; wakeup = true; } if (wakeup) <API key>(req); spin_unlock(&req->rq_lock); ptlrpc_req_finished(req); } /* * Client's incoming reply callback */ void reply_in_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); LASSERT(ev->md.start == req->rq_repbuf); LASSERT(ev->offset + ev->mlength <= req->rq_repbuf_len); /* We've set <API key> for all outgoing requests * for adaptive timeouts' early reply. */ LASSERT((ev->md.options & <API key>) != 0); spin_lock(&req->rq_lock); req->rq_receiving_reply = 0; req->rq_early = 0; if (ev->unlinked) req->rq_reply_unlinked = 1; if (ev->status) goto out_wake; if (ev->type == LNET_EVENT_UNLINK) { LASSERT(ev->unlinked); DEBUG_REQ(D_NET, req, "unlink"); goto out_wake; } if (ev->mlength < ev->rlength) { CDEBUG(D_RPCTRACE, "truncate req %p rpc %d - %d+%d\n", req, req->rq_replen, ev->rlength, ev->offset); req->rq_reply_truncated = 1; req->rq_replied = 1; req->rq_status = -EOVERFLOW; req->rq_nob_received = ev->rlength + ev->offset; goto out_wake; } if ((ev->offset == 0) && ((<API key>(req->rq_reqmsg) & MSGHDR_AT_SUPPORT))) { /* Early reply */ DEBUG_REQ(D_ADAPTTO, req, "Early reply received: mlen=%u offset=%d replen=%d replied=%d unlinked=%d", ev->mlength, ev->offset, req->rq_replen, req->rq_replied, ev->unlinked); req->rq_early_count++; /* number received, client side */ /* already got the real reply or buffers are already unlinked */ if (req->rq_replied || req->rq_reply_unlinked == 1) goto out_wake; req->rq_early = 1; req->rq_reply_off = ev->offset; req->rq_nob_received = ev->mlength; /* And we're still receiving */ req->rq_receiving_reply = 1; } else { /* Real reply */ req->rq_rep_swab_mask = 0; req->rq_replied = 1; /* Got reply, no resend required */ req->rq_resend = 0; req->rq_reply_off = ev->offset; req->rq_nob_received = ev->mlength; /* LNetMDUnlink can't be called under the LNET_LOCK, * so we must unlink in <API key> */ DEBUG_REQ(D_INFO, req, "reply in flags=%x mlen=%u offset=%d replen=%d", <API key>(req->rq_reqmsg), ev->mlength, ev->offset, req->rq_replen); } req->rq_import->imp_last_reply_time = <API key>(); out_wake: /* NB don't unlock till after wakeup; req can disappear under us * since we don't have our own ref */ <API key>(req); spin_unlock(&req->rq_lock); } /* * Client's bulk has been written/read */ void <API key>(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; struct ptlrpc_request *req; LASSERT((<API key>(desc->bd_type) && ev->type == LNET_EVENT_PUT) || (<API key>(desc->bd_type) && ev->type == LNET_EVENT_GET) || ev->type == LNET_EVENT_UNLINK); LASSERT(ev->unlinked); if (<API key>(<API key>, CFS_FAIL_ONCE)) ev->status = -EIO; if (<API key>(<API key>, CFS_FAIL_ONCE)) ev->status = -EIO; CDEBUG((ev->status == 0) ? D_NET : D_ERROR, "event type %d, status %d, desc %p\n", ev->type, ev->status, desc); spin_lock(&desc->bd_lock); req = desc->bd_req; LASSERT(desc->bd_md_count > 0); desc->bd_md_count if (ev->type != LNET_EVENT_UNLINK && ev->status == 0) { desc->bd_nob_transferred += ev->mlength; desc->bd_sender = ev->sender; } else { /* start reconnect and resend if network error hit */ spin_lock(&req->rq_lock); req->rq_net_err = 1; spin_unlock(&req->rq_lock); } if (ev->status != 0) desc->bd_failure = 1; /* NB don't unlock till after wakeup; desc can disappear under us * otherwise */ if (desc->bd_md_count == 0) <API key>(desc->bd_req); spin_unlock(&desc->bd_lock); } #define REQS_CPT_BITS(svcpt) ((svcpt)->scp_service->srv_cpt_bits) #define REQS_SEC_SHIFT 32 #define REQS_USEC_SHIFT 16 #define REQS_SEQ_SHIFT(svcpt) REQS_CPT_BITS(svcpt) static void <API key>(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { __u64 sec = req->rq_arrival_time.tv_sec; __u32 usec = req->rq_arrival_time.tv_nsec / NSEC_PER_USEC / 16; /* usec / 16 */ __u64 new_seq; /* set sequence ID for request and add it to history list, * it must be called with hold svcpt::scp_lock */ new_seq = (sec << REQS_SEC_SHIFT) | (usec << REQS_USEC_SHIFT) | (svcpt->scp_cpt < 0 ? 0 : svcpt->scp_cpt); if (new_seq > svcpt->scp_hist_seq) { /* This handles the initial case of scp_hist_seq == 0 or * we just jumped into a new time window */ svcpt->scp_hist_seq = new_seq; } else { LASSERT(REQS_SEQ_SHIFT(svcpt) < REQS_USEC_SHIFT); /* NB: increase sequence number in current usec bucket, * however, it's possible that we used up all bits for * sequence and jumped into the next usec bucket (future time), * then we hope there will be less RPCs per bucket at some * point, and sequence will catch up again */ svcpt->scp_hist_seq += (1ULL << REQS_SEQ_SHIFT(svcpt)); new_seq = svcpt->scp_hist_seq; } req->rq_history_seq = new_seq; list_add_tail(&req->rq_history_list, &svcpt->scp_hist_reqs); } /* * Server's incoming request callback */ void request_in_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct <API key> *rqbd = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; struct ptlrpc_service *service = svcpt->scp_service; struct ptlrpc_request *req; LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); LASSERT((char *)ev->md.start >= rqbd->rqbd_buffer); LASSERT((char *)ev->md.start + ev->offset + ev->mlength <= rqbd->rqbd_buffer + service->srv_buf_size); CDEBUG((ev->status == 0) ? D_NET : D_ERROR, "event type %d, status %d, service %s\n", ev->type, ev->status, service->srv_name); if (ev->unlinked) { /* If this is the last request message to fit in the * request buffer we can use the request object embedded in * rqbd. Note that if we failed to allocate a request, * we'd have to re-post the rqbd, which we can't do in this * context. */ req = &rqbd->rqbd_req; memset(req, 0, sizeof(*req)); } else { LASSERT(ev->type == LNET_EVENT_PUT); if (ev->status != 0) { /* We moaned above already... */ return; } req = <API key>(GFP_ATOMIC); if (!req) { CERROR("Can't allocate incoming request descriptor: Dropping %s RPC from %s\n", service->srv_name, libcfs_id2str(ev->initiator)); return; } } ptlrpc_srv_req_init(req); /* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL, * flags are reset and scalars are zero. We only set the message * size to non-zero if this was a successful receive. */ req->rq_xid = ev->match_bits; req->rq_reqbuf = ev->md.start + ev->offset; if (ev->type == LNET_EVENT_PUT && ev->status == 0) req->rq_reqdata_len = ev->mlength; ktime_get_real_ts64(&req->rq_arrival_time); req->rq_peer = ev->initiator; req->rq_self = ev->target.nid; req->rq_rqbd = rqbd; req->rq_phase = RQ_PHASE_NEW; if (ev->type == LNET_EVENT_PUT) CDEBUG(D_INFO, "incoming req@%p x%llu msgsize %u\n", req, req->rq_xid, ev->mlength); CDEBUG(D_RPCTRACE, "peer: %s\n", libcfs_id2str(req->rq_peer)); spin_lock(&svcpt->scp_lock); <API key>(svcpt, req); if (ev->unlinked) { svcpt->scp_nrqbds_posted CDEBUG(D_INFO, "Buffer complete: %d buffers still posted\n", svcpt->scp_nrqbds_posted); /* Normally, don't complain about 0 buffers posted; LNET won't * drop incoming reqs since we set the portal lazy */ if (<API key> && ev->type != LNET_EVENT_UNLINK && svcpt->scp_nrqbds_posted == 0) CWARN("All %s request buffers busy\n", service->srv_name); /* req takes over the network's ref on rqbd */ } else { /* req takes a ref on rqbd */ rqbd->rqbd_refcount++; } list_add_tail(&req->rq_list, &svcpt->scp_req_incoming); svcpt->scp_nreqs_incoming++; /* NB everything can disappear under us once the request * has been queued and we unlock, so do the wake now... */ wake_up(&svcpt->scp_waitq); spin_unlock(&svcpt->scp_lock); } /* * Server's outgoing reply callback */ void reply_out_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; LASSERT(ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_ACK || ev->type == LNET_EVENT_UNLINK); if (!rs->rs_difficult) { /* 'Easy' replies have no further processing so I drop the * net's ref on 'rs' */ LASSERT(ev->unlinked); ptlrpc_rs_decref(rs); return; } LASSERT(rs->rs_on_net); if (ev->unlinked) { /* Last network callback. The net's ref on 'rs' stays put * until ptlrpc_handle_rs() is done with it */ spin_lock(&svcpt->scp_rep_lock); spin_lock(&rs->rs_lock); rs->rs_on_net = 0; if (!rs->rs_no_ack || rs->rs_transno <= rs->rs_export->exp_obd->obd_last_committed || list_empty(&rs->rs_obd_list)) <API key>(rs); spin_unlock(&rs->rs_lock); spin_unlock(&svcpt->scp_rep_lock); } } static void <API key>(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; void (*callback)(lnet_event_t *ev) = cbid->cbid_fn; /* Honestly, it's best to find out early. */ LASSERT(cbid->cbid_arg != LP_POISON); LASSERT(callback == <API key> || callback == reply_in_callback || callback == <API key> || callback == request_in_callback || callback == reply_out_callback); callback(ev); } int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, lnet_process_id_t *peer, lnet_nid_t *self) { int best_dist = 0; __u32 best_order = 0; int count = 0; int rc = -ENOENT; int dist; __u32 order; lnet_nid_t dst_nid; lnet_nid_t src_nid; peer->pid = LNET_PID_LUSTRE; /* Choose the matching UUID that's closest */ while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) { dist = LNetDist(dst_nid, &src_nid, &order); if (dist < 0) continue; if (dist == 0) { /* local! use loopback LND */ peer->nid = *self = LNET_MKNID(LNET_MKNET(LOLND, 0), 0); rc = 0; break; } if (rc < 0 || dist < best_dist || (dist == best_dist && order < best_order)) { best_dist = dist; best_order = order; peer->nid = dst_nid; *self = src_nid; rc = 0; } } CDEBUG(D_NET, "%s->%s\n", uuid->uuid, libcfs_id2str(*peer)); return rc; } static void ptlrpc_ni_fini(void) { wait_queue_head_t waitq; struct l_wait_info lwi; int rc; int retries; /* Wait for the event queue to become idle since there may still be * messages in flight with pending events (i.e. the fire-and-forget * messages == client requests and "non-difficult" server * replies */ for (retries = 0;; retries++) { rc = LNetEQFree(ptlrpc_eq_h); switch (rc) { default: LBUG(); case 0: LNetNIFini(); return; case -EBUSY: if (retries != 0) CWARN("Event queue still busy\n"); /* Wait for a bit */ init_waitqueue_head(&waitq); lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL, NULL); l_wait_event(waitq, 0, &lwi); break; } } /* notreached */ } static lnet_pid_t ptl_get_pid(void) { lnet_pid_t pid; pid = LNET_PID_LUSTRE; return pid; } static int ptlrpc_ni_init(void) { int rc; lnet_pid_t pid; pid = ptl_get_pid(); CDEBUG(D_NET, "My pid is: %x\n", pid); /* We're not passing any limits yet... */ rc = LNetNIInit(pid); if (rc < 0) { CDEBUG(D_NET, "Can't init network interface: %d\n", rc); return rc; } /* CAVEAT EMPTOR: how we process portals events is _radically_ * different depending on... */ /* kernel LNet calls our master callback when there are new event, * because we are guaranteed to get every event via callback, * so we just set EQ size to 0 to avoid overhead of serializing * enqueue/dequeue operations in LNet. */ rc = LNetEQAlloc(0, <API key>, &ptlrpc_eq_h); if (rc == 0) return 0; CERROR("Failed to allocate event queue: %d\n", rc); LNetNIFini(); return rc; } int ptlrpc_init_portals(void) { int rc = ptlrpc_ni_init(); if (rc != 0) { CERROR("network initialisation failed\n"); return rc; } rc = ptlrpcd_addref(); if (rc == 0) return 0; CERROR("rpcd initialisation failed\n"); ptlrpc_ni_fini(); return rc; } void ptlrpc_exit_portals(void) { ptlrpcd_decref(); ptlrpc_ni_fini(); }
<?php /** * @file ShibbolethUser.php */ /** * Represents an external user and its attributes. * * @class ShibbolethUser */ class ShibbolethUser { /** * The username. * @var string */ private $_username; /** * The user's first name. * @var string */ private $_firstname; /** * The user's last name. * @var string */ private $_lastname; /** * The user's email address. * @var string */ private $_email; /** * The user's phone number. * @var string */ private $_phone; /** * Constructor. * Populates the object's members with given values. * * @param array $values A map of user attributes. * @param ShibbolethOptions $options The plugin configuration. */ public function __construct (array $values, ShibbolethOptions $options) { $config = $options-><API key>(); $this->_username = $this->GetValue($values, $config[ShibbolethConfig::USERNAME]); $this->_firstname = $this->GetValue($values, $config[ShibbolethConfig::FIRSTNAME]); $this->_lastname = $this->GetValue($values, $config[ShibbolethConfig::LASTNAME]); $this->_email = $this->GetValue($values, $config[ShibbolethConfig::EMAIL]); $this->_phone = $this->GetValue($values, $config[ShibbolethConfig::PHONE]); } /** * Retrieves the username. * @return string|null */ public function GetUsername () { return $this->_username; } /** * Retrieve's the user's first name. * @return string|null */ public function GetFirstName () { return $this->_firstname; } /** * Retrieves the user's last name. * @return string|null */ public function GetLastName () { return $this->_lastname; } /** * Retrieves the user's email address. * @return string|null */ public function GetEmailAddress () { return $this->_email; } /** * Retrieves the user's phone number. * @return string|null */ public function GetPhone () { return $this->_phone; } /** * Retrieves a value from a given map by a given key. * * @param array $values A map of key/value pairs. * @param string $key The key. * @return string|null The value, or NULL if none was found. */ protected function GetValue (array $values, $key) { $value = null; if (array_key_exists($key, $values)) { $value = $values[$key]; } return $value; } }
// detail/thread_group.hpp #ifndef <API key> #define <API key> #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include "asio/detail/scoped_ptr.hpp" #include "asio/detail/thread.hpp" #include "asio/detail/push_options.hpp" namespace asio { namespace detail { class thread_group { public: // Constructor initialises an empty thread group. thread_group() : first_(0) { } // Destructor joins any remaining threads in the group. ~thread_group() { join(); } // Create a new thread in the group. template <typename Function> void create_thread(Function f) { first_ = new item(f, first_); } // Create new threads in the group. template <typename Function> void create_threads(Function f, std::size_t num_threads) { for (std::size_t i = 0; i < num_threads; ++i) create_thread(f); } // Wait for all threads in the group to exit. void join() { while (first_) { first_->thread_.join(); item* tmp = first_; first_ = first_->next_; delete tmp; } } // Test whether the group is empty. bool empty() const { return first_ == 0; } private: // Structure used to track a single thread in the group. struct item { template <typename Function> explicit item(Function f, item* next) : thread_(f), next_(next) { } asio::detail::thread thread_; item* next_; }; // The first thread in the group. item* first_; }; } // namespace detail } // namespace asio #include "asio/detail/pop_options.hpp" #endif // <API key>
<?php get_header(); ?> <section id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); <API key>( '<div class="<API key>">', '</div>' ); ?> </header><!-- .page-header --> <?php // Start the Loop. while ( have_posts() ) : the_post(); get_template_part( 'content', get_post_format() ); // End the loop. endwhile; // Previous/next page navigation. <API key>( array( 'prev_text' => __( 'Previous page', 'twentyfifteen' ), 'next_text' => __( 'Next page', 'twentyfifteen' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>', ) ); // If no content, include the "No posts found" template. else : get_template_part( 'content', 'none' ); endif; ?> </main><!-- .site-main --> </section><!-- .content-area --> <?php get_footer(); ?>
package org.swiftp; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import android.util.Log; public class <API key> extends DataSocketFactory { /** * This class implements normal, traditional opening and closing of data sockets * used for transmitting directory listings and file contents. PORT and PASV * work according to the FTP specs. This is in contrast to a * <API key>, which performs contortions to allow data sockets * to be proxied through a server out in the cloud. * */ // Listener socket used for PASV mode ServerSocket server = null; // Remote IP & port information used for PORT mode InetAddress remoteAddr; int remotePort; boolean isPasvMode = true; public <API key>() { clearState(); } private void clearState() { /** * Clears the state of this object, as if no pasv() or port() had occurred. * All sockets are closed. */ if(server != null) { try { server.close(); } catch (IOException e) {} } server = null; remoteAddr = null; remotePort = 0; myLog.l(Log.DEBUG, "<API key> state cleared"); } public int onPasv() { clearState(); try { // Listen on any port (port parameter 0) server = new ServerSocket(0, Defaults.<API key>); myLog.l(Log.DEBUG, "Data socket pasv() listen successful"); return server.getLocalPort(); } catch(IOException e) { myLog.l(Log.ERROR, "Data socket creation error"); clearState(); return 0; } } public boolean onPort(InetAddress remoteAddr, int remotePort) { clearState(); this.remoteAddr = remoteAddr; this.remotePort = remotePort; return true; } public Socket onTransfer() { if(server == null) { // We're in PORT mode (not PASV) if(remoteAddr == null || remotePort == 0) { myLog.l(Log.INFO, "PORT mode but not initialized correctly"); clearState(); return null; } Socket socket; try { socket = new Socket(remoteAddr, remotePort); } catch (IOException e) { myLog.l(Log.INFO, "Couldn't open PORT data socket to: " + remoteAddr.toString() + ":" + remotePort); clearState(); return null; } // Kill the socket if nothing happens for X milliseconds try { socket.setSoTimeout(Defaults.SO_TIMEOUT_MS); } catch (Exception e) { myLog.l(Log.ERROR, "Couldn't set SO_TIMEOUT"); clearState(); return null; } return socket; } else { // We're in PASV mode (not PORT) Socket socket = null; try { socket = server.accept(); myLog.l(Log.DEBUG, "onTransfer pasv accept successful"); } catch (Exception e) { myLog.l(Log.INFO, "Exception accepting PASV socket"); socket = null; } clearState(); return socket; // will be null if error occurred } } /** * Return the port number that the remote client should be informed of (in the body * of the PASV response). * @return The port number, or -1 if error. */ public int getPortNumber() { if(server != null) { return server.getLocalPort(); // returns -1 if serversocket is unbound } else { return -1; } } public InetAddress getPasvIp() { //String retVal = server.getInetAddress().getHostAddress(); return FTPServerService.getWifiIp(); } public void reportTraffic(long bytes) { // ignore, we don't care about how much traffic goes over wifi. } }
#include "modfile.h" #include "tstringlist.h" #include "tdebug.h" #include "modfileprivate.h" #include "tpropertymap.h" using namespace TagLib; using namespace Mod; class Mod::File::FilePrivate { public: FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) { } Mod::Tag tag; Mod::Properties properties; }; Mod::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) { if(isOpen()) read(readProperties); } Mod::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) { if(isOpen()) read(readProperties); } Mod::File::~File() { delete d; } Mod::Tag *Mod::File::tag() const { return &d->tag; } Mod::Properties *Mod::File::audioProperties() const { return &d->properties; } PropertyMap Mod::File::properties() const { return d->tag.properties(); } PropertyMap Mod::File::setProperties(const PropertyMap &properties) { return d->tag.setProperties(properties); } bool Mod::File::save() { if(readOnly()) { debug("Mod::File::save() - Cannot save to a read only file."); return false; } seek(0); writeString(d->tag.title(), 20); StringList lines = d->tag.comment().split("\n"); unsigned int n = std::min(lines.size(), d->properties.instrumentCount()); for(unsigned int i = 0; i < n; ++ i) { writeString(lines[i], 22); seek(8, Current); } for(unsigned int i = n; i < d->properties.instrumentCount(); ++ i) { writeString(String(), 22); seek(8, Current); } return true; } void Mod::File::read(bool) { if(!isOpen()) return; seek(1080); ByteVector modId = readBlock(4); READ_ASSERT(modId.size() == 4); int channels = 4; unsigned int instruments = 31; if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") { d->tag.setTrackerName("ProTracker"); channels = 4; } else if(modId.startsWith("FLT") || modId.startsWith("TDZ")) { d->tag.setTrackerName("StarTrekker"); char digit = modId[3]; READ_ASSERT(digit >= '0' && digit <= '9'); channels = digit - '0'; } else if(modId.endsWith("CHN")) { d->tag.setTrackerName("StarTrekker"); char digit = modId[0]; READ_ASSERT(digit >= '0' && digit <= '9'); channels = digit - '0'; } else if(modId == "CD81" || modId == "OKTA") { d->tag.setTrackerName("Atari Oktalyzer"); channels = 8; } else if(modId.endsWith("CH") || modId.endsWith("CN")) { d->tag.setTrackerName("TakeTracker"); char digit = modId[0]; READ_ASSERT(digit >= '0' && digit <= '9'); channels = (digit - '0') * 10; digit = modId[1]; READ_ASSERT(digit >= '0' && digit <= '9'); channels += digit - '0'; } else { // Not sure if this is correct. I'd need a file // created with NoiseTracker to check this. d->tag.setTrackerName("NoiseTracker"); // probably channels = 4; instruments = 15; } d->properties.setChannels(channels); d->properties.setInstrumentCount(instruments); seek(0); READ_STRING(d->tag.setTitle, 20); StringList comment; for(unsigned int i = 0; i < instruments; ++ i) { READ_STRING_AS(instrumentName, 22); // value in words, * 2 (<< 1) for bytes: READ_U16B_AS(sampleLength); READ_BYTE_AS(fineTuneByte); int fineTune = fineTuneByte & 0xF; // > 7 means negative value if(fineTune > 7) fineTune -= 16; READ_BYTE_AS(volume); if(volume > 64) volume = 64; // volume in decibels: 20 * log10(volume / 64) // value in words, * 2 (<< 1) for bytes: READ_U16B_AS(repeatStart); // value in words, * 2 (<< 1) for bytes: READ_U16B_AS(repatLength); comment.append(instrumentName); } READ_BYTE(d->properties.setLengthInPatterns); d->tag.setComment(comment.toString("\n")); }
#include "indexer/feature_visibility.hpp" #include "indexer/classificator.hpp" #include "indexer/feature.hpp" #include "indexer/scales.hpp" #include "base/assert.hpp" #include "std/array.hpp" namespace { bool NeedProcessParent(ClassifObject const * p) { return false; } } template <class ToDo> typename ToDo::ResultType Classificator::ProcessObjects(uint32_t type, ToDo & toDo) const { typedef typename ToDo::ResultType ResultType; ResultType res = ResultType(); // default initialization ClassifObject const * p = &m_root; uint8_t i = 0; uint8_t v; // it's enough for now with our 3-level classificator array<ClassifObject const *, 8> path; // get objects route in hierarchy for type while (ftype::GetValue(type, i, v)) { p = p->GetObject(v); if (p != 0) { path[i++] = p; toDo(p); } else break; } if (path.empty()) return res; else { // process objects from child to root for (; i > 0; --i) { // process and stop find if needed if (toDo(path[i-1], res)) break; // no need to process parents if (!NeedProcessParent(path[i-1])) break; } return res; } } ClassifObject const * Classificator::GetObject(uint32_t type) const { ClassifObject const * p = &m_root; uint8_t i = 0; // get the final ClassifObject uint8_t v; while (ftype::GetValue(type, i, v)) { ++i; p = p->GetObject(v); } return p; } string Classificator::GetFullObjectName(uint32_t type) const { ClassifObject const * p = &m_root; uint8_t i = 0; string s; // get the final ClassifObject uint8_t v; while (ftype::GetValue(type, i, v)) { ++i; p = p->GetObject(v); s = s + p->GetName() + '|'; } return s; } namespace feature { namespace { class DrawRuleGetter { int m_scale; EGeomType m_ft; drule::KeysT & m_keys; public: DrawRuleGetter(int scale, EGeomType ft, drule::KeysT & keys) : m_scale(scale), m_ft(ft), m_keys(keys) { } typedef bool ResultType; void operator() (ClassifObject const *) { } bool operator() (ClassifObject const * p, bool & res) { res = true; p->GetSuitable(min(m_scale, scales::GetUpperStyleScale()), m_ft, m_keys); return false; } }; } pair<int, bool> GetDrawRule(FeatureBase const & f, int level, drule::KeysT & keys) { TypesHolder types(f); ASSERT ( keys.empty(), () ); Classificator const & c = classif(); DrawRuleGetter doRules(level, types.GetGeoType(), keys); for (uint32_t t : types) (void)c.ProcessObjects(t, doRules); return make_pair(types.GetGeoType(), types.Has(c.GetCoastType())); } void GetDrawRule(vector<uint32_t> const & types, int level, int geoType, drule::KeysT & keys) { ASSERT ( keys.empty(), () ); Classificator const & c = classif(); DrawRuleGetter doRules(level, EGeomType(geoType), keys); for (size_t i = 0; i < types.size(); ++i) (void)c.ProcessObjects(types[i], doRules); } namespace { class IsDrawableChecker { int m_scale; public: IsDrawableChecker(int scale) : m_scale(scale) {} typedef bool ResultType; void operator() (ClassifObject const *) {} bool operator() (ClassifObject const * p, bool & res) { if (p->IsDrawable(m_scale)) { res = true; return true; } return false; } }; class <API key> { EGeomType m_type; public: <API key>(EGeomType type) : m_type(type) {} typedef bool ResultType; void operator() (ClassifObject const *) {} bool operator() (ClassifObject const * p, bool & res) { if (p->IsDrawableLike(m_type)) { res = true; return true; } return false; } }; class <API key> { int m_scale; EGeomType m_ft; bool m_arr[3]; public: <API key>(int scale, EGeomType ft, int rules) : m_scale(scale), m_ft(ft) { m_arr[0] = rules & RULE_CAPTION; m_arr[1] = rules & RULE_PATH_TEXT; m_arr[2] = rules & RULE_SYMBOL; } typedef bool ResultType; void operator() (ClassifObject const *) {} bool operator() (ClassifObject const * p, bool & res) { drule::KeysT keys; p->GetSuitable(m_scale, m_ft, keys); for (size_t i = 0; i < keys.size(); ++i) { if ((m_arr[0] && keys[i].m_type == drule::caption) || (m_arr[1] && keys[i].m_type == drule::pathtext) || (m_arr[2] && keys[i].m_type == drule::symbol)) { res = true; return true; } } return false; } }; Add here all exception classificator types: needed for algorithms, but don't have drawing rules. bool TypeAlwaysExists(uint32_t t, EGeomType g = GEOM_UNDEFINED) { static const uint32_t s1 = classif().GetTypeByPath({ "junction", "roundabout" }); static const uint32_t s2 = classif().GetTypeByPath({ "hwtag" }); if (g == GEOM_LINE || g == GEOM_UNDEFINED) { if (s1 == t) return true; ftype::TruncValue(t, 1); if (s2 == t) return true; } return false; } } bool IsDrawableAny(uint32_t type) { return (TypeAlwaysExists(type) || classif().GetObject(type)->IsDrawableAny()); } bool IsDrawableLike(vector<uint32_t> const & types, EGeomType ft) { Classificator const & c = classif(); <API key> doCheck(ft); for (size_t i = 0; i < types.size(); ++i) if (c.ProcessObjects(types[i], doCheck)) return true; return false; } bool IsDrawableForIndex(FeatureBase const & f, int level) { return <API key>(f, level) && <API key>(f, level); } bool <API key>(FeatureBase const & f, int level) { Classificator const & c = classif(); TypesHolder const types(f); if (types.GetGeoType() == GEOM_AREA && !types.Has(c.GetCoastType()) && !scales::IsGoodForLevel(level, f.GetLimitRect())) return false; return true; } bool <API key>(FeatureBase const & f, int level) { Classificator const & c = classif(); TypesHolder const types(f); IsDrawableChecker doCheck(level); for (uint32_t t : types) if (c.ProcessObjects(t, doCheck)) return true; return false; } namespace { class IsNonDrawableType { Classificator & m_c; EGeomType m_type; public: IsNonDrawableType(EGeomType ft) : m_c(classif()), m_type(ft) {} bool operator() (uint32_t t) const { if (TypeAlwaysExists(t, m_type)) return false; <API key> doCheck(m_type); if (m_c.ProcessObjects(t, doCheck)) return false; // <API key> checks only unique area styles, // so we need to take into account point styles too. if (m_type == GEOM_AREA) { <API key> doCheck(GEOM_POINT); if (m_c.ProcessObjects(t, doCheck)) return false; } return true; } }; } bool <API key>(vector<uint32_t> & types, EGeomType ft) { types.erase(remove_if(types.begin(), types.end(), IsNonDrawableType(ft)), types.end()); return !types.empty(); } int GetMinDrawableScale(FeatureBase const & f) { int const upBound = scales::GetUpperStyleScale(); for (int level = 0; level <= upBound; ++level) if (IsDrawableForIndex(f, level)) return level; return -1; } int <API key>(FeatureBase const & f) { int const upBound = scales::GetUpperStyleScale(); for (int level = 0; level <= upBound; ++level) if (<API key>(f, level)) return level; return -1; } namespace { void AddRange(pair<int, int> & dest, pair<int, int> const & src) { if (src.first != -1) { ASSERT_GREATER(src.first, -1, ()); ASSERT_GREATER(src.second, -1, ()); dest.first = min(dest.first, src.first); dest.second = max(dest.second, src.second); ASSERT_GREATER(dest.first, -1, ()); ASSERT_GREATER(dest.second, -1, ()); } } class DoGetScalesRange { pair<int, int> m_scales; public: DoGetScalesRange() : m_scales(1000, -1000) {} typedef bool ResultType; void operator() (ClassifObject const *) {} bool operator() (ClassifObject const * p, bool & res) { res = true; AddRange(m_scales, p->GetDrawScaleRange()); return false; } pair<int, int> GetScale() const { return (m_scales.first > m_scales.second ? make_pair(-1, -1) : m_scales); } }; } pair<int, int> <API key>(uint32_t type) { DoGetScalesRange doGet; (void)classif().ProcessObjects(type, doGet); return doGet.GetScale(); } pair<int, int> <API key>(TypesHolder const & types) { pair<int, int> res(1000, -1000); for (uint32_t t : types) AddRange(res, <API key>(t)); return (res.first > res.second ? make_pair(-1, -1) : res); } namespace { bool IsDrawableForRules(TypesHolder const & types, int level, int rules) { Classificator const & c = classif(); <API key> doCheck(level, types.GetGeoType(), rules); for (uint32_t t : types) if (c.ProcessObjects(t, doCheck)) return true; return false; } } pair<int, int> <API key>(TypesHolder const & types, int rules) { int const upBound = scales::GetUpperStyleScale(); int lowL = -1; for (int level = 0; level <= upBound; ++level) { if (IsDrawableForRules(types, level, rules)) { lowL = level; break; } } if (lowL == -1) return make_pair(-1, -1); int highL = lowL; for (int level = upBound; level > lowL; --level) { if (IsDrawableForRules(types, level, rules)) { highL = level; break; } } return make_pair(lowL, highL); } pair<int, int> <API key>(FeatureBase const & f, int rules) { return <API key>(TypesHolder(f), rules); } TypeSetChecker::TypeSetChecker(initializer_list<char const *> const & lst) { m_type = classif().GetTypeByPath(lst); m_level = lst.size(); } bool TypeSetChecker::IsEqual(uint32_t type) const { ftype::TruncValue(type, m_level); return (m_type == type); } } // namespace feature
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0-google-internal) on Wed Dec 30 10:35:12 PST 2009 --> <TITLE> Uses of Class com.google.common.collect.<API key> (Google Collections Library 1.0 (FINAL)) </TITLE> <META NAME="date" CONTENT="2009-12-30"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class com.google.common.collect.<API key> (Google Collections Library 1.0 (FINAL))"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?com/google/common/collect//<API key>.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="<API key>.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <CENTER> <H2> <B>Uses of Class<br>com.google.common.collect.<API key></B></H2> </CENTER> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Packages that use <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><A HREF="#com.google.common.collect"><B>com.google.common.collect</B></A></TD> <TD>This package contains generic collection interfaces and implementations, and other utilities for working with collections.&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <A NAME="com.google.common.collect"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A> in <A HREF="../../../../../com/google/common/collect/package-summary.html">com.google.common.collect</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="<API key>"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../com/google/common/collect/package-summary.html">com.google.common.collect</A> that return <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;<A HREF="../../../../../com/google/common/collect/<API key>.Builder.html" title="type parameter in <API key>.Builder">K</A>,<A HREF="../../../../../com/google/common/collect/<API key>.Builder.html" title="type parameter in <API key>.Builder">V</A>&gt;</CODE></FONT></TD> <TD><CODE><B><API key>.Builder.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.Builder.html#build()">build</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a newly-created immutable multimap.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#copyOf(com.google.common.collect.Multimap)">copyOf</A></B>(<A HREF="../../../../../com/google/common/collect/Multimap.html" title="interface in com.google.common.collect">Multimap</A>&lt;? extends K,? extends V&gt;&nbsp;multimap)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing the same mappings as <code>multimap</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B>Multimaps.</B><B><A HREF="../../../../../com/google/common/collect/Multimaps.html <A HREF="../../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A>&lt;? super V,K&gt;&nbsp;keyFunction)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an index <code>ImmutableMultimap</code> that contains the results of applying a specified function to each item in an <code>Iterable</code> of values.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of()">of</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the empty multimap.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of(K, V)">of</A></B>(K&nbsp;k1, V&nbsp;v1)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing a single entry.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of(K, V, K, V)">of</A></B>(K&nbsp;k1, V&nbsp;v1, K&nbsp;k2, V&nbsp;v2)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing the given entries, in order.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of(K, V, K, V, K, V)">of</A></B>(K&nbsp;k1, V&nbsp;v1, K&nbsp;k2, V&nbsp;v2, K&nbsp;k3, V&nbsp;v3)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing the given entries, in order.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of(K, V, K, V, K, V, K, V)">of</A></B>(K&nbsp;k1, V&nbsp;v1, K&nbsp;k2, V&nbsp;v2, K&nbsp;k3, V&nbsp;v3, K&nbsp;k4, V&nbsp;v4)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing the given entries, in order.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> <TR ALIGN="right" VALIGN=""> <TD NOWRAP><FONT SIZE="-1"> <CODE>&lt;K,V&gt; <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><API key></A>&lt;K,V&gt;</CODE></FONT></TD> </TR> </TABLE> </CODE></FONT></TD> <TD><CODE><B><API key>.</B><B><A HREF="../../../../../com/google/common/collect/<API key>.html#of(K, V, K, V, K, V, K, V, K, V)">of</A></B>(K&nbsp;k1, V&nbsp;v1, K&nbsp;k2, V&nbsp;v2, K&nbsp;k3, V&nbsp;v3, K&nbsp;k4, V&nbsp;v4, K&nbsp;k5, V&nbsp;v5)</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an immutable multimap containing the given entries, in order.</TD> </TR> </TABLE> &nbsp; <P> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../com/google/common/collect/<API key>.html" title="class in com.google.common.collect"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?com/google/common/collect//<API key>.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="<API key>.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> </BODY> </HTML>
// The LLVM Compiler Infrastructure // This file is distributed under the University of Illinois Open Source // This file implements a wrapper around MCSchedModel that allows the interface // to benefit from information currently only available in TargetInstrInfo. #include "llvm/CodeGen/TargetSchedule.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" using namespace llvm; static cl::opt<bool> EnableSchedModel("schedmodel", cl::Hidden, cl::init(true), cl::desc("Use TargetSchedModel for latency lookup")); static cl::opt<bool> EnableSchedItins("scheditins", cl::Hidden, cl::init(true), cl::desc("Use InstrItineraryData for latency lookup")); bool TargetSchedModel::hasInstrSchedModel() const { return EnableSchedModel && SchedModel.hasInstrSchedModel(); } bool TargetSchedModel::hasInstrItineraries() const { return EnableSchedItins && !InstrItins.isEmpty(); } static unsigned gcd(unsigned Dividend, unsigned Divisor) { // Dividend and Divisor will be naturally swapped as needed. while(Divisor) { unsigned Rem = Dividend % Divisor; Dividend = Divisor; Divisor = Rem; }; return Dividend; } static unsigned lcm(unsigned A, unsigned B) { unsigned LCM = (uint64_t(A) * B) / gcd(A, B); assert((LCM >= A && LCM >= B) && "LCM overflow"); return LCM; } void TargetSchedModel::init(const MCSchedModel &sm, const TargetSubtargetInfo *sti, const TargetInstrInfo *tii) { SchedModel = sm; STI = sti; TII = tii; STI->initInstrItins(InstrItins); unsigned NumRes = SchedModel.<API key>(); ResourceFactors.resize(NumRes); ResourceLCM = SchedModel.IssueWidth; for (unsigned Idx = 0; Idx < NumRes; ++Idx) { unsigned NumUnits = SchedModel.getProcResource(Idx)->NumUnits; if (NumUnits > 0) ResourceLCM = lcm(ResourceLCM, NumUnits); } MicroOpFactor = ResourceLCM / SchedModel.IssueWidth; for (unsigned Idx = 0; Idx < NumRes; ++Idx) { unsigned NumUnits = SchedModel.getProcResource(Idx)->NumUnits; ResourceFactors[Idx] = NumUnits ? (ResourceLCM / NumUnits) : 0; } } unsigned TargetSchedModel::getNumMicroOps(const MachineInstr *MI, const MCSchedClassDesc *SC) const { if (hasInstrItineraries()) { int UOps = InstrItins.getNumMicroOps(MI->getDesc().getSchedClass()); return (UOps >= 0) ? UOps : TII->getNumMicroOps(&InstrItins, MI); } if (hasInstrSchedModel()) { if (!SC) SC = resolveSchedClass(MI); if (SC->isValid()) return SC->NumMicroOps; } return MI->isTransient() ? 0 : 1; } // The machine model may explicitly specify an invalid latency, which // effectively means infinite latency. Since users of the TargetSchedule API // don't know how to handle this, we convert it to a very large latency that is // easy to distinguish when debugging the DAG but won't induce overflow. static unsigned capLatency(int Cycles) { return Cycles >= 0 ? Cycles : 1000; } Return the MCSchedClassDesc for this instruction. Some SchedClasses require evaluation of predicates that depend on instruction operands or flags. const MCSchedClassDesc *TargetSchedModel:: resolveSchedClass(const MachineInstr *MI) const { // Get the definition's scheduling class descriptor from this machine model. unsigned SchedClass = MI->getDesc().getSchedClass(); const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SchedClass); if (!SCDesc->isValid()) return SCDesc; #ifndef NDEBUG unsigned NIter = 0; #endif while (SCDesc->isVariant()) { assert(++NIter < 6 && "Variants are nested deeper than the magic number"); SchedClass = STI->resolveSchedClass(SchedClass, MI, this); SCDesc = SchedModel.getSchedClassDesc(SchedClass); } return SCDesc; } Find the def index of this operand. This index maps to the machine model and is independent of use operands. Def operands may be reordered with uses or merged with uses without affecting the def index (e.g. before/after regalloc). However, an instruction's def operands must never be reordered with respect to each other. static unsigned findDefIdx(const MachineInstr *MI, unsigned DefOperIdx) { unsigned DefIdx = 0; for (unsigned i = 0; i != DefOperIdx; ++i) { const MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.isDef()) ++DefIdx; } return DefIdx; } Find the use index of this operand. This is independent of the instruction's def operands. Note that uses are not determined by the operand's isUse property, which is simply the inverse of isDef. Here we consider any readsReg operand to be a "use". The machine model allows an operand to be both a Def and Use. static unsigned findUseIdx(const MachineInstr *MI, unsigned UseOperIdx) { unsigned UseIdx = 0; for (unsigned i = 0; i != UseOperIdx; ++i) { const MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.readsReg()) ++UseIdx; } return UseIdx; } // Top-level API for clients that know the operand indices. unsigned TargetSchedModel::<API key>( const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const { if (!hasInstrSchedModel() && !hasInstrItineraries()) return TII->defaultDefLatency(SchedModel, DefMI); if (hasInstrItineraries()) { int OperLatency = 0; if (UseMI) { OperLatency = TII->getOperandLatency(&InstrItins, DefMI, DefOperIdx, UseMI, UseOperIdx); } else { unsigned DefClass = DefMI->getDesc().getSchedClass(); OperLatency = InstrItins.getOperandCycle(DefClass, DefOperIdx); } if (OperLatency >= 0) return OperLatency; // No operand latency was found. unsigned InstrLatency = TII->getInstrLatency(&InstrItins, DefMI); // Expected latency is the max of the stage latency and itinerary props. // Rather than directly querying InstrItins stage latency, we call a TII // hook to allow subtargets to specialize latency. This hook is only // applicable to the InstrItins model. InstrSchedModel should model all // special cases without TII hooks. InstrLatency = std::max(InstrLatency, TII->defaultDefLatency(SchedModel, DefMI)); return InstrLatency; } // hasInstrSchedModel() const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI); unsigned DefIdx = findDefIdx(DefMI, DefOperIdx); if (DefIdx < SCDesc-><API key>) { // Lookup the definition's write latency in SubtargetInfo. const MCWriteLatencyEntry *WLEntry = STI-><API key>(SCDesc, DefIdx); unsigned WriteID = WLEntry->WriteResourceID; unsigned Latency = capLatency(WLEntry->Cycles); if (!UseMI) return Latency; // Lookup the use's latency adjustment in SubtargetInfo. const MCSchedClassDesc *UseDesc = resolveSchedClass(UseMI); if (UseDesc-><API key> == 0) return Latency; unsigned UseIdx = findUseIdx(UseMI, UseOperIdx); int Advance = STI-><API key>(UseDesc, UseIdx, WriteID); if (Advance > 0 && (unsigned)Advance > Latency) // unsigned wrap return 0; return Latency - Advance; } // If DefIdx does not exist in the model (e.g. implicit defs), then return // unit latency (defaultDefLatency may be too conservative). #ifndef NDEBUG if (SCDesc->isValid() && !DefMI->getOperand(DefOperIdx).isImplicit() && !DefMI->getDesc().OpInfo[DefOperIdx].isOptionalDef() && SchedModel.isComplete()) { std::string Err; raw_string_ostream ss(Err); ss << "DefIdx " << DefIdx << " exceeds machine model writes for " << *DefMI; report_fatal_error(ss.str()); } #endif // FIXME: Automatically giving all implicit defs defaultDefLatency is // undesirable. We should only do it for defs that are known to the MC // desc like flags. Truly implicit defs should get 1 cycle latency. return DefMI->isTransient() ? 0 : TII->defaultDefLatency(SchedModel, DefMI); } unsigned TargetSchedModel::computeInstrLatency(unsigned Opcode) const { assert(hasInstrSchedModel() && "Only call this function with a SchedModel"); unsigned SCIdx = TII->get(Opcode).getSchedClass(); const MCSchedClassDesc *SCDesc = SchedModel.getSchedClassDesc(SCIdx); unsigned Latency = 0; if (SCDesc->isValid() && !SCDesc->isVariant()) { for (unsigned DefIdx = 0, DefEnd = SCDesc-><API key>; DefIdx != DefEnd; ++DefIdx) { // Lookup the definition's write latency in SubtargetInfo. const MCWriteLatencyEntry *WLEntry = STI-><API key>(SCDesc, DefIdx); Latency = std::max(Latency, capLatency(WLEntry->Cycles)); } return Latency; } assert(Latency && "No MI sched latency"); return 0; } unsigned TargetSchedModel::computeInstrLatency(const MachineInstr *MI, bool <API key>) const { // For the itinerary model, fall back to the old subtarget hook. // Allow subtargets to compute Bundle latencies outside the machine model. if (hasInstrItineraries() || MI->isBundle() || (!hasInstrSchedModel() && !<API key>)) return TII->getInstrLatency(&InstrItins, MI); if (hasInstrSchedModel()) { const MCSchedClassDesc *SCDesc = resolveSchedClass(MI); if (SCDesc->isValid()) { unsigned Latency = 0; for (unsigned DefIdx = 0, DefEnd = SCDesc-><API key>; DefIdx != DefEnd; ++DefIdx) { // Lookup the definition's write latency in SubtargetInfo. const MCWriteLatencyEntry *WLEntry = STI-><API key>(SCDesc, DefIdx); Latency = std::max(Latency, capLatency(WLEntry->Cycles)); } return Latency; } } return TII->defaultDefLatency(SchedModel, MI); } unsigned TargetSchedModel:: <API key>(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *DepMI) const { if (SchedModel.MicroOpBufferSize <= 1) return 1; // MicroOpBufferSize > 1 indicates an out-of-order processor that can dispatch // WAW dependencies in the same cycle. // Treat predication as a data dependency for out-of-order cpus. In-order // cpus do not need to treat predicated writes specially. // TODO: The following hack exists because predication passes do not // correctly append imp-use operands, and readsReg() strangely returns false // for predicated defs. unsigned Reg = DefMI->getOperand(DefOperIdx).getReg(); const MachineFunction &MF = *DefMI->getParent()->getParent(); const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); if (!DepMI->readsRegister(Reg, TRI) && TII->isPredicated(DepMI)) return computeInstrLatency(DefMI); // If we have a per operand scheduling model, check if this def is writing // an unbuffered resource. If so, it treated like an in-order cpu. if (hasInstrSchedModel()) { const MCSchedClassDesc *SCDesc = resolveSchedClass(DefMI); if (SCDesc->isValid()) { for (const MCWriteProcResEntry *PRI = STI-><API key>(SCDesc), *PRE = STI->getWriteProcResEnd(SCDesc); PRI != PRE; ++PRI) { if (!SchedModel.getProcResource(PRI->ProcResourceIdx)->BufferSize) return 1; } } } return 0; }
assert.throw(function() { class C extends Math {} }, 'Super expression must either be null or a function'); assert.throw(function() { function f() {} // prototype needs to be an Object or null. f.prototype = 42; class C extends f {} }, 'super prototype must be an Object or null');
<!DOCTYPE html> <meta charset="utf-8"> <title>CSS Test: hsl() values</title> <link rel="author" title="L. David Baron" href="http://dbaron.org/" /> <link rel="author" title="Mozilla Corporation" href="http://mozilla.com/" /> <link rel="author" title="Intel" href="http: <link rel="help" href="http://www.w3.org/TR/css3-color/#hsl-color" /> <link rel="match" href="reference/<API key>.html" /> <meta name="flags" content="" /> <meta name="assert" content="Implementation of algorithm for converting hsl() colors to rgb() colors." /> <style> table { border-spacing: 0; padding: 0; border: none; } td { border: none; padding: 0; } td { width: 1.2em; height: 1.2em; } </style> <body> <p>The following two matching (except the checkerboard at both ends to show where the rows are) rows of colors should change in ten steps from black at the left to white at the right with blue at the middle.</p> <table> <tr> <td style="background: black">&nbsp;</td> <td style="background: hsl(240, 100%, 0%)">&nbsp;</td> <td style="background: hsl(240, 100%, 10%)">&nbsp;</td> <td style="background: hsl(240, 100%, 20%)">&nbsp;</td> <td style="background: hsl(240, 100%, 30%)">&nbsp;</td> <td style="background: hsl(240, 100%, 40%)">&nbsp;</td> <td style="background: hsl(240, 100%, 50%)">&nbsp;</td> <td style="background: hsl(240, 100%, 60%)">&nbsp;</td> <td style="background: hsl(240, 100%, 70%)">&nbsp;</td> <td style="background: hsl(240, 100%, 80%)">&nbsp;</td> <td style="background: hsl(240, 100%, 90%)">&nbsp;</td> <td style="background: hsl(240, 100%, 100%)">&nbsp;</td> <td style="background: white">&nbsp;</td> </tr> <tr> <td style="background: white">&nbsp;</td> <td style="background: rgb(0, 0, 0)">&nbsp;</td> <td style="background: rgb(0, 0, 51)">&nbsp;</td> <td style="background: rgb(0, 0, 102)">&nbsp;</td> <td style="background: rgb(0, 0, 153)">&nbsp;</td> <td style="background: rgb(0, 0, 204)">&nbsp;</td> <td style="background: rgb(0, 0, 255)">&nbsp;</td> <td style="background: rgb(51, 51, 255)">&nbsp;</td> <td style="background: rgb(102, 102, 255)">&nbsp;</td> <td style="background: rgb(153, 153, 255)">&nbsp;</td> <td style="background: rgb(204, 204, 255)">&nbsp;</td> <td style="background: rgb(255, 255, 255)">&nbsp;</td> <td style="background: black">&nbsp;</td> </tr> </table> </body>
#ifndef <API key> #define <API key> #include <list> #include <map> #include <set> #include <utility> #include <vector> #include "base/memory/weak_ptr.h" #include "media/base/pipeline_status.h" #include "media/base/video_decoder.h" #include "media/video/<API key>.h" template <class T> class scoped_refptr; namespace base { class MessageLoopProxy; class SharedMemory; } namespace media { class DecoderBuffer; class <API key>; // GPU-accelerated video decoder implementation. Relies on // <API key> and friends. class MEDIA_EXPORT GpuVideoDecoder : public VideoDecoder, public <API key>::Client { public: // The message loop of |factories| will be saved to |gvd_loop_proxy_|. explicit GpuVideoDecoder( const scoped_refptr<<API key>>& factories); // VideoDecoder implementation. virtual void Initialize(const VideoDecoderConfig& config, const PipelineStatusCB& status_cb) OVERRIDE; virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, const DecodeCB& decode_cb) OVERRIDE; virtual void Reset(const base::Closure& closure) OVERRIDE; virtual void Stop(const base::Closure& closure) OVERRIDE; virtual bool HasAlpha() const OVERRIDE; virtual bool <API key>() const OVERRIDE; virtual bool <API key>() const OVERRIDE; // <API key>::Client implementation. virtual void <API key>() OVERRIDE; virtual void <API key>(uint32 count, const gfx::Size& size, uint32 texture_target) OVERRIDE; virtual void <API key>(int32 id) OVERRIDE; virtual void PictureReady(const media::Picture& picture) OVERRIDE; virtual void <API key>(int32 id) OVERRIDE; virtual void NotifyFlushDone() OVERRIDE; virtual void NotifyResetDone() OVERRIDE; virtual void NotifyError(media::<API key>::Error error) OVERRIDE; protected: virtual ~GpuVideoDecoder(); private: enum State { kNormal, kDrainingDecoder, kDecoderDrained, kError }; // Return true if more decode work can be piled on to the VDA. bool <API key>(); // Enqueue a frame for later delivery (or drop it on the floor if a // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest // ready frame to the client if there is a pending read. A NULL |frame| // merely triggers delivery, and requires the ready_video_frames_ queue not be // empty. void <API key>( const scoped_refptr<VideoFrame>& frame); // Indicate the picture buffer can be reused by the decoder. void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); void RecordBufferData( const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); void GetBufferData(int32 id, base::TimeDelta* timetamp, gfx::Rect* visible_rect, gfx::Size* natural_size); void DestroyVDA(); // A shared memory segment and its allocated size. struct SHMBuffer { SHMBuffer(base::SharedMemory* m, size_t s); ~SHMBuffer(); base::SharedMemory* shm; size_t size; }; // Request a shared-memory segment of at least |min_size| bytes. Will // allocate as necessary. Caller does not own returned pointer. SHMBuffer* GetSHM(size_t min_size); // Return a shared-memory segment to the available pool. void PutSHM(SHMBuffer* shm_buffer); void DestroyTextures(); bool <API key>; // Message loop which this class and |factories_| run on. scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; base::WeakPtr<GpuVideoDecoder> weak_this_; scoped_refptr<<API key>> factories_; // Populated during Initialize() (on success) and unchanged until an error // occurs. scoped_ptr<<API key>> vda_; // Callbacks that are !is_null() only during their respective operation being // asynchronously executed. DecodeCB pending_decode_cb_; base::Closure pending_reset_cb_; State state_; VideoDecoderConfig config_; // Shared-memory buffer pool. Since allocating SHM segments requires a // round-trip to the browser process, we keep allocation out of the // steady-state of the decoder. std::vector<SHMBuffer*> <API key>; // Book-keeping variables. struct BufferPair { BufferPair(SHMBuffer* s, const scoped_refptr<DecoderBuffer>& b); ~BufferPair(); SHMBuffer* shm_buffer; scoped_refptr<DecoderBuffer> buffer; }; std::map<int32, BufferPair> <API key>; std::map<int32, PictureBuffer> <API key>; std::map<int32, PictureBuffer> <API key>; // PictureBuffers given to us by VDA via PictureReady, which we sent forward // as VideoFrames to be rendered via decode_cb_, and which will be returned // to us via ReusePictureBuffer. std::set<int32> <API key>; // The texture target used for decoded pictures. uint32 <API key>; struct BufferData { BufferData(int32 bbid, base::TimeDelta ts, const gfx::Rect& visible_rect, const gfx::Size& natural_size); ~BufferData(); int32 bitstream_buffer_id; base::TimeDelta timestamp; gfx::Rect visible_rect; gfx::Size natural_size; }; std::list<BufferData> input_buffer_data_; // picture_buffer_id and the frame wrapping the corresponding Picture, for // frames that have been decoded but haven't been requested by a Decode() yet. std::list<scoped_refptr<VideoFrame> > ready_video_frames_; int32 <API key>; int32 <API key>; // Set during <API key>(), used for checking and implementing // <API key>(). int available_pictures_; <API key>(GpuVideoDecoder); }; } // namespace media #endif // <API key>
// Use of this source code is governed by a BSD-style // This is the input program for an end-to-end test of the DWARF produced // by the compiler. It is compiled with various flags, then the resulting // binary is "debugged" under the control of a harness. Because the compile+debug // step is time-consuming, the tests for different bugs are all accumulated here // so that their cost is only the time to "n" through the additional code. package main import ( "bufio" "fmt" "io" "os" "strconv" "strings" ) type point struct { x, y int } type line struct { begin, end point } var zero int var sink int //go:noinline func tinycall() { } func ensure(n int, sl []int) []int { for len(sl) <= n { sl = append(sl, 0) } return sl } var cannedInput string = `1 1 1 2 2 2 4 4 5 ` func test() { // For #19868 l := line{point{1 + zero, 2 + zero}, point{3 + zero, 4 + zero}} tinycall() // this forces l etc to stack dx := l.end.x - l.begin.x //gdb-dbg=(l.begin.x,l.end.y)//gdb-opt=(l,dx/O,dy/O) dy := l.end.y - l.begin.y //gdb-opt=(dx,dy/O) sink = dx + dy //gdb-opt=(dx,dy) // For #21098 hist := make([]int, 7) //gdb-opt=(dx/O,dy/O) // TODO sink is missing if this code is in 'test' instead of 'main' var reader io.Reader = strings.NewReader(cannedInput) //gdb-dbg=(hist/A) // TODO cannedInput/A is missing if this code is in 'test' instead of 'main' if len(os.Args) > 1 { var err error reader, err = os.Open(os.Args[1]) if err != nil { fmt.Fprintf(os.Stderr, "There was an error opening %s: %v\n", os.Args[1], err) return } } scanner := bufio.NewScanner(reader) for scanner.Scan() { //gdb-opt=(scanner/A) s := scanner.Text() i, err := strconv.ParseInt(s, 10, 64) if err != nil { //gdb-dbg=(i) //gdb-opt=(err,hist,i) fmt.Fprintf(os.Stderr, "There was an error: %v\n", err) return } hist = ensure(int(i), hist) hist[int(i)]++ } t := 0 n := 0 for i, a := range hist { if a == 0 { //gdb-opt=(a,n,t) continue } t += i * a n += a fmt.Fprintf(os.Stderr, "%d\t%d\t%d\t%d\t%d\n", i, a, n, i*a, t) //gdb-dbg=(n,i,t) } } func main() { growstack() // Use stack early to prevent growth during test, which confuses gdb test() } var snk string //go:noinline func growstack() { snk = fmt.Sprintf("%#v,%#v,%#v", 1, true, "cat") }
<!doctype html> <title>select size=0 renders the same as plain select</title> <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1643279"> <link rel="author" title="Mozilla" href="https://mozilla.org"> <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> <link rel="match" href="select-size-ref.html"> <select size="0"> <option value ="1">1</option> <option value ="2">2</option> <option value ="3">3</option> </select>
#include <stddef.h> #include "chrome/browser/ui/tabs/<API key>.h" namespace { std::string TabToString(const StartupTab& tab) { return tab.url.spec() + ":" + (tab.is_pinned ? "pinned" : ""); } } // namespace // static std::string PinnedTabTestUtils::TabsToString( const std::vector<StartupTab>& values) { std::string result; for (size_t i = 0; i < values.size(); ++i) { if (i != 0) result += " "; result += TabToString(values[i]); } return result; }
<!DOCTYPE html> <meta charset="UTF-8"> <title>CSS Reference Test</title> <link rel="author" title="Gérard Talbot" href="http: <style> div { border: black solid 2px; font-family: monospace; font-size: 32px; width: 10ch; } </style> <div>Deoxy&#x2010;<br>ribonucleic acid</div> <! Hyphen-minus == &#x002D; == &#0045; Hyphen == &#x2010; == &#8208;
// RUN: %clang_cc1 -ffreestanding %s -triple=i386-pc-win32 -target-feature -sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s // RUN: %clang_cc1 -ffreestanding %s -triple=i386-pc-win32 -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s #include <x86intrin.h> void test_mm_pause() { // CHECK-LABEL: test_mm_pause // CHECK: call void @llvm.x86.sse2.pause() return _mm_pause(); }
import { CSSModule } from '../index'; export interface CardImgProps extends React.HTMLAttributes<HTMLElement> { tag?: React.ReactType; top?: boolean; bottom?: boolean; className?: string; cssModule?: CSSModule; src?: string; width?: string; height?: string; alt?: string; } declare const CardImg: React.StatelessComponent<CardImgProps>; export default CardImg;
(function () { "use strict"; var StartScreen = Windows.UI.StartScreen; var JumpList = StartScreen.JumpList; var page = WinJS.UI.Pages.define("/html/<API key>.html", { ready: function (element, options) { Supported.innerText = JumpList.isSupported() ? "supports" : "does not support"; } }); })();
// Unit tests for block.CheckBlock() #include "main.h" #include "auxpow.h" #include <cstdio> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> #include <boost/test/unit_test.hpp> <API key>(CheckBlock_tests) bool read_block(const std::string& filename, CBlock& block) { namespace fs = boost::filesystem; fs::path testFile = fs::current_path() / "data" / filename; #ifdef TEST_DATA_DIR if (!fs::exists(testFile)) { testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; } #endif FILE* fp = fopen(testFile.string().c_str(), "rb"); if (!fp) return false; fseek(fp, 8, SEEK_SET); // skip msgheader/size CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION); if (!filein) return false; filein >> block; return true; } <API key>(May15) { // Putting a 1MB binary file in the git repository is not a great // idea, so this test is only run if you manually download // test/data/Mar12Fork.dat from unsigned int tMay15 = 1368576000; SetMockTime(tMay15); // Test as if it was right at May 15 CBlock forkingBlock; if (read_block("Mar12Fork.dat", forkingBlock)) { CValidationState state; // After May 15'th, big blocks are OK: forkingBlock.nTime = tMay15; // Invalidates PoW BOOST_CHECK(CheckBlock(forkingBlock, state, false, false)); } SetMockTime(0); } <API key>()
<div class="debug support-section"> <h3><?php _e( 'Diagnostic Info', '<API key>' ); ?></h3> <textarea class="debug-log-textarea" autocomplete="off" readonly><?php $this-><API key>(); ?></textarea> <?php $args = array( 'nonce' => wp_create_nonce( 'as3cf-download-log' ), 'as3cf-download-log' => '1', 'hash' => 'support', ); $url = $this->get_plugin_page_url( $args, 'network', false ); ?> <a href="<?php echo esc_url( $url ); ?>" class="button"><?php _ex( 'Download', 'Download to your computer', '<API key>' ); ?></a> </div>
.<API key>,.<API key>{display:none}.yui3-calendar-day{cursor:pointer}.<API key>{cursor:default}.<API key>{cursor:default}.<API key>{cursor:default}.<API key>:hover .yui3-calendar-day,.<API key>:hover .<API key>,.<API key>:hover .<API key>{-moz-user-select:none}.yui3-skin-sam .<API key>{background-color:#dcdef5}.yui3-skin-sam .<API key>.<API key>{background-color:#758fbb}#yui3-css-stamp.skin-sam-calendar{display:none}
<?php class <API key> extends <API key> { public function getTestName() { return 'GetDeleted'; } protected function _run() { $sObject = new stdclass(); $sObject->FirstName = 'Smith'; $sObject->LastName = 'John'; $sObject->Phone = '510-555-5555'; $sObject->BirthDate = '1927-01-25'; echo "**** Creating the following:\n"; $createResponse = $this->_mySforceConnection->create(array($sObject), 'Contact'); print_r($createResponse); $id = $createResponse->id; $deleteResponse = $this->_mySforceConnection->delete(array ($id)); echo "***** Deleting record *****\n"; print_r($deleteResponse); echo "***** Wait 60 seconds *****\n"; sleep(60); $currentTime = mktime(); // assume that delete occured within the last 5 mins. $startTime = $currentTime - (60*10); $endTime = $currentTime; echo "***** Get Deleted Leads *****\n"; $getDeletedResponse = $this->_mySforceConnection->getDeleted('Contact', $startTime, $endTime); print_r($getDeletedResponse); } }
/* Test conversions of signaling NaNs to and from long double. */ #include <stdint.h> #include <stdio.h> volatile float f_res; volatile double d_res; volatile long double ld_res; volatile float f_snan = __builtin_nansf(""); volatile double d_snan = __builtin_nans(""); volatile long double ld_snan = __builtin_nansl(""); int issignaling_f(float x) { union { float f; uint32_t u; } u = { .f = x }; return (u.u & 0x7fffffff) > 0x7f800000 && (u.u & 0x400000) == 0; } int issignaling_d(double x) { union { double d; uint64_t u; } u = { .d = x }; return (((u.u & UINT64_C(0x7fffffffffffffff)) > UINT64_C(0x7ff0000000000000)) && (u.u & UINT64_C(0x8000000000000)) == 0); } int issignaling_ld(long double x) { union { long double ld; struct { uint64_t sig; uint16_t sign_exp; } s; } u = { .ld = x }; return ((u.s.sign_exp & 0x7fff) == 0x7fff && (u.s.sig >> 63) != 0 && (u.s.sig & UINT64_C(0x4000000000000000)) == 0); } int main(void) { int ret = 0; ld_res = f_snan; if (issignaling_ld(ld_res)) { printf("FAIL: float -> long double\n"); ret = 1; } ld_res = d_snan; if (issignaling_ld(ld_res)) { printf("FAIL: double -> long double\n"); ret = 1; } f_res = ld_snan; if (issignaling_d(f_res)) { printf("FAIL: long double -> float\n"); ret = 1; } d_res = ld_snan; if (issignaling_d(d_res)) { printf("FAIL: long double -> double\n"); ret = 1; } return ret; }
include $(TOPDIR)/rules.mk PKG_NAME:=yunbridge PKG_VERSION:=1.6.0 PKG_RELEASE:=1 PKG_SOURCE_URL:=https://codeload.github.com/arduino/YunBridge/tar.gz/$(PKG_VERSION)? PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_HASH:=<SHA256-like> PKG_BUILD_DIR:=$(BUILD_DIR)/YunBridge-$(PKG_VERSION) PKG_MAINTAINER:=John Crispin <blogic@openwrt.org> PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk define Package/yunbridge SECTION:=utils CATEGORY:=Utilities TITLE:=Arduino YUN bridge library URL:=http://arduino.cc/ DEPENDS:=+python endef define Package/yunbridge/description Arduino YUN bridge library endef define Build/Compile true endef define Package/yunbridge/install mkdir -p $(1)/usr/lib/python2.7/bridge
#include "ash/accelerators/<API key>.h" #if defined(USE_X11) #include <X11/Xlib.h> // Xlib defines RootWindow #ifdef RootWindow #undef RootWindow #endif #endif // defined(USE_X11) #include "ash/accelerators/<API key>.h" #include "ash/shell.h" #include "ash/wm/<API key>.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/base/accelerators/accelerator.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" #include "ui/events/event_utils.h" #include "ui/views/controls/menu/menu_controller.h" namespace ash { namespace { const int kModifierMask = (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN); #if defined(OS_WIN) bool IsKeyEvent(const MSG& msg) { return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN || msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP; } #elif defined(USE_X11) bool IsKeyEvent(const XEvent* xev) { return xev->type == KeyPress || xev->type == KeyRelease; } #elif defined(USE_OZONE) bool IsKeyEvent(const base::NativeEvent& native_event) { const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); return event->IsKeyEvent(); } #endif bool <API key>(const ui::KeyEvent& key_event) { // For shortcuts generated by Ctrl or Alt plus a letter, number or // the tab key, we want to exit the context menu first and then // repost the event. That allows for the shortcut execution after // the context menu has exited. if (key_event.type() == ui::ET_KEY_PRESSED && (key_event.flags() & (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))) { const ui::KeyboardCode key_code = key_event.key_code(); if ((key_code >= ui::VKEY_A && key_code <= ui::VKEY_Z) || (key_code >= ui::VKEY_0 && key_code <= ui::VKEY_9) || (key_code == ui::VKEY_TAB)) { return true; } } return false; } } // namespace <API key>::<API key>( base::MessageLoop::Dispatcher* nested_dispatcher, aura::Window* associated_window) : nested_dispatcher_(nested_dispatcher), associated_window_(associated_window) { DCHECK(nested_dispatcher_); associated_window_->AddObserver(this); } <API key>::~<API key>() { if (associated_window_) associated_window_->RemoveObserver(this); } void <API key>::OnWindowDestroying(aura::Window* window) { if (associated_window_ == window) associated_window_ = NULL; } bool <API key>::Dispatch(const base::NativeEvent& event) { if (!associated_window_) return false; if (!ui::IsNoopEvent(event) && !associated_window_->CanReceiveEvents()) return aura::Env::GetInstance()->GetDispatcher()->Dispatch(event); if (IsKeyEvent(event)) { // Modifiers can be changed by the user preference, so we need to rewrite // the event explicitly. ui::KeyEvent key_event(event, false); ui::EventHandler* event_rewriter = ash::Shell::GetInstance()-><API key>(); DCHECK(event_rewriter); event_rewriter->OnKeyEvent(&key_event); if (key_event.stopped_propagation()) return true; if (<API key>(key_event)) { if (views::MenuController* menu_controller = views::MenuController::GetActiveInstance()) { menu_controller->CancelAll(); #if defined(USE_X11) XPutBackEvent(event->xany.display, event); #else NOTIMPLEMENTED() << " Repost NativeEvent here."; #endif return false; } } ash::<API key>* <API key> = ash::Shell::GetInstance()-><API key>(); if (<API key>) { ui::Accelerator accelerator(key_event.key_code(), key_event.flags() & kModifierMask); if (key_event.type() == ui::ET_KEY_RELEASED) accelerator.set_type(ui::ET_KEY_RELEASED); // Fill out context object so <API key> will know what // was the previous accelerator or if the current accelerator is repeated. Shell::GetInstance()-><API key>()->context()-> UpdateContext(accelerator); if (<API key>->Process(accelerator)) return true; } return nested_dispatcher_->Dispatch(key_event.native_event()); } return nested_dispatcher_->Dispatch(event); } } // namespace ash
#include <linux/init.h> #include <linux/device.h> #include <linux/platform_device.h> #include <linux/regulator/machine.h> #include <linux/i2c.h> #include <mach/irqs.h> #include <linux/power_supply.h> #include <linux/apm_bios.h> #include <linux/apm-emulation.h> #include "axp-mfd.h" #include "axp-cfg.h" /* Reverse engineered partly from Platformx drivers */ enum axp_regls{ vcc_ldo1, vcc_ldo2, vcc_ldo3, vcc_ldo4, vcc_ldo5, vcc_buck1, vcc_buck2, vcc_buck3, vcc_ldoio0, }; /* The values of the various regulator constraints are obviously dependent * on exactly what is wired to each ldo. Unfortunately this information is * not generally available. More information has been requested from Xbow * but as of yet they haven't been forthcoming. * * Some of these are clearly Stargate 2 related (no way of plugging * in an lcd on the IM2 for example!). */ static struct <API key> ldo1_data[] = { { .supply = "axp19_rtc", }, }; static struct <API key> ldo2_data[] = { { .supply = "axp19_analog/fm", }, }; static struct <API key> ldo3_data[] = { { .supply = "axp19_pll/sdram", }, }; static struct <API key> ldo4_data[] = { { .supply = "axp19_hdmi", }, }; static struct <API key> ldoio0_data[] = { { .supply = "axp19_mic", }, }; static struct <API key> buck1_data[] = { { .supply = "axp19_io", }, }; static struct <API key> buck2_data[] = { { .supply = "axp19_core", }, }; static struct <API key> buck3_data[] = { { .supply = "axp19_ddr", }, }; static struct regulator_init_data axp_regl_init_data[] = { [vcc_ldo1] = { .constraints = { /* board default 1.25V */ .name = "axp19_ldo1", .min_uV = AXP19LDO1 * 1000, .max_uV = AXP19LDO1 * 1000, }, .<API key> = ARRAY_SIZE(ldo1_data), .consumer_supplies = ldo1_data, }, [vcc_ldo2] = { .constraints = { /* board default 3.0V */ .name = "axp19_ldo2", .min_uV = 1800000, .max_uV = 3300000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(ldo2_data), .consumer_supplies = ldo2_data, }, [vcc_ldo3] = { .constraints = {/* default is 1.8V */ .name = "axp19_ldo3", .min_uV = 700 * 1000, .max_uV = 3500* 1000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(ldo3_data), .consumer_supplies = ldo3_data, }, [vcc_ldo4] = { .constraints = { /* board default is 3.3V */ .name = "axp19_ldo4", .min_uV = 1800000, .max_uV = 3300000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(ldo4_data), .consumer_supplies = ldo4_data, }, [vcc_buck1] = { .constraints = { /* default 3.3V */ .name = "axp19_buck1", .min_uV = 700000, .max_uV = 3500000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(buck1_data), .consumer_supplies = buck1_data, }, [vcc_buck2] = { .constraints = { /* default 1.24V */ .name = "axp19_buck2", .min_uV = 700 * 1000, .max_uV = 2275 * 1000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(buck2_data), .consumer_supplies = buck2_data, }, [vcc_buck3] = { .constraints = { /* default 2.5V */ .name = "axp19_buck3", .min_uV = 700 * 1000, .max_uV = 3500 * 1000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(buck3_data), .consumer_supplies = buck3_data, }, [vcc_ldoio0] = { .constraints = { /* default 2.5V */ .name = "axp19_ldoio0", .min_uV = 1800 * 1000, .max_uV = 3300 * 1000, .valid_ops_mask = <API key> | <API key>, }, .<API key> = ARRAY_SIZE(ldoio0_data), .consumer_supplies = ldoio0_data, }, }; static struct axp_funcdev_info axp_regldevs[] = { { .name = "axp19-regulator", .id = AXP19_ID_LDO1, .platform_data = &axp_regl_init_data[vcc_ldo1], }, { .name = "axp19-regulator", .id = AXP19_ID_LDO2, .platform_data = &axp_regl_init_data[vcc_ldo2], }, { .name = "axp19-regulator", .id = AXP19_ID_LDO3, .platform_data = &axp_regl_init_data[vcc_ldo3], }, { .name = "axp19-regulator", .id = AXP19_ID_LDO4, .platform_data = &axp_regl_init_data[vcc_ldo4], }, { .name = "axp19-regulator", .id = AXP19_ID_BUCK1, .platform_data = &axp_regl_init_data[vcc_buck1], }, { .name = "axp19-regulator", .id = AXP19_ID_BUCK2, .platform_data = &axp_regl_init_data[vcc_buck2], }, { .name = "axp19-regulator", .id = AXP19_ID_BUCK3, .platform_data = &axp_regl_init_data[vcc_buck3], }, { .name = "axp19-regulator", .id = AXP19_ID_LDOIO0, .platform_data = &axp_regl_init_data[vcc_ldoio0], }, }; static struct power_supply_info battery_data ={ .name ="PTI PL336078", .technology = <API key>, .voltage_max_design = 4200000, .voltage_min_design = 2700000, .charge_full_design = 1450, .energy_full_design = 1450, .use_for_apm = 1, }; static void axp_battery_low(void) { #if defined(<API key>) apm_queue_event(APM_LOW_BATTERY); #endif } static void <API key>(void) { #if defined(<API key>) apm_queue_event(<API key>); #endif } static struct <API key> axp_sply_init_data = { .battery_info = &battery_data, .chgcur = 700, .chgvol = 4200, .chgend = 60, .chgen = 1, //.limit_on = 1, .sample_time = 25, .chgpretime = 40, .chgcsttime = 480, .battery_low = axp_battery_low, .battery_critical = <API key>, }; static struct axp_funcdev_info axp_splydev[]={ { .name = "axp19-supplyer", .id = AXP19_ID_SUPPLY, .platform_data = &axp_sply_init_data, }, }; static struct axp_funcdev_info axp_gpiodev[]={ { .name = "axp19-gpio", .id = AXP19_ID_GPIO, }, }; static struct axp_platform_data axp_pdata = { .num_regl_devs = ARRAY_SIZE(axp_regldevs), .num_sply_devs = ARRAY_SIZE(axp_splydev), .num_gpio_devs = ARRAY_SIZE(axp_gpiodev), .regl_devs = axp_regldevs, .sply_devs = axp_splydev, .gpio_devs = axp_gpiodev, }; static struct i2c_board_info __initdata <API key>[] = { { .type = "axp19_mfd", .addr = AXP19_ADDR, .platform_data = &axp_pdata, .irq = SW_INT_IRQNO_ENMI, }, }; static int __init axp_board_init(void) { return <API key>(AXP19_I2CBUS, <API key>, ARRAY_SIZE(<API key>)); } fs_initcall(axp_board_init); MODULE_DESCRIPTION("Krosspower axp board"); MODULE_AUTHOR("Donglu Zhang Krosspower"); MODULE_LICENSE("GPL");
#include "prototype.h" #include <avr/io.h> #include "backlight.h" #include "print.h" void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up matrix_init_user(); led_init_ports(); } void matrix_scan_kb(void) { matrix_scan_user(); } void <API key>(void) { print("init_backlight_pin()\n"); // Set our LED pins as output DDRD |= (1<<0); // Esc DDRD |= (1<<4); // Page Up DDRD |= (1<<1); // Arrows // Set our LED pins low PORTD &= ~(1<<0); // Esc PORTD &= ~(1<<4); // Page Up PORTD &= ~(1<<1); // Arrows } void backlight_set(uint8_t level) { if ( level == 0 ) { // Turn off light PORTD |= (1<<0); // Esc PORTD |= (1<<4); // Page Up PORTD |= (1<<1); // Arrows } else { // Turn on light PORTD &= ~(1<<0); // Esc PORTD &= ~(1<<4); // Page Up PORTD &= ~(1<<1); // Arrows } } void led_init_ports() { // * Set our LED pins as output DDRB |= (1<<4); } void led_set_kb(uint8_t usb_led) { DDRB |= (1<<4); if (usb_led & (1<<USB_LED_CAPS_LOCK)) { // Turn capslock on PORTB |= (1<<4); } else { // Turn capslock off PORTB &= ~(1<<4); } }
#pragma once #ifndef REPORTSWIDGET_H #define REPORTSWIDGET_H #include <QWidget> #include "ResourceObjects/Resource.h" #include "BookManipulation/Book.h" /** * Base Interface for reports widgets. */ class ReportsWidget : public QWidget { Q_OBJECT public: virtual void CreateReport(QSharedPointer< Book > book) = 0; }; #endif // REPORTSWIDGET_H
#include <config.h> #include "roken.h" /* * return a malloced copy of `h' */ struct hostent * ROKEN_LIB_FUNCTION copyhostent (const struct hostent *h) { struct hostent *res; char **p; int i, n; res = malloc (sizeof (*res)); if (res == NULL) return NULL; res->h_name = NULL; res->h_aliases = NULL; res->h_addrtype = h->h_addrtype; res->h_length = h->h_length; res->h_addr_list = NULL; res->h_name = strdup (h->h_name); if (res->h_name == NULL) { freehostent (res); return NULL; } for (n = 0, p = h->h_aliases; *p != NULL; ++p) ++n; res->h_aliases = malloc ((n + 1) * sizeof(*res->h_aliases)); if (res->h_aliases == NULL) { freehostent (res); return NULL; } for (i = 0; i < n + 1; ++i) res->h_aliases[i] = NULL; for (i = 0; i < n; ++i) { res->h_aliases[i] = strdup (h->h_aliases[i]); if (res->h_aliases[i] == NULL) { freehostent (res); return NULL; } } for (n = 0, p = h->h_addr_list; *p != NULL; ++p) ++n; res->h_addr_list = malloc ((n + 1) * sizeof(*res->h_addr_list)); if (res->h_addr_list == NULL) { freehostent (res); return NULL; } for (i = 0; i < n + 1; ++i) { res->h_addr_list[i] = NULL; } for (i = 0; i < n; ++i) { res->h_addr_list[i] = malloc (h->h_length); if (res->h_addr_list[i] == NULL) { freehostent (res); return NULL; } memcpy (res->h_addr_list[i], h->h_addr_list[i], h->h_length); } return res; }
<!DOCTYPE html> <html lang="en" > <head> <meta charset="utf-8"/> <title>CSS3 Text, linebreaks: FF01 FULLWIDTH EXCLAMATION MARK (strict,zh)</title> <link rel='author' title='Richard Ishida' href='mailto:ishida@w3.org'> <meta name='flags' content='font'> <style type='text/css'> @font-face { font-family: 'mplus-1p-regular'; src: url('support/mplus-1p-regular.woff') format('woff'); /* filesize: 803K */ } .test, .ref { font-size: 30px; font-family: mplus-1p-regular, sans-serif; width: 93px; padding: 0; border: 1px solid orange; line-height: 1em; } .name { font-size: 10px; } .test { line-break: strict; } </style> </head> <body> <p class='instructions'>Test passes if the two orange boxes are identical.</p> <div class='ref'><br/>&#xFF01;</div></div> <div class='ref'><br/>&#xFF01;</div></div> </body> </html>
<?php use Illuminate\Database\Migrations\Migration; class <API key> extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('locations', function ($table) { $table->increments('id'); $table->string('name'); $table->string('city'); $table->string('state',2); $table->string('country',2); $table->timestamps(); $table->integer('user_id'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('locations'); } }
/* jshint phantom:true, devel: true */ var RED = "\x1b\x5b31;1m"; var GREEN = "\x1b\x5b32;1m"; var RESET = "\x1b\x5b0m"; function passLog(msg) { console.log(GREEN + "JS: " + msg + RESET); } function failLog(msg) { console.log(RED + "JS: " + msg + RESET); } // PhantomJS driver for loading Enyo core tests and checking for failures var page = require('webpage').create(); var totalMsgs = 0; page.onConsoleMessage = function (msg) { ++totalMsgs; if (msg.match(/FAILED TEST/)) { failLog(msg); } else { console.log("JS: " + msg); } if (msg === "TEST RUNNER FINISHED") { var pass = totalMsgs > 1 && page.evaluate(function() { return (document.querySelector(".<API key>") === null); }); if (pass) { passLog("Enyo core tests passed!"); phantom.exit(0); } else { failLog("Enyo core tests failed. :("); phantom.exit(1); } } }; page.onError = function(msg, trace) { phantom.exit(1); }; page.open("tools/test/core/index.html", function(status) { if (status !== "success") { failLog("Error loading page, status: " + status); phantom.exit(1); } }); setTimeout(function() { failLog("timed out after 1 minute"); phantom.exit(1); }, 60 * 1000);
# -*- coding: utf-8 -*- import webapp2 from webapp2_extras import sessions from webapp2_extras import sessions_memcache import test_base app = webapp2.WSGIApplication(config={ 'webapp2_extras.sessions': { 'secret_key': 'my-super-secret', }, }) class TestMemcacheSession(test_base.BaseTestCase): #factory = sessions_memcache.<API key> def <API key>(self): req = webapp2.Request.blank('/') req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') rsp = webapp2.Response() # Nothing changed, we want to test anyway. store.save_sessions(rsp) session['a'] = 'b' session['c'] = 'd' session['e'] = 'f' store.save_sessions(rsp) cookies = rsp.headers.get('Set-Cookie') req = webapp2.Request.blank('/', headers=[('Cookie', cookies)]) req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') self.assertEqual(session['a'], 'b') self.assertEqual(session['c'], 'd') self.assertEqual(session['e'], 'f') session['g'] = 'h' rsp = webapp2.Response() store.save_sessions(rsp) cookies = rsp.headers.get('Set-Cookie') req = webapp2.Request.blank('/', headers=[('Cookie', cookies)]) req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') self.assertEqual(session['a'], 'b') self.assertEqual(session['c'], 'd') self.assertEqual(session['e'], 'f') self.assertEqual(session['g'], 'h') def test_flashes(self): req = webapp2.Request.blank('/') req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') flashes = session.get_flashes() self.assertEqual(flashes, []) session.add_flash('foo') rsp = webapp2.Response() store.save_sessions(rsp) cookies = rsp.headers.get('Set-Cookie') req = webapp2.Request.blank('/', headers=[('Cookie', cookies)]) req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') flashes = session.get_flashes() self.assertEqual(flashes, [(u'foo', None)]) flashes = session.get_flashes() self.assertEqual(flashes, []) session.add_flash('bar') session.add_flash('baz', 'important') rsp = webapp2.Response() store.save_sessions(rsp) cookies = rsp.headers.get('Set-Cookie') req = webapp2.Request.blank('/', headers=[('Cookie', cookies)]) req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') flashes = session.get_flashes() self.assertEqual(flashes, [(u'bar', None), (u'baz', 'important')]) flashes = session.get_flashes() self.assertEqual(flashes, []) rsp = webapp2.Response() store.save_sessions(rsp) cookies = rsp.headers.get('Set-Cookie') req = webapp2.Request.blank('/', headers=[('Cookie', cookies)]) req.app = app store = sessions.SessionStore(req) session = store.get_session(backend='memcache') flashes = session.get_flashes() self.assertEqual(flashes, []) if __name__ == '__main__': test_base.main()
#ifndef _SAMD20J15_PIO_ #define _SAMD20J15_PIO_ #define PIN_PA00 0 /**< \brief Pin Number for PA00 */ #define PORT_PA00 (1ul << 0) /**< \brief PORT Mask for PA00 */ #define PIN_PA01 1 /**< \brief Pin Number for PA01 */ #define PORT_PA01 (1ul << 1) /**< \brief PORT Mask for PA01 */ #define PIN_PA02 2 /**< \brief Pin Number for PA02 */ #define PORT_PA02 (1ul << 2) /**< \brief PORT Mask for PA02 */ #define PIN_PA03 3 /**< \brief Pin Number for PA03 */ #define PORT_PA03 (1ul << 3) /**< \brief PORT Mask for PA03 */ #define PIN_PA04 4 /**< \brief Pin Number for PA04 */ #define PORT_PA04 (1ul << 4) /**< \brief PORT Mask for PA04 */ #define PIN_PA05 5 /**< \brief Pin Number for PA05 */ #define PORT_PA05 (1ul << 5) /**< \brief PORT Mask for PA05 */ #define PIN_PA06 6 /**< \brief Pin Number for PA06 */ #define PORT_PA06 (1ul << 6) /**< \brief PORT Mask for PA06 */ #define PIN_PA07 7 /**< \brief Pin Number for PA07 */ #define PORT_PA07 (1ul << 7) /**< \brief PORT Mask for PA07 */ #define PIN_PA08 8 /**< \brief Pin Number for PA08 */ #define PORT_PA08 (1ul << 8) /**< \brief PORT Mask for PA08 */ #define PIN_PA09 9 /**< \brief Pin Number for PA09 */ #define PORT_PA09 (1ul << 9) /**< \brief PORT Mask for PA09 */ #define PIN_PA10 10 /**< \brief Pin Number for PA10 */ #define PORT_PA10 (1ul << 10) /**< \brief PORT Mask for PA10 */ #define PIN_PA11 11 /**< \brief Pin Number for PA11 */ #define PORT_PA11 (1ul << 11) /**< \brief PORT Mask for PA11 */ #define PIN_PA12 12 /**< \brief Pin Number for PA12 */ #define PORT_PA12 (1ul << 12) /**< \brief PORT Mask for PA12 */ #define PIN_PA13 13 /**< \brief Pin Number for PA13 */ #define PORT_PA13 (1ul << 13) /**< \brief PORT Mask for PA13 */ #define PIN_PA14 14 /**< \brief Pin Number for PA14 */ #define PORT_PA14 (1ul << 14) /**< \brief PORT Mask for PA14 */ #define PIN_PA15 15 /**< \brief Pin Number for PA15 */ #define PORT_PA15 (1ul << 15) /**< \brief PORT Mask for PA15 */ #define PIN_PA16 16 /**< \brief Pin Number for PA16 */ #define PORT_PA16 (1ul << 16) /**< \brief PORT Mask for PA16 */ #define PIN_PA17 17 /**< \brief Pin Number for PA17 */ #define PORT_PA17 (1ul << 17) /**< \brief PORT Mask for PA17 */ #define PIN_PA18 18 /**< \brief Pin Number for PA18 */ #define PORT_PA18 (1ul << 18) /**< \brief PORT Mask for PA18 */ #define PIN_PA19 19 /**< \brief Pin Number for PA19 */ #define PORT_PA19 (1ul << 19) /**< \brief PORT Mask for PA19 */ #define PIN_PA20 20 /**< \brief Pin Number for PA20 */ #define PORT_PA20 (1ul << 20) /**< \brief PORT Mask for PA20 */ #define PIN_PA21 21 /**< \brief Pin Number for PA21 */ #define PORT_PA21 (1ul << 21) /**< \brief PORT Mask for PA21 */ #define PIN_PA22 22 /**< \brief Pin Number for PA22 */ #define PORT_PA22 (1ul << 22) /**< \brief PORT Mask for PA22 */ #define PIN_PA23 23 /**< \brief Pin Number for PA23 */ #define PORT_PA23 (1ul << 23) /**< \brief PORT Mask for PA23 */ #define PIN_PA24 24 /**< \brief Pin Number for PA24 */ #define PORT_PA24 (1ul << 24) /**< \brief PORT Mask for PA24 */ #define PIN_PA25 25 /**< \brief Pin Number for PA25 */ #define PORT_PA25 (1ul << 25) /**< \brief PORT Mask for PA25 */ #define PIN_PA27 27 /**< \brief Pin Number for PA27 */ #define PORT_PA27 (1ul << 27) /**< \brief PORT Mask for PA27 */ #define PIN_PA28 28 /**< \brief Pin Number for PA28 */ #define PORT_PA28 (1ul << 28) /**< \brief PORT Mask for PA28 */ #define PIN_PA30 30 /**< \brief Pin Number for PA30 */ #define PORT_PA30 (1ul << 30) /**< \brief PORT Mask for PA30 */ #define PIN_PA31 31 /**< \brief Pin Number for PA31 */ #define PORT_PA31 (1ul << 31) /**< \brief PORT Mask for PA31 */ #define PIN_PB00 32 /**< \brief Pin Number for PB00 */ #define PORT_PB00 (1ul << 0) /**< \brief PORT Mask for PB00 */ #define PIN_PB01 33 /**< \brief Pin Number for PB01 */ #define PORT_PB01 (1ul << 1) /**< \brief PORT Mask for PB01 */ #define PIN_PB02 34 /**< \brief Pin Number for PB02 */ #define PORT_PB02 (1ul << 2) /**< \brief PORT Mask for PB02 */ #define PIN_PB03 35 /**< \brief Pin Number for PB03 */ #define PORT_PB03 (1ul << 3) /**< \brief PORT Mask for PB03 */ #define PIN_PB04 36 /**< \brief Pin Number for PB04 */ #define PORT_PB04 (1ul << 4) /**< \brief PORT Mask for PB04 */ #define PIN_PB05 37 /**< \brief Pin Number for PB05 */ #define PORT_PB05 (1ul << 5) /**< \brief PORT Mask for PB05 */ #define PIN_PB06 38 /**< \brief Pin Number for PB06 */ #define PORT_PB06 (1ul << 6) /**< \brief PORT Mask for PB06 */ #define PIN_PB07 39 /**< \brief Pin Number for PB07 */ #define PORT_PB07 (1ul << 7) /**< \brief PORT Mask for PB07 */ #define PIN_PB08 40 /**< \brief Pin Number for PB08 */ #define PORT_PB08 (1ul << 8) /**< \brief PORT Mask for PB08 */ #define PIN_PB09 41 /**< \brief Pin Number for PB09 */ #define PORT_PB09 (1ul << 9) /**< \brief PORT Mask for PB09 */ #define PIN_PB10 42 /**< \brief Pin Number for PB10 */ #define PORT_PB10 (1ul << 10) /**< \brief PORT Mask for PB10 */ #define PIN_PB11 43 /**< \brief Pin Number for PB11 */ #define PORT_PB11 (1ul << 11) /**< \brief PORT Mask for PB11 */ #define PIN_PB12 44 /**< \brief Pin Number for PB12 */ #define PORT_PB12 (1ul << 12) /**< \brief PORT Mask for PB12 */ #define PIN_PB13 45 /**< \brief Pin Number for PB13 */ #define PORT_PB13 (1ul << 13) /**< \brief PORT Mask for PB13 */ #define PIN_PB14 46 /**< \brief Pin Number for PB14 */ #define PORT_PB14 (1ul << 14) /**< \brief PORT Mask for PB14 */ #define PIN_PB15 47 /**< \brief Pin Number for PB15 */ #define PORT_PB15 (1ul << 15) /**< \brief PORT Mask for PB15 */ #define PIN_PB16 48 /**< \brief Pin Number for PB16 */ #define PORT_PB16 (1ul << 16) /**< \brief PORT Mask for PB16 */ #define PIN_PB17 49 /**< \brief Pin Number for PB17 */ #define PORT_PB17 (1ul << 17) /**< \brief PORT Mask for PB17 */ #define PIN_PB22 54 /**< \brief Pin Number for PB22 */ #define PORT_PB22 (1ul << 22) /**< \brief PORT Mask for PB22 */ #define PIN_PB23 55 /**< \brief Pin Number for PB23 */ #define PORT_PB23 (1ul << 23) /**< \brief PORT Mask for PB23 */ #define PIN_PB30 62 /**< \brief Pin Number for PB30 */ #define PORT_PB30 (1ul << 30) /**< \brief PORT Mask for PB30 */ #define PIN_PB31 63 /**< \brief Pin Number for PB31 */ #define PORT_PB31 (1ul << 31) /**< \brief PORT Mask for PB31 */ #define PIN_PB14H_GCLK_IO0 46L /**< \brief GCLK signal: IO0 on PB14 mux H */ #define MUX_PB14H_GCLK_IO0 7L #define <API key> ((PIN_PB14H_GCLK_IO0 << 16) | MUX_PB14H_GCLK_IO0) #define PORT_PB14H_GCLK_IO0 (1ul << 14) #define PIN_PB22H_GCLK_IO0 54L /**< \brief GCLK signal: IO0 on PB22 mux H */ #define MUX_PB22H_GCLK_IO0 7L #define <API key> ((PIN_PB22H_GCLK_IO0 << 16) | MUX_PB22H_GCLK_IO0) #define PORT_PB22H_GCLK_IO0 (1ul << 22) #define PIN_PA14H_GCLK_IO0 14L /**< \brief GCLK signal: IO0 on PA14 mux H */ #define MUX_PA14H_GCLK_IO0 7L #define <API key> ((PIN_PA14H_GCLK_IO0 << 16) | MUX_PA14H_GCLK_IO0) #define PORT_PA14H_GCLK_IO0 (1ul << 14) #define PIN_PA27H_GCLK_IO0 27L /**< \brief GCLK signal: IO0 on PA27 mux H */ #define MUX_PA27H_GCLK_IO0 7L #define <API key> ((PIN_PA27H_GCLK_IO0 << 16) | MUX_PA27H_GCLK_IO0) #define PORT_PA27H_GCLK_IO0 (1ul << 27) #define PIN_PA28H_GCLK_IO0 28L /**< \brief GCLK signal: IO0 on PA28 mux H */ #define MUX_PA28H_GCLK_IO0 7L #define <API key> ((PIN_PA28H_GCLK_IO0 << 16) | MUX_PA28H_GCLK_IO0) #define PORT_PA28H_GCLK_IO0 (1ul << 28) #define PIN_PA30H_GCLK_IO0 30L /**< \brief GCLK signal: IO0 on PA30 mux H */ #define MUX_PA30H_GCLK_IO0 7L #define <API key> ((PIN_PA30H_GCLK_IO0 << 16) | MUX_PA30H_GCLK_IO0) #define PORT_PA30H_GCLK_IO0 (1ul << 30) #define PIN_PB15H_GCLK_IO1 47L /**< \brief GCLK signal: IO1 on PB15 mux H */ #define MUX_PB15H_GCLK_IO1 7L #define <API key> ((PIN_PB15H_GCLK_IO1 << 16) | MUX_PB15H_GCLK_IO1) #define PORT_PB15H_GCLK_IO1 (1ul << 15) #define PIN_PB23H_GCLK_IO1 55L /**< \brief GCLK signal: IO1 on PB23 mux H */ #define MUX_PB23H_GCLK_IO1 7L #define <API key> ((PIN_PB23H_GCLK_IO1 << 16) | MUX_PB23H_GCLK_IO1) #define PORT_PB23H_GCLK_IO1 (1ul << 23) #define PIN_PA15H_GCLK_IO1 15L /**< \brief GCLK signal: IO1 on PA15 mux H */ #define MUX_PA15H_GCLK_IO1 7L #define <API key> ((PIN_PA15H_GCLK_IO1 << 16) | MUX_PA15H_GCLK_IO1) #define PORT_PA15H_GCLK_IO1 (1ul << 15) #define PIN_PB16H_GCLK_IO2 48L /**< \brief GCLK signal: IO2 on PB16 mux H */ #define MUX_PB16H_GCLK_IO2 7L #define <API key> ((PIN_PB16H_GCLK_IO2 << 16) | MUX_PB16H_GCLK_IO2) #define PORT_PB16H_GCLK_IO2 (1ul << 16) #define PIN_PA16H_GCLK_IO2 16L /**< \brief GCLK signal: IO2 on PA16 mux H */ #define MUX_PA16H_GCLK_IO2 7L #define <API key> ((PIN_PA16H_GCLK_IO2 << 16) | MUX_PA16H_GCLK_IO2) #define PORT_PA16H_GCLK_IO2 (1ul << 16) #define PIN_PA17H_GCLK_IO3 17L /**< \brief GCLK signal: IO3 on PA17 mux H */ #define MUX_PA17H_GCLK_IO3 7L #define <API key> ((PIN_PA17H_GCLK_IO3 << 16) | MUX_PA17H_GCLK_IO3) #define PORT_PA17H_GCLK_IO3 (1ul << 17) #define PIN_PB17H_GCLK_IO3 49L /**< \brief GCLK signal: IO3 on PB17 mux H */ #define MUX_PB17H_GCLK_IO3 7L #define <API key> ((PIN_PB17H_GCLK_IO3 << 16) | MUX_PB17H_GCLK_IO3) #define PORT_PB17H_GCLK_IO3 (1ul << 17) #define PIN_PA10H_GCLK_IO4 10L /**< \brief GCLK signal: IO4 on PA10 mux H */ #define MUX_PA10H_GCLK_IO4 7L #define <API key> ((PIN_PA10H_GCLK_IO4 << 16) | MUX_PA10H_GCLK_IO4) #define PORT_PA10H_GCLK_IO4 (1ul << 10) #define PIN_PA20H_GCLK_IO4 20L /**< \brief GCLK signal: IO4 on PA20 mux H */ #define MUX_PA20H_GCLK_IO4 7L #define <API key> ((PIN_PA20H_GCLK_IO4 << 16) | MUX_PA20H_GCLK_IO4) #define PORT_PA20H_GCLK_IO4 (1ul << 20) #define PIN_PB10H_GCLK_IO4 42L /**< \brief GCLK signal: IO4 on PB10 mux H */ #define MUX_PB10H_GCLK_IO4 7L #define <API key> ((PIN_PB10H_GCLK_IO4 << 16) | MUX_PB10H_GCLK_IO4) #define PORT_PB10H_GCLK_IO4 (1ul << 10) #define PIN_PA11H_GCLK_IO5 11L /**< \brief GCLK signal: IO5 on PA11 mux H */ #define MUX_PA11H_GCLK_IO5 7L #define <API key> ((PIN_PA11H_GCLK_IO5 << 16) | MUX_PA11H_GCLK_IO5) #define PORT_PA11H_GCLK_IO5 (1ul << 11) #define PIN_PA21H_GCLK_IO5 21L /**< \brief GCLK signal: IO5 on PA21 mux H */ #define MUX_PA21H_GCLK_IO5 7L #define <API key> ((PIN_PA21H_GCLK_IO5 << 16) | MUX_PA21H_GCLK_IO5) #define PORT_PA21H_GCLK_IO5 (1ul << 21) #define PIN_PB11H_GCLK_IO5 43L /**< \brief GCLK signal: IO5 on PB11 mux H */ #define MUX_PB11H_GCLK_IO5 7L #define <API key> ((PIN_PB11H_GCLK_IO5 << 16) | MUX_PB11H_GCLK_IO5) #define PORT_PB11H_GCLK_IO5 (1ul << 11) #define PIN_PA22H_GCLK_IO6 22L /**< \brief GCLK signal: IO6 on PA22 mux H */ #define MUX_PA22H_GCLK_IO6 7L #define <API key> ((PIN_PA22H_GCLK_IO6 << 16) | MUX_PA22H_GCLK_IO6) #define PORT_PA22H_GCLK_IO6 (1ul << 22) #define PIN_PB12H_GCLK_IO6 44L /**< \brief GCLK signal: IO6 on PB12 mux H */ #define MUX_PB12H_GCLK_IO6 7L #define <API key> ((PIN_PB12H_GCLK_IO6 << 16) | MUX_PB12H_GCLK_IO6) #define PORT_PB12H_GCLK_IO6 (1ul << 12) #define PIN_PA23H_GCLK_IO7 23L /**< \brief GCLK signal: IO7 on PA23 mux H */ #define MUX_PA23H_GCLK_IO7 7L #define <API key> ((PIN_PA23H_GCLK_IO7 << 16) | MUX_PA23H_GCLK_IO7) #define PORT_PA23H_GCLK_IO7 (1ul << 23) #define PIN_PB13H_GCLK_IO7 45L /**< \brief GCLK signal: IO7 on PB13 mux H */ #define MUX_PB13H_GCLK_IO7 7L #define <API key> ((PIN_PB13H_GCLK_IO7 << 16) | MUX_PB13H_GCLK_IO7) #define PORT_PB13H_GCLK_IO7 (1ul << 13) #define <API key> 16L /**< \brief EIC signal: EXTINT0 on PA16 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 16) #define <API key> 32L /**< \brief EIC signal: EXTINT0 on PB00 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 0) #define <API key> 48L /**< \brief EIC signal: EXTINT0 on PB16 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 16) #define <API key> 0L /**< \brief EIC signal: EXTINT0 on PA00 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 0) #define <API key> 17L /**< \brief EIC signal: EXTINT1 on PA17 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 17) #define <API key> 33L /**< \brief EIC signal: EXTINT1 on PB01 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 1) #define <API key> 49L /**< \brief EIC signal: EXTINT1 on PB17 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 17) #define <API key> 1L /**< \brief EIC signal: EXTINT1 on PA01 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 1) #define <API key> 2L /**< \brief EIC signal: EXTINT2 on PA02 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 2) #define <API key> 18L /**< \brief EIC signal: EXTINT2 on PA18 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 18) #define <API key> 34L /**< \brief EIC signal: EXTINT2 on PB02 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 2) #define <API key> 3L /**< \brief EIC signal: EXTINT3 on PA03 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 3) #define <API key> 19L /**< \brief EIC signal: EXTINT3 on PA19 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 19) #define <API key> 35L /**< \brief EIC signal: EXTINT3 on PB03 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 3) #define <API key> 4L /**< \brief EIC signal: EXTINT4 on PA04 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 4) #define <API key> 20L /**< \brief EIC signal: EXTINT4 on PA20 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 20) #define <API key> 36L /**< \brief EIC signal: EXTINT4 on PB04 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 4) #define <API key> 5L /**< \brief EIC signal: EXTINT5 on PA05 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 5) #define <API key> 21L /**< \brief EIC signal: EXTINT5 on PA21 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 21) #define <API key> 37L /**< \brief EIC signal: EXTINT5 on PB05 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 5) #define <API key> 6L /**< \brief EIC signal: EXTINT6 on PA06 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 6) #define <API key> 22L /**< \brief EIC signal: EXTINT6 on PA22 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 22) #define <API key> 38L /**< \brief EIC signal: EXTINT6 on PB06 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 6) #define <API key> 54L /**< \brief EIC signal: EXTINT6 on PB22 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 22) #define <API key> 7L /**< \brief EIC signal: EXTINT7 on PA07 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 7) #define <API key> 23L /**< \brief EIC signal: EXTINT7 on PA23 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 23) #define <API key> 39L /**< \brief EIC signal: EXTINT7 on PB07 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 7) #define <API key> 55L /**< \brief EIC signal: EXTINT7 on PB23 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 23) #define <API key> 28L /**< \brief EIC signal: EXTINT8 on PA28 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 28) #define <API key> 40L /**< \brief EIC signal: EXTINT8 on PB08 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 8) #define <API key> 9L /**< \brief EIC signal: EXTINT9 on PA09 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 9) #define <API key> 41L /**< \brief EIC signal: EXTINT9 on PB09 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 9) #define <API key> 10L /**< \brief EIC signal: EXTINT10 on PA10 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 10) #define <API key> 30L /**< \brief EIC signal: EXTINT10 on PA30 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 30) #define <API key> 42L /**< \brief EIC signal: EXTINT10 on PB10 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 10) #define <API key> 11L /**< \brief EIC signal: EXTINT11 on PA11 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 11) #define <API key> 31L /**< \brief EIC signal: EXTINT11 on PA31 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 31) #define <API key> 43L /**< \brief EIC signal: EXTINT11 on PB11 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 11) #define <API key> 12L /**< \brief EIC signal: EXTINT12 on PA12 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 12) #define <API key> 24L /**< \brief EIC signal: EXTINT12 on PA24 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 24) #define <API key> 44L /**< \brief EIC signal: EXTINT12 on PB12 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 12) #define <API key> 13L /**< \brief EIC signal: EXTINT13 on PA13 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 13) #define <API key> 25L /**< \brief EIC signal: EXTINT13 on PA25 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 25) #define <API key> 45L /**< \brief EIC signal: EXTINT13 on PB13 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 13) #define <API key> 46L /**< \brief EIC signal: EXTINT14 on PB14 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 14) #define <API key> 62L /**< \brief EIC signal: EXTINT14 on PB30 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 30) #define <API key> 14L /**< \brief EIC signal: EXTINT14 on PA14 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 14) #define <API key> 27L /**< \brief EIC signal: EXTINT15 on PA27 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 27) #define <API key> 47L /**< \brief EIC signal: EXTINT15 on PB15 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 15) #define <API key> 63L /**< \brief EIC signal: EXTINT15 on PB31 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 31) #define <API key> 15L /**< \brief EIC signal: EXTINT15 on PA15 mux A */ #define <API key> 0L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 15) #define PIN_PA08A_EIC_NMI 8L /**< \brief EIC signal: NMI on PA08 mux A */ #define MUX_PA08A_EIC_NMI 0L #define <API key> ((PIN_PA08A_EIC_NMI << 16) | MUX_PA08A_EIC_NMI) #define PORT_PA08A_EIC_NMI (1ul << 8) #define <API key> 4L /**< \brief SERCOM0 signal: PAD0 on PA04 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 4) #define <API key> 8L /**< \brief SERCOM0 signal: PAD0 on PA08 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 8) #define <API key> 5L /**< \brief SERCOM0 signal: PAD1 on PA05 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 5) #define <API key> 9L /**< \brief SERCOM0 signal: PAD1 on PA09 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 9) #define <API key> 6L /**< \brief SERCOM0 signal: PAD2 on PA06 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 6) #define <API key> 10L /**< \brief SERCOM0 signal: PAD2 on PA10 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 10) #define <API key> 7L /**< \brief SERCOM0 signal: PAD3 on PA07 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 7) #define <API key> 11L /**< \brief SERCOM0 signal: PAD3 on PA11 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 11) #define <API key> 16L /**< \brief SERCOM1 signal: PAD0 on PA16 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 16) #define <API key> 0L /**< \brief SERCOM1 signal: PAD0 on PA00 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 0) #define <API key> 17L /**< \brief SERCOM1 signal: PAD1 on PA17 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 17) #define <API key> 1L /**< \brief SERCOM1 signal: PAD1 on PA01 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 1) #define <API key> 30L /**< \brief SERCOM1 signal: PAD2 on PA30 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 30) #define <API key> 18L /**< \brief SERCOM1 signal: PAD2 on PA18 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 18) #define <API key> 31L /**< \brief SERCOM1 signal: PAD3 on PA31 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 31) #define <API key> 19L /**< \brief SERCOM1 signal: PAD3 on PA19 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 19) #define <API key> 8L /**< \brief SERCOM2 signal: PAD0 on PA08 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 8) #define <API key> 12L /**< \brief SERCOM2 signal: PAD0 on PA12 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 12) #define <API key> 9L /**< \brief SERCOM2 signal: PAD1 on PA09 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 9) #define <API key> 13L /**< \brief SERCOM2 signal: PAD1 on PA13 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 13) #define <API key> 10L /**< \brief SERCOM2 signal: PAD2 on PA10 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 10) #define <API key> 14L /**< \brief SERCOM2 signal: PAD2 on PA14 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 14) #define <API key> 11L /**< \brief SERCOM2 signal: PAD3 on PA11 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 11) #define <API key> 15L /**< \brief SERCOM2 signal: PAD3 on PA15 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 15) #define <API key> 16L /**< \brief SERCOM3 signal: PAD0 on PA16 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 16) #define <API key> 22L /**< \brief SERCOM3 signal: PAD0 on PA22 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 22) #define <API key> 17L /**< \brief SERCOM3 signal: PAD1 on PA17 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 17) #define <API key> 23L /**< \brief SERCOM3 signal: PAD1 on PA23 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 23) #define <API key> 18L /**< \brief SERCOM3 signal: PAD2 on PA18 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 18) #define <API key> 20L /**< \brief SERCOM3 signal: PAD2 on PA20 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 20) #define <API key> 24L /**< \brief SERCOM3 signal: PAD2 on PA24 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 24) #define <API key> 19L /**< \brief SERCOM3 signal: PAD3 on PA19 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 19) #define <API key> 21L /**< \brief SERCOM3 signal: PAD3 on PA21 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 21) #define <API key> 25L /**< \brief SERCOM3 signal: PAD3 on PA25 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 25) #define <API key> 12L /**< \brief SERCOM4 signal: PAD0 on PA12 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 12) #define <API key> 40L /**< \brief SERCOM4 signal: PAD0 on PB08 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 8) #define <API key> 44L /**< \brief SERCOM4 signal: PAD0 on PB12 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 12) #define <API key> 13L /**< \brief SERCOM4 signal: PAD1 on PA13 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 13) #define <API key> 41L /**< \brief SERCOM4 signal: PAD1 on PB09 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 9) #define <API key> 45L /**< \brief SERCOM4 signal: PAD1 on PB13 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 13) #define <API key> 14L /**< \brief SERCOM4 signal: PAD2 on PA14 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 14) #define <API key> 42L /**< \brief SERCOM4 signal: PAD2 on PB10 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 10) #define <API key> 46L /**< \brief SERCOM4 signal: PAD2 on PB14 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 14) #define <API key> 15L /**< \brief SERCOM4 signal: PAD3 on PA15 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 15) #define <API key> 43L /**< \brief SERCOM4 signal: PAD3 on PB11 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 11) #define <API key> 47L /**< \brief SERCOM4 signal: PAD3 on PB15 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 15) #define <API key> 22L /**< \brief SERCOM5 signal: PAD0 on PA22 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 22) #define <API key> 34L /**< \brief SERCOM5 signal: PAD0 on PB02 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 2) #define <API key> 62L /**< \brief SERCOM5 signal: PAD0 on PB30 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 30) #define <API key> 48L /**< \brief SERCOM5 signal: PAD0 on PB16 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 16) #define <API key> 23L /**< \brief SERCOM5 signal: PAD1 on PA23 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 23) #define <API key> 35L /**< \brief SERCOM5 signal: PAD1 on PB03 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 3) #define <API key> 63L /**< \brief SERCOM5 signal: PAD1 on PB31 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 31) #define <API key> 49L /**< \brief SERCOM5 signal: PAD1 on PB17 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 17) #define <API key> 24L /**< \brief SERCOM5 signal: PAD2 on PA24 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 24) #define <API key> 32L /**< \brief SERCOM5 signal: PAD2 on PB00 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 0) #define <API key> 54L /**< \brief SERCOM5 signal: PAD2 on PB22 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 22) #define <API key> 20L /**< \brief SERCOM5 signal: PAD2 on PA20 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 20) #define <API key> 25L /**< \brief SERCOM5 signal: PAD3 on PA25 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 25) #define <API key> 33L /**< \brief SERCOM5 signal: PAD3 on PB01 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 1) #define <API key> 55L /**< \brief SERCOM5 signal: PAD3 on PB23 mux D */ #define <API key> 3L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 23) #define <API key> 21L /**< \brief SERCOM5 signal: PAD3 on PA21 mux C */ #define <API key> 2L #define <API key> ((<API key> << 16) | <API key>) #define <API key> (1ul << 21) #define PIN_PA04F_TC0_WO0 4L /**< \brief TC0 signal: WO0 on PA04 mux F */ #define MUX_PA04F_TC0_WO0 5L #define <API key> ((PIN_PA04F_TC0_WO0 << 16) | MUX_PA04F_TC0_WO0) #define PORT_PA04F_TC0_WO0 (1ul << 4) #define PIN_PB30F_TC0_WO0 62L /**< \brief TC0 signal: WO0 on PB30 mux F */ #define MUX_PB30F_TC0_WO0 5L #define <API key> ((PIN_PB30F_TC0_WO0 << 16) | MUX_PB30F_TC0_WO0) #define PORT_PB30F_TC0_WO0 (1ul << 30) #define PIN_PA08E_TC0_WO0 8L /**< \brief TC0 signal: WO0 on PA08 mux E */ #define MUX_PA08E_TC0_WO0 4L #define <API key> ((PIN_PA08E_TC0_WO0 << 16) | MUX_PA08E_TC0_WO0) #define PORT_PA08E_TC0_WO0 (1ul << 8) #define PIN_PA05F_TC0_WO1 5L /**< \brief TC0 signal: WO1 on PA05 mux F */ #define MUX_PA05F_TC0_WO1 5L #define <API key> ((PIN_PA05F_TC0_WO1 << 16) | MUX_PA05F_TC0_WO1) #define PORT_PA05F_TC0_WO1 (1ul << 5) #define PIN_PB31F_TC0_WO1 63L /**< \brief TC0 signal: WO1 on PB31 mux F */ #define MUX_PB31F_TC0_WO1 5L #define <API key> ((PIN_PB31F_TC0_WO1 << 16) | MUX_PB31F_TC0_WO1) #define PORT_PB31F_TC0_WO1 (1ul << 31) #define PIN_PA09E_TC0_WO1 9L /**< \brief TC0 signal: WO1 on PA09 mux E */ #define MUX_PA09E_TC0_WO1 4L #define <API key> ((PIN_PA09E_TC0_WO1 << 16) | MUX_PA09E_TC0_WO1) #define PORT_PA09E_TC0_WO1 (1ul << 9) #define PIN_PA06F_TC1_WO0 6L /**< \brief TC1 signal: WO0 on PA06 mux F */ #define MUX_PA06F_TC1_WO0 5L #define <API key> ((PIN_PA06F_TC1_WO0 << 16) | MUX_PA06F_TC1_WO0) #define PORT_PA06F_TC1_WO0 (1ul << 6) #define PIN_PA30F_TC1_WO0 30L /**< \brief TC1 signal: WO0 on PA30 mux F */ #define MUX_PA30F_TC1_WO0 5L #define <API key> ((PIN_PA30F_TC1_WO0 << 16) | MUX_PA30F_TC1_WO0) #define PORT_PA30F_TC1_WO0 (1ul << 30) #define PIN_PA10E_TC1_WO0 10L /**< \brief TC1 signal: WO0 on PA10 mux E */ #define MUX_PA10E_TC1_WO0 4L #define <API key> ((PIN_PA10E_TC1_WO0 << 16) | MUX_PA10E_TC1_WO0) #define PORT_PA10E_TC1_WO0 (1ul << 10) #define PIN_PA07F_TC1_WO1 7L /**< \brief TC1 signal: WO1 on PA07 mux F */ #define MUX_PA07F_TC1_WO1 5L #define <API key> ((PIN_PA07F_TC1_WO1 << 16) | MUX_PA07F_TC1_WO1) #define PORT_PA07F_TC1_WO1 (1ul << 7) #define PIN_PA31F_TC1_WO1 31L /**< \brief TC1 signal: WO1 on PA31 mux F */ #define MUX_PA31F_TC1_WO1 5L #define <API key> ((PIN_PA31F_TC1_WO1 << 16) | MUX_PA31F_TC1_WO1) #define PORT_PA31F_TC1_WO1 (1ul << 31) #define PIN_PA11E_TC1_WO1 11L /**< \brief TC1 signal: WO1 on PA11 mux E */ #define MUX_PA11E_TC1_WO1 4L #define <API key> ((PIN_PA11E_TC1_WO1 << 16) | MUX_PA11E_TC1_WO1) #define PORT_PA11E_TC1_WO1 (1ul << 11) #define PIN_PA16F_TC2_WO0 16L /**< \brief TC2 signal: WO0 on PA16 mux F */ #define MUX_PA16F_TC2_WO0 5L #define <API key> ((PIN_PA16F_TC2_WO0 << 16) | MUX_PA16F_TC2_WO0) #define PORT_PA16F_TC2_WO0 (1ul << 16) #define PIN_PA12E_TC2_WO0 12L /**< \brief TC2 signal: WO0 on PA12 mux E */ #define MUX_PA12E_TC2_WO0 4L #define <API key> ((PIN_PA12E_TC2_WO0 << 16) | MUX_PA12E_TC2_WO0) #define PORT_PA12E_TC2_WO0 (1ul << 12) #define PIN_PA00F_TC2_WO0 0L /**< \brief TC2 signal: WO0 on PA00 mux F */ #define MUX_PA00F_TC2_WO0 5L #define <API key> ((PIN_PA00F_TC2_WO0 << 16) | MUX_PA00F_TC2_WO0) #define PORT_PA00F_TC2_WO0 (1ul << 0) #define PIN_PA17F_TC2_WO1 17L /**< \brief TC2 signal: WO1 on PA17 mux F */ #define MUX_PA17F_TC2_WO1 5L #define <API key> ((PIN_PA17F_TC2_WO1 << 16) | MUX_PA17F_TC2_WO1) #define PORT_PA17F_TC2_WO1 (1ul << 17) #define PIN_PA13E_TC2_WO1 13L /**< \brief TC2 signal: WO1 on PA13 mux E */ #define MUX_PA13E_TC2_WO1 4L #define <API key> ((PIN_PA13E_TC2_WO1 << 16) | MUX_PA13E_TC2_WO1) #define PORT_PA13E_TC2_WO1 (1ul << 13) #define PIN_PA01F_TC2_WO1 1L /**< \brief TC2 signal: WO1 on PA01 mux F */ #define MUX_PA01F_TC2_WO1 5L #define <API key> ((PIN_PA01F_TC2_WO1 << 16) | MUX_PA01F_TC2_WO1) #define PORT_PA01F_TC2_WO1 (1ul << 1) #define PIN_PA18F_TC3_WO0 18L /**< \brief TC3 signal: WO0 on PA18 mux F */ #define MUX_PA18F_TC3_WO0 5L #define <API key> ((PIN_PA18F_TC3_WO0 << 16) | MUX_PA18F_TC3_WO0) #define PORT_PA18F_TC3_WO0 (1ul << 18) #define PIN_PA14E_TC3_WO0 14L /**< \brief TC3 signal: WO0 on PA14 mux E */ #define MUX_PA14E_TC3_WO0 4L #define <API key> ((PIN_PA14E_TC3_WO0 << 16) | MUX_PA14E_TC3_WO0) #define PORT_PA14E_TC3_WO0 (1ul << 14) #define PIN_PA19F_TC3_WO1 19L /**< \brief TC3 signal: WO1 on PA19 mux F */ #define MUX_PA19F_TC3_WO1 5L #define <API key> ((PIN_PA19F_TC3_WO1 << 16) | MUX_PA19F_TC3_WO1) #define PORT_PA19F_TC3_WO1 (1ul << 19) #define PIN_PA15E_TC3_WO1 15L /**< \brief TC3 signal: WO1 on PA15 mux E */ #define MUX_PA15E_TC3_WO1 4L #define <API key> ((PIN_PA15E_TC3_WO1 << 16) | MUX_PA15E_TC3_WO1) #define PORT_PA15E_TC3_WO1 (1ul << 15) #define PIN_PA22F_TC4_WO0 22L /**< \brief TC4 signal: WO0 on PA22 mux F */ #define MUX_PA22F_TC4_WO0 5L #define <API key> ((PIN_PA22F_TC4_WO0 << 16) | MUX_PA22F_TC4_WO0) #define PORT_PA22F_TC4_WO0 (1ul << 22) #define PIN_PB08F_TC4_WO0 40L /**< \brief TC4 signal: WO0 on PB08 mux F */ #define MUX_PB08F_TC4_WO0 5L #define <API key> ((PIN_PB08F_TC4_WO0 << 16) | MUX_PB08F_TC4_WO0) #define PORT_PB08F_TC4_WO0 (1ul << 8) #define PIN_PB12E_TC4_WO0 44L /**< \brief TC4 signal: WO0 on PB12 mux E */ #define MUX_PB12E_TC4_WO0 4L #define <API key> ((PIN_PB12E_TC4_WO0 << 16) | MUX_PB12E_TC4_WO0) #define PORT_PB12E_TC4_WO0 (1ul << 12) #define PIN_PA23F_TC4_WO1 23L /**< \brief TC4 signal: WO1 on PA23 mux F */ #define MUX_PA23F_TC4_WO1 5L #define <API key> ((PIN_PA23F_TC4_WO1 << 16) | MUX_PA23F_TC4_WO1) #define PORT_PA23F_TC4_WO1 (1ul << 23) #define PIN_PB09F_TC4_WO1 41L /**< \brief TC4 signal: WO1 on PB09 mux F */ #define MUX_PB09F_TC4_WO1 5L #define <API key> ((PIN_PB09F_TC4_WO1 << 16) | MUX_PB09F_TC4_WO1) #define PORT_PB09F_TC4_WO1 (1ul << 9) #define PIN_PB13E_TC4_WO1 45L /**< \brief TC4 signal: WO1 on PB13 mux E */ #define MUX_PB13E_TC4_WO1 4L #define <API key> ((PIN_PB13E_TC4_WO1 << 16) | MUX_PB13E_TC4_WO1) #define PORT_PB13E_TC4_WO1 (1ul << 13) #define PIN_PA24F_TC5_WO0 24L /**< \brief TC5 signal: WO0 on PA24 mux F */ #define MUX_PA24F_TC5_WO0 5L #define <API key> ((PIN_PA24F_TC5_WO0 << 16) | MUX_PA24F_TC5_WO0) #define PORT_PA24F_TC5_WO0 (1ul << 24) #define PIN_PB10F_TC5_WO0 42L /**< \brief TC5 signal: WO0 on PB10 mux F */ #define MUX_PB10F_TC5_WO0 5L #define <API key> ((PIN_PB10F_TC5_WO0 << 16) | MUX_PB10F_TC5_WO0) #define PORT_PB10F_TC5_WO0 (1ul << 10) #define PIN_PB14E_TC5_WO0 46L /**< \brief TC5 signal: WO0 on PB14 mux E */ #define MUX_PB14E_TC5_WO0 4L #define <API key> ((PIN_PB14E_TC5_WO0 << 16) | MUX_PB14E_TC5_WO0) #define PORT_PB14E_TC5_WO0 (1ul << 14) #define PIN_PA25F_TC5_WO1 25L /**< \brief TC5 signal: WO1 on PA25 mux F */ #define MUX_PA25F_TC5_WO1 5L #define <API key> ((PIN_PA25F_TC5_WO1 << 16) | MUX_PA25F_TC5_WO1) #define PORT_PA25F_TC5_WO1 (1ul << 25) #define PIN_PB11F_TC5_WO1 43L /**< \brief TC5 signal: WO1 on PB11 mux F */ #define MUX_PB11F_TC5_WO1 5L #define <API key> ((PIN_PB11F_TC5_WO1 << 16) | MUX_PB11F_TC5_WO1) #define PORT_PB11F_TC5_WO1 (1ul << 11) #define PIN_PB15E_TC5_WO1 47L /**< \brief TC5 signal: WO1 on PB15 mux E */ #define MUX_PB15E_TC5_WO1 4L #define <API key> ((PIN_PB15E_TC5_WO1 << 16) | MUX_PB15E_TC5_WO1) #define PORT_PB15E_TC5_WO1 (1ul << 15) #define PIN_PB02F_TC6_WO0 34L /**< \brief TC6 signal: WO0 on PB02 mux F */ #define MUX_PB02F_TC6_WO0 5L #define <API key> ((PIN_PB02F_TC6_WO0 << 16) | MUX_PB02F_TC6_WO0) #define PORT_PB02F_TC6_WO0 (1ul << 2) #define PIN_PB16E_TC6_WO0 48L /**< \brief TC6 signal: WO0 on PB16 mux E */ #define MUX_PB16E_TC6_WO0 4L #define <API key> ((PIN_PB16E_TC6_WO0 << 16) | MUX_PB16E_TC6_WO0) #define PORT_PB16E_TC6_WO0 (1ul << 16) #define PIN_PB03F_TC6_WO1 35L /**< \brief TC6 signal: WO1 on PB03 mux F */ #define MUX_PB03F_TC6_WO1 5L #define <API key> ((PIN_PB03F_TC6_WO1 << 16) | MUX_PB03F_TC6_WO1) #define PORT_PB03F_TC6_WO1 (1ul << 3) #define PIN_PB17E_TC6_WO1 49L /**< \brief TC6 signal: WO1 on PB17 mux E */ #define MUX_PB17E_TC6_WO1 4L #define <API key> ((PIN_PB17E_TC6_WO1 << 16) | MUX_PB17E_TC6_WO1) #define PORT_PB17E_TC6_WO1 (1ul << 17) #define PIN_PB00F_TC7_WO0 32L /**< \brief TC7 signal: WO0 on PB00 mux F */ #define MUX_PB00F_TC7_WO0 5L #define <API key> ((PIN_PB00F_TC7_WO0 << 16) | MUX_PB00F_TC7_WO0) #define PORT_PB00F_TC7_WO0 (1ul << 0) #define PIN_PB22F_TC7_WO0 54L /**< \brief TC7 signal: WO0 on PB22 mux F */ #define MUX_PB22F_TC7_WO0 5L #define <API key> ((PIN_PB22F_TC7_WO0 << 16) | MUX_PB22F_TC7_WO0) #define PORT_PB22F_TC7_WO0 (1ul << 22) #define PIN_PA20E_TC7_WO0 20L /**< \brief TC7 signal: WO0 on PA20 mux E */ #define MUX_PA20E_TC7_WO0 4L #define <API key> ((PIN_PA20E_TC7_WO0 << 16) | MUX_PA20E_TC7_WO0) #define PORT_PA20E_TC7_WO0 (1ul << 20) #define PIN_PB01F_TC7_WO1 33L /**< \brief TC7 signal: WO1 on PB01 mux F */ #define MUX_PB01F_TC7_WO1 5L #define <API key> ((PIN_PB01F_TC7_WO1 << 16) | MUX_PB01F_TC7_WO1) #define PORT_PB01F_TC7_WO1 (1ul << 1) #define PIN_PB23F_TC7_WO1 55L /**< \brief TC7 signal: WO1 on PB23 mux F */ #define MUX_PB23F_TC7_WO1 5L #define <API key> ((PIN_PB23F_TC7_WO1 << 16) | MUX_PB23F_TC7_WO1) #define PORT_PB23F_TC7_WO1 (1ul << 23) #define PIN_PA21E_TC7_WO1 21L /**< \brief TC7 signal: WO1 on PA21 mux E */ #define MUX_PA21E_TC7_WO1 4L #define <API key> ((PIN_PA21E_TC7_WO1 << 16) | MUX_PA21E_TC7_WO1) #define PORT_PA21E_TC7_WO1 (1ul << 21) #define PIN_PA02B_ADC_AIN0 2L /**< \brief ADC signal: AIN0 on PA02 mux B */ #define MUX_PA02B_ADC_AIN0 1L #define <API key> ((PIN_PA02B_ADC_AIN0 << 16) | MUX_PA02B_ADC_AIN0) #define PORT_PA02B_ADC_AIN0 (1ul << 2) #define PIN_PA03B_ADC_AIN1 3L /**< \brief ADC signal: AIN1 on PA03 mux B */ #define MUX_PA03B_ADC_AIN1 1L #define <API key> ((PIN_PA03B_ADC_AIN1 << 16) | MUX_PA03B_ADC_AIN1) #define PORT_PA03B_ADC_AIN1 (1ul << 3) #define PIN_PB08B_ADC_AIN2 40L /**< \brief ADC signal: AIN2 on PB08 mux B */ #define MUX_PB08B_ADC_AIN2 1L #define <API key> ((PIN_PB08B_ADC_AIN2 << 16) | MUX_PB08B_ADC_AIN2) #define PORT_PB08B_ADC_AIN2 (1ul << 8) #define PIN_PB09B_ADC_AIN3 41L /**< \brief ADC signal: AIN3 on PB09 mux B */ #define MUX_PB09B_ADC_AIN3 1L #define <API key> ((PIN_PB09B_ADC_AIN3 << 16) | MUX_PB09B_ADC_AIN3) #define PORT_PB09B_ADC_AIN3 (1ul << 9) #define PIN_PA04B_ADC_AIN4 4L /**< \brief ADC signal: AIN4 on PA04 mux B */ #define MUX_PA04B_ADC_AIN4 1L #define <API key> ((PIN_PA04B_ADC_AIN4 << 16) | MUX_PA04B_ADC_AIN4) #define PORT_PA04B_ADC_AIN4 (1ul << 4) #define PIN_PA05B_ADC_AIN5 5L /**< \brief ADC signal: AIN5 on PA05 mux B */ #define MUX_PA05B_ADC_AIN5 1L #define <API key> ((PIN_PA05B_ADC_AIN5 << 16) | MUX_PA05B_ADC_AIN5) #define PORT_PA05B_ADC_AIN5 (1ul << 5) #define PIN_PA06B_ADC_AIN6 6L /**< \brief ADC signal: AIN6 on PA06 mux B */ #define MUX_PA06B_ADC_AIN6 1L #define <API key> ((PIN_PA06B_ADC_AIN6 << 16) | MUX_PA06B_ADC_AIN6) #define PORT_PA06B_ADC_AIN6 (1ul << 6) #define PIN_PA07B_ADC_AIN7 7L /**< \brief ADC signal: AIN7 on PA07 mux B */ #define MUX_PA07B_ADC_AIN7 1L #define <API key> ((PIN_PA07B_ADC_AIN7 << 16) | MUX_PA07B_ADC_AIN7) #define PORT_PA07B_ADC_AIN7 (1ul << 7) #define PIN_PB00B_ADC_AIN8 32L /**< \brief ADC signal: AIN8 on PB00 mux B */ #define MUX_PB00B_ADC_AIN8 1L #define <API key> ((PIN_PB00B_ADC_AIN8 << 16) | MUX_PB00B_ADC_AIN8) #define PORT_PB00B_ADC_AIN8 (1ul << 0) #define PIN_PB01B_ADC_AIN9 33L /**< \brief ADC signal: AIN9 on PB01 mux B */ #define MUX_PB01B_ADC_AIN9 1L #define <API key> ((PIN_PB01B_ADC_AIN9 << 16) | MUX_PB01B_ADC_AIN9) #define PORT_PB01B_ADC_AIN9 (1ul << 1) #define PIN_PB02B_ADC_AIN10 34L /**< \brief ADC signal: AIN10 on PB02 mux B */ #define MUX_PB02B_ADC_AIN10 1L #define <API key> ((PIN_PB02B_ADC_AIN10 << 16) | MUX_PB02B_ADC_AIN10) #define <API key> (1ul << 2) #define PIN_PB03B_ADC_AIN11 35L /**< \brief ADC signal: AIN11 on PB03 mux B */ #define MUX_PB03B_ADC_AIN11 1L #define <API key> ((PIN_PB03B_ADC_AIN11 << 16) | MUX_PB03B_ADC_AIN11) #define <API key> (1ul << 3) #define PIN_PB04B_ADC_AIN12 36L /**< \brief ADC signal: AIN12 on PB04 mux B */ #define MUX_PB04B_ADC_AIN12 1L #define <API key> ((PIN_PB04B_ADC_AIN12 << 16) | MUX_PB04B_ADC_AIN12) #define <API key> (1ul << 4) #define PIN_PB05B_ADC_AIN13 37L /**< \brief ADC signal: AIN13 on PB05 mux B */ #define MUX_PB05B_ADC_AIN13 1L #define <API key> ((PIN_PB05B_ADC_AIN13 << 16) | MUX_PB05B_ADC_AIN13) #define <API key> (1ul << 5) #define PIN_PB06B_ADC_AIN14 38L /**< \brief ADC signal: AIN14 on PB06 mux B */ #define MUX_PB06B_ADC_AIN14 1L #define <API key> ((PIN_PB06B_ADC_AIN14 << 16) | MUX_PB06B_ADC_AIN14) #define <API key> (1ul << 6) #define PIN_PB07B_ADC_AIN15 39L /**< \brief ADC signal: AIN15 on PB07 mux B */ #define MUX_PB07B_ADC_AIN15 1L #define <API key> ((PIN_PB07B_ADC_AIN15 << 16) | MUX_PB07B_ADC_AIN15) #define <API key> (1ul << 7) #define PIN_PA08B_ADC_AIN16 8L /**< \brief ADC signal: AIN16 on PA08 mux B */ #define MUX_PA08B_ADC_AIN16 1L #define <API key> ((PIN_PA08B_ADC_AIN16 << 16) | MUX_PA08B_ADC_AIN16) #define <API key> (1ul << 8) #define PIN_PA09B_ADC_AIN17 9L /**< \brief ADC signal: AIN17 on PA09 mux B */ #define MUX_PA09B_ADC_AIN17 1L #define <API key> ((PIN_PA09B_ADC_AIN17 << 16) | MUX_PA09B_ADC_AIN17) #define <API key> (1ul << 9) #define PIN_PA10B_ADC_AIN18 10L /**< \brief ADC signal: AIN18 on PA10 mux B */ #define MUX_PA10B_ADC_AIN18 1L #define <API key> ((PIN_PA10B_ADC_AIN18 << 16) | MUX_PA10B_ADC_AIN18) #define <API key> (1ul << 10) #define PIN_PA11B_ADC_AIN19 11L /**< \brief ADC signal: AIN19 on PA11 mux B */ #define MUX_PA11B_ADC_AIN19 1L #define <API key> ((PIN_PA11B_ADC_AIN19 << 16) | MUX_PA11B_ADC_AIN19) #define <API key> (1ul << 11) #define PIN_PA04B_ADC_VREFP 4L /**< \brief ADC signal: VREFP on PA04 mux B */ #define MUX_PA04B_ADC_VREFP 1L #define <API key> ((PIN_PA04B_ADC_VREFP << 16) | MUX_PA04B_ADC_VREFP) #define <API key> (1ul << 4) #define PIN_PA04B_AC_AIN0 4L /**< \brief AC signal: AIN0 on PA04 mux B */ #define MUX_PA04B_AC_AIN0 1L #define <API key> ((PIN_PA04B_AC_AIN0 << 16) | MUX_PA04B_AC_AIN0) #define PORT_PA04B_AC_AIN0 (1ul << 4) #define PIN_PA05B_AC_AIN1 5L /**< \brief AC signal: AIN1 on PA05 mux B */ #define MUX_PA05B_AC_AIN1 1L #define <API key> ((PIN_PA05B_AC_AIN1 << 16) | MUX_PA05B_AC_AIN1) #define PORT_PA05B_AC_AIN1 (1ul << 5) #define PIN_PA06B_AC_AIN2 6L /**< \brief AC signal: AIN2 on PA06 mux B */ #define MUX_PA06B_AC_AIN2 1L #define <API key> ((PIN_PA06B_AC_AIN2 << 16) | MUX_PA06B_AC_AIN2) #define PORT_PA06B_AC_AIN2 (1ul << 6) #define PIN_PA07B_AC_AIN3 7L /**< \brief AC signal: AIN3 on PA07 mux B */ #define MUX_PA07B_AC_AIN3 1L #define <API key> ((PIN_PA07B_AC_AIN3 << 16) | MUX_PA07B_AC_AIN3) #define PORT_PA07B_AC_AIN3 (1ul << 7) #define PIN_PA12H_AC_CMP0 12L /**< \brief AC signal: CMP0 on PA12 mux H */ #define MUX_PA12H_AC_CMP0 7L #define <API key> ((PIN_PA12H_AC_CMP0 << 16) | MUX_PA12H_AC_CMP0) #define PORT_PA12H_AC_CMP0 (1ul << 12) #define PIN_PA18H_AC_CMP0 18L /**< \brief AC signal: CMP0 on PA18 mux H */ #define MUX_PA18H_AC_CMP0 7L #define <API key> ((PIN_PA18H_AC_CMP0 << 16) | MUX_PA18H_AC_CMP0) #define PORT_PA18H_AC_CMP0 (1ul << 18) #define PIN_PA13H_AC_CMP1 13L /**< \brief AC signal: CMP1 on PA13 mux H */ #define MUX_PA13H_AC_CMP1 7L #define <API key> ((PIN_PA13H_AC_CMP1 << 16) | MUX_PA13H_AC_CMP1) #define PORT_PA13H_AC_CMP1 (1ul << 13) #define PIN_PA19H_AC_CMP1 19L /**< \brief AC signal: CMP1 on PA19 mux H */ #define MUX_PA19H_AC_CMP1 7L #define <API key> ((PIN_PA19H_AC_CMP1 << 16) | MUX_PA19H_AC_CMP1) #define PORT_PA19H_AC_CMP1 (1ul << 19) #define PIN_PA02B_DAC_VOUT 2L /**< \brief DAC signal: VOUT on PA02 mux B */ #define MUX_PA02B_DAC_VOUT 1L #define <API key> ((PIN_PA02B_DAC_VOUT << 16) | MUX_PA02B_DAC_VOUT) #define PORT_PA02B_DAC_VOUT (1ul << 2) #define PIN_PA03B_DAC_VREFP 3L /**< \brief DAC signal: VREFP on PA03 mux B */ #define MUX_PA03B_DAC_VREFP 1L #define <API key> ((PIN_PA03B_DAC_VREFP << 16) | MUX_PA03B_DAC_VREFP) #define <API key> (1ul << 3) #endif /* _SAMD20J15_PIO_ */
#ifndef <API key> #define <API key> #include "ppapi_simple/ps.h" #include "ppapi_simple/ps_event.h" EXTERN_C_BEGIN typedef int (*PSMainFunc_t)(int argc, char *argv[]); /** * PSUserMainGet * * Prototype for the user provided function which retrieves the user's main * function. * This is normally defined using the <API key> macro. */ PSMainFunc_t PSUserMainGet(); /** * <API key> * * Constructs a PSInstance object and configures it to use call the provided * 'main' function on its own thread once initialization is complete. * * The ps_entrypoint_*.o and ps_main.o objects will not be linked by default, * so we force them to be linked here. */ #define <API key>(main_func) \ PSMainFunc_t PSUserMainGet() { return main_func; } EXTERN_C_END #endif /* <API key> */
#ifndef <API key> #define <API key> #include <string> #include "base/callback_list.h" #include "base/gtest_prod_util.h" #include "base/mac/scoped_nsobject.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/prefs/pref_member.h" #include "base/strings/string16.h" #include "ios/web/public/web_state/web_state_observer.h" class GURL; @class <API key>; class PrefService; namespace base { class DictionaryValue; } namespace web { class WebState; } namespace translate { class <API key> : public web::WebStateObserver { public: // Language detection details, passed to language detection callbacks. struct DetectionDetails { // The language detected by the content (Content-Language). std::string content_language; // The language written in the lang attribute of the html element. std::string html_root_language; // The adopted language. std::string adopted_language; }; <API key>(web::WebState* web_state, <API key>* manager, PrefService* prefs); ~<API key>() override; // Callback types for language detection events. typedef base::Callback<void(const DetectionDetails&)> Callback; typedef base::CallbackList<void(const DetectionDetails&)> CallbackList; // Registers a callback for language detection events. scoped_ptr<CallbackList::Subscription> <API key>( const Callback& callback); private: <API key>(<API key>, OnTextCaptured); // Starts the page language detection and initiates the translation process. void <API key>(); // Handles the "languageDetection.textCaptured" javascript command. // |interacting| is true if the user is currently interacting with the page. bool OnTextCaptured(const base::DictionaryValue& value, const GURL& url, bool interacting); // Completion handler used to retrieve the text buffered by the // <API key>. void OnTextRetrieved(const std::string& <API key>, const std::string& html_lang, const base::string16& text); // web::WebStateObserver implementation: void PageLoaded( web::<API key> <API key>) override; void UrlHashChanged() override; void HistoryStateChanged() override; void WebStateDestroyed() override; CallbackList <API key>; base::scoped_nsobject<<API key>> js_manager_; BooleanPrefMember translate_enabled_; base::WeakPtrFactory<<API key>> <API key>; <API key>(<API key>); }; } // namespace translate #endif // <API key>
#include "libtorrent/session.hpp" #include "libtorrent/session_settings.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/thread.hpp" #include "libtorrent/time.hpp" #include <boost/tuple/tuple.hpp> #include "test.hpp" #include "setup_transfer.hpp" #include <iostream> void test_swarm(bool super_seeding = false, bool strict = false, bool seed_mode = false, bool time_critical = false) { using namespace libtorrent; // in case the previous run was terminated error_code ec; remove_all("tmp1_swarm", ec); remove_all("tmp2_swarm", ec); remove_all("tmp3_swarm", ec); session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48000, 49000), "0.0.0.0", 0); session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49000, 50000), "0.0.0.0", 0); session ses3(fingerprint("LT", 0, 1, 0, 0), std::make_pair(50000, 51000), "0.0.0.0", 0); // this is to avoid everything finish from a single peer // immediately. To make the swarm actually connect all // three peers before finishing. float rate_limit = 100000; session_settings settings; settings.<API key> = true; settings.<API key> = false; settings.<API key> = strict; settings.upload_rate_limit = rate_limit; ses1.set_settings(settings); settings.download_rate_limit = rate_limit / 2; settings.upload_rate_limit = rate_limit; ses2.set_settings(settings); ses3.set_settings(settings); #ifndef <API key> pe_settings pes; pes.out_enc_policy = pe_settings::forced; pes.in_enc_policy = pe_settings::forced; ses1.set_pe_settings(pes); ses2.set_pe_settings(pes); ses3.set_pe_settings(pes); #endif torrent_handle tor1; torrent_handle tor2; torrent_handle tor3; add_torrent_params p; p.flags |= add_torrent_params::flag_seed_mode; // test using piece sizes smaller than 16kB boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true , false, true, "_swarm", 32 * 1024, 0, super_seeding, &p); int mask = alert::all_categories & ~(alert::<API key> | alert::performance_warning | alert::stats_notification); ses1.set_alert_mask(mask); ses2.set_alert_mask(mask); ses3.set_alert_mask(mask); if (time_critical) { tor2.set_piece_deadline(2, 0); tor2.set_piece_deadline(5, 1000); tor2.set_piece_deadline(8, 2000); } float sum_dl_rate2 = 0.f; float sum_dl_rate3 = 0.f; int count_dl_rates2 = 0; int count_dl_rates3 = 0; for (int i = 0; i < 80; ++i) { print_alerts(ses1, "ses1"); print_alerts(ses2, "ses2"); print_alerts(ses3, "ses3"); torrent_status st1 = tor1.status(); torrent_status st2 = tor2.status(); torrent_status st3 = tor3.status(); if (st2.progress < 1.f && st2.progress > 0.5f) { sum_dl_rate2 += st2.<API key>; ++count_dl_rates2; } if (st3.progress < 1.f && st3.progress > 0.5f) { sum_dl_rate3 += st3.download_rate; ++count_dl_rates3; } std::cerr << "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s " << st1.num_peers << ": " << "\033[32m" << int(st2.<API key> / 1000.f) << "kB/s " << "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s " << "\033[0m" << int(st2.progress * 100) << "% " << st2.num_peers << " - " << "\033[32m" << int(st3.<API key> / 1000.f) << "kB/s " << "\033[31m" << int(st3.upload_payload_rate / 1000.f) << "kB/s " << "\033[0m" << int(st3.progress * 100) << "% " << st3.num_peers << std::endl; if (st2.is_seeding && st3.is_seeding) break; test_sleep(1000); } TEST_CHECK(tor2.status().is_seeding); TEST_CHECK(tor3.status().is_seeding); float average2 = sum_dl_rate2 / float(count_dl_rates2); float average3 = sum_dl_rate3 / float(count_dl_rates3); std::cerr << average2 << std::endl; std::cerr << "average rate: " << (average2 / 1000.f) << "kB/s - " << (average3 / 1000.f) << "kB/s" << std::endl; if (tor2.status().is_seeding && tor3.status().is_seeding) std::cerr << "done\n"; // make sure the files are deleted ses1.remove_torrent(tor1, session::delete_files); ses2.remove_torrent(tor2, session::delete_files); ses3.remove_torrent(tor3, session::delete_files); std::auto_ptr<alert> a = ses1.pop_alert(); ptime end = time_now() + seconds(20); while (a.get() == 0 || dynamic_cast<<API key>*>(a.get()) == 0) { if (ses1.wait_for_alert(end - time_now()) == 0) { std::cerr << "wait_for_alert() expired" << std::endl; break; } a = ses1.pop_alert(); assert(a.get()); std::cerr << a->message() << std::endl; } TEST_CHECK(dynamic_cast<<API key>*>(a.get()) != 0); // there shouldn't be any alerts generated from now on // make sure that the timer in wait_for_alert() works // this should time out (ret == 0) and it should take // about 2 seconds ptime start = time_now_hires(); alert const* ret; while ((ret = ses1.wait_for_alert(seconds(2)))) { a = ses1.pop_alert(); std::cerr << ret->message() << std::endl; start = time_now(); } TEST_CHECK(time_now_hires() - start < seconds(3)); TEST_CHECK(time_now_hires() - start >= seconds(2)); TEST_CHECK(!exists("tmp1_swarm/temporary")); TEST_CHECK(!exists("tmp2_swarm/temporary")); TEST_CHECK(!exists("tmp3_swarm/temporary")); remove_all("tmp1_swarm", ec); remove_all("tmp2_swarm", ec); remove_all("tmp3_swarm", ec); } int test_main() { using namespace libtorrent; // with time critical pieces test_swarm(false, false, false, true); // with seed mode test_swarm(false, false, true); test_swarm(); // with super seeding test_swarm(true); // with strict super seeding test_swarm(true, true); return 0; }
from reportlab.lib import styles from reportlab.lib import colors from reportlab.lib.units import cm from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY from reportlab.platypus import Preformatted, Paragraph, Frame, \ Image, Table, TableStyle, Spacer from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont def getParagraphStyles(): """Returns a dictionary of styles to get you started. We will provide a way to specify a module of these. Note that this just includes TableStyles as well as ParagraphStyles for any tables you wish to use. """ pdfmetrics.registerFont(TTFont('Verdana','verdana.ttf')) pdfmetrics.registerFont(TTFont('Verdana-Bold','verdanab.ttf')) pdfmetrics.registerFont(TTFont('Verdana-Italic','verdanai.ttf')) pdfmetrics.registerFont(TTFont('Verdana-BoldItalic','verdanaz.ttf')) pdfmetrics.registerFont(TTFont('Arial Narrow','arialn.ttf')) pdfmetrics.registerFont(TTFont('Arial Narrow-Bold','arialnb.ttf')) pdfmetrics.registerFont(TTFont('Arial Narrow-Italic','arialni.ttf')) pdfmetrics.registerFont(TTFont('Arial Narrow-BoldItalic','arialnbi.ttf')) stylesheet = {} ParagraphStyle = styles.ParagraphStyle para = ParagraphStyle('Normal', None) #the ancestor of all para.fontName = 'Verdana' para.fontSize = 28 para.leading = 32 para.spaceAfter = 6 stylesheet['Normal'] = para #This one is spaced out a bit... para = ParagraphStyle('BodyText', stylesheet['Normal']) para.spaceBefore = 12 stylesheet['BodyText'] = para #Indented, for lists para = ParagraphStyle('Indent', stylesheet['Normal']) para.leftIndent = 60 para.firstLineIndent = 0 stylesheet['Indent'] = para para = ParagraphStyle('Centered', stylesheet['Normal']) para.alignment = TA_CENTER stylesheet['Centered'] = para para = ParagraphStyle('BigCentered', stylesheet['Normal']) para.fontSize = 32 para.alignment = TA_CENTER para.spaceBefore = 12 para.spaceAfter = 12 stylesheet['BigCentered'] = para para = ParagraphStyle('Italic', stylesheet['BodyText']) para.fontName = 'Verdana-Italic' stylesheet['Italic'] = para para = ParagraphStyle('Title', stylesheet['Normal']) para.fontName = 'Arial Narrow-Bold' para.fontSize = 48 para.leading = 58 para.alignment = TA_CENTER stylesheet['Title'] = para para = ParagraphStyle('Heading1', stylesheet['Normal']) para.fontName = 'Arial Narrow-Bold' para.fontSize = 40 para.leading = 44 para.alignment = TA_CENTER stylesheet['Heading1'] = para para = ParagraphStyle('Heading2', stylesheet['Normal']) para.fontName = 'Verdana' para.fontSize = 32 para.leading = 36 para.spaceBefore = 32 para.spaceAfter = 12 stylesheet['Heading2'] = para para = ParagraphStyle('Heading3', stylesheet['Normal']) para.fontName = 'Verdana' para.spaceBefore = 20 para.spaceAfter = 6 stylesheet['Heading3'] = para para = ParagraphStyle('Heading4', stylesheet['Normal']) para.fontName = 'Verdana-BoldItalic' para.spaceBefore = 6 stylesheet['Heading4'] = para para = ParagraphStyle('Bullet', stylesheet['Normal']) para.firstLineIndent = 0 para.leftIndent = 56 para.spaceBefore = 6 para.bulletFontName = 'Symbol' para.bulletFontSize = 24 para.bulletIndent = 20 stylesheet['Bullet'] = para para = ParagraphStyle('Bullet2', stylesheet['Normal']) para.firstLineIndent = 0 para.leftIndent = 80 para.spaceBefore = 6 para.fontSize = 24 para.bulletFontName = 'Symbol' para.bulletFontSize = 20 para.bulletIndent = 60 stylesheet['Bullet2'] = para para = ParagraphStyle('Definition', stylesheet['Normal']) #use this for definition lists para.firstLineIndent = 0 para.leftIndent = 60 para.bulletIndent = 0 para.bulletFontName = 'Verdana-BoldItalic' para.bulletFontSize = 24 stylesheet['Definition'] = para para = ParagraphStyle('Code', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 16 para.leading = 18 para.leftIndent = 36 stylesheet['Code'] = para para = ParagraphStyle('PythonCode', stylesheet['Normal']) para.fontName = 'Courier' para.fontSize = 16 para.leading = 18 para.leftIndent = 36 stylesheet['Code'] = para para = ParagraphStyle('Small', stylesheet['Normal']) para.fontSize = 12 para.leading = 14 stylesheet['Small'] = para #now for a table ts = TableStyle([ ('FONT', (0,0), (-1,-1), 'Arial Narrow', 22), ('LINEABOVE', (0,1), (-1,1), 2, colors.green), ('LINEABOVE', (0,2), (-1,-1), 0.25, colors.black), ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green), ('LINEBEFORE', (0,1), (-1,-1), 2, colors.black), ('LINEAFTER', (0,1), (-1,-1), 2, colors.black), ('ALIGN', (4,1), (-1,-1), 'RIGHT'), #all numeric cells right aligned ('TEXTCOLOR', (0,2), (0,-1), colors.black), ('BACKGROUND', (0,1), (-1,1), colors.Color(0,0.7,0.7)) ]) stylesheet['table1'] = ts return stylesheet
#include <linux/errno.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/dma-mapping.h> #include <linux/param.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/module.h> #include <linux/spinlock.h> #include <linux/slab.h> #include <asm/page.h> #include <asm/pgtable.h> #include <asm/8xx_immap.h> #include <asm/cpm1.h> #include <asm/io.h> #include <asm/tlbflush.h> #include <asm/rheap.h> #include <asm/prom.h> #include <asm/cpm.h> #include <asm/fs_pd.h> #ifdef CONFIG_8xx_GPIO #include <linux/of_gpio.h> #endif #define CPM_MAP_SIZE (0x4000) cpm8xx_t __iomem *cpmp; /* Pointer to comm processor space */ immap_t __iomem *mpc8xx_immr; static cpic8xx_t __iomem *cpic_reg; static struct irq_host *cpm_pic_host; static void cpm_mask_irq(unsigned int irq) { unsigned int cpm_vec = (unsigned int)irq_map[irq].hwirq; clrbits32(&cpic_reg->cpic_cimr, (1 << cpm_vec)); } static void cpm_unmask_irq(unsigned int irq) { unsigned int cpm_vec = (unsigned int)irq_map[irq].hwirq; setbits32(&cpic_reg->cpic_cimr, (1 << cpm_vec)); } static void cpm_end_irq(unsigned int irq) { unsigned int cpm_vec = (unsigned int)irq_map[irq].hwirq; out_be32(&cpic_reg->cpic_cisr, (1 << cpm_vec)); } static struct irq_chip cpm_pic = { .name = "CPM PIC", .mask = cpm_mask_irq, .unmask = cpm_unmask_irq, .eoi = cpm_end_irq, }; int cpm_get_irq(void) { int cpm_vec; /* Get the vector by setting the ACK bit and then reading * the register. */ out_be16(&cpic_reg->cpic_civr, 1); cpm_vec = in_be16(&cpic_reg->cpic_civr); cpm_vec >>= 11; return irq_linear_revmap(cpm_pic_host, cpm_vec); } static int cpm_pic_host_map(struct irq_host *h, unsigned int virq, irq_hw_number_t hw) { pr_debug("cpm_pic_host_map(%d, 0x%lx)\n", virq, hw); irq_to_desc(virq)->status |= IRQ_LEVEL; <API key>(virq, &cpm_pic, handle_fasteoi_irq); return 0; } /* The CPM can generate the error interrupt when there is a race condition * between generating and masking interrupts. All we have to do is ACK it * and return. This is a no-op function so we don't need any special * tests in the interrupt handler. */ static irqreturn_t cpm_error_interrupt(int irq, void *dev) { return IRQ_HANDLED; } static struct irqaction cpm_error_irqaction = { .handler = cpm_error_interrupt, .name = "error", }; static struct irq_host_ops cpm_pic_host_ops = { .map = cpm_pic_host_map, }; unsigned int cpm_pic_init(void) { struct device_node *np = NULL; struct resource res; unsigned int sirq = NO_IRQ, hwirq, eirq; int ret; pr_debug("cpm_pic_init\n"); np = <API key>(NULL, NULL, "fsl,cpm1-pic"); if (np == NULL) np = <API key>(NULL, "cpm-pic", "CPM"); if (np == NULL) { printk(KERN_ERR "CPM PIC init: can not find cpm-pic node\n"); return sirq; } ret = <API key>(np, 0, &res); if (ret) goto end; cpic_reg = ioremap(res.start, res.end - res.start + 1); if (cpic_reg == NULL) goto end; sirq = <API key>(np, 0); if (sirq == NO_IRQ) goto end; /* Initialize the CPM interrupt controller. */ hwirq = (unsigned int)irq_map[sirq].hwirq; out_be32(&cpic_reg->cpic_cicr, (CICR_SCD_SCC4 | CICR_SCC_SCC3 | CICR_SCB_SCC2 | CICR_SCA_SCC1) | ((hwirq/2) << 13) | CICR_HP_MASK); out_be32(&cpic_reg->cpic_cimr, 0); cpm_pic_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, 64, &cpm_pic_host_ops, 64); if (cpm_pic_host == NULL) { printk(KERN_ERR "CPM2 PIC: failed to allocate irq host!\n"); sirq = NO_IRQ; goto end; } /* Install our own error handler. */ np = <API key>(NULL, NULL, "fsl,cpm1"); if (np == NULL) np = <API key>(NULL, "cpm"); if (np == NULL) { printk(KERN_ERR "CPM PIC init: can not find cpm node\n"); goto end; } eirq = <API key>(np, 0); if (eirq == NO_IRQ) goto end; if (setup_irq(eirq, &cpm_error_irqaction)) printk(KERN_ERR "Could not allocate CPM error IRQ!"); setbits32(&cpic_reg->cpic_cicr, CICR_IEN); end: of_node_put(np); return sirq; } void __init cpm_reset(void) { sysconf8xx_t __iomem *siu_conf; mpc8xx_immr = ioremap(get_immrbase(), 0x4000); if (!mpc8xx_immr) { printk(KERN_CRIT "Could not map IMMR\n"); return; } cpmp = &mpc8xx_immr->im_cpm; #ifndef <API key> /* Perform a reset. */ out_be16(&cpmp->cp_cpcr, CPM_CR_RST | CPM_CR_FLG); /* Wait for it. */ while (in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG); #endif #ifdef CONFIG_UCODE_PATCH cpm_load_patch(cpmp); #endif /* Set SDMA Bus Request priority 5. * On 860T, this also enables FEC priority 6. I am not sure * this is what we realy want for some applications, but the * manual recommends it. * Bit 25, FAM can also be set to use FEC aggressive mode (860T). */ siu_conf = immr_map(im_siu_conf); out_be32(&siu_conf->sc_sdcr, 1); immr_unmap(siu_conf); cpm_muram_init(); } static DEFINE_SPINLOCK(cmd_lock); #define MAX_CR_CMD_LOOPS 10000 int cpm_command(u32 command, u8 opcode) { int i, ret; unsigned long flags; if (command & 0xffffff0f) return -EINVAL; spin_lock_irqsave(&cmd_lock, flags); ret = 0; out_be16(&cpmp->cp_cpcr, command | CPM_CR_FLG | (opcode << 8)); for (i = 0; i < MAX_CR_CMD_LOOPS; i++) if ((in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0) goto out; printk(KERN_ERR "%s(): Not able to issue CPM command\n", __func__); ret = -EIO; out: <API key>(&cmd_lock, flags); return ret; } EXPORT_SYMBOL(cpm_command); /* Set a baud rate generator. This needs lots of work. There are * four BRGs, any of which can be wired to any channel. * The internal baud rate clock is the system clock divided by 16. * This assumes the baudrate is 16x oversampled by the uart. */ #define BRG_INT_CLK (get_brgfreq()) #define BRG_UART_CLK (BRG_INT_CLK/16) #define BRG_UART_CLK_DIV16 (BRG_UART_CLK/16) void cpm_setbrg(uint brg, uint rate) { u32 __iomem *bp; /* This is good enough to get SMCs running..... */ bp = &cpmp->cp_brgc1; bp += brg; /* The BRG has a 12-bit counter. For really slow baud rates (or * really fast processors), we may have to further divide by 16. */ if (((BRG_UART_CLK / rate) - 1) < 4096) out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN); else out_be32(bp, (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) | CPM_BRG_EN | CPM_BRG_DIV16); } struct cpm_ioport16 { __be16 dir, par, odr_sor, dat, intr; __be16 res[3]; }; struct cpm_ioport32b { __be32 dir, par, odr, dat; }; struct cpm_ioport32e { __be32 dir, par, sor, odr, dat; }; static void cpm1_set_pin32(int port, int pin, int flags) { struct cpm_ioport32e __iomem *iop; pin = 1 << (31 - pin); if (port == CPM_PORTB) iop = (struct cpm_ioport32e __iomem *) &mpc8xx_immr->im_cpm.cp_pbdir; else iop = (struct cpm_ioport32e __iomem *) &mpc8xx_immr->im_cpm.cp_pedir; if (flags & CPM_PIN_OUTPUT) setbits32(&iop->dir, pin); else clrbits32(&iop->dir, pin); if (!(flags & CPM_PIN_GPIO)) setbits32(&iop->par, pin); else clrbits32(&iop->par, pin); if (port == CPM_PORTB) { if (flags & CPM_PIN_OPENDRAIN) setbits16(&mpc8xx_immr->im_cpm.cp_pbodr, pin); else clrbits16(&mpc8xx_immr->im_cpm.cp_pbodr, pin); } if (port == CPM_PORTE) { if (flags & CPM_PIN_SECONDARY) setbits32(&iop->sor, pin); else clrbits32(&iop->sor, pin); if (flags & CPM_PIN_OPENDRAIN) setbits32(&mpc8xx_immr->im_cpm.cp_peodr, pin); else clrbits32(&mpc8xx_immr->im_cpm.cp_peodr, pin); } } static void cpm1_set_pin16(int port, int pin, int flags) { struct cpm_ioport16 __iomem *iop = (struct cpm_ioport16 __iomem *)&mpc8xx_immr->im_ioport; pin = 1 << (15 - pin); if (port != 0) iop += port - 1; if (flags & CPM_PIN_OUTPUT) setbits16(&iop->dir, pin); else clrbits16(&iop->dir, pin); if (!(flags & CPM_PIN_GPIO)) setbits16(&iop->par, pin); else clrbits16(&iop->par, pin); if (port == CPM_PORTA) { if (flags & CPM_PIN_OPENDRAIN) setbits16(&iop->odr_sor, pin); else clrbits16(&iop->odr_sor, pin); } if (port == CPM_PORTC) { if (flags & CPM_PIN_SECONDARY) setbits16(&iop->odr_sor, pin); else clrbits16(&iop->odr_sor, pin); } } void cpm1_set_pin(enum cpm_port port, int pin, int flags) { if (port == CPM_PORTB || port == CPM_PORTE) cpm1_set_pin32(port, pin, flags); else cpm1_set_pin16(port, pin, flags); } int cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode) { int shift; int i, bits = 0; u32 __iomem *reg; u32 mask = 7; u8 clk_map[][3] = { {CPM_CLK_SCC1, CPM_BRG1, 0}, {CPM_CLK_SCC1, CPM_BRG2, 1}, {CPM_CLK_SCC1, CPM_BRG3, 2}, {CPM_CLK_SCC1, CPM_BRG4, 3}, {CPM_CLK_SCC1, CPM_CLK1, 4}, {CPM_CLK_SCC1, CPM_CLK2, 5}, {CPM_CLK_SCC1, CPM_CLK3, 6}, {CPM_CLK_SCC1, CPM_CLK4, 7}, {CPM_CLK_SCC2, CPM_BRG1, 0}, {CPM_CLK_SCC2, CPM_BRG2, 1}, {CPM_CLK_SCC2, CPM_BRG3, 2}, {CPM_CLK_SCC2, CPM_BRG4, 3}, {CPM_CLK_SCC2, CPM_CLK1, 4}, {CPM_CLK_SCC2, CPM_CLK2, 5}, {CPM_CLK_SCC2, CPM_CLK3, 6}, {CPM_CLK_SCC2, CPM_CLK4, 7}, {CPM_CLK_SCC3, CPM_BRG1, 0}, {CPM_CLK_SCC3, CPM_BRG2, 1}, {CPM_CLK_SCC3, CPM_BRG3, 2}, {CPM_CLK_SCC3, CPM_BRG4, 3}, {CPM_CLK_SCC3, CPM_CLK5, 4}, {CPM_CLK_SCC3, CPM_CLK6, 5}, {CPM_CLK_SCC3, CPM_CLK7, 6}, {CPM_CLK_SCC3, CPM_CLK8, 7}, {CPM_CLK_SCC4, CPM_BRG1, 0}, {CPM_CLK_SCC4, CPM_BRG2, 1}, {CPM_CLK_SCC4, CPM_BRG3, 2}, {CPM_CLK_SCC4, CPM_BRG4, 3}, {CPM_CLK_SCC4, CPM_CLK5, 4}, {CPM_CLK_SCC4, CPM_CLK6, 5}, {CPM_CLK_SCC4, CPM_CLK7, 6}, {CPM_CLK_SCC4, CPM_CLK8, 7}, {CPM_CLK_SMC1, CPM_BRG1, 0}, {CPM_CLK_SMC1, CPM_BRG2, 1}, {CPM_CLK_SMC1, CPM_BRG3, 2}, {CPM_CLK_SMC1, CPM_BRG4, 3}, {CPM_CLK_SMC1, CPM_CLK1, 4}, {CPM_CLK_SMC1, CPM_CLK2, 5}, {CPM_CLK_SMC1, CPM_CLK3, 6}, {CPM_CLK_SMC1, CPM_CLK4, 7}, {CPM_CLK_SMC2, CPM_BRG1, 0}, {CPM_CLK_SMC2, CPM_BRG2, 1}, {CPM_CLK_SMC2, CPM_BRG3, 2}, {CPM_CLK_SMC2, CPM_BRG4, 3}, {CPM_CLK_SMC2, CPM_CLK5, 4}, {CPM_CLK_SMC2, CPM_CLK6, 5}, {CPM_CLK_SMC2, CPM_CLK7, 6}, {CPM_CLK_SMC2, CPM_CLK8, 7}, }; switch (target) { case CPM_CLK_SCC1: reg = &mpc8xx_immr->im_cpm.cp_sicr; shift = 0; break; case CPM_CLK_SCC2: reg = &mpc8xx_immr->im_cpm.cp_sicr; shift = 8; break; case CPM_CLK_SCC3: reg = &mpc8xx_immr->im_cpm.cp_sicr; shift = 16; break; case CPM_CLK_SCC4: reg = &mpc8xx_immr->im_cpm.cp_sicr; shift = 24; break; case CPM_CLK_SMC1: reg = &mpc8xx_immr->im_cpm.cp_simode; shift = 12; break; case CPM_CLK_SMC2: reg = &mpc8xx_immr->im_cpm.cp_simode; shift = 28; break; default: printk(KERN_ERR "cpm1_clock_setup: invalid clock target\n"); return -EINVAL; } for (i = 0; i < ARRAY_SIZE(clk_map); i++) { if (clk_map[i][0] == target && clk_map[i][1] == clock) { bits = clk_map[i][2]; break; } } if (i == ARRAY_SIZE(clk_map)) { printk(KERN_ERR "cpm1_clock_setup: invalid clock combination\n"); return -EINVAL; } bits <<= shift; mask <<= shift; if (reg == &mpc8xx_immr->im_cpm.cp_sicr) { if (mode == CPM_CLK_RTX) { bits |= bits << 3; mask |= mask << 3; } else if (mode == CPM_CLK_RX) { bits <<= 3; mask <<= 3; } } out_be32(reg, (in_be32(reg) & ~mask) | bits); return 0; } /* * GPIO LIB API implementation */ #ifdef CONFIG_8xx_GPIO struct cpm1_gpio16_chip { struct of_mm_gpio_chip mm_gc; spinlock_t lock; /* shadowed data register to clear/set bits safely */ u16 cpdata; }; static inline struct cpm1_gpio16_chip * to_cpm1_gpio16_chip(struct of_mm_gpio_chip *mm_gc) { return container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc); } static void <API key>(struct of_mm_gpio_chip *mm_gc) { struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); struct cpm_ioport16 __iomem *iop = mm_gc->regs; cpm1_gc->cpdata = in_be16(&iop->dat); } static int cpm1_gpio16_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm_ioport16 __iomem *iop = mm_gc->regs; u16 pin_mask; pin_mask = 1 << (15 - gpio); return !!(in_be16(&iop->dat) & pin_mask); } static void __cpm1_gpio16_set(struct of_mm_gpio_chip *mm_gc, u16 pin_mask, int value) { struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); struct cpm_ioport16 __iomem *iop = mm_gc->regs; if (value) cpm1_gc->cpdata |= pin_mask; else cpm1_gc->cpdata &= ~pin_mask; out_be16(&iop->dat, cpm1_gc->cpdata); } static void cpm1_gpio16_set(struct gpio_chip *gc, unsigned int gpio, int value) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); unsigned long flags; u16 pin_mask = 1 << (15 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); __cpm1_gpio16_set(mm_gc, pin_mask, value); <API key>(&cpm1_gc->lock, flags); } static int cpm1_gpio16_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); struct cpm_ioport16 __iomem *iop = mm_gc->regs; unsigned long flags; u16 pin_mask = 1 << (15 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); setbits16(&iop->dir, pin_mask); __cpm1_gpio16_set(mm_gc, pin_mask, val); <API key>(&cpm1_gc->lock, flags); return 0; } static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); struct cpm_ioport16 __iomem *iop = mm_gc->regs; unsigned long flags; u16 pin_mask = 1 << (15 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); clrbits16(&iop->dir, pin_mask); <API key>(&cpm1_gc->lock, flags); return 0; } int cpm1_gpiochip_add16(struct device_node *np) { struct cpm1_gpio16_chip *cpm1_gc; struct of_mm_gpio_chip *mm_gc; struct gpio_chip *gc; cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); if (!cpm1_gc) return -ENOMEM; spin_lock_init(&cpm1_gc->lock); mm_gc = &cpm1_gc->mm_gc; gc = &mm_gc->gc; mm_gc->save_regs = <API key>; gc->ngpio = 16; gc->direction_input = cpm1_gpio16_dir_in; gc->direction_output = cpm1_gpio16_dir_out; gc->get = cpm1_gpio16_get; gc->set = cpm1_gpio16_set; return of_mm_gpiochip_add(np, mm_gc); } struct cpm1_gpio32_chip { struct of_mm_gpio_chip mm_gc; spinlock_t lock; /* shadowed data register to clear/set bits safely */ u32 cpdata; }; static inline struct cpm1_gpio32_chip * to_cpm1_gpio32_chip(struct of_mm_gpio_chip *mm_gc) { return container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc); } static void <API key>(struct of_mm_gpio_chip *mm_gc) { struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); struct cpm_ioport32b __iomem *iop = mm_gc->regs; cpm1_gc->cpdata = in_be32(&iop->dat); } static int cpm1_gpio32_get(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm_ioport32b __iomem *iop = mm_gc->regs; u32 pin_mask; pin_mask = 1 << (31 - gpio); return !!(in_be32(&iop->dat) & pin_mask); } static void __cpm1_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask, int value) { struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); struct cpm_ioport32b __iomem *iop = mm_gc->regs; if (value) cpm1_gc->cpdata |= pin_mask; else cpm1_gc->cpdata &= ~pin_mask; out_be32(&iop->dat, cpm1_gc->cpdata); } static void cpm1_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); unsigned long flags; u32 pin_mask = 1 << (31 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); __cpm1_gpio32_set(mm_gc, pin_mask, value); <API key>(&cpm1_gc->lock, flags); } static int cpm1_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); struct cpm_ioport32b __iomem *iop = mm_gc->regs; unsigned long flags; u32 pin_mask = 1 << (31 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); setbits32(&iop->dir, pin_mask); __cpm1_gpio32_set(mm_gc, pin_mask, val); <API key>(&cpm1_gc->lock, flags); return 0; } static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) { struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); struct cpm_ioport32b __iomem *iop = mm_gc->regs; unsigned long flags; u32 pin_mask = 1 << (31 - gpio); spin_lock_irqsave(&cpm1_gc->lock, flags); clrbits32(&iop->dir, pin_mask); <API key>(&cpm1_gc->lock, flags); return 0; } int cpm1_gpiochip_add32(struct device_node *np) { struct cpm1_gpio32_chip *cpm1_gc; struct of_mm_gpio_chip *mm_gc; struct gpio_chip *gc; cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); if (!cpm1_gc) return -ENOMEM; spin_lock_init(&cpm1_gc->lock); mm_gc = &cpm1_gc->mm_gc; gc = &mm_gc->gc; mm_gc->save_regs = <API key>; gc->ngpio = 32; gc->direction_input = cpm1_gpio32_dir_in; gc->direction_output = cpm1_gpio32_dir_out; gc->get = cpm1_gpio32_get; gc->set = cpm1_gpio32_set; return of_mm_gpiochip_add(np, mm_gc); } static int cpm_init_par_io(void) { struct device_node *np; <API key>(np, NULL, "fsl,cpm1-pario-bank-a") cpm1_gpiochip_add16(np); <API key>(np, NULL, "fsl,cpm1-pario-bank-b") cpm1_gpiochip_add32(np); <API key>(np, NULL, "fsl,cpm1-pario-bank-c") cpm1_gpiochip_add16(np); <API key>(np, NULL, "fsl,cpm1-pario-bank-d") cpm1_gpiochip_add16(np); /* Port E uses CPM2 layout */ <API key>(np, NULL, "fsl,cpm1-pario-bank-e") cpm2_gpiochip_add32(np); return 0; } arch_initcall(cpm_init_par_io); #endif /* CONFIG_8xx_GPIO */
try: import jni System = jni.cls("java/lang/System") except: print("SKIP") raise SystemExit System.out.println("Hello, Java!")
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="robots" content="index, follow, all" /> <title>Thelia\Core\Event\ShippingZone\<API key> | </title> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css"> </head> <body id="class"> <div class="header"> <ul> <li><a href="../../../../classes.html">Classes</a></li> <li><a href="../../../../namespaces.html">Namespaces</a></li> <li><a href="../../../../interfaces.html">Interfaces</a></li> <li><a href="../../../../traits.html">Traits</a></li> <li><a href="../../../../doc-index.html">Index</a></li> </ul> <div id="title"></div> <div class="type">Class</div> <h1><a href="../../../../Thelia/Core/Event/ShippingZone.html">Thelia\Core\Event\ShippingZone</a>\<API key></h1> </div> <div class="content"> <p> class <strong><API key></strong> extends <a href="../../../../Thelia/Core/Event/ActionEvent.html"><abbr title="Thelia\Core\Event\ActionEvent">ActionEvent</abbr></a></p> <div class="description"> <p>Class <API key></p> <p> </p> </div> <h2>Methods</h2> <table> <tr> <td class="type"> </td> <td class="last"> <a href=" <p> </p> </td> <td><small>from&nbsp;<a href="../../../../Thelia/Core/Event/ActionEvent.html </tr> <tr> <td class="type"> </td> <td class="last"> <a href=" <p> </p> </td> <td><small>from&nbsp;<a href="../../../../Thelia/Core/Event/ActionEvent.html </tr> <tr> <td class="type"> </td> <td class="last"> <a href="#method_bindForm">bindForm</a>(<abbr title="Symfony\Component\Form\Form">Form</abbr> $form) <p> </p> </td> <td><small>from&nbsp;<a href="../../../../Thelia/Core/Event/ActionEvent.html#method_bindForm"><abbr title="Thelia\Core\Event\ActionEvent">ActionEvent</abbr></a></small></td> </tr> <tr> <td class="type"> </td> <td class="last"> <a href=" <p> </p> </td> <td></td> </tr> <tr> <td class="type"> <abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr> </td> <td class="last"> <a href="#method_setAreaId">setAreaId</a>(mixed $area_id) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> mixed </td> <td class="last"> <a href="#method_getAreaId">getAreaId</a>() <p> </p> </td> <td></td> </tr> <tr> <td class="type"> <abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr> </td> <td class="last"> <a href="#<API key>">setShippingZoneId</a>(mixed $shipping_zone_id) <p> </p> </td> <td></td> </tr> <tr> <td class="type"> mixed </td> <td class="last"> <a href="#<API key>">getShippingZoneId</a>() <p> </p> </td> <td></td> </tr> </table> <h2>Details</h2> <h3 id="method___set"> <div class="location">in <a href="../../../../Thelia/Core/Event/ActionEvent.html <code> public <strong>__set</strong>($name, $value)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$name</td> <td> </td> </tr> <tr> <td></td> <td>$value</td> <td> </td> </tr> </table> </div> </div> <h3 id="method___get"> <div class="location">in <a href="../../../../Thelia/Core/Event/ActionEvent.html <code> public <strong>__get</strong>($name)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$name</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_bindForm"> <div class="location">in <a href="../../../../Thelia/Core/Event/ActionEvent.html#method_bindForm"><abbr title="Thelia\Core\Event\ActionEvent">ActionEvent</abbr></a> at line 44</div> <code> public <strong>bindForm</strong>(<abbr title="Symfony\Component\Form\Form">Form</abbr> $form)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td><abbr title="Symfony\Component\Form\Form">Form</abbr></td> <td>$form</td> <td> </td> </tr> </table> </div> </div> <h3 id="method___construct"> <div class="location">at line 27</div> <code> public <strong>__construct</strong>($area_id, $shipping_zone_id)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td></td> <td>$area_id</td> <td> </td> </tr> <tr> <td></td> <td>$shipping_zone_id</td> <td> </td> </tr> </table> </div> </div> <h3 id="method_setAreaId"> <div class="location">at line 38</div> <code> public <abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr> <strong>setAreaId</strong>(mixed $area_id)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td>mixed</td> <td>$area_id</td> <td> </td> </tr> </table> <h4>Return Value</h4> <table> <tr> <td><abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr></td> <td> </td> </tr> </table> </div> </div> <h3 id="method_getAreaId"> <div class="location">at line 48</div> <code> public mixed <strong>getAreaId</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Return Value</h4> <table> <tr> <td>mixed</td> <td> </td> </tr> </table> </div> </div> <h3 id="<API key>"> <div class="location">at line 58</div> <code> public <abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr> <strong>setShippingZoneId</strong>(mixed $shipping_zone_id)</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Parameters</h4> <table> <tr> <td>mixed</td> <td>$shipping_zone_id</td> <td> </td> </tr> </table> <h4>Return Value</h4> <table> <tr> <td><abbr title="Thelia\Core\Event\ShippingZone\$this">$this</abbr></td> <td> </td> </tr> </table> </div> </div> <h3 id="<API key>"> <div class="location">at line 68</div> <code> public mixed <strong>getShippingZoneId</strong>()</code> </h3> <div class="details"> <p> </p> <p> </p> <div class="tags"> <h4>Return Value</h4> <table> <tr> <td>mixed</td> <td> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated by <a href="http://sami.sensiolabs.org/" target="_top">Sami, the API Documentation Generator</a>. </div> </body> </html>
package org.mockito.release.util; /** * Utility for validation of arguments */ public abstract class ArgumentValidation { /** * None of the input targets can not be null otherwise <API key> is thrown. * Every second argument must a String describing the previous element. */ public static void notNull(Object ... targets) { if (targets.length % 2 != 0) { throw new <API key>("notNull method requires pairs of argument + message"); } boolean nullFound = false; for (Object t : targets) { if (t == null) { nullFound = true; continue; } if (nullFound) { if (!(t instanceof String)) { throw new <API key>("notNull method requires pairs of argument + message"); } throw new <API key>(((String) t).concat(" cannot be null.")); } } } }
/* * Authors: * Jaromir Koutek <miri@punknet.cz>, * Jan Harkes <jaharkes@cwi.nl>, * Mark Lord <mlord@pobox.com> * Some parts of code are from ali14xx.c and from rz1000.c. * * OPTi is trademark of OPTi, Octek is trademark of Octek. * * I used docs from OPTi databook, from ftp.opti.com, file 9123-0002.ps * and disassembled/traced setupvic.exe (DOS program). * It increases kernel code about 2 kB. * I don't have this card no more, but I hope I can get some in case * of needed development. * My card is Octek PIDE 1.01 (on card) or OPTiViC (program). * It has a place for a secondary connector in circuit, but nothing * is there. Also BIOS says no address for * secondary controller (see bellow in ide_init_opti621). * I've only tested this on my system, which only has one disk. * It's Western Digital WDAC2850, with PIO mode 3. The PCI bus * is at 20 MHz (I have DX2/80, I tried PCI at 40, but I got random * lockups). I tried the OCTEK double speed CD-ROM and * it does not work! But I can't boot DOS also, so it's probably * hardware fault. I have connected Conner 80MB, the Seagate 850MB (no * problems) and Seagate 1GB (as slave, WD as master). My experiences * with the third, 1GB drive: I got 3MB/s (hdparm), but sometimes * it slows to about 100kB/s! I don't know why and I have * not this drive now, so I can't try it again. * I write this driver because I lost the paper ("manual") with * settings of jumpers on the card and I have to boot Linux with * Loadlin except LILO, cause I have to run the setupvic.exe program * already or I get disk errors (my test: rpm -Vf * /usr/X11R6/bin/XF86_SVGA - or any big file). * Some numbers from hdparm -t /dev/hda: * Timing buffer-cache reads: 32 MB in 3.02 seconds =10.60 MB/sec * Timing buffered disk reads: 16 MB in 5.52 seconds = 2.90 MB/sec * I have 4 Megs/s before, but I don't know why (maybe changes * in hdparm test). * After release of 0.1, I got some successful reports, so it might work. * * The main problem with OPTi is that some timings for master * and slave must be the same. For example, if you have master * PIO 3 and slave PIO 0, driver have to set some timings of * master for PIO 0. Second problem is that opti621_tune_drive * got only one drive to set, but have to set both drives. * This is solved in compute_pios. If you don't set * the second drive, compute_pios use <API key> * for autoselect mode (you can change it to PIO 0, if you want). * If you then set the second drive to another PIO, the old value * (automatically selected) will be overrided by yours. * There is a 25/33MHz switch in configuration * register, but driver is written for use at any frequency which get * (use idebus=xx to select PCI bus speed). * Use ide0=autotune for automatical tune of the PIO modes. * If you get strange results, do not use this and set PIO manually * by hdparm. * * Version 0.1, Nov 8, 1996 * by Jaromir Koutek, for 2.1.8. * Initial version of driver. * * Version 0.2 * Number 0.2 skipped. * * Version 0.3, Nov 29, 1997 * by Mark Lord (probably), for 2.1.68 * Updates for use with new IDE block driver. * * Version 0.4, Dec 14, 1997 * by Jan Harkes * Fixed some errors and cleaned the code. * * Version 0.5, Jan 2, 1998 * by Jaromir Koutek * Updates for use with (again) new IDE block driver. * Update of documentation. * * Version 0.6, Jan 2, 1999 * by Jaromir Koutek * Reversed to version 0.3 of the driver, because * 0.5 doesn't work. */ #undef REALLY_SLOW_IO /* most systems can safely undef this */ #define OPTI621_DEBUG /* define for debug messages */ #include <linux/types.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/ioport.h> #include <linux/blkdev.h> #include <linux/pci.h> #include <linux/hdreg.h> #include <linux/ide.h> #include <asm/io.h> #define OPTI621_MAX_PIO 3 /* In fact, I do not have any PIO 4 drive * (address: 25 ns, data: 70 ns, recovery: 35 ns), * but OPTi 82C621 is programmable and it can do (minimal values): * on 40MHz PCI bus (pulse 25 ns): * address: 25 ns, data: 25 ns, recovery: 50 ns; * on 20MHz PCI bus (pulse 50 ns): * address: 50 ns, data: 50 ns, recovery: 100 ns. */ /* #define READ_PREFETCH 0 */ /* Uncomment for disable read prefetch. * There is some readprefetch capatibility in hdparm, * but when I type hdparm -P 1 /dev/hda, I got errors * and till reset drive is inaccessible. * This (hw) read prefetch is safe on my drive. */ #ifndef READ_PREFETCH #define READ_PREFETCH 0x40 /* read prefetch is enabled */ #endif /* else read prefetch is disabled */ #define READ_REG 0 /* index of Read cycle timing register */ #define WRITE_REG 1 /* index of Write cycle timing register */ #define CNTRL_REG 3 /* index of Control register */ #define STRAP_REG 5 /* index of Strap register */ #define MISC_REG 6 /* index of Miscellaneous register */ static int reg_base; #define PIO_NOT_EXIST 254 #define PIO_DONT_KNOW 255 /* there are stored pio numbers from other calls of opti621_tune_drive */ static void compute_pios(ide_drive_t *drive, u8 pio) /* Store values into drive->drive_data * second_contr - 0 for primary controller, 1 for secondary * slave_drive - 0 -> pio is for master, 1 -> pio is for slave * pio - PIO mode for selected drive (for other we don't know) */ { int d; ide_hwif_t *hwif = HWIF(drive); drive->drive_data = <API key>(drive, pio, OPTI621_MAX_PIO, NULL); for (d = 0; d < 2; ++d) { drive = &hwif->drives[d]; if (drive->present) { if (drive->drive_data == PIO_DONT_KNOW) drive->drive_data = <API key>(drive, 255, OPTI621_MAX_PIO, NULL); #ifdef OPTI621_DEBUG printk("%s: Selected PIO mode %d\n", drive->name, drive->drive_data); #endif } else { drive->drive_data = PIO_NOT_EXIST; } } } static int cmpt_clk(int time, int bus_speed) /* Returns (rounded up) time in clocks for time in ns, * with bus_speed in MHz. * Example: bus_speed = 40 MHz, time = 80 ns * 1000/40 = 25 ns (clk value), * 80/25 = 3.2, rounded up to 4 (I hope ;-)). * Use idebus=xx to select right frequency. */ { return ((time*bus_speed+999)/1000); } static void write_reg(ide_hwif_t *hwif, u8 value, int reg) /* Write value to register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). * This is from setupvic.exe program. */ { hwif->INW(reg_base+1); hwif->INW(reg_base+1); hwif->OUTB(3, reg_base+2); hwif->OUTB(value, reg_base+reg); hwif->OUTB(0x83, reg_base+2); } static u8 read_reg(ide_hwif_t *hwif, int reg) /* Read value from register reg, base of register * is at reg_base (0x1f0 primary, 0x170 secondary, * if not changed by PCI configuration). * This is from setupvic.exe program. */ { u8 ret = 0; hwif->INW(reg_base+1); hwif->INW(reg_base+1); hwif->OUTB(3, reg_base+2); ret = hwif->INB(reg_base+reg); hwif->OUTB(0x83, reg_base+2); return ret; } typedef struct pio_clocks_s { int address_time; /* Address setup (clocks) */ int data_time; /* Active/data pulse (clocks) */ int recovery_time; /* Recovery time (clocks) */ } pio_clocks_t; static void compute_clocks(int pio, pio_clocks_t *clks) { if (pio != PIO_NOT_EXIST) { int adr_setup, data_pls; int bus_speed = system_bus_clock(); adr_setup = ide_pio_timings[pio].setup_time; data_pls = ide_pio_timings[pio].active_time; clks->address_time = cmpt_clk(adr_setup, bus_speed); clks->data_time = cmpt_clk(data_pls, bus_speed); clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time - adr_setup-data_pls, bus_speed); if (clks->address_time<1) clks->address_time = 1; if (clks->address_time>4) clks->address_time = 4; if (clks->data_time<1) clks->data_time = 1; if (clks->data_time>16) clks->data_time = 16; if (clks->recovery_time<2) clks->recovery_time = 2; if (clks->recovery_time>17) clks->recovery_time = 17; } else { clks->address_time = 1; clks->data_time = 1; clks->recovery_time = 2; /* minimal values */ } } /* Main tune procedure, called from tuneproc. */ static void opti621_tune_drive (ide_drive_t *drive, u8 pio) { /* primary and secondary drives share some registers, * so we have to program both drives */ unsigned long flags; u8 pio1 = 0, pio2 = 0; pio_clocks_t first, second; int ax, drdy; u8 cycle1, cycle2, misc; ide_hwif_t *hwif = HWIF(drive); /* sets drive->drive_data for both drives */ compute_pios(drive, pio); pio1 = hwif->drives[0].drive_data; pio2 = hwif->drives[1].drive_data; compute_clocks(pio1, &first); compute_clocks(pio2, &second); /* ax = max(a1,a2) */ ax = (first.address_time < second.address_time) ? second.address_time : first.address_time; drdy = 2; /* DRDY is default 2 (by OPTi Databook) */ cycle1 = ((first.data_time-1)<<4) | (first.recovery_time-2); cycle2 = ((second.data_time-1)<<4) | (second.recovery_time-2); misc = READ_PREFETCH | ((ax-1)<<4) | ((drdy-2)<<1); #ifdef OPTI621_DEBUG printk("%s: master: address: %d, data: %d, " "recovery: %d, drdy: %d [clk]\n", hwif->name, ax, first.data_time, first.recovery_time, drdy); printk("%s: slave: address: %d, data: %d, " "recovery: %d, drdy: %d [clk]\n", hwif->name, ax, second.data_time, second.recovery_time, drdy); #endif spin_lock_irqsave(&ide_lock, flags); reg_base = hwif->io_ports[IDE_DATA_OFFSET]; /* allow Register-B */ hwif->OUTB(0xc0, reg_base+CNTRL_REG); /* hmm, setupvic.exe does this ;-) */ hwif->OUTB(0xff, reg_base+5); /* if reads 0xff, adapter not exist? */ (void) hwif->INB(reg_base+CNTRL_REG); /* if reads 0xc0, no interface exist? */ read_reg(hwif, CNTRL_REG); /* read version, probably 0 */ read_reg(hwif, STRAP_REG); /* program primary drive */ /* select Index-0 for Register-A */ write_reg(hwif, 0, MISC_REG); /* set read cycle timings */ write_reg(hwif, cycle1, READ_REG); /* set write cycle timings */ write_reg(hwif, cycle1, WRITE_REG); /* program secondary drive */ /* select Index-1 for Register-B */ write_reg(hwif, 1, MISC_REG); /* set read cycle timings */ write_reg(hwif, cycle2, READ_REG); /* set write cycle timings */ write_reg(hwif, cycle2, WRITE_REG); /* use Register-A for drive 0 */ /* use Register-B for drive 1 */ write_reg(hwif, 0x85, CNTRL_REG); /* set address setup, DRDY timings, */ /* and read prefetch for both drives */ write_reg(hwif, misc, MISC_REG); <API key>(&ide_lock, flags); } /* * init_hwif_opti621() is called once for each hwif found at boot. */ static void __init init_hwif_opti621 (ide_hwif_t *hwif) { hwif->autodma = 0; hwif->drives[0].drive_data = PIO_DONT_KNOW; hwif->drives[1].drive_data = PIO_DONT_KNOW; hwif->tuneproc = &opti621_tune_drive; if (!(hwif->dma_base)) return; hwif->atapi_dma = 1; hwif->mwdma_mask = 0x07; hwif->swdma_mask = 0x07; if (!noautodma) hwif->autodma = 1; hwif->drives[0].autodma = hwif->autodma; hwif->drives[1].autodma = hwif->autodma; } static ide_pci_device_t opti621_chipsets[] __devinitdata = { { .name = "OPTI621", .init_hwif = init_hwif_opti621, .channels = 2, .autodma = AUTODMA, .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, .bootable = ON_BOARD, },{ .name = "OPTI621X", .init_hwif = init_hwif_opti621, .channels = 2, .autodma = AUTODMA, .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, .bootable = ON_BOARD, } }; static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) { return <API key>(dev, &opti621_chipsets[id->driver_data]); } static struct pci_device_id opti621_pci_tbl[] = { { PCI_VENDOR_ID_OPTI, <API key>, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { PCI_VENDOR_ID_OPTI, <API key>, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, { 0, }, }; MODULE_DEVICE_TABLE(pci, opti621_pci_tbl); static struct pci_driver driver = { .name = "Opti621_IDE", .id_table = opti621_pci_tbl, .probe = opti621_init_one, }; static int opti621_ide_init(void) { return <API key>(&driver); } module_init(opti621_ide_init); MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord"); MODULE_DESCRIPTION("PCI driver module for Opti621 IDE"); MODULE_LICENSE("GPL");
<?php defined('_JEXEC') or die; if (!key_exists('field', $displayData)) { return; } $field = $displayData['field']; $label = JText::_($field->label); $value = $field->value; $class = $field->params->get('render_class'); $showLabel = $field->params->get('showlabel'); $labelClass = $field->params->get('label_render_class'); if ($field->context == 'com_contact.mail') { // Prepare the value for the contact form mail $value = html_entity_decode($value); echo ($showLabel ? $label . ': ' : '') . $value . "\r\n"; return; } if (!strlen($value)) { return; } ?> <dt class="contact-field-entry <?php echo $class; ?>"> <?php if ($showLabel == 1) : ?> <span class="field-label <?php echo $labelClass; ?>"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span> <?php endif; ?> </dt> <dd class="contact-field-entry <?php echo $class; ?>"> <span class="field-value"><?php echo $value; ?></span> </dd>
/* ScriptData SDName: Boss_Baron_Geddon SD%Complete: 100 SDComment: SDCategory: Molten Core EndScriptData */ #include "ObjectMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" #include "molten_core.h" #include "SpellAuraEffects.h" #include "SpellScript.h" enum Emotes { EMOTE_SERVICE = 0 }; enum Spells { SPELL_INFERNO = 19695, SPELL_INFERNO_DMG = 19698, SPELL_IGNITE_MANA = 19659, SPELL_LIVING_BOMB = 20475, SPELL_ARMAGEDDON = 20478, }; enum Events { EVENT_INFERNO = 1, EVENT_IGNITE_MANA = 2, EVENT_LIVING_BOMB = 3, }; class boss_baron_geddon : public CreatureScript { public: boss_baron_geddon() : CreatureScript("boss_baron_geddon") { } struct boss_baron_geddonAI : public BossAI { boss_baron_geddonAI(Creature* creature) : BossAI(creature, BOSS_BARON_GEDDON) { } void EnterCombat(Unit* victim) override { BossAI::EnterCombat(victim); events.ScheduleEvent(EVENT_INFERNO, 45000); events.ScheduleEvent(EVENT_IGNITE_MANA, 30000); events.ScheduleEvent(EVENT_LIVING_BOMB, 35000); } void UpdateAI(uint32 diff) override { if (!UpdateVictim()) return; events.Update(diff); // If we are <2% hp cast Armageddon if (!HealthAbovePct(2)) { me-><API key>(true); DoCast(me, SPELL_ARMAGEDDON); Talk(EMOTE_SERVICE); return; } if (me->HasUnitState(UNIT_STATE_CASTING)) return; while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_INFERNO: DoCast(me, SPELL_INFERNO); events.ScheduleEvent(EVENT_INFERNO, 45000); break; case EVENT_IGNITE_MANA: if (Unit* target = SelectTarget(<API key>, 0, 0.0f, true, -SPELL_IGNITE_MANA)) DoCast(target, SPELL_IGNITE_MANA); events.ScheduleEvent(EVENT_IGNITE_MANA, 30000); break; case EVENT_LIVING_BOMB: if (Unit* target = SelectTarget(<API key>, 0, 0.0f, true)) DoCast(target, SPELL_LIVING_BOMB); events.ScheduleEvent(EVENT_LIVING_BOMB, 35000); break; default: break; } if (me->HasUnitState(UNIT_STATE_CASTING)) return; } <API key>(); } }; CreatureAI* GetAI(Creature* creature) const override { return new boss_baron_geddonAI(creature); } }; class <API key> : public SpellScriptLoader { public: <API key>() : SpellScriptLoader("<API key>") { } class <API key> : public AuraScript { PrepareAuraScript(<API key>); void OnPeriodic(AuraEffect const* aurEff) { <API key>(); int32 damageForTick[8] = { 500, 500, 1000, 1000, 2000, 2000, 3000, 5000 }; GetTarget()->CastCustomSpell(SPELL_INFERNO_DMG, <API key>, damageForTick[aurEff->GetTickNumber() - 1], (Unit*)nullptr, TRIGGERED_FULL_MASK, nullptr, aurEff); } void Register() override { OnEffectPeriodic += <API key>(<API key>::OnPeriodic, EFFECT_0, <API key>); } }; AuraScript* GetAuraScript() const override { return new <API key>(); } }; void <API key>() { new boss_baron_geddon(); new <API key>(); }
#include "cache.h" int copy_fd(int ifd, int ofd) { while (1) { char buffer[8192]; ssize_t len = xread(ifd, buffer, sizeof(buffer)); if (!len) break; if (len < 0) { return error("copy-fd: read returned %s", strerror(errno)); } if (write_in_full(ofd, buffer, len) < 0) return error("copy-fd: write returned %s", strerror(errno)); } return 0; } static int copy_times(const char *dst, const char *src) { struct stat st; struct utimbuf times; if (stat(src, &st) < 0) return -1; times.actime = st.st_atime; times.modtime = st.st_mtime; if (utime(dst, &times) < 0) return -1; return 0; } int copy_file(const char *dst, const char *src, int mode) { int fdi, fdo, status; mode = (mode & 0111) ? 0777 : 0666; if ((fdi = open(src, O_RDONLY)) < 0) return fdi; if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) { close(fdi); return fdo; } status = copy_fd(fdi, fdo); close(fdi); if (close(fdo) != 0) return error("%s: close error: %s", dst, strerror(errno)); if (!status && adjust_shared_perm(dst)) return -1; return status; } int copy_file_with_time(const char *dst, const char *src, int mode) { int status = copy_file(dst, src, mode); if (!status) return copy_times(dst, src); return status; }
#include <drivers/mmcsd_core.h> #include <drivers/sdio.h> #ifndef RT_SDIO_STACK_SIZE #define RT_SDIO_STACK_SIZE 512 #endif #ifndef <API key> #define <API key> 0x40 #endif static rt_list_t sdio_cards; static rt_list_t sdio_drivers; struct sdio_card { struct rt_mmcsd_card *card; rt_list_t list; }; struct sdio_driver { struct rt_sdio_driver *drv; rt_list_t list; }; #define MIN(a, b) (a < b ? a : b) static const rt_uint8_t speed_value[16] = { 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 }; static const rt_uint32_t speed_unit[8] = { 10000, 100000, 1000000, 10000000, 0, 0, 0, 0 }; rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card *card, const struct rt_sdio_device_id *id); rt_int32_t <API key>(struct rt_mmcsd_host *host, rt_uint32_t ocr, rt_uint32_t *cmd5_resp) { struct rt_mmcsd_cmd cmd; rt_int32_t i, err = 0; RT_ASSERT(host != RT_NULL); rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); cmd.cmd_code = SD_IO_SEND_OP_COND; cmd.arg = ocr; cmd.flags = RESP_SPI_R4 | RESP_R4 | CMD_BCR; for (i = 100; i; i { err = mmcsd_send_cmd(host, &cmd, 0); if (err) break; /* if we're just probing, do a single pass */ if (ocr == 0) break; /* otherwise wait until reset completes */ if (controller_is_spi(host)) { /* * Both R1_SPI_IDLE and MMC_CARD_BUSY indicate * an initialized card under SPI, but some cards * (Marvell's) only behave when looking at this * one. */ if (cmd.resp[1] & CARD_BUSY) break; } else { if (cmd.resp[0] & CARD_BUSY) break; } err = -RT_ETIMEOUT; mmcsd_delay_ms(10); } if (cmd5_resp) *cmd5_resp = cmd.resp[controller_is_spi(host) ? 1 : 0]; return err; } rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card, rt_int32_t rw, rt_uint32_t fn, rt_uint32_t reg_addr, rt_uint8_t *pdata, rt_uint8_t raw) { struct rt_mmcsd_cmd cmd; rt_int32_t err; RT_ASSERT(card != RT_NULL); RT_ASSERT(fn <= SDIO_MAX_FUNCTIONS); if (reg_addr & ~<API key>) return -RT_ERROR; rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); cmd.cmd_code = SD_IO_RW_DIRECT; cmd.arg = rw ? <API key> : SDIO_ARG_CMD52_READ; cmd.arg |= fn << <API key>; cmd.arg |= raw ? <API key> : 0x00000000; cmd.arg |= reg_addr << <API key>; cmd.arg |= *pdata; cmd.flags = RESP_SPI_R5 | RESP_R5 | CMD_AC; err = mmcsd_send_cmd(card->host, &cmd, 0); if (err) return err; if (!controller_is_spi(card->host)) { if (cmd.resp[0] & R5_ERROR) return -RT_EIO; if (cmd.resp[0] & R5_FUNCTION_NUMBER) return -RT_ERROR; if (cmd.resp[0] & R5_OUT_OF_RANGE) return -RT_ERROR; } if (!rw || raw) { if (controller_is_spi(card->host)) *pdata = (cmd.resp[0] >> 8) & 0xFF; else *pdata = cmd.resp[0] & 0xFF; } return 0; } rt_int32_t sdio_io_rw_extended(struct rt_mmcsd_card *card, rt_int32_t rw, rt_uint32_t fn, rt_uint32_t addr, rt_int32_t op_code, rt_uint8_t *buf, rt_uint32_t blocks, rt_uint32_t blksize) { struct rt_mmcsd_req req; struct rt_mmcsd_cmd cmd; struct rt_mmcsd_data data; RT_ASSERT(card != RT_NULL); RT_ASSERT(fn <= SDIO_MAX_FUNCTIONS); RT_ASSERT(blocks != 1 || blksize <= 512); RT_ASSERT(blocks != 0); RT_ASSERT(blksize != 0); if (addr & ~<API key>) return -RT_ERROR; rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); rt_memset(&data, 0, sizeof(struct rt_mmcsd_data)); req.cmd = &cmd; req.data = &data; cmd.cmd_code = SD_IO_RW_EXTENDED; cmd.arg = rw ? <API key> : SDIO_ARG_CMD53_READ; cmd.arg |= fn << <API key>; cmd.arg |= op_code ? <API key> : 0x00000000; cmd.arg |= addr << <API key>; if (blocks == 1 && blksize <= 512) cmd.arg |= (blksize == 512) ? 0 : blksize; /* byte mode */ else cmd.arg |= <API key> | blocks; /* block mode */ cmd.flags = RESP_SPI_R5 | RESP_R5 | CMD_ADTC; data.blksize = blksize; data.blks = blocks; data.flags = rw ? DATA_DIR_WRITE : DATA_DIR_READ; data.buf = (rt_uint32_t *)buf; <API key>(&data, card); mmcsd_send_request(card->host, &req); if (cmd.err) return cmd.err; if (data.err) return data.err; if (!controller_is_spi(card->host)) { if (cmd.resp[0] & R5_ERROR) return -RT_EIO; if (cmd.resp[0] & R5_FUNCTION_NUMBER) return -RT_ERROR; if (cmd.resp[0] & R5_OUT_OF_RANGE) return -RT_ERROR; } return 0; } rt_inline rt_uint32_t sdio_max_block_size(struct rt_sdio_function *func) { rt_uint32_t size = MIN(func->card->host->max_seg_size, func->card->host->max_blk_size); size = MIN(size, func->max_blk_size); return MIN(size, 512u); /* maximum size for byte mode */ } static rt_int32_t <API key>(struct rt_sdio_function *func, rt_int32_t rw, rt_uint32_t addr, rt_int32_t op_code, rt_uint8_t *buf, rt_uint32_t len) { rt_int32_t ret; rt_uint32_t left_size; rt_uint32_t max_blks, blks; left_size = len; /* Do the bulk of the transfer using block mode (if supported). */ if (func->card->cccr.multi_block && (len > sdio_max_block_size(func))) { max_blks = MIN(func->card->host->max_blk_count, func->card->host->max_seg_size / func->cur_blk_size); max_blks = MIN(max_blks, 511u); while (left_size > func->cur_blk_size) { blks = left_size / func->cur_blk_size; if (blks > max_blks) blks = max_blks; len = blks * func->cur_blk_size; ret = sdio_io_rw_extended(func->card, rw, func->num, addr, op_code, buf, blks, func->cur_blk_size); if (ret) return ret; left_size -= len; buf += len; if (op_code) addr += len; } } while (left_size > 0) { len = MIN(left_size, sdio_max_block_size(func)); ret = sdio_io_rw_extended(func->card, rw, func->num, addr, op_code, buf, 1, len); if (ret) return ret; left_size -= len; buf += len; if (op_code) addr += len; } return 0; } rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, rt_uint32_t reg, rt_int32_t *err) { rt_uint8_t data; rt_int32_t ret; ret = sdio_io_rw_direct(func->card, 0, func->num, reg, &data, 0); if (err) { *err = ret; } return data; } rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, rt_uint32_t reg, rt_uint8_t data) { return sdio_io_rw_direct(func->card, 1, func->num, reg, &data, 0); } rt_uint16_t sdio_io_readw(struct rt_sdio_function *func, rt_uint32_t addr, rt_int32_t *err) { rt_int32_t ret; rt_uint32_t dmabuf; if (err) *err = 0; ret = <API key>(func, 0, addr, 1, (rt_uint8_t *)&dmabuf, 2); if (ret) { if (err) *err = ret; } return (rt_uint16_t)dmabuf; } rt_int32_t sdio_io_writew(struct rt_sdio_function *func, rt_uint16_t data, rt_uint32_t addr) { rt_uint32_t dmabuf = data; return <API key>(func, 1, addr, 1, (rt_uint8_t *)&dmabuf, 2); } rt_uint32_t sdio_io_readl(struct rt_sdio_function *func, rt_uint32_t addr, rt_int32_t *err) { rt_int32_t ret; rt_uint32_t dmabuf; if (err) *err = 0; ret = <API key>(func, 0, addr, 1, (rt_uint8_t *)&dmabuf, 4); if (ret) { if (err) *err = ret; } return dmabuf; } rt_int32_t sdio_io_writel(struct rt_sdio_function *func, rt_uint32_t data, rt_uint32_t addr) { rt_uint32_t dmabuf = data; return <API key>(func, 1, addr, 1, (rt_uint8_t *)&dmabuf, 4); } rt_int32_t <API key>(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) { return <API key>(func, 0, addr, 0, buf, len); } rt_int32_t <API key>(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) { return <API key>(func, 1, addr, 0, buf, len); } rt_int32_t <API key>(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) { return <API key>(func, 0, addr, 1, buf, len); } rt_int32_t <API key>(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) { return <API key>(func, 1, addr, 1, buf, len); } static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card) { rt_int32_t ret; rt_int32_t cccr_version; rt_uint8_t data; rt_memset(&card->cccr, 0, sizeof(struct rt_sdio_cccr)); data = sdio_io_readb(card->sdio_function[0], <API key>, &ret); if (ret) goto out; cccr_version = data & 0x0f; if (cccr_version > SDIO_CCCR_REV_1_20) { rt_kprintf("unrecognised CCCR structure version %d\n", cccr_version); return -RT_ERROR; } card->cccr.sdio_version = (data & 0xf0) >> 4; data = sdio_io_readb(card->sdio_function[0], <API key>, &ret); if (ret) goto out; if (data & SDIO_CCCR_CAP_SMB) card->cccr.multi_block = 1; if (data & SDIO_CCCR_CAP_LSC) card->cccr.low_speed = 1; if (data & SDIO_CCCR_CAP_4BLS) card->cccr.low_speed_4 = 1; if (data & SDIO_CCCR_CAP_4BLS) card->cccr.bus_width = 1; if (cccr_version >= SDIO_CCCR_REV_1_10) { data = sdio_io_readb(card->sdio_function[0], <API key>, &ret); if (ret) goto out; if (data & SDIO_POWER_SMPC) card->cccr.power_ctrl = 1; } if (cccr_version >= SDIO_CCCR_REV_1_20) { data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_SPEED, &ret); if (ret) goto out; if (data & SDIO_SPEED_SHS) card->cccr.high_speed = 1; } out: return ret; } static rt_int32_t cistpl_funce_func0(struct rt_mmcsd_card *card, const rt_uint8_t *buf, rt_uint32_t size) { if (size < 0x04 || buf[0] != 0) return -RT_ERROR; /* TPLFE_FN0_BLK_SIZE */ card->cis.func0_blk_size = buf[1] | (buf[2] << 8); /* <API key> */ card->cis.max_tran_speed = speed_value[(buf[3] >> 3) & 15] * speed_unit[buf[3] & 7]; return 0; } static rt_int32_t cistpl_funce_func(struct rt_sdio_function *func, const rt_uint8_t *buf, rt_uint32_t size) { rt_uint32_t version; rt_uint32_t min_size; version = func->card->cccr.sdio_version; min_size = (version == SDIO_SDIO_REV_1_00) ? 28 : 42; if (size < min_size || buf[0] != 1) return -RT_ERROR; /* TPLFE_MAX_BLK_SIZE */ func->max_blk_size = buf[12] | (buf[13] << 8); /* <API key>, present in ver 1.1 and above */ if (version > SDIO_SDIO_REV_1_00) func->enable_timeout_val = (buf[28] | (buf[29] << 8)) * 10; else func->enable_timeout_val = 1000; /* 1000ms */ return 0; } static rt_int32_t sdio_read_cis(struct rt_sdio_function *func) { rt_int32_t ret; struct <API key> *curr, **prev; rt_uint32_t i, cisptr = 0; rt_uint8_t data; rt_uint8_t tpl_code, tpl_link; struct rt_mmcsd_card *card = func->card; struct rt_sdio_function *func0 = card->sdio_function[0]; RT_ASSERT(func0 != RT_NULL); for (i = 0; i < 3; i++) { data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_CIS + i, &ret); if (ret) return ret; cisptr |= data << (i * 8); } prev = &func->tuples; do { tpl_code = sdio_io_readb(func0, cisptr++, &ret); if (ret) break; tpl_link = sdio_io_readb(func0, cisptr++, &ret); if (ret) break; if ((tpl_code == CISTPL_END) || (tpl_link == 0xff)) break; if (tpl_code == CISTPL_NULL) continue; curr = rt_malloc(sizeof(struct <API key>) + tpl_link); if (!curr) return -RT_ENOMEM; curr->data = (rt_uint8_t *)curr + sizeof(struct <API key>); for (i = 0; i < tpl_link; i++) { curr->data[i] = sdio_io_readb(func0, cisptr + i, &ret); if (ret) break; } if (ret) { rt_free(curr); break; } switch (tpl_code) { case CISTPL_MANFID: if (tpl_link < 4) { rt_kprintf("bad CISTPL_MANFID length\n"); break; } if (func->num != 0) { func->manufacturer = curr->data[0]; func->manufacturer |= curr->data[1] << 8; func->product = curr->data[2]; func->product |= curr->data[3] << 8; } else { card->cis.manufacturer = curr->data[0]; card->cis.manufacturer |= curr->data[1] << 8; card->cis.product = curr->data[2]; card->cis.product |= curr->data[3] << 8; } break; case CISTPL_FUNCE: if (func->num != 0) ret = cistpl_funce_func(func, curr->data, tpl_link); else ret = cistpl_funce_func0(card, curr->data, tpl_link); if (ret) { rt_kprintf("bad CISTPL_FUNCE size %u " "type %u\n", tpl_link, curr->data[0]); } break; case CISTPL_VERS_1: if (tpl_link < 2) { rt_kprintf("CISTPL_VERS_1 too short\n"); } break; default: /* this tuple is unknown to the core */ curr->next = RT_NULL; curr->code = tpl_code; curr->size = tpl_link; *prev = curr; prev = &curr->next; rt_kprintf( "function %d, CIS tuple code %#x, length %d\n", func->num, tpl_code, tpl_link); break; } cisptr += tpl_link; } while (1); /* * Link in all unknown tuples found in the common CIS so that * drivers don't have to go digging in two places. */ if (func->num != 0) *prev = func0->tuples; return ret; } void sdio_free_cis(struct rt_sdio_function *func) { struct <API key> *tuple, *tmp; struct rt_mmcsd_card *card = func->card; tuple = func->tuples; while (tuple && ((tuple != card->sdio_function[0]->tuples) || (!func->num))) { tmp = tuple; tuple = tuple->next; rt_free(tmp); } func->tuples = RT_NULL; } static rt_int32_t sdio_read_fbr(struct rt_sdio_function *func) { rt_int32_t ret; rt_uint8_t data; struct rt_sdio_function *func0 = func->card->sdio_function[0]; data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + <API key>, &ret); if (ret) goto err; data &= 0x0f; if (data == 0x0f) { data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + <API key>, &ret); if (ret) goto err; } func->func_code = data; err: return ret; } static rt_int32_t <API key>(struct rt_mmcsd_card *card, rt_uint32_t func_num) { rt_int32_t ret; struct rt_sdio_function *func; RT_ASSERT(func_num <= SDIO_MAX_FUNCTIONS); func = rt_malloc(sizeof(struct rt_sdio_function)); if (!func) { rt_kprintf("malloc rt_sdio_function failed\n"); ret = -RT_ENOMEM; goto err; } rt_memset(func, 0, sizeof(struct rt_sdio_function)); func->card = card; func->num = func_num; ret = sdio_read_fbr(func); if (ret) goto err1; ret = sdio_read_cis(func); if (ret) goto err1; card->sdio_function[func_num] = func; return 0; err1: sdio_free_cis(func); rt_free(func); card->sdio_function[func_num] = RT_NULL; err: return ret; } static rt_int32_t sdio_set_highspeed(struct rt_mmcsd_card *card) { rt_int32_t ret; rt_uint8_t speed; if (!(card->host->flags & MMCSD_SUP_HIGHSPEED)) return 0; if (!card->cccr.high_speed) return 0; speed = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_SPEED, &ret); if (ret) return ret; speed |= SDIO_SPEED_EHS; ret = sdio_io_writeb(card->sdio_function[0], SDIO_REG_CCCR_SPEED, speed); if (ret) return ret; card->flags |= CARD_FLAG_HIGHSPEED; return 0; } static rt_int32_t sdio_set_bus_wide(struct rt_mmcsd_card *card) { rt_int32_t ret; rt_uint8_t busif; if (!(card->host->flags & MMCSD_BUSWIDTH_4)) return 0; if (card->cccr.low_speed && !card->cccr.bus_width) return 0; busif = sdio_io_readb(card->sdio_function[0], <API key>, &ret); if (ret) return ret; busif |= SDIO_BUS_WIDTH_4BIT; ret = sdio_io_writeb(card->sdio_function[0], <API key>, busif); if (ret) return ret; mmcsd_set_bus_width(card->host, MMCSD_BUS_WIDTH_4); return 0; } static rt_int32_t sdio_register_card(struct rt_mmcsd_card *card) { struct sdio_card *sc; struct sdio_driver *sd; rt_list_t *l; sc = rt_malloc(sizeof(struct sdio_card)); if (sc == RT_NULL) { rt_kprintf("malloc sdio card failed\n"); return -RT_ENOMEM; } sc->card = card; <API key>(&sdio_cards, &sc->list); if (rt_list_isempty(&sdio_drivers)) { goto out; } for (l = (&sdio_drivers)->next; l != &sdio_drivers; l = l->next) { sd = (struct sdio_driver *)rt_list_entry(l, struct sdio_driver, list); if (sdio_match_card(card, sd->drv->id)) { sd->drv->probe(card); } } out: return 0; } static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) { rt_int32_t err = 0; rt_int32_t i, function_num; rt_uint32_t cmd5_resp; struct rt_mmcsd_card *card; err = <API key>(host, ocr, &cmd5_resp); if (err) goto err; if (controller_is_spi(host)) { err = mmcsd_spi_use_crc(host, host->spi_use_crc); if (err) goto err; } function_num = (cmd5_resp & 0x70000000) >> 28; card = rt_malloc(sizeof(struct rt_mmcsd_card)); if (!card) { rt_kprintf("malloc card failed\n"); err = -RT_ENOMEM; goto err; } rt_memset(card, 0, sizeof(struct rt_mmcsd_card)); card->card_type = CARD_TYPE_SDIO; card->sdio_function_num = function_num; card->host = host; host->card = card; card->sdio_function[0] = rt_malloc(sizeof(struct rt_sdio_function)); if (!card->sdio_function[0]) { rt_kprintf("malloc sdio_func0 failed\n"); err = -RT_ENOMEM; goto err1; } rt_memset(card->sdio_function[0], 0, sizeof(struct rt_sdio_function)); card->sdio_function[0]->card = card; card->sdio_function[0]->num = 0; if (!controller_is_spi(host)) { err = mmcsd_get_card_addr(host, &card->rca); if (err) goto err2; mmcsd_set_bus_mode(host, <API key>); } if (!controller_is_spi(host)) { err = mmcsd_select_card(card); if (err) goto err2; } err = sdio_read_cccr(card); if (err) goto err2; err = sdio_read_cis(card->sdio_function[0]); if (err) goto err2; err = sdio_set_highspeed(card); if (err) goto err2; if (card->flags & CARD_FLAG_HIGHSPEED) { mmcsd_set_clock(host, 50000000); } else { mmcsd_set_clock(host, card->cis.max_tran_speed); } err = sdio_set_bus_wide(card); if (err) goto err2; for (i = 1; i < function_num + 1; i++) { err = <API key>(card, i); if (err) goto err3; } /* register sdio card */ err = sdio_register_card(card); if (err) { goto err3; } return 0; err3: if (host->card) { for (i = 1; i < host->card->sdio_function_num + 1; i++) { if (host->card->sdio_function[i]) { sdio_free_cis(host->card->sdio_function[i]); rt_free(host->card->sdio_function[i]); host->card->sdio_function[i] = RT_NULL; rt_free(host->card); host->card = RT_NULL; } } } err2: if (host->card && host->card->sdio_function[0]) { sdio_free_cis(host->card->sdio_function[0]); rt_free(host->card->sdio_function[0]); host->card->sdio_function[0] = RT_NULL; } err1: if (host->card) { rt_free(host->card); } err: rt_kprintf("error %d while initialising SDIO card\n", err); return err; } rt_int32_t init_sdio(struct rt_mmcsd_host *host, rt_uint32_t ocr) { rt_int32_t err; rt_uint32_t current_ocr; RT_ASSERT(host != RT_NULL); if (ocr & 0x7F) { rt_kprintf("Card ocr below the defined voltage rang.\n"); ocr &= ~0x7F; } if (ocr & VDD_165_195) { rt_kprintf("Can't support the low voltage SDIO card.\n"); ocr &= ~VDD_165_195; } current_ocr = <API key>(host, ocr); if (!current_ocr) { err = -RT_ERROR; goto err; } err = sdio_init_card(host, current_ocr); if (err) goto remove_card; return 0; remove_card: rt_free(host->card); host->card = RT_NULL; err: rt_kprintf("init SDIO card failed\n"); return err; } static void sdio_irq_thread(void *param) { rt_int32_t i, ret; rt_uint8_t pending; struct rt_mmcsd_card *card; struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)param; RT_ASSERT(host != RT_NULL); card = host->card; RT_ASSERT(card != RT_NULL); while (1) { if (rt_sem_take(host->sdio_irq_sem, RT_WAITING_FOREVER) == RT_EOK) { mmcsd_host_lock(host); pending = sdio_io_readb(host->card->sdio_function[0], <API key>, &ret); if (ret) { mmcsd_dbg("error %d reading <API key>\n", ret); goto out; } for (i = 1; i <= 7; i++) { if (pending & (1 << i)) { struct rt_sdio_function *func = card->sdio_function[i]; if (!func) { mmcsd_dbg("pending IRQ for " "non-existant function %d\n", func->num); goto out; } else if (func->irq_handler) { func->irq_handler(func); } else { mmcsd_dbg("pending IRQ with no register handler\n"); goto out; } } } out: mmcsd_host_unlock(host); if (host->flags & MMCSD_SUP_SDIO_IRQ) host->ops->enable_sdio_irq(host, 1); continue; } } } static rt_int32_t <API key>(struct rt_mmcsd_card *card) { struct rt_mmcsd_host *host = card->host; /* init semaphore and create sdio irq processing thread */ if (!host->sdio_irq_num) { host->sdio_irq_num++; host->sdio_irq_sem = rt_sem_create("sdio_irq", 0, RT_IPC_FLAG_FIFO); RT_ASSERT(host->sdio_irq_sem != RT_NULL); host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, RT_SDIO_STACK_SIZE, <API key>, 20); if (host->sdio_irq_thread != RT_NULL) { rt_thread_startup(host->sdio_irq_thread); } } return 0; } static rt_int32_t <API key>(struct rt_mmcsd_card *card) { struct rt_mmcsd_host *host = card->host; RT_ASSERT(host->sdio_irq_num > 0); host->sdio_irq_num if (!host->sdio_irq_num) { if (host->flags & MMCSD_SUP_SDIO_IRQ) host->ops->enable_sdio_irq(host, 0); rt_sem_delete(host->sdio_irq_sem); host->sdio_irq_sem = RT_NULL; rt_thread_delete(host->sdio_irq_thread); host->sdio_irq_thread = RT_NULL; } return 0; } rt_int32_t sdio_attach_irq(struct rt_sdio_function *func, <API key> *handler) { rt_int32_t ret; rt_uint8_t reg; struct rt_sdio_function *func0; RT_ASSERT(func != RT_NULL); RT_ASSERT(func->card != RT_NULL); func0 = func->card->sdio_function[0]; mmcsd_dbg("SDIO: enabling IRQ for function %d\n", func->num); if (func->irq_handler) { mmcsd_dbg("SDIO: IRQ for already in use.\n"); return -RT_EBUSY; } reg = sdio_io_readb(func0, <API key>, &ret); if (ret) return ret; reg |= 1 << func->num; reg |= 1; /* Master interrupt enable */ ret = sdio_io_writeb(func0, <API key>, reg); if (ret) return ret; func->irq_handler = handler; ret = <API key>(func->card); if (ret) func->irq_handler = RT_NULL; return ret; } rt_int32_t sdio_detach_irq(struct rt_sdio_function *func) { rt_int32_t ret; rt_uint8_t reg; struct rt_sdio_function *func0; RT_ASSERT(func != RT_NULL); RT_ASSERT(func->card != RT_NULL); func0 = func->card->sdio_function[0]; mmcsd_dbg("SDIO: disabling IRQ for function %d\n", func->num); if (func->irq_handler) { func->irq_handler = RT_NULL; <API key>(func->card); } reg = sdio_io_readb(func0, <API key>, &ret); if (ret) return ret; reg &= ~(1 << func->num); /* Disable master interrupt with the last function interrupt */ if (!(reg & 0xFE)) reg = 0; ret = sdio_io_writeb(func0, <API key>, reg); if (ret) return ret; return 0; } void sdio_irq_wakeup(struct rt_mmcsd_host *host) { host->ops->enable_sdio_irq(host, 0); rt_sem_release(host->sdio_irq_sem); } rt_int32_t sdio_enable_func(struct rt_sdio_function *func) { rt_int32_t ret; rt_uint8_t reg; rt_uint32_t timeout; struct rt_sdio_function *func0; RT_ASSERT(func != RT_NULL); RT_ASSERT(func->card != RT_NULL); func0 = func->card->sdio_function[0]; mmcsd_dbg("SDIO: enabling function %d\n", func->num); reg = sdio_io_readb(func0, SDIO_REG_CCCR_IO_EN, &ret); if (ret) goto err; reg |= 1 << func->num; ret = sdio_io_writeb(func0, SDIO_REG_CCCR_IO_EN, reg); if (ret) goto err; timeout = rt_tick_get() + func->enable_timeout_val * 1000 / RT_TICK_PER_SECOND; while (1) { reg = sdio_io_readb(func0, <API key>, &ret); if (ret) goto err; if (reg & (1 << func->num)) break; ret = -RT_ETIMEOUT; if (rt_tick_get() > timeout) goto err; } mmcsd_dbg("SDIO: enabled function successfull\n"); return 0; err: mmcsd_dbg("SDIO: failed to enable function %d\n", func->num); return ret; } rt_int32_t sdio_disable_func(struct rt_sdio_function *func) { rt_int32_t ret; rt_uint8_t reg; struct rt_sdio_function *func0; RT_ASSERT(func != RT_NULL); RT_ASSERT(func->card != RT_NULL); func0 = func->card->sdio_function[0]; mmcsd_dbg("SDIO: disabling function %d\n", func->num); reg = sdio_io_readb(func0, SDIO_REG_CCCR_IO_EN, &ret); if (ret) goto err; reg &= ~(1 << func->num); ret = sdio_io_writeb(func0, SDIO_REG_CCCR_IO_EN, reg); if (ret) goto err; mmcsd_dbg("SDIO: disabled function successfull\n"); return 0; err: mmcsd_dbg("SDIO: failed to disable function %d\n", func->num); return -RT_EIO; } rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, rt_uint32_t blksize) { rt_int32_t ret; struct rt_sdio_function *func0 = func->card->sdio_function[0]; if (blksize > func->card->host->max_blk_size) return -RT_ERROR; if (blksize == 0) { blksize = MIN(func->max_blk_size, func->card->host->max_blk_size); blksize = MIN(blksize, 512u); } ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + <API key>, blksize & 0xff); if (ret) return ret; ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + <API key> + 1, (blksize >> 8) & 0xff); if (ret) return ret; func->cur_blk_size = blksize; return 0; } rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card *card, const struct rt_sdio_device_id *id) { if ((id->manufacturer != SDIO_ANY_MAN_ID) && (id->manufacturer != card->cis.manufacturer)) return 0; if ((id->product != SDIO_ANY_PROD_ID) && (id->product != card->cis.product)) return 0; return 1; } static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id) { rt_list_t *l; struct sdio_card *sc; struct rt_mmcsd_card *card; for (l = (&sdio_cards)->next; l != &sdio_cards; l = l->next) { sc = (struct sdio_card *)rt_list_entry(l, struct sdio_card, list); card = sc->card; if (sdio_match_card(card, id)) { return card; } } return RT_NULL; } rt_int32_t <API key>(struct rt_sdio_driver *driver) { struct sdio_driver *sd; struct rt_mmcsd_card *card; sd = rt_malloc(sizeof(struct sdio_driver)); if (sd == RT_NULL) { rt_kprintf("malloc sdio driver failed\n"); return -RT_ENOMEM; } <API key>(&sdio_drivers, &sd->list); if (!rt_list_isempty(&sdio_cards)) { card = sdio_match_driver(driver->id); if (card != RT_NULL) { driver->probe(card); } } return 0; } rt_int32_t <API key>(struct rt_sdio_driver *driver) { rt_list_t *l; struct sdio_driver *sd = RT_NULL; struct rt_mmcsd_card *card; <API key>(&sdio_drivers, &sd->list); for (l = (&sdio_drivers)->next; l != &sdio_drivers; l = l->next) { sd = (struct sdio_driver *)rt_list_entry(l, struct sdio_driver, list); if (sd->drv != driver) { sd = RT_NULL; } } if (sd == RT_NULL) { rt_kprintf("SDIO driver %s not register\n", driver->name); return -RT_ERROR; } if (!rt_list_isempty(&sdio_cards)) { card = sdio_match_driver(driver->id); if (card != RT_NULL) { driver->remove(card); rt_list_remove(&sd->list); rt_free(sd); } } return 0; } void rt_sdio_init(void) { rt_list_init(&sdio_cards); rt_list_init(&sdio_drivers); }
#include "chrome/browser/extensions/api/location/location_api.h" #include "chrome/browser/extensions/api/location/location_manager.h" #include "chrome/common/extensions/api/location.h" #include "extensions/common/error_utils.h" // TODO(vadimt): add tests. namespace location = extensions::api::location; namespace WatchLocation = location::WatchLocation; namespace ClearWatch = location::ClearWatch; namespace extensions { const char kMustBePositive[] = "'*' must be 0 or greater."; const char <API key>[] = "minDistanceInMeters"; const char <API key>[] = "<API key>"; bool IsNegative(double* value) { return value && *value < 0.0; } bool <API key>::RunImpl() { scoped_ptr<WatchLocation::Params> params( WatchLocation::Params::Create(*args_)); <API key>(params.get()); double* <API key> = params->request_info.<API key>.get(); if (IsNegative(<API key>)) { error_ = ErrorUtils::FormatErrorMessage( kMustBePositive, <API key>); return false; } double* <API key> = params->request_info.<API key>.get(); if (IsNegative(<API key>)) { error_ = ErrorUtils::FormatErrorMessage( kMustBePositive, <API key>); return false; } // TODO(vadimt): validate and use params->request_info.maximumAge LocationManager::Get(GetProfile()) ->AddLocationRequest(extension_id(), params->name, <API key>, <API key>); return true; } bool <API key>::RunImpl() { scoped_ptr<ClearWatch::Params> params( ClearWatch::Params::Create(*args_)); <API key>(params.get()); LocationManager::Get(GetProfile()) -><API key>(extension_id(), params->name); return true; } } // namespace extensions
/* * This function is used through-out the kernel (including mm and fs) * to indicate a major problem. */ #include <linux/debug_locks.h> #include <linux/interrupt.h> #include <linux/kmsg_dump.h> #include <linux/kallsyms.h> #include <linux/notifier.h> #include <linux/module.h> #include <linux/random.h> #include <linux/reboot.h> #include <linux/delay.h> #include <linux/kexec.h> #include <linux/sched.h> #include <linux/sysrq.h> #include <linux/init.h> #include <linux/nmi.h> #include <linux/dmi.h> #include <asm/memory.h> #include <asm/cacheflush.h> #define PANIC_TIMER_STEP 100 #define PANIC_BLINK_SPD 18 /* Machine specific panic information string */ char *mach_panic_string; int panic_on_oops; static unsigned long tainted_mask; static int pause_on_oops; static int pause_on_oops_flag; static DEFINE_SPINLOCK(pause_on_oops_lock); #ifndef <API key> #define <API key> 0 #endif int panic_timeout = <API key>; EXPORT_SYMBOL_GPL(panic_timeout); <API key>(panic_notifier_list); EXPORT_SYMBOL(panic_notifier_list); static long no_blink(int state) { return 0; } /* Returns how long it waited in ms */ long (*panic_blink)(int state); EXPORT_SYMBOL(panic_blink); /* * Stop ourself in panic -- architecture code may override this */ void __weak panic_smp_self_stop(void) { while (1) cpu_relax(); } #ifdef CONFIG_ARCH_MSM #define __LOG_BUF_LEN (1 << <API key>) extern char __log_buf[]; void flush_log_buf(void *ignored) { dmac_clean_range(__log_buf, __log_buf + __LOG_BUF_LEN); } #endif /** * panic - halt the system * @fmt: The text string to print * * Display a message, then perform cleanups. * * This function never returns. */ void panic(const char *fmt, ...) { static DEFINE_SPINLOCK(panic_lock); static char buf[1024]; va_list args; long i, i_next = 0; int state = 0; #if defined(CONFIG_ARCH_MSM) && defined(CONFIG_OUTER_CACHE) unsigned long paddr; #endif /* * Disable local interrupts. This will prevent panic_smp_self_stop * from deadlocking the first cpu that invokes the panic, since * there is nothing to prevent an interrupt handler (that runs * after the panic_lock is acquired) from invoking panic again. */ local_irq_disable(); /* * It's possible to come here directly from a panic-assertion and * not have preempt disabled. Some functions called from here want * preempt to be disabled. No point enabling it later though... * * Only one CPU is allowed to execute the panic code from here. For * multiple parallel invocations of panic, all other CPUs either * stop themself or will wait until they are stopped by the 1st CPU * with smp_send_stop(). */ if (!spin_trylock(&panic_lock)) panic_smp_self_stop(); console_verbose(); bust_spinlocks(1); va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); #ifdef <API key> /* * Avoid nested stack-dumping if a panic occurs during oops processing */ if (!test_taint(TAINT_DIE) && oops_in_progress <= 1) dump_stack(); #endif #ifdef CONFIG_ARCH_MSM /* XXX: on_each_cpu "should" work in UP case, but the UP * version is wrapped with local_irq_disable/enable, * other than local_irq_save/restore. The previous will * corrupt the environment, so use "ifdef" here. */ #ifdef CONFIG_SMP on_each_cpu(flush_log_buf, NULL, 1); #else flush_log_buf(NULL); #endif #ifdef CONFIG_OUTER_CACHE paddr = (unsigned long)__virt_to_phys((unsigned long)__log_buf); outer_clean_range(paddr, paddr + __LOG_BUF_LEN); #endif #endif /* * If we have crashed and we have a crash kernel loaded let it handle * everything else. * Do we want to call this before we try to display a message? */ crash_kexec(NULL); kmsg_dump(KMSG_DUMP_PANIC); /* * Note smp_send_stop is the usual smp shutdown function, which * unfortunately means it may not be hardened to work in a panic * situation. */ smp_send_stop(); <API key>(&panic_notifier_list, 0, buf); bust_spinlocks(0); if (!panic_blink) panic_blink = no_blink; if (panic_timeout > 0) { /* * Delay timeout seconds before rebooting the machine. * We can't use the "normal" timers since we just panicked. */ printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout); for (i = 0; i < panic_timeout * 1000; i += PANIC_TIMER_STEP) { touch_nmi_watchdog(); if (i >= i_next) { i += panic_blink(state ^= 1); i_next = i + 3600 / PANIC_BLINK_SPD; } mdelay(PANIC_TIMER_STEP); } } if (panic_timeout != 0) { /* * This will not be a clean reboot, with everything * shutting down. But if there is a chance of * rebooting the system it will be rebooted. */ emergency_restart(); } #ifdef __sparc__ { extern int stop_a_enabled; /* Make sure the user can actually press Stop-A (L1-A) */ stop_a_enabled = 1; printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n"); } #endif #if defined(CONFIG_S390) { unsigned long caller; caller = (unsigned long)<API key>(0); disabled_wait(caller); } #endif local_irq_enable(); for (i = 0; ; i += PANIC_TIMER_STEP) { <API key>(); if (i >= i_next) { i += panic_blink(state ^= 1); i_next = i + 3600 / PANIC_BLINK_SPD; } mdelay(PANIC_TIMER_STEP); } } EXPORT_SYMBOL(panic); struct tnt { u8 bit; char true; char false; }; static const struct tnt tnts[] = { { <API key>, 'P', 'G' }, { TAINT_FORCED_MODULE, 'F', ' ' }, { TAINT_UNSAFE_SMP, 'S', ' ' }, { TAINT_FORCED_RMMOD, 'R', ' ' }, { TAINT_MACHINE_CHECK, 'M', ' ' }, { TAINT_BAD_PAGE, 'B', ' ' }, { TAINT_USER, 'U', ' ' }, { TAINT_DIE, 'D', ' ' }, { <API key>, 'A', ' ' }, { TAINT_WARN, 'W', ' ' }, { TAINT_CRAP, 'C', ' ' }, { <API key>, 'I', ' ' }, { TAINT_OOT_MODULE, 'O', ' ' }, }; const char *print_tainted(void) { static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1]; if (tainted_mask) { char *s; int i; s = buf + sprintf(buf, "Tainted: "); for (i = 0; i < ARRAY_SIZE(tnts); i++) { const struct tnt *t = &tnts[i]; *s++ = test_bit(t->bit, &tainted_mask) ? t->true : t->false; } *s = 0; } else snprintf(buf, sizeof(buf), "Not tainted"); return buf; } int test_taint(unsigned flag) { return test_bit(flag, &tainted_mask); } EXPORT_SYMBOL(test_taint); unsigned long get_taint(void) { return tainted_mask; } void add_taint(unsigned flag) { /* * Can't trust the integrity of the kernel anymore. * We don't call directly debug_locks_off() because the issue * is not necessarily serious enough to set oops_in_progress to 1 * Also we want to keep up lockdep for staging/out-of-tree * development and post-warning case. */ switch (flag) { case TAINT_CRAP: case TAINT_OOT_MODULE: case TAINT_WARN: case <API key>: break; default: if (__debug_locks_off()) printk(KERN_WARNING "Disabling lock debugging due to kernel taint\n"); } set_bit(flag, &tainted_mask); } EXPORT_SYMBOL(add_taint); static void spin_msec(int msecs) { int i; for (i = 0; i < msecs; i++) { touch_nmi_watchdog(); mdelay(1); } } /* * It just happens that oops_enter() and oops_exit() are identically * implemented... */ static void do_oops_enter_exit(void) { unsigned long flags; static int spin_counter; if (!pause_on_oops) return; spin_lock_irqsave(&pause_on_oops_lock, flags); if (pause_on_oops_flag == 0) { /* This CPU may now print the oops message */ pause_on_oops_flag = 1; } else { /* We need to stall this CPU */ if (!spin_counter) { /* This CPU gets to do the counting */ spin_counter = pause_on_oops; do { spin_unlock(&pause_on_oops_lock); spin_msec(MSEC_PER_SEC); spin_lock(&pause_on_oops_lock); } while (--spin_counter); pause_on_oops_flag = 0; } else { /* This CPU waits for a different one */ while (spin_counter) { spin_unlock(&pause_on_oops_lock); spin_msec(1); spin_lock(&pause_on_oops_lock); } } } <API key>(&pause_on_oops_lock, flags); } /* * Return true if the calling CPU is allowed to print oops-related info. * This is a bit racy.. */ int oops_may_print(void) { return pause_on_oops_flag == 0; } /* * Called when the architecture enters its oops handler, before it prints * anything. If this is the first CPU to oops, and it's oopsing the first * time then let it proceed. * * This is all enabled by the pause_on_oops kernel boot option. We do all * this to ensure that oopses don't scroll off the screen. It has the * side-effect of preventing later-oopsing CPUs from mucking up the display, * too. * * It turns out that the CPU which is allowed to print ends up pausing for * the right duration, whereas all the other CPUs pause for twice as long: * once in oops_enter(), once in oops_exit(). */ void oops_enter(void) { tracing_off(); /* can't trust the integrity of the kernel anymore: */ debug_locks_off(); do_oops_enter_exit(); } /* * 64-bit random ID for oopses: */ static u64 oops_id; static int init_oops_id(void) { if (!oops_id) get_random_bytes(&oops_id, sizeof(oops_id)); else oops_id++; return 0; } late_initcall(init_oops_id); void <API key>(void) { init_oops_id(); if (mach_panic_string) printk(KERN_WARNING "Board Information: %s\n", mach_panic_string); printk(KERN_WARNING " (unsigned long long)oops_id); } /* * Called when the architecture exits its oops handler, after printing * everything. */ void oops_exit(void) { do_oops_enter_exit(); <API key>(); kmsg_dump(KMSG_DUMP_OOPS); } #ifdef <API key> struct slowpath_args { const char *fmt; va_list args; }; static void <API key>(const char *file, int line, void *caller, unsigned taint, struct slowpath_args *args) { const char *board; #if defined(CONFIG_ARCH_MSM) && defined(CONFIG_OUTER_CACHE) unsigned long paddr; #endif printk(KERN_WARNING " printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller); board = dmi_get_system_info(DMI_PRODUCT_NAME); if (board) printk(KERN_WARNING "Hardware name: %s\n", board); if (args) vprintk(args->fmt, args->args); print_modules(); dump_stack(); <API key>(); add_taint(taint); #ifdef CONFIG_ARCH_MSM /* XXX: we can not flush it in every online CPU by calling * on_each_cpu here in case of the endless recursion, due * to WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled() \ * && !oops_in_progress && !<API key>) in * <API key>() function. */ flush_log_buf(NULL); #ifdef CONFIG_OUTER_CACHE paddr = (unsigned long)__virt_to_phys((unsigned long)__log_buf); outer_clean_range(paddr, paddr + __LOG_BUF_LEN); #endif #endif } void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...) { struct slowpath_args args; args.fmt = fmt; va_start(args.args, fmt); <API key>(file, line, <API key>(0), TAINT_WARN, &args); va_end(args.args); } EXPORT_SYMBOL(warn_slowpath_fmt); void <API key>(const char *file, int line, unsigned taint, const char *fmt, ...) { struct slowpath_args args; args.fmt = fmt; va_start(args.args, fmt); <API key>(file, line, <API key>(0), taint, &args); va_end(args.args); } EXPORT_SYMBOL(<API key>); void warn_slowpath_null(const char *file, int line) { <API key>(file, line, <API key>(0), TAINT_WARN, NULL); } EXPORT_SYMBOL(warn_slowpath_null); #endif #ifdef <API key> /* * Called when gcc's -fstack-protector feature is used, and * gcc detects corruption of the on-stack canary value */ void __stack_chk_fail(void) { panic("stack-protector: Kernel stack is corrupted in: %p\n", <API key>(0)); } EXPORT_SYMBOL(__stack_chk_fail); #endif core_param(panic, panic_timeout, int, 0644); core_param(pause_on_oops, pause_on_oops, int, 0644); static int __init oops_setup(char *s) { if (!s) return -EINVAL; if (!strcmp(s, "panic")) panic_on_oops = 1; return 0; } early_param("oops", oops_setup);
#include <linux/kernel.h> #include <linux/types.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/list.h> #include <linux/sched.h> #include <linux/init.h> #include <linux/device.h> #include <linux/serial_8250.h> #include <linux/io.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/irq.h> #include <asm/mach/time.h> #include <mach/hardware.h> #include <asm/hardware/iomd.h> #include <asm/irq.h> #include <asm/mach-types.h> unsigned int vram_size; static void cl7500_ack_irq_a(unsigned int irq) { unsigned int val, mask; mask = 1 << irq; val = iomd_readb(IOMD_IRQMASKA); iomd_writeb(val & ~mask, IOMD_IRQMASKA); iomd_writeb(mask, IOMD_IRQCLRA); } static void cl7500_mask_irq_a(unsigned int irq) { unsigned int val, mask; mask = 1 << irq; val = iomd_readb(IOMD_IRQMASKA); iomd_writeb(val & ~mask, IOMD_IRQMASKA); } static void cl7500_unmask_irq_a(unsigned int irq) { unsigned int val, mask; mask = 1 << irq; val = iomd_readb(IOMD_IRQMASKA); iomd_writeb(val | mask, IOMD_IRQMASKA); } static struct irq_chip clps7500_a_chip = { .ack = cl7500_ack_irq_a, .mask = cl7500_mask_irq_a, .unmask = cl7500_unmask_irq_a, }; static void cl7500_mask_irq_b(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKB); iomd_writeb(val & ~mask, IOMD_IRQMASKB); } static void cl7500_unmask_irq_b(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKB); iomd_writeb(val | mask, IOMD_IRQMASKB); } static struct irq_chip clps7500_b_chip = { .ack = cl7500_mask_irq_b, .mask = cl7500_mask_irq_b, .unmask = cl7500_unmask_irq_b, }; static void cl7500_mask_irq_c(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKC); iomd_writeb(val & ~mask, IOMD_IRQMASKC); } static void cl7500_unmask_irq_c(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKC); iomd_writeb(val | mask, IOMD_IRQMASKC); } static struct irq_chip clps7500_c_chip = { .ack = cl7500_mask_irq_c, .mask = cl7500_mask_irq_c, .unmask = cl7500_unmask_irq_c, }; static void cl7500_mask_irq_d(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKD); iomd_writeb(val & ~mask, IOMD_IRQMASKD); } static void cl7500_unmask_irq_d(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_IRQMASKD); iomd_writeb(val | mask, IOMD_IRQMASKD); } static struct irq_chip clps7500_d_chip = { .ack = cl7500_mask_irq_d, .mask = cl7500_mask_irq_d, .unmask = cl7500_unmask_irq_d, }; static void cl7500_mask_irq_dma(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_DMAMASK); iomd_writeb(val & ~mask, IOMD_DMAMASK); } static void <API key>(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_DMAMASK); iomd_writeb(val | mask, IOMD_DMAMASK); } static struct irq_chip clps7500_dma_chip = { .ack = cl7500_mask_irq_dma, .mask = cl7500_mask_irq_dma, .unmask = <API key>, }; static void cl7500_mask_irq_fiq(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_FIQMASK); iomd_writeb(val & ~mask, IOMD_FIQMASK); } static void <API key>(unsigned int irq) { unsigned int val, mask; mask = 1 << (irq & 7); val = iomd_readb(IOMD_FIQMASK); iomd_writeb(val | mask, IOMD_FIQMASK); } static struct irq_chip clps7500_fiq_chip = { .ack = cl7500_mask_irq_fiq, .mask = cl7500_mask_irq_fiq, .unmask = <API key>, }; static void cl7500_no_action(unsigned int irq) { } static struct irq_chip clps7500_no_chip = { .ack = cl7500_no_action, .mask = cl7500_no_action, .unmask = cl7500_no_action, }; static struct irqaction irq_isa = { .handler = no_action, .mask = CPU_MASK_NONE, .name = "isa", }; static void __init clps7500_init_irq(void) { unsigned int irq, flags; iomd_writeb(0, IOMD_IRQMASKA); iomd_writeb(0, IOMD_IRQMASKB); iomd_writeb(0, IOMD_FIQMASK); iomd_writeb(0, IOMD_DMAMASK); for (irq = 0; irq < NR_IRQS; irq++) { flags = IRQF_VALID; if (irq <= 6 || (irq >= 9 && irq <= 15) || (irq >= 48 && irq <= 55)) flags |= IRQF_PROBE; switch (irq) { case 0 ... 7: set_irq_chip(irq, &clps7500_a_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 8 ... 15: set_irq_chip(irq, &clps7500_b_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 16 ... 22: set_irq_chip(irq, &clps7500_dma_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 24 ... 31: set_irq_chip(irq, &clps7500_c_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 40 ... 47: set_irq_chip(irq, &clps7500_d_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 48 ... 55: set_irq_chip(irq, &clps7500_no_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; case 64 ... 72: set_irq_chip(irq, &clps7500_fiq_chip); set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, flags); break; } } setup_irq(IRQ_ISA, &irq_isa); } static struct map_desc cl7500_io_desc[] __initdata = { { /* IO space */ .virtual = (unsigned long)IO_BASE, .pfn = __phys_to_pfn(IO_START), .length = IO_SIZE, .type = MT_DEVICE }, { /* ISA space */ .virtual = ISA_BASE, .pfn = __phys_to_pfn(ISA_START), .length = ISA_SIZE, .type = MT_DEVICE }, { /* Flash */ .virtual = CLPS7500_FLASH_BASE, .pfn = __phys_to_pfn(<API key>), .length = CLPS7500_FLASH_SIZE, .type = MT_DEVICE }, { /* LED */ .virtual = LED_BASE, .pfn = __phys_to_pfn(LED_START), .length = LED_SIZE, .type = MT_DEVICE } }; static void __init clps7500_map_io(void) { iotable_init(cl7500_io_desc, ARRAY_SIZE(cl7500_io_desc)); } extern void ioctime_init(void); extern unsigned long <API key>(void); static irqreturn_t <API key>(int irq, void *dev_id) { timer_tick(); /* Why not using do_leds interface?? */ { /* Twinkle the lights. */ static int count, state = 0xff00; if (count state ^= 0x100; count = 25; *((volatile unsigned int *)LED_ADDRESS) = state; } } return IRQ_HANDLED; } static struct irqaction clps7500_timer_irq = { .name = "CLPS7500 Timer Tick", .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, .handler = <API key>, }; /* * Set up timer interrupt. */ static void __init clps7500_timer_init(void) { ioctime_init(); setup_irq(IRQ_TIMER, &clps7500_timer_irq); } static struct sys_timer clps7500_timer = { .init = clps7500_timer_init, .offset = <API key>, }; static struct <API key> <API key>[] = { { .mapbase = 0x03010fe0, .irq = 10, .uartclk = 1843200, .regshift = 2, .iotype = UPIO_MEM, .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST, }, { .mapbase = 0x03010be0, .irq = 0, .uartclk = 1843200, .regshift = 2, .iotype = UPIO_MEM, .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SKIP_TEST, }, { .iobase = ISASLOT_IO + 0x2e8, .irq = 41, .uartclk = 1843200, .regshift = 0, .iotype = UPIO_PORT, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, }, { .iobase = ISASLOT_IO + 0x3e8, .irq = 40, .uartclk = 1843200, .regshift = 0, .iotype = UPIO_PORT, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, }, { }, }; static struct platform_device serial_device = { .name = "serial8250", .id = <API key>, .dev = { .platform_data = <API key>, }, }; static void __init clps7500_init(void) { <API key>(&serial_device); } MACHINE_START(CLPS7500, "CL-PS7500") /* Maintainer: Philip Blundell */ .phys_io = 0x03000000, .io_pg_offst = ((0xe0000000) >> 18) & 0xfffc, .map_io = clps7500_map_io, .init_irq = clps7500_init_irq, .init_machine = clps7500_init, .timer = &clps7500_timer, MACHINE_END
package org.w3c.dom; public interface NamedNodeMap { /** * Retrieves a node specified by name. * @param name The <code>nodeName</code> of a node to retrieve. * @return A <code>Node</code> (of any type) with the specified * <code>nodeName</code>, or <code>null</code> if it does not identify * any node in this map. */ public Node getNamedItem(String name); /** * Adds a node using its <code>nodeName</code> attribute. If a node with * that name is already present in this map, it is replaced by the new * one. Replacing a node by itself has no effect. * <br>As the <code>nodeName</code> attribute is used to derive the name * which the node must be stored under, multiple nodes of certain types * (those that have a "special" string value) cannot be stored as the * names would clash. This is seen as preferable to allowing nodes to be * aliased. * @param arg A node to store in this map. The node will later be * accessible using the value of its <code>nodeName</code> attribute. * @return If the new <code>Node</code> replaces an existing node the * replaced <code>Node</code> is returned, otherwise <code>null</code> * is returned. * @exception DOMException * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a * different document than the one that created this map. * <br><API key>: Raised if this map is readonly. * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an * <code>Attr</code> that is already an attribute of another * <code>Element</code> object. The DOM user must explicitly clone * <code>Attr</code> nodes to re-use them in other elements. * <br><API key>: Raised if an attempt is made to add a node * doesn't belong in this NamedNodeMap. Examples would include trying * to insert something other than an Attr node into an Element's map * of attributes, or a non-Entity node into the DocumentType's map of * Entities. */ public Node setNamedItem(Node arg) throws DOMException; /** * Removes a node specified by name. When this map contains the attributes * attached to an element, if the removed attribute is known to have a * default value, an attribute immediately appears containing the * default value as well as the corresponding namespace URI, local name, * and prefix when applicable. * @param name The <code>nodeName</code> of the node to remove. * @return The node removed from this map if a node with such a name * exists. * @exception DOMException * NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in * this map. * <br><API key>: Raised if this map is readonly. */ public Node removeNamedItem(String name) throws DOMException; /** * Returns the <code>index</code>th item in the map. If <code>index</code> * is greater than or equal to the number of nodes in this map, this * returns <code>null</code>. * @param index Index into this map. * @return The node at the <code>index</code>th position in the map, or * <code>null</code> if that is not a valid index. */ public Node item(int index); /** * The number of nodes in this map. The range of valid child node indices * is <code>0</code> to <code>length-1</code> inclusive. */ public int getLength(); public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException; public Node setNamedItemNS(Node arg) throws DOMException; public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException; }
// <API key>: GPL-2.0 #include <inttypes.h> #include <stdio.h> #include <stdbool.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/perf_event.h> #include "util/evsel_fprintf.h" struct bit_names { int bit; const char *name; }; static void __p_bits(char *buf, size_t size, u64 value, struct bit_names *bits) { bool first_bit = true; int i = 0; do { if (value & bits[i].bit) { buf += scnprintf(buf, size, "%s%s", first_bit ? "" : "|", bits[i].name); first_bit = false; } } while (bits[++i].name != NULL); } static void __p_sample_type(char *buf, size_t size, u64 value) { #define bit_name(n) { PERF_SAMPLE_##n, #n } struct bit_names bits[] = { bit_name(IP), bit_name(TID), bit_name(TIME), bit_name(ADDR), bit_name(READ), bit_name(CALLCHAIN), bit_name(ID), bit_name(CPU), bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW), bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER), bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC), bit_name(WEIGHT), bit_name(PHYS_ADDR), { .name = NULL, } }; #undef bit_name __p_bits(buf, size, value, bits); } static void <API key>(char *buf, size_t size, u64 value) { #define bit_name(n) { PERF_SAMPLE_BRANCH_##n, #n } struct bit_names bits[] = { bit_name(USER), bit_name(KERNEL), bit_name(HV), bit_name(ANY), bit_name(ANY_CALL), bit_name(ANY_RETURN), bit_name(IND_CALL), bit_name(ABORT_TX), bit_name(IN_TX), bit_name(NO_TX), bit_name(COND), bit_name(CALL_STACK), bit_name(IND_JUMP), bit_name(CALL), bit_name(NO_FLAGS), bit_name(NO_CYCLES), { .name = NULL, } }; #undef bit_name __p_bits(buf, size, value, bits); } static void __p_read_format(char *buf, size_t size, u64 value) { #define bit_name(n) { PERF_FORMAT_##n, #n } struct bit_names bits[] = { bit_name(TOTAL_TIME_ENABLED), bit_name(TOTAL_TIME_RUNNING), bit_name(ID), bit_name(GROUP), { .name = NULL, } }; #undef bit_name __p_bits(buf, size, value, bits); } #define BUF_SIZE 1024 #define p_hex(val) snprintf(buf, BUF_SIZE, "%#"PRIx64, (uint64_t)(val)) #define p_unsigned(val) snprintf(buf, BUF_SIZE, "%"PRIu64, (uint64_t)(val)) #define p_signed(val) snprintf(buf, BUF_SIZE, "%"PRId64, (int64_t)(val)) #define p_sample_type(val) __p_sample_type(buf, BUF_SIZE, val) #define <API key>(val) <API key>(buf, BUF_SIZE, val) #define p_read_format(val) __p_read_format(buf, BUF_SIZE, val) #define PRINT_ATTRn(_n, _f, _p) \ do { \ if (attr->_f) { \ _p(attr->_f); \ ret += attr__fprintf(fp, _n, buf, priv);\ } \ } while (0) #define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p) int <API key>(FILE *fp, struct perf_event_attr *attr, attr__fprintf_f attr__fprintf, void *priv) { char buf[BUF_SIZE]; int ret = 0; PRINT_ATTRf(type, p_unsigned); PRINT_ATTRf(size, p_unsigned); PRINT_ATTRf(config, p_hex); PRINT_ATTRn("{ sample_period, sample_freq }", sample_period, p_unsigned); PRINT_ATTRf(sample_type, p_sample_type); PRINT_ATTRf(read_format, p_read_format); PRINT_ATTRf(disabled, p_unsigned); PRINT_ATTRf(inherit, p_unsigned); PRINT_ATTRf(pinned, p_unsigned); PRINT_ATTRf(exclusive, p_unsigned); PRINT_ATTRf(exclude_user, p_unsigned); PRINT_ATTRf(exclude_kernel, p_unsigned); PRINT_ATTRf(exclude_hv, p_unsigned); PRINT_ATTRf(exclude_idle, p_unsigned); PRINT_ATTRf(mmap, p_unsigned); PRINT_ATTRf(comm, p_unsigned); PRINT_ATTRf(freq, p_unsigned); PRINT_ATTRf(inherit_stat, p_unsigned); PRINT_ATTRf(enable_on_exec, p_unsigned); PRINT_ATTRf(task, p_unsigned); PRINT_ATTRf(watermark, p_unsigned); PRINT_ATTRf(precise_ip, p_unsigned); PRINT_ATTRf(mmap_data, p_unsigned); PRINT_ATTRf(sample_id_all, p_unsigned); PRINT_ATTRf(exclude_host, p_unsigned); PRINT_ATTRf(exclude_guest, p_unsigned); PRINT_ATTRf(<API key>, p_unsigned); PRINT_ATTRf(<API key>, p_unsigned); PRINT_ATTRf(mmap2, p_unsigned); PRINT_ATTRf(comm_exec, p_unsigned); PRINT_ATTRf(use_clockid, p_unsigned); PRINT_ATTRf(context_switch, p_unsigned); PRINT_ATTRf(write_backward, p_unsigned); PRINT_ATTRf(namespaces, p_unsigned); PRINT_ATTRf(ksymbol, p_unsigned); PRINT_ATTRf(bpf_event, p_unsigned); PRINT_ATTRf(aux_output, p_unsigned); PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned); PRINT_ATTRf(bp_type, p_unsigned); PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex); PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex); PRINT_ATTRf(branch_sample_type, <API key>); PRINT_ATTRf(sample_regs_user, p_hex); PRINT_ATTRf(sample_stack_user, p_unsigned); PRINT_ATTRf(clockid, p_signed); PRINT_ATTRf(sample_regs_intr, p_hex); PRINT_ATTRf(aux_watermark, p_unsigned); PRINT_ATTRf(sample_max_stack, p_unsigned); return ret; }
#ifndef _TIPC_NAME_TABLE_H #define _TIPC_NAME_TABLE_H struct tipc_subscription; struct tipc_plist; struct tipc_nlist; struct tipc_group; struct tipc_uaddr; /* * TIPC name types reserved for internal TIPC use (both current and planned) */ #define TIPC_ZM_SRV 3 /* zone master service name type */ #define TIPC_PUBL_SCOPE_NUM (TIPC_NODE_SCOPE + 1) #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ /** * struct publication - info about a published service address or range * @sr: service range represented by this publication * @sk: address of socket bound to this publication * @scope: scope of publication, TIPC_NODE_SCOPE or TIPC_CLUSTER_SCOPE * @key: publication key, unique across the cluster * @id: publication id * @binding_node: all publications from the same node which bound this one * - Remote publications: in node->publ_list; * Used by node/name distr to withdraw publications when node is lost * - Local/node scope publications: in name_table->node_scope list * - Local/cluster scope publications: in name_table->cluster_scope list * @binding_sock: all publications from the same socket which bound this one * Used by socket to withdraw publications when socket is unbound/released * @local_publ: list of identical publications made from this node * Used by closest_first and multicast receive lookup algorithms * @all_publ: all publications identical to this one, whatever node and scope * Used by round-robin lookup algorithm * @list: to form a list of publications in temporal order * @rcu: RCU callback head used for deferred freeing */ struct publication { struct tipc_service_range sr; struct tipc_socket_addr sk; u16 scope; u32 key; u32 id; struct list_head binding_node; struct list_head binding_sock; struct list_head local_publ; struct list_head all_publ; struct list_head list; struct rcu_head rcu; }; /** * struct name_table - table containing all existing port name publications * @services: name sequence hash lists * @node_scope: all local publications with node scope * - used by name_distr during re-init of name table * @cluster_scope: all local publications with cluster scope * - used by name_distr to send bulk updates to new nodes * - used by name_distr during re-init of name table * @cluster_scope_lock: lock for accessing @cluster_scope * @local_publ_count: number of publications issued by this node * @rc_dests: destination node counter * @snd_nxt: next sequence number to be used */ struct name_table { struct hlist_head services[TIPC_NAMETBL_SIZE]; struct list_head node_scope; struct list_head cluster_scope; rwlock_t cluster_scope_lock; u32 local_publ_count; u32 rc_dests; u32 snd_nxt; }; int <API key>(struct sk_buff *skb, struct netlink_callback *cb); bool <API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk); void <API key>(struct net *net, struct tipc_uaddr *ua, bool exact, struct list_head *dports); void <API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_nlist *nodes); bool <API key>(struct net *net, struct tipc_uaddr *ua, struct list_head *dsts, int *dstcnt, u32 exclude, bool mcast); void <API key>(struct net *net, struct tipc_group *grp, struct tipc_uaddr *ua); struct publication *<API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk, u32 key); void <API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk, u32 key); struct publication *<API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk, u32 key); struct publication *<API key>(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk, u32 key); bool <API key>(struct tipc_subscription *s); void <API key>(struct tipc_subscription *s); int tipc_nametbl_init(struct net *net); void tipc_nametbl_stop(struct net *net); struct tipc_dest { struct list_head list; u32 port; u32 node; }; struct tipc_dest *tipc_dest_find(struct list_head *l, u32 node, u32 port); bool tipc_dest_push(struct list_head *l, u32 node, u32 port); bool tipc_dest_pop(struct list_head *l, u32 *node, u32 *port); bool tipc_dest_del(struct list_head *l, u32 node, u32 port); void <API key>(struct list_head *l); int tipc_dest_list_len(struct list_head *l); #endif
#ifndef __STRUCT_H__ #define __STRUCT_H__ ////////////// Windows NT /////////////// #include <winternl.h> typedef struct _PEB_FREE_BLOCK // Size = 8 { struct _PEB_FREE_BLOCK *Next; ULONG Size; } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK; typedef void (*PPEBLOCKROUTINE)(PVOID); // PEB (Process Environment Block) data structure (FS:[0x30]) // Located at addr. 0x7FFDF000 typedef struct _PEB_NT // Size = 0x1E8 { BOOLEAN <API key>; //000 BOOLEAN <API key>; //001 BOOLEAN BeingDebugged; //002 BOOLEAN SpareBool; //003 Allocation size HANDLE Mutant; //004 HINSTANCE ImageBaseAddress; //008 Instance PPEB_LDR_DATA LdrData; //00C <API key> ProcessParameters; //010 ULONG SubSystemData; //014 HANDLE ProcessHeap; //018 KSPIN_LOCK FastPebLock; //01C PPEBLOCKROUTINE FastPebLockRoutine; //020 PPEBLOCKROUTINE <API key>; //024 ULONG <API key>; //028 PVOID * KernelCallbackTable; //02C PVOID EventLogSection; //030 PVOID EventLog; //034 PPEB_FREE_BLOCK FreeList; //038 ULONG TlsExpansionCounter; //03C ULONG TlsBitmap; //040 LARGE_INTEGER TlsBitmapBits; //044 PVOID <API key>; //04C PVOID <API key>; //050 PVOID * <API key>; //054 PVOID AnsiCodePageData; //058 PVOID OemCodePageData; //05C PVOID <API key>; //060 ULONG NumberOfProcessors; //064 LARGE_INTEGER NtGlobalFlag; //068 Address of a local copy LARGE_INTEGER <API key>; //070 ULONG HeapSegmentReserve; //078 ULONG HeapSegmentCommit; //07C ULONG <API key>; //080 ULONG <API key>; //084 ULONG NumberOfHeaps; //088 ULONG <API key>; //08C PVOID ** ProcessHeaps; //090 PVOID <API key>; //094 PVOID <API key>; //098 PVOID GdiDCAttributeList; //09C KSPIN_LOCK LoaderLock; //0A0 ULONG OSMajorVersion; //0A4 ULONG OSMinorVersion; //0A8 USHORT OSBuildNumber; //0AC USHORT OSCSDVersion; //0AE ULONG OSPlatformId; //0B0 ULONG ImageSubsystem; //0B4 ULONG <API key>; //0B8 ULONG <API key>; //0BC ULONG <API key>; //0C0 ULONG GdiHandleBuffer[0x22]; //0C4 ULONG <API key>; //14C ULONG TlsExpansionBitmap; //150 UCHAR <API key>[0x80]; //154 ULONG SessionId; //1D4 void * AppCompatInfo; //1D8 UNICODE_STRING CSDVersion; //1DC } PEB_NT, *PPEB_NT; #endif // __STRUCT_H__
#include "athena/content/public/<API key>.h" #include "chrome/browser/autocomplete/<API key>.h" #include "chrome/browser/profiles/profile.h" namespace athena { scoped_ptr<<API key>> <API key>( content::BrowserContext* context) { return scoped_ptr<<API key>>( new <API key>( Profile::FromBrowserContext(context))); } } // namespace athena
#include "nc4internal.h" #include "nc3dispatch.h" #ifdef IGNORE /* Keep a linked list of file info objects. */ extern NC_FILE_INFO_T *nc_file; #endif #ifdef IGNORE /* This function deletes a member of parliment. Be careful! Last time * this function was used, Labor got in! This function only does * anything for netcdf-3 files. */ int nc_delete(const char *path) { return NC3_delete_mp(path, 0); } int nc_delete_mp(const char *path, int basepe) { return NC3_delete_mp(path, basepe); } #endif /* This will return the length of a netcdf data type in bytes. Since we haven't added any new types, I just call the v3 function. Ed Hartnett 10/43/03 */ /* This function only does anything for netcdf-3 files. */ int NC4_set_base_pe(int ncid, int pe) { NC_FILE_INFO_T *nc; if (!(nc = nc4_find_nc_file(ncid))) return NC_EBADID; if (nc->nc4_info) return NC_ENOTNC3; return NC3_set_base_pe(nc->int_ncid, pe); } /* This function only does anything for netcdf-3 files. */ int NC4_inq_base_pe(int ncid, int *pe) { NC_FILE_INFO_T *nc; if (!(nc = nc4_find_nc_file(ncid))) return NC_EBADID; if (nc->nc4_info) return NC_ENOTNC3; return NC3_inq_base_pe(nc->int_ncid, pe); } /* Get the format (i.e. classic, 64-bit-offset, or netcdf-4) of an * open file. */ int NC4_inq_format(int ncid, int *formatp) { NC_FILE_INFO_T *nc; LOG((2, "nc_inq_format: ncid 0x%x", ncid)); if (!formatp) return NC_NOERR; /* Find the file metadata. */ if (!(nc = nc4_find_nc_file(ncid))) return NC_EBADID; /* If this isn't a netcdf-4 file, pass this call on to the netcdf-3 * library. */ if (!nc->nc4_info) return NC3_inq_format(nc->int_ncid, formatp); /* Otherwise, this is a netcdf-4 file. Check if classic NC3 rules * are in effect for this file. */ if (nc->nc4_info->cmode & NC_CLASSIC_MODEL) *formatp = <API key>; else *formatp = NC_FORMAT_NETCDF4; return NC_NOERR; }
var utf_encodings = ['utf-8', 'utf-16le', 'utf-16be']; var encodings_table = [ { "encodings": [ { "labels": [ "unicode-1-1-utf-8", "utf-8", "utf8" ], "name": "UTF-8" } ], "heading": "The Encoding" }, { "encodings": [ { "labels": [ "866", "cp866", "csibm866", "ibm866" ], "name": "IBM866" }, { "labels": [ "csisolatin2", "iso-8859-2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2" ], "name": "ISO-8859-2" }, { "labels": [ "csisolatin3", "iso-8859-3", "iso-ir-109", "iso8859-3", "iso88593", "iso_8859-3", "iso_8859-3:1988", "l3", "latin3" ], "name": "ISO-8859-3" }, { "labels": [ "csisolatin4", "iso-8859-4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4" ], "name": "ISO-8859-4" }, { "labels": [ "csisolatincyrillic", "cyrillic", "iso-8859-5", "iso-ir-144", "iso8859-5", "iso88595", "iso_8859-5", "iso_8859-5:1988" ], "name": "ISO-8859-5" }, { "labels": [ "arabic", "asmo-708", "csiso88596e", "csiso88596i", "csisolatinarabic", "ecma-114", "iso-8859-6", "iso-8859-6-e", "iso-8859-6-i", "iso-ir-127", "iso8859-6", "iso88596", "iso_8859-6", "iso_8859-6:1987" ], "name": "ISO-8859-6" }, { "labels": [ "csisolatingreek", "ecma-118", "elot_928", "greek", "greek8", "iso-8859-7", "iso-ir-126", "iso8859-7", "iso88597", "iso_8859-7", "iso_8859-7:1987", "sun_eu_greek" ], "name": "ISO-8859-7" }, { "labels": [ "csiso88598e", "csisolatinhebrew", "hebrew", "iso-8859-8", "iso-8859-8-e", "iso-ir-138", "iso8859-8", "iso88598", "iso_8859-8", "iso_8859-8:1988", "visual" ], "name": "ISO-8859-8" }, { "labels": [ "csiso88598i", "iso-8859-8-i", "logical" ], "name": "ISO-8859-8-I" }, { "labels": [ "csisolatin6", "iso-8859-10", "iso-ir-157", "iso8859-10", "iso885910", "l6", "latin6" ], "name": "ISO-8859-10" }, { "labels": [ "iso-8859-13", "iso8859-13", "iso885913" ], "name": "ISO-8859-13" }, { "labels": [ "iso-8859-14", "iso8859-14", "iso885914" ], "name": "ISO-8859-14" }, { "labels": [ "csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9" ], "name": "ISO-8859-15" }, { "labels": [ "iso-8859-16" ], "name": "ISO-8859-16" }, { "labels": [ "cskoi8r", "koi", "koi8", "koi8-r", "koi8_r" ], "name": "KOI8-R" }, { "labels": [ "koi8-ru", "koi8-u" ], "name": "KOI8-U" }, { "labels": [ "csmacintosh", "mac", "macintosh", "x-mac-roman" ], "name": "macintosh" }, { "labels": [ "dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874" ], "name": "windows-874" }, { "labels": [ "cp1250", "windows-1250", "x-cp1250" ], "name": "windows-1250" }, { "labels": [ "cp1251", "windows-1251", "x-cp1251" ], "name": "windows-1251" }, { "labels": [ "ansi_x3.4-1968", "ascii", "cp1252", "cp819", "csisolatin1", "ibm819", "iso-8859-1", "iso-ir-100", "iso8859-1", "iso88591", "iso_8859-1", "iso_8859-1:1987", "l1", "latin1", "us-ascii", "windows-1252", "x-cp1252" ], "name": "windows-1252" }, { "labels": [ "cp1253", "windows-1253", "x-cp1253" ], "name": "windows-1253" }, { "labels": [ "cp1254", "csisolatin5", "iso-8859-9", "iso-ir-148", "iso8859-9", "iso88599", "iso_8859-9", "iso_8859-9:1989", "l5", "latin5", "windows-1254", "x-cp1254" ], "name": "windows-1254" }, { "labels": [ "cp1255", "windows-1255", "x-cp1255" ], "name": "windows-1255" }, { "labels": [ "cp1256", "windows-1256", "x-cp1256" ], "name": "windows-1256" }, { "labels": [ "cp1257", "windows-1257", "x-cp1257" ], "name": "windows-1257" }, { "labels": [ "cp1258", "windows-1258", "x-cp1258" ], "name": "windows-1258" }, { "labels": [ "x-mac-cyrillic", "x-mac-ukrainian" ], "name": "x-mac-cyrillic" } ], "heading": "Legacy single-byte encodings" }, { "encodings": [ { "labels": [ "chinese", "csgb2312", "csiso58gb231280", "gb2312", "gb_2312", "gb_2312-80", "gbk", "iso-ir-58", "x-gbk" ], "name": "GBK" }, { "labels": [ "gb18030" ], "name": "gb18030" } ], "heading": "Legacy multi-byte Chinese (simplified) encodings" }, { "encodings": [ { "labels": [ "big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5" ], "name": "Big5" } ], "heading": "Legacy multi-byte Chinese (traditional) encodings" }, { "encodings": [ { "labels": [ "cseucpkdfmtjapanese", "euc-jp", "x-euc-jp" ], "name": "EUC-JP" }, { "labels": [ "csiso2022jp", "iso-2022-jp" ], "name": "ISO-2022-JP" }, { "labels": [ "csshiftjis", "ms932", "ms_kanji", "shift-jis", "shift_jis", "sjis", "windows-31j", "x-sjis" ], "name": "Shift_JIS" } ], "heading": "Legacy multi-byte Japanese encodings" }, { "encodings": [ { "labels": [ "cseuckr", "csksc56011987", "euc-kr", "iso-ir-149", "korean", "ks_c_5601-1987", "ks_c_5601-1989", "ksc5601", "ksc_5601", "windows-949" ], "name": "EUC-KR" } ], "heading": "Legacy multi-byte Korean encodings" }, { "encodings": [ { "labels": [ "csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr" ], "name": "replacement" }, { "labels": [ "utf-16be" ], "name": "UTF-16BE" }, { "labels": [ "utf-16", "utf-16le" ], "name": "UTF-16LE" }, { "labels": [ "x-user-defined" ], "name": "x-user-defined" } ], "heading": "Legacy miscellaneous encodings" } ] ;
# modification, are permitted provided that the following conditions are met: # and/or other materials provided with the distribution. # contributors may be used to endorse or promote products derived from this # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # 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. # Android CMake toolchain file, for use with the Android NDK r5-r10c # Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended). # Usage Linux: # $ export ANDROID_NDK=/absolute/path/to/the/android-ndk # $ mkdir build && cd build # $ cmake -<API key>=path/to/the/android.toolchain.cmake .. # $ make -j8 # Usage Linux (using standalone toolchain): # $ export <API key>=/absolute/path/to/android-toolchain # $ mkdir build && cd build # $ cmake -<API key>=path/to/the/android.toolchain.cmake .. # $ make -j8 # Usage Windows: # You need native port of make to build your project. # Android NDK r7 (and newer) already has make.exe on board. # For older NDK you have to install it separately. # $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk # $ mkdir build && cd build # $ cmake.exe -G"MinGW Makefiles" # -<API key>=path\to\the\android.toolchain.cmake # -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" .. # $ cmake.exe --build . # Options (can be set as cmake parameters: -D<option_name>=<value>): # ANDROID_NDK=/opt/android-ndk - path to the NDK root. # Can be set as environment variable. Can be set only at first cmake run. # <API key>=/opt/android-toolchain - path to the # standalone toolchain. This option is not used if full NDK is found # (ignored if ANDROID_NDK is set). # Can be set as environment variable. Can be set only at first cmake run. # ANDROID_ABI=armeabi-v7a - specifies the target Application Binary # Interface (ABI). This option nearly matches to the APP_ABI variable # used by ndk-build tool from Android NDK. # Possible targets are: # "armeabi" - ARMv5TE based CPU with software floating point operations # "armeabi-v7a" - ARMv7 based devices with hardware FPU instructions # this ABI target is used by default # "armeabi-v7a with NEON" - same as armeabi-v7a, but # sets NEON as floating-point unit # "armeabi-v7a with VFPV3" - same as armeabi-v7a, but # sets VFPV3 as floating-point unit (has 32 registers instead of 16) # "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP # "x86" - IA-32 instruction set # "mips" - MIPS32 instruction set # 64-bit ABIs for NDK r10 and newer: # "arm64-v8a" - ARMv8 AArch64 instruction set # "x86_64" - Intel64 instruction set (r1) # "mips64" - MIPS64 instruction set (r6) # <API key>=android-8 - level of Android API compile for. # Option is read-only when standalone toolchain is used. # Note: building for "android-L" requires explicit configuration. # <API key>=<API key>.9 - the name of compiler # toolchain to be used. The list of possible values depends on the NDK # version. For NDK r10c the possible values are: # * <API key>.9 # * <API key>.4 # * <API key>.5 # * <API key>.6 # * <API key>.8 # * <API key>.9 (default) # * <API key>.4 # * <API key>.5 # * <API key>.9 # * <API key>.4 # * <API key>.5 # * <API key>.6 # * <API key>.8 # * <API key>.9 # * <API key>.4 # * <API key>.5 # * x86-4.6 # * x86-4.8 # * x86-4.9 # * x86-clang3.4 # * x86-clang3.5 # * x86_64-4.9 # * x86_64-clang3.4 # * x86_64-clang3.5 # <API key>=OFF - set ON to generate 32-bit ARM instructions # instead of Thumb. Is not available for "x86" (inapplicable) and # "armeabi-v6 with VFP" (is forced to be ON) ABIs. # <API key>=ON - set ON to show all undefined symbols as linker # errors even if they are not used. # <API key>=OFF - set ON to allow undefined symbols in shared # libraries. Automatically turned for NDK r5x and r6x due to GLESv2 # problems. # <API key>=${CMAKE_SOURCE_DIR} - where to output binary # files. See additional details below. # <API key>=ON - if set, then toolchain defines some # obsolete variables which were used by previous versions of this file for # backward compatibility. # ANDROID_STL=gnustl_static - specify the runtime to use. # Possible values are: # none -> Do not configure the runtime. # system -> Use the default minimal system C++ runtime library. # Implies -fno-rtti -fno-exceptions. # Is not available for standalone toolchain. # system_re -> Use the default minimal system C++ runtime library. # Implies -frtti -fexceptions. # Is not available for standalone toolchain. # gabi++_static -> Use the GAbi++ runtime as a static library. # Implies -frtti -fno-exceptions. # Available for NDK r7 and newer. # Is not available for standalone toolchain. # gabi++_shared -> Use the GAbi++ runtime as a shared library. # Implies -frtti -fno-exceptions. # Available for NDK r7 and newer. # Is not available for standalone toolchain. # stlport_static -> Use the STLport runtime as a static library. # Implies -fno-rtti -fno-exceptions for NDK before r7. # Implies -frtti -fno-exceptions for NDK r7 and newer. # Is not available for standalone toolchain. # stlport_shared -> Use the STLport runtime as a shared library. # Implies -fno-rtti -fno-exceptions for NDK before r7. # Implies -frtti -fno-exceptions for NDK r7 and newer. # Is not available for standalone toolchain. # gnustl_static -> Use the GNU STL as a static library. # Implies -frtti -fexceptions. # gnustl_shared -> Use the GNU STL as a shared library. # Implies -frtti -fno-exceptions. # Available for NDK r7b and newer. # Silently degrades to gnustl_static if not available. # <API key>=ON - turn rtti and exceptions support based on # chosen runtime. If disabled, then the user is responsible for settings # these options. # What?: # android-cmake toolchain searches for NDK/toolchain in the following order: # ANDROID_NDK - cmake parameter # ANDROID_NDK - environment variable # <API key> - cmake parameter # <API key> - environment variable # ANDROID_NDK - default locations # <API key> - default locations # Make sure to do the following in your scripts: # SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" ) # SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" ) # The flags will be prepopulated with critical flags, so don't loose them. # Also be aware that toolchain also sets <API key> compiler # flags and linker flags. # ANDROID and BUILD_ANDROID will be set to true, you may test any of these # variables to make necessary Android-specific configuration changes. # Also ARMEABI or ARMEABI_V7A or X86 or MIPS or ARM64_V8A or X86_64 or MIPS64 # will be set true, mutually exclusive. NEON option will be set true # if VFP is set to NEON. # <API key> should be set in cache to determine where Android # libraries will be installed. # Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be # under the ${<API key>}/libs/${<API key>} # (depending on the target ABI). This is convenient for Android packaging. <API key>( VERSION 2.6.3 ) # Urho3D: on Windows Cygwin-based NDK tools may fail in the linking phase with too long command line. Turn on response files to avoid this if( CMAKE_HOST_WIN32 ) set( <API key> 1 ) set( <API key> 1 ) endif() if( DEFINED <API key> ) # subsequent toolchain loading is not really needed return() endif() if( <API key> ) # touch toolchain variable to suppress "unused variable" warning endif() # inherit settings in recursive loads get_property( <API key> GLOBAL PROPERTY IN_TRY_COMPILE ) if( <API key> ) include( "${<API key>}/../android.toolchain.config.cmake" OPTIONAL ) endif() # this one is important if( CMAKE_VERSION VERSION_GREATER "3.0.99" ) set( CMAKE_SYSTEM_NAME Android ) else() set( CMAKE_SYSTEM_NAME Linux ) endif() # this one not so much set( <API key> 1 ) # rpath makes low sence for Android set( <API key> "" ) set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) # NDK search paths set( <API key> ${<API key>} -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED <API key>) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" <API key> ) set( <API key> "${<API key>}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" ) else() file( TO_CMAKE_PATH "$ENV{HOME}" <API key> ) set( <API key> /opt/android-ndk "${<API key>}/NVPACK/android-ndk" ) endif() endif() if(NOT DEFINED <API key>) set( <API key> /opt/android-toolchain ) endif() # known ABIs set( <API key> "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" ) set( <API key> "arm64-v8a" ) set( <API key> "x86" ) set( <API key> "x86_64" ) set( <API key> "mips" ) set( <API key> "mips64" ) # API level defaults # Urho3D: default to API 12 set( <API key> 12 ) set( <API key> 21 ) set( <API key> 12) set( <API key> 21 ) set( <API key> 12 ) set( <API key> 21 ) macro( __LIST_FILTER listvar regex ) if( ${listvar} ) foreach( __val ${${listvar}} ) if( __val MATCHES "${regex}" ) list( REMOVE_ITEM ${listvar} "${__val}" ) endif() endforeach() endif() endmacro() macro( __INIT_VARIABLE var_name ) set( __test_path 0 ) foreach( __var ${ARGN} ) if( __var STREQUAL "PATH" ) set( __test_path 1 ) break() endif() endforeach() if( __test_path AND NOT EXISTS "${${var_name}}" ) unset( ${var_name} CACHE ) endif() if( "${${var_name}}" STREQUAL "" ) set( __values 0 ) foreach( __var ${ARGN} ) if( __var STREQUAL "VALUES" ) set( __values 1 ) elseif( NOT __var STREQUAL "PATH" ) set( __obsolete 0 ) if( __var MATCHES "^OBSOLETE_.*$" ) string( REPLACE "OBSOLETE_" "" __var "${__var}" ) set( __obsolete 1 ) endif() if( __var MATCHES "^ENV_.*$" ) string( REPLACE "ENV_" "" __var "${__var}" ) set( __value "$ENV{${__var}}" ) elseif( DEFINED ${__var} ) set( __value "${${__var}}" ) else() if( __values ) set( __value "${__var}" ) else() set( __value "" ) endif() endif() if( NOT "${__value}" STREQUAL "" ) if( __test_path ) if( EXISTS "${__value}" ) file( TO_CMAKE_PATH "${__value}" ${var_name} ) if( __obsolete AND NOT <API key> ) message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) endif() break() endif() else() set( ${var_name} "${__value}" ) if( __obsolete AND NOT <API key> ) message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." ) endif() break() endif() endif() endif() endforeach() unset( __value ) unset( __values ) unset( __obsolete ) elseif( __test_path ) file( TO_CMAKE_PATH "${${var_name}}" ${var_name} ) endif() unset( __test_path ) endmacro() macro( <API key> _var _path ) SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" ) FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" ) if( NOT __apiFileContent ) message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." ) endif() string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" ) unset( __apiFileContent ) unset( __ndkApiLevelRegex ) endmacro() macro( <API key> _var _root ) if( EXISTS "${_root}" )
package tests.javax_servlet_http.HttpServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.Cookie; import javax.servlet.ServletException; import java.io.IOException; import java.io.PrintWriter; /** * A Test for addCookie(Cookie) method */ public class <API key> extends HttpServlet { public void service ( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { PrintWriter out = response.getWriter(); //check for this in the client side response.addCookie( new Cookie( "BestLanguage", "Java" ) ); } }
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="shortcut icon" type="image/x-icon" href="../../../../favicon.ico" /> <title> <API key> | Guice </title> <link href="../../../../../javadoc/assets/<API key>.css" rel="stylesheet" type="text/css" /> <link href="../../../../../javadoc/assets/customizations.css" rel="stylesheet" type="text/css" /> <script src="../../../../../javadoc/assets/search_autocomplete.js" type="text/javascript"></script> <script src="../../../../../javadoc/assets/jquery-resizable.min.js" type="text/javascript"></script> <script src="../../../../../javadoc/assets/<API key>.js" type="text/javascript"></script> <script src="../../../../../javadoc/assets/prettify.js" type="text/javascript"></script> <script type="text/javascript"> setToRoot("../../../../", "../../../../../javadoc/assets/"); </script> <script src="../../../../../javadoc/assets/<API key>.js" type="text/javascript"></script> <script src="../../../../../javadoc/assets/navtree_data.js" type="text/javascript"></script> <script src="../../../../../javadoc/assets/customizations.js" type="text/javascript"></script> <noscript> <style type="text/css"> html,body{overflow:auto;} #body-content{position:relative; top:0;} #doc-content{overflow:visible;border-left:3px solid #666;} #side-nav{padding:0;} #side-nav .toggle-list ul {display:block;} #resize-packages-nav{border-bottom:3px solid #666;} </style> </noscript> </head> <body class="Guice_2.0"> <div id="header"> <div id="headerLeft"> <span id="masthead-title">Guice</span> </div> <div id="headerRight"> <div id="search" > <div id="searchForm"> <form accept-charset="utf-8" class="gsc-search-box" onsubmit="return submit_search()"> <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody> <tr> <td class="gsc-input"> <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off" title="search developer docs" name="q" value="search developer docs" onFocus="<API key>(this, true)" onBlur="<API key>(this, false)" onkeydown="return search_changed(event, true, '../../../../')" onkeyup="return search_changed(event, false, '../../../../')" /> <div id="search_filtered_div" class="no-display"> <table id="search_filtered" cellspacing=0> </table> </div> </td> <td class="gsc-search-button"> <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" /> </td> <td class="gsc-clear-button"> <div title="clear results" class="gsc-clear-button">&nbsp;</div> </td> </tr></tbody> </table> </form> </div><!-- searchForm --> </div><!-- search --> <div id="api-level-toggle"> <input type="checkbox" id="apiLevelCheckbox" onclick="<API key>(this)" /> <label for="apiLevelCheckbox" class="disabled">Filter by API Level: </label> <select id="apiLevelSelector"> <!-- option elements added by <API key>() --> </select> </div> <script> var SINCE_DATA = [ 'Guice_1.0', 'Guice_2.0', 'Guice_3.0' ]; var SINCE_LABELS = [ 'Guice_1.0', 'Guice_2.0', 'Guice_3.0' ]; <API key>(); addLoadEvent(changeApiLevel); </script> </div> </div><!-- header --> <div class="g-section g-tpl-240" id="body-content"> <div class="g-unit g-first side-nav-resizable" id="side-nav"> <div id="swapper"> <div id="nav-panels"> <div id="resize-packages-nav"> <div id="packages-nav"> <div id="index-links"><nobr> <a href="../../../../packages.html" >Package Index</a> | <a href="../../../../classes.html" >Class Index</a></nobr> </div> <ul> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/package-summary.html">com.google.inject</a></li> <li class="api apilevel-Guice_2.0"> <a href="../../../../com/google/inject/assistedinject/package-summary.html">com.google.inject.assistedinject</a></li> <li class="selected api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/binder/package-summary.html">com.google.inject.binder</a></li> <li class="api apilevel-Guice_3.0"> <a href="../../../../com/google/inject/grapher/package-summary.html">com.google.inject.grapher</a></li> <li class="api apilevel-Guice_3.0"> <a href="../../../../com/google/inject/grapher/graphviz/package-summary.html">com.google.inject.grapher.graphviz</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/jndi/package-summary.html">com.google.inject.jndi</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/matcher/package-summary.html">com.google.inject.matcher</a></li> <li class="api apilevel-Guice_2.0"> <a href="../../../../com/google/inject/multibindings/package-summary.html">com.google.inject.multibindings</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/name/package-summary.html">com.google.inject.name</a></li> <li class="api apilevel-Guice_3.0"> <a href="../../../../com/google/inject/persist/package-summary.html">com.google.inject.persist</a></li> <li class="api apilevel-Guice_3.0"> <a href="../../../../com/google/inject/persist/finder/package-summary.html">com.google.inject.persist.finder</a></li> <li class="api apilevel-Guice_3.0"> <a href="../../../../com/google/inject/persist/jpa/package-summary.html">com.google.inject.persist.jpa</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/servlet/package-summary.html">com.google.inject.servlet</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/spi/package-summary.html">com.google.inject.spi</a></li> <li class="api apilevel-Guice_2.0"> <a href="../../../../com/google/inject/spring/package-summary.html">com.google.inject.spring</a></li> <li class="api apilevel-Guice_2.0"> <a href="../../../../com/google/inject/throwingproviders/package-summary.html">com.google.inject.throwingproviders</a></li> <li class="api apilevel-Guice_1.0"> <a href="../../../../com/google/inject/tools/jmx/package-summary.html">com.google.inject.tools.jmx</a></li> <li class="api apilevel-Guice_2.0"> <a href="../../../../com/google/inject/util/package-summary.html">com.google.inject.util</a></li> </ul><br/> </div> <!-- end packages --> </div> <!-- end resize-packages --> <div id="classes-nav"> <ul> <li><h2>Interfaces</h2> <ul> <li class="api apilevel-Guice_1.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a>&lt;T&gt;</li> <li class="api apilevel-Guice_1.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a></li> <li class="selected api apilevel-Guice_2.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a></li> <li class="api apilevel-Guice_1.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a></li> <li class="api apilevel-Guice_1.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a>&lt;T&gt;</li> <li class="api apilevel-Guice_1.0"><a href="../../../../com/google/inject/binder/<API key>.html"><API key></a></li> </ul> </li> </ul><br/> </div><!-- end classes --> </div><!-- end nav-panels --> <div id="nav-tree" style="display:none"> <div id="index-links"><nobr> <a href="../../../../packages.html" >Package Index</a> | <a href="../../../../classes.html" >Class Index</a></nobr> </div> </div><!-- end nav-tree --> </div><!-- end swapper --> </div> <!-- end side-nav --> <script> if (!isMobile) { $("<a href='#' id='nav-swap' onclick='swapNav();return false;' style='font-size:10px;line-height:9px;margin-left:1em;text-decoration:none;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>").appendTo("#side-nav"); chooseDefaultNav(); if ($("#nav-tree").is(':visible')) { <API key>("../../../../"); } else { addLoadEvent(function() { scrollIntoView("packages-nav"); scrollIntoView("classes-nav"); }); } $("#swapper").css({borderBottom:"2px solid #aaa"}); } else { swapNav(); // tree view should be used on mobile } </script> <div class="g-unit" id="doc-content"> <div id="api-info-block"> <div class="sum-details-links"> </div><!-- end sum-details-links --> <div class="api-level"> Since: <a href="../../../../guide/appendix/api-levels.html#levelGuice_2.0">API Level Guice_2.0</a> </div> </div><!-- end api-info-block --> <div id="jd-header"> public interface <h1><API key></h1> </div><!-- end header --> <div id="naMessage"></div> <div id="jd-content" class="api apilevel-Guice_2.0"> <table class="<API key>"> <tr> <td colspan="1" class="<API key>">com.google.inject.binder.<API key></td> </tr> </table> <div class="jd-descr"> <h2>Class Overview</h2> <p>See the EDSL examples at <code><a href="../../../../com/google/inject/Binder.html">Binder</a></code>.</p> </div><!-- jd-descr --> <div class="jd-descr"> <h2>Summary</h2> <table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr> <tr class="alt-color api apilevel-Guice_2.0" > <td class="jd-typecol"><nobr> abstract void</nobr> </td> <td class="jd-linkcol" width="100%"><nobr> <span class="sympad"><a href="../../../../com/google/inject/binder/<API key>.html#annotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation>)">annotatedWith</a></span>(Class&lt;?&nbsp;extends&nbsp;Annotation&gt; annotationType)</nobr> <div class="jd-descrdiv">See the EDSL examples at <code><a href="../../../../com/google/inject/Binder.html">Binder</a></code>.</div> </td></tr> <tr class=" api apilevel-Guice_2.0" > <td class="jd-typecol"><nobr> abstract void</nobr> </td> <td class="jd-linkcol" width="100%"><nobr> <span class="sympad"><a href="../../../../com/google/inject/binder/<API key>.html#annotatedWith(java.lang.annotation.Annotation)">annotatedWith</a></span>(Annotation annotation)</nobr> <div class="jd-descrdiv">See the EDSL examples at <code><a href="../../../../com/google/inject/Binder.html">Binder</a></code>.</div> </td></tr> </table> </div><!-- jd-descr (summary) --> <!-- Details --> <!-- XML Attributes --> <!-- Enum Values --> <!-- Constants --> <!-- Fields --> <!-- Public ctors --> <!-- Protected ctors --> <!-- Public methdos --> <h2>Public Methods</h2> <A NAME="annotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation>)"></A> <div class="jd-details api apilevel-Guice_2.0"> <h4 class="jd-details-title"> <span class="normal"> public abstract void </span> <span class="sympad">annotatedWith</span> <span class="normal">(Class&lt;?&nbsp;extends&nbsp;Annotation&gt; annotationType)</span> </h4> <div class="api-level"> <div> Since: <a href="../../../../guide/appendix/api-levels.html#levelGuice_2.0">API Level Guice_2.0</a> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>See the EDSL examples at <code><a href="../../../../com/google/inject/Binder.html">Binder</a></code>. </p></div> </div> </div> <A NAME="annotatedWith(java.lang.annotation.Annotation)"></A> <div class="jd-details api apilevel-Guice_2.0"> <h4 class="jd-details-title"> <span class="normal"> public abstract void </span> <span class="sympad">annotatedWith</span> <span class="normal">(Annotation annotation)</span> </h4> <div class="api-level"> <div> Since: <a href="../../../../guide/appendix/api-levels.html#levelGuice_2.0">API Level Guice_2.0</a> </div> </div> <div class="jd-details-descr"> <div class="jd-tagdata jd-tagdescr"><p>See the EDSL examples at <code><a href="../../../../com/google/inject/Binder.html">Binder</a></code>. </p></div> </div> </div> <A NAME="navbar_top"></A> <div id="footer"> Generated by <a href="http://code.google.com/p/doclava/">Doclava</a>. </div> <!-- end footer --> </div> <!-- jd-content --> </div><!-- end doc-content --> </div> <!-- end body-content --> <script type="text/javascript"> init(); /* initialize <API key>.js */ </script> </body> </html>
// of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // all copies or substantial portions of the Software. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // Parser combinator framework! // This file declares several functions which construct parsers, usually taking other parsers as // input, thus making them parser combinators. // A valid parser is any functor which takes a reference to an input cursor (defined below) as its // input and returns a Maybe. The parser returns null on parse failure, or returns the parsed // result on success. // An "input cursor" is any type which implements the same interface as IteratorInput, below. Such // a type acts as a pointer to the current input location. When a parser returns successfully, it // will have updated the input cursor to point to the position just past the end of what was parsed. // On failure, the cursor position is unspecified. #ifndef KJ_PARSE_COMMON_H_ #define KJ_PARSE_COMMON_H_ #if defined(__GNUC__) && !KJ_HEADER_WARNINGS #pragma GCC system_header #endif #include "../common.h" #include "../memory.h" #include "../array.h" #include "../tuple.h" #include "../vector.h" namespace kj { namespace parse { template <typename Element, typename Iterator> class IteratorInput { // A parser input implementation based on an iterator range. public: IteratorInput(Iterator begin, Iterator end) : parent(nullptr), pos(begin), end(end), best(begin) {} explicit IteratorInput(IteratorInput& parent) : parent(&parent), pos(parent.pos), end(parent.end), best(parent.pos) {} ~IteratorInput() { if (parent != nullptr) { parent->best = kj::max(kj::max(pos, best), parent->best); } } KJ_DISALLOW_COPY(IteratorInput); void advanceParent() { parent->pos = pos; } void forgetParent() { parent = nullptr; } bool atEnd() { return pos == end; } auto current() -> decltype(*instance<Iterator>()) { KJ_IREQUIRE(!atEnd()); return *pos; } auto consume() -> decltype(*instance<Iterator>()) { KJ_IREQUIRE(!atEnd()); return *pos++; } void next() { KJ_IREQUIRE(!atEnd()); ++pos; } Iterator getBest() { return kj::max(pos, best); } Iterator getPosition() { return pos; } private: IteratorInput* parent; Iterator pos; Iterator end; Iterator best; // furthest we got with any sub-input }; template <typename T> struct OutputType_; template <typename T> struct OutputType_<Maybe<T>> { typedef T Type; }; template <typename Parser, typename Input> using OutputType = typename OutputType_<decltype(instance<Parser&>()(instance<Input&>()))>::Type; // Synonym for the output type of a parser, given the parser type and the input type. template <typename Input, typename Output> class ParserRef { // Acts as a reference to some other parser, with simplified type. The referenced parser // is polymorphic by virtual call rather than templates. For grammars of non-trivial size, // it is important to inject refs into the grammar here and there to prevent the parser types // from becoming ridiculous. Using too many of them can hurt performance, though. public: ParserRef(): parser(nullptr), wrapper(nullptr) {} ParserRef(const ParserRef&) = default; ParserRef(ParserRef&&) = default; ParserRef& operator=(const ParserRef& other) = default; ParserRef& operator=(ParserRef&& other) = default; template <typename Other> constexpr ParserRef(Other&& other) : parser(&other), wrapper(&WrapperImplInstance<Decay<Other>>::instance) { static_assert(kj::isReference<Other>(), "ParseRef should not be assigned to a temporary."); } template <typename Other> inline ParserRef& operator=(Other&& other) { static_assert(kj::isReference<Other>(), "ParseRef should not be assigned to a temporary."); parser = &other; wrapper = &WrapperImplInstance<Decay<Other>>::instance; return *this; } KJ_ALWAYS_INLINE(Maybe<Output> operator()(Input& input) const) { // Always inline in the hopes that this allows branch prediction to kick in so the virtual call // doesn't hurt so much. return wrapper->parse(parser, input); } private: struct Wrapper { virtual Maybe<Output> parse(const void* parser, Input& input) const = 0; }; template <typename ParserImpl> struct WrapperImpl: public Wrapper { Maybe<Output> parse(const void* parser, Input& input) const override { return (*reinterpret_cast<const ParserImpl*>(parser))(input); } }; template <typename ParserImpl> struct WrapperImplInstance { static constexpr WrapperImpl<ParserImpl> instance = WrapperImpl<ParserImpl>(); }; const void* parser; const Wrapper* wrapper; }; template <typename Input, typename Output> template <typename ParserImpl> constexpr ParserRef<Input, Output>::WrapperImpl<ParserImpl> ParserRef<Input, Output>::WrapperImplInstance<ParserImpl>::instance; template <typename Input, typename ParserImpl> constexpr ParserRef<Input, OutputType<ParserImpl, Input>> ref(ParserImpl& impl) { // Constructs a ParserRef. You must specify the input type explicitly, e.g. // `ref<MyInput>(myParser)`. return ParserRef<Input, OutputType<ParserImpl, Input>>(impl); } // any // Output = one token class Any_ { public: template <typename Input> Maybe<Decay<decltype(instance<Input>().consume())>> operator()(Input& input) const { if (input.atEnd()) { return nullptr; } else { return input.consume(); } } }; constexpr Any_ any = Any_(); // A parser which matches any token and simply returns it. // exactly() // Output = Tuple<> template <typename T> class Exactly_ { public: explicit constexpr Exactly_(T&& expected): expected(expected) {} template <typename Input> Maybe<Tuple<>> operator()(Input& input) const { if (input.atEnd() || input.current() != expected) { return nullptr; } else { input.next(); return Tuple<>(); } } private: T expected; }; template <typename T> constexpr Exactly_<T> exactly(T&& expected) { // Constructs a parser which succeeds when the input is exactly the token specified. The // result is always the empty tuple. return Exactly_<T>(kj::fwd<T>(expected)); } // exactlyConst() // Output = Tuple<> template <typename T, T expected> class ExactlyConst_ { public: explicit constexpr ExactlyConst_() {} template <typename Input> Maybe<Tuple<>> operator()(Input& input) const { if (input.atEnd() || input.current() != expected) { return nullptr; } else { input.next(); return Tuple<>(); } } }; template <typename T, T expected> constexpr ExactlyConst_<T, expected> exactlyConst() { // Constructs a parser which succeeds when the input is exactly the token specified. The // result is always the empty tuple. This parser is templated on the token value which may cause // it to perform better -- or worse. Be sure to measure. return ExactlyConst_<T, expected>(); } // constResult() template <typename SubParser, typename Result> class ConstResult_ { public: explicit constexpr ConstResult_(SubParser&& subParser, Result&& result) : subParser(kj::fwd<SubParser>(subParser)), result(kj::fwd<Result>(result)) {} template <typename Input> Maybe<Result> operator()(Input& input) const { if (subParser(input) == nullptr) { return nullptr; } else { return result; } } private: SubParser subParser; Result result; }; template <typename SubParser, typename Result> constexpr ConstResult_<SubParser, Result> constResult(SubParser&& subParser, Result&& result) { // Constructs a parser which returns exactly `result` if `subParser` is successful. return ConstResult_<SubParser, Result>(kj::fwd<SubParser>(subParser), kj::fwd<Result>(result)); } template <typename SubParser> constexpr ConstResult_<SubParser, Tuple<>> discard(SubParser&& subParser) { // Constructs a parser which wraps `subParser` but discards the result. return constResult(kj::fwd<SubParser>(subParser), Tuple<>()); } // sequence() // Output = Flattened Tuple of outputs of sub-parsers. template <typename... SubParsers> class Sequence_; template <typename FirstSubParser, typename... SubParsers> class Sequence_<FirstSubParser, SubParsers...> { public: template <typename T, typename... U> explicit constexpr Sequence_(T&& firstSubParser, U&&... rest) : first(kj::fwd<T>(firstSubParser)), rest(kj::fwd<U>(rest)...) {} template <typename Input> auto operator()(Input& input) const -> Maybe<decltype(tuple( instance<OutputType<FirstSubParser, Input>>(), instance<OutputType<SubParsers, Input>>()...))> { return parseNext(input); } template <typename Input, typename... InitialParams> auto parseNext(Input& input, InitialParams&&... initialParams) const -> Maybe<decltype(tuple( kj::fwd<InitialParams>(initialParams)..., instance<OutputType<FirstSubParser, Input>>(), instance<OutputType<SubParsers, Input>>()...))> { KJ_IF_MAYBE(firstResult, first(input)) { return rest.parseNext(input, kj::fwd<InitialParams>(initialParams)..., kj::mv(*firstResult)); } else { return nullptr; } } private: FirstSubParser first; Sequence_<SubParsers...> rest; }; template <> class Sequence_<> { public: template <typename Input> Maybe<Tuple<>> operator()(Input& input) const { return parseNext(input); } template <typename Input, typename... Params> auto parseNext(Input& input, Params&&... params) const -> Maybe<decltype(tuple(kj::fwd<Params>(params)...))> { return tuple(kj::fwd<Params>(params)...); } }; template <typename... SubParsers> constexpr Sequence_<SubParsers...> sequence(SubParsers&&... subParsers) { // Constructs a parser that executes each of the parameter parsers in sequence and returns a // tuple of their results. return Sequence_<SubParsers...>(kj::fwd<SubParsers>(subParsers)...); } // many() // Output = Array of output of sub-parser, or just a uint count if the sub-parser returns Tuple<>. template <typename SubParser, bool atLeastOne> class Many_ { template <typename Input, typename Output = OutputType<SubParser, Input>> struct Impl; public: explicit constexpr Many_(SubParser&& subParser) : subParser(kj::fwd<SubParser>(subParser)) {} template <typename Input> auto operator()(Input& input) const -> decltype(Impl<Input>::apply(instance<const SubParser&>(), input)); private: SubParser subParser; }; template <typename SubParser, bool atLeastOne> template <typename Input, typename Output> struct Many_<SubParser, atLeastOne>::Impl { static Maybe<Array<Output>> apply(const SubParser& subParser, Input& input) { typedef Vector<OutputType<SubParser, Input>> Results; Results results; while (!input.atEnd()) { Input subInput(input); KJ_IF_MAYBE(subResult, subParser(subInput)) { subInput.advanceParent(); results.add(kj::mv(*subResult)); } else { break; } } if (atLeastOne && results.empty()) { return nullptr; } return results.releaseAsArray(); } }; template <typename SubParser, bool atLeastOne> template <typename Input> struct Many_<SubParser, atLeastOne>::Impl<Input, Tuple<>> { // If the sub-parser output is Tuple<>, just return a count. static Maybe<uint> apply(const SubParser& subParser, Input& input) { uint count = 0; while (!input.atEnd()) { Input subInput(input); KJ_IF_MAYBE(subResult, subParser(subInput)) { subInput.advanceParent(); ++count; } else { break; } } if (atLeastOne && count == 0) { return nullptr; } return count; } }; template <typename SubParser, bool atLeastOne> template <typename Input> auto Many_<SubParser, atLeastOne>::operator()(Input& input) const -> decltype(Impl<Input>::apply(instance<const SubParser&>(), input)) { return Impl<Input, OutputType<SubParser, Input>>::apply(subParser, input); } template <typename SubParser> constexpr Many_<SubParser, false> many(SubParser&& subParser) { // Constructs a parser that repeatedly executes the given parser until it fails, returning an // Array of the results (or a uint count if `subParser` returns an empty tuple). return Many_<SubParser, false>(kj::fwd<SubParser>(subParser)); } template <typename SubParser> constexpr Many_<SubParser, true> oneOrMore(SubParser&& subParser) { // Like `many()` but the parser must parse at least one item to be successful. return Many_<SubParser, true>(kj::fwd<SubParser>(subParser)); } // times() // Output = Array of output of sub-parser, or Tuple<> if sub-parser returns Tuple<>. template <typename SubParser> class Times_ { template <typename Input, typename Output = OutputType<SubParser, Input>> struct Impl; public: explicit constexpr Times_(SubParser&& subParser, uint count) : subParser(kj::fwd<SubParser>(subParser)), count(count) {} template <typename Input> auto operator()(Input& input) const -> decltype(Impl<Input>::apply(instance<const SubParser&>(), instance<uint>(), input)); private: SubParser subParser; uint count; }; template <typename SubParser> template <typename Input, typename Output> struct Times_<SubParser>::Impl { static Maybe<Array<Output>> apply(const SubParser& subParser, uint count, Input& input) { auto results = heapArrayBuilder<OutputType<SubParser, Input>>(count); while (results.size() < count) { if (input.atEnd()) { return nullptr; } else KJ_IF_MAYBE(subResult, subParser(input)) { results.add(kj::mv(*subResult)); } else { return nullptr; } } return results.finish(); } }; template <typename SubParser> template <typename Input> struct Times_<SubParser>::Impl<Input, Tuple<>> { // If the sub-parser output is Tuple<>, just return a count. static Maybe<Tuple<>> apply(const SubParser& subParser, uint count, Input& input) { uint actualCount = 0; while (actualCount < count) { if (input.atEnd()) { return nullptr; } else KJ_IF_MAYBE(subResult, subParser(input)) { ++actualCount; } else { return nullptr; } } return tuple(); } }; template <typename SubParser> template <typename Input> auto Times_<SubParser>::operator()(Input& input) const -> decltype(Impl<Input>::apply(instance<const SubParser&>(), instance<uint>(), input)) { return Impl<Input, OutputType<SubParser, Input>>::apply(subParser, count, input); } template <typename SubParser> constexpr Times_<SubParser> times(SubParser&& subParser, uint count) { // Constructs a parser that repeats the subParser exactly `count` times. return Times_<SubParser>(kj::fwd<SubParser>(subParser), count); } // optional() // Output = Maybe<output of sub-parser> template <typename SubParser> class Optional_ { public: explicit constexpr Optional_(SubParser&& subParser) : subParser(kj::fwd<SubParser>(subParser)) {} template <typename Input> Maybe<Maybe<OutputType<SubParser, Input>>> operator()(Input& input) const { typedef Maybe<OutputType<SubParser, Input>> Result; Input subInput(input); KJ_IF_MAYBE(subResult, subParser(subInput)) { subInput.advanceParent(); return Result(kj::mv(*subResult)); } else { return Result(nullptr); } } private: SubParser subParser; }; template <typename SubParser> constexpr Optional_<SubParser> optional(SubParser&& subParser) { // Constructs a parser that accepts zero or one of the given sub-parser, returning a Maybe // of the sub-parser's result. return Optional_<SubParser>(kj::fwd<SubParser>(subParser)); } // oneOf() // All SubParsers must have same output type, which becomes the output type of the // OneOfParser. template <typename... SubParsers> class OneOf_; template <typename FirstSubParser, typename... SubParsers> class OneOf_<FirstSubParser, SubParsers...> { public: explicit constexpr OneOf_(FirstSubParser&& firstSubParser, SubParsers&&... rest) : first(kj::fwd<FirstSubParser>(firstSubParser)), rest(kj::fwd<SubParsers>(rest)...) {} template <typename Input> Maybe<OutputType<FirstSubParser, Input>> operator()(Input& input) const { { Input subInput(input); Maybe<OutputType<FirstSubParser, Input>> firstResult = first(subInput); if (firstResult != nullptr) { subInput.advanceParent(); return kj::mv(firstResult); } } // Hoping for some tail recursion here... return rest(input); } private: FirstSubParser first; OneOf_<SubParsers...> rest; }; template <> class OneOf_<> { public: template <typename Input> decltype(nullptr) operator()(Input& input) const { return nullptr; } }; template <typename... SubParsers> constexpr OneOf_<SubParsers...> oneOf(SubParsers&&... parsers) { // Constructs a parser that accepts one of a set of options. The parser behaves as the first // sub-parser in the list which returns successfully. All of the sub-parsers must return the // same type. return OneOf_<SubParsers...>(kj::fwd<SubParsers>(parsers)...); } // transform() // Output = Result of applying transform functor to input value. If input is a tuple, it is // unpacked to form the transformation parameters. template <typename Position> struct Span { public: inline const Position& begin() const { return begin_; } inline const Position& end() const { return end_; } Span() = default; inline constexpr Span(Position&& begin, Position&& end): begin_(mv(begin)), end_(mv(end)) {} private: Position begin_; Position end_; }; template <typename Position> constexpr Span<Decay<Position>> span(Position&& start, Position&& end) { return Span<Decay<Position>>(kj::fwd<Position>(start), kj::fwd<Position>(end)); } template <typename SubParser, typename TransformFunc> class Transform_ { public: explicit constexpr Transform_(SubParser&& subParser, TransformFunc&& transform) : subParser(kj::fwd<SubParser>(subParser)), transform(kj::fwd<TransformFunc>(transform)) {} template <typename Input> Maybe<decltype(kj::apply(instance<TransformFunc&>(), instance<OutputType<SubParser, Input>&&>()))> operator()(Input& input) const { KJ_IF_MAYBE(subResult, subParser(input)) { return kj::apply(transform, kj::mv(*subResult)); } else { return nullptr; } } private: SubParser subParser; TransformFunc transform; }; template <typename SubParser, typename TransformFunc> class TransformOrReject_ { public: explicit constexpr TransformOrReject_(SubParser&& subParser, TransformFunc&& transform) : subParser(kj::fwd<SubParser>(subParser)), transform(kj::fwd<TransformFunc>(transform)) {} template <typename Input> decltype(kj::apply(instance<TransformFunc&>(), instance<OutputType<SubParser, Input>&&>())) operator()(Input& input) const { KJ_IF_MAYBE(subResult, subParser(input)) { return kj::apply(transform, kj::mv(*subResult)); } else { return nullptr; } } private: SubParser subParser; TransformFunc transform; }; template <typename SubParser, typename TransformFunc> class <API key> { public: explicit constexpr <API key>(SubParser&& subParser, TransformFunc&& transform) : subParser(kj::fwd<SubParser>(subParser)), transform(kj::fwd<TransformFunc>(transform)) {} template <typename Input> Maybe<decltype(kj::apply(instance<TransformFunc&>(), instance<Span<Decay<decltype(instance<Input&>().getPosition())>>>(), instance<OutputType<SubParser, Input>&&>()))> operator()(Input& input) const { auto start = input.getPosition(); KJ_IF_MAYBE(subResult, subParser(input)) { return kj::apply(transform, Span<decltype(start)>(kj::mv(start), input.getPosition()), kj::mv(*subResult)); } else { return nullptr; } } private: SubParser subParser; TransformFunc transform; }; template <typename SubParser, typename TransformFunc> constexpr Transform_<SubParser, TransformFunc> transform( SubParser&& subParser, TransformFunc&& functor) { // Constructs a parser which executes some other parser and then transforms the result by invoking // `functor` on it. Typically `functor` is a lambda. It is invoked using `kj::apply`, // meaning tuples will be unpacked as arguments. return Transform_<SubParser, TransformFunc>( kj::fwd<SubParser>(subParser), kj::fwd<TransformFunc>(functor)); } template <typename SubParser, typename TransformFunc> constexpr TransformOrReject_<SubParser, TransformFunc> transformOrReject( SubParser&& subParser, TransformFunc&& functor) { // Like `transform()` except that `functor` returns a `Maybe`. If it returns null, parsing fails, // otherwise the parser's result is the content of the `Maybe`. return TransformOrReject_<SubParser, TransformFunc>( kj::fwd<SubParser>(subParser), kj::fwd<TransformFunc>(functor)); } template <typename SubParser, typename TransformFunc> constexpr <API key><SubParser, TransformFunc> <API key>( SubParser&& subParser, TransformFunc&& functor) { // Like `transform` except that `functor` also takes a `Span` as its first parameter specifying // the location of the parsed content. The span's position type is whatever the parser input's // getPosition() returns. return <API key><SubParser, TransformFunc>( kj::fwd<SubParser>(subParser), kj::fwd<TransformFunc>(functor)); } // notLookingAt() // Fails if the given parser succeeds at the current location. template <typename SubParser> class NotLookingAt_ { public: explicit constexpr NotLookingAt_(SubParser&& subParser) : subParser(kj::fwd<SubParser>(subParser)) {} template <typename Input> Maybe<Tuple<>> operator()(Input& input) const { Input subInput(input); subInput.forgetParent(); if (subParser(subInput) == nullptr) { return Tuple<>(); } else { return nullptr; } } private: SubParser subParser; }; template <typename SubParser> constexpr NotLookingAt_<SubParser> notLookingAt(SubParser&& subParser) { // Constructs a parser which fails at any position where the given parser succeeds. Otherwise, // it succeeds without consuming any input and returns an empty tuple. return NotLookingAt_<SubParser>(kj::fwd<SubParser>(subParser)); } // endOfInput() // Output = Tuple<>, only succeeds if at end-of-input class EndOfInput_ { public: template <typename Input> Maybe<Tuple<>> operator()(Input& input) const { if (input.atEnd()) { return Tuple<>(); } else { return nullptr; } } }; constexpr EndOfInput_ endOfInput = EndOfInput_(); // A parser that succeeds only if it is called with no input. } // namespace parse } // namespace kj #endif // KJ_PARSE_COMMON_H_